Reputation: 1464
I am trying to use Tesseract OCR on Android to read the state of a gas meter when you take a picture of it:
This is the output when I parse this image:
vb"
22% BK-G4T ||||||||I||||I|||ii\|||\
’ 64 2007
22?: 06.0"! 'm'lm Mm. 23212274 ,
v 2,0 dm’ 1
pmn 0_5 bar tm ~25°C v‘40"(1 I
1amp é 0_o1m’ sb15°cl :Sp 20°c l
'I ELSTEQ~I¢¢>>InstrogwnSs HB Z _ 18 _ 1013 . ‘
a, 069373593435- 3 I
i'23212214 Y _ w w V'
g
The idea is to extract the first 5 digits of the state of the gas meter ( 06937 on this image ).
My question is, is there a way to train Tesseract to only parse this part of the image? Absolute coordinates are not an option since every picture would be different. I am guessing the best logic would be something like: parse only white numbers on black background.
Upvotes: 1
Views: 4499
Reputation: 8626
By changing the page segmentation mode (psm)
, tesseract 4.00.00 alpha
is able to read the meter line characters correctly as 06937598-m3
apart from other characters.
The command used is:
tesseract meter.jpg output --psm 11 -l eng
--psm 11
means to recognize "Sparse text. Find as much text as possible in no particular order"
.
Here is the output
file with showing all the ASCII control characters.
If --psm 11
works on other meter images, then you could just need to search -m3
at the end of the line to extract the who meter line characters. With that, you can get the first 5 digits right away.
Hope this help.
Upvotes: 2