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 http://www.cs.ubc.ca/research/flann/), 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 http://en.wikipedia.org/wiki/K-medoids. K-means/median/medoids is not that complicated.