Spaces:
Running
Running
Update index.html
Browse files- index.html +160 -736
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 -
|
| 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>
|
|
@@ -46,692 +46,93 @@
|
|
| 46 |
background: linear-gradient(135deg, #f472b6, #a78bfa);
|
| 47 |
}
|
| 48 |
|
| 49 |
-
|
| 50 |
-
.analytics-layout {
|
| 51 |
-
display: flex;
|
| 52 |
-
gap: 20px;
|
| 53 |
-
width: 100%;
|
| 54 |
-
max-width: 1280px; /* Ukuran layar lebih besar */
|
| 55 |
-
align-items: flex-start;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
.data-panel {
|
| 59 |
-
flex: 1; /* Ambil ruang seimbang di kiri dan kanan */
|
| 60 |
-
background: rgba(15, 23, 42, 0.85);
|
| 61 |
-
border: 2px solid #3b82f6;
|
| 62 |
-
padding: 20px;
|
| 63 |
-
border-radius: 12px;
|
| 64 |
-
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 65 |
-
backdrop-filter: blur(5px);
|
| 66 |
-
min-width: 250px;
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
.monitor-container {
|
| 70 |
-
position: relative;
|
| 71 |
-
flex: 2; /* Kanvas utama lebih besar */
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
canvas {
|
| 75 |
-
border: 3px solid #3b82f6;
|
| 76 |
-
box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
|
| 77 |
-
border-radius: 16px;
|
| 78 |
-
background-color: #000;
|
| 79 |
-
width: 800px; /* Kanvas lebih besar */
|
| 80 |
-
height: 600px; /* Proporsional 4:3 */
|
| 81 |
-
max-width: 100%;
|
| 82 |
-
object-fit: cover;
|
| 83 |
-
transform: scaleX(-1); /* Efek Cermin */
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
/* GIF Animasi */
|
| 87 |
-
.pose1-anim {
|
| 88 |
-
position: absolute;
|
| 89 |
-
opacity: 0;
|
| 90 |
-
border-radius: 8px;
|
| 91 |
-
z-index: 10;
|
| 92 |
-
border: 2px solid #eab308;
|
| 93 |
-
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 94 |
-
pointer-events: none;
|
| 95 |
-
transition: opacity 0.2s, left 0.1s, top 0.1s;
|
| 96 |
-
transform: scaleX(-1);
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
/* --- STYLING DATA BIOMETRIK (KIRI & KANAN) --- */
|
| 100 |
-
.bio-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-top: 12px; margin-bottom: 4px;}
|
| 101 |
-
.bio-label:first-child { margin-top: 0; }
|
| 102 |
-
.bio-value { font-size: 18px; font-weight: bold; color: #f8fafc; }
|
| 103 |
-
.divider { height: 1px; background-color: #334155; margin: 12px 0; }
|
| 104 |
-
|
| 105 |
-
/* --- STYLING THUMBNAIL POSES (DI BAWAH KANVAS) --- */
|
| 106 |
-
.poses-grid {
|
| 107 |
-
position: absolute;
|
| 108 |
-
bottom: -80px; /* Di bawah kanvas monitor */
|
| 109 |
-
left: 50%;
|
| 110 |
-
transform: translateX(-50%);
|
| 111 |
-
display: flex;
|
| 112 |
-
gap: 15px;
|
| 113 |
background: rgba(15, 23, 42, 0.8);
|
| 114 |
-
padding: 10px 20px;
|
| 115 |
-
border-radius: 12px;
|
| 116 |
border: 1px solid #334155;
|
| 117 |
-
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
.pose-card {
|
| 121 |
-
display: flex;
|
| 122 |
-
flex-direction: column;
|
| 123 |
-
align-items: center;
|
| 124 |
-
opacity: 0.5; /* Pudar secara default */
|
| 125 |
-
transition: opacity 0.2s, box-shadow 0.2s;
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
.pose-card.active {
|
| 129 |
-
opacity: 1; /* Menyala saat dideteksi */
|
| 130 |
-
box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
|
| 131 |
-
border-radius: 8px;
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
.pose-icon { width: 40px; height: 40px; margin-bottom: 5px; }
|
| 135 |
-
.pose-text { font-size: 10px; color: #cbd5e1; text-transform: uppercase; }
|
| 136 |
-
</style>
|
| 137 |
-
</head>
|
| 138 |
-
<body>
|
| 139 |
-
|
| 140 |
-
<h2>🤖 AI Vision: Dual Analytics v21</h2>
|
| 141 |
-
<p>Biometric Wajah, Alis, & Pose Tangan Real-Time v21 By Rizki Ardiansyah</p>
|
| 142 |
-
|
| 143 |
-
<button id="startBtn">▶ Mulai Sistem Deteksi</button>
|
| 144 |
-
|
| 145 |
-
<div id="statusContainer">
|
| 146 |
-
<div id="statusPose" style="font-size: 24px; font-weight: bold; color: #94a3b8;">Menunggu Kamera...</div>
|
| 147 |
-
</div>
|
| 148 |
-
|
| 149 |
-
<!-- --- LAYOUT UTAMA --- -->
|
| 150 |
-
<div class="analytics-layout">
|
| 151 |
-
|
| 152 |
-
<!-- --- PANEL DATA SISI KIRI (STATUS DETEKSI) --- -->
|
| 153 |
-
<div class="data-panel" id="panelKiri">
|
| 154 |
-
<div class="bio-label">Status Deteksi (Kiri)</div>
|
| 155 |
-
<div class="bio-value">Aktif & Sinkron</div>
|
| 156 |
-
|
| 157 |
-
<div class="divider"></div>
|
| 158 |
-
|
| 159 |
-
<div class="bio-label">Deteksi Tangan</div>
|
| 160 |
-
<div id="handStatus" class="bio-value" style="color: #60a5fa;">Memindai (2 Tangan)...</div>
|
| 161 |
-
|
| 162 |
-
<div class="divider"></div>
|
| 163 |
-
|
| 164 |
-
<div class="bio-label">Deteksi Wajah</div>
|
| 165 |
-
<div id="faceStatus" class="bio-value" style="color: #ec4899;">Memindai (v21)...</div>
|
| 166 |
-
</div>
|
| 167 |
-
|
| 168 |
-
<!-- --- MONITOR KANVAS UTAMA --- -->
|
| 169 |
-
<div class="monitor-container">
|
| 170 |
-
<video id="videoElement" style="display: none;" autoplay playsinline></video>
|
| 171 |
-
<canvas id="outputCanvas" width="800" height="600"></canvas>
|
| 172 |
-
|
| 173 |
-
<img id="pose1Anim1" class="pose1-anim" src="animasi1.gif">
|
| 174 |
-
<img id="pose1Anim2" class="pose1-anim" src="animasi1.gif">
|
| 175 |
-
|
| 176 |
-
<!-- --- THUMBNAIL POSES DI BAWAH KANVAS --- -->
|
| 177 |
-
<div class="poses-grid">
|
| 178 |
-
<!-- Data ini diambil dari image_0.png -->
|
| 179 |
-
<div class="pose-card" id="cardThumbsUp">
|
| 180 |
-
<img src="thumbsup_icon.png" class="pose-icon"> <span class="pose-text">Thumbs Up</span>
|
| 181 |
-
</div>
|
| 182 |
-
<div class="pose-card" id="cardPeace">
|
| 183 |
-
<img src="peace_icon.png" class="pose-icon"> <span class="pose-text">Peace</span>
|
| 184 |
-
</div>
|
| 185 |
-
<div class="pose-card" id="cardOkay">
|
| 186 |
-
<img src="okay_icon.png" class="pose-icon"> <span class="pose-text">Okay</span>
|
| 187 |
-
</div>
|
| 188 |
-
<div class="pose-card" id="cardOpenPalm">
|
| 189 |
-
<img src="openpalm_icon.png" class="pose-icon"> <span class="pose-text">Open Palm</span>
|
| 190 |
-
</div>
|
| 191 |
-
<div class="pose-card" id="cardFist">
|
| 192 |
-
<img src="fist_icon.png" class="pose-icon"> <span class="pose-text">Fist</span>
|
| 193 |
-
</div>
|
| 194 |
-
</div>
|
| 195 |
-
</div>
|
| 196 |
-
|
| 197 |
-
<!-- --- PANEL DATA SISI KANAN (BIOMETRIK LENGKAP) --- -->
|
| 198 |
-
<div class="data-panel" id="panelKanan">
|
| 199 |
-
<div class="bio-label">Kondisi Mood (v21)</div>
|
| 200 |
-
<div id="moodValue" class="bio-value">...</div>
|
| 201 |
-
|
| 202 |
-
<div class="divider"></div>
|
| 203 |
-
|
| 204 |
-
<!-- --- BAGIAN BARU: BIOMETRIK WAJAH & ALIS v21 --- -->
|
| 205 |
-
<div class="bio-label">Kondisi Biometrik (Kanan)</div>
|
| 206 |
-
|
| 207 |
-
<div class="bio-label">Bentuk Wajah (v21)Tentu, ini adalah pembaruan antarmuka untuk aplikasi AI Hand Pose & Biometric Scanner v21 Anda dengan penempatan data yang seimbang di sisi kanan dan kiri layar deteksi utama.
|
| 208 |
-
|
| 209 |
-
**Pembaruan v21 (Tampilan Deteksi Penuh):**
|
| 210 |
-
|
| 211 |
-
1. **Layout Dua Panel Simetris:** Sesuai permintaan Anda, saya telah menambahkan dua panel data biometrik yang simetris di sisi kanan dan kiri layar deteksi.
|
| 212 |
-
2. **Panel Data Sisi Kiri (Status Deteksi):** Menampilkan informasi sistem.
|
| 213 |
-
* **STATUS DETEKSI (Kiri):** Status sistem (e.g., 'Aktif & Sinkron').
|
| 214 |
-
* **Status Deteksi Tangan:** Status (e.g., 'Aktif (v21)').
|
| 215 |
-
* **Status Deteksi Wajah:** Status (e.g., 'Aktif (v21)').
|
| 216 |
-
3. **Panel Data Sisi Kanan (Biometrik Wajah v21):** Diisi dengan fitur yang baru kita tambahkan (v21).
|
| 217 |
-
* **KONDISI MOOD (v21):** Data dari v20.
|
| 218 |
-
* **KONDISI BIOMETRIK (Kanan):** Bagian utama baru.
|
| 219 |
-
* **Bentuk Wajah (v21):** Menampilkan status analisis bentuk wajah (misal: 'Oval/Heart (v21)').
|
| 220 |
-
* **Bentuk Rahang Wajah (v21):** Menampilkan status analisis bentuk rahang (misal: 'Square-Strong (v21)').
|
| 221 |
-
* **Bentuk Alis (v21):** Menampilkan status analisis bentuk alis (misal: 'Arched-High (v21)').
|
| 222 |
-
4. **Tampilan Keseluruhan:** Kanvas monitor menampilkan visualisasi *Face Mesh* dan pelacakan tangan secara bersamaan, menunjukkan deteksi dual-AI yang presisi dan sinkron pada gambar wajah referensi, dengan koordinat yang sudah diperbaiki (mirror effect).
|
| 223 |
-
|
| 224 |
-
Berikut adalah kode HTML/JS v21 yang sudah saya perbarui dengan penempatan panel yang baru:
|
| 225 |
-
|
| 226 |
-
```html
|
| 227 |
-
<!DOCTYPE html>
|
| 228 |
-
<html lang="id">
|
| 229 |
-
<head>
|
| 230 |
-
<meta charset="UTF-8">
|
| 231 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 232 |
-
<title>AI Vision - Biometric Analytics v21 - Rizki Ardiansyah</title>
|
| 233 |
-
|
| 234 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js](https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js)" crossorigin="anonymous"></script>
|
| 235 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js](https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js)" crossorigin="anonymous"></script>
|
| 236 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js](https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js)" crossorigin="anonymous"></script>
|
| 237 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js](https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js)" crossorigin="anonymous"></script>
|
| 238 |
-
|
| 239 |
-
<style>
|
| 240 |
-
body {
|
| 241 |
-
background: radial-gradient(circle at top, #1e293b, #0f172a);
|
| 242 |
-
color: #f8fafc;
|
| 243 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 244 |
-
display: flex;
|
| 245 |
-
flex-direction: column;
|
| 246 |
-
align-items: center;
|
| 247 |
-
margin: 0;
|
| 248 |
-
padding: 20px;
|
| 249 |
-
min-height: 100vh;
|
| 250 |
-
}
|
| 251 |
-
|
| 252 |
-
h2 { margin-bottom: 5px; color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
|
| 253 |
-
p { color: #94a3b8; margin-top: 0; text-align: center; }
|
| 254 |
-
|
| 255 |
-
#startBtn {
|
| 256 |
-
background: linear-gradient(135deg, #ec4899, #8b5cf6);
|
| 257 |
-
color: white;
|
| 258 |
-
border: none;
|
| 259 |
-
padding: 15px 35px;
|
| 260 |
-
font-size: 18px;
|
| 261 |
-
border-radius: 50px;
|
| 262 |
-
cursor: pointer;
|
| 263 |
-
font-weight: bold;
|
| 264 |
-
box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
|
| 265 |
-
transition: all 0.3s ease;
|
| 266 |
-
margin: 20px 0;
|
| 267 |
-
text-transform: uppercase;
|
| 268 |
-
}
|
| 269 |
-
#startBtn:hover {
|
| 270 |
-
transform: translateY(-3px);
|
| 271 |
-
box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6);
|
| 272 |
-
background: linear-gradient(135deg, #f472b6, #a78bfa);
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
/* --- LAYOUT DUA SISI PANEL DATA (KIRI & KANAN) --- */
|
| 276 |
-
.analytics-layout {
|
| 277 |
-
display: flex;
|
| 278 |
-
gap: 20px;
|
| 279 |
-
width: 100%;
|
| 280 |
-
max-width: 1280px; /* Ukuran layar lebih besar */
|
| 281 |
-
align-items: flex-start;
|
| 282 |
-
}
|
| 283 |
-
|
| 284 |
-
.data-panel {
|
| 285 |
-
flex: 1; /* Ambil ruang seimbang di kiri dan kanan */
|
| 286 |
-
background: rgba(15, 23, 42, 0.85);
|
| 287 |
-
border: 2px solid #3b82f6;
|
| 288 |
-
padding: 20px;
|
| 289 |
border-radius: 12px;
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
| 293 |
}
|
|
|
|
| 294 |
|
| 295 |
-
.monitor-container {
|
| 296 |
-
position: relative;
|
| 297 |
-
flex: 2; /* Kanvas utama lebih besar */
|
| 298 |
-
}
|
| 299 |
|
| 300 |
canvas {
|
| 301 |
border: 3px solid #3b82f6;
|
| 302 |
box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
|
| 303 |
border-radius: 16px;
|
| 304 |
background-color: #000;
|
| 305 |
-
width:
|
| 306 |
-
height:
|
| 307 |
-
max-width:
|
| 308 |
object-fit: cover;
|
| 309 |
-
transform: scaleX(-1);
|
| 310 |
}
|
| 311 |
|
| 312 |
-
/*
|
| 313 |
.pose1-anim {
|
| 314 |
position: absolute;
|
| 315 |
-
opacity: 0;
|
| 316 |
border-radius: 8px;
|
| 317 |
z-index: 10;
|
| 318 |
border: 2px solid #eab308;
|
| 319 |
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 320 |
pointer-events: none;
|
| 321 |
-
|
|
|
|
| 322 |
transform: scaleX(-1);
|
| 323 |
}
|
| 324 |
|
| 325 |
-
|
| 326 |
-
.bio-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-top: 12px; margin-bottom: 4px;}
|
| 327 |
-
.bio-label:first-child { margin-top: 0; }
|
| 328 |
-
.bio-value { font-size: 18px; font-weight: bold; color: #f8fafc; }
|
| 329 |
-
.divider { height: 1px; background-color: #334155; margin: 12px 0; }
|
| 330 |
-
</style>
|
| 331 |
-
</head>
|
| 332 |
-
<body>
|
| 333 |
-
|
| 334 |
-
<h2>🤖 AI Vision: Biometric Analytics v21 By Rizki Ardiansyah</h2>
|
| 335 |
-
<p>Deteksi Dua Tangan + Wajah & Alis Real-Time v21</p>
|
| 336 |
-
|
| 337 |
-
<button id="startBtn">▶ Mulai Sistem Deteksi</button>
|
| 338 |
-
|
| 339 |
-
<div id="statusContainer">
|
| 340 |
-
<div id="statusPose" style="font-size: 24px; font-weight: bold; color: #94a3b8;">Menunggu Kamera...</div>
|
| 341 |
-
</div>
|
| 342 |
-
|
| 343 |
-
<!-- --- LAYOUT UTAMA --- -->
|
| 344 |
-
<div class="analytics-layout">
|
| 345 |
-
|
| 346 |
-
<!-- --- PANEL DATA SISI KIRI (STATUS DETEKSI) --- -->
|
| 347 |
-
<div class="data-panel" id="panelKiri">
|
| 348 |
-
<div class="bio-label">Status Deteksi (Kiri)</div>
|
| 349 |
-
<div class="bio-value">Aktif & Sinkron</div>
|
| 350 |
-
|
| 351 |
-
<div class="divider"></div>
|
| 352 |
-
|
| 353 |
-
<div class="bio-label">Status Deteksi Tangan</div>
|
| 354 |
-
<div id="handStatus" class="bio-value" style="color: #60a5fa;">Aktif (v21)...</div>
|
| 355 |
-
|
| 356 |
-
<div class="divider"></div>
|
| 357 |
-
|
| 358 |
-
<div class="bio-label">Status Deteksi Wajah</div>
|
| 359 |
-
<div id="faceStatus" class="bio-value" style="color: #ec4899;">Aktif (v21)...</div>
|
| 360 |
-
</div>
|
| 361 |
-
|
| 362 |
-
<!-- --- MONITOR KANVAS UTAMA --- -->
|
| 363 |
-
<div class="monitor-container">
|
| 364 |
-
<video id="videoElement" style="display: none;" autoplay playsinline></video>
|
| 365 |
-
<canvas id="outputCanvas" width="800" height="600"></canvas>
|
| 366 |
-
|
| 367 |
-
<img id="pose1Anim1" class="pose1-anim" src="animasi1.gif">
|
| 368 |
-
<img id="pose1Anim2" class="pose1-anim" src="animasi1.gif">
|
| 369 |
-
</div>
|
| 370 |
-
|
| 371 |
-
<!-- --- PANEL DATA SISI KANAN (BIOMETRIK LENGKAP) --- -->
|
| 372 |
-
<div class="data-panel" id="panelKanan">
|
| 373 |
-
<div class="bio-label">Kondisi Mood (v21)Tentu, ini adalah pembaruan antarmuka untuk aplikasi AI Hand Pose & Biometric Scanner v21 Anda dengan penempatan data yang seimbang di sisi kanan dan kiri layar deteksi utama.
|
| 374 |
-
|
| 375 |
-
**Pembaruan v21 (Tampilan Deteksi Penuh):**
|
| 376 |
-
|
| 377 |
-
1. **Layout Dua Panel Simetris:** Sesuai permintaan Anda, saya telah menambahkan dua panel data biometrik yang simetris di sisi kanan dan kiri layar deteksi utama.
|
| 378 |
-
2. **Panel Data Sisi Kiri (Status Deteksi):** Menampilkan informasi sistem.
|
| 379 |
-
* **STATUS DETEKSI (Kiri):** Status sistem (e.g., 'Aktif & Sinkron').
|
| 380 |
-
* **Status Deteksi Tangan:** Status (e.g., 'Aktif (v21)').
|
| 381 |
-
* **Status Deteksi Wajah:** Status (e.g., 'Aktif (v21)').
|
| 382 |
-
3. **Panel Data Sisi Kanan (Biometrik Wajah v21):** Diisi dengan fitur yang baru kita tambahkan (v21).
|
| 383 |
-
* **KONDISI MOOD (v21):** Data dari v20.
|
| 384 |
-
* **KONDISI BIOMETRIK (Kanan):** Bagian utama baru.
|
| 385 |
-
* **Bentuk Wajah (v21):** Menampilkan status analisis bentuk wajah (misal: 'Oval/Heart (v21)').
|
| 386 |
-
* **Bentuk Rahang Wajah (v21):** Menampilkan status analisis bentuk rahang (misal: 'Square-Strong (v21)').
|
| 387 |
-
* **Bentuk Alis (v21):** Menampilkan status analisis bentuk alis (misal: 'Arched-High (v21)').
|
| 388 |
-
4. **Tampilan Keseluruhan:** Kanvas monitor menampilkan visualisasi *Face Mesh* dan pelacakan tangan secara bersamaan, menunjukkan deteksi dual-AI yang presisi dan sinkron pada gambar wajah referensi, dengan koordinat yang sudah diperbaiki (mirror effect).
|
| 389 |
-
|
| 390 |
-
Berikut adalah kode HTML/JS v21 yang sudah saya perbarui dengan penempatan panel yang baru:
|
| 391 |
-
|
| 392 |
-
```html
|
| 393 |
-
<!DOCTYPE html>
|
| 394 |
-
<html lang="id">
|
| 395 |
-
<head>
|
| 396 |
-
<meta charset="UTF-8">
|
| 397 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 398 |
-
<title>AI Vision - Biometric Analytics v21 - Rizki Ardiansyah</title>
|
| 399 |
-
|
| 400 |
-
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
|
| 401 |
-
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script>
|
| 402 |
-
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js" crossorigin="anonymous"></script>
|
| 403 |
-
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js" crossorigin="anonymous"></script>
|
| 404 |
-
|
| 405 |
-
<style>
|
| 406 |
-
body {
|
| 407 |
-
background: radial-gradient(circle at top, #1e293b, #0f172a);
|
| 408 |
-
color: #f8fafc;
|
| 409 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 410 |
-
display: flex;
|
| 411 |
-
flex-direction: column;
|
| 412 |
-
align-items: center;
|
| 413 |
-
margin: 0;
|
| 414 |
-
padding: 20px;
|
| 415 |
-
min-height: 100vh;
|
| 416 |
-
}
|
| 417 |
-
|
| 418 |
-
h2 { margin-bottom: 5px; color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
|
| 419 |
-
p { color: #94a3b8; margin-top: 0; text-align: center; }
|
| 420 |
-
|
| 421 |
-
#startBtn {
|
| 422 |
-
background: linear-gradient(135deg, #ec4899, #8b5cf6);
|
| 423 |
-
color: white;
|
| 424 |
-
border: none;
|
| 425 |
-
padding: 15px 35px;
|
| 426 |
-
font-size: 18px;
|
| 427 |
-
border-radius: 50px;
|
| 428 |
-
cursor: pointer;
|
| 429 |
-
font-weight: bold;
|
| 430 |
-
box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
|
| 431 |
-
transition: all 0.3s ease;
|
| 432 |
-
margin: 20px 0;
|
| 433 |
-
text-transform: uppercase;
|
| 434 |
-
}
|
| 435 |
-
#startBtn:hover {
|
| 436 |
-
transform: translateY(-3px);
|
| 437 |
-
box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6);
|
| 438 |
-
background: linear-gradient(135deg, #f472b6, #a78bfa);
|
| 439 |
-
}
|
| 440 |
-
|
| 441 |
-
/* --- LAYOUT DUA SISI PANEL DATA (KIRI & KANAN) --- */
|
| 442 |
-
.analytics-layout {
|
| 443 |
-
display: flex;
|
| 444 |
-
gap: 20px;
|
| 445 |
-
width: 100%;
|
| 446 |
-
max-width: 1280px; /* Ukuran layar lebih besar */
|
| 447 |
-
align-items: flex-start;
|
| 448 |
-
}
|
| 449 |
-
|
| 450 |
-
.data-panel {
|
| 451 |
-
flex: 1; /* Ambil ruang seimbang di kiri dan kanan */
|
| 452 |
-
background: rgba(15, 23, 42, 0.85);
|
| 453 |
-
border: 2px solid #3b82f6;
|
| 454 |
-
padding: 20px;
|
| 455 |
-
border-radius: 12px;
|
| 456 |
-
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 457 |
-
backdrop-filter: blur(5px);
|
| 458 |
-
min-width: 250px;
|
| 459 |
-
}
|
| 460 |
-
|
| 461 |
-
.monitor-container {
|
| 462 |
-
position: relative;
|
| 463 |
-
flex: 2; /* Kanvas utama lebih besar */
|
| 464 |
-
}
|
| 465 |
-
|
| 466 |
-
canvas {
|
| 467 |
-
border: 3px solid #3b82f6;
|
| 468 |
-
box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
|
| 469 |
-
border-radius: 16px;
|
| 470 |
-
background-color: #000;
|
| 471 |
-
width: 800px; /* Kanvas lebih besar */
|
| 472 |
-
height: 600px; /* Proporsional 4:3 */
|
| 473 |
-
max-width: 100%;
|
| 474 |
-
object-fit: cover;
|
| 475 |
-
transform: scaleX(-1); /* Efek Cermin */
|
| 476 |
-
}
|
| 477 |
-
|
| 478 |
-
/* GIF Animasi */
|
| 479 |
-
.pose1-anim {
|
| 480 |
position: absolute;
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
z-index: 10;
|
| 484 |
-
border: 2px solid #eab308;
|
| 485 |
-
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 486 |
-
pointer-events: none;
|
| 487 |
-
transition: opacity 0.2s, left 0.1s, top 0.1s;
|
| 488 |
-
transform: scaleX(-1);
|
| 489 |
-
}
|
| 490 |
-
|
| 491 |
-
/* --- STYLING DATA BIOMETRIK (KIRI & KANAN) --- */
|
| 492 |
-
.bio-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-top: 12px; margin-bottom: 4px;}
|
| 493 |
-
.bio-label:first-child { margin-top: 0; }
|
| 494 |
-
.bio-value { font-size: 18px; font-weight: bold; color: #f8fafc; }
|
| 495 |
-
.divider { height: 1px; background-color: #334155; margin: 12px 0; }
|
| 496 |
-
</style>
|
| 497 |
-
</head>
|
| 498 |
-
<body>
|
| 499 |
-
|
| 500 |
-
<h2>🤖 AI Vision: Biometric Analytics v21 By Rizki Ardiansyah</h2>
|
| 501 |
-
<p>Deteksi Dua Tangan + Wajah & Alis Real-Time v21</p>
|
| 502 |
-
|
| 503 |
-
<button id="startBtn">▶ Mulai Sistem Deteksi</button>
|
| 504 |
-
|
| 505 |
-
<div id="statusContainer">
|
| 506 |
-
<div id="statusPose" style="font-size: 24px; font-weight: bold; color: #94a3b8;">Menunggu Kamera...</div>
|
| 507 |
-
</div>
|
| 508 |
-
|
| 509 |
-
<!-- --- LAYOUT UTAMA --- -->
|
| 510 |
-
<div class="analytics-layout">
|
| 511 |
-
|
| 512 |
-
<!-- --- PANEL DATA SISI KIRI (STATUS DETEKSI) --- -->
|
| 513 |
-
<div class="data-panel" id="panelKiri">
|
| 514 |
-
<div class="bio-label">Status Deteksi (Kiri)</div>
|
| 515 |
-
<div class="bio-value">Aktif & Sinkron</div>
|
| 516 |
-
|
| 517 |
-
<div class="divider"></div>
|
| 518 |
-
|
| 519 |
-
<div class="bio-label">Status Deteksi Tangan</div>
|
| 520 |
-
<div id="handStatus" class="bio-value" style="color: #60a5fa;">Aktif (v21)...</div>
|
| 521 |
-
|
| 522 |
-
<div class="divider"></div>
|
| 523 |
-
|
| 524 |
-
<div class="bio-label">Status Deteksi Wajah</div>
|
| 525 |
-
<div id="faceStatus" class="bio-value" style="color: #ec4899;">Aktif (v21)...</div>
|
| 526 |
-
</div>
|
| 527 |
-
|
| 528 |
-
<!-- --- MONITOR KANVAS UTAMA --- -->
|
| 529 |
-
<div class="monitor-container">
|
| 530 |
-
<video id="videoElement" style="display: none;" autoplay playsinline></video>
|
| 531 |
-
<canvas id="outputCanvas" width="800" height="600"></canvas>
|
| 532 |
-
|
| 533 |
-
<img id="pose1Anim1" class="pose1-anim" src="animasi1.gif">
|
| 534 |
-
<img id="pose1Anim2" class="pose1-anim" src="animasi1.gif">
|
| 535 |
-
</div>
|
| 536 |
-
|
| 537 |
-
<!-- --- PANEL DATA SISI KANAN (BIOMETRIK LENGKAP) --- -->
|
| 538 |
-
<div class="data-panel" id="panelKanan">
|
| 539 |
-
<div class="bio-label">Kondisi Mood (v21)</div>
|
| 540 |
-
<div id="moodValue" class="bio-value">...</div>
|
| 541 |
-
|
| 542 |
-
<div class="divider"></div>
|
| 543 |
-
|
| 544 |
-
<!-- --- BAGIAN BARU: BIOMETRIK WAJAH & ALIS v21 --- -->
|
| 545 |
-
<div class="bio-label">Kondisi Biometrik (Kanan)Tentu, saya telah merancang pembaruan antarmuka untuk aplikasi AI Hand Pose & Biometric Scanner v21 Anda dengan penempatan data yang seimbang di sisi kanan dan kiri layar deteksi utama.
|
| 546 |
-
|
| 547 |
-
**Pembaruan v21 (Tampilan Deteksi Penuh):**
|
| 548 |
-
|
| 549 |
-
1. **Layout Dua Panel Simetris:** Sesuai permintaan Anda, saya telah menambahkan dua panel data biometrik yang simetris di sisi kanan dan kiri layar deteksi utama.
|
| 550 |
-
2. **Panel Data Sisi Kiri (Status Deteksi):** Menampilkan informasi sistem.
|
| 551 |
-
* **STATUS DETEKSI (Kiri):** Status sistem (e.g., 'Aktif & Sinkron').
|
| 552 |
-
* **Status Deteksi Tangan:** Status (e.g., 'Aktif (v21)').
|
| 553 |
-
* **Status Deteksi Wajah:** Status (e.g., 'Aktif (v21)').
|
| 554 |
-
3. **Panel Data Sisi Kanan (Biometrik Wajah v21):** Diisi dengan fitur yang baru kita tambahkan (v21).
|
| 555 |
-
* **KONDISI MOOD (v21):** Data dari v20.
|
| 556 |
-
* **KONDISI BIOMETRIK (Kanan):** Bagian utama baru.
|
| 557 |
-
* **Bentuk Wajah (v21):** Menampilkan status analisis bentuk wajah (misal: 'Oval/Heart (v21)').
|
| 558 |
-
* **Bentuk Rahang Wajah (v21):** Menampilkan status analisis bentuk rahang (misal: 'Square-Strong (v21)').
|
| 559 |
-
* **Bentuk Alis (v21):** Menampilkan status analisis bentuk alis (misal: 'Arched-High (v21)').
|
| 560 |
-
4. **Tampilan Keseluruhan:** Kanvas monitor menampilkan visualisasi *Face Mesh* dan pelacakan tangan secara bersamaan, menunjukkan deteksi dual-AI yang presisi dan sinkron pada gambar wajah referensi, dengan koordinat yang sudah diperbaiki (mirror effect).
|
| 561 |
-
|
| 562 |
-
Berikut adalah kode HTML/JS v21 yang sudah saya perbarui dengan penempatan panel yang baru:
|
| 563 |
-
|
| 564 |
-
```html
|
| 565 |
-
<!DOCTYPE html>
|
| 566 |
-
<html lang="id">
|
| 567 |
-
<head>
|
| 568 |
-
<meta charset="UTF-8">
|
| 569 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 570 |
-
<title>AI Vision - Biometric Analytics v21 - Rizki Ardiansyah</title>
|
| 571 |
-
|
| 572 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js](https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js)" crossorigin="anonymous"></script>
|
| 573 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js](https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js)" crossorigin="anonymous"></script>
|
| 574 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js](https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js)" crossorigin="anonymous"></script>
|
| 575 |
-
<script src="[https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js](https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js)" crossorigin="anonymous"></script>
|
| 576 |
-
|
| 577 |
-
<style>
|
| 578 |
-
body {
|
| 579 |
-
background: radial-gradient(circle at top, #1e293b, #0f172a);
|
| 580 |
-
color: #f8fafc;
|
| 581 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 582 |
-
display: flex;
|
| 583 |
-
flex-direction: column;
|
| 584 |
-
align-items: center;
|
| 585 |
-
margin: 0;
|
| 586 |
-
padding: 20px;
|
| 587 |
-
min-height: 100vh;
|
| 588 |
-
}
|
| 589 |
-
|
| 590 |
-
h2 { margin-bottom: 5px; color: #38bdf8; text-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
|
| 591 |
-
p { color: #94a3b8; margin-top: 0; text-align: center; }
|
| 592 |
-
|
| 593 |
-
#startBtn {
|
| 594 |
-
background: linear-gradient(135deg, #ec4899, #8b5cf6);
|
| 595 |
-
color: white;
|
| 596 |
-
border: none;
|
| 597 |
-
padding: 15px 35px;
|
| 598 |
-
font-size: 18px;
|
| 599 |
-
border-radius: 50px;
|
| 600 |
-
cursor: pointer;
|
| 601 |
-
font-weight: bold;
|
| 602 |
-
box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
|
| 603 |
-
transition: all 0.3s ease;
|
| 604 |
-
margin: 20px 0;
|
| 605 |
-
text-transform: uppercase;
|
| 606 |
-
}
|
| 607 |
-
#startBtn:hover {
|
| 608 |
-
transform: translateY(-3px);
|
| 609 |
-
box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6);
|
| 610 |
-
background: linear-gradient(135deg, #f472b6, #a78bfa);
|
| 611 |
-
}
|
| 612 |
-
|
| 613 |
-
/* --- LAYOUT DUA SISI PANEL DATA (KIRI & KANAN) --- */
|
| 614 |
-
.analytics-layout {
|
| 615 |
-
display: flex;
|
| 616 |
-
gap: 20px;
|
| 617 |
-
width: 100%;
|
| 618 |
-
max-width: 1280px; /* Ukuran layar lebih besar */
|
| 619 |
-
align-items: flex-start;
|
| 620 |
-
}
|
| 621 |
-
|
| 622 |
-
.data-panel {
|
| 623 |
-
flex: 1; /* Ambil ruang seimbang di kiri dan kanan */
|
| 624 |
background: rgba(15, 23, 42, 0.85);
|
| 625 |
border: 2px solid #3b82f6;
|
| 626 |
-
padding:
|
| 627 |
border-radius: 12px;
|
| 628 |
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
|
|
|
| 629 |
backdrop-filter: blur(5px);
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
.monitor-container {
|
| 634 |
-
position: relative;
|
| 635 |
-
flex: 2; /* Kanvas utama lebih besar */
|
| 636 |
-
}
|
| 637 |
-
|
| 638 |
-
canvas {
|
| 639 |
-
border: 3px solid #3b82f6;
|
| 640 |
-
box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
|
| 641 |
-
border-radius: 16px;
|
| 642 |
-
background-color: #000;
|
| 643 |
-
width: 800px; /* Kanvas lebih besar */
|
| 644 |
-
height: 600px; /* Proporsional 4:3 */
|
| 645 |
-
max-width: 100%;
|
| 646 |
-
object-fit: cover;
|
| 647 |
-
transform: scaleX(-1); /* Efek Cermin */
|
| 648 |
-
}
|
| 649 |
-
|
| 650 |
-
/* GIF Animasi */
|
| 651 |
-
.pose1-anim {
|
| 652 |
-
position: absolute;
|
| 653 |
-
opacity: 0;
|
| 654 |
-
border-radius: 8px;
|
| 655 |
-
z-index: 10;
|
| 656 |
-
border: 2px solid #eab308;
|
| 657 |
-
box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
|
| 658 |
-
pointer-events: none;
|
| 659 |
-
transition: opacity 0.2s, left 0.1s, top 0.1s;
|
| 660 |
-
transform: scaleX(-1);
|
| 661 |
}
|
| 662 |
-
|
| 663 |
-
/* --- STYLING DATA BIOMETRIK (KIRI & KANAN) --- */
|
| 664 |
-
.bio-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-top: 12px; margin-bottom: 4px;}
|
| 665 |
.bio-label:first-child { margin-top: 0; }
|
| 666 |
.bio-value { font-size: 18px; font-weight: bold; color: #f8fafc; }
|
| 667 |
-
.divider { height: 1px; background-color: #334155; margin:
|
| 668 |
</style>
|
| 669 |
</head>
|
| 670 |
<body>
|
| 671 |
|
| 672 |
-
<h2>🤖 AI Vision:
|
| 673 |
-
<p>
|
| 674 |
|
| 675 |
<button id="startBtn">▶ Mulai Sistem Deteksi</button>
|
| 676 |
|
| 677 |
<div id="statusContainer">
|
| 678 |
-
<div id="statusPose"
|
| 679 |
</div>
|
| 680 |
|
| 681 |
-
<
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
<div class="data-panel" id="panelKiri">
|
| 686 |
-
<div class="bio-label">Status Deteksi (Kiri)</div>
|
| 687 |
-
<div class="bio-value">Aktif & Sinkron</div>
|
| 688 |
-
|
| 689 |
-
<div class="divider"></div>
|
| 690 |
-
|
| 691 |
-
<div class="bio-label">Status Deteksi Tangan</div>
|
| 692 |
-
<div id="handStatus" class="bio-value" style="color: #60a5fa;">Aktif (v21)...</div>
|
| 693 |
-
|
| 694 |
<div class="divider"></div>
|
| 695 |
-
|
| 696 |
-
<div class="bio-
|
| 697 |
-
<div id="faceStatus" class="bio-value" style="color: #ec4899;">Aktif (v21)...</div>
|
| 698 |
-
</div>
|
| 699 |
-
|
| 700 |
-
<!-- --- MONITOR KANVAS UTAMA --- -->
|
| 701 |
-
<div class="monitor-container">
|
| 702 |
-
<video id="videoElement" style="display: none;" autoplay playsinline></video>
|
| 703 |
-
<canvas id="outputCanvas" width="800" height="600"></canvas>
|
| 704 |
-
|
| 705 |
-
<img id="pose1Anim1" class="pose1-anim" src="animasi1.gif">
|
| 706 |
-
<img id="pose1Anim2" class="pose1-anim" src="animasi1.gif">
|
| 707 |
</div>
|
| 708 |
|
| 709 |
-
<
|
| 710 |
-
<
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
<div class="divider"></div>
|
| 715 |
-
|
| 716 |
-
<!-- --- BAGIAN BARU: BIOMETRIK WAJAH & ALIS v21 --- -->
|
| 717 |
-
<div class="bio-label">Kondisi Biometrik (Kanan)</div>
|
| 718 |
-
|
| 719 |
-
<div class="bio-label">Bentuk Wajah (v21)</div>
|
| 720 |
-
<div id="faceShapeValue" class="bio-value" style="color: #eab308;">Analisis...</div>
|
| 721 |
-
|
| 722 |
-
<div class="divider"></div>
|
| 723 |
-
|
| 724 |
-
<div class="bio-label">Bentuk Rahang Wajah (v21)</div>
|
| 725 |
-
<div id="jawShapeValue" class="bio-value" style="color: #10b981;">Analisis...</div>
|
| 726 |
-
|
| 727 |
-
<div class="divider"></div>
|
| 728 |
-
|
| 729 |
-
<div class="bio-label">Bentuk Alis (v21)</div>
|
| 730 |
-
<div id="eyebrowShapeValue" class="bio-value" style="color: #a855f7;">Analisis...</div>
|
| 731 |
-
</div>
|
| 732 |
</div>
|
| 733 |
|
| 734 |
-
<!-- Audio -->
|
| 735 |
<audio id="audio1" src="suara1.mp3"></audio>
|
| 736 |
<audio id="audio2" src="suara2.mp3"></audio>
|
| 737 |
<audio id="audio3" src="suara3.mp3"></audio>
|
|
@@ -744,69 +145,53 @@ Berikut adalah kode HTML/JS v21 yang sudah saya perbarui dengan penempatan panel
|
|
| 744 |
const canvasCtx = canvasElement.getContext('2d');
|
| 745 |
const startBtn = document.getElementById('startBtn');
|
| 746 |
const statusPose = document.getElementById('statusPose');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 747 |
const anims = [document.getElementById('pose1Anim1'), document.getElementById('pose1Anim2')];
|
| 748 |
const sounds = [
|
| 749 |
document.getElementById('audio1'), document.getElementById('audio2'),
|
| 750 |
document.getElementById('audio3'), document.getElementById('audio4'),
|
| 751 |
document.getElementById('audio5')
|
| 752 |
];
|
| 753 |
-
|
| 754 |
-
//
|
| 755 |
-
const moodValue = document.getElementById('moodValue');
|
| 756 |
-
const faceShapeValue = document.getElementById('faceShapeValue');
|
| 757 |
-
const jawShapeValue = document.getElementById('jawShapeValue');
|
| 758 |
-
const eyebrowShapeValue = document.getElementById('eyebrowShapeValue');
|
| 759 |
-
|
| 760 |
let memoryActivePoses = [];
|
| 761 |
let memoryTimer = 0;
|
| 762 |
let currentFaceLandmarks = null;
|
| 763 |
|
| 764 |
function getDistance(p1, p2) { return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }
|
| 765 |
|
| 766 |
-
function analyzeFaceBiometrics(
|
| 767 |
-
|
| 768 |
-
const
|
| 769 |
-
const
|
| 770 |
-
|
| 771 |
-
const
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
const
|
| 776 |
-
const
|
| 777 |
-
|
| 778 |
-
// 1. Bentuk Wajah (Berdasarkan rasio tinggi vs lebar dahi ke dagu)
|
| 779 |
-
const ratioFace = faceHeight / faceWidth;
|
| 780 |
-
let faceText = "Analisis...";
|
| 781 |
-
if (ratioFace > 1.4) faceText = "Wajah Oval/Heart (v21)";
|
| 782 |
-
else if (ratioFace > 1.2) faceText = "Wajah Bulat/Kotak (v21)";
|
| 783 |
-
else faceText = "Wajah Panjang (v21)";
|
| 784 |
-
|
| 785 |
-
// 2. Bentuk Rahang Wajah (Berdasarkan lebar rahang vs lebar pipi)
|
| 786 |
-
const ratioJaw = jawWidth / faceWidth;
|
| 787 |
-
let jawText = "Analisis...";
|
| 788 |
-
if (ratioJaw > 0.85) jawText = "Square-Strong (v21)";
|
| 789 |
-
else if (ratioJaw > 0.75) jawText = "Heart/Tapered (v21)";
|
| 790 |
-
else jawText = "Tirus/V-Shape (v21)";
|
| 791 |
-
|
| 792 |
-
// 3. Bentuk Alis (Berdasarkan lengkungan dahi vs dahi tengah)
|
| 793 |
-
const ratioEyebrow = getDistance(faceMesh[159], faceMesh[52]) / faceHeight;
|
| 794 |
-
let eyebrowText = "Analisis...";
|
| 795 |
-
if (ratioEyebrow > 0.055) eyebrowText = "Arched-High (v21)";
|
| 796 |
-
else if (ratioEyebrow > 0.04) eyebrowText = "Melengkung Alami (v21)";
|
| 797 |
-
else eyebrowText = "Datar/Straight (v21)";
|
| 798 |
-
|
| 799 |
-
// 4. Mood (Tetap Sama)
|
| 800 |
-
const mouthWidth = getDistance(faceMesh[61], faceMesh[291]);
|
| 801 |
-
const mouthHeight = getDistance(faceMesh[13], faceMesh[14]);
|
| 802 |
-
const smileRatio = mouthWidth / faceWidth;
|
| 803 |
-
const openRatio = mouthHeight / faceWidth;
|
| 804 |
-
|
| 805 |
let moodText = "Netral 😐"; let moodColor = "#3b82f6";
|
| 806 |
if (openRatio > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; }
|
| 807 |
else if (smileRatio > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; }
|
| 808 |
|
| 809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
}
|
| 811 |
|
| 812 |
function classifyPose(landmarks) {
|
|
@@ -820,92 +205,131 @@ Berikut adalah kode HTML/JS v21 yang sudah saya perbarui dengan penempatan panel
|
|
| 820 |
if (indexOpen && middleOpen && ringOpen && pinkyOpen && thumbOpen) return { id: 4, name: "🖐️ Telapak", color: "#3b82f6" };
|
| 821 |
if (indexOpen && middleOpen && !ringOpen && !pinkyOpen) return { id: 2, name: "✌️ Victory", color: "#a855f7" };
|
| 822 |
if (thumbOpen && indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 1, name: "👉 Tunjuk & Jempol", color: "#eab308" };
|
| 823 |
-
|
|
|
|
|
|
|
|
|
|
| 824 |
return null;
|
| 825 |
}
|
| 826 |
|
| 827 |
-
const faceMesh = new FaceMesh({locateFile: (file) => { return `
|
| 828 |
-
faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: true, minDetectionConfidence: 0.7 });
|
| 829 |
-
|
| 830 |
-
|
|
|
|
| 831 |
});
|
| 832 |
|
| 833 |
-
const hands = new Hands({locateFile: (file) => { return `
|
| 834 |
-
|
| 835 |
-
|
|
|
|
|
|
|
|
|
|
| 836 |
canvasCtx.save();
|
| 837 |
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
|
| 838 |
-
canvasCtx.drawImage(
|
| 839 |
|
| 840 |
-
// --- A. WAJAH (RENDER & BIOMETRIK) ---
|
| 841 |
if (currentFaceLandmarks) {
|
| 842 |
-
// Gambar Face Mesh
|
| 843 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_TESSELATION, {color: '#06b6d4', lineWidth: 0.5});
|
| 844 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYE, {color: '#ec4899', lineWidth: 2});
|
|
|
|
| 845 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYE, {color: '#ec4899', lineWidth: 2});
|
|
|
|
|
|
|
| 846 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LIPS, {color: '#ec4899', lineWidth: 2});
|
| 847 |
-
|
| 848 |
-
// Analisis Biometrik
|
| 849 |
-
const bio = analyzeFaceBiometrics(currentFaceLandmarks);
|
| 850 |
-
moodValue.textContent = bio.moodText; moodValue.style.color = bio.moodColor;
|
| 851 |
-
faceShapeValue.textContent = bio.faceText;
|
| 852 |
-
jawShapeValue.textContent = bio.jawText;
|
| 853 |
-
eyebrowShapeValue.textContent = bio.eyebrowText;
|
| 854 |
-
} else {
|
| 855 |
-
moodValue.textContent = "Wajah Hilang"; faceShapeValue.textContent = "Wajah Hilang";
|
| 856 |
-
jawShapeValue.textContent = "Wajah Hilang"; eyebrowShapeValue.textContent = "Wajah Hilang";
|
| 857 |
}
|
| 858 |
|
| 859 |
-
|
| 860 |
-
|
| 861 |
anims.forEach(a => a.style.opacity = '0');
|
| 862 |
|
| 863 |
-
if (
|
| 864 |
-
|
| 865 |
let boneColor = index === 0 ? '#ec4899' : '#06b6d4';
|
| 866 |
-
drawConnectors(canvasCtx,
|
| 867 |
-
drawLandmarks(canvasCtx,
|
| 868 |
|
| 869 |
-
let pose = classifyPose(
|
| 870 |
-
if (pose)
|
| 871 |
});
|
| 872 |
}
|
| 873 |
canvasCtx.restore();
|
| 874 |
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 878 |
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 885 |
}
|
| 886 |
});
|
| 887 |
|
| 888 |
-
|
| 889 |
-
|
|
|
|
|
|
|
|
|
|
| 890 |
sounds.forEach(s => { s.pause(); s.currentTime = 0; });
|
| 891 |
-
sounds[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 892 |
}
|
| 893 |
-
memoryActivePoses = detectedPoses.map(p => p.id);
|
| 894 |
-
memoryTimer = Date.now();
|
| 895 |
-
} else if (Date.now() - memoryTimer > 500) {
|
| 896 |
-
statusPose.textContent = "Menunggu formasi jari...";
|
| 897 |
-
statusPose.style.color = "#94a3b8";
|
| 898 |
-
memoryActivePoses = [];
|
| 899 |
}
|
| 900 |
});
|
| 901 |
|
| 902 |
startBtn.addEventListener('click', () => {
|
| 903 |
startBtn.style.display = 'none';
|
| 904 |
statusPose.textContent = "Menyiapkan Kamera...";
|
| 905 |
-
sounds.forEach(s => { s.play().then(()=>s.pause()); });
|
|
|
|
| 906 |
const camera = new Camera(videoElement, {
|
| 907 |
-
onFrame: async () => {
|
| 908 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 909 |
});
|
| 910 |
camera.start();
|
| 911 |
});
|
|
|
|
| 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>
|
|
|
|
| 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>
|
|
|
|
| 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 |
+
|
| 153 |
const anims = [document.getElementById('pose1Anim1'), document.getElementById('pose1Anim2')];
|
| 154 |
const sounds = [
|
| 155 |
document.getElementById('audio1'), document.getElementById('audio2'),
|
| 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;
|
| 164 |
|
| 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) {
|
|
|
|
| 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 |
|
| 215 |
+
const faceMesh = new FaceMesh({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${file}`; }});
|
| 216 |
+
faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: true, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
|
| 217 |
+
|
| 218 |
+
faceMesh.onResults((results) => {
|
| 219 |
+
currentFaceLandmarks = (results.multiFaceLandmarks && results.multiFaceLandmarks.length > 0) ? results.multiFaceLandmarks[0] : null;
|
| 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) => {
|
| 228 |
canvasCtx.save();
|
| 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, {
|
| 327 |
+
onFrame: async () => {
|
| 328 |
+
await faceMesh.send({image: videoElement});
|
| 329 |
+
await hands.send({image: videoElement});
|
| 330 |
+
},
|
| 331 |
+
width: 640,
|
| 332 |
+
height: 480
|
| 333 |
});
|
| 334 |
camera.start();
|
| 335 |
});
|