如何在OpenCV中创建描述符矩阵 [英] How to create a descriptor matrix in OpenCV

查看:318
本文介绍了如何在OpenCV中创建描述符矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在OpenCV中创建一个描述符,可以按照以下方式与OpenCV中的描述符计算器之一一起使用。

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 );

我已经有了下面的描述符类。如何转换或创建一个可以与DescriptorMatcher一起使用的新矩阵。最好是BFMatcher。

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;
    }
};


推荐答案

我只是在寻找同样的问题。
但是很快我发现答案很简单,所有你需要的是做一个Mat。

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.

例如,下面是一个SIFT-LIKE描述符。

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 );

这篇关于如何在OpenCV中创建描述符矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆