open cv使用给定坐标进行特征匹配

时间:2015-06-24 11:25:45

标签: c++ opencv feature-detection feature-extraction opticalflow

我是使用openCv,FAST特征检测和强力匹配的立体图像之间的特征匹配。

            FastFeatureDetector detector(threshold);
            detector.detect(img1, keypoints1);
            detector.detect(img2, keypoints2);

            OrbDescriptorExtractor extractor;
            extractor.compute(img1, keypoints1, descriptors1);
            extractor.compute(img2, keypoints2, descriptors2);

            BFMatcher matcher(NORM_L2);
            matcher.match(descriptors1, descriptors2, matches);

我想做什么,左边框架上的跟踪点是否使用光流,然后使用特征匹配匹配右框架上的那些点。

是否可以为要匹配的点的像素坐标提供特征匹配功能?

1 个答案:

答案 0 :(得分:1)

您不能将此指定给匹配器,但可以在提取时限制点。在您的代码中, keypoints1 keypoints2 可以是您希望仅匹配的点的提取器的输入。因此,您应该执行以下操作:

// perform "optical flow tracking" and get some points
// for left and right frame

// convert them to cv::KeyPoint
// cv::KeyPoint keypoints1; // left frames
// cv::KeyPoint keypoints1; // right frames

// extract feature for those points only
OrbDescriptorExtractor extractor;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);

// match for the descriptors computed at the pixel coordinates
// given by the "optical flow tracking" only
BFMatcher matcher(NORM_L2);
matcher.match(descriptors1, descriptors2, matches);