我正在尝试将基本矩阵与一列矩阵(二维齐次坐标)相乘,但出现以下错误:CvException occurred - OpenCV: src1.size == dst.size && src1.channels() == dst.channels()
代码如下所示:
IntPtr fundamentalMatrix = CvInvoke.cvCreateMat(3, 3, MAT_DEPTH.CV_32F);
[... finding the fundamental matrix ...]
IntPtr cam1PointRef = CvInvoke.cvCreateMat(3, 1, MAT_DEPTH.CV_32F);
IntPtr cam2PointRef = CvInvoke.cvCreateMat(3, 1, MAT_DEPTH.CV_32F);
//cam1Point is known
CvInvoke.cvSet2D(cam1PointRef, 0, 0, new MCvScalar(cam1Point.X));
CvInvoke.cvSet2D(cam1PointRef, 1, 0, new MCvScalar(cam1Point.Y));
CvInvoke.cvSet2D(cam1PointRef, 2, 0, new MCvScalar(1));
CvInvoke.cvMul(fundamentalMatrix, cam1PointRef, cam2PointRef, 1);
Matrix<float> cam2PointMat = new Matrix<float>(3, 1, cam2PointRef);
PointF cam2Point = new PointF();
cam2Point.X = cam2PointMat[0, 0] / cam2PointMat[0, 2];
cam2Point.Y = cam2PointMat[0, 1] / cam2PointMat[0, 2];
如果我像这样反转乘法顺序:CvInvoke.cvMul(cam1PointRef, fundamentalMatrix, cam2PointRef, 1);
我得到另一个异常:
OpenCV: The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array'
我做错了什么?为什么我不能将 (3 x 3) 矩阵与 (3 x 1) 矩阵相乘以获得对应点?