资源简介

hog特征+svm分类器行人检测训练的负样本处理程序,千万注意路径问题

资源截图

代码片段和文件信息

#include 
#include 
#include  //srand()和rand()函数
#include  //time()函数
#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;

int CropImageCount = 0; //裁剪出来的负样本图片个数

int main()
{
Mat src;
string ImgName;

char saveName[256];//裁剪出来的负样本图片文件名
ifstream fin(“INRIANegativeImageList.txt“);//打开原始负样本图片文件列表
//ifstream fin(“subset.txt“);

//一行一行读取文件列表
while(getline(finImgName))
{
cout<<“处理:“< ImgName = “E:\\运动目标检测\\INRIAPerson\\Train\\neg\\“ + ImgName;

src = imread(ImgName1);//读取图片


//src =cvLoadImage(imagename1);
//cout<<“宽:“<
//图片大小应该能能至少包含一个64*128的窗口
if(src.cols >= 64 && src.rows >= 128)
{
srand(time(NULL));//设置随机数种子

//从每张图片中随机裁剪10个64*128大小的不包含人的负样本
for(int i=0; i<10; i++)
{
int x = ( rand() % (src.cols-64) ); //左上角x坐标
int y = ( rand() % (src.rows-128) ); //左上角y坐标
//cout< Mat imgROI = src(Rect(xy64128)); 
sprintf(saveName“E:\\运动目标检测\\INRIAPerson\\negphoto\\noperson%06d.jpg“++CropImageCount);//生成裁剪出的负样本图片的文件名
imwrite(saveName imgROI);//保存文件
}
}
}

system(“pause“);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-11-24 17:24  CropNegativeSampleFromImage\
     目录           0  2014-11-24 11:17  CropNegativeSampleFromImage\CropNegativeSampleFromImage\
     文件         948  2013-11-06 20:28  CropNegativeSampleFromImage\CropNegativeSampleFromImage.sln
     文件       13312  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage.suo
     文件        1535  2014-11-24 16:36  CropNegativeSampleFromImage\CropNegativeSampleFromImage\CropNegativeSampleFromImage.cpp
     文件        5019  2014-11-24 11:06  CropNegativeSampleFromImage\CropNegativeSampleFromImage\CropNegativeSampleFromImage.vcxproj
     文件         978  2013-11-06 20:40  CropNegativeSampleFromImage\CropNegativeSampleFromImage\CropNegativeSampleFromImage.vcxproj.filters
     文件         143  2013-11-06 20:28  CropNegativeSampleFromImage\CropNegativeSampleFromImage\CropNegativeSampleFromImage.vcxproj.user
     目录           0  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\
     文件         842  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\cl.command.1.tlog
     文件       19230  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CL.read.1.tlog
     文件         578  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CL.write.1.tlog
     文件        2939  2014-11-24 10:34  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.Build.CppClean.log
     文件         406  2014-11-24 10:34  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.exe.embed.manifest
     文件         472  2014-11-24 10:34  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.exe.embed.manifest.res
     文件         381  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.exe.intermediate.manifest
     文件          77  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.lastbuildstate
     文件        3646  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.log
     文件      292046  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.obj
     文件         707  2014-11-24 17:23  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.vcxprojResolveAssemblyReference.cache
     文件           0  2014-11-24 10:34  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage.write.1.tlog
     文件         244  2014-11-24 10:34  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\CropNegativeSampleFromImage_manifest.rc
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link-cvtres.read.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link-cvtres.write.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.10228-cvtres.read.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.10228-cvtres.write.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.10228.read.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.10228.write.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.6888-cvtres.read.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.6888-cvtres.write.1.tlog
     文件           2  2014-11-24 17:24  CropNegativeSampleFromImage\CropNegativeSampleFromImage\Debug\link.6888.read.1.tlog
............此处省略50个文件信息

评论

共有 条评论