Search code examples
opencvindexingsiftsurf

Is local sensitive hashing algorithm only compatible with binary descriptors in opencv / flann?


I am trying to use local sensitive hashing algorithm in flann in opencv 2.4.4. Here is my code

Ptr<IplImage> cluster_image = cvLoadImage("C:\\Users\\Administrator\\Pictures\\1.jpg");
vector<KeyPoint> cluster_keypoint;
Mat des;

description_detect(cluster_image,cluster_keypoint,des,SIFT_DESCRIPTION);
//My function to extract the sift feature from image.
//Descriptions are stored at variable des.

flann::Index my_index(des, flann::LshIndexParams(10, 10, 2));

When running this code to build the index of flann by lsh algo. The code assert that

"Opencv Error,unsupported format or combination of formats type=5"

I check code in miniflann.cpp. It seems that local sensitive hashing algorithm in flann are only compatible with CV_8U Mat type,other than CV_32F which is generated by sift.

However, other binary descriptors detected from ORB, Brief, BRISK, FREAK can produce CV_8U Mat type.

So my question is: Is local sensitive hashing algorithm only compatible with binary descriptors in opencv?


Solution

  • Yes: the hashing function is only implemented for binary descriptors (i.e. descriptors that can be represented as an array of unsigned char).

    Please refer to this answer for more details: Binary features and Locality Sensitive Hashing (LSH)