Creating Haar Cascade from images shows error

狂风中的少年 提交于 2019-12-11 16:36:00

问题


I want to create my own haarcascade for license plates. I have found a GUI called Cascade-Trainer-GUI that does this. I'm using Windows 10. You can download gui from here:

http://amin-ahmadi.com/cascade-trainer-gui/

I have two folders with positive and negative images. There are about 650 positive images and 570 negative images.

When I run the program, it finishes in a couple of seconds, but I do not get cascade.xml file. I get .txt file, and in the end of that txt file it says :

OpenCV Error: Insufficient memory (Failed to allocate 1357715212 bytes) in cv::OutOfMemoryError, file D:\cv\opencv_3.2.0\sources_withTextModule\modules\core\src\alloc.cpp, line 52

I have followed the documentation and I have watched some videos on youtube, but I do not know what am I doing wrong.

These are performance of my PC when I try to train my cascade:

I have tried to clean my disk space and to shut down all other programs so that I can increase my RAM memory but I still get the same error.

I have tried to reduce buffer size from 1024 to 256. In that case it starts working but after 5-6 samples (10 minutes )it shows an error Insufficient Count of Samples, I have tried to reduce parameter number of max features from 100% to 70%, but I get the same error after same time.

You can download the images from here, I have sorted them into positive and negative:

https://www.sendspace.com/file/uo18pu

Do you know what am I doing wrong, what should I do to fix this? What parameters should I choose in this gui?

Also, is there some kind of app that creates haar cascades online?


回答1:


I believe that you problem is due to the size of the image patches used for training. In the original Violaj-Jones paper they used patches of 20x20 pixels, which resulted in more than 180,000 features. To find the best set of features in each stage of the cascade, the boosting algorithm must find the best feature/threshold combination (the weak classifier is a perceptron) in each iteration. This involves to calcule the entropy for N features with M possible thresholds, where M coincides whit the number of training images. Then it is required MxN memory spaces in each boosting iteration. Assuming that internally this program uses floating precision, then you need MxNx4 bytes of memory approximately for each boosting iteration. In you case, for 20x20 image patches this is only 180000x(119+114)x4=167,760,000 bytes, that is, approximately 0.16 GB, but this number may be much larger if the size of the training patches is larger or if the set of base features that you use is larger than the original Violaj-Jones paper (in this paper the set of base features is 4, but there is another set called haar-like) . Then, I believe that you need to configure the size of the image patches of training.



来源:https://stackoverflow.com/questions/58730450/creating-haar-cascade-from-images-shows-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!