src/matching2D_Student.cpp
// Detect keypoints in an image using more recent methods available in OpenCV
Detect keypoints in an image using more recent methods available in OpenCV
Detect keypoints in an image using more recent methods available in OpenCV
void detKeypointsModern(std::vector<cv::KeyPoint> &keypoints, cv::Mat &img, std::string detectorType, bool bVis) {
    cv::Ptr<cv::Feature2D> detector;
    if (detectorType.compare("FAST") == 0) detector = cv::FastFeatureDetector::create();
    else if (detectorType.compare("BRISK") == 0) detector = cv::BRISK::create();
    else if (detectorType.compare("ORB") == 0) detector = cv::ORB::create();
    else if (detectorType.compare("AKAZE") == 0) detector = cv::AKAZE::create();
    else if (detectorType.compare("SIFT") == 0) detector = cv::xfeatures2d::SIFT::create();
    else throw invalid_argument(detectorType + " unsupported detectorType");
    detector->detect(img, keypoints);
    if (bVis) {
        string windowName = detectorType + " Keypoint Detection Results";
        cv::namedWindow(windowName);
        cv::Mat visImage = img.clone();
        cv::drawKeypoints(img, keypoints, visImage, cv::Scalar::all(-1), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
        cv::imshow(windowName, visImage);
        cv::waitKey(0);
    }
}
void detKeypointsModern ( std :: vector < cv :: KeyPoint > & keypoints , cv :: Mat & img , std :: string detectorType , bool bVis ) { cv :: Ptr < cv :: Feature2D > detector ; if ( detectorType . compare ( " " ) == 0 ) detector = cv :: FastFeatureDetector :: create ( ) ; else if ( detectorType . compare ( " " ) == 0 ) detector = cv :: BRISK :: create ( ) ; else if ( detectorType . compare ( " " ) == 0 ) detector = cv :: ORB :: create ( ) ; else if ( detectorType . compare ( " " ) == 0 ) detector = cv :: AKAZE :: create ( ) ; else if ( detectorType . compare ( " " ) == 0 ) detector = cv :: xfeatures2d :: SIFT :: create ( ) ; else throw invalid_argument ( detectorType + " " ) ; detector -> detect ( img , keypoints ) ; if ( bVis ) { string windowName = detectorType + " " ; cv :: namedWindow ( windowName ) ; cv :: Mat visImage = img . clone ( ) ; cv :: drawKeypoints ( img , keypoints , visImage , cv :: Scalar :: all ( -1 ) , cv :: DrawMatchesFlags :: DRAW_RICH_KEYPOINTS ) ; cv :: imshow ( windowName , visImage ) ; cv :: waitKey ( 0 ) ; } }
Detect keypoints in an image using more recent methods available in OpenCV
Detect keypoints in an image using more recent methods available in OpenCV
// Visualize the keypoints