c++ - 如何在 OpenCV 中创建描述符矩阵

标签 c++ c opencv image-processing feature-descriptor

如何在 OpenCV 中创建一个描述符,该描述符可以通过以下方式与 OpenCV 中的 DescriptorMatcher 之一一起使用。

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

我已经有了以下描述符类。如何转换或创建可与 DescriptorMatcher 一起使用的新矩阵。最好是 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;
    }
};

最佳答案

我只是在寻找有关同一问题的答案时访问这里。 但很快我发现答案很简单,你只需要做一个垫子。

例如,下面是一些类似 SIFT 的描述符。

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

关于c++ - 如何在 OpenCV 中创建描述符矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22506500/

相关文章:

python - 是否可以对多个图像使用 cv2.HoughCircles 函数?

c++ - 表示范围所需位的编译时计算

C++ getline(cin, str) 给我额外的行

c - 如何在没有遇到 EOF 时终止 read()?

c - 如何为 char 字符串中的位获取和设置位?

c++ - 使用 opencv 数据结构进行图像平滑

c++ - Qt (OSX) 和 OpenCV 错误

c++ - 如果,否则产生错误C2181 : illegal else without if

c++ - 质数保理,无 IO

Clock() 没有按预期工作;避免IO