与立体摄像头实时特征匹配

Real time feature matching with stereo camera

本文关键字:特征 实时 摄像头      更新时间:2023-10-16

我有一个立体相机设置,我正在尝试匹配两帧之间的特征,以便我可以将相应的点三角测量成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;
}

SURF太慢了。尝试使用实时运行的ORB。OrbFeatureDetector