OpenCV: Using cvGoodFeaturesToTrack with C++ mat variable

后端 未结 1 1583
深忆病人
深忆病人 2021-01-28 22:21

I am trying to use the cvGoodFeatureToTrack function in Visual Studio 2010 with the image type as Mat. Most of the examples I have seen use the I

相关标签:
1条回答
  • 2021-01-28 23:00

    As a starting point, if using C++ anyway (like your use of cv::Mat and cv::cvtColor suggests), then why not use C++ interface for the rest, too?

    This would mean the use of cv::goodFeaturesToTrack or a cv::GoodFeaturesToTrackDetector, which are made to work on cv::Mat and friends instead of making unneccessary casts from cv::Mat to IplImage*.

    cv::Mat grayFrame;
    std::vector<cv::Point2f> corners;
    double quality_level = 0.1;
    double min_distance = 10;
    int eig_block_size = 3;
    int use_harris = false;
    
    const int MAX_CORNERS = 10;
    cv::cvtColor(CurrFrame, grayFrame, CV_BGR2GRAY);
    cv::goodFeaturesToTrack(grayFrame,
                            corners,
                            MAX_CORNERS,
                            quality_level,
                            min_distance,
                            cv::noArray(), 
                            eig_block_size,
                            use_harris);
    
    0 讨论(0)
提交回复
热议问题