Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 读取图像并打印出来_Python_Ocr - Fatal编程技术网

Python 读取图像并打印出来

Python 读取图像并打印出来,python,ocr,Python,Ocr,我是python新手,所以我尝试编写一个suduko解算器,以便在完成程序的过程中学习python。 其主要思想是,导入一张图片,让程序读取它,解出suduko,然后打印出答案。我在任何地方都看到过类似的事情,但我无法让程序读取图像并理解所有东西的位置,我尝试了pyterresact,但我得到了很多错误 from PIL import Image import pytesseract im = Image.open("sudukopic.png") text = pytesseract.i

我是python新手,所以我尝试编写一个suduko解算器,以便在完成程序的过程中学习python。 其主要思想是,导入一张图片,让程序读取它,解出suduko,然后打印出答案。我在任何地方都看到过类似的事情,但我无法让程序读取图像并理解所有东西的位置,我尝试了pyterresact,但我得到了很多错误

from PIL import Image

import pytesseract

im = Image.open("sudukopic.png")

text = pytesseract.image_to_string(im, lang = 'eng')

print(text)
这是我收到的错误信息

 Traceback (most recent call last):
 File "C:/Users/Emre/Desktop/Suduko solver/Sudukosolver.py", line 6, 
 in <module>
 text = pytesseract.image_to_string(im, lang = 'eng')
 File "C:\Users\Emre\AppData\Local\Programs\Python\Python36\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\Emre\AppData\Local\Programs\Python\Python36\lib\site-
 packages\pytesseract\pytesseract.py", line 140, in run_and_get_output
 run_tesseract(**kwargs)
 File "C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\site-
 packages\pytesseract\pytesseract.py", line 111, in run_tesseract
 proc = subprocess.Popen(command, stderr=subprocess.PIPE)
 File "C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\subprocess.py",
 line 707, in __init__restore_signals, start_new_session)
 File "C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 990, in _execute_child
 startupinfo)
 FileNotFoundError: [WinError 2] Det går inte att hitta filen
回溯(最近一次呼叫最后一次):
文件“C:/Users/Emre/Desktop/Suduko solver/Sudukosolver.py”,第6行,
在里面
text=pytesseract.image\u to\u字符串(im,lang='eng')
文件“C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\site-
packages\pytesseract\pytesseract.py”,第193行,在图像\u到\u字符串中
返回run_和get_输出(图像,'txt',lang,config,nice)
文件“C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\site-
packages\pytesseract\pytesseract.py”,第140行,在运行和获取输出中
运行_tesseract(**kwargs)
文件“C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\site-
packages\pytesseract\pytesseract.py”,运行\u tesseract中的第111行
proc=subprocess.Popen(命令,stderr=subprocess.PIPE)
文件“C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\subprocess.py”,
第707行,在初始化恢复信号中,启动新会话)
文件“C:\Users\Emre\AppData\Local\Programs\Python\Python36\lib\subprocess.py”,第990行,在\u execute\u child中
startupinfo)
FileNotFoundError:[WinError 2]确定了连接hitta文件的内部数据

我不确定你的意思,但从我的角度看,你似乎在考虑实施一个图像识别程序

我在CNN找到了对初学者非常有用的资源


对于加载图像,我建议使用
imread
from
skimage

指定完整路径。请使用{}按钮阅读并格式化代码。