Environment:
- Jetson Orin Nano Super 8GB
- JetPack 6.2.2
- DeepStream 7.1
- TensorRT 10.3
- Python API: pyservicemaker (pybind11-based)
- Pipeline: nvurisrcbin → nvstreammux → nvinfer → nvvideoconvert → capsfilter(RGBA) → nvdsosd → nv3dsink
What we’re doing:
We have an object detection pipeline (3 classes). We define rectangular lane ROIs on the frame. In a BatchMetadataOperator probe attached after nvinfer, we:
-
Draw lane overlays on the OSD using display_meta.add_text() and display_meta.add_rect():
def _draw_overlays(self, batch_meta, frame_meta, det_labels):
display_meta = batch_meta.acquire_display_meta()for lane in self._lanes:
rect = osd.Rect()
rect.left = float(lane.x1)
rect.top = float(lane.y1)
rect.width = float(lane.x2 - lane.x1)
rect.height = float(lane.y2 - lane.y1)
rect.border_width = 3
rect.border_color = color
display_meta.add_rect(rect)text = osd.Text() text.display_text = f"L{lane.id}".encode("ascii") text.x_offset = int(lane.x1 + 5) text.y_offset = int(lane.y1 + 5) text.font.name = osd.FontFamily.Serif text.font.size = 14 text.font.color = osd.Color(1.0, 1.0, 1.0, 1.0) display_meta.add_text(text)frame_meta.append(display_meta)
-
Suppress bounding boxes outside lanes by zeroing rect_params — this works perfectly, nvdsosd does not render the bbox:
for obj in frame_meta.object_items:
r = obj.rect_params
x1, y1 = float(r.left), float(r.top)
w, h = float(r.width), float(r.height)
cx, cy = x1 + w * 0.5, y1 + h * 0.5if not inside_any_lane(cx, cy):
This successfully hides the bounding box
r.width = 0
r.height = 0
r.border_width = 0
continue
The problem:
Zeroing rect_params hides the bounding box, but nvdsosd still renders the text label (populated by nvinfer from labelfile-path) for the suppressed object. The
label floats outside the lane boundaries with no associated bbox.
What we’ve tried (all failed):
- obj.text_params.display_text = “” — Crashes with:
TypeError: Unable to convert function return value to a Python type! The signature was
(arg0: pyservicemaker._pydeepstream.ObjectMetadata) → _NvOSD_TextParams - The text_params property getter in pyservicemaker’s pybind11 binding cannot convert _NvOSD_TextParams to a Python type.
- obj.label = “” — Does not affect nvdsosd rendering. nvdsosd reads from text_params.display_text, not the label property.
- Moving bbox off-screen (r.left = -10000.0, r.top = -10000.0) — nvdsosd appears to clamp negative coordinates to 0, so labels render at the top-left of the frame
instead. - Setting display-text=0 on nvdsosd element — This suppresses ALL text globally, including our custom display_meta.add_text() lane labels. We confirmed from the
nvdsosd source (gstnvdsosd.c line 583) that draw_text gates both object metadata text AND display metadata text.
What we need:
A way to either:
- Clear/suppress text_params.display_text on individual NvDsObjectMeta objects from a pyservicemaker probe
- Or selectively disable nvinfer-generated object labels while keeping custom display_meta text rendering active
Potential workaround we’re considering:
Removing labelfile-path from the nvinfer config so nvinfer never populates text_params.display_text, then manually drawing labels only for in-lane detections via
display_meta.add_text(). However, we’d like to confirm this is the correct approach, or if there’s a proper way to modify text_params via pyservicemaker.
Pipeline setup (pyservicemaker):
p.add(“nvdsosd”, “osd”)
Probe attached to nvinfer output:
p.attach(“infer”, Probe(“my-probe”, probe))
nvinfer config (relevant lines):
labelfile-path=../../models/my_model/labels.txt
num-detected-classes=3
custom-lib-path=../../lib/my_parser.so
parse-bbox-func-name=MyCustomParser
Any guidance appreciated. Thanks!