import cv2 as cv
import pytesseract
from PIL import Image
import sys
pytesseract.pytesseract.tesseract_cmd = r'C:\Tesseract\tesseract.exe'
def recognize_text(image):
blur = cv.pyrMeanShiftFiltering(image, sp=8, sr=60)
gray = cv.cvtColor(blur, cv.COLOR_BGR2GRAY)
binary = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 11, 2)
test_message = Image.fromarray(binary)
text = pytesseract.image_to_string(test_message, config='--psm 7 -c tessedit_char_whitelist=0123456789')
return text
src = cv.imread(r'C:\yanzhengma\tupian\7364.jpg')
if src is None:
print("无法读取图像文件,请检查文件路径")
sys.exit(1)
else:
result = recognize_text(src)
print(result)
Why can I run this code in VsCode and get the output.But there is no output in Power Automate?