Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync NN meta with depth(x,y,z), sync previewout & metaout #157

Merged
merged 7 commits into from Jul 30, 2020

Conversation

alex-luxonis
Copy link
Collaborator

  • Sync NN metadata with depth frames for X,Y,Z calculation, based on camera capture timestamps.
    As RGB and Mono cameras are not synchronized, another problem we saw was a slow drift, 1 frame every 80 seconds at 30fps. To circumvent this, a software-sync method is implemented: based on RGB-Mono timestamp diff, a control loop is adjusting the RGB frame interval, in small amounts by up to ± 0.2ms. During startup, it may take few seconds (up to 10), until RGB and Mono get in close sync together (this could be further improved). Until then, then max timestamp diff between RGB-Mono is no larger than half frametime (that is 16.6ms at 30fps).
    Note: for this mechanism to work well, if the RGB and Mono FPS are modified from the default of 30 (using -rgbf and -monof arguments), they should be set to the same value.

  • Add an option to improve the synchronization of NN metadata overlay on the previewout stream, by aligning the packets sent from device:

  -sync, --sync-video-meta
                        Synchronize 'previewout' and 'metaout' streams

Note: for this to work well, the NN FPS should not be slower than camera FPS. To improve on this (for some NN models), run NN with 2 NCEs and more Shaves, or reduce RGB and Mono FPS, for example:
./depthai.py -nce 2 -sh 10 -cmx 10 -sync
./depthai.py -rgbf 24 -monof 24 -sync

@SzabolcsGergely
Copy link
Collaborator

LGTM

@VanDavv
Copy link
Contributor

VanDavv commented Jul 28, 2020

Tested with 8 different networks and they all performed great - I've even got feeling that some tracker is attached to my face with face-detection-retail-0004 as both network and preview were running with 30 FPS and the sync was visible.
With slower network - face-detection-adas-0001, got 8 FPS and the preview also went down to 8 FPS and both results and image were consistent.

LGTM, great to have this @alex-luxonis !

@Luxonis-Brandon
Copy link
Contributor

Thanks @VanDavv for testing and sorry @alex-luxonis that I've been so far behind on testing. Trying this now.

@Luxonis-Brandon
Copy link
Contributor

Luxonis-Brandon commented Jul 28, 2020

This works insanely well @alex-luxonis ! I agree with Lukasz comment of it feeling glued to you. I ran python3 test.py -nce 2 -sh 10 -cmx 10 -sync and it was fantastic how well synced and fast everything was!

See the quick video below:
Hard sync mode of DepthAI
https://youtu.be/BCa5z1ssxxo
https://i.imgur.com/nXVZkeC.jpg

@alex-luxonis alex-luxonis merged commit df7e2dc into master Jul 30, 2020
@alex-luxonis alex-luxonis deleted the sync_nn_depth branch July 30, 2020 23:03
SzabolcsGergely pushed a commit that referenced this pull request Oct 30, 2020
Sync NN meta with depth(x,y,z), sync previewout & metaout
jdavidberger pushed a commit to constructiverealities/depthai that referenced this pull request May 26, 2022
Change name of libarchive for better compatiblity with Hunter's packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants