我有两张图片(A和B),它们之间略有扭曲,存在平移、旋转和缩放的差异(例如,这些图片)。
所以我的需求是对图像 B 应用某种变换,以补偿存在的扭曲 / 平移 / 旋转,使得两个图像具有相同的大小、方向和无平移。
我已经提取了点并找到了 Homography,如下所示。但我不知道如何使用 Homography 来转换 Mat img_B
,使其看起来像 Mat img_A
。有什么想法吗?
//-- Localize the object from img_1 in img_2
std::vector<Point2f> obj;
std::vector<Point2f> scene;
for (unsigned int i = 0; i < good_matches.size(); i++) {
//-- Get the keypoints from the good matches
obj.push_back(keypoints_object[good_matches[i].queryIdx].pt);
scene.push_back(keypoints_scene[good_matches[i].trainIdx].pt);
}
Mat H = findHomography(obj, scene, CV_RANSAC);
祝好!