From 174200eb0338750251c63797e2f43fd4b704b70d Mon Sep 17 00:00:00 2001 From: miketsai Date: Thu, 16 Jul 2026 17:33:02 +0800 Subject: [PATCH] separate alert and collision threshold --- .../pre_post_proc/stdc_post_process.h | 17 +++++++++++----- src/host_stream/app_header_init.c | 4 +--- src/host_stream/handshake.c | 4 ++-- src/pre_post_proc/stdc_post_process.c | 20 +++++++++---------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/include/app_flow/pre_post_proc/stdc_post_process.h b/include/app_flow/pre_post_proc/stdc_post_process.h index f71e242..562c119 100644 --- a/include/app_flow/pre_post_proc/stdc_post_process.h +++ b/include/app_flow/pre_post_proc/stdc_post_process.h @@ -34,7 +34,7 @@ #define STDC_WARNING_SECONDS 2.0f #define STDC_MOTION_THRESHOLD 3.0f #define STDC_TREE_GROWTH_THR 0.05f -#define THR_GRASS_ROI 0.30f /* grass ratio in forward ROI */ +#define THR_GRASS_ROI 0.75f /* grass ratio in forward ROI */ #define THR_CAR_GLOBAL 0.05f #define THR_PERSON_GLOBAL 0.01f #define THR_GREENERY_GLOBAL 0.20f @@ -48,11 +48,18 @@ #define COL_ROI_TOP 0.25f #define COL_ROI_BOTTOM 0.70f -#define THR_PERSON_COLLISION 0.01f -#define THR_CAR_COLLISION 0.05f +#define THR_PERSON_COLLISION 0.10f +#define THR_CAR_COLLISION 0.20f #define THR_TREE_COLLISION 0.20f -#define THR_BUNKER_COLLISION 0.01f -#define THR_POND_COLLISION 0.01f +#define THR_BUNKER_COLLISION 0.20f +#define THR_POND_COLLISION 0.20f + +/* Alert ROI thresholds (left/right sides) — tuned independently from collision */ +#define THR_PERSON_ALERT 0.10f +#define THR_CAR_ALERT 0.10f +#define THR_TREE_ALERT 0.20f +#define THR_BUNKER_ALERT 0.10f +#define THR_POND_ALERT 0.10f /* Forward ROI trapezoid - from Python roi_pts */ #define FWD_ROI_TOP_LEFT 0.45f diff --git a/src/host_stream/app_header_init.c b/src/host_stream/app_header_init.c index ac2afda..f7563b2 100644 --- a/src/host_stream/app_header_init.c +++ b/src/host_stream/app_header_init.c @@ -546,9 +546,7 @@ int app_header_recv_inference(uint32_t buf_addr, bool *bl_run_next_inference) /*2. Grass / motion state*/ if (ana->on_grass) - printf("[STDC] ON GRASS: %.1fs%s\n", - ana->grass_duration_sec, - ana->grass_warning ? " *** GRASS WARNING ***" : ""); + printf("[STDC] ON GRASS: %.1fs%s\n",ana->grass_duration_sec,ana->grass_warning ? " *** GRASS WARNING ***" : ""); else printf("[STDC] ON ROAD\n"); } diff --git a/src/host_stream/handshake.c b/src/host_stream/handshake.c index 2166dd4..3daf0af 100644 --- a/src/host_stream/handshake.c +++ b/src/host_stream/handshake.c @@ -79,7 +79,7 @@ int handshake_build_challenge(handshake_ctx_t *ctx, }; memcpy(ctx->R, TEST_R, HANDSHAKE_R_LEN); time_t now = time(NULL); /* still needed for s_challenge_send_time */ -#else /* ── Normal operation: random R ────────────────────────────────────── */ +#else /* Normal operation: random R */ /* R[0..3] = current time big-endian */ time_t now = time(NULL); ctx->R[0] = (uint8_t)((now >> 24) & 0xFF); @@ -121,7 +121,7 @@ int handshake_build_challenge(handshake_ctx_t *ctx, return 0; } -/* ── Response validation ─────────────────────────────────────────────────── */ +/* Response validation*/ int handshake_process_response(handshake_ctx_t *ctx, const char *json_str) { diff --git a/src/pre_post_proc/stdc_post_process.c b/src/pre_post_proc/stdc_post_process.c index bba0a60..4eaad9c 100644 --- a/src/pre_post_proc/stdc_post_process.c +++ b/src/pre_post_proc/stdc_post_process.c @@ -252,11 +252,11 @@ int stdc_post_process(int model_id, struct kdp_image_s *image_p) ana->left_type[0] = '\0'; { struct { float ratio; float thr; const char *name; } lc[] = { - { ana->left_person_ratio, THR_PERSON_COLLISION, "person" }, - { ana->left_car_ratio, THR_CAR_COLLISION, "vehicle" }, - { ana->left_tree_ratio, THR_TREE_COLLISION, "tree" }, - { ana->left_pond_ratio, THR_POND_COLLISION, "water_hazard" }, - { ana->left_bunker_ratio, THR_BUNKER_COLLISION, "bush" }, + { ana->left_person_ratio, THR_PERSON_ALERT, "person" }, + { ana->left_car_ratio, THR_CAR_ALERT, "vehicle" }, + { ana->left_tree_ratio, THR_TREE_ALERT, "tree" }, + { ana->left_pond_ratio, THR_POND_ALERT, "water_hazard" }, + { ana->left_bunker_ratio, THR_BUNKER_ALERT, "bush" }, }; float best = 0.0f; for (int i = 0; i < 5; i++) { @@ -275,11 +275,11 @@ int stdc_post_process(int model_id, struct kdp_image_s *image_p) ana->right_type[0] = '\0'; { struct { float ratio; float thr; const char *name; } rc[] = { - { ana->right_person_ratio, THR_PERSON_COLLISION, "person" }, - { ana->right_car_ratio, THR_CAR_COLLISION, "vehicle" }, - { ana->right_tree_ratio, THR_TREE_COLLISION, "tree" }, - { ana->right_pond_ratio, THR_POND_COLLISION, "water_hazard" }, - { ana->right_bunker_ratio, THR_BUNKER_COLLISION, "bush" }, + { ana->right_person_ratio, THR_PERSON_ALERT, "person" }, + { ana->right_car_ratio, THR_CAR_ALERT, "vehicle" }, + { ana->right_tree_ratio, THR_TREE_ALERT, "tree" }, + { ana->right_pond_ratio, THR_POND_ALERT, "water_hazard" }, + { ana->right_bunker_ratio, THR_BUNKER_ALERT, "bush" }, }; float best = 0.0f; for (int i = 0; i < 5; i++) {