this is not good practice to not be backward compatible.
#!/bin/bash
. setup_env.sh
#hailopipe/hailopipe &
hailocmdbox/build-hailocmdbox-Desktop-Release/Qthailopipe &
python3 basic_pipelines/madsen2.py --hef-path local_resources/yolov11s.hef --input rpi --show-fps >> /tmp/hailo
rm /tmp/hailo
yolov11s.hef didnot exits anymore what to usu instead.
Waste of my time.
for the user using my small aps this is the new madsen.py
from pathlib import Path
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import Gst, GLib
import os
import numpy as np
import cv2
import hailo
from hailo_apps.hailo_app_python.core.common.buffer_utils import get_caps_from_pad, get_numpy_from_buffer
from hailo_apps.hailo_app_python.core.gstreamer.gstreamer_app import app_callback_class
from hailo_apps.hailo_app_python.apps.detection.detection_pipeline import GStreamerDetectionApp
-----------------------------------------------------------------------------------------------
User-defined class to be used in the callback function
-----------------------------------------------------------------------------------------------
class user_app_callback_class(app_callback_class):
def init(self):
super().init()
self.new_variable = 42 # New variable example
def new_function(self): # New function example
return "The meaning of life is: "
-----------------------------------------------------------------------------------------------
User-defined callback function
-----------------------------------------------------------------------------------------------
def app_callback(pad, info, user_data):
buffer = info.get_buffer()
if buffer is None:
return Gst.PadProbeReturn.OK
user_data.increment()
string_to_print = f"Frame count: {user_data.get_count()}\n"
format, width, height = get_caps_from_pad(pad)
frame = None
if user_data.use_frame and format is not None and width is not None and height is not None:
frame = get_numpy_from_buffer(buffer, format, width, height)
roi = hailo.get_roi_from_buffer(buffer)
detections = roi.get_objects_typed(hailo.HAILO_DETECTION)
detection_count = 0
for detection in detections:
label = detection.get_label()
bbox = detection.get_bbox()
confidence = detection.get_confidence()
if label:
# Get track ID
track_id = 0
track = detection.get_objects_typed(hailo.HAILO_UNIQUE_ID)
if len(track) == 1:
track_id = track[0].get_id()
string_to_print += (f"Detection: ID: {track_id} Label: {label} Confidence: {confidence:.2f}\n")
detection_count += 1
if user_data.use_frame and frame is not None:
x_min = bbox.xmin()
y_min = bbox.ymin()
box_width = bbox.width()
box_height = bbox.height()
x_max = x_min + box_width
y_max = y_min + box_height
cv2.rectangle(
frame,
(int(x_min * width), int(y_min * height)),
(int(x_max * width), int(y_max * height)),
(255, 255, 255),
1,
)
cv2.putText(
frame,
label,
(int(x_min * width), int(y_min * height) - 10),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(255, 255, 255),
1,
)
if user_data.use_frame and frame is not None:
cv2.putText(frame, f"Detections: {detection_count}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
cv2.putText(frame, f"{user_data.new_function()} {user_data.new_variable}", (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
user_data.set_frame(frame)
print(string_to_print)
return Gst.PadProbeReturn.OK
if name == “main”:
project_root = Path(file).resolve().parent.parent
env_file = project_root / “.env”
env_path_str = str(env_file)
os.environ[“HAILO_ENV_FILE”] = env_path_str
user_data = user_app_callback_class()
app = GStreamerDetectionApp(app_callback, user_data)
app.run()