1+ import os
2+ import cv2
3+ import sys
4+ sys .path .append ('../' )
5+ from dbr import DynamsoftBarcodeReader
6+ dbr = DynamsoftBarcodeReader ()
7+
8+ def InitLicense (license ):
9+ dbr .InitLicense (license )
10+
11+ def DecodeFileStream (imagePath ):
12+ with open (imagePath , "rb" ) as fread :
13+ total = fread .read ()
14+ results = dbr .DecodeFileStream (bytearray (total ), len (total ))
15+ textResults = results ["TextResults" ]
16+ # intermediateResults = results["IntermediateResults"]
17+ print (len (textResults ))
18+ for textResult in textResults :
19+ print (textResult ["BarcodeFormatString" ])
20+ print (textResult ["BarcodeText" ])
21+ localizationResult = textResult ["LocalizationResult" ]
22+ x1 = localizationResult ["X1" ]
23+ y1 = localizationResult ["Y1" ]
24+ x2 = localizationResult ["X2" ]
25+ y2 = localizationResult ["Y2" ]
26+ x3 = localizationResult ["X3" ]
27+ y3 = localizationResult ["Y3" ]
28+ x4 = localizationResult ["X4" ]
29+ y4 = localizationResult ["Y4" ]
30+ localizationPoints = [(x1 ,y1 ),(x2 ,y2 ),(x3 ,y3 ),(x4 ,y4 )]
31+ print (localizationPoints )
32+
33+
34+ if __name__ == "__main__" :
35+
36+ #you can change the following two variables' value to your own value.
37+ licenseKey = "Input your own license"
38+ fileName = r"D:\Work\Python\python-barcode\images\test.jpg"
39+
40+ InitLicense (licenseKey )
41+ DecodeFileStream (fileName )
0 commit comments