从数组创建 Mat 时,'cv::Mat' 和 'int' 类型不兼容
Types 'cv::Mat' and 'int' are not compatible when create a Mat from array
在有关Mat
的文档中,它展示了如何使用逗号分隔的初始值设定项创建Mat
,如下所示:
// create 3x3 double-precision identity matrix
Mat M = (Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
但是当我尝试时,它显示一个错误:
Types 'cv::Mat' and 'int' are not compatible
如何解决异常?
谢谢
你的代码没有问题
cv::Mat M = (cv::Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
我可以确认它适用于 gcc 5.4.0 和 OpenCV 3.1.0。应使用 Matx 创建固定大小的小矩阵:
typedef cv::Matx<double, 3, 3> Mat33d;
Mat33d m(1, 0, 0, 0, 1, 0, 0, 0, 1);
相关文章:
- 从数组创建 Mat 时,'cv::Mat' 和 'int' 类型不兼容
- 如何将 cv::mat 对象从 python 模块传递到 c++ 函数并返回返回的 cv::mat 类型为对象?
- 初始化cv :: mat ::具有int类型的定义大小的人
- Mat的convertTo函数在OpenCV中将灰度图像的类型转换为CV_32F时抱怨断言错误
- OpenCV:分配给类型为 int16_t 的 Mat 会给出所有零
- 如何使用avcodec从OpenCV::Mat类型的jpeg图像创建视频
- 如何在不显式指定 OpenCV C++ 中 Mat 类型的情况下为不同的矩阵类型编写方法
- 不完整的类型 "cv::Mat" opencv c++
- 如何将labview图像类型转换为opencv图像类型(或Mat)
- 在uchar类型的特征::矩阵和cv::Mat之间的转换
- 具有 const cv::Mat 类型的参数将在函数中更改
- 从未知类型的 cv::Mat 获取 cv::标量
- 错误:类型为"cv::Mat&"的非常量引用初始化无效
- 无法使用大小和类型参数调用 OpenCV 的 Mat::zeros
- cv::Mat,在不知道矩阵类型的情况下获取行-列的值
- 如何访问函数内部Mat类型参数的变量名
- OpenCV帮助-错误:没有匹配' operator[] '(操作数类型是' cv::Mat '和' int ').&l
- opencv#定义Mat的类型
- 如何在创建时强制cv::Mat中的数据类型为float ?
- 如何生成 cv::Mat 类型代码