src/matching2D_Student.cpp
// Detect keypoints in image using the traditional Shi-Thomasi detector
Detect keypoints in image using the traditional Shi-Thomasi detector
Detect keypoints in image using the traditional Shi - Thomasi detector
double detKeypointsShiTomasi(vector<cv::KeyPoint> &keypoints, cv::Mat &img, bool bVis)
{
    int blockSize = 4;       
    double maxOverlap = 0.0; 
    double minDistance = (1.0 - maxOverlap) * blockSize;
    int maxCorners = img.rows * img.cols / max(1.0, minDistance); 
    double qualityLevel = 0.01; 
    double k = 0.04;
    double t = (double)cv::getTickCount();
    vector<cv::Point2f> corners;
    cv::goodFeaturesToTrack(img, corners, maxCorners, qualityLevel, minDistance, cv::Mat(), blockSize, false, k);
    for (auto it = corners.begin(); it != corners.end(); ++it)
    {
        cv::KeyPoint newKeyPoint;
        newKeyPoint.pt = cv::Point2f((*it).x, (*it).y);
        newKeyPoint.size = blockSize;
        keypoints.push_back(newKeyPoint);
    }
    t = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
    cout << "Shi-Tomasi detection with n=" << keypoints.size() << " keypoints in " << 1000 * t / 1.0 << " ms" << endl;
    if (bVis)
    {
        cv::Mat visImage = img.clone();
        cv::drawKeypoints(img, keypoints, visImage, cv::Scalar::all(-1), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
        string windowName = "Shi-Tomasi Corner Detector Results";
        cv::namedWindow(windowName, 6);
        imshow(windowName, visImage);
        cv::waitKey(0);
    }
    return 1000 * t / 1.0;
}
double detKeypointsShiTomasi ( vector < cv :: KeyPoint > & keypoints , cv :: Mat & img , bool bVis ) { int blockSize = 4 ; double maxOverlap = 0.0 ; double minDistance = ( 1.0 - maxOverlap ) * blockSize ; int maxCorners = img . rows * img . cols / max ( 1.0 , minDistance ) ; double qualityLevel = 0.01 ; double k = 0.04 ; double t = ( double ) cv :: getTickCount ( ) ; vector < cv :: Point2f > corners ; cv :: goodFeaturesToTrack ( img , corners , maxCorners , qualityLevel , minDistance , cv :: Mat ( ) , blockSize , false , k ) ; for ( auto it = corners . begin ( ) ; it != corners . end ( ) ; ++ it ) { cv :: KeyPoint newKeyPoint ; newKeyPoint . pt = cv :: Point2f ( ( * it ) . x , ( * it ) . y ) ; newKeyPoint . size = blockSize ; keypoints . push_back ( newKeyPoint ) ; } t = ( ( double ) cv :: getTickCount ( ) - t ) / cv :: getTickFrequency ( ) ; cout << " " << keypoints . size ( ) << " " << 1000 * t / 1.0 << " " << endl ; if ( bVis ) { cv :: Mat visImage = img . clone ( ) ; cv :: drawKeypoints ( img , keypoints , visImage , cv :: Scalar :: all ( -1 ) , cv :: DrawMatchesFlags :: DRAW_RICH_KEYPOINTS ) ; string windowName = " " ; cv :: namedWindow ( windowName , 6 ) ; imshow ( windowName , visImage ) ; cv :: waitKey ( 0 ) ; } return 1000 * t / 1.0 ; }
Detect keypoints in image using the traditional Shi-Thomasi detector
Detect keypoints in image using the traditional Shi - Thomasi detector
// compute detector parameters based on image size //  size of an average block for computing a derivative covariation matrix over each pixel neighborhood // max. permissible overlap between two features in % // max. num. of keypoints // minimal accepted quality of image corners // Apply corner detection // add corners to result vector // visualize results