OpenCV各个detector/descriptor/matcher的创建和使用

OpenCV里有很多的feature,建立和使用方法也比较杂,现在整理一下避免以后用到。
1、detector 
统一的定义方式:
Ptr    detector= FeatureDetector::create("STAR");
"FAST" – FastFeatureDetector
"STAR" – StarFeatureDetector
"SIFT" – SIFT (nonfree module)
"SURF" – SURF (nonfree module)
"ORB" – ORB
"BRISK" – BRISK
"MSER" – MSER
"GFTT" – GoodFeaturesToTrackDetec tor
"HARRIS" – GoodFeaturesToTrackDetec tor with Harris detectorenabled
"Dense" – DenseFeatureDetector
"SimpleBlob" – SimpleBlobDetector

除了统一定义方式之外,有的可以用它自己的feature名字定义,比如
SurfFeatureDetector detector;
SiftFeatureDetector detector;
FastFeatureDetector detector;
STARFeatureDetector detector;

还有一种统一定义方式:
cv:: Ptr   detector2= cv::Algorithm::create("BRISK");
其中cv::可以去掉。
动态的特征点定义方式:
Ptr detector =
            newDynamicAdaptedFeatureDet ector(
            AdjusterAdapter::create("SURF"), 100, 500, 5);


2、Descriptorextractor
统一定义方式:    Ptrextractor=DescriptorExtractor::create("SURF");
"SIFT" – SIFT
"SURF" – SURF
"BRIEF" – BriefDescriptorExtractor
"BRISK" – BRISK
"ORB" – ORB
"FREAK" – FREAK

个别定义方式:Ptr extractor=new SiftDescriptorExtractor;
Ptrextractor  =newSurfDescriptorExtractor;
Ptrextractor  =newBriefDescriptorExtractor ;
其他定义方式:
  SurfDescriptorExtractor extractor;
SiftDescriptorExtractor extractor;
BriefDescriptorExtractor extractor;
其他的一些特征可以直接定义对象并用来detect和extract特征
比方说 BRISK   BRISKD(60,4,1.0f);
    BRISKD.create("BRISK");
    BRISKD.detect(object,kp_object);
    BRISKD.compute(object,kp_object,des_object);
3、matcher
统一定义方式  Ptr matcher =DescriptorMatcher::create("FlannBased");
BruteForce (it uses L2 )
BruteForce-L1
BruteForce-Hamming
BruteForce-Hamming(2)
FlannBased
其他定义方式:
BFMatcher matcher(type);
normType – One of NORM_L1, NORM_L2, NORM_HAMMING,NORM_HAMMING2. L1 and L2 norms are preferable choices for SIFT andSURF descriptors, NORM_HAMMING should be used with ORB, BRISK andBRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4(see ORB::ORB constructor description).
FlannBasedMatcher matcher;
  • 3
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个基本的使用OpenCV进行3D物体识别的C ++代码示例: ``` #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { // Load the image and convert it to grayscale Mat image = imread("object.png", IMREAD_COLOR); Mat gray; cvtColor(image, gray, COLOR_BGR2GRAY); // Initialize the SURF detector and descriptor Ptr<FeatureDetector> detector = SURF::create(); Ptr<DescriptorExtractor> extractor = SURF::create(); // Find keypoints and compute descriptors vector<KeyPoint> keypoints; Mat descriptors; detector->detect(gray, keypoints); extractor->compute(gray, keypoints, descriptors); // Load the 3D object model Mat objModel = imread("object_model.png", IMREAD_COLOR); Mat objGray; cvtColor(objModel, objGray, COLOR_BGR2GRAY); // Initialize the SURF detector and descriptor for the object model Ptr<FeatureDetector> objDetector = SURF::create(); Ptr<DescriptorExtractor> objExtractor = SURF::create(); // Find keypoints and compute descriptors for the object model vector<KeyPoint> objKeypoints; Mat objDescriptors; objDetector->detect(objGray, objKeypoints); objExtractor->compute(objGray, objKeypoints, objDescriptors); // Match descriptors BFMatcher matcher(NORM_L2); vector<DMatch> matches; matcher.match(descriptors, objDescriptors, matches); // Draw matches Mat imgMatches; drawMatches(gray, keypoints, objGray, objKeypoints, matches, imgMatches); // Display the matches imshow("Matches", imgMatches); waitKey(0); return 0; } ``` 在这个示例中,我们首先加载了一张包含目标物体的图像,并将其转换为灰度图像。然后,我们使用SURF检测器和描述符来找到关键点并计算描述符。接下来,我们加载了一个包含3D物体模型的图像,并执行了相同的操作。最后,我们使用BFMatcher来匹配描述符,并使用drawMatches函数在原始图像和物体模型上绘制匹配。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值