image_to_data returns different results than image_to_string
See original GitHub issueI use image_to_string
for single digits but additionally I want to obtain the confidence value. Therefore I replaced it with image_to_data
like this:
ocrResult = pytesseract.image_to_data(digitBinary, config='-psm 10 -c tessedit_char_whitelist=0123456789', output_type="dict")
digitasNumber = ocrResult["text"][0]
With image_to_string
the results are reasonably good.
With image_to_data
every text
dict entry is empty but for one case, where it returns two digits. the empty digits have conf
-1 and the digit where text
is filled the conf
is 6.
I don’t think that this is intended behavior.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (6 by maintainers)
Top Results From Across the Web
tesseract ocr text: output difference between image_to_string ...
I am doing some OCR using tesseract to recognition text and numbers on a document. I used pytesseract as my python wrapper.
Read more >Pytesseract Behaving Differently In Windows Vs. Linux
Tesseract is an optical character recognition engine for various ... Linux Mac OSX and Windows.. imagetodata returns different results than imagetostring.
Read more >Tesseract OCR in Python with Pytesseract & OpenCV
In OCR software, it's main aim to identify and capture all the unique words using different languages from written text characters. For almost ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The default value is not the real problem here. The problem is that the tsv config is apparently loaded after the config is applied (see my use case in the first post) and overwriting the value. I tried to fix the code by myself but I didn’t manage to make it work so far.
Internally it is currently called like this
but it should be
CLI prints the same output of
image_to_string()
to a.txt
file andimage_to_data()
to a.tsv
file when I gave parameter-c tessedit_create_tsv=1
.The problem is
image_to_string()
output is really good, but it doesn’t have text coordinates.image_to_data()
output has all of the additional data but it shows each word in a seperate field.Let’s say I have an image with
Text: Hello World!
text on it.image_to_string()
returnsText: Hello World!
(or something similar to it) whereimage_to_data()
returns["Text:", "Hello", "World!"]
(basically) and loses spaces between words. I guess I need to concatnate these words manually 😞 This is the difference I’m talking about. The result is same in terms of letters.