objectMarker正样本采集
在利用Adaboost算法识别物体之前,需要用ObjectMarker标定正样本进行正样本数据的采集。早先别人上传的ObjectMarker不可用,我作了些修改上传,希望对大家有帮助。运行前把正样本图片放在rawdata文件夹下,运行时按空格标定正样本区域,按回车继续下一张图。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-22 15:37 objectMarker
目录 0 2017-02-22 15:37 objectMarkerobjectMarker
文件 1187898 2006-09-12 18:23 objectMarkerobjectMarkerCV.dll
文件 4097 2017-02-22 11:52 objectMarkerobjectMarkerobjectMarker.vcxproj
文件 953 2017-02-22 11:52 objectMarkerobjectMarkerobjectMarker.vcxproj.filters
文件 512070 2006-09-12 18:25 objectMarkerobjectMarkercvaux.dll
文件 512000 2006-09-12 18:23 objectMarkerobjectMarkerhighgui.dll
文件 1906 2017-02-22 13:35 objectMarkerobjectMarkerinfo.txt
文件 3912 2017-02-22 13:29 objectMarkerobjectMarkerobjectmarker.cpp
目录 0 2017-02-22 15:37 objectMarkerobjectMarker
awdata
文件 143402 2017-02-21 22:07 objectMarkerobjectMarker
awdata1_1297_113.430269_34.526398.jpg
文件 4608 2006-11-02 19:49 objectMarkerobjectMarker
awdataThumbs.db
文件 982 2017-02-22 11:49 objectMarkerobjectMarker.sln
文件 20992 2017-02-22 15:20 objectMarkerobjectMarker.v12.suo
#include
#include
#include
// for filelisting
#include
#include
// for fileoutput
#include
#include
#include
using namespace std;
IplImage* image=0;
IplImage* image2=0;
int start_roi=0;
int roi_x0=0;
int roi_y0=0;
int roi_x1=0;
int roi_y1=0;
int numOfRec=0;
char* window_name=“add save and load next exit“;
string IntToString(int num)
{
ostringstream myStream; //creates an ostringstream object
myStream << num << flush;
/*
* outputs the number into the string stream and then flushes
* the buffer (makes sure the output is put into the stream)
*/
return(myStream.str()); //returns the string form of the stringstream object
};
void on_mouse(int event int x int y int flag void* param)
{
if(event==CV_EVENT_LBUTTONDOWN)
{
start_roi=1;
roi_x0=x;
roi_y0=y;
}
if(event==CV_EVENT_MOUSEMOVE && flag==CV_EVENT_FLAG_LBUTTON)
{
roi_x1=x;
roi_y1=y;
//redraw ROI selection
image2=cvCloneImage(image);
cvRectangle(image2cvPoint(roi_x0roi_y0)cvPoint(roi_x1roi_y1)CV_RGB(2550255)1);
cvShowImage(window_nameimage2);
cvReleaseImage(&image2);
}
if(event==CV_EVENT_LBUTTONUP)
{
start_roi=0;
}
}
int main(int argc char** argv)
{
struct _finddata_t bmp_file;
long hFile;
int iKey=0;
// get *.bmp files in directory
if((hFile=_findfirst(“rawdata/*.jpg“&bmp_file))==-1L)
printf(“no *.bmp files in directory ‘rawdata‘
“);
else
{
// init highgui
cvAddSearchPath(“rawdata“);
cvNamedWindow(window_name1);
cvSetMouseCallback(window_nameon_mouse);
// init output of rectangles to the info file
ofstream output(“info.txt“);
string strPrefix;
string strPostfix;
// open every *.bmp file
do
{
printf(“ %-12s
“bmp_file.name);
numOfRec=0;
strPostfix=““;
strPrefix=“rawdata/“;
strPrefix+=bmp_file.name;
image = cvLoadImage(strPrefix.c_str() 1);
// work on current image
do
{
cvShowImage(window_nameimage);
// used cvWaitKey returns:
// =13 save added rectangles and show next image
// =27 exit program
// =32 add rectangle to current image
// any other key clears rectangle drawing only
iKey=cvWaitKey(0);
switch(iKey)
{
case 27:
cvReleaseImage(&image);
cvDestroyWindow(window_name);
return 0;
case 32:
numOfRec++;
// currently two draw directions possible:
// from top left to bottom right or vice versa
if(roi_x0 {
printf(“ %d. rect x=%d y=%d width=%d height=%d
“numOfRecroi_x0roi_y0roi_x1-roi_x0roi_y1-roi_y0);
// append rectangle coord to previous line content
strPostfix+=“ “+IntToString(roi_x0)+“ “+IntToString(roi_y0)+“ “+IntToString(roi_x1-ro
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-22 15:37 ob
目录 0 2017-02-22 15:37 ob
文件 1187898 2006-09-12 18:23 ob
文件 4097 2017-02-22 11:52 ob
文件 953 2017-02-22 11:52 ob
文件 512070 2006-09-12 18:25 ob
文件 512000 2006-09-12 18:23 ob
文件 1906 2017-02-22 13:35 ob
文件 3912 2017-02-22 13:29 ob
目录 0 2017-02-22 15:37 ob
awdata
文件 143402 2017-02-21 22:07 ob
awdata1_1297_113.430269_34.526398.jpg
文件 4608 2006-11-02 19:49 ob
awdataThumbs.db
文件 982 2017-02-22 11:49 ob
文件 20992 2017-02-22 15:20 ob
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)