From 265c5c9503b060eef1082aba4a86900151e8cd73 Mon Sep 17 00:00:00 2001 From: Evgeny Demchenko Date: Thu, 18 Jun 2026 03:08:14 +0100 Subject: [PATCH] =?UTF-8?q?detbox:=20label=20+=20score=20pill=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20bbox=20(FreeType)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раньше detbox рисовал только рамку. Теперь на каждое active событие отображает "label NN%" в полупрозрачной pill цвета рамки над верхним краем bbox. include/cuframes_composer/overlay.h: - cfc_overlay_detbox_config_t: + font_path, font_size, label_bg_alpha - cfc_overlay_detbox_upsert: + float score parameter src/overlay.c: - detbox_entry_t: + score, rendered_text (кеш), text_atlas/w/h/pitch - detbox_data_t: + ft_library, ft_face, font_path_copy, font_size_px - cfc_overlay_create_detection_boxes: opens FT face если font_path задан - cfc_overlay_destroy: free cached atlas'ы + FT face/library - detbox_rebuild_label_atlas: format "label NN%" → FT render → VRAM upload (reuse text_measure / text_render из CFC_OVERLAY_TEXT) - upsert: вызывает rebuild при изменении label/score (кеш по rendered_text) - draw_detection_boxes: snap расширен под text_atlas; после border рисует pill bg (fill_nv12 цветом рамки) + текст (blit_rgba_nv12, белый) - mutex hold всю draw — atlas чтение должно быть atomic против upsert src/frigate_mqtt.c: - parse after.score → передаём в upsert (Frigate & yoloworld envelope совместимы: оба содержат score) examples/grid_record.c: - 4 frigate detbox: font_path=/fonts/DejaVuSans-Bold.ttf, font_size=16 - 4 yw detbox: то же — magenta pill с белым текстом Live: cfc-grid healthy 25 fps, image gx/cuframes-composer:0.11b-step4 deployed. Видно на TV при первом detection event. Co-Authored-By: Claude Opus 4.7 --- examples/grid_record.c | 8 ++ include/cuframes_composer/overlay.h | 10 ++ src/frigate_mqtt.c | 6 +- src/overlay.c | 180 ++++++++++++++++++++++++++-- 4 files changed, 193 insertions(+), 11 deletions(-) diff --git a/examples/grid_record.c b/examples/grid_record.c index aa90d7b..34f8111 100644 --- a/examples/grid_record.c +++ b/examples/grid_record.c @@ -570,6 +570,11 @@ int main(int argc, char **argv) .stale_ms = 8000, .required_zones = detcells[i].num_zones ? detcells[i].zone_ptrs : NULL, .required_zones_count = detcells[i].num_zones, + /* Label+score pill — белым текстом на полупрозрачном зелёном + * фоне (color_y/u/v). Шрифт DejaVu mounted из /fonts (см. compose). */ + .font_path = "/fonts/DejaVuSans-Bold.ttf", + .font_size = 16, + .label_bg_alpha = 200, }; if (cfc_overlay_create_detection_boxes(&dc, &detbox_overlays[i]) != 0) { fprintf(stderr, "[grid_record] detbox create failed для '%s'\n", @@ -608,6 +613,9 @@ int main(int argc, char **argv) .stale_ms = 8000, .required_zones = detcells[i].num_zones ? detcells[i].zone_ptrs : NULL, .required_zones_count = detcells[i].num_zones, + .font_path = "/fonts/DejaVuSans-Bold.ttf", + .font_size = 16, + .label_bg_alpha = 200, }; if (cfc_overlay_create_detection_boxes(&yc, &yw_detbox_overlays[i]) != 0) { fprintf(stderr, "[grid_record] yw detbox create failed для '%s'\n", diff --git a/include/cuframes_composer/overlay.h b/include/cuframes_composer/overlay.h index a67554d..fe9a71b 100644 --- a/include/cuframes_composer/overlay.h +++ b/include/cuframes_composer/overlay.h @@ -165,6 +165,13 @@ typedef struct cfc_overlay_detbox_config { * NULL или пустой массив → принимать все события. */ const char *const *required_zones; /* массив строк */ int required_zones_count; + + /* Label + confidence text над bbox. + * NULL font_path → рисовать только рамки (legacy behavior). + * Текст формата "