Search code examples
androidopencvfeature-extractionsurf

OpenCV Error: Unsupported format or combination of formats (type=16)


I have an Android application which uses BOW + SVM method for object detection. I'm using DynamicSURF for feature detection, OpponentSURF for descriptor extraction and FlannBased matcher. I'm getting the frame in RGBA format so I'm I'm converting in it to BGR.

The problem comes when I try to compute features. The following error is given:

03-08 23:31:07.965: E/cv::error()(1578): OpenCV Error: Unsupported format or combination of formats (type=16
03-08 23:31:07.965: E/cv::error()(1578): ) in void cv::flann::buildIndex_(void*&, const cv::Mat&, const cv::flann::IndexParams&, const Distance&) [with Distance = cvflann::L2<float>, IndexType = cvflann::Index<cvflann::L2<float> >], file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/flann/src/miniflann.cpp, line 315

Here is my code:

    Mat matBGR;
    cvtColor(matRGBA, matBGR, CV_RGBA2BGR);

    const Ptr<FeatureDetector> detector =   FeatureDetector::create("DynamicSURF");
    const Ptr<DescriptorExtractor> descriptors = DescriptorExtractor::create("OpponentSURF");
    const Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("FlannBased");
    BOWImgDescriptorExtractor bowDE(descriptors, matcher);

    FileStorage fileStorage(dictionaryPathString + dictionaryNameString, FileStorage::READ);

    Mat dictionary;

    fileStorage["dictionary"] >> dictionary;
    fileStorage.release();
    bowDE.setVocabulary(dictionary);

    Mat features;
    vector<KeyPoint> keypoints;

    detector->detect(matBGR, keypoints);
    KeyPointsFilter::retainBest(keypoints, 1700);
    bowDE.compute(matBGR, keypoints, features);

Do you have any idea what causes this problem? I searched for solutions but I didn't find a solution.


Solution

  • Silly mistake.. It turns out I was using wrong file for BOW dictionary. I put the proper file and the error is gone. Always check for such things, it can save you hours!