我使用openCv、FAST特征检测和Brute力匹配在立体图像之间进行特征匹配。
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);
不过,我想做的是,使用光流跟踪左框上的点,然后使用特征匹配匹配右框上的那些点。
是否可以向特征匹配函数提供您希望匹配的点的像素坐标?
您不能将其指定给匹配器,但可以在提取时限制点。在您的代码中,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);