Ask Your Question
0

How to populate a custom binary feature descriptor in opencv?

asked 2018-08-13 21:44:15 -0600

updated 2018-08-13 23:27:06 -0600

I have a binary vector generated for each keypoint as its description. I would like to create my own binary descriptor matrix. I understand that descriptors are just matrices. Binary descriptor is a matrix with depth CV_8U. Below is my code to create the matrix. But is there an easy way to populate it?

//I have 4096 bit data for descriptor. So 4096/8=512 will be my bytes   
cv::Mat descriptors;    
int bytes_ = 512;  
descriptors.create((int)keypoints.size(), bytes_ , CV_8U);

I have the binary data in the form of four 32X32 binary images. How do I encode this data into the descriptor matrix? Is it the right way if I read 8 pixels at a time and convert them into a single uchar (byte) and then use it as my descriptor matrix element? Later, I want to use this descriptor with opencv's DescriptorMatcher to match the descriptors.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-14 02:15:53 -0600

berak gravatar image

you''re already close. your create function won't work, but there is a Mat constructor for this, like:

Mat descriptors;
for ( each keypoint ) {
    uchar *bytes_ = ???
    Mat descriptor_row(512, 1, CV_8U, bytes_ );
    descriptors.push_back(descriptor_row);
}

then, match with BFMatcher/HAMMING or FlannBasedMatcher/LSHIndex

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-08-13 21:28:48 -0600

Seen: 303 times

Last updated: Aug 14 '18