Spaces:
Sleeping

File size: 1,859 Bytes
6e01233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Debug script to check hand detection on specific images.
"""

import sys
import cv2
import numpy as np
from pathlib import Path

project_root = Path(__file__).parent.parent.parent.parent
src_path = project_root / 'src'
sys.path.insert(0, str(src_path))

from feature_extraction.mediapipe_hand_extractor import MediaPipeHandExtractor


def test_image(image_path: str):
    """Test hand detection on a specific image."""
    print("=" * 60)
    print(f"Testing: {image_path}")
    print("=" * 60)

    extractor = MediaPipeHandExtractor()

    img_path = Path(image_path)
    if not img_path.exists():
        print(f"✗ Image not found: {img_path}")
        return

    image = cv2.imread(str(img_path))
    if image is None:
        print(f"✗ Failed to load image")
        return

    print(f"\nImage info:")
    print(f"  Shape: {image.shape}")
    print(f"  Dtype: {image.dtype}")
    print(f"  Min/Max: {image.min()}/{image.max()}")

    # Extract features
    features = extractor.extract(image)

    print(f"\nMediaPipe Results:")
    print(f"  Hand detected: {features.metadata.get('hand_detected', False)}")
    print(f"  Extraction time: {features.extraction_time_ms:.2f}ms")
    print(f"  Feature shape: {features.shape}")
    print(f"  Feature min/max: {features.features.min():.3f}/{features.features.max():.3f}")
    print(f"  All zeros: {np.allclose(features.features, 0.0)}")

    # Check settings
    print(f"\nMediaPipe Settings:")
    print(f"  static_image_mode: False")
    print(f"  min_detection_confidence: 0.5")
    print(f"  min_tracking_confidence: 0.5")
    print(f"  model_complexity: 0")

    extractor.close()


if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('image_path', help='Path to image')
    args = parser.parse_args()

    test_image(args.image_path)