Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5224

Python • Need help for read numbers from a picture

$
0
0
I have a digital thermometer and I want to read the temperature it reads using OCR, extracting it from an image of the display thermometer. I have tried easyOCR and pytesseract but both give me problems, the last script I have tried is:

Code:

import numpy as npimport pytesseractimport cv2pytesseract.pytesseract.tesseract_cmd = "/usr/local/lib/python3.7/dist-packages/pytesseract/pytesseract.py"BGR = cv2.imread('chktemp.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)
and it gives me the following error and I don't go any further.

Code:

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.7/dist-packages/pytesseract/pytesseract.py'

Does anyone have a script that works for what I want.
I'm using Raspberry Pi 3 B+ with "Raspbian GNU/Linux 10 (buster)"
Thanks in advance

Statistics: Posted by joseplaselva — Fri Jul 19, 2024 12:15 pm



Viewing all articles
Browse latest Browse all 5224

Trending Articles