其他分享
首页 > 其他分享> > convert bitset descriptor -> cv::Mat

convert bitset descriptor -> cv::Mat

作者:互联网

bitset转opencv cv::Mat 
注意
(1)Mat 的列为32列,类型为uchar
(2)BRIEF::bitset 的长度为256
(3)每8个构成一个uchar

vector<BRIEF::bitset> temp_brief_descriptors;
extractor(image, keypoints, temp_brief_descriptors);
brief_descriptors_mat=Mat::zeros(brief_descriptors.size(),32,CV_8UC1);
int row=0;
 for(iter = temp_brief_descriptors.begin(); iter!=temp_brief_descriptors.end();iter++)
 {
     BRIEF::bitset bits=*iter;
     for (int i = 0; i < 32; i += 8)
     {
         char ch;
         for (int j = 0; j < 8; ++j)
         {
             if (bits.test(i + j))	// 第i + j位为1
                 ch |= (1 << j);
             else
                 ch &= ~(1 << j);
         }
         brief_descriptors_mat.at<uchar>(row, i)=(uchar)ch;

     }
     row++;
 }

标签:convert,Mat,temp,descriptors,brief,iter,descriptor,bitset
来源: https://blog.csdn.net/ktigerhero3/article/details/104673574