Error transforming a vector via Homography matrix - C++

asked 2013-04-18 06:07:53 -0600

matteo gravatar image

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)

Why?

edit retag flag offensive close merge delete

Comments

It seems to be the type... Did you check H and srcMat elements size and channels ?

Rogeeeer gravatar imageRogeeeer ( 2013-04-18 06:44:54 -0600 )edit