Skipping Frames
The method is based on default ROI removal for a frame when a specific condition is met:
class ConditionalDetectorSkip(NvDsPyFuncPlugin):
def __init__(self, **kwargs):
super().__init__(**kwargs)
with open(self.config_path, 'r', encoding='utf8') as stream:
self.line_config = yaml.safe_load(stream)
def process_frame(self, buffer: Gst.Buffer, frame_meta: NvDsFrameMeta):
primary_meta_object = None
for obj_meta in frame_meta.objects:
if obj_meta.is_primary:
primary_meta_object = obj_meta
break
# if the boundary lines are not configured for this source
# then disable detector inference entirely by removing the primary object
# Note:
# In order to enable use cases such as conditional inference skip
# or user-defined ROI, Savant configures all Deepstream models to run
# in 'secondary' mode and inserts a primary 'frame' object into the DS meta
if (
primary_meta_object is not None
and frame_meta.source_id not in self.line_config