我从图像中提取了四个角,
std::vector<cv::Point2f> ecken;
ecken.push_back(corners[0]);
ecken.push_back(corners[size.height-1]);
ecken.push_back(corners[size.area()-size.height-1]);
ecken.push_back(corners[size.area()-1]);
它们被扭曲成第二张图像:
quad_pts.push_back(cv::Point2f(0, 0));
quad_pts.push_back(cv::Point2f(quad.cols, 0));
quad_pts.push_back(cv::Point2f(quad.cols, quad.rows));
quad_pts.push_back(cv::Point2f(0, quad.rows));
// Get transformation matrix
cv::Mat transmtx = cv::getPerspectiveTransform(ecken, quad_pts);
cv::warpPerspective(src, quad, transmtx, quad.size(),1);
我想从我在四边形中得到的结果返回到原始图像,这些是我尝试过的:
cv::Mat trans = cv::getPerspectiveTransform(quad_pts,ecken );
cv::perspectiveTransform(quad,test,trans); /// I'm not sure that this correct and the program crashes here
这里是控制台中的错误消息:
OpenCV Error: Assertion failed (scn + 1 == m.cols && (depth == CV_32F || depth =
= CV_64F)) in unknown function, file ..\..\..\opencv\modules\core\src\matmul.cpp
, line 1926
它没有用!任何想法 ??