资源简介
在利用Adaboost算法识别物体之前,需要用ObjectMarker标定正样本进行正样本数据的采集。早先别人上传的ObjectMarker不可用,我作了些修改上传,希望对大家有帮助。运行前把正样本图片放在rawdata文件夹下,运行时按空格标定正样本区域,按回车继续下一张图。

代码片段和文件信息
#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‘\n“);
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\n“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\ty=%d\twidth=%d\theight=%d\n“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
文件 143402 2017-02-21 22:07 ob
文件 4608 2006-11-02 19:49 ob
文件 982 2017-02-22 11:49 ob
文件 20992 2017-02-22 15:20 ob
- 上一篇:单片机控制GSM模块实现温度数据的远程采集及传输
- 下一篇:极化SAR图像数据
相关资源
- labview中的DAQ助手采集多个通道电压
- 数据采集系统——ADC0808的应用,单片
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- AD7606采集程序
- CY7C68013A固件程序(用于摄像机采集)
- 基于AT89C51的数据采集系统设计新方法
- 基于delphi的声卡采集程序.rar
- stm32通过DMA方式采集ADC数据
- opencv环境配置
- 创龙C66x平台GigE工业相机图像采集案例
- win10 64位下编译的opencv4.5.5库,opencv
- 全自动采集getshell工具
- LabVIEW 数据采集 模拟量+编码器(Daq
- LabVIEW 声音信号的采集与存储.vi
- 多通道数据采集.vi(labview)
- 基于LabVIEW的声卡声音采集与播放
- 基于labVIEW的虚拟数据采集与输出仿真
- VS1053B编解码器的VDR分布式声音采集卡
- TMEIC TMdrive-MVGC 高压变频器手册.pdf
- 杰奇小说连载系统采集器V1.1
- 基于STM32的嵌入式双目图像采集系统设
- 用ARM7和UC/OS-II设计的信号采集系统
- 一种用ARM7+UC/OS-II设计的信号采集系统
- LSI 3ware 6Gb提高视频采集和编辑的吞吐
- EasyCAP SM-USB 007采集卡驱动 官方版
- NI 6221用户手册
- 基于LabVIEW的并行数据采集系统设计
- 基于V4L2的视频采集,能够采集YUVJPE
- TD-SCDMA网络测试仪中E1数据采集卡的驱
评论
共有 条评论