PROGRAMMING / TECHNOLOGY / ARTIFICIAL INTELLIGENCE
Image To Text in 5 Lines Of Python
Or… How to extract text from images easily
--
Optical Character Recognition (OCR) used to be thought of as Artificial Intelligence — now it is sublimely easy to do on your local machine.
Image to Code
This is the image that I wanted to convert to text:
The first way to do this is straightforward, involves no coding, and is quick
Do it through Google Docs
Upload the file into Google Docs and the right click the image and select Open with
-> Google Docs
The result is a two-page document — one with the image in it — and the second with the converted text.
The text came out —however, it is unreadable.
Time To Get To The Code
I booted up pycharm (you can get the community edition here)
and pasted this code:
I was missing a few of the components namely cv2
and pytesseract
which were underlined in red.
A quick right-click on the offending import