2014-07-24 2 views
1

나는 pytesser 사용하는 경우 (와 이미지 처리 lib 디렉토리를 정팔 포체 - OCR 파이썬에 대한) 실행 : 내가 얻을 결과로메시지

image= Image.open(ImagePath) 
text = image_to_string(image) 
print text 

을 정팔 포체에서 text뿐만 아니라,이 라인 :

Tesseract Open Source OCR Engine v3.02 with Leptonica 

은 내가 image_to_string 기능이 실행될 때이 줄을 실행 생각합니다.

이렇게하면 콘솔에 출력 된 결과물이 실제로 막히게됩니다. 그리고 정말 짜증이납니다. 아무도 그것을 제거하는 방법을 알고 있습니까? 어쩌면 파이썬이나 뭐 그런 줄일까요?

+0

에서 [README 파일에 대한 의견을] 참조 (https://code.google .com/p/pytesser/wiki/README # commentlist) -이 문제를 해결하는 사람들이 게시 한 두 가지 해결 방법이 있습니다. –

답변

1

메인 pytesser 폴더에 pytesser.py 열려 있고이 기능 변경 :

def call_tesseract(input_filename, output_filename): 
    """Calls external tesseract.exe on input file (restrictions on types), 
    outputting output_filename+'txt'""" 
    args = [tesseract_exe_name, input_filename, output_filename] 
    proc = subprocess.Popen(args) 
    retcode = proc.wait() 
    if retcode!=0: 
     errors.check_for_errors() 

def call_tesseract(input_filename, output_filename): 
    """Calls external tesseract.exe on input file (restrictions on types), 
    outputting output_filename+'txt'""" 
    devnull = open(os.devnull, 'w') 
    args = [tesseract_exe_name, input_filename, output_filename] 
    proc = subprocess.Popen(args, stderr=devnull) 
    retcode = proc.wait() 
    if retcode!=0: 
     errors.check_for_errors() 

에 또한 파일의 맨 위에 import os를 추가합니다.

0

debug_file 매개 변수를 설정하여 redirect it to a log file을 시도 할 수 있습니다. 당신이 무엇

+0

정확히 어떻게합니까 ...? – Micro

+1

'api.SetVariable ("debug_file", "tesseract.log")'를'api.Init' 다음에 호출하십시오. – nguyenq

1

프리스트는 설정 파일에게 tessconfigs 다른 곳이 될 수

cat <<CNF >>/usr/share/tessdata/tessconfigs/nobanner 
debug_file /dev/null 
CNF 

주를 생성,/usr/지방/주/tessdata/tessconfigs을 좋아한다.

그런 다음 코드 만 아래에 성공 가지고

tesseract infile.png outprefix -l eng nobanner 
1

명령 줄에서 'nobanner'를 사용 :

tesseract infile.png outprefix 1>/dev/null 2>&1 
+0

ftw. 이것은 간단합니다. 똑바로 작동합니다. –