关键点描述符OpenCV [英] KeyPoint descriptor OpenCV

查看:165
本文介绍了关键点描述符OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解如何在OpenCV中获取给定KeyPoint的描述符.到目前为止,我的代码如下:

I am trying to understand how to get the descriptor for a given KeyPoint in OpenCV. So far my code looks like follows:

#include <iostream>
#include "opencv2/opencv.hpp"

typedef cv::Mat Image;

int main(int argc, const char * argv[])
{

    Image imgA = cv::imread("images/buddhamulticam_total100.png",
                              CV_LOAD_IMAGE_GRAYSCALE);
    Image imgB = cv::imread("images/buddhamulticam_total101.png", 
                            CV_LOAD_IMAGE_GRAYSCALE);

    cv::Ptr<cv::FeatureDetector> detector = 
                    cv::FeatureDetector::create("ORB");
    cv::Ptr<cv::DescriptorExtractor> descriptor = 
                    cv::DescriptorExtractor::create("ORB");

    std::vector<cv::KeyPoint> keyPointsA, keyPointsB;

    keyPointsA.push_back(cv::KeyPoint(0,0,5));
    keyPointsB.push_back(cv::KeyPoint(10,10,5));

    cv::Mat descriptorA, descriptorB;
    descriptor->compute(imgA, keyPointsA, descriptorA);
    descriptor->compute(imgB, keyPointsB, descriptorB);

    std::cout << "DescriptorA (" << descriptorA.rows << "," <<
                descriptorA.cols << ")" << std::endl;
    std::cout << "DescriptorB (" << descriptorB.rows << "," 
              << descriptorB.cols << ")" << std::endl;
    return 0;
}

问题是我在描述符中没有数据.我想念什么? 您能否更详细地解释传递给KeyPoint对象的参数是什么?我是计算机视觉+ OpenCV的新手,所以可能有一个比OpenCV的文档更好的解释.

The problem is that I am getting no data in the descriptor. What am I missing? Could you explain in more detail what are the params passed to the KeyPoint object? I am new to computer vision + OpenCV, so probably a better explanation (than OpenCV's documentation) could help.

推荐答案

您试图在点(0,0)和(10,10)上进行ORB运算,但是它们太靠近图像边界,因此ORB无法在这些位置计算描述符. ORB(以及其他二进制描述符)将它们过滤掉.

You're trying to computer ORB on the points (0,0) and (10,10), but they are too close to the image border, so ORB can't compute descriptors in those locations. ORB (as well as the other binary descriptors) filters them out.

由于您询问了用法,因此我正在编辑答案.您应该传递整个图像.我将其用作:

since you asked about usage, I'm editing the answer. You should pass the whole image. I use it as:

Ptr<FeatureDetector> detector = FeatureDetector::create(detector_name);
Ptr<DescriptorExtractor> descriptor = DescriptorExtractor::create(descriptor_name);

detector->detect(imgK, kp);
descriptor->compute(imgK, kp, desc);

这篇关于关键点描述符OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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