A Python-based attendance tracking system that uses facial recognition to automatically register student attendance. The system operates in both online and offline modes, with local SQLite storage and cloud PostgreSQL synchronization.
flowchart TB
subgraph Camera["Camera Capture"]
FRP[Face Recognition Processor]
end
subgraph Local["Local Processing"]
SQLite[(SQLite DB)]
FRP --> |Attendance Record| SQLite
end
subgraph Cloud["Cloud Services"]
AWS[AWS Rekognition]
PG[(PostgreSQL DB)]
API[External API Service]
end
subgraph Sync["Sync Service"]
SS[Sync Manager]
end
FRP --> |Face Comparison| AWS
AWS --> |Match Results| FRP
SQLite --> |Pending Records| SS
SS --> |Sync Status| SQLite
SS --> |Validate Attendance| API
API --> |Attendance Status| SS
SS --> |Synced Records| PG
PG --> |Student Data| SQLite
- Face Recognition Service: Uses AWS Rekognition for facial comparison
- Local Database (SQLite): Stores attendance records and student data for offline operation
- Cloud Database (PostgreSQL): Central database for attendance records
- External API Integration: Validates and processes attendance records
- Sync Service: Manages data synchronization between local and cloud storage
- Real-time face recognition using webcam
- Offline functionality with local storage
- Automatic synchronization when internet connection is available
- Duplicate attendance prevention
- Comprehensive logging and error handling
- Configurable settings via environment variables
- Students: Stores student information and face encodings
- Attendance Records: Tracks attendance with timestamps and confidence scores
- Sync Logs: Monitors synchronization status and errors
- Devices: Manages multiple capture devices
- Captures frames from webcam
- Compares captured faces with stored face encodings using AWS Rekognition
- Records attendance when match confidence exceeds threshold
- Prevents duplicate entries within configurable time window
- Stores attendance records locally in SQLite
- Periodically checks for internet connectivity
- Syncs pending records to PostgreSQL when online
- Validates attendance through external API
- Updates sync status and logs
POSTGRES_DB=attendance_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changeme
POSTGRES_HOST=localhost
POSTGRES_PORT=5435
EXTERNAL_API_URL=http://localhost:8001/api
EXTERNAL_API_KEY=your-api-key
AWS_ACCESS_KEY_ID=your-aws-key
AWS_SECRET_ACCESS_KEY=your-aws-secret
AWS_REGION=your-aws-region
DEVICE_ID=DEVICE_001
CAMERA_INDEX=0
FACE_RECOGNITION_THRESHOLD
: Minimum confidence score (default: 95%)MINUTES_BEFORE_NEXT_CAPTURE
: Duplicate prevention window (default: 10 minutes)STUDENT_SYNC_INTERVAL
: Student data sync frequency (default: 60 minutes)ATTENDANCE_SYNC_INTERVAL
: Attendance sync frequency (default: 5 minutes)CLEANUP_DAYS
: Data retention period (default: 30 days)
- Install required dependencies:
pip install opencv-python boto3 psycopg2-binary python-dotenv
-
Set up databases:
- Configure PostgreSQL connection in environment variables
- SQLite database will be created automatically
-
Configure AWS Rekognition:
- Set up AWS credentials in environment variables
- Create a faces directory for storing reference images
-
Run the system:
from attendance_system import FaceRecognitionProcessor
from attendance_system.database import SQLiteManager
processor = FaceRecognitionProcessor(device_id="DEVICE_001")
processor.start_camera()
processor.run_recognition(callback=sqlite_manager.save_attendance)
- Comprehensive error logging for:
- Database operations
- Face recognition process
- API communications
- Synchronization failures
- Logs stored in 'attendance_system.log'
- Secure AWS authentication
- API key authentication for external services
- SSL support for PostgreSQL connections
- Face recognition quality filtering
- Soft delete support for student records
This project was built for the discipline of Software Design for the bachelors in Software Engineering at the Federal University of Goias (UFG).