Employee time tracking system using facial recognition. Look at the camera for 2 seconds to automatically clock in/out.
- Face recognition identifies employees automatically
- Auto clock in/out - no buttons to press
- Liveness detection prevents photo spoofing
- Time tracking calculates work hours
- Web interface for management and reports
- Python 3.8+
- Webcam
- Modern browser (Chrome recommended)
-
Clone repository
git clone https://github.com/yourusername/securetime-pro.git cd securetime-pro -
Install dependencies
pip install -r requirements.txt
-
Run application
python face_recognition_webui.py
-
Open browser
http://localhost:5000
- Go to "Add Employee"
- Enter name
- Take photos from different angles (front, left, right)
- System trains recognition model
- Go to "Time Clock"
- Click "Start Camera"
- Look at camera for 2 seconds
- System automatically:
- Clocks you IN if you're not working
- Clocks you OUT if you're currently working
- Camera stops automatically
- Go to "Reports"
- Select date range
- Generate time reports
- Uses
dlibandface_recognitionlibraries - Adaptive learning improves accuracy over time
- Confidence threshold prevents false matches
- Detects real faces vs photos
- Analyzes face movement and quality
- Prevents spoofing with printed photos
- SQLite stores employee data and time records
- Each work session = one record with clock_in/clock_out times
- Automatic hours calculation
Current Status → Action
Not clocked in → Clock IN
Clocked in → Clock OUT
Previously clocked out → Clock IN (new session)
SecureTime-Pro/
├── face_recognition_webui.py # Main Flask application
├── maml_face_recognition.py # Face recognition engine
├── anti_spoofing_system.py # Liveness detection
├── improved_few_shot.py # Learning algorithms
├── face_recognition_system.py # Base recognition system
├── templates/ # HTML templates
│ ├── base.html # Main layout
│ ├── timeclock.html # Time clock interface
│ ├── index.html # Dashboard
│ ├── employees.html # Employee list
│ ├── add_employee.html # Add new employee
│ └── reports.html # Time reports
├── requirements.txt # Python dependencies
└── README.md # This file
Edit these values in face_recognition_webui.py:
RECOGNITION_THRESHOLD = 0.6 # Minimum confidence to recognize (60%)
CLOCK_ACTION_THRESHOLD = 60 # Minimum confidence to clock in/out (60%)
AUTO_CLOCK_DELAY = 2 # Seconds to hold steady (2 seconds)GET /api/status- System statusGET /api/employees- List employeesGET /api/time_records- Get time recordsDELETE /api/delete_employee/<name>- Remove employee
start_session- Start cameravideo_frame- Process video frameauto_clock_result- Clock action result
Camera not working:
- Check browser permissions
- Close other apps using camera
- Try different browser
Recognition not accurate:
- Add more training photos
- Ensure good lighting
- Check camera focus
Database errors:
- Check file permissions
- Restart application
Add debug routes to see employee status:
@app.route('/api/debug/<employee_name>')
def debug_employee(employee_name):
# Shows current status and all recordsemployees table:
id,name,department,created_at
time_records table:
id,employee_name,clock_in,clock_out,hours_worked,date,confidence
- Employee photos stored locally only
- Database contains sensitive time data
- Use proper access controls in production
- Consider encryption for sensitive environments
- Backend: Flask, Flask-SocketIO
- Face Recognition: dlib, face_recognition, OpenCV
- Database: SQLite
- Frontend: HTML5, JavaScript, WebSocket
- ML: scikit-learn, numpy