Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The link you posted, gives one possibilty to solve the issue of binary descriptors by simple conversion to float (CV_32F) and relies on the fact that OpenCV's k-means algorithm can only deal with CV_32F and uses L2-distance for comparison. Thus, the binary descriptors may however also cluster in a wrong way (since actually you want to have a Hamming distance measure)!

Possibilities to circumvent this (however doesn't use the BOWImgDescriptor):

  • Use flann's k-means (HierarchicalClusteringIndexParams, see manual at, it can deal with binary features, however also needs you to convert the data to float (maybe I am wrong with this), at least the output are means in float again, which you need to convert to binary then.
  • Code yourself a k-means which can deal with it or implement a k-medoids algorithm, like PAM, see K-means/median/medoids is not that complicated.