# Training own classifiers using trainCascadeObjectDetector for face detection

I want to train a cascade classifier to face detect. I read this page. But I wont use trainingImageLabeler app, because I already have face and nonface database sized 24x24. How I use trainCascadeObjectDetector function with my own database?

Is there any example except this you know?

## 3 Answers

If you want to train the classifiers with your own database, you will only need 'trainCascadeObjectDetector' function and feed your images into the proper arguments (Positive, negative images). The output classifier will be in your 'outputXMLFilename' as in traincascadeobjectdetector

trainingImageLabeler is helpful function for classifying positive/negative image. Try this function later when you work with larger database.

• Thanks for giving time. I am feeding images properly and it works, but has very bad performance. I think this function doesnt like images that have small size (like 24x24). Am I right?
– emre
Feb 4 '15 at 15:59
• If I use 24x24 negative image, training takes a few minutes an it ends at stage 3 of 20. So it doesnt give good performance. However I use a variant set of large images as negative example it works better. Why this happens? I have thousands of example images and I want to use these for training.
– emre
Feb 4 '15 at 16:58
• 1. Yes, you are right. We use smaller images just for speed-up the training process. 2. Larger set of negative images will tell the classifier what it should not decide in the wrong way. This will surely help. Feb 4 '15 at 18:52
• The point is, if you appropriately feed the classifier. The results will be improved. Because the algorithm of it is the same. Try the alternate way to go. Feb 4 '15 at 18:56
• I am trying to implement Viola Jones and all articles I read talks about image database that have a same small size. Therefore I think I should use a database like them. At the moment, I confused that which way is the best? What I should to do? Try another function or try large size random negative images?
– emre
Feb 4 '15 at 20:23

I know it is not matlab, but this post about training a 'banana' detector is really great and can give you some tips.

There is a tutorial on how to use trainCascadeObjectDetector in the documentation.