Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error transforming a vector via Homography matrix - C++

I have 2 frames of a video stream done by a moving (very slow) camera; after using SIFT algorithm and findHomography OpenCv function i have the transformation matrix that describes the movement done by the camera between the 2 frames. what i would like to do is to find a point of the first frame in the second one: so my code is:

H = findHomography( point1, point2, CV_RANSAC );  //compute the transformation matrix using the
                                       // matching points (the matrix is correct, i checked it)
Mat dstMat(3, 1, H.type());    
vector<Point3f> vec;
Mat srcMat(3, 1, H.type());
vec.push_back(Point3f(Ptx,Pty,-1));   // fill the 3x1 vector with the coordinate
                                         // of the interest point in frame 1
srcMat= Mat(vec).reshape(1).t();     //conversion of vec in Mat (the vector is correct, i checked it)
dstMat = H*srcMat;     //compute the arrival point in frame 2  // ERROR

But, where error is written, i receive the following error: OpenCV Error: Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2)) in gemm, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/core/src/matmul.cpp, line 711 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/core/src/matmul.cpp:711: error: (-215) type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) in function gemm

Aborted (core dumped)