Layer 4: Attendance
Attendance logging with timestamp management
The Attendance Layer handles attendance logging with timestamps and duplicate prevention.
Overview
- Purpose: Log attendance records with proper timestamps
- Components: AttendanceTracker, PostgreSQL Logger
- Output: PostgreSQL attendance records
Timestamp Management
The system uses server/system time for consistent timestamp recording.
| Feature | Description |
|---|---|
| System Time | Use server time for reliable timestamps |
| UTC Storage | Store in UTC for consistency |
| Timezone Display | Convert to local timezone for display |
Attendance Logger
Data Structure
| Field | Type | Description |
|---|---|---|
| Person ID | UUID | Identified person |
| Timestamp | DateTime | Attendance time |
| Camera ID | String | Source camera |
| Confidence | Float | Recognition confidence (0-1) |
| Snapshot Path | String | Path to face snapshot (optional) |
Logger Functions
| Function | Description |
|---|---|
| Log Attendance | Create new attendance record in PostgreSQL |
| Check Duplicate | Query database for existing entry |
| Save Snapshot | Store face image for verification |
| Query Records | Retrieve attendance data from database |
Duplicate Prevention
The logger checks for existing entries before creating new records:
- Prevents multiple entries for the same person on the same day
- Returns null if duplicate detected
Snapshot Storage
Optional face snapshots can be saved for:
- Visual verification
- Audit trail
- Debugging recognition issues
Complete Pipeline
The attendance layer processes recognition results through these steps:
- Receive Recognition Result - Get matched person from recognition layer
- Get Timestamp - Record current system time
- Check Duplicates - Verify no existing entry
- Save Snapshot - Store face image if provided
- Create Record - Insert attendance entry into PostgreSQL
- Return Result - Confirm successful logging
Integration
The attendance layer receives input from the Recognition layer and outputs to the Storage layer:
| Input | Output |
|---|---|
| Recognition result (person ID, confidence) | Attendance record |
| Camera ID | Log entry |
| Face image (optional) | Snapshot file |
.png)