I'm trying to read all data matrixes from an image and write to dataframe. I can print barcode number and location via pylibdmtx but I can't figure out how to store in dataframe
image = cv2.imread('IMG-4951.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
plt.imshow(gray)
ret,thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
msg = pylibdmtx.decode(thresh)
print(msg)
Output:
[Decoded(data=b'01086995460155972150046789702417240229109LB02199', rect=Rect(left=984, top=1172, width=290, height=287)), Decoded(data=b'01086995460155972154702360250417240229109LB02199', rect=Rect(left=899, top=2242, width=279, height=272))]
'msg' variable stored as list with 2 elements in this case and when I try to convert pandas Dataframe 'data' column is blank but 'rect' column is proper like above. (Rect(left=984, top=1172, width=290, height=287))
Dataframe looks like below;
data rect
Rect(left=984, top=1172, width=290, height=287)
Rect(left=899, top=2242, width=279, height=272)
How can I fill data column or any other method do you suggest?
My second question is, this library seems very slow any suggestion how to make it quicker?
Thanks in advance,