forked from JohnnyPhil22/AI-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.py
More file actions
73 lines (67 loc) · 1.52 KB
/
Test.py
File metadata and controls
73 lines (67 loc) · 1.52 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
64
65
66
67
68
69
70
71
72
73
import usrtFaceTracking as ft
import servoController as sc
import queue
import threading
import time
# (Pixels)
CAMERA_WIDTH = 640
# (Pixels)
CAMERA_HEIGHT = 480
# (Frames per second)
CAMERA_FPS = 30
# (N)
CAMERA_INDEX = 0
# (File containing cascade classifier)
CASCADE_CLASSIFIER = 'haarcascade_frontalface_alt.xml'
# (multiplier greater than 1)
SCALE_FACTOR = 1.2
# (N)
MIN_NEIGHBORS = 8
# (Pixels, Pixels)
MIN_SIZE = (1, 1)
# (Multiplier)
MOTION_TOLERANCE = 0.75
# (Seconds)
TRACKING_GRACE = 0.75
# (Number of frames)
ROLLING_AVG_COUNT = 1
# (Pixels)
CENTER_WIDTH = 60
# (N)
SERVO_PIN = 18
# (Pulse width ms)
SERVO_MIN = 0.5
# (Pulse width ms)
SERVO_MAX = 2.5
# (Degrees per second)
SPEED = 60
# (Boolean)
REVERSE = True
fifoQueue = queue.Queue()
def servo_thread(servo):
while True:
try:
status = fifoQueue.get(block=False)
if status == 400:
break
servo.updateStatus(status)
except queue.Empty:
pass
servo.runServoLoop()
time.sleep(0.02)
def main():
servo1 = sc.ServoController(SERVO_PIN, SERVO_MIN, SERVO_MAX, SPEED, REVERSE)
t_servo = threading.Thread(target=servo_thread, args =(servo1,))
t_servo.start()
try:
while True:
status = int(input("Please enter status: "))
fifoQueue.put(status)
if status == 400:
break
t_servo.join()
except KeyboardInterrupt:
fifoQueue.put(400)
t_servo.join()
if __name__ == "__main__":
main()