How to locate and read Data Matrix code with python

前端 未结 2 1160
孤城傲影
孤城傲影 2021-02-15 21:57

I\'m trying to read a datamatrix barcodes on the bottom of microtubes. I tried libdmtx which has python bindings and works reasonably well when the dots of the matrix are square

2条回答
  •  清酒与你
    2021-02-15 22:53

    For python 3 compatibility you need to modify the above code as this:

    contours, hierarchy = cv2.findContours(thr.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 
    areas = map(lambda x: cv2.contourArea(cv2.convexHull(x)), contours)  
    areas = list(areas)  
    max_i = areas.index(max(areas))
    

提交回复
热议问题