资源简介
用于生成机器学习正样本的标注工具,内含使用说明和图片格式批量转换工具(bat文件)
代码片段和文件信息
#include “cv.h“
#include “cvaux.h“
#include “highgui.h“
// 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 eventint xint yint flag)
{
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/*.bmp“&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(bmp_file.name1);
// 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-roi_x0)+“ “+IntToString(roi_y1-roi_y0);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-03-27 14:13 ob
文件 312118 2003-06-05 15:11 ob
文件 1187898 2006-09-12 18:23 ob
文件 512070 2006-09-12 18:25 ob
文件 512000 2006-09-12 18:23 ob
文件 0 2019-03-27 14:07 ob
文件 15 2019-03-26 17:22 ob
文件 3867 2003-06-09 12:38 ob
文件 520281 2003-06-10 12:54 ob
目录 0 2019-03-26 16:00 ob
文件 6220854 2019-03-26 16:00 ob
文件 4608 2006-11-02 19:49 ob
文件 1293 2003-06-18 20:43 ob
文件 312 2019-03-27 14:12 ob
- 上一篇:rtmp+nginx实现rtmp直播
- 下一篇:PIC CCS C编译器使用手册
相关资源
-
ob
ject Detection in 20 Years A Survey总结汇 -
Evolutionary Algorithms for Solving Multi-ob
- 设计模式中文版Design Patterns:Elements
- 深入浅出设计模式中文版高清 pdf
-
ob
jectmarker样本生成工具 - Dlib各种组件
-
各版本的ob
jectARX Wizards for AutoCAD 文 -
ob
jectSNMP -
pdfob
jectTest - IOS图书管理系统
-
ob
jective-C基础教程第2版源代码 - ARX二次开发精粹
-
SuperMap ob
jects .NET 保存和另存地图 -
AutoCAD ob
jectARXVC开发基础与教程201 - 目标检测经典论文
-
Multiob
jective Problem Solving from Nature - 1000幅 MSRA图像数据集1000幅含真实标注
-
OOD启思录 ob
ject Oriented Design Heurist -
Remob
jects Remoting SDK for Delphi - 9.0.97 -
AutoCAD2000ob
jectArx编程指南(电子书及 -
Effective ob
jective-C 2.0 中文版 -
ob
ject-c编程之道pdf+源码(适合进阶 - MSRA图像数据集1000幅含真实标注
- 缓冲区查询
-
高清彩版 Effective ob
jective-C 2.0 -
SuperMap ob
jects .NET 淹没分析 -
ob
jectARX 自定义实体 源码 -
ob
jective-C Programming The Big Nerd Ranch -
AutoCAD ob
jectARX(VC)开发基础与教程 -
ob
jectArx通过Jig拖动绘制自定义实体
评论
共有 条评论