c++ - opencv 使用给定坐标进行特征匹配

标签 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);

不过我想做的是,使用光流跟踪左帧上的点,然后使用特征匹配匹配右帧上的那些点。

是否可以将您希望匹配的点的像素坐标提供给特征匹配函数?

最佳答案

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

// 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);

关于c++ - opencv 使用给定坐标进行特征匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31025265/

相关文章:

c++ - Opencv cvConvertScale 面临的问题

OpenCV:在顶部和底部配置中绘制匹配项?

c# - SendMessage 中的误导参数类型 (... IntPtr wParam ...)

c++ - 在 UNICODE_STRING 中搜索字符

c++ - 从循环内的 vector 中删除项目

opencv - 来自网络摄像头的面部表情识别

python - 如何使用 OpenCV 和 SIFT 查找训练图像的多个实例

c++ - 不同场景下的virtual关键字

c++ - 对象指针的全局 vector 错误 c++

linux - Qimage 到 cv::Mat 转换奇怪的行为