SIFT detects 0 keypoints?

asked 2016-07-19 22:25:01 -0600

lovaj gravatar image

I'm creating the visual histograms (following the Bag of Visual Words model) of a dataset of n images using OpenCV.

This is the code:

    std::vector<std::string> fileList;
    std::unique_ptr<cv::BOWImgDescriptorExtractor> bowDE;
    cv::Mat vocabulary;//will be filled through KMeans
    ...
    bowDE->setVocabulary(vocabulary);
    cv::Ptr<cv::Feature2D> featureDetectorDescriptor = cv::xfeatures2d::SIFT::create(0,3,0.04,10,1.6);;
    for(size_t i=0;i<n;i++) {
        cv::UMat img;
        cv::Mat word;
        imread(fileList[i], cv::IMREAD_GRAYSCALE).copyTo(img);
        std::vector<cv::KeyPoint> keyPoints;
        featureDetectorDescriptor->detect(img, keyPoints);
        bowDE->compute(img, keyPoints, word);
        histograms.push_back(word);
        assert(histograms.rows==(i+1));//this is for testing
    }

The problem is that after 4625 images have been inserted, the assert condition is false. I tested keypoints.size() and it results 0, no keypoints are detected!

I tried to remove the image which created the error, but another one creates the same error (so the error seems not to depend from the image).

Why this happens?

Update: actually I found out that the error was image dependent. It seems that with the default parameters cv::SIFT detects 0 keypoints with this image from Caltech101:

enter image description here

edit retag flag offensive close merge delete

Comments

1

Actually that is quite normal. SIFT performs poorly on binary or binary-like images. For that keypoint detectors like ORB perform way better! :)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-20 04:45:20 -0600 )edit