use subprocess.call to call ocr (#4448)

This commit is contained in:
Frédéric Péters 2014-03-12 12:37:02 +01:00
parent b4367e4386
commit 7139a92d25
1 changed files with 4 additions and 2 deletions

View File

@ -41,8 +41,10 @@ def process(cfg, filename, payload, enable_ocr=True):
os.write(fd, payload)
os.close(fd)
print >> sys.stderr, ' running OCR on file'
os.system('abbyyocr9 -rl French -if %s -f PDF -pem ImageOnText -pfpr 150 -pfq 100 -of %s' % \
(tmpfilename, ocr_filename))
subprocess.call(['/opt/ABBYYOCR9/abbyyocr9',
'-rl', 'French', '-if', tmpfilename,
'-f', 'PDF', '-pem', 'ImageOnText', '-pfpr', '150',
'-pfq', '100', '-of', ocr_filename])
if not os.path.exists(ocr_filename):
print >> sys.stderr, 'failed to OCR %s' % filename
file('/tmp/' + filename, 'w').write(payload) # keep it for inspection