简体   繁体   中英

opencv c++ ORB Bag Of Words

After reading this paper , as well as many answers.opencv questions, I was wondering if there was any code examples out there of an ORB Bag Of Words? I could only find SURF or SIFT examples.

Unfortunately there is no example of using Bag-Of-Words with binary descriptors (BRIEF, ORB , BRISK, FREAK). Either way the paper you showed explains how you can do it. For traditional descriptors (SIFT, SURF) the k-means clustering technique is used because the vocabulary is generated from a set of real valued descriptors. However to obtain a binary vocabulary, k-means method is not ideal because mean is not defined in binary space, then you can use the k-majority method.

Easiest way to cluster binary features in OpenCV is using FLANN with Hamming distance. To my knowledge no example exist, because it would require first fixing a bug in OpenCv's Hamming distance function [ 1 ].
This is my code for it, where cvhack::Hamming<uchar> is a bug-fixed Hamming distance.

    cvflann::KMeansIndexParams params;  
    cv::Mat centres = cv::Mat::zeros(dictionarySize, features.cols, CV_32F);
    int count = cv::flann::hierarchicalClustering<uchar,cvhack::Hamming<uchar>>(features,centres,params);   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM