How can use BOWImgDescriptorExtractor with sift and no error

asked 2014-03-26 20:54:33 -0500

lkjs gravatar image

updated 2014-03-26 22:21:04 -0500


I made bag of words with sift feature. and I wanna use it. so I code search program based on sample code.

and when I use BOWImgDescriptorExtractor. but I have format exception when i compute.

sorry for that if it's easy problem, i'm beginner TT.

using namespace cv;

string type2str(int type);

int main( int argc, char** argv )
     if( argc < 2 )
     { return -1; }

     int match_img_num = atoi(argv[1]);
     Mat dictionary;
     FileStorage fs("./dictionary_rgbdslam.yml", FileStorage::READ);
     fs["vocabulary"] >> dictionary;
     Ptr<DescriptorMatcher> matcher(new FlannBasedMatcher);
     Ptr<FeatureDetector> detector(new SiftFeatureDetector());
     Ptr<DescriptorExtractor> extractor(new SiftDescriptorExtractor);
     BOWImgDescriptorExtractor bowDE(extractor,matcher);

     FileStorage fs1("descriptor_sicklaser.yml",FileStorage::WRITE);
     for(int i = 0; i < match_img_num; i++){
              char * filename = new char[100];
              char * imageTag = new char[10];

              Mat img=imread(filename);

              vector<KeyPoint> keypoints;

              Mat bowDescriptor;
              bowDE.compute(img,keypoints,bowDescriptor);//here error
              fs1 << imageTag << bowDescriptor;

error message is

OpenCV Error: Unsupported format or combination of formats (type=0
) in buildIndex_, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules  /flann/src/miniflann.cpp, line 299
terminate called after throwing an instance of 'cv::Exception'
what():  /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1306/modules/flann/src/miniflann.cpp:299: error: (-210) type=0
in function buildIndex_

Aborted (core dumped)


edit retag flag offensive close merge delete


Hello, I meet the same problem. Have you solve it?

vincentweisen gravatar imagevincentweisen ( 2016-04-22 03:35:48 -0500 )edit