openalpr / train-detector

Input files and scripts necessary to train the license plate detector.
GNU Affero General Public License v3.0
125 stars 166 forks source link

How does the train-detector work? #27

Closed zhouhao27 closed 6 years ago

zhouhao27 commented 6 years ago

I run the following command, but nothing happened.

./prep.py neg

It only shows: Neg. Then nothing happened. May I know what should I include in raw-neg folder?

But when I run:

./prep.py pos

Pos
/usr/local/Cellar/opencv/3.4.1_5/bin/opencv_createsamples -vec /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec -w 70 -h 50 -info /Users/xxx/Projects/ocr/train-detector/positive/positive.txt -num 1
Info file name: /Users/xxx/Projects/ocr/train-detector/positive/positive.txt
Img file name: (NULL)
Vec file name: /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec
BG  file name: (NULL)
Num: 1
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 70
Height: 50
Max Scale: -1
RNG Seed: 12345
Create training samples from images collection...
Done. Created 1 samples

Only 1 samples created. Is this correct?

zhouhao27 commented 6 years ago

I managed to make the prep.py pos work like this:

/usr/local/Cellar/opencv/3.4.1_5/bin/opencv_createsamples -vec /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec -w 70 -h 50 -info /Users/xxx/Projects/ocr/train-detector/positive/positive.txt -num 349
Info file name: /Users/xxx/Projects/ocr/train-detector/positive/positive.txt
Img file name: (NULL)
Vec file name: /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec
BG  file name: (NULL)
Num: 349
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 70
Height: 50
Max Scale: -1
RNG Seed: 12345
Create training samples from images collection...
Done. Created 349 samples

It seems 349 samples created.

My command to train:

/usr/local/Cellar/opencv/3.4.1_5/bin/opencv_traincascade -data /Users/xxx/Projects/ocr/train-detector/out// -vec /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec -bg /Users/xxx/Projects/ocr/train-detector/negative/negative.txt -w 70 -h 50 -numPos 349 -numNeg 4705 -maxFalseAlarmRate 0.45 -featureType LBP -numStages 13

Then I got the following result after training stage 0:

PARAMETERS:
cascadeDirName: /Users/xxx/Projects/ocr/train-detector/out//
vecFileName: /Users/xxx/Projects/ocr/train-detector/positive/vecfile.vec
bgFileName: /Users/xxx/Projects/ocr/train-detector/negative/negative.txt
numPos: 349
numNeg: 4705
numStages: 13
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: LBP
sampleWidth: 70
sampleHeight: 50
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.45
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
Number of unique features given windowSize [70,50] : 328440

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   349 : 349
NEG count : acceptanceRatio    4705 : 1
Precalculation time: 16
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3| 0.997135| 0.233369|
+----+---------+---------+
END>
Training until now has taken 0 days 0 hours 3 minutes 38 seconds.

===== TRAINING 1-stage =====
<BEGIN
OpenCV(3.4.1) Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
) in get, file /tmp/opencv-20180529-55469-97fkx6/opencv-3.4.1/apps/traincascade/imagestorage.cpp, line 158
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.1) /tmp/opencv-20180529-55469-97fkx6/opencv-3.4.1/apps/traincascade/imagestorage.cpp:158: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

[1]    50492 abort      /usr/local/Cellar/opencv/3.4.1_5/bin/opencv_traincascade -data  -vec  -bg  -w

I reduce the numPos. It only works when numPos = 1. Any idea? Thanks.

alucard079 commented 5 years ago

@zhouhao27 I followed your repo, and I received this error

screenshot from 2019-01-07 22-54-28

`

alucard079 commented 5 years ago

Hello, how did you fixed this issue? img_20190131_104446