[英]train Cascade ObjectDetector matlab
我问我如何使用trainCascadeObjectDetector,而我已经创建了一个由文件名和绑定框坐标组成的正smples结构。 我也有一个负的示例图像文件。 但是当我将功能作为流程
trainCascadeObjectDetector('newDetector.xml', str, negativeFolder, 'FalseAlarmRate', 0.2, 'NumCascadeStages', 5);
我有这个错误:
Error using trainCascadeObjectDetector>parseInputs (line 306)
Argument 'POSITIVE_INSTANCES' failed validation with error:
Cannot find struct field 'imageFilename' in POSITIVE_INSTANCES.
Error in trainCascadeObjectDetector (line 161)
parser = parseInputs(varargin{:});
正如错误本身所言,str不包含名为imageFilename
的字段,该字段应该是图像文件所在的字段。 引用matlab文档:
POSITIVE_INSTANCES是带有正实例信息的结构数组。 struct字段是:imageFilename-指定图像名称的字符串。 图像可以是IMREAD支持的任何格式的真彩色,灰度或带索引的图像。
objectBoundingBoxes - An M-by-4 matrix of [xy width height] bounding boxes specifying object locations.
因此,您的str
参数应该是具有此信息的结构数组,即(file1有3个框,file2 2和file3 4):
str = struct('imageFileName',{'file1Path', 'file2Path', 'file3Path'},...
'objectBoundingBoxes',{[xBox1 yBox1 w1 h1;xBox2 yBox2 w2 h2;xBox3 yBox3 w3 h3]...
[xBox1 yBox1 w1 h1;xBox2 yBox2 w2 h2],...
[xBox1 yBox1 w1 h1;xBox2 yBox2 w2 h2;xBox3 yBox3 w3 h3,xBox4 yBox4 w4 h4]});
或您要声明的任何其他方式。 但是请确保您以这种格式输入文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.