Spaces:
Sleeping

File size: 2,352 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
68
69
70
71
72
73
74
75
76
77
78
"""
Vizualizálja miért nem talál kezet bizonyos képeken.
"""

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 analyze_image(image_path: str):
    """Részletes elemzés egy képről."""

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

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

    print("=" * 60)
    print(f"Analyzing: {img_path.name}")
    print("=" * 60)

    # Image properties
    print(f"\nImage properties:")
    print(f"  Shape: {image.shape}")
    print(f"  Dtype: {image.dtype}")
    print(f"  Value range: {image.min()}-{image.max()}")
    print(f"  Mean brightness: {image.mean():.1f}")

    # Check if it's grayscale disguised as RGB
    if len(image.shape) == 3:
        is_grayscale = np.allclose(image[:,:,0], image[:,:,1]) and np.allclose(image[:,:,1], image[:,:,2])
        print(f"  Effectively grayscale: {is_grayscale}")

    # Test MediaPipe
    extractor = MediaPipeHandExtractor()
    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")

    if not features.metadata.get('hand_detected', False):
        print("\n⚠️  FAILED TO DETECT HAND")
        print("\nPossible reasons:")
        print("  • Kéz túl kicsi vagy levágva")
        print("  • Szokatlan pózíció/szög")
        print("  • Rossz megvilágítás/háttér")
        print("  • CGI/rajzolt kéz (nem valódi fotó)")
        print("  • Ujjak összeérnek/takarják egymást")
    else:
        print("\n✓ Hand detected successfully")
        print(f"  Landmarks: {features.metadata.get('num_landmarks', 0)}")

    extractor.close()
    print()


if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('images', nargs='+', help='Image paths')
    args = parser.parse_args()

    for img in args.images:
        analyze_image(img)