Hygiene patterns for any OpenCV + dlib vision pipeline: camera index probing + macOS init quirks, warmup that verifies real frames, frame-skip policy for expensive inference.
96
93%
Does it follow best practices?
Impact
100%
1.36xAverage score across 6 eval scenarios
Passed
No known issues
A HR-tech startup is building a real-time kiosk that monitors a meeting room and tracks two things continuously: who is present (face recognition against a known-employee database) and the general emotional tone of the room (emotion classification using a ViT model). The kiosk runs on an M-series MacBook with a 30 fps USB webcam.
Early prototypes ran face recognition and emotion classification on every frame. The camera loop dropped to under 5 fps and the UI became unresponsive. The team needs a redesigned capture loop that keeps the camera reading at full rate while running the two expensive inference steps at sensible, lower frequencies. The emotion model is notably slower than the face encoder.
You do not need to implement actual face recognition or emotion models — stub them with functions that sleep to simulate realistic inference latency. Document the chosen inference frequencies as named constants at the top of the script.
Produce a single Python script attendance_monitor.py that:
monitor_summary.json.The script must be runnable with python attendance_monitor.py (no real camera required — use cv2.VideoCapture(0) and handle the case where it cannot be opened by using a synthetic black frame of shape 480×640×3).