Issue
import cv2
import pytesseract
import ast
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR'
img=cv2.imread("number_1.jpg")
img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
new_array=[]
arr=pytesseract.pytesseract.image_to_string(img)
try :
arr = ast.literal_eval(arr)
except:
arr=arr.split("\n")
arr =list(filter(None, arr))
for i in arr:
i=i.split(",")
for j in i:
j =int(j)
new_array.append(j)
arr=new_array
cv2.imshow("result",img)
cv2.waitKey(0)
I am getting a permission error when trying to convert the list of texts in the picture to a list in python. I don't have to do this test this way, but it happened when I tried it yesterday, but it didn't work today.
Traceback (most recent call last):
File "C:\Users\ayano\OneDrive\Masaüstü\tesseract_detect_text\main.py", line 14, in <module>
arr=pytesseract.pytesseract.image_to_string(img)
File "C:\Users\ayano\OneDrive\Masaüstü\tesseract_detect_text\lab_interpreter\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string
return {
File "C:\Users\ayano\OneDrive\Masaüstü\tesseract_detect_text\lab_interpreter\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\ayano\OneDrive\Masaüstü\tesseract_detect_text\lab_interpreter\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\ayano\OneDrive\Masaüstü\tesseract_detect_text\lab_interpreter\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\ayano\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\ayano\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Erişim engellendi
Solution
I found the solution. I extracted the 22mb file size named "eng.traineddata" to an external folder .that is to the folder named tesseract-ocr.
Answered By - izmirlikezzap
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.