Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

multiplying homography and image matrices

I have been trying to understand how warpPerspective() is working. I understand that among other things it multiplies the homography matrix by the source image matrix. I have the source image matrix generated by

Mat img_src = imread(imageName, IMREAD_GRAYSCALE);

and the homography matrix generated by

Mat h = findHomography(pts_src, pts_dst);

where pts_src and pts_dst are filled using four point each

 pts_dst.push_back(Point2f(0,0));

This works well with warpPerspective(), but the code

Mat im=h*img_src; 
imshow("Image", im);

compiles well, yet imshow("Image", im) generates an error:

Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2))

I guess this is probably type mismatch between img_src and h which seems to be of type double because only

cout << h.at<double>(i,j) << endl;

works on it.

How could be this sorted out?