Overview
The FramesDepot class is designed to store and manage video frames in shared memory, allowing for controlled access and efficient frame management in asynchronous environments. It’s particularly useful in scenarios where frames need to be shared between different processes or handled at different rates.
Features
Fixed-size Queue: Holds a specified maximum number of frames.
Shared Memory: Utilizes shared memory for efficient inter-process communication.
Backpressure Management: Provides a callback mechanism to handle situations where the frame queue is full.
Asynchronous Support: Designed to work in an asynchronous environment, ensuring safe and efficient operations.
Usage
Initialization
frame_size = (width, height, channels) # Dimensions of the frames
memory_name = "frame_depot" # Name for the shared memory block
max_size = 10 # Maximum number of frames in the queue
frames_depot = FramesDepot(frame_size, memory_name, max_size)
Adding Frames
# Assume frame is a NumPy array representing a video frame and current_frame is an integer frame number
frame_dict = {"frame_number": current_frame, "frame": frame}
await frames_depot.enqueue(frame_dict)
Retrieving Frames
frame_number = 5 # The specific frame number you want to retrieve
frames_depot.get_frame(frame_number)
Handling Full Queue
Implement a backpressure_callback function that will be called when the queue is full.
def backpressure_callback():
print("The queue is full. Consider slowing down frame production or handling the surplus.")
frames_depot = FramesDepot(frame_size, memory_name, max_size, backpressure_callback)
Clearing the Queue
await frames_depot.clear_queue()
Closing and Releasing Resources
await frames_depot.close()
Methods
__init__(frame_size, memory_name, max_size, backpressure_callback): Initializes the FramesDepot.
enqueue(frame_dict): Asynchronously adds a frame to the queue and shared memory.
get_frame(frame_number): Retrieves a specific frame by number.
clear_queue(): Asynchronously clears the frame queue and index.
close(): Asynchronously closes and releases all resources, including shared memory.
Properties
queue_is_full: Indicates whether the queue is full.
Requirements
Python 3.7+
NumPy
asyncio
Note
Ensure proper synchronization and error handling in your production environment, especially when dealing with shared resources and asynchronous operations.
Metadata
Release files for gh-frames-depot 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gh-frames-depot-1.0.0.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gh_frames_depot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / gh-frames-depot-1.0.0.tar.gz
| Download URL | gh-frames-depot-1.0.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bae639ba23b6a3664fa3d3501a311746917c691ca08494cf2775cd6b977f726
|
|
BLAKE2b-256 checksum How to use checksums |
0243a0c08b95c82aa6d2033877dbb8f9cbd0519792b54e885ffccd84190b680a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / gh_frames_depot-1.0.0-py3-none-any.whl
| Download URL | gh_frames_depot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82ea738e6b73b268922a96403811bb78172afb120d1845100204044c56dee616
|
|
BLAKE2b-256 checksum How to use checksums |
fd0e73bec25096333c7bbf6a13e5dbb469096cd70009792288b0e278e2bb642e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for gh-frames-depot 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.