From 4c98fc8d6098b1c22bf28f0b31ce661dd6df64d1 Mon Sep 17 00:00:00 2001 From: Arnaud_Cayrol Date: Mon, 9 Feb 2026 19:40:18 +0100 Subject: [PATCH] Implement webUI setting for min sharpness --- .../src/lib/components/SettingsPanel.svelte | 80 ++++++++++++++++++- frontend/src/lib/constants.js | 4 + src/web/handlers/config.rs | 17 +++- 3 files changed, 98 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/SettingsPanel.svelte b/frontend/src/lib/components/SettingsPanel.svelte index 07f0a85..d37cefe 100644 --- a/frontend/src/lib/components/SettingsPanel.svelte +++ b/frontend/src/lib/components/SettingsPanel.svelte @@ -28,6 +28,10 @@ min_brightness: 0.1, max_brightness: 0.95, }, + blur: { + enabled: false, + min_sharpness: 15.0, + }, head_pose: { enabled: true, max_yaw: 35.0, @@ -73,10 +77,53 @@ error = null; saveMessage = null; try { + // Ensure all numeric values are proper numbers (not strings from range inputs) + const configToSend = { + processing: { + max_workers: Number(config.processing.max_workers), + face_resolution: { + enabled: config.processing.face_resolution.enabled, + min_size: Number(config.processing.face_resolution.min_size), + }, + brightness: { + enabled: config.processing.brightness.enabled, + min_brightness: Number(config.processing.brightness.min_brightness), + max_brightness: Number(config.processing.brightness.max_brightness), + }, + blur: { + enabled: config.processing.blur.enabled, + min_sharpness: Number(config.processing.blur.min_sharpness), + }, + head_pose: { + enabled: config.processing.head_pose.enabled, + max_yaw: Number(config.processing.head_pose.max_yaw), + max_pitch: Number(config.processing.head_pose.max_pitch), + max_roll: Number(config.processing.head_pose.max_roll), + }, + eye_filter: { + enabled: config.processing.eye_filter.enabled, + min_ear: Number(config.processing.eye_filter.min_ear), + }, + output: { + size: Number(config.processing.output.size), + keep_intermediates: config.processing.output.keep_intermediates, + }, + alignment: { + eye_distance: Number(config.processing.alignment.eye_distance), + }, + }, + video: { + enabled: config.video.enabled, + framerate: Number(config.video.framerate), + codec: config.video.codec, + crf: Number(config.video.crf), + }, + }; + const res = await fetch('/api/config', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(config), + body: JSON.stringify(configToSend), }); if (!res.ok) throw res; config = await res.json(); @@ -207,6 +254,37 @@ {/if} + +
+
+ Blur Filter + +
+ + {#if config.processing.blur.enabled} +
+ +
+ + {Number(config.processing.blur.min_sharpness).toFixed(0)} +
+
+ {/if} +
+
diff --git a/frontend/src/lib/constants.js b/frontend/src/lib/constants.js index ecee837..76e8e05 100644 --- a/frontend/src/lib/constants.js +++ b/frontend/src/lib/constants.js @@ -133,6 +133,10 @@ export const DEFAULT_CONFIG = { enabled: true, min_size: 80, }, + blur: { + enabled: false, + min_sharpness: 15.0, + }, brightness: { enabled: false, min_brightness: 0.1, diff --git a/src/web/handlers/config.rs b/src/web/handlers/config.rs index 6922cf6..beff1ca 100644 --- a/src/web/handlers/config.rs +++ b/src/web/handlers/config.rs @@ -1,8 +1,8 @@ //! Configuration endpoints. use crate::config::{ - AlignmentConfig, BrightnessConfig, EyeFilterConfig, FaceResolutionConfig, HeadPoseConfig, - OutputConfig, ProcessingConfig, VideoConfig, + AlignmentConfig, BlurConfig, BrightnessConfig, EyeFilterConfig, FaceResolutionConfig, + HeadPoseConfig, OutputConfig, ProcessingConfig, VideoConfig, }; use crate::web::state::AppState; use axum::{extract::State, http::StatusCode, response::Json}; @@ -39,6 +39,7 @@ pub struct ConfigUpdateRequest { pub struct ProcessingConfigUpdate { pub max_workers: Option, pub face_resolution: Option, + pub blur: Option, pub brightness: Option, pub head_pose: Option, pub eye_filter: Option, @@ -96,6 +97,15 @@ fn validate_processing_config(proc: &ProcessingConfigUpdate) -> Result<(), Valid } } + if let Some(ref bl) = proc.blur { + if bl.enabled && bl.min_sharpness < 0.0 { + return Err(ValidationError::new( + "processing.blur.min_sharpness", + format!("must be non-negative, got {}", bl.min_sharpness), + )); + } + } + if let Some(ref br) = proc.brightness { if br.enabled { if br.min_brightness < 0.0 || br.min_brightness > 1.0 { @@ -238,6 +248,9 @@ pub async fn update_config( if let Some(v) = proc.face_resolution { config.processing.face_resolution = v; } + if let Some(v) = proc.blur { + config.processing.blur = v; + } if let Some(v) = proc.brightness { config.processing.brightness = v; }