2
$\begingroup$

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).

enter image description here

enter image description here


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)
$\endgroup$
10
  • $\begingroup$ What feature detectors are you using? What cascade detector are you using? Also, showing some code would go along way. If you just want to detect that shoe by itself then what you're doing will work. It may be a problem with something in your code than your overall method. $\endgroup$
    – rayryeng
    Commented Jul 16, 2014 at 14:08
  • $\begingroup$ Here is the code I am using: % Load Positive 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); $\endgroup$
    – user8919
    Commented Jul 18, 2014 at 7:28
  • $\begingroup$ Please edit your question to include this code. Placing code in comments that is more than a couple of lines doesn't look very nice. $\endgroup$
    – rayryeng
    Commented Jul 18, 2014 at 7:29
  • $\begingroup$ I'm very sorry about my code above. I couldn't get it in the proper format fast enough to edit it. Can someone fix it? As for the code, I am using the built in training app to put the bounding boxes around each shoe, and saving the data in positiveInstances, which I use in the first line of the code. $\endgroup$
    – user8919
    Commented Jul 18, 2014 at 7:31
  • $\begingroup$ I will place an edit. $\endgroup$
    – rayryeng
    Commented Jul 18, 2014 at 7:37

0