Pelacak Fokus Mata Real-Time — Aplikasi AI untuk memonitor tingkat konsentrasi melalui kamera web, menggunakan deteksi landmark wajah via MediaPipe.
v2.0 — Proportional scoring + fixation hysteresis + EMA smoothing + peak saccade detection
- Fitur Utama
- Arsitektur
- Cara Kerja
- Setup & Menjalankan
- Mode Offline / Akses dari Device Lain
- API Dokumentasi
- Algoritma & Parameter
- Teknologi Stack
- Struktur Proyek
- Pengaturan & Threshold
- Troubleshooting
| Fitur | Deskripsi |
|---|---|
| Deteksi Wajah & Landmark Mata | Menggunakan MediaPipe FaceMesh untuk mendeteksi 478 titik wajah termasuk kontur mata & iris |
| Pelacakan Iris | Deteksi posisi iris/iris kiri & kanan untuk menentukan arah pandang |
| Eye Aspect Ratio (EAR) | Hitung rasio aspek mata secara real-time untuk mendeteksi kedipan & rasa kantuk |
| Blink vs Drowsy State Machine | Membedakan kedipan normal (<400ms) dengan kondisi mengantuk (>700ms mata tertutup) |
| Relative Gaze | Posisi iris relatif terhadap eye socket — tidak terpengaruh oleh pergerakan kepala |
| Fixation Detection | Mendeteksi saat mata diam (fiksasi) berdasarkan kecepatan gaze < threshold |
| Saccade Detection (Peak) | Mendeteksi pergerakan mata cepat berbasis MAX single-step gaze velocity (jauh lebih sensitif dari rata-rata) |
| Screen Detection | Kombinasi head pose + iris position untuk memperkirakan apakah user melihat layar |
| Focus Score | Skor 0–100 dari agregasi EAR, gaze, fiksasi, saccade, dan screen detection |
| Kalibrasi Adaptif | Auto-kalibrasi baseline EAR & gaze center untuk adaptasi per-user |
| Real-time Web Dashboard | UI Vue 3 dengan gauge, metrik, grafik, dan sesi monitoring |
| Session Recording | Rekam data fokus per sesi, simpan di localStorage, lihat riwayat |
| PDF Export | Ekspor laporan sesi ke PDF profesional |
| CSV Export | Ekspor raw data sesi ke CSV (22 kolom metrik) + ringkasan sesi, kompatibel Excel |
| REST API | Endpoint untuk integrasi dashboard eksternal / parent system |
| WebSocket Realtime | Kirim data fokus ke backend secara real-time |
| Akses mobile via LAN | Auto-deteksi IP lokal & opsi tunnel Cloudflare untuk HTTPS publik |
| Cloudflare Tunnel | HTTPS publik via wrangler tunnel quick-start — no SSL warning di HP |
| Saccade Velocity | Metrik velositas puncak (peak) per frame — tidak diencerkan oleh frame diam di sekitarnya |
| Multi-Metric Chart | Grafik canvas multi-metrik: focus_score + screen_score + blink + saccade + drowsy markers |
| Calibration UI | Full-screen overlay kalibrasi dengan animasi progress bar, step indicator, tombol prominent |
| Metrics Panel v5 | 16 metrik real-time dengan color-coding dan blink/saccade flash animations |
| Export group | Tombol PDF & CSV bersebelahan di sesi aktif + ikon export di setiap riwayat sesi |
| Bundle Optimization | Code splitting (MediaPipe, jsPDF, Vue) + minify + tree-shaking |
| Dark/Light Theme | Tema gelap & terang dengan persistensi localStorage |
| Bahasa Indonesia | UI & laporan sepenuhnya dalam Bahasa Indonesia |
| Responsive | Layout adaptif untuk mobile, tablet, dan desktop |
┌─────────────────────────────────────────────────────────────┐
│ BROWSER (Vue 3 SPA) │
│ ┌──────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Camera │ │ FocusTracker │ │ WebSocket Client │ │
│ │ (MediaPipe│→│ (Algorithm │→│ (useFocusApi.js) │ │
│ │ FaceMesh) │ │ Engine) │ │ │ │
│ └──────────┘ └──────────────┘ └─────────┬────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────┴──────────────┐ │
│ │ App.vue (Layout, Settings, Session, Charts, Controls) │ │
│ └────────────────────────────────────────────────────────┘ │
└────────────────────────────────┬────────────────────────────┘
│ WebSocket /ws/focus
▼
┌─────────────────────────────────────────────────────────────┐
│ BACKEND (FastAPI + uvicorn) │
│ │
│ ┌────────────────────┐ ┌──────────────────────────────┐ │
│ │ WebSocket Handler │ │ REST API │ │
│ │ /ws/focus │ │ /api/current-status │ │
│ │ │ │ /api/summary │ │
│ └────────┬───────────┘ │ /api/history │ │
│ │ │ /api/session │ │
│ ▼ │ /api/health │ │
│ ┌────────────────┐ └──────────────────────────────┘ │
│ │ FocusStore │ │
│ │ (In-Memory) │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌──────────┴──────────┐
▼ ▼
┌──────────────┐ ┌──────────────────┐
│ Vue Dev Server│ │ Cloudflare Tunnel │
│ :5173 │ │ (opsional) │
│ HTTP │ │ HTTPS publik │
└──────────────┘ └──────────────────┘
- Camera →
getUserMedia()menangkap video 640×480 - MediaPipe FaceMesh → Deteksi 478 landmark wajah per-frame
- FocusTracker.process() → Compute: EAR → Relative Gaze → Blink State → Fixation/Saccade → Screen Detection → Focus Score → Status
- Emit → Data dikirim ke App.vue (display) via event, dan ke backend via WebSocket
- Backend → FastAPI menerima, menyimpan di FocusStore (in-memory deque), menyediakan REST API
- LocalStorage → Settings & completed sessions disimpan di browser
MediaPipe FaceMesh menghasilkan 478 titik 3D per wajah
├── Kontur mata kiri: [33, 160, 158, 133, 153, 144]
├── Kontur mata kanan: [362, 385, 387, 263, 373, 380]
├── Iris kiri: [474, 475, 476, 477]
├── Iris kanan: [469, 470, 471, 472]
└── Wajah: hidung, dagu, pipi, dahi, dll.
EAR = (|p1-p5| + |p2-p4|) / (2 × |p0-p3|)
p1───p2
/ \
p0 p3
\ /
p5───p4
- EAR normal : ~0.22–0.35 (mata terbuka)
- EAR rendah : <0.175 (mata tertutup/nyaris tertutup)
- Smoothing : rolling average 5 frame
┌──────────┐
│ AWAKE │ ◄───────────────────────────────┐
│ (EAR≥thr) │ │
└─────┬─────┘ │
│ EAR < ear_drowsy_threshold │
▼ │
┌──────────┐ ┌──────────────────┐ │
│ BLINK │──dt→ │ EAR naik < 400ms │──────┤ (Blink normal)
│ CHECK │ │ → BLINK COUNT++ │ │
│ (EAR low)│ └──────────────────┘ │
└─────┬────┘ │
│ dt > 700ms & EAR masih rendah │
▼ │
┌──────────┐ ┌──────────────────┐ │
│ DROWSY │──dt→ │ EAR naik ≥ 0.22 │──────┤ (Sadar lagi)
│ (ngantuk)│ │ (debounce 100ms) │ │
└──────────┘ └──────────────────┘ │
│
Relative gaze menghitung posisi iris relatif terhadap eye socket, bukan terhadap frame kamera. Ini membuatnya tidak terpengaruh oleh pergerakan kepala.
rel_x = (iris_center.x - eye_center.x) / eye_width
rel_y = (iris_center.y - eye_center.y) / eye_height
Nilai:
(0, 0) = iris tepat di tengah eye socket
positif = kanan (x) / bawah (y)
negatif = kiri (x) / atas (y)
Peningkatan kunci di v2.0:
Fixation menggunakan HYSTERESIS — threshold masuk (0.08) lebih rendah dari threshold keluar (0.18). Ini mencegah rapid toggling akibat noise MediaPipe. Begitu mata diam, fixation bertahan sampai ada gerakan berarti.
Saccade dideteksi dengan PEAK velocity (max single-step dari 2-3 frame terakhir), bukan rata-rata. Satu gerakan mata cepat tidak akan terencerkan oleh frame-frame diam di sekitarnya.
| Parameter | Fixation | Saccade |
|---|---|---|
| Velocity Method | Average (5 frame) | PEAK (max last 3 frame) |
| Threshold Masuk | < 0.08 unit/frame | > 0.20 unit/frame |
| Threshold Keluar | > 0.18 unit/frame (hysteresis) | — |
| Deskripsi | Mata diam, fokus | Mata bergerak cepat |
| Konstribusi Score | +0–25 (proportional) | 0 (saccade count rendah → +0–15) |
| Fixation Reset | — | Otomatis reset saat saccade terdeteksi |
Kombinasi 4 sinyal untuk menentukan apakah user melihat layar:
| Signal | Bobot | Deskripsi |
|---|---|---|
| Head turn | 1.0 | Face asymmetry ratio (1.0 = symmetric) |
| Gaze away | 1.0 | Relative gaze terlalu jauh dari center |
| Eyes closed | 1.0 | Drowsy = tidak lihat layar |
| Gaze centered | 1.0 | Gaze dalam threshold ratio |
Score = average(4 signals); looking_at_screen = score ≥ 0.5
Tidak ada komponen binary (on/off). Semua kontribusi bersifat proportional sehingga skor tidak melompat drastis akibat noise kecil.
Focus Score (0–100) = Base 15 + Σ kontribusi proportional:
+0–10 EAR (linear: 0.15→0pts, 0.35→10pts)
+0–20 Gaze centered (deadband 0.05: 20pts, linear turun ke 0 di 0.25)
+0–25 Fixation confidence (gaze_velocity/0.25, inverse)
+0–15 Saccade inverse (count <20: 15pts, 20-100: linear turun, >100: 0)
+0–15 Screen score continuous (screen_score × 15)
-0–15 Blink penalty (smooth: -0.33/blink, max -15)
Max raw = 100 → langsung clamp 0-100 (tanpa normalisasi 100/85)
Smoothing: EMA α=0.10 (Exponential Moving Average)
Keuntungan proportional scoring:
- Saat user diam (tidak bergerak), skor stabil karena tidak ada komponen yang tiba-tiba hilang 25 poin
- Noise kecil dari MediaPipe tidak menyebabkan lompatan 30-50 poin
- Base score 15 memastikan skor tidak pernah 0 selama wajah terdeteksi
Status ditentukan setelah semua komponen proportional dijumlah + di-EMA smooth:
| Kondisi | Status |
|---|---|
| Drowsy true | MENGANTUK |
| Not looking at screen & score < 65 | TDK FOKUS |
| Score ≥ 65 & lihat layar | FOKUS |
| Score ≥ 40 & lihat layar | KURANG FOKUS |
| Score < 40 atau tidak lihat layar | TDK FOKUS |
- Trigger: Tombol "Kalibrasi Mata" di kamera, atau auto-kalibrasi 1 detik setelah tracker pertama dibuat
- UI: Full-screen overlay dengan progress bar, animasi pulse, dan step indicator (1. Tengok tengah → 2. Mata terbuka → 3. Selesai)
- Proses: Kumpulkan 30 frame non-blink → hitung rata-rata EAR & relative gaze
- Output:
baseline_ear,baseline_rel_gaze_x,baseline_rel_gaze_y - Gunakan: Baseline digunakan untuk menyesuaikan threshold per-user
- Python 3.10+
- Node.js 18+
- Kamera web (built-in atau eksternal)
- Cloudflare Wrangler (opsional, untuk tunnel)
# Backend
cd backend
pip install -r requirements.txt
# Frontend
cd frontend
npm installGunakan start.bat (Windows) atau jalankan manual:
# Terminal 1: Backend
cd backend
uvicorn app:app --host 0.0.0.0 --port 8765 --reload
# Terminal 2: Frontend
cd frontend
npx vite --host 0.0.0.0 --port 5173Buka http://localhost:5173 di browser.
start.batScript akan:
- Deteksi IP lokal otomatis
- Kill proses lama
- Start backend (uvicorn di port 8765)
- Start frontend (Vite di port 5173)
- Start Cloudflare tunnel (opsional, untuk akses publik HTTPS)
cd frontend
npm run build # Output ke frontend/dist/Backend akan otomatis serve file static dari frontend/dist/ jika ada.
- Jalankan
start.bat— IP lokal terdeteksi otomatis - Dari HP/device lain, buka
http://{IP_LOKAL}:5173 - Browser mungkin tampilkan warning SSL (self-signed cert untuk localhost) — klik "Load unsafe scripts"
- Pastikan
wranglerterinstall:npm install -g wrangler - Jalankan
start.bat— tunnel otomatis start di jendela terpisah - Cari URL
https://xxx.trycloudflare.comdi jendela "EyeFocus-Tunnel" - Buka URL tersebut dari HP — no SSL warning, camera API berfungsi penuh
┌─────────────────────────────────────────────┐
│ MOBILE │
│ https://xxx.trycloudflare.com │
│ │ │
│ ▼ │
│ Cloudflare Tunnel │
│ (HTTPS with REAL SSL cert) │
│ │ │
│ ▼ │
│ Laptop: localhost:5173 (HTTP) │
│ Laptop: localhost:8765 (Backend HTTP) │
└─────────────────────────────────────────────┘
Catatan: Tunnel butuh koneksi internet. Pertama kali
wrangler tunnel quick-startakan mendownload cloudflared (~15MB).
Jika akses dari HP tanpa tunnel, pastikan:
- Halaman diakses via HTTPS (atau
localhost/127.0.0.1) — karenagetUserMedia()butuh secure context - Gunakan
http://{IP}:5173via WiFi — beberapa browser mobile tetap blokir. Gunakan tunnel untuk solusi terbaik.
Semua endpoint REST API tersedia di port 8765 (backend).
| Method | Endpoint | Deskripsi |
|---|---|---|
| GET | /api/current-status |
Status fokus terkini (real-time) |
| GET | /api/summary |
Ringkasan statistik session (avg, pct) |
| GET | /api/history?limit=300 |
Riwayat data fokus (default 300 titik) |
| GET | /api/session |
Informasi session saat ini |
| GET | /api/health |
Health check |
| WS | /ws/focus |
WebSocket untuk menerima data real-time |
| GET | /api/docs |
Dokumentasi API interaktif (Swagger) |
GET /api/current-status (v5)
{
"status": "FOKUS",
"focus_score": 85,
"ear": 0.25,
"iris_diam": 15.3,
"gaze_x": 0.02,
"gaze_y": -0.01,
"motion_speed": 0.08,
"fixation_time": 2.5,
"saccade_count": 12,
"brightness": 145,
"session_id": "A1B2C3D4E5F6",
"elapsed": 120.5,
"face_detected": true,
"timestamp": 1718000000.0,
"is_blinking": false,
"is_drowsy": false,
"looking_at_screen": true,
"screen_score": 0.95,
"gaze_velocity": 0.08,
"face_asymmetry": 0.98,
"calibrated": true,
"blink_count": 5
}GET /api/summary
{
"session_id": "A1B2C3D4E5F6",
"duration": 125.3,
"avg_focus": 72.4,
"focus_pct": 68.5,
"no_face_pct": 5.2,
"drowsy_pct": 8.1,
"total_points": 1253
}GET /api/health
{
"status": "ok",
"service": "eye-focus-tracker",
"version": "1.0.0"
}Setiap data point yang dikirim via WebSocket, dan juga diexport ke CSV:
| Field | Tipe | Deskripsi |
|---|---|---|
index |
number | No urut (hanya di CSV) |
status |
string | FOKUS, KURANG_FOKUS, TDK_FOKUS, MENGANTUK, NO_FACE |
focus_score |
number | Skor fokus 0–100 (smoothed) |
ear |
number | Eye Aspect Ratio |
iris_diam |
number | Diameter iris (px) |
gaze_x |
number | Relative gaze X (-1..1) |
gaze_y |
number | Relative gaze Y (-1..1) |
gaze_velocity |
number | Average gaze velocity (normalized units/frame) |
saccade_velocity |
number | PEAK saccade velocity (normalized units/frame) |
blink_count |
number | Total kedipan dalam sesi |
is_blinking |
boolean | Apakah sedang kedip (CSV: 1/0) |
is_drowsy |
boolean | Apakah sedang mengantuk (CSV: 1/0) |
is_fixating |
boolean | Apakah mata diam/fiksasi (CSV: 1/0) |
is_saccade |
boolean | Apakah terjadi saccade (CSV: 1/0) |
looking_at_screen |
boolean | Apakah user melihat layar (CSV: 1/0) |
screen_score |
number | Skor screen detection (0–1) |
face_asymmetry |
number | Rasio asimetri wajah (1.0 = simetris) |
brightness |
number | Kecerahan area iris (0–255) |
face_detected |
boolean | Apakah wajah terdeteksi (CSV: 1/0) |
calibrated |
boolean | Apakah kalibrasi sudah dilakukan (CSV: 1/0) |
fixation_time |
number | Durasi fiksasi (detik) |
saccade_count |
number | Jumlah saccade |
motion_speed |
number | Gaze velocity (avg) — duplicate |
@dataclass
class FocusConfig:
# Blink / Drowsy
ear_drowsy_threshold: float = 0.175 # EAR threshold for eye closure
ear_focus_threshold: float = 0.22 # EAR threshold for focus
blink_max_duration: float = 0.40 # detik — maks durasi kedipan normal
drowsy_min_duration: float = 0.70 # detik — minimal untuk dinyatakan mengantuk
# Gaze (relative / normalized)
gaze_ratio_threshold: float = 0.12 # max |relative_gaze| for center-looking
# Fixation — hysteresis (cegah rapid toggling)
relative_gaze_fixation_threshold: float = 0.08 # masuk fixation
relative_gaze_fixation_exit_threshold: float = 0.18 # keluar fixation
# Saccade — PEAK detection
relative_gaze_saccade_threshold: float = 0.20 # normalized units/frame
# Focus score weights (proportional)
score_ear: float = 10
score_gaze: float = 20
score_fixation: float = 25
score_saccade_low: float = 15
score_screen: float = 15
score_blink_penalty: float = -5
# Screen detection
head_turn_threshold: float = 0.30
gaze_away_threshold_x: float = 0.35
gaze_away_threshold_y: float = 0.25
# Kalibrasi
calibration_frames: int = 30
calibration_timeout: float = 5.0| Aspek | v5 (sebelumnya) | v2.0 (sekarang) |
|---|---|---|
| Focus Score | Binary on/off — swing 60 pts dari noise | Proportional — semua komponen kontinu, stabil ✅ |
| Fixation | Threshold tunggal 0.05 → rapid toggling | Hysteresis: masuk 0.08, keluar 0.18 — cegah toggling ✅ |
| Normalisasi | 100/85 amplifikasi fluktuasi 1.176× |
Max raw=100, langsung clamp, tidak ada amplifikasi ✅ |
| Smoothing | Rolling average 8 frame | EMA α=0.10 — memori lebih panjang, lebih halus ✅ |
| Saccade Detection | Average velocity (terencerkan) | PEAK velocity — 1 gerakan cepat langsung terdeteksi ✅ |
| Blink vs Drowsy | State machine: kedip (<400ms) vs drowsy (>700ms) | Sama ✅ |
| Gaze Tracking | Relative gaze (iris vs eye socket) | Sama ✅ |
| Screen Detection | Head pose + iris position + drowsiness | Sama ✅ |
| Kalibrasi | Auto-kalibrasi baseline EAR & gaze center | Sama ✅ |
| Base Score | 0 (bisa 0 saat wajah terdeteksi) | 15 — selalu dapat minimal 15 ✅ |
| Multi-Metric Chart | Grafik multi-metrik | Sama ✅ |
| Calibration UI | Full-screen overlay | Sama ✅ |
| Metrics Panel | 16 metrik | Sama ✅ |
CSV export tersedia dalam dua mode:
| Mode | Tombol | Data | Header Kolom |
|---|---|---|---|
| Raw Data | CSV (di sesi aktif) |
Semua data points dari focusHistory (22 kolom metrik) |
index, status, focus_score, ear, …, motion_speed |
| Summary | Ikon CSV (di riwayat sesi) | Ringkasan statistik sesi (11 kolom) | session_id, start, end, duration_s, data_points, avg_focus, focus_pct, kurang_fokus_pct, tdk_fokus_pct, drowsy_pct, no_face_pct |
Fitur CSV:
- BOM UTF-8 (
\uFEFF) — kompatibel dengan Excel, bukan UTF-8 BOM → kolom tidak terpisah - Escaping — string dengan koma, kutip, atau newline otomatis di-quote
- Boolean —
true/falsedikonversi ke1/0untuk kemudahan analisis - Number — diformat dengan 4 desimal untuk presisi
- Filename —
eye-focus_{sessionId}_{YYYY-MM-DD}.csv
Catatan: Raw data hanya tersedia untuk sesi aktif (belum di-stop). Sesi yang sudah selesai hanya menyimpan ringkasan di localStorage, bukan data mentah.
| Layer | Teknologi | Versi |
|---|---|---|
| Face Detection | MediaPipe FaceMesh | 0.10.18 |
| Frontend Framework | Vue 3 (Composition API) | 3.5.13 |
| Build Tool | Vite | 6.2.4 |
| Backend | FastAPI + uvicorn | 0.115.6 |
| PDF Export | jsPDF | 4.2.1 |
| WebSocket | Native WebSocket API + FastAPI WebSocket | — |
| Tunnel | Cloudflare Wrangler | latest |
| Python OpenCV | OpenCV untuk visualisasi debug | 4.x |
| Python | eye5.py — standalone CLI dengan OpenCV highgui | — |
| CSS | CSS Variables (theming), CSS Grid, Flexbox, Transitions | — |
eye-focus-tracker/
├── eye5.py # ⚡ Standalone Python eye tracker (OpenCV + MediaPipe)
├── start.bat # 🚀 Startup script (backend + frontend + tunnel)
├── .gitignore
│
├── backend/
│ ├── app.py # 🖥 FastAPI backend (WebSocket + REST + static)
│ ├── requirements.txt # Python dependencies
│ └── __init__.py
│
├── frontend/
│ ├── package.json # Node dependencies & scripts
│ ├── vite.config.js # Vite build config (code splitting, minify, proxy)
│ ├── index.html # Entry HTML
│ │
│ └── src/
│ ├── main.js # Vue app bootstrap + l10n
│ ├── App.vue # 🏠 Main layout (header, grid, footer, settings drawer)
│ │
│ ├── components/
│ │ ├── CameraView.vue # 📷 Kamera + MediaPipe loop + overlay
│ │ ├── FocusGauge.vue # 🎯 Gauge chart (0–100 score)
│ │ ├── StatusCard.vue # 🟢 Status indikator (FOKUS/MENGANTUK/dll)
│ │ ├── MetricsPanel.vue # 📊 Metrik grid (EAR, gaze, fiksasi, dll)│ │ ├── FocusChart.vue # 📈 Timeline chart (single metric: focus_score)
│ │ ├── MultiMetricChart.vue # 📊 Multi-metrik chart (focus + screen + events)
│ │ ├── SessionInfo.vue # 📋 Detail sesi aktif
│ │ ├── SessionControls.vue # 🎮 Start/stop, riwayat, export PDF & CSV
│ │ ├── SettingsDrawer.vue # ⚙️ Settings drawer (theme, threshold, performa)
│ │ └── ParentApiInfo.vue # 🔗 API docs untuk integrasi parent system
│ │
│ ├── composables/
│ │ ├── useEyeTracker.js # 🧠 Core algorithm engine (mirror eye5.py)
│ │ ├── useFocusApi.js # 🔌 WebSocket + REST API client
│ │ ├── useSession.js # 📝 Session management (start/stop/storage)
│ │ ├── useSettings.js # ⚙️ Reactive settings with localStorage
│ │ └── usePdfExport.js # 📄 jsPDF report generator
│ │
│ ├── utils/
│ │ └── exportCsv.js # 📊 CSV export: raw data + summary, BOM Excel, escaping
│ │
│ └── locales/
│ └── id.js # 🇮🇩 Bahasa Indonesia translations
│
└── ssl/ (deleted — no longer needed since tunnel provides HTTPS)
Semua pengaturan dapat diubah via Settings Drawer (ikon gear di header).
| Pengaturan | Default | Deskripsi |
|---|---|---|
| Theme | dark |
Dark / Light theme |
| Mirror Camera | ✓ | Balik tampilan kamera horizontal |
| Show Overlay | ✓ | Tampilkan landmark mata & iris di video |
| Show Metrics | ✓ | Tampilkan panel metrik |
| Show Chart | ✓ | Tampilkan grafik timeline |
| Threshold | Default | Range | Deskripsi |
|---|---|---|---|
| EAR Fokus | 0.22 | 0.10–0.40 | Minimal EAR untuk fokus (proportional score) |
| EAR Mengantuk | 0.175 | 0.08–0.30 | Maksimal EAR sebelum dianggap mengantuk |
| Rasio Pandangan | 0.12 | 0.02–0.30 | Toleransi arah pandang ke tengah |
| Durasi Kedip Max | 0.40s | 0.15–0.80 | Maks durasi kedipan normal (state machine) |
| Durasi Ngantuk Min | 0.70s | 0.30–2.00 | Minimal durasi tutup mata untuk drowsy |
| Fixation Masuk | 0.08 | 0.02–0.20 | Gaze velocity threshold untuk masuk fixation |
| Fixation Keluar | 0.18 | 0.08–0.35 | Gaze velocity threshold untuk keluar fixation (hysteresis) |
| Saccade Ambang | 0.20 | 0.08–0.50 | Peak velocity threshold untuk saccade |
| Head Turn Ambang | 0.30 | 0.05–0.60 | Toleransi geleng kepala (face asymmetry) |
| Pandangan Samping | 0.35 | 0.10–0.60 | Ambang X untuk 'tidak lihat layar' |
| Pandangan Bawah | 0.25 | 0.08–0.50 | Ambang Y untuk 'tidak lihat layar' |
| Pengaturan | Default | Deskripsi |
|---|---|---|
| Max History Points | 300 | Jumlah data di grafik timeline |
| Emit Rate | 15 Hz | Frekuensi update data per detik |
Semua komponen focus score bersifat proportional (tidak binary). Detail formula:
| Parameter | Default | Formula | Maks |
|---|---|---|---|
scoreEar |
10 | ((ear-0.15)/0.20)*10 (linear 0.15→0, 0.35→10) |
10 |
scoreGaze |
20 | 20*(1-(gazeMag-0.05)/0.20) (deadband 0.05, linear ke 0 di 0.25) |
20 |
scoreFixation |
25 | 25*max(0,1-gazeVel/0.25) (kecepatan rendah = confidence tinggi) |
25 |
scoreSaccadeLow |
15 | 15 jika count<20, 15*(1-(count-20)/80) jika 20-100, 0 jika >100 |
15 |
scoreScreen |
15 | screen_score * 15 (continuous dari 0-1) |
15 |
scoreBlinkPenalty |
-5 | min(15, blinkCount*0.33) (smooth, max -15) |
0 s.d. -15 |
| Base | 15 | Selalu dapat selama wajah terdeteksi | 15 |
| Total Max | — | — | 100 |
Penyebab: Backend (uvicorn) tidak berjalan.
Solusi:
- Pastikan backend sudah start: buka
http://localhost:8765/api/health - Jalankan
start.batatau manual:cd backend && python -m uvicorn app:app --host 0.0.0.0 --port 8765 --reload - Cek port 8765 tidak conflict:
netstat -ano | findstr :8765 - Pastikan
uvicornterinstall:pip install uvicorn[standard]
Penjelasan: Vite di vite.config.js punya proxy:
"/ws": { target: "ws://127.0.0.1:8765", ws: true }Setiap kali frontend mencoba konek WebSocket ke backend tapi backend mati, Vite log error ini.
Penyebab: WebSocket tidak terhubung ke backend.
Solusi:
- Pastikan backend berjalan (cek
/api/health) - Refresh halaman — WebSocket auto-reconnect setiap 3 detik
- Jika dari HP: pastikan pakai tunnel URL (
https://xxx.trycloudflare.com)
Penyebab: Browser tidak mendapat izin kamera.
Solusi:
- Klik "Izinkan Kamera" di prompt browser
- Di iOS: Settings > Safari > Camera > Allow
- Pastikan halaman diakses via HTTPS atau localhost (secure context)
Penyebab: Kamera sedang dipakai aplikasi lain.
Solusi: Tutup aplikasi kamera lain (Zoom, Discord, OBS, dll).
Penyebab: Self-signed SSL cert tidak dikenal browser mobile.
Solusi: Gunakan Cloudflare Tunnel (wrangler tunnel quick-start) yang memberikan HTTPS cert valid.
cd frontend
npm run build # Pastikan tanpa errorJika error terkait Vite versi, coba:
npm install vite@6Hak cipta © 2026. Dibuat untuk keperluan penelitian dan pengembangan.
Dibuat menggunakan MediaPipe, Vue 3, dan FastAPI.