欢迎来到天天文库
浏览记录
ID:38220781
大小:14.08 KB
页数:8页
时间:2019-06-06
《BOW-SURF影像检测》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、BOW-SURF天安门影像检测#include"stdafx.h"#include"highgui.h"#include"opencv2/objdetect/objdetect.hpp"#include"opencv2/highgui/highgui.hpp"#include"opencv2/imgproc/imgproc.hpp"#include"opencv2/legacy/legacy.hpp"#include"opencv2/nonfree/features2d.hpp"#include"opencv2/ml/ml.hpp"#include"opencv2/cor
2、e/core.hpp"#include"opencv2/contrib/contrib.hpp"#include#include"features2d(2).hpp"#include"opencv.hpp"#include"features2d.hpp"#include#includeusingnamespacestd;usingnamespacecv;/*************SURF训练,SURF提取********************/voidmain(intargc,char**argv){DWORD
3、start_time=GetTickCount();//结果输出CStringdata;CStringOutData;CStringOutData_result;CStringResultPath=_T("E://temp//result//BOW_SURF_result.txt");CFilefile(ResultPath,CFile::modeCreate
4、CFile::modeWrite);file.SeekToBegin();file.Write("xffxfe",2);MatsrcImage1=imread("E:\temp\天安门.bmp");Mat*
5、srcImage2=newMat[100];intminHessian=1000;SURFdetector(minHessian);std::vector*train_keyPoint2=newstd::vector[21];SURFextractor;Mat*train_descriptor2=newMat[21];charimagepath[100];charmatchResult[100];inttiananmen_tiananmen_count=0;inttiananmen_qita_count=0;intqita_tian
6、anmen_count=0;intqita_qita_count=0;//训练得到BOW特征训练集detector.detect(srcImage1,train_keyPoint2[0]);extractor.compute(srcImage1,train_keyPoint2[0],train_descriptor2[0]);for(ints=1;s<21;s++){sprintf_s(imagepath,"E:\temp\天安门(%d).jpg",s);srcImage2[s]=imread(imagepath);if(!srcImage1.data
7、
8、!srcIm
9、age2[s].data){printf("读取检测图片%d错误",s);}//训练影像特征检测detector.detect(srcImage2[s],train_keyPoint2[s]);extractor.compute(srcImage2[s],train_keyPoint2[s],train_descriptor2[s]);}for(ints=21;s<100;s++){sprintf_s(imagepath,"E:\temp\其它(%d).jpg",s-20);srcImage2[s]=imread(imagepath);if(!srcImage1.da
10、ta
11、
12、!srcImage2[s].data){printf("读取检测图片%d错误",s);}}BOWKMeansTrainerbowTraining(100);//定义聚类中心1000个,其余的默认参数;for(inti=0;i<21;i++)bowTraining.add(train_descriptor2[i]);Matdictionary=bowTraining.cluster();//ObtaintheBoFdescriptor//FlannBasedMatcher*matcher=newstd::vector
此文档下载收益归作者所有