opencv 使用给定坐标进行特征匹配
open cv Feature matching using given coordinates
我正在使用 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);
不过我想做的是,使用光流跟踪左帧上的点,然后使用特征匹配匹配右帧上的那些点。
是否可以将您希望匹配的点的像素坐标提供给特征匹配函数?
您不能将此指定给匹配器,但您可以在提取时限制点数。在您的代码中,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);
我正在使用 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);
不过我想做的是,使用光流跟踪左帧上的点,然后使用特征匹配匹配右帧上的那些点。
是否可以将您希望匹配的点的像素坐标提供给特征匹配函数?
您不能将此指定给匹配器,但您可以在提取时限制点数。在您的代码中,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);