File size: 2,426 Bytes
6f3fe10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Terminal-only decorative output for `measure_finger.py` CLI.

Anything with emoji, ASCII headers, or "press-release" phrasing belongs
here. `src/` production code and the web demo use the `logger` from
`src.logging_config` instead so log streams stay clean and structured.
"""

from __future__ import annotations

from typing import Any, Dict, Optional


def print_image_loaded(path: str, shape: tuple) -> None:
    print(f"Loaded image: {path} ({shape[1]}x{shape[0]})")


def print_skip_card_warning() -> None:
    print("TESTING MODE: Skipping card detection (using dummy scale factor)")


def print_result_path(path: str) -> None:
    print(f"Results saved to: {path}")


def print_single_result(result: Dict[str, Any]) -> None:
    """One-screen summary after a successful single-finger measurement."""
    if result.get("fail_reason"):
        print(f"Measurement failed: {result['fail_reason']}")
        return
    print(f"Finger diameter: {result['finger_outer_diameter_cm']} cm")
    if result.get("raw_diameter_cm"):
        print(f"  (raw: {result['raw_diameter_cm']} cm, calibrated)")
    rec = result.get("ring_size")
    if rec:
        print(f"Ring size: best match {rec['best_match']}, recommended {rec['range_min']}-{rec['range_max']}")
    print(f"Confidence: {result['confidence']}")


def print_multi_result(result: Dict[str, Any]) -> None:
    """One-screen summary after a multi-finger measurement."""
    if result.get("fail_reason"):
        print(f"Measurement failed: {result['fail_reason']}")
        return
    print("\n=== Multi-Finger Results ===")
    print(
        f"Fingers: {result.get('fingers_succeeded', 0)}/"
        f"{result.get('fingers_measured', 0)} succeeded"
    )
    for fn, pf in result.get("per_finger", {}).items():
        if pf.get("status") == "ok":
            print(
                f"  {fn.capitalize()}: {pf['diameter_cm']:.2f}cm "
                f"-> Size {pf['best_match']} "
                f"(range {pf['range'][0]}-{pf['range'][1]})"
            )
        else:
            print(f"  {fn.capitalize()}: FAILED ({pf.get('fail_reason', 'unknown')})")
    if result.get("overall_best_size"):
        print(f"\nOverall Best Size: {result['overall_best_size']}")
        print(f"Recommended Range: {result['overall_range_min']}-{result['overall_range_max']}")


def print_error(message: str) -> None:
    import sys
    print(f"Error: {message}", file=sys.stderr)