r/learnpython • u/Michanix • Nov 14 '17
Reading text from images with Python
Hi, So, I want to build a small project for personal use, that will read text from books covers and write it in to the table like Excel or Sql. For example, I am showing a book cover to camera and written app detect the title of the book, year, author etc. Like detect text on the cover and categorize them, i guess. I already done some researches about that for a couple hours, but I`am still confused what tools do I need and from where I should begin. So, I would appreciate any suggestion or advices about this.
At the moment the list of tools is next: Numpy, MatplotLib,Py-tesseract?, OpenCv(not sure if needed)...
For the record, my software development skills is a little poor, but I am not afraid of teaching new stuff if situation required and learning while building something is more productive for me. So, yeah, thanks in advance for wasting time on me :3
Update: Okay, thank for all responses I got. Just want to clarify one more thing. Do I need to use machine learning to categorize detected data(For example, tell the difference between title and the name of the author at the book cover) or would be enough to have Cv libraries?
1
u/Cpt_TickleButts Nov 14 '17
OpenCV is probably a must unless you know a different library that can read images. What you are trying to do would be image detection, which does require knowledge and libraries that deal with machine learning. I like siraj‘s tutorials on this.
1
u/amall_asaad2 Mar 22 '18
you should learn machine learning to doing that and i have a poster from standford uni that was a final project in it with name (classification of book genres ). but i can't put photo here
1
u/Yoghurt42 Nov 14 '17
OpenCV could be useful for character detection (what part of images are letters), while (py)tesseract would do the character recognition.
OpenCV is not strictly needed, but might be useful for preprocessing. Tesseract is a good OCR, but if you give it a raw color image, the detection rate would be poor. Tesseract works best with 1-bit (grayscale also works, but not as well in my experience) images that are cleaned up from clutter.
My advice would be first to manually preprocess an image you have, and fiddle with it until tesseract can detect the text. Then do it again with another image; once you know which adjustments you have to make, you can either use pillow, if those adjustments are only things like converting into 1-bit image with a given threshold, or OpenCV if you need to do more work (like extracting the part with the text first)