2016-09-20 4 views
0

이미지에서 텍스트를 가져 오기 위해 Python (2.7, Windows OS)과 함께 OCR 스크립트를 작성하려고합니다. 먼저 PyTesser을 다운로드하고 Python27/Lib/site-packages에 'pytesser'로 압축을 풉니 다. pip install tesseract으로 tesseract를 설치했습니다. 그럼 난 self.py로 다음 스크립트 작성 :파일 'tesseract.log'가 없습니다. (Python 2.7, Windows)

from PIL import Image 
from pytesser.pytesser import * 

image_file = 'C:/Users/blabla/test.png' 
im = Image.open(image_file) 
text = image_to_string(im) 
text = image_file_to_string(image_file) 
text = image_file_to_string(image_file, graceful_errors=True) 
print text 

을하지만 다음과 같은 오류를 받고 있어요 :

Traceback (most recent call last): 
    File "C:/Users/blabla/self.py", line 7, in <module> 
    text = image_file_to_string(image_file) 
    File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 44, in image_file_to_string 
    call_tesseract(filename, scratch_text_name_root) 
    File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 24, in call_tesseract 
    errors.check_for_errors() 
    File "C:\Python27\lib\site-packages\pytesser\errors.py", line 10, in check_for_errors 
    inf = file(logfile) 
IOError: [Errno 2] No such file or directory: 'tesseract.log' 

그리고 그래, 어디 더 'tesseract.log'파일이 없습니다. 어떻게해야합니까? 이 문제를 어떻게 해결해야합니까?

미리 감사드립니다.

참고 : 나는 C에 정팔 포체에서 pytesser.py에서 선 tesseract_exe_name을 변경했습니다 :/Python27/lib 디렉토리/사이트 패키지/pytesser/정팔 포체하지만이 작동하지 않습니다.

편집 : 좋아, 난 그냥 'pytesser'에 teseract.exe을 runned했고 그것이 'tesseract.log'파일을 생성하지만 난 여전히 같은 오류가납니다.

답변

0

나는 ../pytesser/errors.pydef check_for_errors(logfile = "C:/Python27/Lib/site-packages/pytesser/tesseract.log"):def check_for_errors(logfile = "tesseract.log"):에서 라인을 변경했습니다 그것은했다.