-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraTest.py
More file actions
executable file
·61 lines (55 loc) · 1.5 KB
/
CameraTest.py
File metadata and controls
executable file
·61 lines (55 loc) · 1.5 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
# $ python3 CameraTest.py
"""
******* Realsense camera as the sensor ***************
The Intel Realsense 435i camera provides
RGB Data
Depth Data
Gyroscope Data
Accelerometer Data
This example only shows RGB and Depth data.
You can hit
'r' to record video for development and training
's' to stop recording
'i' to save an image
'q' to quit the program
***********************************************
"""
# import the necessary packages
from RealSense import *
import cv2
import imutils
rs = RealSense("/dev/video2", RS_VGA) # RS_VGA, RS_720P, or RS_1080P
writer = None
recording = False
frameIndex = 0
while True:
(time, rgb, depth, accel, gyro) = rs.getData()
if writer is None and recording is True:
# initialize our video writer
writer = cv2.VideoWriter(
"Video.avi",
cv2.VideoWriter_fourcc(*"MJPG"),
15,
(rgb.shape[1], rgb.shape[0]),
True,
)
if recording == True:
# write the output frame to disk
writer.write(rgb)
# key = cv2.waitKey(1) & 0xFF
key = input("press input")
key = ord(key[0])
if key == ord("r"): # Start Recording
recording = True
if key == ord("s"): # Stop Recording
recording = False
if key == ord("i"): # Save image
filename = "image" + str(frameIndex) + ".jpg"
cv2.imwrite(filename, rgb)
frameIndex += 1
if key == ord("q"):
break
if writer:
writer.release()
del rs
cv2.destroyAllWindows()