-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (28 loc) · 850 Bytes
/
main.py
File metadata and controls
40 lines (28 loc) · 850 Bytes
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
import serial
import time
import cv2
from facial_detection import FacialDetection
time.sleep(2)
def write_position(x, y):
time.sleep(.02)
ser.write(f"X{x}Y{y}\n".encode())
return 0
stream = cv2.VideoCapture(0)
faces = FacialDetection()
if not stream.isOpened():
print("no stream")
exit()
while True:
ret, frame = stream.read() # Read a frame from the camera
if not ret:
print("no more stream")
break
faces.refresh(frame)
cv2.rectangle(frame, (faces.faceCoords[0], faces.faceCoords[1]), (faces.faceCoords[2], faces.faceCoords[3]), (0, 255, 0), 2)
#cv2.circle(frame, (faces.laserCoords[0], faces.laserCoords[1]), 4, (255, 0, 0))
cv2.imshow("Webcam", frame)
#write_position(xSet, ySet)
if cv2.waitKey(1) == ord('q'):
break
stream.release()
cv2.destroyAllWindows()