-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture_loop.py
66 lines (49 loc) · 1.52 KB
/
capture_loop.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
"""
python3 capture_loop.py /home/susi/Documents/captures/
"""
import sys
import pyzed.sl as sl
from signal import signal, SIGINT
import time
import datetime
cam = sl.Camera()
cam.set_camera_settings(sl.VIDEO_SETTINGS.EXPOSURE, 0)
def handler(signal_received, frame):
cam.disable_recording()
cam.close()
sys.exit(0)
signal(SIGINT, handler)
def main():
if not sys.argv or len(sys.argv) != 2:
exit(1)
init = sl.InitParameters()
init.camera_resolution = sl.RESOLUTION.HD720
init.camera_fps = 30
init.depth_mode = sl.DEPTH_MODE.ULTRA # Use ULTRA depth mode
init.coordinate_units = sl.UNIT.METER
init.depth_minimum_distance = 0.15
cont = 0
status = cam.open(init)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit(1)
while True:
t = 0
t0 = time.time()
name = datetime.datetime.now()
path_output = name.strftime("%d_%m_%Y__%H_%M_") + str(cont) + ".svo"
path_output = sys.argv[1] + path_output
recording_param = sl.RecordingParameters(path_output, sl.SVO_COMPRESSION_MODE.LOSSLESS)
err = cam.enable_recording(recording_param)
if err != sl.ERROR_CODE.SUCCESS:
print(repr(status))
exit(1)
runtime = sl.RuntimeParameters()
while t < 180:
if cam.grab(runtime) == sl.ERROR_CODE.SUCCESS:
print("grabando \n")
t = time.time() - t0
print(str(t))
cont = cont+1
if __name__ == "__main__":
main()