codrizsain commited on
Commit
e299c0a
·
verified ·
1 Parent(s): 10e28f7

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +233 -184
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>AI Vision - v19 Smooth Performance</title>
7
 
8
  <script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script>
@@ -21,118 +21,166 @@
21
  margin: 0;
22
  padding: 20px;
23
  min-height: 100vh;
 
24
  }
25
 
26
- h2 { margin-bottom: 5px; color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
27
- p { color: #94a3b8; margin-top: 0; text-align: center; }
28
-
29
  #startBtn {
30
- background: linear-gradient(135deg, #ec4899, #8b5cf6);
31
- color: white;
32
- border: none;
33
- padding: 15px 35px;
34
- font-size: 18px;
35
- border-radius: 50px;
36
- cursor: pointer;
37
- font-weight: bold;
38
- box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
39
- transition: all 0.3s ease;
40
- margin: 20px 0;
41
  text-transform: uppercase;
42
  }
43
- #startBtn:hover {
44
- transform: translateY(-3px);
45
- box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6);
46
- background: linear-gradient(135deg, #f472b6, #a78bfa);
 
 
47
  }
48
 
49
- #statusContainer {
50
- background: rgba(15, 23, 42, 0.8);
51
- border: 1px solid #334155;
52
- padding: 15px 30px;
53
- border-radius: 12px;
54
- margin-bottom: 20px;
55
- min-width: 300px;
56
- text-align: center;
57
- box-shadow: 0 4px 6px rgba(0,0,0,0.3);
58
  }
59
- #statusPose { font-size: 24px; font-weight: bold; color: #94a3b8; transition: color 0.3s; }
60
 
61
- .monitor-container { position: relative; }
 
 
 
 
 
 
 
 
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  canvas {
64
- border: 3px solid #3b82f6;
65
- box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
66
- border-radius: 16px;
67
- background-color: #000;
68
- width: 640px;
69
- height: 480px;
70
- max-width: 90vw;
71
- object-fit: cover;
72
  transform: scaleX(-1);
73
  }
74
 
75
- /* PERBAIKAN CSS: Animasi GIF Transisi Halus (Anti-Blink) */
76
  .pose1-anim {
77
- position: absolute;
78
- opacity: 0; /* Default tidak terlihat */
79
- border-radius: 8px;
80
- z-index: 10;
81
- border: 2px solid #eab308;
82
- box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
83
- pointer-events: none;
84
- /* Transisi opacity ditambahkan agar memudar perlahan saat AI berkedip */
85
- transition: opacity 0.2s ease-in-out, left 0.1s linear, top 0.1s linear;
86
  transform: scaleX(-1);
87
  }
88
 
89
- #biometricContainer {
90
- position: absolute;
91
- top: 15px;
92
- right: 15px;
93
- background: rgba(15, 23, 42, 0.85);
94
- border: 2px solid #3b82f6;
95
- padding: 15px;
96
- border-radius: 12px;
97
- box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
98
- z-index: 20;
99
- backdrop-filter: blur(5px);
100
- transition: border-color 0.3s, box-shadow 0.3s;
101
- min-width: 150px;
102
  }
103
- .bio-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-top: 8px; margin-bottom: 2px;}
104
- .bio-label:first-child { margin-top: 0; }
105
- .bio-value { font-size: 18px; font-weight: bold; color: #f8fafc; }
106
- .divider { height: 1px; background-color: #334155; margin: 8px 0; }
 
 
 
 
 
 
 
 
107
  </style>
108
  </head>
109
  <body>
110
 
111
- <h2>🤖 AI Vision: Smooth Tracking</h2>
112
- <p>Algoritma Debounce untuk Audio & Visual v19</p>
113
-
114
  <button id="startBtn">▶ Mulai Sistem Deteksi</button>
115
-
116
- <div id="statusContainer">
117
- <div id="statusPose">Menunggu Kamera...</div>
118
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
- <div class="monitor-container">
121
- <div id="biometricContainer">
122
- <div class="bio-label">Kondisi Mood</div>
123
- <div id="moodValue" class="bio-value">Menganalisis...</div>
124
- <div class="divider"></div>
125
- <div class="bio-label">Estimasi Anatomi</div>
126
- <div id="genderValue" class="bio-value" style="color: #cbd5e1;">Memindai...</div>
 
 
 
 
 
 
 
 
 
 
127
  </div>
128
 
129
- <video id="videoElement" style="display: none;" autoplay playsinline></video>
130
- <canvas id="outputCanvas" width="640" height="480"></canvas>
131
-
132
- <img id="pose1Anim1" class="pose1-anim" src="animasi1.gif" alt="Pose 1">
133
- <img id="pose1Anim2" class="pose1-anim" src="animasi1.gif" alt="Pose 2">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  </div>
135
 
 
136
  <audio id="audio1" src="suara1.mp3"></audio>
137
  <audio id="audio2" src="suara2.mp3"></audio>
138
  <audio id="audio3" src="suara3.mp3"></audio>
@@ -144,9 +192,13 @@
144
  const canvasElement = document.getElementById('outputCanvas');
145
  const canvasCtx = canvasElement.getContext('2d');
146
  const startBtn = document.getElementById('startBtn');
147
- const statusPose = document.getElementById('statusPose');
 
148
 
149
- const biometricContainer = document.getElementById('biometricContainer');
 
 
 
150
  const moodValue = document.getElementById('moodValue');
151
  const genderValue = document.getElementById('genderValue');
152
 
@@ -156,8 +208,14 @@
156
  document.getElementById('audio3'), document.getElementById('audio4'),
157
  document.getElementById('audio5')
158
  ];
159
-
160
- // VARIABEL MEMORI (ANTI-LAG & ANTI-STUTTER)
 
 
 
 
 
 
161
  let memoryActivePoses = [];
162
  let memoryTimer = 0;
163
  let currentFaceLandmarks = null;
@@ -165,33 +223,49 @@
165
  function getDistance(p1, p2) { return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }
166
 
167
  function analyzeFaceBiometrics(faceLandmarks) {
168
- const leftMouth = faceLandmarks[61]; const rightMouth = faceLandmarks[291];
169
- const topLip = faceLandmarks[13]; const bottomLip = faceLandmarks[14];
170
- const leftEye = faceLandmarks[33]; const rightEye = faceLandmarks[263];
171
-
172
- const mouthWidth = getDistance(leftMouth, rightMouth);
173
- const mouthHeight = getDistance(topLip, bottomLip);
174
- const faceScale = getDistance(leftEye, rightEye);
175
-
176
- const smileRatio = mouthWidth / faceScale;
177
- const openRatio = mouthHeight / faceScale;
178
-
179
- let moodText = "Netral 😐"; let moodColor = "#3b82f6";
180
- if (openRatio > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; }
181
- else if (smileRatio > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; }
182
-
183
- const leftCheek = faceLandmarks[234]; const rightCheek = faceLandmarks[454];
184
- const leftJaw = faceLandmarks[132]; const rightJaw = faceLandmarks[361];
185
-
186
- const cheekWidth = getDistance(leftCheek, rightCheek);
187
- const jawWidth = getDistance(leftJaw, rightJaw);
188
- const jawToCheekRatio = jawWidth / cheekWidth;
189
 
190
- let genderText = "Memindai..."; let genderColor = "#cbd5e1";
191
- if (jawToCheekRatio > 0.755) { genderText = "Pria 👨"; genderColor = "#60a5fa"; }
192
- else { genderText = "Wanita 👩"; genderColor = "#f472b6"; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
- return { moodText, moodColor, genderText, genderColor };
195
  }
196
 
197
  function classifyPose(landmarks) {
@@ -201,14 +275,11 @@
201
  const pinkyOpen = landmarks[20].y < landmarks[18].y;
202
  const thumbOpen = getDistance(landmarks[4], landmarks[5]) > 0.08;
203
 
204
- if (!indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 5, name: "✊ Kepalan", color: "#ef4444" };
205
- if (indexOpen && middleOpen && ringOpen && pinkyOpen && thumbOpen) return { id: 4, name: "🖐️ Telapak", color: "#3b82f6" };
206
- if (indexOpen && middleOpen && !ringOpen && !pinkyOpen) return { id: 2, name: "✌️ Victory", color: "#a855f7" };
207
- if (thumbOpen && indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 1, name: "👉 Tunjuk & Jempol", color: "#eab308" };
208
-
209
- const thumbIndexTipDist = getDistance(landmarks[4], landmarks[8]);
210
- if (thumbIndexTipDist < 0.05 && middleOpen && ringOpen && pinkyOpen) return { id: 3, name: "👌 Okay", color: "#10b981" };
211
-
212
  return null;
213
  }
214
 
@@ -220,8 +291,6 @@
220
  });
221
 
222
  const hands = new Hands({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`; }});
223
-
224
- // PERBAIKAN PERFORMA: modelComplexity diturunkan ke 0 agar 3x lebih cepat memproses 2 tangan sekaligus
225
  hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
226
 
227
  hands.onResults((results) => {
@@ -229,98 +298,78 @@
229
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
230
  canvasCtx.drawImage(results.image, 0, 0, canvasElement.width, canvasElement.height);
231
 
 
232
  if (currentFaceLandmarks) {
233
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_TESSELATION, {color: '#06b6d4', lineWidth: 0.5});
234
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYE, {color: '#ec4899', lineWidth: 2});
235
- drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYEBROW, {color: '#ec4899', lineWidth: 2});
236
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYE, {color: '#ec4899', lineWidth: 2});
237
- drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYEBROW, {color: '#ec4899', lineWidth: 2});
238
- drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_FACE_OVAL, {color: '#ec4899', lineWidth: 2});
239
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LIPS, {color: '#ec4899', lineWidth: 2});
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
 
242
- let detectedPosesThisFrame = [];
243
- // Reset opacity GIF (bukan display none, agar tidak kaku)
244
- anims.forEach(a => a.style.opacity = '0');
245
 
246
  if (results.multiHandLandmarks && results.multiHandLandmarks.length > 0) {
247
  results.multiHandLandmarks.forEach((landmarks, index) => {
248
- let boneColor = index === 0 ? '#ec4899' : '#06b6d4';
249
- drawConnectors(canvasCtx, landmarks, HAND_CONNECTIONS, {color: boneColor, lineWidth: 4});
250
  drawLandmarks(canvasCtx, landmarks, {color: '#ffffff', lineWidth: 2, radius: 3});
251
 
252
- let pose = classifyPose(landmarks);
253
- if (pose) detectedPosesThisFrame.push({ ...pose, handIndex: index, wrist: landmarks[0] });
 
 
 
 
 
 
 
 
 
 
 
 
254
  });
255
  }
256
  canvasCtx.restore();
257
 
258
- // RENDER UI & LOGIKA
259
- if (currentFaceLandmarks) {
260
- let bio = analyzeFaceBiometrics(currentFaceLandmarks);
261
- let isPositivePose = detectedPosesThisFrame.some(p => p.id === 1 || p.id === 2 || p.id === 3);
262
- if (bio.moodText === "Senang 😊" && isPositivePose) {
263
- bio.moodText = "Sangat Senang! ✨"; bio.moodColor = "#eab308";
264
- }
265
- moodValue.textContent = bio.moodText; moodValue.style.color = bio.moodColor;
266
- genderValue.textContent = bio.genderText; genderValue.style.color = bio.genderColor;
267
- biometricContainer.style.borderColor = bio.moodColor; biometricContainer.style.boxShadow = `0 0 15px ${bio.moodColor}80`;
268
- } else {
269
- moodValue.textContent = "Wajah Hilang"; moodValue.style.color = "#94a3b8";
270
- genderValue.textContent = "Wajah Hilang"; genderValue.style.color = "#94a3b8";
271
- biometricContainer.style.borderColor = "#334155";
272
- }
273
-
274
- // --- LOGIKA AUDIO DENGAN MEMORI DEBOUNCE ---
275
- let currentIds = detectedPosesThisFrame.map(p => p.id);
276
-
277
  if (currentIds.length > 0) {
278
- let uniquePoseNames = [...new Set(detectedPosesThisFrame.map(p => p.name))];
279
- statusPose.textContent = uniquePoseNames.join(" & ");
280
- statusPose.style.color = detectedPosesThisFrame[0].color;
281
-
282
- // Perbarui posisi GIF dengan halus
283
- detectedPosesThisFrame.forEach((pose, i) => {
284
- if (pose.id === 1 && anims[i]) {
285
- const wrist = pose.wrist;
286
- const leftPos = ((1 - wrist.x) * canvasElement.width) - 75;
287
- const topPos = (wrist.y * canvasElement.height) + 30;
288
-
289
- anims[i].style.opacity = '1'; // Munculkan dengan efek fade
290
- anims[i].style.left = `${leftPos}px`;
291
- anims[i].style.top = `${topPos}px`;
292
- anims[i].style.width = `150px`;
293
- }
294
- });
295
-
296
- // Cek pose baru yang belum ada di memori stabil
297
  let newPoses = currentIds.filter(id => !memoryActivePoses.includes(id));
298
-
299
  if (newPoses.length > 0) {
300
- let primaryNewPoseId = newPoses[0];
301
  sounds.forEach(s => { s.pause(); s.currentTime = 0; });
302
- const soundToPlay = sounds[primaryNewPoseId - 1];
303
  if (soundToPlay) soundToPlay.play();
304
  }
305
 
306
- memoryActivePoses = currentIds; // Simpan memori terbaru
307
- memoryTimer = Date.now(); // Reset stopwatch memori
308
-
309
  } else {
310
- // Tangan tidak terdeteksi. Jangan langsung bersihkan memori! Tunggu 0.5 detik (500ms)
311
  if (Date.now() - memoryTimer > 500) {
312
- if (memoryActivePoses.length > 0) {
313
- statusPose.textContent = "Menunggu formasi jari...";
314
- statusPose.style.color = "#94a3b8";
315
- memoryActivePoses = [];
316
- }
317
  }
318
  }
319
  });
320
 
321
  startBtn.addEventListener('click', () => {
322
  startBtn.style.display = 'none';
323
- statusPose.textContent = "Menyiapkan Kamera...";
324
  sounds.forEach(s => { s.play().then(() => { s.pause(); s.currentTime = 0; }).catch(()=>{}); });
325
 
326
  const camera = new Camera(videoElement, {
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Zero-Team AI - Biometric Dashboard v22</title>
7
 
8
  <script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script>
 
21
  margin: 0;
22
  padding: 20px;
23
  min-height: 100vh;
24
+ overflow-x: hidden;
25
  }
26
 
 
 
 
27
  #startBtn {
28
+ background: linear-gradient(135deg, #a855f7, #ec4899);
29
+ color: white; border: none; padding: 15px 40px;
30
+ font-size: 18px; border-radius: 50px; cursor: pointer;
31
+ font-weight: bold; box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
32
+ transition: all 0.3s ease; margin-bottom: 20px;
 
 
 
 
 
 
33
  text-transform: uppercase;
34
  }
35
+ #startBtn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6); }
36
+
37
+ #mainStatus {
38
+ font-size: 20px; font-weight: bold; color: #94a3b8;
39
+ background: rgba(15, 23, 42, 0.6); padding: 10px 30px;
40
+ border-radius: 20px; border: 1px solid #334155; margin-bottom: 25px;
41
  }
42
 
43
+ /* --- LAYOUT UTAMA (KIRI - TENGAH - KANAN) --- */
44
+ .dashboard-container {
45
+ display: flex; flex-direction: row; gap: 25px;
46
+ align-items: stretch; justify-content: center;
47
+ width: 100%; max-width: 1400px;
 
 
 
 
48
  }
 
49
 
50
+ /* Panel Kiri & Kanan */
51
+ .side-panel {
52
+ background: rgba(15, 23, 42, 0.7);
53
+ border: 2px solid #3b82f6; border-radius: 12px;
54
+ padding: 20px; width: 280px;
55
+ box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
56
+ backdrop-filter: blur(10px);
57
+ display: flex; flex-direction: column; gap: 15px;
58
+ }
59
 
60
+ .side-panel.pink-border { border-color: #ec4899; box-shadow: 0 0 20px rgba(236, 72, 153, 0.3); }
61
+
62
+ .panel-title { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #334155; padding-bottom: 8px; margin-bottom: 5px; }
63
+ .data-item { display: flex; flex-direction: column; gap: 4px; }
64
+ .data-label { font-size: 14px; font-weight: bold; color: #f8fafc; }
65
+ .data-value { font-size: 13px; color: #10b981; }
66
+
67
+ /* Monitor Tengah */
68
+ .center-stage {
69
+ display: flex; flex-direction: column; align-items: center; gap: 20px;
70
+ position: relative;
71
+ }
72
+
73
+ .canvas-container { position: relative; }
74
  canvas {
75
+ border: 3px solid #06b6d4; box-shadow: 0 0 25px rgba(6, 182, 212, 0.4);
76
+ border-radius: 16px; background-color: #000;
77
+ width: 640px; height: 480px; object-fit: cover;
 
 
 
 
 
78
  transform: scaleX(-1);
79
  }
80
 
81
+ /* GIF Transisi Halus */
82
  .pose1-anim {
83
+ position: absolute; opacity: 0; border-radius: 8px; z-index: 10;
84
+ border: 2px solid #eab308; box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
85
+ pointer-events: none; transition: opacity 0.2s, left 0.1s, top 0.1s;
 
 
 
 
 
 
86
  transform: scaleX(-1);
87
  }
88
 
89
+ /* Baris Pose di Bawah */
90
+ .pose-indicators {
91
+ display: flex; gap: 15px; justify-content: center;
 
 
 
 
 
 
 
 
 
 
92
  }
93
+ .pose-box {
94
+ background: rgba(15, 23, 42, 0.8); border: 2px solid #334155;
95
+ border-radius: 12px; padding: 10px 15px; text-align: center;
96
+ width: 70px; transition: all 0.3s ease; opacity: 0.5;
97
+ }
98
+ .pose-box.active {
99
+ border-color: #eab308; background: rgba(234, 179, 8, 0.2);
100
+ box-shadow: 0 0 15px rgba(234, 179, 8, 0.5); opacity: 1; transform: translateY(-5px);
101
+ }
102
+ .pose-emoji { font-size: 24px; margin-bottom: 5px; }
103
+ .pose-name { font-size: 11px; font-weight: bold; color: #f8fafc; }
104
+
105
  </style>
106
  </head>
107
  <body>
108
 
 
 
 
109
  <button id="startBtn">▶ Mulai Sistem Deteksi</button>
110
+ <div id="mainStatus">Sistem Menunggu...</div>
111
+
112
+ <div class="dashboard-container">
113
+ <!-- PANEL KIRI -->
114
+ <div class="side-panel">
115
+ <div class="data-item" style="margin-bottom: 10px;">
116
+ <div class="data-label" style="font-size: 18px; color: #38bdf8;">⚙️ Zero-Team AI v22</div>
117
+ </div>
118
+ <div class="data-item">
119
+ <div class="data-label">👁️ Computer Vision Engine</div>
120
+ </div>
121
+ <div class="data-item">
122
+ <div class="data-label">🖐️ Mediapipe Hands: v0.10.x</div>
123
+ </div>
124
+ <div class="data-item">
125
+ <div class="data-label">🎭 Mediapipe FaceMesh: v0.10.x</div>
126
+ </div>
127
+ <div class="data-item" style="margin-top: 20px;">
128
+ <div class="data-label">🛡️ Status Deteksi:</div>
129
+ <div id="statusKiri" class="data-value" style="color: #94a3b8; font-size: 14px;">Standby</div>
130
+ </div>
131
+ </div>
132
 
133
+ <!-- TENGAH: KAMERA & INDIKATOR POSE -->
134
+ <div class="center-stage">
135
+ <div class="canvas-container">
136
+ <video id="videoElement" style="display: none;" autoplay playsinline></video>
137
+ <canvas id="outputCanvas" width="640" height="480"></canvas>
138
+ <img id="pose1Anim1" class="pose1-anim" src="animasi1.gif" alt="Pose 1">
139
+ <img id="pose1Anim2" class="pose1-anim" src="animasi1.gif" alt="Pose 2">
140
+ </div>
141
+
142
+ <!-- Indikator 5 Pose -->
143
+ <div class="pose-indicators">
144
+ <div id="boxPose1" class="pose-box"><div class="pose-emoji">👍</div><div class="pose-name">Thumbs Up</div></div>
145
+ <div id="boxPose2" class="pose-box"><div class="pose-emoji">✌️</div><div class="pose-name">Peace</div></div>
146
+ <div id="boxPose3" class="pose-box"><div class="pose-emoji">👌</div><div class="pose-name">Okay</div></div>
147
+ <div id="boxPose4" class="pose-box"><div class="pose-emoji">🖐️</div><div class="pose-name">Open Palm</div></div>
148
+ <div id="boxPose5" class="pose-box"><div class="pose-emoji">✊</div><div class="pose-name">Fist</div></div>
149
+ </div>
150
  </div>
151
 
152
+ <!-- PANEL KANAN -->
153
+ <div style="display: flex; flex-direction: column; gap: 20px;">
154
+ <div class="side-panel">
155
+ <div class="panel-title">Kondisi Biometrik (Kanan)</div>
156
+ <div class="data-item">
157
+ <div class="data-label">Bentuk Wajah</div>
158
+ <div id="valWajah" class="data-value" style="color: #cbd5e1;">Menunggu Wajah...</div>
159
+ </div>
160
+ <div class="data-item">
161
+ <div class="data-label">Bentuk Rahang</div>
162
+ <div id="valRahang" class="data-value" style="color: #cbd5e1;">Menunggu Wajah...</div>
163
+ </div>
164
+ <div class="data-item">
165
+ <div class="data-label">Karakter Alis (v22)</div>
166
+ <div id="valAlis" class="data-value" style="color: #cbd5e1;">Menunggu Wajah...</div>
167
+ </div>
168
+ </div>
169
+
170
+ <div class="side-panel pink-border">
171
+ <div class="data-item">
172
+ <div class="panel-title">Kondisi Mood</div>
173
+ <div id="moodValue" class="data-label" style="font-size: 18px;">Menganalisis...</div>
174
+ </div>
175
+ <div class="data-item" style="margin-top: 10px;">
176
+ <div class="panel-title">Estimasi Anatomi</div>
177
+ <div id="genderValue" class="data-label" style="font-size: 18px;">Memindai...</div>
178
+ </div>
179
+ </div>
180
+ </div>
181
  </div>
182
 
183
+ <!-- Audio Element -->
184
  <audio id="audio1" src="suara1.mp3"></audio>
185
  <audio id="audio2" src="suara2.mp3"></audio>
186
  <audio id="audio3" src="suara3.mp3"></audio>
 
192
  const canvasElement = document.getElementById('outputCanvas');
193
  const canvasCtx = canvasElement.getContext('2d');
194
  const startBtn = document.getElementById('startBtn');
195
+ const mainStatus = document.getElementById('mainStatus');
196
+ const statusKiri = document.getElementById('statusKiri');
197
 
198
+ // Element Data Kanan
199
+ const valWajah = document.getElementById('valWajah');
200
+ const valRahang = document.getElementById('valRahang');
201
+ const valAlis = document.getElementById('valAlis');
202
  const moodValue = document.getElementById('moodValue');
203
  const genderValue = document.getElementById('genderValue');
204
 
 
208
  document.getElementById('audio3'), document.getElementById('audio4'),
209
  document.getElementById('audio5')
210
  ];
211
+
212
+ // Box Indikator Pose Bawah
213
+ const poseBoxes = [
214
+ document.getElementById('boxPose1'), document.getElementById('boxPose2'),
215
+ document.getElementById('boxPose3'), document.getElementById('boxPose4'),
216
+ document.getElementById('boxPose5')
217
+ ];
218
+
219
  let memoryActivePoses = [];
220
  let memoryTimer = 0;
221
  let currentFaceLandmarks = null;
 
223
  function getDistance(p1, p2) { return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }
224
 
225
  function analyzeFaceBiometrics(faceLandmarks) {
226
+ // Titik Referensi Anatomi
227
+ const dahi = faceLandmarks[10]; const dagu = faceLandmarks[152];
228
+ const pipiKiri = faceLandmarks[234]; const pipiKanan = faceLandmarks[454];
229
+ const rahangKiri = faceLandmarks[132]; const rahangKanan = faceLandmarks[361];
230
+ const alisKiri = faceLandmarks[159]; const alisKiriTengah = faceLandmarks[52];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ const faceHeight = getDistance(dahi, dagu);
233
+ const faceWidth = getDistance(pipiKiri, pipiKanan);
234
+ const jawWidth = getDistance(rahangKiri, rahangKanan);
235
+
236
+ // 1. Analisis Bentuk Wajah
237
+ const ratioFace = faceHeight / faceWidth;
238
+ let faceText = "Analisis: Lebar/Pendek";
239
+ if (ratioFace > 1.35) faceText = "Analisis: Oval/Heart (v22)";
240
+ else if (ratioFace > 1.20) faceText = "Analisis: Bulat/Kotak";
241
+
242
+ // 2. Analisis Bentuk Rahang
243
+ const ratioJaw = jawWidth / faceWidth;
244
+ let jawText = "Analisis: Tirus/V-Shape";
245
+ if (ratioJaw > 0.85) jawText = "Analisis: Square-Strong (v22)";
246
+ else if (ratioJaw > 0.75) jawText = "Analisis: Heart/Tapered";
247
+
248
+ // 3. Analisis Karakter Alis
249
+ const ratioEyebrow = getDistance(alisKiri, alisKiriTengah) / faceHeight;
250
+ let browText = "Analisis: Datar/Straight";
251
+ if (ratioEyebrow > 0.055) browText = "Analisis: Arched-High (v22)";
252
+ else if (ratioEyebrow > 0.040) browText = "Analisis: Melengkung Alami";
253
+
254
+ // 4. Mood
255
+ const mouthWidth = getDistance(faceLandmarks[61], faceLandmarks[291]);
256
+ const mouthHeight = getDistance(faceLandmarks[13], faceLandmarks[14]);
257
+ let moodText = "Netral 😐"; let moodColor = "#3b82f6";
258
+ if (mouthHeight / faceWidth > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; }
259
+ else if (mouthWidth / faceWidth > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; }
260
+
261
+ // 5. Gender (Hijab & Rahang Logic)
262
+ const headRatio = getDistance(dahi, faceLandmarks[168]) / jawWidth;
263
+ let genderText = "Pria 👨"; let genderColor = "#60a5fa";
264
+ if (headRatio < 0.22 || ratioJaw < 0.75) {
265
+ genderText = "Wanita 👩"; genderColor = "#f472b6";
266
+ }
267
 
268
+ return { faceText, jawText, browText, moodText, moodColor, genderText, genderColor };
269
  }
270
 
271
  function classifyPose(landmarks) {
 
275
  const pinkyOpen = landmarks[20].y < landmarks[18].y;
276
  const thumbOpen = getDistance(landmarks[4], landmarks[5]) > 0.08;
277
 
278
+ if (!indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return 5; // Fist
279
+ if (indexOpen && middleOpen && ringOpen && pinkyOpen && thumbOpen) return 4; // Open Palm
280
+ if (indexOpen && middleOpen && !ringOpen && !pinkyOpen) return 2; // Peace
281
+ if (thumbOpen && indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return 1; // Thumbs Up / L-Shape
282
+ if (getDistance(landmarks[4], landmarks[8]) < 0.05 && middleOpen && ringOpen && pinkyOpen) return 3; // Okay
 
 
 
283
  return null;
284
  }
285
 
 
291
  });
292
 
293
  const hands = new Hands({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`; }});
 
 
294
  hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
295
 
296
  hands.onResults((results) => {
 
298
  canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
299
  canvasCtx.drawImage(results.image, 0, 0, canvasElement.width, canvasElement.height);
300
 
301
+ // Tampilkan Wajah & Hitung Data
302
  if (currentFaceLandmarks) {
303
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_TESSELATION, {color: '#06b6d4', lineWidth: 0.5});
304
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYE, {color: '#ec4899', lineWidth: 2});
 
305
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYE, {color: '#ec4899', lineWidth: 2});
 
 
306
  drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LIPS, {color: '#ec4899', lineWidth: 2});
307
+
308
+ const bio = analyzeFaceBiometrics(currentFaceLandmarks);
309
+ valWajah.textContent = bio.faceText; valWajah.style.color = "#10b981";
310
+ valRahang.textContent = bio.jawText; valRahang.style.color = "#10b981";
311
+ valAlis.textContent = bio.browText; valAlis.style.color = "#10b981";
312
+
313
+ moodValue.textContent = bio.moodText; moodValue.style.color = bio.moodColor;
314
+ genderValue.textContent = bio.genderText; genderValue.style.color = bio.genderColor;
315
+ } else {
316
+ valWajah.textContent = "Wajah Hilang"; valRahang.textContent = "Wajah Hilang"; valAlis.textContent = "Wajah Hilang";
317
+ valWajah.style.color = "#cbd5e1"; valRahang.style.color = "#cbd5e1"; valAlis.style.color = "#cbd5e1";
318
+ moodValue.textContent = "Menganalisis..."; moodValue.style.color = "#f8fafc";
319
+ genderValue.textContent = "Memindai..."; genderValue.style.color = "#f8fafc";
320
  }
321
 
322
+ let currentIds = [];
323
+ anims.forEach(a => a.style.opacity = '0'); // Sembunyikan GIF
324
+ poseBoxes.forEach(b => b.classList.remove('active')); // Matikan semua indikator pose
325
 
326
  if (results.multiHandLandmarks && results.multiHandLandmarks.length > 0) {
327
  results.multiHandLandmarks.forEach((landmarks, index) => {
328
+ drawConnectors(canvasCtx, landmarks, HAND_CONNECTIONS, {color: index === 0 ? '#ec4899' : '#06b6d4', lineWidth: 4});
 
329
  drawLandmarks(canvasCtx, landmarks, {color: '#ffffff', lineWidth: 2, radius: 3});
330
 
331
+ let poseId = classifyPose(landmarks);
332
+ if (poseId) {
333
+ currentIds.push(poseId);
334
+ poseBoxes[poseId - 1].classList.add('active'); // Nyalakan indikator
335
+
336
+ // GIF Animasi Posisi Dinamis (Khusus Pose 1 L-Shape)
337
+ if (poseId === 1 && anims[index]) {
338
+ const wrist = landmarks[0];
339
+ anims[index].style.opacity = '1';
340
+ anims[index].style.left = `${((1 - wrist.x) * canvasElement.width) - 75}px`;
341
+ anims[index].style.top = `${(wrist.y * canvasElement.height) + 30}px`;
342
+ anims[index].style.width = `150px`;
343
+ }
344
+ }
345
  });
346
  }
347
  canvasCtx.restore();
348
 
349
+ // LOGIKA AUDIO & STATUS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  if (currentIds.length > 0) {
351
+ statusKiri.textContent = "Aktif & Responsif 🟢"; statusKiri.style.color = "#10b981";
352
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  let newPoses = currentIds.filter(id => !memoryActivePoses.includes(id));
 
354
  if (newPoses.length > 0) {
 
355
  sounds.forEach(s => { s.pause(); s.currentTime = 0; });
356
+ const soundToPlay = sounds[newPoses[0] - 1];
357
  if (soundToPlay) soundToPlay.play();
358
  }
359
 
360
+ memoryActivePoses = currentIds;
361
+ memoryTimer = Date.now();
 
362
  } else {
 
363
  if (Date.now() - memoryTimer > 500) {
364
+ statusKiri.textContent = "Menunggu Tangan 🟡"; statusKiri.style.color = "#eab308";
365
+ memoryActivePoses = [];
 
 
 
366
  }
367
  }
368
  });
369
 
370
  startBtn.addEventListener('click', () => {
371
  startBtn.style.display = 'none';
372
+ mainStatus.textContent = "Kamera Aktif & Memindai...";
373
  sounds.forEach(s => { s.play().then(() => { s.pause(); s.currentTime = 0; }).catch(()=>{}); });
374
 
375
  const camera = new Camera(videoElement, {