For a couple of moth ago some one where asking for frame count in main window.
here is a way.
in venv_hailo_rpi5_examples/lib/python3.11/site-packages/hailo_ap/detection_pipelines.py
replace def get_pipeline_string(self):
with
def get_pipeline_string(self):
source_pipeline = SOURCE_PIPELINE(self.video_source, self.video_width, self.video_height)
detection_pipeline = INFERENCE_PIPELINE(
hef_path=self.hef_path,
post_process_so=self.post_process_so,
post_function_name=self.post_function_name,
batch_size=self.batch_size,
config_json=self.labels_json,
additional_params=self.thresholds_str
)
detection_pipeline_wrapper = INFERENCE_PIPELINE_WRAPPER(detection_pipeline)
tracker_pipeline = TRACKER_PIPELINE(class_id=1)
user_callback_pipeline = USER_CALLBACK_PIPELINE()
# Add textoverlay for frame count
text_overlay_pipeline = (
'textoverlay name=framecount_overlay font-desc="Sans, 12" halignment=center valignment=top'
)
display_pipeline = DISPLAY_PIPELINE(
video_sink=self.video_sink,
sync=self.sync,
show_fps=self.show_fps,
name='hailo_display'
)
pipeline_string = (
f'{source_pipeline} ! '
f'{detection_pipeline_wrapper} ! '
f'{tracker_pipeline} ! '
f'{user_callback_pipeline} ! '
f'{text_overlay_pipeline} ! '
f'{display_pipeline}'
)
print(pipeline_string)
return pipeline_string
and in basic_pipelines/detection.py
set this in the end of the code overwriting all of if name == “main”:
def update_framecount_overlay(pipeline, user_data):
overlay = pipeline.get_by_name(“framecount_overlay”)
if overlay is not None:
overlay.set_property(“text”, f"Frame: {user_data.get_count()}")
# Return True to keep the timer running
return True
if name == “main”:
user_data = user_app_callback_class()
app = GStreamerDetectionApp(app_callback, user_data)
# After the pipeline is created, but before app.run()
GLib.timeout_add(100, update_framecount_overlay, app.pipeline, user_data)
app.run()