Hi, I doing a project that load a roadsigns.mat, which a exported from Image Lableler. Can someone help me to fix the error below ?

4 views (last 30 days)
'Error using trainCascadeObjectDetector>parseInputs (line 310) The value of 'positiveInstances' is invalid. Expected input number 2, positiveInstances, to be one of these types: struct, char'
imDir = fullfile('/Users/Anisio/Documents/MATLAB/IMAGE');
%Add the images location to the MATLAB path.
%Specify the folder for negative images.
negativeFolder = fullfile('/Users/Anisio/Documents/MATLAB/IMAGE');
%Train a cascade object detector called 'stopSignDetector.xml' using HOG features. The following command may take several minutes to run:
%Use the newly trained classifier to detect a stop sign in an image.
detector = vision.CascadeObjectDetector('stopSignDetector.xml');
%Read the test image.
img = imread('SpeedCameraSample.jpg');
%Detect a stop sign.
bbox = step(detector,img);
%Insert bounding boxes and return marked image.
detectedImg = insertObjectAnnotation(img,'rectangle',bbox,'stop sign');
%Display the detected stop sign.
%Remove the image directory from the path.

Accepted Answer

Dima Lisin
Dima Lisin on 23 Feb 2016
You should export the ROIs using the "Export" button. That will create a variable in the workspace that you can pass into trainCascadeObjectDetector.
You have saved a labeling session. It is for resuming labeling after a break, not for passing into a function.
Dima Lisin
Dima Lisin on 24 Feb 2016
It looks like one of your negative images may be corrupt. Please check what's in your nonHardHat directory, and make sure you can read all of the images from it into MATLAB with imread.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!