[Jocr-devels] gocr in python
Status: Alpha
Brought to you by:
joerg10
From: Carl K. <ca...@pe...> - 2006-08-26 00:15:54
|
My goal is to rename an image file based on some text in the file. also to get more python experience. I am trying to use api's instead of os.system() calls. libgocr is an attempt to create a library that have all functionality that you may need to develop a OCR engine. http://jocr.sourceforge.net/api/ (not sure this is what I want) I am using a business card's phone number as an example, but the real files will all have a consistent label (they are photos of widgets with a ID card in front of them, much like a mug shot.) Step 3: ocr the phone number image into text. gocr -i phone.png 773.338.4000 >>> os.system( 'gocr -C "0123456789" phone.png' ) 773.338.4000 I hear I will be better off using: >>> p = subprocess.Popen( ["echo", "hello"], stdout=subprocess.PIPE ) >>> p.stdout.read() 'hello\n' Except that trying to use it with gocr errors: >>> p = subprocess.Popen( ["gocr", "-i phone.png"], stdout=subprocess.PIPE ) ERROR pnm.c L118: opening file so I am looking for any of the following: A) trap sdtout from os.system B) get subprocess.Popen to work, then I can use p.stdout.read() C) use the gocr api, if it exists. |