feat: add MediaPipe Pose support (highest accuracy)

問題:
- Apple Vision Pose 準確率太低
- YOLOv8 Pose 效果也不好
- 需要 MediaPipe Pose (Google)

新增:
- ✅ pose_processor_mediapipe.py (Python)
- ✅ Worker 支持 MediaPipe Pose
- ✅ model_complexity=2 (最準確)

處理器優先級:
1. MediaPipe Pose (最高準確率) ← 新增
2. Rust Pose
3. Swift Pose (Apple Vision)
4. Python YOLOv8

技術:
- MediaPipe Pose: 33 關鍵點
- 支持遮擋和困難姿勢
- CPU 運算(較慢但準確)

測試:
- ✅ 編譯成功
- ⚠️ 需要實際測試準確率
This commit is contained in:
Accusys
2026-09-28 00:15:49 +08:00
parent cc4cb1f9f1
commit 33ee2d37c9
2 changed files with 283 additions and 1 deletions
+80 -1
View File
@@ -159,6 +159,45 @@ pub async fn process_pose(
let executor = PythonExecutor::new()?;
// Check for MediaPipe Pose first (highest accuracy)
let mediapipe_script = executor.script_path("pose_processor_mediapipe.py");
if mediapipe_script.exists() {
tracing::info!("[POSE] Using MediaPipe Pose for interpolation (highest accuracy): {:?}", mediapipe_script);
let mut args = vec![video_path.to_string(), output_path.to_string()];
if let Some(u) = uuid {
args.push("--uuid".to_string());
args.push(u.to_string());
}
args.push("--model-complexity".to_string());
args.push("2".to_string()); // Highest accuracy
executor
.run_with_frames(
"pose_processor_mediapipe.py",
&[video_path, output_path],
uuid,
"POSE",
Some(POSE_TIMEOUT),
frames,
)
.await
.with_context(|| format!("Failed to run MediaPipe Pose"))?;
let json_str = std::fs::read_to_string(output_path)
.context("Failed to read MediaPipe POSE output")?;
let result: PoseResult = serde_json::from_str(&json_str)
.context("Failed to parse MediaPipe POSE output")?;
tracing::info!(
"[POSE] MediaPipe Pose interpolation completed: {} frames",
result.frames.len()
);
return Ok(result);
}
tracing::info!("[POSE] MediaPipe Pose not found, trying other processors");
// Rust processor path (MOMENTRY_USE_RUST_PROCESSORS=1)
if *USE_RUST_PROCESSORS {
if let Some(rust_bin) = executor.rust_binary_path("rust_pose") {
@@ -271,6 +310,46 @@ pub async fn process_pose(
tracing::info!("[POSE] Starting pose estimation: {}", video_path);
// Check for MediaPipe Pose first (highest accuracy)
let mediapipe_script = executor.script_path("pose_processor_mediapipe.py");
if mediapipe_script.exists() {
tracing::info!("[POSE] Using MediaPipe Pose (highest accuracy): {:?}", mediapipe_script);
let mut args = vec![video_path.to_string(), output_path.to_string()];
if let Some(u) = uuid {
args.push("--uuid".to_string());
args.push(u.to_string());
}
args.push("--model-complexity".to_string());
args.push("2".to_string()); // Highest accuracy
executor
.run_with_frames(
"pose_processor_mediapipe.py",
&[video_path, output_path],
uuid,
"POSE",
Some(POSE_TIMEOUT),
frames,
)
.await
.with_context(|| format!("Failed to run MediaPipe Pose"))?;
let json_str = std::fs::read_to_string(output_path)
.context("Failed to read MediaPipe POSE output")?;
let result: PoseResult = serde_json::from_str(&json_str)
.context("Failed to parse MediaPipe POSE output")?;
tracing::info!(
"[POSE] MediaPipe Pose completed: {} frames, {} total poses",
result.frames.len(),
result.frames.iter().map(|f| f.persons.len()).sum::<usize>()
);
return Ok(result);
}
tracing::info!("[POSE] MediaPipe Pose not found, trying other processors");
// Rust processor path (MOMENTRY_USE_RUST_PROCESSORS=1)
if *USE_RUST_PROCESSORS {
if let Some(rust_bin) = executor.rust_binary_path("rust_pose") {
@@ -300,7 +379,7 @@ pub async fn process_pose(
);
}
// Swift processor path (preferred over Python)
// Swift processor path (Apple Vision - faster but lower accuracy)
let swift_pose_path = std::path::Path::new(
"/Users/accusys/momentry_core/scripts/swift_processors/.build/release/swift_pose"
);