Error decoding data matrix code using pylibdmtx in Python

108 views Asked by At

I am trying to decode data matrix qr codes using pylibdmtx. I have below image

enter image description here

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 image is correct but may be something is wrong in the code. Can anyone please help me out. Thanks

0

There are 0 answers