2

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?

zhfkt
  • 2,415
  • 3
  • 21
  • 24

1 Answers1

4

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)

Community
  • 1
  • 1
deltheil
  • 15,496
  • 2
  • 44
  • 64
  • As the topic you mention, we can only use hashing function in descriptors that can be represented as an array of unsigned char. The unsigned char ranges from 0 to 255,which is not equal to binary 0,1. I am sure the binary descriptor, e.g:(1,0,0,1,0,……), will take effect. But will unsigned char descriptor,e.g: (2,4,1,6,29,255……) , also take effect in the same way? – zhfkt Mar 07 '13 at 12:37
  • 1
    When you work with binary descriptors, the [bit array](http://en.wikipedia.org/wiki/Bit_array) is stored with bytes (8 bits) in practice, e.g. a 512-bit descriptor is represented by a 64-size byte array (`unsigned char`-s). Then [bitwise operations](http://en.wikipedia.org/wiki/Bitwise_operation) are used to manipulate the descriptor at the bit level. – deltheil Mar 07 '13 at 13:19
  • 1
    Aha,that means a byte variable includes 8 binary descriptor,not just includes 1 binary descriptor. – zhfkt Mar 07 '13 at 17:21