1

Here is my code. i am trying to apply an OCR on a racing image.

im = Image.open("runners_1.jpg") # the second one 
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('temp2.jpg')
text=pytesseract.image_to_string(Image.open('temp2.jpg','r'),config="--psm 
8")
print(text)

and facing this error

Traceback (most recent call last):
File "face_detection.py", line 27, in <module>
text = pytesseract.image_to_string(Image.open('temp2.jpg','r'),config="--psm 
8")
File "C:\Users\salmankazmi\Anaconda3\lib\site- 
packages\pytesseract\pytesseract.py", line 193, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File "C:\Users\salmankazmi\Anaconda3\lib\site- 
packages\pytesseract\pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\salmankazmi\Anaconda3\lib\site- 
packages\pytesseract\pytesseract.py", line 111, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Users\salmankazmi\Anaconda3\lib\subprocess.py", line 707, in 
__init__
restore_signals, start_new_session)
File "C:\Users\salmankazmi\Anaconda3\lib\subprocess.py", line 990, in 
_execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied

Line 27 is the call to this "image_to_string" function

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • I suspect it's `Image.open('temp2.jpg','r')` failing to read that file. try to read it on a separate line and check. – 9000 Apr 06 '18 at 19:12
  • Possibly related https://stackoverflow.com/questions/28528020/why-am-i-getting-windowserror-error-5-access-is-denied#28528104 – Adonis Apr 06 '18 at 19:15
  • i did run it as administrator and getting this error now FileNotFoundError: [WinError 2] The system cannot find the file specified on the same line – Syed Salman Kazmi Apr 06 '18 at 20:11

0 Answers0