File size: 3,471 Bytes
c269c95
375924d
 
c269c95
 
 
 
375924d
 
c269c95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375924d
 
 
fe675d0
 
375924d
 
fe675d0
375924d
 
 
 
 
 
fe675d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375924d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c269c95
ce51e88
 
9a82bce
 
 
 
ce51e88
9a82bce
 
ce51e88
 
8539a00
 
 
 
 
 
 
 
 
 
375924d
 
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import type { MemoryBucket, SensingState } from "../types";

const AFFECT_EMOJI: Record<string, string> = {
  HAPPY: "😊",
  FRUSTRATED: "😤",
  NEUTRAL: "😐",
  SURPRISED: "😲",
};

const ZONE_LABEL: Record<MemoryBucket, string> = {
  family:        "👨‍👩‍👧 Family",
  medical:       "🏥 Medical",
  social:        "👥 Social",
  hobbies:       "🎨 Hobbies",
  daily_routine: "🌅 Routine",
};

function GazeZoneMap({ active }: { active: MemoryBucket | null }) {
  const zone = (bucket: MemoryBucket) => (
    <div
      key={bucket}
      className={`gaze-zone${active === bucket ? " gaze-zone--active" : ""}`}
    >
      {ZONE_LABEL[bucket]}
    </div>
  );

  return (
    <div className="gaze-zone-map">
      <div className="gaze-zone-row">
        {zone("family")}
        {zone("medical")}
      </div>
      <div className="gaze-zone-row">
        {zone("social")}
      </div>
      <div className="gaze-zone-row">
        {zone("hobbies")}
        {zone("daily_routine")}
      </div>
    </div>
  );
}

interface Props {
  sensing: SensingState;
  webcamActive: boolean;
  calibrated?: boolean;
  onRecalibrate?: () => void;
}

export function SensingStatus({ sensing, webcamActive, calibrated, onRecalibrate }: Props) {
  if (!webcamActive) {
    return <p className="sensing-off">Webcam off</p>;
  }

  return (
    <div className="sensing-status">
      {calibrated !== undefined && (
        <div className="sensing-row">
          <span className="sensing-label">Calibration</span>
          <span className="sensing-value">
            {calibrated ? "✓ ready" : "—"}
            {onRecalibrate && (
              <button
                type="button"
                className="recalibrate-btn"
                onClick={onRecalibrate}
              >
                Recalibrate
              </button>
            )}
          </span>
        </div>
      )}
      <div className="sensing-row">
        <span className="sensing-label">Affect</span>
        <span className="sensing-value">
          {AFFECT_EMOJI[sensing.affect ?? "NEUTRAL"]}{" "}
          {sensing.affect ?? "NEUTRAL"}
        </span>
      </div>
      <div className="sensing-row">
        <span className="sensing-label">Gesture</span>
        <span className="sensing-value">
          {sensing.gestureTag ?? "none"}
        </span>
      </div>
      <div className="sensing-row">
        <span className="sensing-label">Gaze</span>
        <span className="sensing-value">
          {sensing.gazeBucket ?? "none"}
        </span>
      </div>
      <GazeZoneMap active={sensing.gazeZone} />
      <div className="sensing-row">
        <span className="sensing-label">Head</span>
        <span className="sensing-value">{sensing.headSignal ?? "steady"}</span>
      </div>
      <div className="sensing-row sensing-debug">
        <span className="sensing-label">  ↳ p/y/r</span>
        <span className="sensing-value">
          {sensing.headDebug.pitch}° / {sensing.headDebug.yaw}° / {sensing.headDebug.roll}°
          {"  "}(x{sensing.headDebug.crossings})
        </span>
      </div>
      <div className="sensing-row">
        <span className="sensing-label">Air-writing</span>
        <span className="sensing-value">
          {sensing.airWritingActive
            ? "✏️ drawing…"
            : sensing.airWrittenText
            ? sensing.airWrittenText
            : "none"}
        </span>
      </div>
    </div>
  );
}