[英]Using featuredescriptors like ORB, Fast, Brsik with OpenCv 3.2
I´m quite new to OpenCV
. 我是OpenCV
新手。 I followed this tutorial for searching an object in a picture and I was able to run the code successfully. 我按照本教程搜索图片中的对象,因此能够成功运行代码。
While I was searching, I saw that there are more options for feature matching (eg Fast
, ORB
or BRISK
). 在搜索时,我发现有更多用于功能匹配的选项 (例如Fast
, ORB
或BRISK
)。 So I decided to try a different descriptor than SURF
. 所以我决定尝试使用不同于SURF
描述符。
But I'm having trouble. 但是我有麻烦了。 What do I have to do to create a different descriptor? 我要做什么才能创建不同的描述符? Can someone help me, maybe with a code example for OpenCV3.2
? 有人可以帮我,也许有一个OpenCV3.2
的代码示例? :) :)
This is a link that I have found while searching, but sadly it is not for OpenCV 3.2
. 这是我在搜索时找到的链接 ,但不幸的是,它不是针对OpenCV 3.2
。
With OpenCV 3 a consistent feature detection API was introduced. 使用OpenCV 3,引入了一致的功能检测API。
That is, every feature detector implements a static create() method which returns a cv::Ptr to the respective detector. 也就是说,每个特征检测器都实现一个静态的create()方法,该方法将cv :: Ptr返回到相应的检测器。
Here's a quick example which shows the described behaviour: 这是一个简短的示例,它描述了所描述的行为:
#include <iostream>
#include <vector>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp>
int main(int argc, char *argv[])
{
if(argc > 1) {
cv::Mat img = cv::imread(argv[1], cv::ImreadModes::IMREAD_GRAYSCALE);
if(!img.empty()) {
cv::Ptr<cv::xfeatures2d::SiftFeatureDetector> siftDetector = cv::xfeatures2d::SiftFeatureDetector::create();
cv::Ptr<cv::BRISK> briskDetector = cv::BRISK::create();
std::vector<cv::KeyPoint> siftKeypoints;
std::vector<cv::KeyPoint> briskKeypoints;
siftDetector->detect(img, siftKeypoints);
briskDetector->detect(img, briskKeypoints);
std::cout << "Detected " << siftKeypoints.size() << " SIFT keypoints." << std::endl;
std::cout << "Detected " << briskKeypoints.size() << " BRISK keypoints." << std::endl;
return 0;
} else {
std::cout << "Unable to load image, aborting." << std::endl;
return -1;
}
}
std::cout << "A path to an (image) file is missing." << std::endl;
return -1;
}
Following this sample you're able to use each of OpenCV's detectors, which are in the latest docs: 遵循此示例,您可以使用最新文档中的每个OpenCV检测器:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.