首页 理论教育 如何创建训练样本配置文件?

如何创建训练样本配置文件?

时间:2023-06-25 理论教育 版权反馈
【摘要】:number_of_samples存放样本数,根据实际情况填写,本次采集了185个正样本,就设置为185。max_x_rotation_angle、max_y_rotation_angle、max_z_rotation_angle表示绕xyz轴的旋转量。sample_width、sample_height指样本图像的宽度和高度,一般保持w和h一致。根据以上opencv_createsamples工具的用法,输入训练样本配置文件的路径,就可以生成vec文件与负样本列表文本文件:opencv_createsamples.exe-info C:\Users\Administrator\Desktop\data\positive\info.dat-vec;C:\Users\Administrator\Desktop\data\mysamples_1024.vecnum 185-bgcolor 0-bgthresh 0-w 24-h 24执行情况如下所示,生成了vec文件与负样本列表文本文件。Done.Created 185 samples上述指令执行完毕后,会在所设定的目录下生成指定名称的vec文件:C:\Users\Administrator\Desktop\data\mysamples_1204.vec

如何创建训练样本配置文件?

通过描述文件的图片列表清单来创建训练样本,需要使用OpenCV的opencv_createsamples工具。进入opencv工作目录下的build/x64/vc14/bin子目录,在此路径下调出cmd命令行,键入opencv_createsamples.exe并直接回车,即可启动。使用前,可先查看opencv_createsamples工具的用法和参数设置情况,如下所示:

其中,collection_file_name指收集的文件,vec_file_name指通过opencv_createsamples工具生成的vec文件名。background_file_name是指背景文件名,根据实际情况选择使用或者不用。number_of_samples存放样本数,根据实际情况填写,本次采集了185个正样本,就设置为185。background_color指背景颜色,可以根据实际情况选择使用或者不用。max_x_rotation_angle、max_y_rotation_angle、max_z_rotation_angle表示绕xyz轴的旋转量。sample_width、sample_height指样本图像的宽度和高度,一般保持w和h一致。

根据以上opencv_createsamples工具的用法,输入训练样本配置文件的路径(本次训练正负样本都放在在桌面下data中),就可以生成vec文件与负样本列表文本文件:

opencv_createsamples.exe-info C:\Users\Administrator\Desktop\data\positive\info.dat-vec;C:\Users\Administrator\Desktop\data\mysamples_1024.vecnum 185-bgcolor 0-bgthresh 0-w 24-h 24

执行情况如下所示,生成了vec文件与负样本列表文本文件。如果正负样本文件数目较少,可以尝试使用-img参数,将一张图片通过扭曲形变成多张图片作为样本,参数的内容为待扭曲的图片的路径。

Info file name:C:\Users\Administrator\Desktop\data\positive\info.dat

Img file name:(NULL)

Vec file name:C:\Users\Administrator\Desktop\data\mysamples_1204.vec

BG file name:(NULL)

Num:185

BG color:0

BG threshold:0

Invert:FALSE

Max intensity deviation:40(www.xing528.com)

Max x angle:1.1

Max y angle:1.1

Max z angle:0.5

Show samples:FALSE

Width:24

Height:24

Max Scale:-1

RNG Seed:12345

Create training samples from images collection…

Done.Created 185 samples

上述指令执行完毕后,会在所设定的目录下生成指定名称的vec文件:

C:\Users\Administrator\Desktop\data\mysamples_1204.vec

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈