我需要从照片中提取url的代码,但错误FileNotFound不停止显示我 输入:
`from PIL import Image, ImageEnhance, ImageFilter
from pytesseract import image_to_string
from pytesseract import image_to_boxes
im = Image.open("oic.png")
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('temp2.jpg')
text = image_to_string(Image.open('temp2.jpg'))
print(text)`
输出:
Traceback (most recent call last):
File "V:\Project\***********\Exstract url form photo\test tow.py", line 170, in <module>
text = image_to_string(Image.open('temp2.jpg'))
File "C:\Users\fahad\AppData\Roaming\Python\Python38\site-packages\pytesseract\pytesseract.py", line 346, in image_to_string
return {
File "C:\Users\fahad\AppData\Roaming\Python\Python38\site-packages\pytesseract\pytesseract.py", line 349, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\fahad\AppData\Roaming\Python\Python38\site-packages\pytesseract\pytesseract.py", line 262, in run_and_get_output
with open(filename, 'rb') as output_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\fahad\\AppData\\Local\\Temp\\tess_mizb9wo_.txt'
你能帮我吗
确保您已经安装了所有依赖项和库
tesseract
、image
和pytesseract
之后,您需要为您的图像放置完整路径。例如,假设您的图像位于
/Users/Desktop
。请参见下面的示例:这就是为什么会出现错误
File not found
。刚刚在这里测试了代码,一切正常相关问题 更多 >
编程相关推荐