I am trying to decode data matrix qr codes using pylibdmtx. I have below image
and using the below code:
import cv2
from pylibdmtx import pylibdmtx
import time
import os
image = cv2.imread('file1.png', cv2.IMREAD_UNCHANGED);
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
t1 = time.time()
msg = pylibdmtx.decode(thresh)
print(msg)
if msg:
print(msg[0].data.decode('utf-8'))
t2 = time.time()
print(t2-t1)
It prints nothing. Is there anything I am missing in the code? I tried some data matrix decoder online, and they were able to decode it so I am sure the image is correct.

print("hello")before the first import, does it still print nothing?printis called later in your script. I wanted to find out what is the last place in the script from which callingprintprints something.