我有两个相同类型的Mat,都是
CV_64F
。
mat1
的大小为:3行,3列
mat2
的大小为:3行,1列我想将它们相乘得到大小为3行,1列的
mat3
。我已经尝试过使用:
Mat mat3 = new Mat(3, 1, CvType.CV_64F);
Core.multiply(mat1, mat2, mat3);
但是我收到了一个错误:
CvException [org.opencv.core.CvException:/home/andreyk/OpenCV2/trunk/opencv_2.3.1.b2/modules/core/src/arithm.cpp:1253: 错误: (-209) 操作既不是 'array op array' (数组具有相同的大小和相同的通道数), 也不是 'array op scalar', 也不是 'scalar op array',在函数 void cv::arithm_op(const cv::_InputArray&, const cv::_InputArray&, const cv::_OutputArray&, const cv::_InputArray&, int, void (*)(const uchar, size_t, const uchar*, size_t, uchar*, size_t, cv::Size, void*), bool, void*)
我做错了什么?
提前感谢任何帮助。
编辑:
如果方便的话, 3x3矩阵mat2
是Imgproc.getPerspectiveTransform
的结果, 其余代码如下:
Mat mat1 = new Mat(3, 1, CvType.CV_64F);
mat1.put(0, 0, 2.0);
mat1.put(1, 0, 0.5);
mat1.put(2, 0, 1.0);
Mat mat3 = new Mat(3, 1, CvType.CV_64F);
Core.multiply(mat2, mat1, mat3);
src3
中使用null
,就会得到NullPointerException
,所以现在我只是在这里使用单位矩阵,直到我弄清楚为什么不允许使用null
。再次感谢。 编辑:new Mat()
用于src3
可以正常工作,所以我将采用它。 - woodstock365src3
,您可以使用Mat.zeros(rows, cols CvType)
:Core.gemm(mat1, mat2.t(), 1, Mat.zeros(rows, rows, MATRIX_TYPE) , 0, mat3, 0);
- auraham