[英]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.