I have changed the script as follow and runs vithout error, but the result is incomprehensible :the picture 'text.jpg' is : a 3 digits 7 segments led red on a black background showing 19.9 and the result is :
Code:
import numpy as npimport pytesseractimport cv2pytesseract.pytesseract.tesseract_cmd = r"/usr/bin/tesseract"BGR = cv2.imread('test.jpg')RGB = cv2.cvtColor(BGR, cv2.COLOR_BGR2RGB)lower = np.array([175, 125, 45], dtype="uint8")upper = np.array([255, 255, 255], dtype="uint8")mask = cv2.inRange(RGB, lower, upper)img = cv2.bitwise_and(RGB, RGB, mask=mask)gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)gray = 255 - grayemp = np.full_like(gray, 255)emp -= grayemp[emp==0] = 255emp[emp<100] = 0gauss = cv2.GaussianBlur(emp, (3,3), 1)gauss[gauss<220] = 0text = pytesseract.image_to_string(gauss, config=' --psm 6')print(text)
Code:
=================== RESTART: /home/pi/TEST-READ NUMBERS.py ===================1 Qn ay 71 SS -4;hf Py) og EG || lf |Yo oo oy
Statistics: Posted by joseplaselva — Fri Jul 19, 2024 4:18 pm