Implement webUI setting for min sharpness
This commit is contained in:
parent
8735f8ef6b
commit
4c98fc8d60
3 changed files with 98 additions and 3 deletions
|
|
@ -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}
|
||||
</div>
|
||||
|
||||
<!-- Blur Detection Section -->
|
||||
<div class="setting-section">
|
||||
<div class="section-header">
|
||||
<span class="section-title">Blur Filter</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={config.processing.blur.enabled}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if config.processing.blur.enabled}
|
||||
<div class="setting-row sub-setting">
|
||||
<label for="min-sharpness">
|
||||
<span class="setting-label">Min Sharpness</span>
|
||||
<span class="setting-hint">Discard blurry faces</span>
|
||||
</label>
|
||||
<div class="setting-control">
|
||||
<input
|
||||
id="min-sharpness"
|
||||
type="range"
|
||||
bind:value={config.processing.blur.min_sharpness}
|
||||
min="10"
|
||||
max="50"
|
||||
step="1"
|
||||
/>
|
||||
<span class="value">{Number(config.processing.blur.min_sharpness).toFixed(0)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Head Pose Filter Section -->
|
||||
<div class="setting-section">
|
||||
<div class="section-header">
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<usize>,
|
||||
pub face_resolution: Option<FaceResolutionConfig>,
|
||||
pub blur: Option<BlurConfig>,
|
||||
pub brightness: Option<BrightnessConfig>,
|
||||
pub head_pose: Option<HeadPoseConfig>,
|
||||
pub eye_filter: Option<EyeFilterConfig>,
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue