资源简介
基于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
相关资源
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- opencv环境配置
- win10 64位下编译的opencv4.5.5库,opencv
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- opencv_contrib-3.4.0.zip
- opencv2.4.9源码分析——SIFT
- 用两个摄像头实现,双目标定,双目
- opencv_traincascade训练分类器,手势识别
- opencv3.0交叉编译用parallel.cpp
- 基于opencv的图像识别识别图像中的色
- 基于openCV的识别特定颜色区域
- 基于OpenCV的分水岭算法实现
- QT+opencv+OCR 身份证号码,银行卡号识别
- opencv视频特定颜色区域识别
- 把RGB转换为HSV和HSI然后根据黄色和蓝
- opencv视觉测距
- 基于Qt和opencv的身份证号码识别系统
- opencv_ffmpeg249.dll
- SfM稀疏三维点云重建--完整工程文件
- 基于opencv的数人头程序源代码
- 利用OpenCV中的Stitcher类实现全景图像拼
- opencv实现的sift算法源码,包含了图像
- openCV 上的小波变换
- 基于OPENCV的车牌识别系统设计
- 617张国内车牌60-17bmp图片用于OpenCV正样
- hog特征提取,c版本代码
- 基于Qt5.8+OpenCV3.2的Basler多相机触发开
- 基于Opencv实现的图像纠偏
- ImageWatch2019.vsix
评论
共有 条评论