How to locate and read Data Matrix code with python

前端 未结 2 2026
花落未央
花落未央 2021-02-15 21:58

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:51

    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))
    

提交回复
热议问题