【问题标题】:Real time feature matching with stereo camera立体相机实时特征匹配
【发布时间】:2015-08-15 03:36:15
【问题描述】:

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

【问题讨论】:

  • 您是否尝试过分析您的代码?瓶颈在哪里?
  • 嗨,它看起来像这个部分:extractor.compute(img_1, keypoints_1, descriptors_1); extractor.compute(img_2, keypoints_2, descriptors_2);

标签: c++ opencv feature-detection


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-01-16
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 2016-08-10
    • 2016-06-25
    • 1970-01-01
    • 2016-01-26
    相关资源
    最近更新 更多