feat: update Python processors and add utility scripts
- Update ASR, face, OCR, pose processors - Add release pre-flight check script - Add synonym generation, chunk processing scripts - Add face recognition, stamp search utilities
This commit is contained in:
81
scripts/test_visual_chunk.rs
Normal file
81
scripts/test_visual_chunk.rs
Normal file
@@ -0,0 +1,81 @@
|
||||
// 測試視覺分片處理器
|
||||
use momentry_core::core::chunk::types::{Chunk, ChunkRule, ChunkType};
|
||||
use momentry_core::core::processor::visual_chunk::process_visual_chunk;
|
||||
use momentry_core::core::processor::yolo::{YoloFrame, YoloObject, YoloResult};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("=== 測試視覺分片處理器 ===");
|
||||
|
||||
// 創建一個簡單的 YOLO 結果用於測試
|
||||
let mut yolo_result = YoloResult {
|
||||
frame_count: 100,
|
||||
fps: 30.0,
|
||||
frames: Vec::new(),
|
||||
};
|
||||
|
||||
// 創建一些測試幀
|
||||
for i in 0..10 {
|
||||
let objects = vec![
|
||||
YoloObject {
|
||||
class_name: "person".to_string(),
|
||||
class_id: 0,
|
||||
x: 100,
|
||||
y: 200,
|
||||
width: 50,
|
||||
height: 100,
|
||||
confidence: 0.85,
|
||||
},
|
||||
YoloObject {
|
||||
class_name: "car".to_string(),
|
||||
class_id: 2,
|
||||
x: 300,
|
||||
y: 150,
|
||||
width: 80,
|
||||
height: 60,
|
||||
confidence: 0.90,
|
||||
},
|
||||
];
|
||||
|
||||
let frame = YoloFrame {
|
||||
frame: i * 10,
|
||||
timestamp: (i * 10) as f64 / 30.0,
|
||||
objects,
|
||||
};
|
||||
|
||||
yolo_result.frames.push(frame);
|
||||
}
|
||||
|
||||
println!("創建了測試 YOLO 結果: {} 幀", yolo_result.frames.len());
|
||||
|
||||
// 測試 process_visual_chunk 函數
|
||||
let result = process_visual_chunk(
|
||||
1,
|
||||
"test_uuid".to_string(),
|
||||
"/test/path/video.mp4",
|
||||
&yolo_result,
|
||||
0,
|
||||
30.0,
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("視覺分片處理器執行成功!");
|
||||
println!("生成分片數量: {}", result.chunk_count);
|
||||
println!("處理總幀數: {}", result.total_frames);
|
||||
println!("檢測物件總數: {}", result.total_objects);
|
||||
println!("唯一物件類別數: {}", result.unique_classes);
|
||||
|
||||
// 顯示前幾個分片的摘要
|
||||
for (i, chunk) in result.chunks.iter().take(3).enumerate() {
|
||||
println!("分片 {}:", i);
|
||||
println!(" ID: {}", chunk.chunk_id);
|
||||
println!(" 類型: {:?}", chunk.chunk_type);
|
||||
println!(" 規則: {:?}", chunk.rule);
|
||||
println!(" 幀範圍: {} - {}", chunk.start_frame, chunk.end_frame);
|
||||
println!(" 持續時間: {:.2}s", chunk.duration_seconds());
|
||||
println!(" 物件統計: {:?}", chunk.visual_stats);
|
||||
}
|
||||
|
||||
println!("\n=== 測試完成 ===");
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user