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

Software camera sync algorithm #184

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open

Software camera sync algorithm #184

wants to merge 8 commits into from

Conversation

davidplowman
Copy link
Collaborator

This series of commits adds the rpi.sync software camera sync algorithm.

davidplowman and others added 2 commits October 3, 2024 10:29
The camera sync algorithm uses the following new controls:

SyncMode - a camera can be a server or client
SyncWait - whether the sync point has been reached
SyncLag - how far away from synchronisation a camera was
SyncFrameWallClock - for passing wall clock time to the IPA.

Signed-off-by: David Plowman <[email protected]>
Signed-off-by: Arsen Mikovic <[email protected]>
Subsequent commits will add actual values to this queue, which we can
then use for sending wallclock timestamps over to the IPAs, where a
future "synchonisation algorithm" can use them.

Also add code to return the wallclock time to the application through
the frame metadata.

Signed-off-by: Naushir Patuck <[email protected]>
@davidplowman
Copy link
Collaborator Author

@naushir For your enjoyment...!

Copy link
Collaborator

@naushir naushir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things, but otherwise looks good!

src/libcamera/pipeline/rpi/vc4/vc4.cpp Outdated Show resolved Hide resolved
src/ipa/rpi/common/ipa_base.cpp Show resolved Hide resolved
maxJitter_ = maxJitter;
minPts_ = minPts;
reset();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move this to the constructor?

Also, maybe worth having maxJitter as a duration type? Although maybe not if the below calcs use int types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I didn't get this quite right. I meant to call initialise() after reading the parameters from the tuning file, but forgot. So I'll put that in (also, things like maxJitter don't need to be member variables either any more).

I'll see if making maxJitter a duration helps me or not...

src/ipa/rpi/controller/rpi/sync.cpp Outdated Show resolved Hide resolved
src/ipa/rpi/controller/rpi/sync.cpp Show resolved Hide resolved
constexpr unsigned int kDefaultMinAdjustment = 50;
constexpr unsigned int kDefaultFitNumPts = 100;
constexpr unsigned int kDefaultFitMaxJitter = 500;
constexpr unsigned int kDefaultFitMinPts = 10;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although libcamera now uses this k notation, none of our other algorithms do. Not really fussed either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the recent AWB patches, I sense leaving the ks in may be preferable...

We add wallclock timestamps to the queue when we dequeue a camera
buffer from the CFE.

Signed-off-by: Naushir Patuck <[email protected]>
We add wallclock timestamps to the queue when we dequeue a camera
buffer from Unicam.

Signed-off-by: Naushir Patuck <[email protected]>
We add a base class for a "sync algorithm", and define its inputs and
outputs in the SyncStatus class.

We add the necessary plumbing to the base IPA code so as to arrange
for the necessary parameters to be made available to such an
algorithm, and also to handle the return values, passing them back as
necessary to the pipeline handler.

Signed-off-by: Naushir Patuck <[email protected]>
In this implementation, the server sends data packets out onto the
network every 30 frames or so.

Clients listening for this packet will send frame length deltas back
to the pipeline handler to match the synchronisation of the server.

We can use wallclock timestamps so that the process will actually work
across networked Pis, but it does really on those wallclocks being
properly synchronised. We de-jitter our wallclock measurements (as
they're made in userspace) to match the more accurate kernel
SensorTimestamp value.

When the server's advertised "ready time" is reached, both client and
server will signal this through metadata back to their respective
controlling applications.

Signed-off-by: David Plowman <[email protected]>
Signed-off-by: Arsen Mikovic <[email protected]>
Signed-off-by: Naushir Patuck <[email protected]>
Standard sync parameters are added to all tuning files.

Signed-off-by: David Plowman <[email protected]>
Standard sync parameters are added to all tuning files.

Signed-off-by: David Plowman <[email protected]>
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.

2 participants