Savant
Savant copied to clipboard
Custom function allowing user to modify frames before processing
This custom function must allow a user to accept frames and return modified (or the same frame) ones. It utilizes the GpuMat API. With the function, the user can change the frame's resolution, add padding, modify the image itself, etc. The frame is not modified when the user returns the same GpuMat object.
Along with GpuMat, the user must be able to access frame metadata (Frame object) for more decision-making information.
Pseudocode:
class X:
def convert(meta: VideoFrame, image: GpuMat) -> GpuMat
The updated resolution is applied to the frame meta when the resolution changes.
By default (for safety reasons), meta is provided as a copy:
https://insight-platform.github.io/savant-rs/modules/savant_rs/primitives.html#savant_rs.primitives.VideoFrame.copy
However, the user can override the behavior with a special class-level variable like
enum MetaAcess:
Shared
Copy # default
CopyReleaseGIL
class X:
meta_access: MetaAccess = MetaAccess.Shared
def convert(meta: VideoFrame, image: GpuMat) -> GpuMat
With such a configuration, the user can modify the original frame meta.
The function is configured in the YAML like:
parameters:
frame:
ingress_converter:
module: module.here
class_name: ImageConverter