(createsamples.cpp)
" [-info <collection_file_name>]\n" " [-img <image_file_name>]\n" " [-vec <vec_file_name>]\n" " [-bg <background_file_name>]\n [-num <number_of_samples = %d>]\n" " [-bgcolor <background_color = %d>]\n" " [-inv] [-randinv] [-bgthresh <background_color_threshold = %d>]\n" " [-maxidev <max_intensity_deviation = %d>]\n" " [-maxxangle <max_x_rotation_angle = %f>]\n" " [-maxyangle <max_y_rotation_angle = %f>]\n" " [-maxzangle <max_z_rotation_angle = %f>]\n" " [-show [<scale = %f>]]\n" " [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n"//默认24*24以下1)~4)是按顺序判断,且有且仅有一个
1)提供imagename 和vecname时,调用以下操作/* * cvCreateTrainingSamples * * Create training samples applying random distortions to sample image and * store them in .vec file * * filename - .vec file name * imgfilename - sample image file name * bgcolor - background color for sample image * bgthreshold - background color threshold. Pixels those colors are in range * [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent * bgfilename - background description file name. If not NULL samples * will be put on arbitrary background * count - desired number of samples * invert - if not 0 sample foreground pixels will be inverted * if invert == CV_RANDOM_INVERT then samples will be inverted randomly * maxintensitydev - desired max intensity deviation of foreground samples pixels * maxxangle - max rotation angles * maxyangle * maxzangle * showsamples - if not 0 samples will be shown * winwidth - desired samples width * winheight - desired samples height */2)提供imagename、bgfilename和infoname时
与1)类似
3)提供 infoname和 vecname时,调用以下操作(这里是我们训练需要的)
/* * cvCreateTrainingSamplesFromInfo * * Create training samples from a set of marked up images and store them into .vec file * infoname - file in which marked up image descriptions are stored * num - desired number of samples * showsamples - if not 0 samples will be shown * winwidth - sample width * winheight - sample height * * Return number of successfully created samples */ int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename, int num, int showsamples, int winwidth, int winheight )
函数内容:读取当前图中所有标记的sample(x,y,w,h),并将其缩放到winwidth、winheight大小,故在这之前的人为缩放操作不需要
4)仅vecname时,可以将vec里面的所有缩放后的samples都显示出来
/* * cvShowVecSamples * * Shows samples stored in .vec file * * filename * .vec file name * winwidth * sample width * winheight * sample height * scale * the scale each sample is adjusted to(这个scale与3中的缩放不是一回事,这里仅为了显示而再次缩放) */ void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale );
2、opencv_haartraining.exe的参数
(haartraining.cpp )
" -data <dir_name>\n" " -vec <vec_file_name>\n" " -bg <background_file_name>\n" " [-bg-vecfile]\n" " [-npos <number_of_positive_samples = %d>]\n" " [-nneg <number_of_negative_samples = %d>]\n" " [-nstages <number_of_stages = %d>]\n" " [-nsplits <number_of_splits = %d>]\n" " [-mem <memory_in_MB = %d>]\n" " [-sym (default)] [-nonsym]\n" " [-minhitrate <min_hit_rate = %f>]\n" " [-maxfalsealarm <max_false_alarm_rate = %f>]\n" " [-weighttrimming <weight_trimming = %f>]\n" " [-eqw]\n" " [-mode <BASIC (default) | CORE | ALL>]\n" " [-w <sample_width = %d>]\n" " [-h <sample_height = %d>]\n" " [-bt <DAB | RAB | LB | GAB (default)>]\n" " [-err <misclass (default) | gini | entropy>]\n" " [-maxtreesplits <max_number_of_splits_in_tree_cascade = %d>]\n" " [-minpos <min_number_of_positive_samples_per_cluster = %d>]\n"3、opencv_performance.exe参数