资源简介
基于opencv的视觉词袋训练程序,用来提取图片的视觉词典
代码片段和文件信息
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
string tr_img_path = “D:\\image\\train\\“;
int tr_img_num = 200;
Mat tr_image;
vector tr_img_keypoints;
Mat tr_descriptor;
for (int i=1; i<=tr_img_num;i++)
{
char temp[10];
_itoa(i temp 10);
string tr_img_index(temp);
string tr_img_name = tr_img_path + “image“ + tr_img_index + “.jpg“;
tr_image = imread(tr_img_name 0);
CV_Assert(!tr_image.empty() && tr_image.depth() == CV_8U);
Mat descriptor;
//initModule_nonfree();
SIFT mySift(400);
mySift(tr_image Mat()tr_img_keypointsdescriptor);
cout<<“The feature extraction for ----- image “ << tr_img_index<<“ ----- has done!“<
/*ofstream test;
test.open(“d:\\text.txt“);
for (int j=0; jriptor.rows; j++)
{
for (int k=0; kriptor.cols; k++)
{
test<riptor.at(j k)<<“ “;
}
test< }
test.close();*/
tr_descriptor.push_back(descriptor);
}
cout< cout<<“The total number of the descriptors for the training set is “<riptor.rows< cout<<“The dimension of the descriptors for the training set is “<riptor.cols<
cout< cout<<“Start training visual words......“<
BOWKMeansTrainer myBOW(100);
Mat VisualWords;
VisualWords = myBOW.cluster(tr_descriptor);
cout<<“Visual words training finish!“<
FileStorage fs;
fs.open(“VisualWords.xml“ FileStorage::WRITE);
cout<<“1“<
fs<<“VisualWords“< cout<<“2“<
fs.release();
cout<<“Successfully saved to the VisualWords.xml!“<
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 60416 2016-11-16 14:40 1\TestBagofFeatures\Debug\TestBagofFeatures.exe
文件 634716 2016-11-16 14:40 1\TestBagofFeatures\Debug\TestBagofFeatures.ilk
文件 1526784 2016-11-16 14:40 1\TestBagofFeatures\Debug\TestBagofFeatures.pdb
文件 7310 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\BuildLog.htm
文件 186060 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\main.obj
文件 69 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\mt.dep
文件 663 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\TestBagofFeatures.exe.em
文件 728 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\TestBagofFeatures.exe.em
文件 621 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\TestBagofFeatures.exe.intermediate.manifest
文件 691200 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\vc90.idb
文件 978944 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug\vc90.pdb
文件 1806 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\main.cpp
文件 4099 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\TestBagofFeatures.vcproj
文件 1427 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\TestBagofFeatures.vcproj.7136780DB741428.Administrator.user
文件 1413 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\TestBagofFeatures.vcproj.apple-PC.hadoop1.user
文件 220768 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\VisualWords.xm
文件 1166336 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures.ncb
文件 917 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures.sln
..A..H. 9728 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures.suo
文件 766 2016-11-16 14:40 1\TestBagofFeatures\使用说明请参看右侧注释===〉〉.txt
目录 0 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures\Debug
目录 0 2016-11-16 14:40 1\TestBagofFeatures\Debug
目录 0 2016-11-16 14:40 1\TestBagofFeatures\TestBagofFeatures
目录 0 2016-11-16 14:40 1\TestBagofFeatures
目录 0 2016-11-16 14:40 1
----------- --------- ---------- ----- ----
5494771 25
相关资源
- vgg_generated_48,vgg_generated_64,vgg_gene
-
opencv的xm
l文件 - openCV 车牌分割
- 基于OpenCV的模拟仪表指针读数识别系
- 指纹提取与识别系统VC源码opencv
-
Measuring size of ob
jects in an image with - opencv实现两幅图像的极线约束匹配
- 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
评论
共有 条评论