I'm trying to read a matrix from an image but I'm having problems with non-spaced numbers. I need to read line by line and make it into an array. I need to detect numbers true first.
Here is my code and output:
import cv2
import pytesseract
myString = ""
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
matris_image = cv2.imread('matris23.png')
matris_image = cv2.cvtColor(matris_image, cv2.COLOR_BGR2RGB)
matris = pytesseract.image_to_string(matris_image)
print(type(matris))
print(matris)
<class 'str'>
9135 2
1117 6
3 7 4 1
6 0 7 10
Process finished with exit code 0
I need output like this:
9 13 5 2
1 11 7 6
3 7 4 1
6 0 7 10