Spaces:
Running
Running
Update index.html
Browse files- index.html +737 -177
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,93 +46,692 @@
|
|
| 46 |
background: linear-gradient(135deg, #f472b6, #a78bfa);
|
| 47 |
}
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
background: rgba(15, 23, 42, 0.8);
|
|
|
|
|
|
|
| 51 |
border: 1px solid #334155;
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
border-radius: 12px;
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 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 {
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 69 |
-
height:
|
| 70 |
-
max-width:
|
| 71 |
object-fit: cover;
|
| 72 |
-
transform: scaleX(-1);
|
| 73 |
}
|
| 74 |
|
| 75 |
-
/*
|
| 76 |
.pose1-anim {
|
| 77 |
position: absolute;
|
| 78 |
-
opacity: 0;
|
| 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 |
-
|
| 85 |
-
transition: opacity 0.2s ease-in-out, left 0.1s linear, top 0.1s linear;
|
| 86 |
transform: scaleX(-1);
|
| 87 |
}
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
background: rgba(15, 23, 42, 0.85);
|
| 94 |
border: 2px solid #3b82f6;
|
| 95 |
-
padding:
|
| 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 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 107 |
</style>
|
| 108 |
</head>
|
| 109 |
<body>
|
| 110 |
|
| 111 |
-
<h2>🤖 AI Vision:
|
| 112 |
-
<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 |
-
<
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
<div class="divider"></div>
|
| 125 |
-
|
| 126 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
</div>
|
| 128 |
|
| 129 |
-
<
|
| 130 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
<
|
| 133 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,71 +744,71 @@
|
|
| 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 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|
| 168 |
-
//
|
| 169 |
-
const
|
| 170 |
-
const
|
| 171 |
-
const
|
| 172 |
-
|
| 173 |
-
const mouthWidth = getDistance(leftMouth, rightMouth);
|
| 174 |
-
const mouthHeight = getDistance(topLip, bottomLip);
|
| 175 |
-
const faceScale = getDistance(leftEye, rightEye);
|
| 176 |
-
|
| 177 |
-
const smileRatio = mouthWidth / faceScale;
|
| 178 |
-
const openRatio = mouthHeight / faceScale;
|
| 179 |
-
|
| 180 |
-
let moodText = "Netral 😐"; let moodColor = "#3b82f6";
|
| 181 |
-
if (openRatio > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; }
|
| 182 |
-
else if (smileRatio > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; }
|
| 183 |
-
|
| 184 |
-
// 2. LOGIKA DETEKSI GENDER BERDASARKAN PENUTUP KEPALA (HIJAB)
|
| 185 |
-
// Kita ukur jarak dari titik dahi paling atas (10) ke garis alis tengah (168)
|
| 186 |
-
const topHead = faceLandmarks[10];
|
| 187 |
-
const midEyebrow = faceLandmarks[168];
|
| 188 |
-
const foreheadHeight = getDistance(topHead, midEyebrow);
|
| 189 |
|
| 190 |
-
//
|
| 191 |
-
const
|
| 192 |
-
const
|
|
|
|
| 193 |
|
| 194 |
-
//
|
| 195 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
let
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
// Pengguna Hijab biasanya menutupi dahi, sehingga jarak 'foreheadHeight'
|
| 201 |
-
// yang dibaca AI akan menjadi sangat pendek atau tidak proporsional (< 0.22)
|
| 202 |
-
if (headRatio < 0.22) {
|
| 203 |
-
genderText = "Wanita 👩 (Hijab)";
|
| 204 |
-
genderColor = "#f472b6"; // Pink
|
| 205 |
-
} else {
|
| 206 |
-
// Jika dahi terlihat jelas (luas), maka deteksi sebagai Pria
|
| 207 |
-
genderText = "Pria 👨";
|
| 208 |
-
genderColor = "#60a5fa"; // Biru
|
| 209 |
-
}
|
| 210 |
|
| 211 |
-
return { moodText, moodColor,
|
| 212 |
}
|
|
|
|
| 213 |
function classifyPose(landmarks) {
|
| 214 |
const indexOpen = landmarks[8].y < landmarks[6].y;
|
| 215 |
const middleOpen = landmarks[12].y < landmarks[10].y;
|
|
@@ -221,131 +820,92 @@
|
|
| 221 |
if (indexOpen && middleOpen && ringOpen && pinkyOpen && thumbOpen) return { id: 4, name: "🖐️ Telapak", color: "#3b82f6" };
|
| 222 |
if (indexOpen && middleOpen && !ringOpen && !pinkyOpen) return { id: 2, name: "✌️ Victory", color: "#a855f7" };
|
| 223 |
if (thumbOpen && indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 1, name: "👉 Tunjuk & Jempol", color: "#eab308" };
|
| 224 |
-
|
| 225 |
-
const thumbIndexTipDist = getDistance(landmarks[4], landmarks[8]);
|
| 226 |
-
if (thumbIndexTipDist < 0.05 && middleOpen && ringOpen && pinkyOpen) return { id: 3, name: "👌 Okay", color: "#10b981" };
|
| 227 |
-
|
| 228 |
return null;
|
| 229 |
}
|
| 230 |
|
| 231 |
-
const faceMesh = new FaceMesh({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${file}`; }});
|
| 232 |
-
faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: true, minDetectionConfidence: 0.7
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
currentFaceLandmarks = (results.multiFaceLandmarks && results.multiFaceLandmarks.length > 0) ? results.multiFaceLandmarks[0] : null;
|
| 236 |
});
|
| 237 |
|
| 238 |
-
const hands = new Hands({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`; }});
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7, minTrackingConfidence: 0.7 });
|
| 242 |
-
|
| 243 |
-
hands.onResults((results) => {
|
| 244 |
canvasCtx.save();
|
| 245 |
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
|
| 246 |
-
canvasCtx.drawImage(
|
| 247 |
|
|
|
|
| 248 |
if (currentFaceLandmarks) {
|
|
|
|
| 249 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_TESSELATION, {color: '#06b6d4', lineWidth: 0.5});
|
| 250 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYE, {color: '#ec4899', lineWidth: 2});
|
| 251 |
-
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYEBROW, {color: '#ec4899', lineWidth: 2});
|
| 252 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYE, {color: '#ec4899', lineWidth: 2});
|
| 253 |
-
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYEBROW, {color: '#ec4899', lineWidth: 2});
|
| 254 |
-
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_FACE_OVAL, {color: '#ec4899', lineWidth: 2});
|
| 255 |
drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LIPS, {color: '#ec4899', lineWidth: 2});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
}
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
anims.forEach(a => a.style.opacity = '0');
|
| 261 |
|
| 262 |
-
if (
|
| 263 |
-
|
| 264 |
let boneColor = index === 0 ? '#ec4899' : '#06b6d4';
|
| 265 |
-
drawConnectors(canvasCtx,
|
| 266 |
-
drawLandmarks(canvasCtx,
|
| 267 |
|
| 268 |
-
let pose = classifyPose(
|
| 269 |
-
if (pose)
|
| 270 |
});
|
| 271 |
}
|
| 272 |
canvasCtx.restore();
|
| 273 |
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
let isPositivePose = detectedPosesThisFrame.some(p => p.id === 1 || p.id === 2 || p.id === 3);
|
| 278 |
-
if (bio.moodText === "Senang 😊" && isPositivePose) {
|
| 279 |
-
bio.moodText = "Sangat Senang! ✨"; bio.moodColor = "#eab308";
|
| 280 |
-
}
|
| 281 |
-
moodValue.textContent = bio.moodText; moodValue.style.color = bio.moodColor;
|
| 282 |
-
genderValue.textContent = bio.genderText; genderValue.style.color = bio.genderColor;
|
| 283 |
-
biometricContainer.style.borderColor = bio.moodColor; biometricContainer.style.boxShadow = `0 0 15px ${bio.moodColor}80`;
|
| 284 |
-
} else {
|
| 285 |
-
moodValue.textContent = "Wajah Hilang"; moodValue.style.color = "#94a3b8";
|
| 286 |
-
genderValue.textContent = "Wajah Hilang"; genderValue.style.color = "#94a3b8";
|
| 287 |
-
biometricContainer.style.borderColor = "#334155";
|
| 288 |
-
}
|
| 289 |
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
statusPose.style.color = detectedPosesThisFrame[0].color;
|
| 297 |
-
|
| 298 |
-
// Perbarui posisi GIF dengan halus
|
| 299 |
-
detectedPosesThisFrame.forEach((pose, i) => {
|
| 300 |
-
if (pose.id === 1 && anims[i]) {
|
| 301 |
-
const wrist = pose.wrist;
|
| 302 |
-
const leftPos = ((1 - wrist.x) * canvasElement.width) - 75;
|
| 303 |
-
const topPos = (wrist.y * canvasElement.height) + 30;
|
| 304 |
-
|
| 305 |
-
anims[i].style.opacity = '1'; // Munculkan dengan efek fade
|
| 306 |
-
anims[i].style.left = `${leftPos}px`;
|
| 307 |
-
anims[i].style.top = `${topPos}px`;
|
| 308 |
-
anims[i].style.width = `150px`;
|
| 309 |
}
|
| 310 |
});
|
| 311 |
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
if (newPoses.length > 0) {
|
| 316 |
-
let primaryNewPoseId = newPoses[0];
|
| 317 |
sounds.forEach(s => { s.pause(); s.currentTime = 0; });
|
| 318 |
-
|
| 319 |
-
if (soundToPlay) soundToPlay.play();
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
memoryActivePoses = currentIds; // Simpan memori terbaru
|
| 323 |
-
memoryTimer = Date.now(); // Reset stopwatch memori
|
| 324 |
-
|
| 325 |
-
} else {
|
| 326 |
-
// Tangan tidak terdeteksi. Jangan langsung bersihkan memori! Tunggu 0.5 detik (500ms)
|
| 327 |
-
if (Date.now() - memoryTimer > 500) {
|
| 328 |
-
if (memoryActivePoses.length > 0) {
|
| 329 |
-
statusPose.textContent = "Menunggu formasi jari...";
|
| 330 |
-
statusPose.style.color = "#94a3b8";
|
| 331 |
-
memoryActivePoses = [];
|
| 332 |
-
}
|
| 333 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
}
|
| 335 |
});
|
| 336 |
|
| 337 |
startBtn.addEventListener('click', () => {
|
| 338 |
startBtn.style.display = 'none';
|
| 339 |
statusPose.textContent = "Menyiapkan Kamera...";
|
| 340 |
-
sounds.forEach(s => { s.play().then(()
|
| 341 |
-
|
| 342 |
const camera = new Camera(videoElement, {
|
| 343 |
-
onFrame: async () => {
|
| 344 |
-
|
| 345 |
-
await hands.send({image: videoElement});
|
| 346 |
-
},
|
| 347 |
-
width: 640,
|
| 348 |
-
height: 480
|
| 349 |
});
|
| 350 |
camera.start();
|
| 351 |
});
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Vision - Biometric & Pose Analytics v21 - Rizki Ardiansyah</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 |
+
/* --- LAYOUT DUA SISI PANEL DATA (KIRI & KANAN) --- */
|
| 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 |
+
z-index: 15;
|
| 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 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 291 |
+
backdrop-filter: blur(5px);
|
| 292 |
+
min-width: 250px;
|
|
|
|
| 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: 800px; /* Kanvas lebih besar */
|
| 306 |
+
height: 600px; /* Proporsional 4:3 */
|
| 307 |
+
max-width: 100%;
|
| 308 |
object-fit: cover;
|
| 309 |
+
transform: scaleX(-1); /* Efek Cermin */
|
| 310 |
}
|
| 311 |
|
| 312 |
+
/* GIF Animasi */
|
| 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 |
+
transition: opacity 0.2s, left 0.1s, top 0.1s;
|
|
|
|
| 322 |
transform: scaleX(-1);
|
| 323 |
}
|
| 324 |
|
| 325 |
+
/* --- STYLING DATA BIOMETRIK (KIRI & KANAN) --- */
|
| 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 |
+
opacity: 0;
|
| 482 |
+
border-radius: 8px;
|
| 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: 20px;
|
| 627 |
+
border-radius: 12px;
|
| 628 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 629 |
+
backdrop-filter: blur(5px);
|
| 630 |
+
min-width: 250px;
|
| 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: 12px 0; }
|
| 668 |
+
</style>
|
| 669 |
+
</head>
|
| 670 |
+
<body>
|
| 671 |
+
|
| 672 |
+
<h2>🤖 AI Vision: Biometric Analytics v21 By Rizki Ardiansyah</h2>
|
| 673 |
+
<p>Deteksi Dua Tangan + Wajah & Alis Real-Time v21</p>
|
| 674 |
+
|
| 675 |
+
<button id="startBtn">▶ Mulai Sistem Deteksi</button>
|
| 676 |
+
|
| 677 |
+
<div id="statusContainer">
|
| 678 |
+
<div id="statusPose" style="font-size: 24px; font-weight: bold; color: #94a3b8;">Menunggu Kamera...</div>
|
| 679 |
+
</div>
|
| 680 |
+
|
| 681 |
+
<!-- --- LAYOUT UTAMA --- -->
|
| 682 |
+
<div class="analytics-layout">
|
| 683 |
|
| 684 |
+
<!-- --- PANEL DATA SISI KIRI (STATUS DETEKSI) --- -->
|
| 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-label">Status Deteksi Wajah</div>
|
| 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 |
+
<!-- --- PANEL DATA SISI KANAN (BIOMETRIK LENGKAP) --- -->
|
| 710 |
+
<div class="data-panel" id="panelKanan">
|
| 711 |
+
<div class="bio-label">Kondisi Mood (v21)</div>
|
| 712 |
+
<div id="moodValue" class="bio-value">...</div>
|
| 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 |
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 |
+
// Variabel Data Panel
|
| 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(faceMesh) {
|
| 767 |
+
// Data anatomi wajah (titik-titik referensi)
|
| 768 |
+
const dahi = faceMesh[10]; const dagu = faceMesh[152];
|
| 769 |
+
const pipiKiri = faceMesh[234]; const pipiKanan = faceMesh[454];
|
| 770 |
+
const rahangKiri = faceMesh[132]; const rahangKanan = faceMesh[361];
|
| 771 |
+
const alisKiri = faceMesh[52]; const alisKanan = faceMesh[282];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
|
| 773 |
+
// Perhitungan Rasio & Jarak
|
| 774 |
+
const faceHeight = getDistance(dahi, dagu);
|
| 775 |
+
const faceWidth = getDistance(pipiKiri, pipiKanan);
|
| 776 |
+
const jawWidth = getDistance(rahangKiri, rahangKanan);
|
| 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 |
+
return { moodText, moodColor, faceText, jawText, eyebrowText };
|
| 810 |
}
|
| 811 |
+
|
| 812 |
function classifyPose(landmarks) {
|
| 813 |
const indexOpen = landmarks[8].y < landmarks[6].y;
|
| 814 |
const middleOpen = landmarks[12].y < landmarks[10].y;
|
|
|
|
| 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 |
+
if (getDistance(landmarks[4], landmarks[8]) < 0.05 && middleOpen) return { id: 3, name: "👌 Okay", color: "#10b981" };
|
|
|
|
|
|
|
|
|
|
| 824 |
return null;
|
| 825 |
}
|
| 826 |
|
| 827 |
+
const faceMesh = new FaceMesh({locateFile: (file) => { return `[https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/$](https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/$){file}`; }});
|
| 828 |
+
faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: true, minDetectionConfidence: 0.7 });
|
| 829 |
+
faceMesh.onResults((res) => {
|
| 830 |
+
currentFaceLandmarks = (res.multiFaceLandmarks && res.multiFaceLandmarks.length > 0) ? res.multiFaceLandmarks[0] : null;
|
|
|
|
| 831 |
});
|
| 832 |
|
| 833 |
+
const hands = new Hands({locateFile: (file) => { return `[https://cdn.jsdelivr.net/npm/@mediapipe/hands/$](https://cdn.jsdelivr.net/npm/@mediapipe/hands/$){file}`; }});
|
| 834 |
+
hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.7 });
|
| 835 |
+
hands.onResults((res) => {
|
|
|
|
|
|
|
|
|
|
| 836 |
canvasCtx.save();
|
| 837 |
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
|
| 838 |
+
canvasCtx.drawImage(res.image, 0, 0, canvasElement.width, canvasElement.height);
|
| 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 |
+
// --- B. TANGAN (RENDER & POSES) ---
|
| 860 |
+
let detectedPoses = [];
|
| 861 |
anims.forEach(a => a.style.opacity = '0');
|
| 862 |
|
| 863 |
+
if (res.multiHandLandmarks) {
|
| 864 |
+
res.multiHandLandmarks.forEach((lm, index) => {
|
| 865 |
let boneColor = index === 0 ? '#ec4899' : '#06b6d4';
|
| 866 |
+
drawConnectors(canvasCtx, lm, HAND_CONNECTIONS, {color: boneColor, lineWidth: 4});
|
| 867 |
+
drawLandmarks(canvasCtx, lm, {color: '#ffffff', lineWidth: 2, radius: 3});
|
| 868 |
|
| 869 |
+
let pose = classifyPose(lm);
|
| 870 |
+
if (pose) detectedPoses.push({ ...pose, handIndex: index, wrist: lm[0] });
|
| 871 |
});
|
| 872 |
}
|
| 873 |
canvasCtx.restore();
|
| 874 |
|
| 875 |
+
if (detectedPoses.length > 0) {
|
| 876 |
+
statusPose.textContent = [...new Set(detectedPoses.map(p => p.name))].join(" & ");
|
| 877 |
+
statusPose.style.color = detectedPoses[0].color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 878 |
|
| 879 |
+
detectedPoses.forEach((p, i) => {
|
| 880 |
+
if (p.id === 1 && anims[i]) {
|
| 881 |
+
anims[i].style.opacity = '1';
|
| 882 |
+
anims[i].style.left = `${((1-p.wrist.x)*canvasElement.width)-75}px`;
|
| 883 |
+
anims[i].style.top = `${(p.wrist.y*canvasElement.height)+30}px`;
|
| 884 |
+
anims[i].style.width = "150px";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 885 |
}
|
| 886 |
});
|
| 887 |
|
| 888 |
+
let newIds = detectedPoses.map(p => p.id).filter(id => !memoryActivePoses.includes(id));
|
| 889 |
+
if (newIds.length > 0) {
|
|
|
|
|
|
|
|
|
|
| 890 |
sounds.forEach(s => { s.pause(); s.currentTime = 0; });
|
| 891 |
+
sounds[newIds[0]-1]?.play();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 () => { await faceMesh.send({image: videoElement}); await hands.send({image: videoElement}); },
|
| 908 |
+
width: 640, height: 480
|
|
|
|
|
|
|
|
|
|
|
|
|
| 909 |
});
|
| 910 |
camera.start();
|
| 911 |
});
|