嗨,我正在尝试在不使用 opencv 提供的缝合类的情况下缝合一些图像。但是,输出意外退出。我将用输入和输出图像来解释它。
输入1
输入2
预期产出
实际输出
我认为我的 ROI 复制有问题。任何人请帮助!
我的缝合部分代码如下 -
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);
Mat stitch_1(Size(input2.cols+150, input2.rows+150),CV_8UC3);
Mat roi1(stitch_1, Rect(0, 0, input1.cols, input1.rows));
Mat roi2(stitch_1, Rect(0, 0, result1.cols, result1.rows));
input2.copyTo(roi1);
result1.copyTo(roi2);
谁能告诉我哪里出错了?谢谢。
编辑: input1(640,360) 和 input2(790,510) 的大小不同。