资源简介
在利用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图像数据
相关资源
- 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数据采集卡的驱
- 基于FPGA的彩色线阵CCD图像采集系统设
- 三款4-20ma模拟量采集电路图
- 三款4-20ma模拟量采集电路图详解
- 基于MC68HC908JB8的USB指纹采集仪
- 基于51单片机的多通道数据采集范围控
- 数据采集系统——ADC0808的应用
- 基于CAN总线与ZigBee的瓦斯实时监测及
- CC2530的分布式无线数据采集系统设计
- 基于ZigBee的工业无线数据采集器设计
- 基于ZigBee的油井无线数据采集系统的
- 基于Zigbee的连采工作面机械设备数据
- 论坛帐号批量采集软件V2012_-
- 基于ADS5517的无线数据采集模块设计
- 基于ADS1298与WiFi的脑电信号采集与传输
- 在QT中使用RTP进行视频的采集和传输
- 通过基于电化学发光的检测平台在患
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- 中维JVS-C701/702采集卡驱动 v5.5.1.3 官方
评论
共有 条评论