forked from Hollyqui/PyStalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManager.py
66 lines (50 loc) · 1.81 KB
/
Manager.py
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
import time
from Drone_Net import Drone_Net
from Drone_Net_Test import Drone_Net_Test
from Movement_Processing import Move_drone
from Movement_Processing import Movement_processing
from pyparrot_modified.pyparrot.Bebop import Bebop
from pyparrot_modified.pyparrot.DroneVisionGUI import DroneVisionGUI
while True:
test_mode = input("Would you like to use the test mode? (Y/N): ").capitalize()
if(test_mode == "Y"):
test_mode = True
break
elif(test_mode == "N"):
test_mode = False
break
else:
print("Invalid input, enter either 'Y' or 'N'")
# this object computes the motion and then feeds it to
# 'Move_drone' which then actually moves the drone accordingly
process = Movement_processing()
# creates the bebop object and connects to it
bebop = Bebop()
success = bebop.connect(5)
# creates the object that moves the drone
move = Move_drone(bebop, process, success)
# creates the GUI that will initiate the video stream
# if testing is true video is streamed from the webcam (this has to be used
# in combination with Drone_Net_Test as the network
vision = DroneVisionGUI(bebop, move=move, process=process, is_bebop=True,
user_args=(bebop,), testing=test_mode)
# initialises neural net
if(test_mode):
net = Drone_Net_Test(vision=vision, process=process)
else:
net = Drone_Net(vision=vision, process=process)
vision.feed_net(net)
move.feed_net(net)
# starts the thread in which the network starts the
# the object detection
net.start()
# waits for the network to start up before starting the vision stream
print("sleeping for 10 seconds")
time.sleep(10)
# starting the vision stream
print("Starting Vision")
vision.start()
move.start()
print('move started')
# starts feeding movement information to the drone once everything else
# is up and running