Spaces:
Running
Running
Update index.html
Browse files- index.html +21 -20
index.html
CHANGED
|
@@ -165,7 +165,7 @@
|
|
| 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 |
-
// 1. Analisis Mood
|
| 169 |
const leftMouth = faceLandmarks[61]; const rightMouth = faceLandmarks[291];
|
| 170 |
const topLip = faceLandmarks[13]; const bottomLip = faceLandmarks[14];
|
| 171 |
const leftEye = faceLandmarks[33]; const rightEye = faceLandmarks[263];
|
|
@@ -181,34 +181,35 @@
|
|
| 181 |
if (openRatio > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; }
|
| 182 |
else if (smileRatio > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; }
|
| 183 |
|
| 184 |
-
// 2.
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
const leftJaw = faceLandmarks[132]; const rightJaw = faceLandmarks[361];
|
| 187 |
-
|
| 188 |
-
const cheekWidth = getDistance(leftCheek, rightCheek);
|
| 189 |
const jawWidth = getDistance(leftJaw, rightJaw);
|
| 190 |
-
const jawToCheekRatio = jawWidth / cheekWidth;
|
| 191 |
|
| 192 |
-
//
|
| 193 |
-
|
| 194 |
-
let angkaRasio = jawToCheekRatio.toFixed(3);
|
| 195 |
|
| 196 |
let genderText = ""; let genderColor = "";
|
| 197 |
-
|
| 198 |
-
//
|
| 199 |
-
//
|
| 200 |
-
//
|
| 201 |
-
if (
|
| 202 |
-
genderText =
|
| 203 |
-
genderColor = "#
|
| 204 |
-
} else {
|
| 205 |
-
|
| 206 |
-
|
|
|
|
| 207 |
}
|
| 208 |
|
| 209 |
return { moodText, moodColor, genderText, genderColor };
|
| 210 |
}
|
| 211 |
-
|
| 212 |
function classifyPose(landmarks) {
|
| 213 |
const indexOpen = landmarks[8].y < landmarks[6].y;
|
| 214 |
const middleOpen = landmarks[12].y < landmarks[10].y;
|
|
|
|
| 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 |
+
// 1. Analisis Mood (Tetap Sama)
|
| 169 |
const leftMouth = faceLandmarks[61]; const rightMouth = faceLandmarks[291];
|
| 170 |
const topLip = faceLandmarks[13]; const bottomLip = faceLandmarks[14];
|
| 171 |
const leftEye = faceLandmarks[33]; const rightEye = faceLandmarks[263];
|
|
|
|
| 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 |
+
// Kita ukur juga lebar rahang untuk perbandingan tambahan
|
| 191 |
const leftJaw = faceLandmarks[132]; const rightJaw = faceLandmarks[361];
|
|
|
|
|
|
|
| 192 |
const jawWidth = getDistance(leftJaw, rightJaw);
|
|
|
|
| 193 |
|
| 194 |
+
// Rasio dahi terhadap lebar wajah
|
| 195 |
+
const headRatio = foreheadHeight / jawWidth;
|
|
|
|
| 196 |
|
| 197 |
let genderText = ""; let genderColor = "";
|
| 198 |
+
|
| 199 |
+
// LOGIKA RIZKI:
|
| 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, genderText, genderColor };
|
| 212 |
}
|
|
|
|
| 213 |
function classifyPose(landmarks) {
|
| 214 |
const indexOpen = landmarks[8].y < landmarks[6].y;
|
| 215 |
const middleOpen = landmarks[12].y < landmarks[10].y;
|