9
I have 30 positive images and 60 negative images. When I tried to run haartraining with 4GB of memory and Quadcore processor, I get this error message:
OpenCV ERROR: Insufficient memory (Out of memory)
in function cvAlloc, cxalloc.cpp(111)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
The command I executed was:
./opencv-haartraining -vec vector/myvector.vec -bg negatives.txt -npos 24 -nneg 55 -mem 2048 -mode ALL -w 86 -h 150
The computer at the time of the tests was using less than 800 MB of memory, but during the execution of the above command, the memory used changes to more than 3GB and more than 1 GB of swap, all in less than 5 minutes of program execution.
Any suggestions of what can be done to solve this problem?
You can have a memory Leak in your code. Or does your code need to allocate all this memory even? It has how to show more of the code?
– Lucas Lima
How big is your myvector.vec? I’ve run haartraining on a 4GB RAM computer for more than 3k images using these parameters: "opencv-haartraining -data Haarcascade -vec samples.vec -bg negatives.dat -nstages 18 -minhitrate 0.999 -maxfalsealarm 0.5 -npos 2032 -nneg 3000 -w 64 -h 128 -nonsym -mem 768 -mode ALL"
– vs06
@Lucasnunes, the library I am using to generate the classifiers is available at: https://github.com/mrnugget/opencv-haar-classifier-training. You may have some memory within it even if you have some memory Leak.
– Elexsandro Rangel dos Santos
@vs06, the file . vec is empty.
– Elexsandro Rangel dos Santos
The file . vec is the file that contains all positive symmetric images. You came to generate it from the application "opencv-createsamples"?
– vs06
Thanks @vs06, several reasons generated over-memory allocation, the first of which I didn’t notice the createsamples errors, and the second reason is that the size and quantity of the positive and negative images were being allocated in memory. Now it’s processing normally.
– Elexsandro Rangel dos Santos