OpenCV 特征描述
2024-10-08 19:28:18
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp" using namespace cv; void readme(); /** @function main */
int main( int argc, char** argv )
{
if( argc != )
{ return -; } Mat img_1 = imread( argv[], CV_LOAD_IMAGE_GRAYSCALE );
Mat img_2 = imread( argv[], CV_LOAD_IMAGE_GRAYSCALE ); if( !img_1.data || !img_2.data )
{ return -; } //-- Step 1: Detect the keypoints using SURF Detector
int minHessian = ; SurfFeatureDetector detector( minHessian ); std::vector<KeyPoint> keypoints_1, keypoints_2; detector.detect( img_1, keypoints_1 );
detector.detect( img_2, keypoints_2 ); //-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor; Mat descriptors_1, descriptors_2; extractor.compute( img_1, keypoints_1, descriptors_1 );
extractor.compute( img_2, keypoints_2, descriptors_2 ); //-- Step 3: Matching descriptor vectors with a brute force matcher
BruteForceMatcher< L2<float> > matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches ); //-- Draw matches
Mat img_matches;
drawMatches( img_1, keypoints_1, img_2, keypoints_2, matches, img_matches ); //-- Show detected matches
imshow("Matches", img_matches ); waitKey(); return ;
} /** @function readme */
void readme()
{ std::cout << " Usage: ./SURF_descriptor <img1> <img2>" << std::endl; }
最新文章
- Socket.io和Redis写Realtime App 之express初试
- SQL注入的字符串连接函数
- RabbitMQ(五) -- topics
- Java中定义Map常量,List常量
- HttpClient 教程 (A)
- windows和ubuntu下gif动态图片的制作
- 关于man和help的区别
- 使用WITH AS提高性能简化嵌套SQL
- C#基础总结之二循环控制-运算符
- Python入门笔记(11):集合
- 八皇后,回溯与递归(Python实现)
- 1.10 编程之美-双线程下载[double threads to download]
- pivot 与 unpivot 函数是SQL05新提供的2个函数 灰常灰常的实用
- PERCONA-TOOLKIT : pt-ioprofile分析IO情况
- CSAPP(深入理解计算机系统)读后感
- 关于HttpsURLConnection的连接问题
- Objective-C Blocks测试题与解析
- centos java环境搭建
- LINUX服务器搭建和常用配置介绍
- sublime中编辑服务器上的文件