OCR of gas meter

127 views
Skip to first unread message

Martina Ilgon

unread,
Dec 25, 2023, 12:09:12 PM12/25/23
to tesseract-ocr
I'm totally new with Tesseract and its usage and I tried several hours to get a suitable result for the attached web-cam picture of my gas meter. I do use tesseract with the PHP wrapper from here https://github.com/thiagoalessio/tesseract-ocr-for-php and installation and recognition with the given examples work fine. Can anybody give me an advice? Thanks...


18129.jpg

Martina Ilgon

unread,
Dec 25, 2023, 12:29:09 PM12/25/23
to tesseract-ocr
Meanwhile I found some PHP functions to crop the image and change the contrast and brightness. The code is as follows:

// Resize
$thumb = imagecrop($source, ['x' => 830, 'y' => 330, 'width' => 115, 'height' => 30]);

// Filter
imagefilter($thumb, IMG_FILTER_GRAYSCALE);
imagefilter($thumb, IMG_FILTER_BRIGHTNESS, +50);
imagefilter($thumb, IMG_FILTER_CONTRAST, -50);

As a result I got at least a result: 39984

Its still not correct, but better than no identification of any letter...

How can I improve?

image.jpg

Mukul Soni

unread,
Dec 26, 2023, 8:00:42 AM12/26/23
to tesseract-ocr
Hi

Can you provide version of tessaract you are using?
and if you are going to use github library
you can try this code

<?php
require ('vendor/autoload.php');
putenv('TESSDATA_PREFIX=C:\Program Files\Tesseract-OCR\tessdata');
use thiagoalessio\TesseractOCR\TesseractOCR;
use thiagoalessio\TesseractOCR\TesseractOcrException;
try {
    $result = (new TesseractOCR('image.jpg'))->run();
    echo $result;
} catch (TesseractOcrException $e) {
    echo 'Error: ' . $e->getMessage();
}

Tom Morris

unread,
Jan 2, 2024, 8:55:10 PMJan 2
to tesseract-ocr
On Monday, December 25, 2023 at 12:09:12 PM UTC-5 martin...@gmail.com wrote:
I'm totally new with Tesseract and its usage and I tried several hours to get a suitable result for the attached web-cam picture of my gas meter.
 
This has been a pretty common use case over the years. If you search the archives here, you'll find threads going back over a decade.

Tom
Reply all
Reply to author
Forward
0 new messages