资源简介
该代码是在VS2010平台上结合OpenCV编写,对于初学者来说有比较大的帮助。
代码片段和文件信息
#include
#include “opencv2/core/core.hpp“
#include “opencv2/features2d/features2d.hpp“
#include “opencv2/highgui/highgui.hpp“
#include “opencv2/nonfree/nonfree.hpp“
#include
#include
using namespace std;
using namespace cv;
static void help()
{
printf(“\nThis program demonstrates using features2d detector descriptor extractor and simple matcher\n“
“Using the SURF desriptor:\n“
“\n“
“Usage:\n matcher_simple \n“);
}
int main(int argc char** argv)
{
//if(argc != 3)
//{
// help();
// return -1;
//}
Mat img1 = imread(“111.jpg“ CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread(“222.jpg“ CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty() || img2.empty())
{
printf(“Can‘t read one of the images\n“);
return -1;
}
// detecting keypoints
SurfFeatureDetector detector(1000);
vector keypoints1 keypoints2;
detector.detect(img1 keypoints1);
detector.detect(img2 keypoints2);
// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1 descriptors2;
extractor.compute(img1 keypoints1 descriptors1);
extractor.compute(img2 keypoints2 descriptors2);
// matching descriptors
BFMatcher matcher(NORM_L2);
vector matches;
matcher.match(descriptors1 descriptors2 matches);
// drawing the results
namedWindow(“matches“ 1);
Mat img_matches0img_matches1;
drawMatches(img1 keypoints1 img2 keypoints2 matches img_matches0);
//for(int i=0;i //{
// //if(abs((keypoints1[matches[i].queryIdx].pt.y-keypoints2[matches[i].trainIdx].pt.y)>5)
// //{
// //}
// //cout< // Point2f pt1pt2;
// pt1=keypoints1[matches[i].queryIdx].pt;
// pt2=keypoints2[matches[i].trainIdx].pt;
// if(abs(pt1.y-pt2.y)>5)
// {
// matches[i].distance=100;
// }
//}
// drawMatches(img1 keypoints1 img2 keypoints2 matches img_matches1);
// 分配空间
int ptCount = (int)matches.size();
Mat p1(ptCount 2 CV_32F);
Mat p2(ptCount 2 CV_32F);
// 把Keypoint转换为Mat
Point2f pt;
for (int i=0; i {
pt = keypoints1[matches[i].queryIdx].pt;
p1.at(i 0) = pt.x;
p1.at(i 1) = pt.y;
pt = keypoints2[matches[i].trainIdx].pt;
p2.at(i 0) = pt.x;
p2.at(i 1) = pt.y;
}
// 用RANSAC方法计算F
// Mat m_Fundamental;
// 上面这个变量是基本矩阵
vector m_RANSACStatus;
// 上面这个变量已经定义过,用于存储RANSAC后每个点的状态
//m_Fundamental = findFundamentalMat(p1 p2 m_RANSACStatus FM_RANSAC);
Mat m_Fundamental=findFundamentalMat(p1 p2 m_RANSACStatus FM_RANSAC);
cout< // 计算野点个数
int OutlinerCount = 0;
for (int i=0; i {
if (m_RANSACStatus[i] == 0) // 状态为0表示野点
{
OutlinerCount++;
}
}
// 计
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 122368 2018-04-10 15:28 jixianyuesu\Debug\jixianyuesu.exe
文件 733140 2018-04-10 15:28 jixianyuesu\Debug\jixianyuesu.ilk
文件 1231872 2018-04-10 15:28 jixianyuesu\Debug\jixianyuesu.pdb
文件 44957696 2018-04-10 15:27 jixianyuesu\ipch\jixianyuesu-28353e67\jixianyuesu-233a92aa.ipch
文件 76590 2018-03-21 16:16 jixianyuesu\jixianyuesu\1.jpg
文件 59827 2018-04-09 16:39 jixianyuesu\jixianyuesu\11.jpg
文件 71261 2018-04-10 15:28 jixianyuesu\jixianyuesu\111.jpg
文件 83052 2018-03-21 16:16 jixianyuesu\jixianyuesu\2.jpg
文件 75396 2018-04-09 16:40 jixianyuesu\jixianyuesu\22.jpg
文件 97309 2018-04-10 15:29 jixianyuesu\jixianyuesu\222.jpg
文件 8637 2018-04-07 20:30 jixianyuesu\jixianyuesu\3.png
文件 8236 2018-04-07 20:30 jixianyuesu\jixianyuesu\4.png
文件 854 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\cl.command.1.tlog
文件 15956 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\CL.read.1.tlog
文件 628 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\CL.write.1.tlog
文件 3224 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\jixianyuesu.Build.CppClean.log
文件 406 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\jixianyuesu.exe.em
文件 472 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\jixianyuesu.exe.em
文件 381 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\jixianyuesu.exe.intermediate.manifest
文件 100 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\jixianyuesu.lastbuildstate
文件 5925 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\jixianyuesu.log
文件 475470 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\jixianyuesu.obj
文件 0 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\jixianyuesu.write.1.tlog
文件 212 2018-04-10 15:27 jixianyuesu\jixianyuesu\Debug\jixianyuesu_manifest.rc
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
文件 2 2018-04-10 15:28 jixianyuesu\jixianyuesu\Debug\li
............此处省略27个文件信息
相关资源
- Criminisi算法OpenCV程序
- Kinect2.0+Opencv人体骨骼捕捉及绘制Vis
- OPENCV实现相机标定程序
- opencv 实现 meanshift 的目标跟踪
- opencv 的knn的训练数据
- 单高斯背景建模opencv
- opencv高斯滤波模板及其滤波
- 基于OpenCV实现Retinex
- 虹膜识别VC2008+opencv2.3.1源码,改编自
- protobuf-cpp-3.1.0.tar.gz 下载192823
- opencv_xxx.310d.lib
- openCV图像检测资源包
- Opencv 下Cascade Classifier实现人脸识别的
-
opencv车牌识别xm
l文件 - Canny算子源代码
- 双目已知图像坐标求空间坐标opencv
- h264+ffmpeg+opencv开发手册
- opencvjs编译后的文件
- OpenCV图像处理教程 - 贾志刚 课程配套
- boostdesc vgg_generated.zip
- 机器视觉标定板选型表-凯林博
- opencv源程序
- 全景拼接_多张图像拼接(stitching_de
- protobuf-cpp-3.1.0.tar.gz 配置文件
- 图像特征点提取与匹配
- opencv获取图像像素值
- 动作识别 Hu距 SVM opencv2.4.9 VS2013
- createsamples.exe和haartraining.exe及所需d
- opencv车牌识别系统可直接运行
- 基于opencv与yolo的目标识别案例
评论
共有 条评论