[英]Types 'cv::Mat' and 'int' are not compatible when create a Mat from array
In the documentation on Mat
it shows how to create a Mat
with a comma-separated initializer as follows: 在
Mat
的文档中,它显示了如何使用逗号分隔的初始化程序创建Mat
,如下所示:
// create 3x3 double-precision identity matrix
Mat M = (Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
But when I try, it shows an error: 但是当我尝试时,它显示了一个错误:
Types 'cv::Mat' and 'int' are not compatible
how to fix the exception? 如何解决异常?
thank you 谢谢
There is no issue with your code 您的代码没有问题
cv::Mat M = (cv::Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
I can confirm that it works with gcc 5.4.0 and OpenCV 3.1.0. 我可以确认它适用于gcc 5.4.0和OpenCV 3.1.0。 Small matrices of fixed size should be created with Matx:
应该使用Matx创建固定大小的小矩阵:
typedef cv::Matx<double, 3, 3> Mat33d;
Mat33d m(1, 0, 0, 0, 1, 0, 0, 0, 1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.