NvDsPyFuncPlugin
- class savant.deepstream.pyfunc.NvDsPyFuncPlugin(**kwargs)
DeepStream PyFunc plugin base class.
PyFunc implementations are defined in and instantiated by a
PyFunc
structure.- on_start()
Do on plugin start.
- on_event(event)
Add stream event callbacks.
- on_source_add(source_id)
On source add event callback.
- on_source_eos(source_id)
On source EOS event callback.
- on_source_delete(source_id)
On source delete event callback.
- get_cuda_stream(frame_meta)
Get a CUDA stream that can be used to asynchronously process a frame in a batch.
All frame CUDA streams will be waited for at the end of batch processing.
- process_buffer(buffer)
Process gstreamer buffer directly. Throws an exception if fatal error has occurred.
Default implementation calls
process_frame_meta()
andprocess_frame()
for each frame in a batch.- Parameters:
buffer (Buffer) – Gstreamer buffer.
- process_frame(buffer, frame_meta)
Process gstreamer buffer and frame metadata. Throws an exception if fatal error has occurred.
Use savant.deepstream.utils.get_nvds_buf_surface to get a frame image.
- Parameters:
buffer (Buffer) – Gstreamer buffer.
frame_meta (NvDsFrameMeta) – Frame metadata for a frame in a batch.
- get_runtime_metrics(n)
Get last runtime metrics.
- property metrics: MetricsRegistry
Get metrics registry.
Usage example:
from savant.metrics import Counter self.metrics['frames_per_source'] = Counter( name='frames_per_source', description='Number of processed frames per source', labelnames=('source_id',), ) ... self.metrics['frames_per_source'].inc(labels=('camera-1',))