Concerning the speed of opencv_traincascaded.exe

asked 2013-11-06 21:39:07 -0500

cv_new gravatar image

updated 2013-11-07 02:04:55 -0500

berak gravatar image

I am now implementing a project for the pattern recognition and using the opencv's opencv_traincascaded.exe to train a classifier. The background of my project is like this. I have 800 positive image samples and 2090 negative image samples, and the ratio between them is reasonable I guess. All are in jpg format.

I used this command to train the classfier as follows. As I have made a crash during the training, I changed the number of samples from 800 to 600. After that, the program can function properly. Unfortunately, it stops at the stage three and do not make any progress anymore.

A warning is shown: Assertion failed (_step >= minstep) in unknown function, file C:\o penCV_file\opencv\modules\core\include\opencv2/core/mat.hpp, line 143

I have read a lot of posts regarding this issue. But they do not give me a satisfying answer. Hope anyone can help me solve it. Thanks in advance!

Program Code

opencv_traincascade.exe -data dt -vec pos.vec -bg neg/bg.txt -numPos 600 -numNeg 2090 -numStages 20 -precalcValbufSize 1024 -precalcdxBufSize 1024 -featureType LBP -w 160 -h 50

PARAMETERS:

  • cascadeDirName: dt
  • vecFileName: pos.vec
  • bgFileName: neg/bg.txt
  • numPos: 600
  • numNeg: 2090
  • numStages: 20
  • precalcValBufSize[Mb] : 1024
  • precalcIdxBufSize[Mb] : 1024
  • stageType: BOOST
  • featureType: LBP
  • sampleWidth: 160
  • sampleHeight: 50
  • boostType: GAB
  • minHitRate: 0.995
  • maxFalseAlarmRate: 0.5
  • weightTrimRate: 0.95
  • maxDepth: 1
  • maxWeakCount: 100
  • Stages 0-2 are loaded


===== TRAINING 3-stage ===== <begin pos="" count="" :="" consumed="" 600="" :="" 603<="" p="">

edit retag flag offensive close merge delete

Comments

Actually I am guessing the following parameters will generate problems: -w 160 -h 50. Keep your training dimensions small... The training is written in the way that all feature calculation and window resizing is stored in memory. Using these large dimensions will surely crash the training. Try setting it to like -h 32 -w 10 which is a 10x reduction.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-07 04:52:37 -0500 )edit

Someone pointed out that there are some reasons for the program to be crashed.

  1. The ratio between the postive and negative samples. Some agree on the ratio between the +ve:-ve is 3:1, or 7:1, and some agrue that the negative samples should be more.

  2. Depend on the size of memory. It is hard to determine how large the size of memory should be..

  3. The quality of the negative samples, that is, if the quality of negative samples is not high, meaning that the similarity between positive samples and negative samples is not large, the positive detection rate will be 1 and the negative one will be 0 during the training process, which would end up in a dead loop.

cv_new gravatar imagecv_new ( 2013-11-08 04:13:30 -0500 )edit

cont. 3. And it also requires a higher quality of the negative images for the further training, meaning that the correlation between +ve and -ve is too high and the number of samples is too small, it will generate a dead loop as well. It is suggested that the correlation between the +ve and -ve should not be too small and be more specific.

In my case, I have tested different ratio of +ve to -ve.

The size of tested positive samples now is 80 * 25. Number of positive samples || Number of negative samples || Results 100 || 300 || OK 300 || 500 || Failed

cv_new gravatar imagecv_new ( 2013-11-08 04:16:46 -0500 )edit

As far as I know, there is a equation to explain how to calculate the number of positive samples used. But I followed that definition and did not use up all positive samples for each training stage. However, the program still crushed finally.

Besides, as StevenPuttemans mentioned, the size of positive samples should be changed to smaller, but I cannot do so. Such change will make a poor detection rate due to a little positive samples size. Nonetheless, I have halved the positive samples image size to 80*25. The program still get crashed.. Hope someone help me. Thanks!

cv_new gravatar imagecv_new ( 2013-11-08 04:40:29 -0500 )edit

A warning always appears : Branch training terminated.

cv_new gravatar imagecv_new ( 2013-11-08 04:43:32 -0500 )edit