立体相机实时特征匹配
Real time feature matching with stereo camera
我有一个立体相机设置,我正在尝试匹配两个帧之间的特征,以便我可以将相应的点三角化为 3d 点云。
它有点工作,使用 SURF,但对于实时使用来说太慢了。有没有更快的方法?或者,解决问题的方法?
这是我的代码:
bool matchFeatures(Mat img_1, Mat img_2)
{
points_2D_left.clear();
points_2D_right.clear();
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400; SurfFeatureDetector detector(minHessian);
std::vector<KeyPoint> keypoints_1, keypoints_2;
detector.detect(img_1, keypoints_1);
detector.detect(img_2, keypoints_2);
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute(img_1, keypoints_1, descriptors_1);
extractor.compute(img_2, keypoints_2, descriptors_2);
//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match(descriptors_1, descriptors_2, matches);
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for (int i = 0; i < descriptors_1.rows; i++)
{
double dist = matches[i].distance;
if (dist < min_dist) min_dist = dist;
if (dist > max_dist) max_dist = dist;
}
std::vector< DMatch > good_matches;
for (int i = 0; i < descriptors_1.rows; i++)
{
if (matches[i].distance <= max(2 * min_dist, 0.02))
{
good_matches.push_back(matches[i]);
}
}
for (int i = 0; i < good_matches.size(); i++)
{
//-- Get the keypoints from the good matches
points_2D_left.push_back(keypoints_1[good_matches[i].queryIdx].pt);
points_2D_right.push_back(keypoints_2[good_matches[i].trainIdx].pt);
}
return true;
}
冲浪很慢。尝试使用实时运行的 ORB。
OrbFeatureDetector
我有一个立体相机设置,我正在尝试匹配两个帧之间的特征,以便我可以将相应的点三角化为 3d 点云。 它有点工作,使用 SURF,但对于实时使用来说太慢了。有没有更快的方法?或者,解决问题的方法?
这是我的代码:
bool matchFeatures(Mat img_1, Mat img_2)
{
points_2D_left.clear();
points_2D_right.clear();
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400; SurfFeatureDetector detector(minHessian);
std::vector<KeyPoint> keypoints_1, keypoints_2;
detector.detect(img_1, keypoints_1);
detector.detect(img_2, keypoints_2);
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute(img_1, keypoints_1, descriptors_1);
extractor.compute(img_2, keypoints_2, descriptors_2);
//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match(descriptors_1, descriptors_2, matches);
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for (int i = 0; i < descriptors_1.rows; i++)
{
double dist = matches[i].distance;
if (dist < min_dist) min_dist = dist;
if (dist > max_dist) max_dist = dist;
}
std::vector< DMatch > good_matches;
for (int i = 0; i < descriptors_1.rows; i++)
{
if (matches[i].distance <= max(2 * min_dist, 0.02))
{
good_matches.push_back(matches[i]);
}
}
for (int i = 0; i < good_matches.size(); i++)
{
//-- Get the keypoints from the good matches
points_2D_left.push_back(keypoints_1[good_matches[i].queryIdx].pt);
points_2D_right.push_back(keypoints_2[good_matches[i].trainIdx].pt);
}
return true;
}
冲浪很慢。尝试使用实时运行的 ORB。 OrbFeatureDetector