Ask Your Question
1

How to convert a row of a descriptor to a binary string

asked 2016-03-03 08:03:13 -0500

501 - not implemented gravatar image

updated 2016-03-03 08:03:52 -0500

hello, In openCV I use binary descriptors like ORB and A-KAZE. Now I want to test and perform some matching algorithms, that aren't part of opencv. For this, I want to create a BitString of each row of the descriptor. But there I have some issueas. How are the bits saved in the the mat object?

thank you

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-03-03 10:36:02 -0500

Eduardo gravatar image

To convert to bit stream:

  • get the descriptor type with descriptors.type()
  • iterate over the descriptor matrix
  • convert each element to bit stream using bitset

For example, for ORB descriptor, the desciptor type is CV_8U, the descriptor size is 256 so there are 256/8=32 columns in the matrix.

The corresponding code prints the descriptor values with binary string:

for(int i = 0; i < descriptors.rows; i++) {
  std::string binary_string = "";
  for(int j = 0; j < descriptors.cols; j++) {
    binary_string += std::bitset< 8 >( descriptors.at<uchar>(i,j) ).to_string();
  }
  std::cout << i << ") " << binary_string << std::endl;
}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-03 08:03:13 -0500

Seen: 314 times

Last updated: Mar 03 '16