Is there something fundamentally wrong with this code:code (see EDIT)
// 2 images are previously loaded in objectImg and sceneImg //
cv::Ptr<cv::BRISK> ptrBrisk = cv::BRISK::create();
ptrBrisk->detect(objectImg, objectKeypoints);
ptrBrisk->compute(objectImg,objectKeypoints,objectDescriptors);
ptrBrisk->detect(sceneImg, sceneKeypoints);
ptrBrisk->compute(sceneImg,sceneKeypoints,sceneDescriptors);
int k =2;
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( objectDescriptors, sceneDescriptors, matches );
On execution, the last line (matcher.match) fails: " Unsupported format or combination of formats (type = 0) in cv::flann:buildIndex_ "
I tried to use:
std::vector< DMatch > matches;
cv::Ptr<cv::DescriptorMatcher> matcher = cv::DescriptorMatcher::create("FlannBased");
matcher->match( objectDescriptors, sceneDescriptors, matches );
But it fails at execution, same error message.
EDIT : I added some code and it now works, but (look after code):
cv::Ptr<cv::BRISK> ptrBrisk = cv::BRISK::create();
ptrBrisk->detect(objectImg, objectKeypoints);
ptrBrisk->compute(objectImg,objectKeypoints,objectDescriptors);
ptrBrisk->detect(sceneImg, sceneKeypoints);
ptrBrisk->compute(sceneImg,sceneKeypoints,sceneDescriptors);
if(objectDescriptors.type() != CV_32F)
{
cv::Mat temp;
objectDescriptors.convertTo(temp, CV_32F);
objectDescriptors = temp;
}
if(sceneDescriptors.type() != CV_32F)
{
cv::Mat temp;
sceneDescriptors.convertTo(temp, CV_32F);
sceneDescriptors = temp;
}
int k =2;
std::vector< DMatch > matches;
cv::Ptr<cv::DescriptorMatcher> matcher = cv::DescriptorMatcher::create("FlannBased");
matcher->match( objectDescriptors, sceneDescriptors, matches );
Isn't using a float version of the descriptors defeating the purpose of using binary descriptors, aka speed? I will try test it with a BFMatcher and keep it updated here!