How to create a descriptor matrix in OpenCV

眉间皱痕 提交于 2019-12-12 01:49:43

问题


How do I create a descriptor in OpenCV that can be used with one of the DescriptorMatchers in OpenCV, in the following manner.

cv::BFMatcher matcher( cv::NORM_L2, false );
std::vector< cv::DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );

I already have the following descriptor class. How do I convert or create a new matrix that can be used with a DescriptorMatcher. Preferably BFMatcher.

class Descriptor
{
    public:
    float lxi, lyi; // Location of descriptor
    vector<double> feature;

    Descriptor()
    {
    }

    Descriptor(float x, float y, vector<double> const& f)
    {
         lxi = x;
         lyi = y;
         feature = f;
    }
};

回答1:


I just visit here when looking for the answers about the same question. But soon I found the answer is so simple, all you need is to make a Mat.

For example , below is a some SIFT-LIKE descriptor.

cv::Mat descriptors_1(nQueries, dimemsion, CV_32F,(void*)pQueries);
cv::Mat descriptors_2(m_nDataSets, dimemsion, CV_32F,(void*)m_pData);

cv::FlannBasedMatcher matcher;
std::vector< cv::DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );


来源:https://stackoverflow.com/questions/22506500/how-to-create-a-descriptor-matrix-in-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!