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

Multiprocessing example #1051

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

davidplowman
Copy link
Collaborator

Two commits:

  • the first actually just adds a context manager way of capturing requests with picam2.captured_request() as request:
  • the second is the multiprocessing example (which uses the captured_request mechanism)

Usage:
    with picam2.captured_request() as request:
        # do stuff, request will be released automatically

Also add a test for this.

Signed-off-by: David Plowman <[email protected]>
This example creates a Picamera2 child "Process" derived from the
multiprocessing module version, and a Picamera2 "Pool" that can
delegate to several of these child processes.

The parent Picamera2 process passes image buffers across to the new
process using file descriptors and memory mapping so that the buffer
can be shared, and the pixel data does not need to be copied.

At the bottom of the file is some example code showing how to use the
classes.

Signed-off-by: David Plowman <[email protected]>
@davidplowman davidplowman force-pushed the multiprocessing-example branch from 253a03c to beb6fd3 Compare June 6, 2024 09:42
@davidplowman davidplowman merged commit 30aa2c2 into raspberrypi:next Jun 10, 2024
4 checks passed
@davidplowman davidplowman deleted the multiprocessing-example branch October 30, 2024 14:01
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.

1 participant