I have noticed that when the first object class in the object detection model disappears from the screen, the bounding box does not disappear immediately but remains on the screen for about 1 to 2 seconds.
I have currently tested three models: “https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.15.0/hailo8l/yolov8s.hef”, “https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.15.0/hailo8l/yolov8m.hef”, and “yolov8s-hailo8l-barcode.hef”. All three models exhibit the issue I described. (I forgot whether “yolov8s-hailo8l-barcode.hef” was obtained from “hailo-rpi5-examples” or “Hailo-Application-Code-Examples”).
The program I am currently using is located in the hailo-rpi5-examples/basic_pipelines/detection.py file from “https://github.com/hailo-ai/hailo-rpi5-example”.
By the way, this problem occurs regardless of whether it is in the native window display of this program or in a window generated using “–use-frame”.
Below is my current code (hailo-rpi5-examples/basic_pipelines/detection.py):
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
import os
import cv2
import hailo
import time
from hailo_apps_infra.hailo_rpi_common import (
get_caps_from_pad,
get_numpy_from_buffer,
app_callback_class,
)
from hailo_apps_infra.detection_pipeline import GStreamerDetectionApp
class user_app_callback_class(app_callback_class):
def __init__(self):
super().__init__()
self.fps = 0.0
self.fps_step = 10
self.last_fps_time = time.time()
def app_callback(pad, info, user_data):
buffer = info.get_buffer()
if buffer is None:
return Gst.PadProbeReturn.OK
user_data.increment()
frame_count = user_data.get_count()
fmt, width, height = get_caps_from_pad(pad)
frame = None
if user_data.use_frame and fmt and width and height:
frame = get_numpy_from_buffer(buffer, fmt, width, height)
roi = hailo.get_roi_from_buffer(buffer)
detections = roi.get_objects_typed(hailo.HAILO_DETECTION)
now = time.time()
if user_data.use_frame and frame is not None:
label_list = ["person", "car", "barcode", "QR code"]
best_detections = {}
filtered_detections = None
# print(f"detections:{len(detections)}")
for det in detections:
lbl = det.get_label()
if lbl not in label_list:
continue
# track_id
track_id = 0
track = det.get_objects_typed(hailo.HAILO_UNIQUE_ID)
for i in range(len(track)):
print(track[0].get_id())
if len(track) == 1:
track_id = track[0].get_id()
# bbox
bbox = det.get_bbox()
x1, y1 = bbox.xmin()*width, bbox.ymin()*height
x2, y2 = bbox.xmax()*width, bbox.ymax()*height
color = (255,0,0)
cv2.rectangle(frame,
(int(x1), int(y1)),
(int(x2), int(y2)),
color, 2)
cv2.putText(frame,
f"{lbl}, {track_id}",
(int(x1), int(y1)-5),
cv2.FONT_HERSHEY_SIMPLEX,
0.5, color, 1)
# ------------------------
# FPS display
# ------------------------
if user_data.use_frame and frame is not None:
if frame_count % user_data.fps_step == 0:
dt = now - user_data.last_fps_time
if dt > 0:
user_data.fps = user_data.fps_step / dt
user_data.last_fps_time = now
cv2.putText(frame,
f"FPS:{user_data.fps:.2f}",
(10,30),
cv2.FONT_HERSHEY_SIMPLEX,
0.7, (255,255,255), 2)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
user_data.set_frame(frame)
return Gst.PadProbeReturn.OK
if __name__ == "__main__":
Gst.init(None)
user_data = user_app_callback_class()
app = GStreamerDetectionApp(app_callback, user_data)
app.run()
Also, I would like to ask where I can find “hailo.HAILO_UNIQUE_ID”?
Please let me know if you need more information regarding this issue.