-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (53 loc) · 1.45 KB
/
main.py
File metadata and controls
63 lines (53 loc) · 1.45 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import cv2
import qr
import colour_detection
import navigate
import time
import serial
video = cv2.VideoCapture(0)
colour,stop='',False,
Ser = serial.Serial("/dev/ttyACM0", baudrate=9600)
Ser.flush()
while True:
flag, frame = video.read()
if not flag:
_, frame = video.read()
cv2.imshow("QR",frame)
print("\n\n--------------Waiting for QR Code--------------\n\n")
if(colour==''):
colour=qr.read(frame)
else:
print("\n\n--------------Start:",colour,"--------------\n\n")
print("--------------Please Remove the QR code--------------")
cv2.destroyWindow("QR")
break
if cv2.waitKey(10) & 0xFF == ord('q'):
video.release()
cv2.destroyAllWindows()
break
time.sleep(1)
#rotate in place
while True:
flag, frame = video.read()
if not flag:
_, frame = video.read()
try:
d=navigate.nav(frame)
Ser.write(bytes(d,'utf-8'))
except:
print("Track Not Visible")
if Ser.inWaiting>0:
Ser.write(b"S")
Ser.write(b"X ")
stop=colour_detection.detect(frame,colour)
if(stop==True):
print("\n\n--------------Stop--------------\n\n")
if Ser.inWaiting>0:
Ser.write(b"S")
video.release()
cv2.destroyAllWindows()
break
if cv2.waitKey(1) & 0xFF == ord('q'):
video.release()
cv2.destroyAllWindows()
break