I compiled the dynamic Tesseract library with its dependencies such as Leptonica, libjpeg, libpng, and libturbojpeg for arm64-v8a (.so files).
The Pix for Tesseract was prepared from a captured 8 MP image (after cropping the image to 1595×2121). Next, I applied a sequence of Leptonica filters with the corresponding variables.
- leptonica.pixMedianFilter(
pixs:pix1,
halfWidth = 1,
halfHeight = 1);
- _leptonica.PixConvertRGBToGray(pixs:pix2, rwt = 0.0, gwt = 0.0, bwt = 0.0);
- MorphologicalClosingGray:
- _leptonica.pixErodeGray(pixs:pix3, hsize: 5, vsize: 7)
- _leptonica.pixDilateGray( pixs:pix4, hsize : 5, vsize : 7)
- _leptonica.GammaTRC(
NULL, // for new pix
pixs: pix5,
gamma: 0.7f,
minval : 40,
maxval : 210);
- _leptonica.AdaptiveThresholdSauvola(
pixs: pix6,
whsize:11,
factor:0.15f); The images before and after processing are shown in the photos
leptonicaaddimage and
leptonicaprepareimage, respectively. Sorry, I can’t show the receipt with English words, but the main topic is price recognition (priceselected.jpg). I hope the Russian symbols won’t bother you.
Tesseract configuration
(version 5.5.1-16-g17b4, tessdata from tessdata_best LSTM only)
- Tesseract.TessBaseAPICreate();
- Tesseract.TessBaseAPIInit2(_handle, dataPath, language:"rus", oem:"1");
- Tesseract.TessBaseAPISetPageSegMode(_handle, pageSegMode:"6 or 3");
Variables:
- "user_defined_dpi" = imageWidth/widthOfCheck = 1821/3.15 = 578;
- "tessedit_char_blacklist" = "\"\\|@#$^&_=<>~`{}[]";
- Tesseract.TessBaseAPISetImage2(_handle, pix);
- TesseractNative.TessBaseAPIGetUTF8Text(_handle);
The recognized text:
1721822 Вафли СЛИВОЧНЫЕ ‘РЛОусПеК те ЭГ 99
Зй 2217431 Кокт, мол. ТОП ЛАВ” (клуб- ан?
50
(Н) ' 1842023 Коктейль мол”ТОП”(2%, пломбир, П
50г 2,29
Скидка бонусы Еплюс ‚08
Г! 1350399 Сыр'БРЕСТ-ЛИТОВСК ПОШЕХОНСКИЙ”
200г 4,59
Скидка бонусы Еплюс -0,05
ИТОГО К ОПЛАТЕ 12,05
УТОГО СКИДКА ы 0,13
There are no prices like 2.99 or 2.35 detected, only part of 0.08. The bigger the receipt, the more price numbers are lost.
Can somebody help me figure it out? Thank you.