What kind of images should I use to train a haarcascade classifier for sad mouth detection to reduce memory use?
1 view (last 30 days)
Show older comments
Michaila Goula on 24 Nov 2015
Commented: Dima Lisin on 11 Dec 2015
I am trying to make a haarcascade classifier using the trainCascadeObjectDetector ( http://www.mathworks.com/help/vision/ref/traincascadeobjectdetector.html ). I want this classifier to detect sad mouths and use it for emotion detection with opencv. I have gathered 1265 possitive images with sad faces and specified the mouths with ROIs using the Training Image Labeler app. I also gathered 12000 negative images with faces having mouths in other positions. All my images are pgm and coloured. When I run the trainCascadeObjectDetector I get a warning "file ended while reading image data." for the negative images folder, after that the procedure starts normally and finally stops with this error: "Error using ocvTrainCascade Error in c:\temp\a3p0_5828a_1708\win64\opencv\modules\core\src\alloc.cpp: Insufficient memory." Do I have to change the format of the photos? Do I need to crop them pointing only the face? Do they need to be grayscale? Or all these will slightly affect the physical memory usage?
Dima Lisin on 24 Nov 2015
Do you have OpenCV installed on your computer? This may be the cause of your error. The Computer Vision System Toolbox ships with its own build of OpenCV. So if you have OpenCV installed separately, trainCascadeObjectDetector may be calling the wrong DLL. If this is the case, I would try uninstalling OpenCV.
Alternatively, you may simply be running out of memory. You could try training with a smaller data set, or you could try using a different feature type. The Haar features use orders of magnitude more memory than HOG or LBP, so using HOG or LBP may help.
There is also an alternative algorithmic approach. You could use the mouth detector that comes with vision.CascadeObjectDetector, and then train a separate classifier to classify the detected mouth as "sad" or "not sad". It should be easier to tell a sad mouth from a non-sad mouth, than a sad mouth from everything else. For instance you could use HOG features and and SVM classifier as shown in this example.
More Answers (0)
Find more on Recognition, Object Detection, and Semantic Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!