Ask Your Question

lkjs's profile - activity

2014-03-26 22:21:04 -0600 received badge  Editor (source)
2014-03-26 20:54:33 -0600 asked a question How can use BOWImgDescriptorExtractor with sift and no error

Hi~

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;
     fs.release();
     Ptr<DescriptorMatcher> matcher(new FlannBasedMatcher);
     Ptr<FeatureDetector> detector(new SiftFeatureDetector());
     Ptr<DescriptorExtractor> extractor(new SiftDescriptorExtractor);
     BOWImgDescriptorExtractor bowDE(extractor,matcher);
     bowDE.setVocabulary(dictionary);

     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];

              sprintf(filename,"./sicklaser_result/data_1/%d.png",i);
              Mat img=imread(filename);

              vector<KeyPoint> keypoints;
              detector->detect(img,keypoints);

              Mat bowDescriptor;
              bowDE.compute(img,keypoints,bowDescriptor);//here error
              sprintf(imageTag,"img%d",i);
              fs1 << imageTag << bowDescriptor;
     }
     fs1.release();
}

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)

thx:)