特征检测器中的析构函数出错+ SURF特征

时间:2017-11-07 13:21:28

标签: c++ opencv surf

我试图根据视频连续帧中的补丁中匹配关键点之间的平均欧几里德距离来测量局部失真量。调用以下函数(使用此tutorial):

double Processing::calculate_distortion(Mat standard, Mat frame)
{
    std::vector<KeyPoint> keypoints_1, keypoints_2;

    cout << standard.rows << ", " << frame.rows << endl;
    cout << standard.cols << ", " << frame.cols << endl;

    FastFeatureDetector detector(10);
    detector.detect( standard, keypoints_1 );
    detector.detect( frame, keypoints_2 );

    cout << keypoints_1.size() << ", " << keypoints_2.size() << endl;

    //-- Step 2: Calculate descriptors (feature vectors)
    SurfDescriptorExtractor extractor;

    Mat descriptors_1, descriptors_2;

    extractor.compute( standard, keypoints_1, descriptors_1 );
    extractor.compute( frame, keypoints_2, descriptors_2 );

    cout << descriptors_1.rows << ", " << descriptors_2.rows << endl;

    cout << "BP1" << endl;

    //-- Step 3: Matching descriptor vectors using FLANN matcher
    FlannBasedMatcher matcher;
    std::vector< DMatch > matches;
    matcher.match( descriptors_1, descriptors_2, matches );

    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;
    }

    cout << "BP2" << endl;

    //-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist,
    //-- or a small arbitary value ( 0.02 ) in the event that min_dist is very
    //-- small)
    //-- PS.- radiusMatch can also be used here.
    double distance = 0.0;
    int count = 0;
    double limit = 2 * min_dist;
    limit = (limit > 0.02) ? limit : 0.02;

    cout << limit << endl;

    for( int i = 0; i < descriptors_1.rows; i++ )
    {
        if( matches[i].distance <= limit )
        {
            Point2f point1 = keypoints_1[matches[i].queryIdx].pt;
            Point2f point2 = keypoints_2[matches[i].trainIdx].pt;

            distance += sqrt(pow(point1.x - point2.x, 2.0) +
                             pow(point1.y - point2.y, 2.0));

            count += 1;
        }
    }

    cout << "Count : " << count << endl;

    return distance / count;
}

该函数返回时失败。调试器产生以下错误:

  

.exe中0x770086ce处的未处理异常:0xC0000005:&gt;访问冲突读取位置0xff244e8b。

我做错了什么?

0 个答案:

没有答案