import cv2
import os
import glob
import pandas as pd
from pylibdmtx import pylibdmtx
import xlsxwriter# co de for scanningimg_dir = "C:\\images" # Enter Directory of all images
data_path = os.path.join(img_dir,'*g')
files = glob.glob(data_path)
data = []
result=[]for f1 in files:img = cv2.imread(f1,cv2.IMREAD_UNCHANGED)gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)msg = pylibdmtx.decode(thresh)print(msg)data.append(img)result.append(msg)print(type(result[0]))
I have a lsit of 4 list inside a lists names result .The output of above code is result . The code is intended to read the barcode , but it also provides location which is not required by me .
SO after the above code , I have a output named result , whch gives me ::
[[Decoded(data=b'AZ:HP7CXNGSUFEPZCO4GS5RQPY6XY', rect=Rect(left=37, top=152, width=94, height=97))], [Decoded(data=b'AZ:RCHKBW5WGZE98J7E9853OW4ZHE', rect=Rect(left=40, top=125, width=91, height=95))], [Decoded(data=b'AZ:5Z7HME1FRNAZFINDPTDAOTB9GQ', rect=Rect(left=27, top=112, width=88, height=88))]
so NOW i want ot jsut extract or find The az aprt from the all the single lists and export it to excel.
AZ:HP7CXNGSUFEPZCO4GS5RQPY6XY
AZ:RCHKBW5WGZE98J7E9853OW4ZHE
AZ:5Z7HME1FRNAZFINDPTDAOTB9GQ
I want only the above output and omit all the location details .
I have tried with indexing , but IT's saying lists out of range.
Please helpme.