|
libfreenect2 0.4
Open source driver for the Kinect for Windows v2 (K4W2) sensor
|
Kinect v2 frames expose two clocks with different purposes:
Frame::sequence identifies stream order, but sequence values from different streams are not a synchronization contract. Device timestamps from different Kinects also do not share an epoch.
SyncMultiFrameListener preserves the original arrival-based behavior: it collects one frame of every requested type and replaces an earlier frame when another frame of that type arrives before the set is complete. It does not test timestamps. The word "sync" in its name means that the API returns the requested frame types together, not that their exposures happened together.
TimestampAlignedFrameListener performs stricter software pairing. It keeps a bounded queue for every requested stream, searches the queued combinations for the smallest wrap-safe device-timestamp span, and delivers a set only when that span is at or below max_delta_ticks. Queue overflow and frames skipped before a selected combination count as drops. getStatistics() returns a thread-safe snapshot containing delivered-set and dropped-frame counts plus the last and maximum delivered deltas.
Neither listener controls exposure timing. The RGB camera auto-exposes and can fall to 15 Hz in low light while the IR/depth stream continues at 30 Hz. Software pairing cannot trigger the two cameras simultaneously, synchronize separate Kinect devices, or recover a frame that was never transferred. Use good lighting, an explicit timestamp threshold, and the drop statistics when motion alignment matters. Kinect v2 does not expose a supported external trigger through libfreenect2.
The threshold uses device ticks, where 200 ticks equals 25 ms:
Start with a threshold that reflects the maximum motion error your application can tolerate, then inspect the observed deltas and drops. A smaller threshold improves temporal proximity but can increase latency and drops. A larger queue can find better combinations during jitter, but holds more frame memory and does not compensate for sustained rate differences.
Do not subtract unsigned device timestamps and apply abs(): that fails at wraparound. TimestampAlignedFrameListener performs wrap-safe comparisons internally.
The one-argument capture command retains legacy pairing:
Use explicit snapshot mode to enforce a threshold. Its default is 200 ticks (25 ms), and it can be overridden:
The command reports delivered sets, dropped frames, and observed deltas. Its metadata.json records the device timestamp, arrival timestamp, and sequence for color, IR, and depth, along with the alignment threshold and statistics.
See upstream discussions #721, #792, and #869 for the original timing and synchronization requests.