我试图通过将第n-1帧与第n帧拼接来创建视频中的全景图。 我的问题是,在(大约20帧)之后,图片的右侧变得非常模糊,我不知道如何处理它。
主:
Ptr<FeatureDetector> brisk = BRISK::create(20, 3, 1.0f);
Ptr<DescriptorMatcher> matcher = BFMatcher::create("BruteForce-Hamming");
// find features
brisk->detect(leftImage, keypoints_1);
brisk->detect(rightImage, keypoints_2);
brisk->compute(leftImage, keypoints_1, descriptors_1);
brisk->compute(rightImage, keypoints_2, descriptors_2);
// Find two nearest matches
matcher->knnMatch(descriptors_1, descriptors_2, matches, 2);
//filter bad matches
const float ratio = 0.6;
for (int i = 0; i < matches.size(); ++i)
{
if (matches[i][0].distance / matches[i][1].distance < ratio)
{
good_matches.push_back(matches[i][0]);
}
}
for (size_t i = 0; i < good_matches.size(); i++)
{
leftImage_matchedKPs.push_back(keypoints_1[good_matches[i].queryIdx].pt);
rightImage_matchedKPs.push_back(keypoints_2[good_matches[i].trainIdx].pt);
}
H = findHomography(Mat(rightImage_matchedKPs), Mat(leftImage_matchedKPs), RANSAC, 5);
warpPerspective(rightImage, rightImageWarped, H, Size(4000, 1280)); // fixed size
panorama = rightImageWarped.clone();
roi = Mat(panorama, Rect(0, 0, leftImage.cols, leftImage.rows));
leftImage.copyTo(roi);
}
stichPair:
Page.FindControl