我曾尝试使用 OpenCV 3.0 进行拼接;结果很好,但也给了我右边的黑色空白区域。
for (int i = 0; i < best_matches.size(); i++)
{
//-- Get the keypoints from the good matches
FirstImageMatchPT.push_back(keypoints1[best_matches[i].queryIdx].pt);
SecondImageMatchPT.push_back(keypoints2[best_matches[i].trainIdx].pt);
}
vector<unsigned char> match_mask;
Mat MatchedImage = findHomography(SecondImageMatchPT, FirstImageMatchPT, CV_RANSAC);
cv::Mat result;
result = img_Right.clone();
warpPerspective(img_Right, result, MatchedImage, cv::Size(img_Left.cols + img_Right.cols, img_Left.rows));
cv::Mat half(result, cv::Rect(0, 0, img_Left.cols, img_Left.rows));
img_Left.copyTo(half);
'findHomography' 的第一个变量是第二个(我的意思是右图)的匹配点,第二个是第一个(左图)的匹配点。
我交换变量的原因是,如果我运行下面的代码,它会裁剪左图并只显示左图的匹配区域加上右图。(甚至有更大的空白区域)
for (int i = 0; i < best_matches.size(); i++)
{
//-- Get the keypoints from the good matches
FirstImageMatchPT.push_back(keypoints1[best_matches[i].queryIdx].pt);
SecondImageMatchPT.push_back(keypoints2[best_matches[i].trainIdx].pt);
}
vector<unsigned char> match_mask;
Mat MatchedImage = findHomography(FirstImageMatchPT, SecondImageMatchPT, CV_RANSAC);
cv::Mat result;
result = img_Left.clone();
warpPerspective(img_Left, result, MatchedImage, cv::Size(img_Left.cols + img_Right.cols, img_Left.rows));
cv::Mat half(result, cv::Rect(0, 0, img_Right.cols, img_Right.rows));
img_Right.copyTo(half);
你能告诉我如何为此制定正确的投资回报率吗?我怎样才能自动切掉那个空白区域?