fix: restore Apple Vision default detection thresholds (0.5 / 1px)

job_worker.rs was overriding Apple Vision defaults with 0.75/64 even when
no face_settings were provided, causing fewer faces to be detected.

Now detect all faces with Vision defaults (confidence 0.5, min_size 1px);
filter later for display via face_filter settings.
This commit is contained in:
Accusys
2026-08-12 09:16:30 +08:00
parent 2e4559715b
commit 86f1fe8852
3 changed files with 94 additions and 4 deletions
+90
View File
@@ -7,6 +7,25 @@ const PROFILE_VERSION: &str = "1.0";
// ─── Data Types ───
/// Per-file face detection thresholds. `min_confidence` is 0–100 (%),
/// `min_size` is px. Mirrors `videos.face_filter` DB column (same units).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FaceFilterSettings {
pub min_confidence: f64,
pub min_size: i32,
}
impl FaceFilterSettings {
/// Mirrors Apple Vision default detection thresholds (0.5 / 1px).
/// Filter later for display; detect everything first.
pub fn defaults() -> Self {
Self {
min_confidence: 50.0,
min_size: 1,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileProfile {
pub version: String,
@@ -20,6 +39,7 @@ pub struct FileProfile {
pub key_frame: Option<String>, // filename: {uuid}.key_frame.jpg, video only
pub proxy_path: Option<String>, // 720p proxy path for 1080p+ videos
pub audio_track: Option<String>, // audio track classification: no_audio/silent_audio/music_only/speech_only/speech_with_music
pub face_filter: Option<FaceFilterSettings>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -123,6 +143,7 @@ impl FileProfile {
key_frame: None,
proxy_path: None,
audio_track: None,
face_filter: None,
}
}
@@ -161,6 +182,7 @@ impl FileProfile {
key_frame: None,
proxy_path: None,
audio_track: None,
face_filter: None,
}
}
@@ -289,6 +311,7 @@ impl FileProfile {
key_frame: None,
proxy_path: None,
audio_track: None,
face_filter: None,
}
}
@@ -562,4 +585,71 @@ mod tests {
assert_eq!(restored.file_name, profile.file_name);
assert_eq!(restored.history.len(), 1);
}
#[test]
fn test_face_filter_roundtrip() {
let mut profile = FileProfile::from_registration(
"abc123",
"test.mp4",
"video",
"aa:bb:cc:dd:ee:ff",
"2026-01-01T00:00:00Z",
"/Users/test/video.mp4",
"hash123",
120.0,
1920,
1080,
30.0,
3600,
);
assert!(profile.face_filter.is_none());
profile.face_filter = Some(FaceFilterSettings {
min_confidence: 85.0,
min_size: 96,
});
let json = serde_json::to_string(&profile).unwrap();
let restored: FileProfile = serde_json::from_str(&json).unwrap();
let ff = restored.face_filter.unwrap();
assert_eq!(ff.min_confidence, 85.0);
assert_eq!(ff.min_size, 96);
}
#[test]
fn test_old_profile_without_face_filter_deserializes() {
let json = r#"{
"version": "1.0",
"file_uuid": "abc123",
"file_name": "test.mp4",
"file_type": "video",
"birth": {
"mac_address": "aa:bb:cc:dd:ee:ff",
"birthday": "2026-01-01T00:00:00Z",
"original_path": "/Users/test",
"original_filename": "test.mp4",
"canonical_path": "/Users/test/video.mp4",
"content_hash": "hash123"
},
"current": {
"path": "/Users/test/video.mp4",
"file_name": "test.mp4",
"file_type": "video"
},
"history": [],
"metadata": null,
"key_frame": null,
"proxy_path": null,
"audio_track": null
}"#;
let profile: FileProfile = serde_json::from_str(json).unwrap();
assert_eq!(profile.file_uuid, "abc123");
assert!(profile.face_filter.is_none());
}
#[test]
fn test_face_filter_defaults_match_detection_defaults() {
let d = FaceFilterSettings::defaults();
assert_eq!(d.min_confidence, 50.0);
assert_eq!(d.min_size, 1);
}
}