简体   繁体   中英

train Cascade ObjectDetector matlab

I'm asking about how can'i use the trainCascadeObjectDetector while i already create a positive smples structre composed of filename and bonding boxes cordinates. Also i hase a negative exemple images file. But when i lnche the function as flow

trainCascadeObjectDetector('newDetector.xml', str, negativeFolder, 'FalseAlarmRate', 0.2, 'NumCascadeStages', 5);

I have this error:

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{:});

As the error itself says, the str does not contain a field called imageFilename , which should be the field where the image files are. Quoting matlab documentation:

POSITIVE_INSTANCES is an array of structs with information about the positive instances. The struct fields are: imageFilename - A string that specifies the image name. The image can be true color, grayscale, or indexed, in any of the formats supported by IMREAD.

 objectBoundingBoxes - An M-by-4 matrix of [xy width height] bounding boxes specifying object locations. 

So, your str argument should be a array of structs with this information, ie (file1 has 3 boxes, file2 2 and 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]});

Or any other way you want to declare it. But be sure that you input files in this format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM