Ask Your Question
1

How to use BRIEF, ORB, FREAK or integer descriptor with cv::BOW?

asked 2013-12-26 18:25:13 -0600

fbnsantos gravatar image

What is the easiest way to use BRIEF, ORB, FREAK or integer based descriptor with opencv BOW implementation.

At this moment (based on http://answers.opencv.org/question/17460/how-to-use-bag-of-words-example-with-brief/) during the the dictionary build I do:

   orbDesc.compute(bwimage, keypoints_1, descriptors1);
   cv::Mat descr;
   descriptors1.convertTo(descr, CV_32F);
   featuresUnclustered.push_back(descr);

And I get the dictionary ( cv::BOWKMeansTrainer, withflags=cv::KMEANS_PP_CENTERS;), however when want o get the word histogram, I do this:

mymatcher=new cv::FlannBasedMatcher; 
...
myextractor=new cv::OrbDescriptorExtractor;
mydetector=new cv::OrbFeatureDetector;
myBOW=new cv::BOWImgDescriptorExtractor(myextractor,mymatcher);
myBOW->setVocabulary(dictionary);
std::vector<cv::KeyPoint> keypoints;
mydetector->detect(bwimage,keypoints);
cv::Mat bowDescriptor;
myBOW->compute(bwimage,keypoints,bowDescriptor);

However, the program breaks at myBOW->compute. This is because orb uses a non float vector. What is the easiest way for I solve this?

from the another post question there is this solution (convert the dictionary to unsigned char ):

cv::Mat floatdictonary; // 
floatDictionary = bowTrainer.cluster(floatFeaturesUnclustered);//you have convert features //unsigned char to float 
cv::Mat udictionary; 
floatdictionary.convertTo(udictonary,CV_8UC1); // 
 bowDE->setVocabulary(udictonary); 
 Mat bowDescriptor; std::vector<std::vector<int> > pointIdxOfClusters; 
 bowDE.compute(img, keypoints, bowDescriptor,&pointIdxOfClusters);

This last option is a good option?

thanks, Filipe

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-07-16 13:13:43 -0600

warith_h gravatar image

As said in the similar post, this is NOT the right solution, the medoid/mean is not correct giving poor results in my experiments for image retrieval. I am looking for a more correct solution.

edit flag offensive delete link more

Comments

Yes, you are definitively right, I also say this in my post, please also have a look at the link of my post above.

Guanta gravatar imageGuanta ( 2014-07-17 02:20:08 -0600 )edit

@Guanta: Thank you. Indeed, we have to look at what Marius Muja did in his implementation of FLANN.

warith_h gravatar imagewarith_h ( 2014-07-17 04:08:14 -0600 )edit
0

answered 2013-12-27 09:47:04 -0600

Guanta gravatar image

updated 2013-12-27 10:11:01 -0600

The easiest way is to convert the binary orb-descriptor to float. The last option, converting the vocabulary to uchar should also work. However note, that both ways contradict in some way the intention of binary descriptors since the implemented BOWImageDescriptor doesn't use the hamming-distance for the comparison (and the internal clustering) of two binary descriptors. Maybe my answer to a similar post: http://answers.opencv.org/question/24835/is-there-a-way-of-using-orb-with-bow/ can help you further.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-12-26 18:25:13 -0600

Seen: 2,893 times

Last updated: Jul 16 '14