Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Recognize text from picture
-
-
@mikael
é yes
à no -
@cvp, checked, usesLanguageCorrection is true and recognitionLevel set to ”accurate” by default, so no help there.
-
Doesn’t work for Cyrillic (Bulgarian).
-
Eh.
revision = VNRecognizeTextRequest.currentRevision() supported = VNRecognizeTextRequest.supportedRecognitionLanguagesForTextRecognitionLevel_revision_error_(0, revision, None)
Returns ”en-US”.
-
@mikael I had also seen that but it supports French, thus ...buggy?
-
BTW, I'm impressed from accuracy ( for Latin based texts ).
-
@mikael @cvp have you tried setting
customWords
attrib of the request? Or, turn offusesLanguageCorrection
? (Since the language is en-US you DON'T want language correction when trying to detect other languages!)I gather they are looking for words you'd find in an English dictionary. So perhaps façade, or tête-à-tête might recognize, while other examples wouldn't?
-
@JonB I didn't try but we are not alone with this problem, see here.
I've tried with unknown language codes like xx and yy in setRecognitionLanguages_ and the result is the same. It seems that characters are recognized in any languages.
My last test on a French text was entirely correctAsie-Pacifique La mission économique belge en Chine cible de cyberattaques massives
-
@JonB said:
usesLanguageCorrection
Tried with False: à still recognized as a
Edit : even with
req.setCustomWords_(['à'])
-
Is there any code examples of how to recognize text with ios 12.4.3 for the i pad mini 2 that would be cool to add it to my sodoku app game
-
@sodoku, yes, but it seems a bit more involved. Check this thread where @cvp does all kinds of magic.
-
def pil2ui(pil_image): buffer = io.BytesIO() pil_image.save(buffer, format='PNG') return ui.Image.from_data(buffer.getvalue())
is memory leaking buffer which has been proven to crash Pythonista when multiple images are processed. A better approach is to use a context manager to force the .close().
def pil2ui(pil_image): with io.BytesIO() as buffer: pil_image.save(buffer, format='PNG') return ui.Image.from_data(buffer.getvalue())
-
Revisiting this.
Regardless of language restrictions, I have found the simple and reliable ability to pick text from paper to be useful for me almost weekly - URLs, email addresses, reservation codes, laptop serial numbers, etc.
With the use, I noted that the original script had some issues:
- Difficult to find and open when quickly needed.
- Slow to get from the picked photo to recognized text.
- Results are a pain to copy from the Console as it likes to jump around just as you’ve selected the text to copy.
Point #1 was fixed with a simple Apple Shortcuts shortcut to make the script easy to run.
Point #3 was resolved by presenting the recognized text in a TableView, with tap to copy.
Point #2 took a bit more doing.
Pythonista
photos
module wants to return PIL images, and that results in two very slow conversions - first the module converts the UIImage to PIL, and then I converted that back to a PNG image for recognition. I found some @cvp code in this thread and replacedphotos
module withobjc_util
pickers, which return PNG data almost directly.And hey presto! Not just faster recognition, but instantaneous - and with much better quality than with the only contender app I could find (Prizmo Go).
Updated script here.
-
@mikael Thanks for your great 🎁for New Year
-
-
Happy last day of the decade to everyone who shares my calendar!
I finessed the script a bit with the ability to select, copy or share multiple items, and nicer icons.
@cvp, noted and wondered about the lack of the link for your handle, no idea why.
-
Does this work with the new iPad OS ????
-
@sodoku, do you mean if the latest versions have included robust support for non-English characters? Not to my knowledge.
-
So good news I got an iPhone 11 and I’m testing this on it, for sudoku, do the pictures taken save anywhere when used, just curious if I have to delete them because after I use it the pictures don’t show up in my pictures app