0

我正在使用 opencv 的“warpperspective”函数相对于 image1 转换 image2。

我们的输出图像如下。谁能告诉我如何知道图像下方指向的坐标角?

warprospective 的代码如下 -

 std::vector< Point2f > points1,points2;
    for( int i = 0; i < matches1.size(); i++ )
       {
        points1.push_back( keypoints_input1[matches1[i].queryIdx ].pt );
        points2.push_back( keypoints_input2[matches1[i].trainIdx ].pt );
       }
    /* Find the Homography Matrix for current and next frame*/
     Mat H1 = findHomography( points2, points1, CV_RANSAC );
     /* Use the Homography Matrix to warp the images*/
    cv::Mat result1;
    warpPerspective(input2, result1, H1, Size(input2.cols+150, input2.rows+150),              
INTER_CUBIC);
imshow("resut",result1);


...
}

谢谢。

4

1 回答 1

1

为了找到扭曲图像角落的坐标,您可以执行以下操作:

cv::Mat_<float> p(3,1), c_topleft, c_topright, c_botleft, c_botright;

p(0)=0; p(1)=0; p(2)=1;
c_topleft=H1*p; c_topleft/=c_topleft(2); // Top-Left corner

p(0)=input2.cols-1; p(1)=0; p(2)=1;
c_topright=H1*p; c_topright/=c_topright(2); // Top-right corner

p(0)=0; p(1)=input2.rows-1; p(2)=1;
c_botleft=H1*p; c_botleft/=c_botleft(2); // Bottom-left corner

p(0)=input2.cols-1; p(1)=input2.rows-1; p(2)=1;
c_botright=H1*p; c_botright/=c_botright(2); // Bottom-right corner
于 2014-02-28T08:39:56.557 回答