strawlab / strand-braid

Live, low-latency 2D and 3D tracking from single or multiple high-speed cameras
https://strawlab.org/braid/
Other
50 stars 8 forks source link

Starting Post-Trigger recording from py-strandcam #14

Closed elhananby closed 2 years ago

elhananby commented 2 years ago

Hi Andrew, I had a question regarding starting to record an MKV post-trigger using a Python script. I saw that you can set the SetPostTriggerBufferSize and PostTrigger configuration, https://github.com/strawlab/strand-braid/blob/58485b64dff08b49a80e5dd2af77ede2d1ca101c/ci2-remote-control/src/lib.rs#L272-L273 however, it requires sending a MkvRecordingConfig, which by itself requires sending a MkvCodec config, which needs H264Options, and so on. https://github.com/strawlab/strand-braid/blob/58485b64dff08b49a80e5dd2af77ede2d1ca101c/ci2-remote-control/src/lib.rs#L146-L150 Is there any simple way to activate the post-trigger recording from Python, similar to just setting SetIsRecordingMkv(True)?

Thanks Elhanan

astraw commented 2 years ago

It has been a while since I tried it, but https://github.com/strawlab/strand-braid/blob/main/strand-braid-user/scripts/record-mkv-video.py should still work. If not, maybe you can fiddle it until it does? Nothing fundamental has changed. In general, it is possible to script anything that can be done with the web UI by directly connecting to Strand Cam from e.g. a Python script.

elhananby commented 2 years ago

Hi Andrew, thanks for the answer and sorry for the late reply. As you said, I got it working by just passing all the required arguments to the camera whenever I want to start recording, i.e.

strand_cam.send_to_camera({"SetPostTriggerBufferSize": 500})
MKVRecordingConfig = {'codec': {'H264': {'bitrate': 5000, 'cuda_device': 0}},
                    'max_framerate': 'Fps100',
                    'writing_application': 'braid-strand-cam-0.11.1',
                    'save_creation_time': True,
                    'do_trim_size': True}
strand_cam.send_to_camera({"PostTrigger": MKVRecordingConfig})

Thanks Elhanan