- Ringkasan Proyek
- Arsitektur Sistem
- Komponen Utama
- Instalasi dan Setup
- Penggunaan
- API Documentation
- Konfigurasi
- Troubleshooting
- Teknologi yang Digunakan
Sistem Deteksi Crowd Fatigue adalah aplikasi web real-time yang menggunakan teknologi AI untuk mendeteksi:
- Crowd Detection: Deteksi kepadatan crowds di area tertentu
- Fatigue Detection: Deteksi tingkat kelelahan pada individu
- Face Recognition: Pengenalan wajah untuk identifikasi pengguna
Sistem ini menggunakan arsitektur microservices dengan komunikasi real-time melalui MQTT dan Socket.IO.
- 🔍 Deteksi real-time crowd dan fatigue
- 👤 Sistem autentikasi dan autorisasi
- 📊 Dashboard monitoring
- 🏢 Manajemen area dan kapasitas
- 📱 Interface web responsif
- 🔄 Komunikasi real-time
- Frontend Application: React 18 dengan TypeScript dan Chakra UI
- HTTP Client: Axios untuk REST API calls (authentication, CRUD operations)
- Real-time Client: Socket.IO client untuk bidirectional communication dengan backend
- Dashboard Monitoring: Visualisasi data real-time crowd dan fatigue
- User Management: Interface untuk registrasi, login, dan profil management
- Backend Server: Node.js/Express.js dengan Socket.IO server
- REST Endpoints: API routes untuk CRUD operations (users, areas, crowds, fatigues)
- Authentication Service: JWT tokens dengan bcrypt password hashing
- Business Logic: Controllers untuk crowd detection, fatigue detection, dan user management
- Real-time Handler: Socket.IO event handlers untuk real-time communication dengan frontend
- Database ORM: Prisma sebagai database abstraction layer
- File Upload: Multer untuk handling face image uploads
- AI Engine: Python Flask microservice dengan YOLOv11, OpenVINO optimization
- Face Detection: SCRFD untuk deteksi wajah real-time
- Face Recognition: ArcFace untuk identifikasi pengguna
- Crowd Detection: YOLOv11 dengan optimasi OpenVINO untuk deteksi kepadatan
- Fatigue Detection: Model AI khusus untuk deteksi tingkat kelelahan
- Object Tracking: ByteTracker untuk tracking objek bergerak
- Primary Database: PostgreSQL 16 dengan Prisma ORM
- User Data: Profile, credentials, dan security answers
- Area Management: Data area monitoring dengan kapasitas
- Detection Results: Historical data crowd dan fatigue detection
- Face Features: Encoded face features untuk recognition
- Message Broker: MQTT (HiveMQ/cloud atau local broker)
- Real-time Messaging: Publish/subscribe pattern untuk frame dan results
- WebSocket: Socket.IO untuk real-time UI updates
Frontend (Axios/REST) → Backend API → JWT Verification → PostgreSQL → JSON Response
Camera Stream → Frontend → Socket.IO → Backend → MQTT → AI Engine →
Processing Results → MQTT → Backend → Socket.IO → Frontend → UI Update
Camera Stream → Frontend → Socket.IO → Backend → MQTT → AI Engine →
Face Recognition + Fatigue Analysis → MQTT → Backend → Socket.IO → Frontend → UI Update
AI Engine → MQTT → Backend → Socket.IO → Frontend → UI Update
- Frontend: React 18, TypeScript, Chakra UI, Socket.IO Client, Axios (HTTP client)
- Backend: Node.js, Express.js, Prisma, PostgreSQL, Socket.IO Server, MQTT Client, JWT
- AI Engine: Python 3.9, Flask, PyTorch, OpenVINO, YOLOv11, OpenCV, MQTT Client
- Communication:
- REST APIs: Axios/Express untuk CRUD operations (login, register, data management)
- Socket.IO: Bidirectional real-time communication (AI processing results)
- MQTT: Publish/subscribe pattern untuk inter-service communication
- Database: PostgreSQL 16, Prisma ORM
- Process Management: PM2 untuk production deployment
Microservice Python yang menangani semua proses AI:
- YOLOv11: Untuk deteksi objek (crowd dan fatigue)
- OpenVINO: Optimasi model untuk inferensi yang lebih cepat
- SCRFD: Face detection
- ArcFace: Face recognition
- ByteTracker: Object tracking
crowd_detector.py: Deteksi kepadatan crowdsfatigue_detector.py: Deteksi tingkat kelelahanface_recognition/: Sistem pengenalan wajahface_tracking/: Pelacakan objek bergerak
API server Node.js yang mengatur:
AuthController.js: Autentikasi dan autorisasiUserController.js: Manajemen userAreaController.js: Manajemen areaCrowdController.js: Data crowd detectionFatigueController.js: Data fatigue detection
UserModel.js: Model userAreaModel.js: Model areaCrowdModel.js: Model data crowdFatigueModel.js: Model data fatigue
authenticateJWT.js: Middleware autentikasi JWTcheckAdmin.js: Middleware check role adminuploadPhotosMiddleware.js: Middleware upload foto
Aplikasi web React dengan fitur:
- Dashboard monitoring
- Crowd Detection interface
- Fatigue Detection interface
- User management (admin only)
- Profile management
useAuth.ts: Hook untuk autentikasiuseUser.ts: Hook untuk data useruseArea.ts: Hook untuk data areauseCrowd.ts: Hook untuk data crowduseFatigue.ts: Hook untuk data fatigue
- Node.js = v24.11.1
- Python = v3.9.25
- PostgreSQL = v16.3
- Anaconda/Miniconda (untuk environment Python)
git clone --recurse-submodules Crowd-Fatigue_detection_web_full
-- Buat database PostgreSQL
CREATE DATABASE comvis;
-- Buat user (opsional)
CREATE USER postgres WITH PASSWORD '123456';
GRANT ALL PRIVILEGES ON DATABASE comvis TO postgres;# Masuk ke direktori ai-engine
cd ai-engine
# Buat environment conda
conda create -n cnfd python=3.9
conda activate cnfd
# Install dependencies
pip install -r requirements.txt# Masuk ke direktori backend
cd backend
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env sesuai konfigurasi Anda
# Generate Prisma client
npx prisma generate
# Jalankan migrasi database
npx prisma db push
# Buat admin user
npm run create-admin# Masuk ke direktori frontend
cd frontend
# Install dependencies
npm install
# Setup environment variables
cp .env.development .env
# Edit .env sesuai konfigurasi Anda# Method 1: Menggunakan PM2 (recommended)
pm2 start ecosystem.config.js
# Method 2: Manual (di terminal terpisah)
# Terminal 1 - Backend
cd backend && npm start
# Terminal 2 - AI Engine
cd ai-engine && python app.py
# Terminal 3 - Frontend
cd frontend && npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
- AI Service: http://localhost:5000/health
Gunakan credentials yang dibuat saat setup admin:
- Email: admin@example.com
- Password: admin123
- Buat area baru dengan kapasitas tertentu
- Camera real-time
- Sistem akan mendeteksi jumlah orang dan status kepadatan
- Data tersimpan otomatis ke database
- Buka halaman Fatigue Detection
- Sistem akan melakukan face recognition terlebih dahulu
- Jika wajah dikenal, akan lanjut ke deteksi fatigue
- Status fatigue akan muncul real-time
- Upload foto wajah saat registrasi
- Sistem akan mengenali wajah secara otomatis
- Hanya satu orang yang boleh terdeteksi untuk fatigue detection
Login user
{
"email": "user@example.com",
"password": "password123"
}Registrasi user baru
{
"email": "user@example.com",
"password": "password123",
"name": "John Doe",
"role": "user",
"security_answer": "answer"
}Get profile user yang sedang login
Update profile user
Get semua area
Create area baru
{
"name": "Area A",
"capacity": 100,
"user_id": "user_id"
}Update area
Delete area
Get semua data crowd
Save data crowd detection
Get data crowd untuk area tertentu
Get semua data fatigue
Save data fatigue detection
Get data fatigue untuk user tertentu
PORT=4000
JWT_SECRET=your_super_secret_jwt_key_here
DATABASE_URL=postgresql://postgres:123456@localhost:5432/comvis
MQTT_BROKER=mqtt://broker.hivemq.com:1883
MQTT_PORT=1883VITE_APP_API_URL=http://localhost:4000
VITE_APP_SOCKET_URL=ws://localhost:4000
VITE_APP_BACKEND_URL=http://localhost:4000AI Engine menggunakan konfigurasi dari:
face_tracking/config/config_tracking.yaml- Model weights di
face_detection/danface_recognition/
mqtt-crowd-frame: Frame untuk crowd detectionmqtt-fatigue-frame: Frame untuk fatigue detectionmqtt-face-frame: Frame untuk face recognition
mqtt-crowd-result: Hasil crowd detectionmqtt-fatigue-result: Hasil fatigue detectionmqtt-face-result: Hasil face recognition
Problem: Model tidak bisa diinisialisasi Solution:
- Pastikan semua dependencies terinstall
- Check Python environment (conda)
- Verify model weights tersedia
Problem: Tidak bisa connect ke PostgreSQL Solution:
- Pastikan PostgreSQL running
- Check DATABASE_URL di .env
- Verify user permissions
Problem: MQTT broker tidak bisa diakses Solution:
- Check MQTT_BROKER URL
- Pastikan internet connection untuk HiveMQ
- Try menggunakan local MQTT broker
Problem: React app tidak bisa di-build Solution:
- Clear node_modules:
rm -rf node_modules && npm install - Check Node.js version
- Verify environment variables
Problem: Face tidak terdeteksi Solution:
- Check kualitas gambar
- Pastikan wajah terlihat jelas
- Verify face features sudah di-training
- React 18: Framework UI
- TypeScript: Type safety
- Chakra UI: Component library
- Vite: Build tool
- Socket.IO Client: Real-time communication
- Axios: HTTP client
- React Hook Form: Form management
- Recharts: Data visualization
- Node.js: Runtime environment
- Express.js: Web framework
- Prisma: Database ORM
- PostgreSQL: Database
- Socket.IO: Real-time communication
- MQTT: Message broker client
- JWT: Authentication
- Bcrypt: Password hashing
- Multer: File upload
- CORS: Cross-origin resource sharing
- Python 3.9: Programming language
- Flask: Web framework
- PyTorch: Deep learning framework
- OpenVINO: Model optimization
- YOLOv11: Object detection
- SCRFD: Face detection
- ArcFace: Face recognition
- ByteTracker: Object tracking
- MQTT: Message broker
- OpenCV: Computer vision
- PM2: Process manager
- Anaconda: Python environment management
- Github: Version control
- ESLint: Code linting
Untuk berkontribusi pada proyek ini:
- Fork repository
- Buat feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
Proyek ini, pada fitur face recognition dan yang terkait menggunakan referensi source code yang dilisensikan di bawah MIT License - lihat file LICENSE.md untuk detail.
Untuk pertanyaan dan support, silakan hubungi tim pengembangan.
Dokumentasi ini dibuat pada: 2025-12-03 Versi: 1.0.0
