how to use the perspectiveTransform function?
when run my code, Will produce the following exception:
OpenCV Error: Assertion failed (scn + 1 == m.cols && (depth == CV_32F || depth == CV_64F)) in perspectiveTransform, file /Users/donbe/Documents/opencv/opencv/modules/core/src/matmul.cpp, line 1916
Who can help me?
My code below:
Point2f srcTri[4];
Point2f dstTri[4];
Mat warp_mat;
Mat src;
/// Load the image
src = imread( argv[1], 1 );
srcTri[0] = Point2f(0,0);
srcTri[1] = Point2f(src.cols,0);
srcTri[2] = Point2f(src.cols,src.rows);
srcTri[3] = Point2f(0,src.rows);
dstTri[0] = Point2f(0,0);
dstTri[1] = Point2f(src.cols/2,0);
dstTri[2] = Point2f(src.cols/2,src.rows);
dstTri[3] = Point2f(0,src.rows);
warp_mat = getPerspectiveTransform(srcTri, dstTri);
Mat warp_dst(src.size(), src.type());
//There will produce a exception.
perspectiveTransform(src, warp_dst, warp_mat);
namedWindow( "Warp", CV_WINDOW_AUTOSIZE );
imshow( "Warp", warp_dst );
waitKey(0);
return 0;