0

我从图像中提取了四个角,

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

它没有用!任何想法 ??

4

1 回答 1

0

您的两个 Mat 对象的深度不同。通过打印具有相同图像类型的 Mat.depth() 进行检查。可能其中一个是灰度而另一种颜色。

于 2013-07-24T13:24:38.047 回答