-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
46 lines (39 loc) · 1.11 KB
/
test.py
File metadata and controls
46 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import cv2
from dbr import *
import sys
import os.path
def readBarcode(fileName):
types = {
0x3FFL: "OneD",
0x1L : "CODE_39",
0x2L : "CODE_128",
0x4L : "CODE_93",
0x8L : "CODABAR",
0x10L : "ITF",
0x20L : "EAN_13",
0x40L : "EAN_8",
0x80L : "UPC_A",
0x100L: "UPC_E",
0x200L: "INDUSTRIAL_25",
0x2000000L: "PDF417",
0x8000000L: "DATAMATRIX",
0x4000000L: "QR_CODE"
}
initLicense("D426ABF246933C82A16D537FC46C064F")
frame = cv2.imread(fileName, cv2.CV_LOAD_IMAGE_COLOR)
results = decodeBuffer(frame)
if (len(results) > 0):
print "Total count: " + str(len(results))
for result in results:
print "Type: " + types[result[0]]
print "Value: " + result[1] + "\n"
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Please add a file path"
sys.exit()
fileName = sys.argv[1]
if not os.path.isfile(fileName):
print "File not found"
sys.exit()
print "OpenCV version: " + cv2.__version__
readBarcode(fileName)