-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenMV注释.txt
103 lines (102 loc) · 2.95 KB
/
OpenMV注释.txt
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import pyb,sensor, image, time, math
from pyb import UART
import ujson
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((640, 80))
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
clock = time.clock()
uart = UART(3, 115200)
led = pyb.LED(3)
def barcode_name(code):
if(code.type() == image.EAN2):
return "EAN2"
if(code.type() == image.EAN5):
return "EAN5"
if(code.type() == image.EAN8):
return "EAN8"
if(code.type() == image.UPCE):
return "UPCE"
if(code.type() == image.ISBN10):
return "ISBN10"
if(code.type() == image.UPCA):
return "UPCA"
if(code.type() == image.EAN13):
return "EAN13"
if(code.type() == image.ISBN13):
return "ISBN13"
if(code.type() == image.I25):
return "I25"
if(code.type() == image.DATABAR):
return "DATABAR"
if(code.type() == image.DATABAR_EXP):
return "DATABAR_EXP"
if(code.type() == image.CODABAR):
return "CODABAR"
if(code.type() == image.CODE39):
return "CODE39"
if(code.type() == image.PDF417):
return "PDF417"
if(code.type() == image.CODE93):
return "CODE93"
if(code.type() == image.CODE128):
return "CODE128"
while(True):
clock.tick()
img = sensor.snapshot()
codes = img.find_barcodes()
x=2
for code in codes:
img.draw_rectangle(code.rect())
b = code.payload()
#a = ujson.dumps(b)
#print(b)
uart.write(b+'\r\n')
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(30)
led.off()
time.sleep(30)
led.on()
time.sleep(30)
led.off()
time.sleep(15000)
#pyb.delay(15000)
if b == 'A':
print("货物 9787306039361 已上到货架第1层\r取货人:小明\r联系方式:15627107394\r取件码:016722\r层\r取货人:小明\r联系方式:15627107394\r取件码:016722\r")
elif b == 'B':
print("货物 47002180393378 已上到货架第2层\r取货人:小红\r联系方式:18972107887\r取件码:119078\r层\r取货人:小红\r联系方式:18972107887\r取件码:119078\r")
elif b == 'C':
print("货物 66844060393820 已上到货架第3层\r取货人:小辉\r联系方式:13422107981\r取件码:900173\r")