gpt4 book ai didi

c - warp前景协调

转载 作者:行者123 更新时间:2023-11-30 15:37:45 25 4
gpt4 key购买 nike

我正在使用 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);


...
}

谢谢。

最佳答案

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

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

关于c - warp前景协调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com