我是编码新手,请耐心等待。如果我在Jupyter笔记本和VSCode(Notebook / Python)中在相同的conda环境中运行相同的代码,则会得到不同的结果。
编辑: 我再次尝试,这一次在VSCode中的Jupyter Notebook上显示“没有名为'pytesseract'的模块”。 我快疯了,什么都没有改变,仍然是相同的conda环境
请帮助我理解这一点。先感谢您。代码是:
import pytesseract
import PIL
from PIL import Image
def binarize(image_to_transform):
out_image=PIL.Image.new(image_to_transform.mode, (image_to_transform.width,image_to_transform.height))
for i in range(255):
threshold=i
temp_image=image_to_transform.convert("L")
for x in range(temp_image.width):
for y in range(temp_image.height):
if temp_image.getpixel((x,y))< threshold:
temp_image.putpixel( (x,y), 0 )
else:
temp_image.putpixel( (x,y), 255 )
if len(pytesseract.image_to_string(temp_image))>len(pytesseract.image_to_string(out_image)):
out_image=temp_image
print(pytesseract.image_to_string(out_image))
display(out_image)
return None
binarize(Image.open('readonly/Noisy_OCR.PNG'))