separate alert and collision threshold

This commit is contained in:
miketsai 2026-07-16 17:33:02 +08:00
parent 4d37fb5075
commit 174200eb03
4 changed files with 25 additions and 20 deletions

View File

@ -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

View File

@ -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");
}

View File

@ -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)
{

View File

@ -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++) {