Hi Alex,
you need to pre process the image a little.

First negate it, tesseract expect dark on white background text.

Then use --psm 6 to tell tesseract that this is a single block or text and
not a complex page to split in paragraphs. Also try psm 7, single line.

tesseract --psm 6 cropped_image.jpg -
1.4 95500>0

Now by stretching the contrast (or and OTSU/adaptive threshold) and
straightening the image I get (almost) correct results, see the attached
image.

1 4 9 55 0 5

Ideally you want an image as simple as possible, black text on white
background. You may also try to crop the black border out, if possible.

Have a look here on how to isolate blocks of text:

https://www.pyimagesearch.com/2017/07/17/credit-card-ocr-with-opencv-and-python/
https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/


Bye

Lorenzo



Il giorno sab 13 apr 2019 alle ore 19:36 alex kelly <[email protected]>
ha scritto:

> Hello,
>
> I'm trying to OCR a small grey scale image, its for a energy meter but it
> says the image is to small  - the full response is below:
>
> pi@OCRReader:~ $ tesseract test_images/cropped_image.png out
> Tesseract Open Source OCR Engine v3.04.01 with Leptonica
> Error in pixGenerateHalftoneMask: pix too small: w = 230, h = 50
> Empty page!!
> Error in pixGenerateHalftoneMask: pix too small: w = 230, h = 50
> Empty page!!
>
> How can I make tesseract-ocr read the value?
>
> I can send this to google computer vission API but i would rather do this
> on the device (rather than sending it to the cloud) and I was recommended 
> tesseract.
> If there is a better solution, please let me know.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "tesseract-ocr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/tesseract-ocr.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tesseract-ocr/2314d522-ac6d-4abc-8d17-42a198503b7d%40googlegroups.com
> <https://groups.google.com/d/msgid/tesseract-ocr/2314d522-ac6d-4abc-8d17-42a198503b7d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/CAMgOLLzWRr8FNptY82E9V32-6MhQJs9N9Z1C7rTGO%3DPeUg%3D5ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to