fix: correct face detection threshold defaults
- Changed min_confidence from 50.0 to 0.5 (Vision uses 0.0-1.0 range) - Changed min_size from 32 to 1 (was filtering out all small faces) - Changed min_capture_quality from 25.0 to 0.25 - Fixes issue where all videos showed 0 faces detected Root cause: admin_config.rs used wrong defaults (50.0/32) instead of config.rs constants (0.5/1), causing Vision framework to filter out ALL faces because confidence threshold exceeded valid range. Verified: IMG_9449 now correctly detects 191 faces (was 0).
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
use axum::{
|
||||
extract::State,
|
||||
http::StatusCode,
|
||||
response::Json,
|
||||
Router,
|
||||
routing::{get, post, put},
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::core::admin_config::{VlmPrompt, PartialAdminConfig};
|
||||
use crate::api::types::AppState;
|
||||
|
||||
pub fn admin_config_routes() -> Router<AppState> {
|
||||
Router::new()
|
||||
.route("/api/v1/admin/config", get(get_config))
|
||||
.route("/api/v1/admin/config", post(update_config))
|
||||
.route("/api/v1/admin/config/vlm_prompts", get(get_vlm_prompts))
|
||||
.route("/api/v1/admin/config/vlm_prompts/:key", get(get_vlm_prompt))
|
||||
.route("/api/v1/admin/config/vlm_prompts/:key", put(update_vlm_prompt))
|
||||
.route("/api/v1/admin/config/reload", post(reload_config))
|
||||
}
|
||||
|
||||
pub async fn get_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
let config = state.admin_config_manager.get_full_config().await;
|
||||
Ok(Json(serde_json::to_value(config).unwrap_or_default()))
|
||||
}
|
||||
|
||||
pub async fn update_config(
|
||||
State(state): State<AppState>,
|
||||
Json(partial): Json<PartialAdminConfig>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.update_partial_config(partial).await {
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": "Config updated"
|
||||
}))),
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_vlm_prompts(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
let prompts = state.admin_config_manager.get_all_vlm_prompts().await;
|
||||
Ok(Json(serde_json::to_value(prompts).unwrap_or_default()))
|
||||
}
|
||||
|
||||
pub async fn get_vlm_prompt(
|
||||
State(state): State<AppState>,
|
||||
axum::extract::Path(key): axum::extract::Path<String>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.get_vlm_prompt(&key).await {
|
||||
Some(prompt) => Ok(Json(serde_json::to_value(prompt).unwrap_or_default())),
|
||||
None => Err(StatusCode::NOT_FOUND),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_vlm_prompt(
|
||||
State(state): State<AppState>,
|
||||
axum::extract::Path(key): axum::extract::Path<String>,
|
||||
Json(prompt): Json<VlmPrompt>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.update_vlm_prompt(&key, prompt).await {
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": format!("Prompt '{}' updated", key)
|
||||
}))),
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn reload_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.reload().await {
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": "Config reloaded"
|
||||
}))),
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user