Viola and Jones gives very bad results

3 views (last 30 days)
Hi,
I trained Viola and Jones on a new class using the following simple code:
DBdir='C:\DB\cars-cut';
list=dir(DBdir);
negativeFolder = 'C:\Program Files\MATLAB\R2013a\toolbox\vision\visiondemos\non_stop_signs';
for ix=3:length(list)
im=imread(fullfile(DBdir,list(ix).name));
data(ix-2).imageFilename=list(ix).name;
data(ix-2).objectBoundingBoxes=[ 1 1 size(im,2) size(im,1)];
end
addpath(DBdir);
trainCascadeObjectDetector('cars.xml', data, negativeFolder, 'FalseAlarmRate', 0.0001, 'NumCascadeStages', 5);
Now, I'm testing this model on new images using the following simple code:
detector = vision.CascadeObjectDetector('cars.xml');
detector.MinSize=[60 60];
detector.MergeThreshold=50;
testDir='C:\DB\carstest200\carstest200';
list=dir(testDir);
for ix=3:length(list)
img=imread(fullfile(testDir,list(ix).name));
bbox = step(detector, img);
close all;
if ~isempty(bbox)
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, 'flower');
f=figure; imshow(detectedImg);
saveas(f,fullfile('C:\carsResults50',list(ix).name),'jpg');
end
end
I'm getting very bad results. The detector keeps missing the cars and labels other object and areas in the image.
Is there anything I'm doing wrong. Can someone please guide me in this problem? What do I need to do to get a good VJ detector?
Any help will be greatly appreciated as I'm quite stuck in this problem.
Thanks in advance,
Gil.
  2 Comments
Gil
Gil on 5 Aug 2013
Any suggestion on other methods for cars detection will be also useful. Thanks!!
RAMESH SEJPAL
RAMESH SEJPAL on 17 Jan 2014
How can we generate and add xml file? and what type of content can we add? can we add image? please help.......

Sign in to comment.

Accepted Answer

Anand
Anand on 23 Sep 2013
There could be a bazillion things wrong...who knows! You're going to have to do some digging here.
Here are a couple of things to try/watch out for:
1. Check how you're doing on the training set itself. Do you get poor results on the training data or is it better there? If you're doing poorly on the training set, it may mean you're doing something wrong. If you're doing too well on it, you may have over-fitted to the training set.
2. Have you tried different feature descriptors? How do the results vary with LBP or HOG?
3. What makes you think you need 5 cascade stages? Why not 3, why not 10, why not the default of 20?
4. It could be that the dataset is too noisy. Maybe you need to preprocess the images so the cascade object detector can get a more standardized set of images to learn from.
5. Have you looked at this page on how to train cascade object detectors?
There's a lot of information in there that could be useful.
Hope this helps!
  3 Comments
RAMESH SEJPAL
RAMESH SEJPAL on 16 Jan 2014
HI ,I am also working for car detection ,Please would you help me ,how can I use viola and Jones algorithm for car detection?
Anand
Anand on 29 Jan 2014
You need a data set of images of cars with bounding boxes for positive training and a set of images for negative training. Use these with the link in the above answer and you should be on your way.

Sign in to comment.

More Answers (2)

tahani
tahani on 9 Nov 2013
Hi, Can you help me please to find the matlab file in viola and jones algorithm (in 2013 matlab vision toolbox) which extracts features (haar, lbp or hog). this is in order to be able to change its continue aiming at using my own features.
thank you in advance
  3 Comments
RAMESH SEJPAL
RAMESH SEJPAL on 17 Jan 2014
@Anand , In Xml file what type of content should we add for the detector?
Anand
Anand on 29 Jan 2014
If you're using the trainCascadeObjectDetector function, you don't need to add any content to the XML file. The function populates the XML file. You then use this XML file to create a detector, like so:
detector = vision.CascadeObjectDetector('xmlfilejustcreated.xml');
bbox = step(detector,new_img);

Sign in to comment.


lourdes ramirez
lourdes ramirez on 29 Mar 2014
Did you find the training algorithm because I'm looking too.

Community Treasure Hunt

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

Start Hunting!