-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pose_estimation.py
More file actions
71 lines (52 loc) · 1.88 KB
/
test_pose_estimation.py
File metadata and controls
71 lines (52 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""
Test script for Phase 4 pose estimation using Face Demo images.
"""
import os
import cv2
import sys
sys.path.append('.')
from app.core.pose_estimator import PoseEstimator
def test_pose_estimation():
"""Test pose estimation on Face Demo images."""
pe = PoseEstimator()
demo_dir = "Face Demo"
test_images = {
'center': 'center.png',
'left': 'left.png',
'right': 'right.png',
'up': 'up.png',
'down': 'down.png',
'roll_left': 'roll_left.png',
'roll_right': 'roll_right.png'
}
print("Testing Phase 4 Pose Estimation")
print("=" * 40)
for pose_name, filename in test_images.items():
image_path = os.path.join(demo_dir, filename)
if not os.path.exists(image_path):
print(f"[FAIL] {pose_name}: Image not found at {image_path}")
continue
try:
image = cv2.imread(image_path)
if image is None:
print(f"[FAIL] {pose_name}: Could not load image")
continue
pose_data = pe.estimate(image)
if not pose_data:
print(f"[FAIL] {pose_name}: Pose estimation failed (no face detected)")
continue
yaw = pose_data['yaw']
pitch = pose_data['pitch']
roll = pose_data['roll']
is_valid = pe.is_pose_valid(yaw, pitch, roll, pose_name)
status = "PASS" if is_valid else "WARN"
print(f"[{status}] {pose_name}: yaw={yaw:.1f}, pitch={pitch:.1f}, roll={roll:.1f}")
feedback = pe.get_pose_feedback(yaw, pitch, roll, pose_name)
print(f" Feedback: {feedback}")
except Exception as e:
print(f"[FAIL] {pose_name}: Error - {str(e)}")
print()
print("Pose estimation test completed!")
if __name__ == "__main__":
test_pose_estimation()