I am trying to train a cascade object detector in MATLAB using the built in functionality from the Computer Vision Toolbox.
I’ve taken 500 photo’s of the sole of my shoe. Every photo is taken from the same angle, so there is very little shifting in rotation and scaling from all of the images.
For the negative images I am using 500 photo’s of the background that is behind the shoe in the positive images.
The reason I am using the background as the negative photo’s is to train the classifier to overlook the background.
After I train the cascade classifier with these positive and negative images and apply it to another image of my shoe (taken from the same angle as one of the positive images) the detector does not detect the shoe!
What am I doing wrong?
Here are two of the photo's I am using for the negative and positive image (with bounding box shown).
Here is the code I have written that performs this task:
% Load Positive Images with Bounding Boxes from the "Training Image Labeler App"
data = positiveInstances;
% Load Negative Images
negativeFolder = fullfile('C:\shoes\neg');
% Train Detector
trainCascadeObjectDetector('detector.xml', data, negativeFolder);
% Use Detector
detector = vision.CascadeObjectDetector('detector.xml');
test_image = imread('C:\shoes\test.jpg');
bbox = step(detector, test_image);
detectedImage = insertObjectAnnotation(test_image, 'rectangle', ...
bbox, 'shoe');
figure;
imshow(detectedImage)