etiennedub / pyk4a

Python 3 wrapper for Azure-Kinect-Sensor-SDK
MIT License
287 stars 81 forks source link

--external-sync flag in pyk4a #203

Closed timsainb closed 1 year ago

timsainb commented 1 year ago

The sdk website explains how to use an external trigger (e.g. an arduino) to acquire frames using the --external sync flag.

e.g.

k4arecorder.exe --external-sync sub -e -8 -r 5 -l 10 sub1.mkv

How would you do the same in pyk4a?

shagren commented 1 year ago

Subordinates:

 config1 = Config(..., wired_sync_mode=WiredSyncMode.SUBORDINATE, subordinate_delay_off_master_usec=0)
 config2 = Config(..., wired_sync_mode=WiredSyncMode.SUBORDINATE, subordinate_delay_off_master_usec=200)
 config3 = Config(..., wired_sync_mode=WiredSyncMode.SUBORDINATE, subordinate_delay_off_master_usec=400)
 ....
 device1=PyK4A(config=config, device_id=device_id)
 device1.start()
...
while True:
   capture1 = device1.get_capture()
   capture2 = device2.get_capture()
   ...

Each subordinate must have own subordinate_delay_off_master_usec. I do not remember exact value, but each next must be greater by some minimal value. 200 is suitable in any case, but you can read SDK docs for better value.

All devices must have same Color and Depth modes, exposure and powerline_frequency settings.

Sometime captures will be returned from different ticks (external trigger ticks). You can compare capture.depth_timestamp_usec with each other, look at https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/examples/green_screen/MultiDeviceCapturer.h .

timsainb commented 1 year ago

Awesome, thanks!