openalpr / train-ocr

Input files and scripts necessary to train the license plate OCR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add trained data for Swiss license plates

maechler opened this issue · comments

We are currently training the Swiss license plate font and I would like to create a pull request out of this. Since Switzerland is surrounded by EU countries, we also need to deal with EU plates. That is why we actually got the best results by adding the Swiss license plate style as an additional font to the EU trained data.
When creating the pull request, should I add the data to eu or create a new config for ch?

I attach the trained data files for anyone interested in using them until this issue is resolved.
The file lch.traineddata contains only the Swiss font data, the file leu.traineddata contains the EU fonts and the Swiss font. Even though our test data only consisted of Swiss license plates we got better results using leu.traineddata.

traineddata.zip

Hie maechler,
Can you help with how to attach our custom fonts to the leu.traineddata.
it would be a great help.

looking forward to hear from you soon.
thanks in advance

@bhavna7 The documentation chapter "Training OCR" tells you how to add your custom fonts: http://doc.openalpr.com/opensource.html#training-ocr

@bhavna7 The documentation chapter "Training OCR" tells you how to add your custom fonts: http://doc.openalpr.com/opensource.html#training-ocr

Hi @bhavna7 , I'm trying to train tessaract for austrian lp, but I have an issue. Could you please spend some time to tell or show us about your approach how you train the data. Especially how did you make the tif file, and how you combine the files for leu.traineddata.
Thanks!

@PetarMG-BG we had a similar discussion starting here: #33 (comment)

Maybe @alucard079 could help you, as he recently used the training tools.

@PetarMG-BG what part are you now?

@alucard079 currently I'm using a tif and box files for austrian lp, provided in some of the treads here.
The problem of this files are the quality of the images. How did you generate them?

@PetarMG-BG markus @maechler provided a train.py for me. I think his code with a minimum revision will make it work.

@PetarMG-BG anw, I recompiled again the openalpr because I reinstalled my linux again, will you help me in compilling it again? I'm having a problem with "make".

@alucard079 what is the error of make?

What exactly do i need to to with that swiss data?

There are many directories:

  • /usr/share/openalpr/runtime_data/config/
    -> There is NO ch.conf !!
  • /usr/share/openalpr/runtime_data/region
    -> There is NO ch.xml
  • /usr/share/openalpr/runtime_data/ocr/tessdata
    -> There is a file leu.traineddata but no lch.traineddata

What are the steps from A-Z so OpenAlpr (Open Sopurce) is able to recognize swiss car numbers?

Thank you for your feedback.

@martijintro

I have not used OpenALPR in a while, so I might be missing something here, but I'll try my best to answer your question.

  1. Download the trained data: traineddata.zip
  2. Decide whether you want to use it for EU and Swiss plates (a) or for Swiss plates only (b):
    a.1. Copy leu.traineddata to runtime_data/ocr/tessdata and overwrite the existing file. Use the regular EU configuration and you are probably done.
    b.1. Copy lch.traineddata to runtime_data/ocr/tessdata
    b.2. Add a file ch.conf to runtime_data/config with the content from below. We use eu.xml for the detector as it works well enough.
    b.3. Add a file ch.patterns to runtime_data/postprocess with the content from below.

runtime_data/config/ch.conf

; Single-line Swiss style plates

; 35-50; 45-60, 55-70, 65-80, 75-90
char_analysis_min_pct = 0.35
char_analysis_height_range = 0.15
char_analysis_height_step_size = 0.10
char_analysis_height_num_steps = 5

segmentation_min_speckle_height_percent = 0.2
segmentation_min_box_width_px = 5
segmentation_min_charheight_percent = 0.4;
segmentation_max_segment_width_percent_vs_average = 2.0;

plate_width_mm = 300
plate_height_mm = 80

multiline = 0

char_height_mm = 55
char_width_mm = 30
char_whitespace_top_mm = 13
char_whitespace_bot_mm = 13

template_max_width_px = 184
template_max_height_px = 46

; Higher sensitivity means less lines
plateline_sensitivity_vertical = 18
plateline_sensitivity_horizontal = 55

; Regions smaller than this will be disqualified
min_plate_size_width_px = 65
min_plate_size_height_px = 18

; Results with fewer or more characters will be discarded
postprocess_min_characters = 3
postprocess_max_characters = 8

detector_file = eu.xml

ocr_language = lch

; Override for postprocess letters/numbers regex. 
postprocess_regex_letters = [ABDEFGHIJLNORSTUVWZ]
postprocess_regex_numbers = [0-9]


; Whether the plate is always dark letters on light background, light letters on dark background, or both
; value can be either always, never, or auto
invert = auto

runtime_data/postprocess/ch.patterns

ch	[ABDEFGHIJLNORSTUVWZ][ABDEFGHIJLNORSTUVWZ]######
ch	[APM]######

thank you very much, will try it!! :-)

and: so i saw, a swiss configuration was not added until now: openalpr/openalpr#881

OpenALPR seems to have a bug with TESSDATA_xxx variable: openalpr/openalpr#882

The only possible way seems to be that:

cp /usr/share/openalpr/runtime_data/ocr/tessdata/leu.traineddata /usr/share/openalpr/runtime_data/ocr

Act of resignation!!!!!!!!!!!!!!

OK, so:

1. wget https://github.com/openalpr/train-ocr/files/1597439/traineddata.zip
2. unzip traineddata.zip
3. cp ./leu.traineddata /usr/share/openalpr/runtime_data/ocr (So NO tessdata directory due to this [CENSORED] bug!!!)
4. alpr -c eu n.jpg -> "No license plates found."

So: Doesn't work, all in all...

I think it's a product strategy to make the opensource version completely unusable, so the people buy it because they are resignated.

I think i'm right with that.

So the OS version is just a decoy, nothing else....!!

And i don't like that strategy. Because it's not honest.

Because of that, now i try it with https://platerecognizer.com, hehe!! :-)

OK thx...