-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBenchmark_Vid.py
50 lines (41 loc) · 1.11 KB
/
Benchmark_Vid.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
'''
This file was used to gather benchmark videos by rotating the robot and recording
-Carlos Cuartas
'''
import numpy as np
import cv2
import time
from adafruit_servokit import ServoKit
kit2 = ServoKit(channels=16, address=0x41, reference_clock_speed = 31000000)
yawServo = 2
kit2.servo[yawServo].angle = 0
time.sleep(.4)
kit2.servo[yawServo].angle = 180
time.sleep(.6)
kit2.servo[yawServo].angle = 90
time.sleep(1)
# This will return video from the first webcam on your computer.
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
i = 90
inc = 1
while(True):
ret, frame = cap.read()
# output the frame
out.write(frame)
if i > 179:
inc = -1
elif i < 1:
inc = 1
i+=inc
kit2.servo[yawServo].angle = i
# The original input frame is shown in the window
cv2.imshow('Original', frame)
# Wait for 'a' key to stop the program
if cv2.waitKey(1) & 0xFF == ord('a'):
break
cap.release()
out.release()
cv2.destroyAllWindows()