-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOError for OSD (psm 0) #75
Comments
Do I need to just specify the location of OSD trained data and if so, how do I specify it? |
Hi @movaid7 - thanks for reporting the issue. |
Hi. @int3l. I'm currently running pytesseract v0.1.7 |
Thank you @movaid7 , it looks like I am familiar with your problem. Can I ask you for one favor, please post the names of the pytesseract temp files in your /tmp folder. It seems like the pytesseract logic doesn't handle the tesseract output filenames correctly. We have two PRs for resolving this - #67 and #40. |
Sure. No problem.
|
Nice. Those files are leftovers. Also if you don't need the temp files, can you delete them all and then try to run the error example once. |
Also about your question related to the OSD - OSD information from the Tesseract documentation and Tesseract PSM modes. Basically you should have your osd file in the same dir as the language traineddata file. By the way - try this command and check if tesseract creates txt temp file with the psm 0 option: ret = image_to_string(im, lang='eng', config="-psm 0 txt") |
Deleting the temp files and running the function had no effect on the outcome. The .osd files that are produced are formatted like
The osd above was produced from an inverted picture that was not recognised as such. This is the reason for the low orientation confidence level. Running the command I also tried a 90° rotated picture and ran a command with psm 1 (OSD+OCR) and it worked really well -
|
pytesseract incorrectly looks for txt file, but at the moment this is by design for the image_to_string function. There is no logic that limits the lookup when psm 0 mode is used. I'm not sure if we should alter the logic, because this is a config behavior. If we apply additional control, the new version of the library might be incompatible with some of the existing user code bases. Maybe we can make the library more granular by separating the preparation logic into different functions. This way we can have functions like image_to_osd, image_to_pdf or etc. Or even better - we can add dynamic approach like image_to_file - and you can specify what you want. |
I have the same issue too, but in the same folder of my code, the tmp folder contains nothing. |
No, @chingjunehao The only file created by a psm 0 command is a .osd file that contains osd details, for example:
The issue is that pytesseract is looking for a txt file that never existed. @int3l I do think dedicated functions could be useful but the problem is what do you return for osd only? Just a text dump of the .osd file contents? |
@movaid7 I suggest leaving the image_to_string function as it is (logically) - returning text or raising error exception, when there is no txt file. |
@movaid7 I used the psm 10 which is "Treat the image as a single character." that will return the first character that detected in my image as .png file, but my tmp folder is empty.
#The function in image_to_string
Isn't it, by this, the file supposed to be in the path that I set already?
|
@chingjunehao try to run it with "boxes=False" and see if a txt file was created at either of the two locations (default tmp folder and the one you created within Downloads) |
@chingjunehao you can check, which temp folder path is used currently with the following code: import tempfile
print(tempfile.gettempdir()) That will be the path that pytesseract will pass as tesseract cli arguments. |
Since now we have the more generic functionality with #85, I'm resolving this issue. |
The orientation parameter is not available with image_to_data, right? |
Running pytesseract on Raspbian, python 2.7, tesseract 4.00 (4.00.00dev-625-g9c2fa0d).
My code is as follows:
Error:
If I run code with psm 1 [Recognition with OSD], I receive no errors but the upside down text is simply treated as right-side-up text, producing garbage results. (This was tested on an inverted test.png)
Essentially text recognition works but OSD does not.
The text was updated successfully, but these errors were encountered: