Face & Mask Detection
The Face & Mask Detection action provides two related capabilities: detecting human faces in video streams and checking for compliance with safety gear requirements (masks, headwear).
Overview
This action is essential for:
- Security applications requiring face detection
- Health and safety compliance (mask wearing)
- PPE (Personal Protective Equipment) verification in work environments
The action includes two separate functions that can be used independently or together in a workflow.
Feature 1: Face Detection
What It Does
The Face Detection function scans video frames to locate human faces. It's optimized for:
- Multiple faces in a single frame
- Various face orientations (though frontal faces work best)
- Different lighting conditions
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
| Streams | Table Selection | Required | Camera(s) to analyze |
| Confidence Threshold | Number (0-1) | 0.5 | Minimum confidence required to report a face |
| Max Runtime Seconds | Number | 60 | How long to search before giving up |
Results
| Result | Meaning |
|---|---|
| face_detected | At least one face was found in the video stream |
| no_face_detected | No faces were found during the entire runtime |
Use Cases
- Access Control: Detect when someone approaches a door
- Attention Detection: Verify someone is present at a station
- Pre-processing: Capture face images for further analysis
Feature 2: Head/Work Clothes Detection
What It Does
The Head/Work Clothes Detection function analyzes a previously captured image to check for specific headwear or masks. This includes:
- Medical/surgical masks
- N95 respirators
- Hard hats
- Hair nets
- Other head-mounted PPE
Important Prerequisite
This function must run after a detection action that captures an image. It cannot analyze live video directly—it needs an image from a previous action in the workflow (such as Face Detection or Object Detection).
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
| Confidence Threshold | Number (0-1) | 0.5 | Minimum confidence required to report detection |
Results
| Result | Meaning |
|---|---|
| head work clothes detected | Mask or headwear was found in the image |
| no head work clothes detected | No mask or headwear was detected |
Typical Workflow
A complete PPE compliance workflow might look like this:
- Object Detection: Detect a person entering the work area
- Face Detection: Confirm a face is visible (person facing camera)
- Mask Detection: Check if the person is wearing required PPE
- Decision Branch:
- If mask detected → Log compliance and end
- If no mask → Create Violation and alert supervisor
Common Use Cases
Health Compliance (Medical/Food Service)
- Scenario: Ensure staff wear masks in food preparation areas
- Setup: Camera at kitchen entrance, face detection zone
- Workflow: Detect person → Check for mask → Alert if non-compliant
Construction Safety
- Scenario: Verify hard hat usage on construction sites
- Setup: Camera at site entry point
- Workflow: Detect person → Check for hard hat → Log or alert
Cleanroom Compliance
- Scenario: Ensure proper head covering in controlled environments
- Setup: Camera at cleanroom entrance
- Workflow: Detect person → Check for hair net/cap → Grant or deny access alert
Troubleshooting
Low Detection Accuracy
-
Lighting Issues: Ensure faces are well-lit from the front. Backlighting (bright light behind the person) severely impacts accuracy.
-
Camera Angle: Face detection works best when faces are relatively frontal. Extreme angles (top-down or side views) reduce accuracy.
-
Distance: Faces that are too small in the frame (person far from camera) may not be detected. Adjust camera zoom or position.
-
Obstructions: Sunglasses, large hats, or hair covering the face can interfere with detection.
Mask Detection Not Working
-
Check Workflow Order: Mask detection requires a previous action that provides an image. Ensure Face Detection or Object Detection runs first.
-
Image Quality: Blurry or low-resolution images make mask detection difficult.
-
Mask Types: The system is trained on common mask styles. Unusual designs may not be recognized.
-
Partial Visibility: If the mask is only partially visible (person turning away), detection may fail.
Model Loading Errors
-
Check Model Files: Verify that the required model files are present on the server:
face_detection.ptfor face detectionmask_detection_model.h5for mask detection
-
Memory Issues: Large AI models require sufficient RAM. Check server memory availability.
-
File Permissions: Ensure the ResEngine process has read access to model files.
Too Many False Positives
-
Increase Confidence Threshold: Raise the threshold to 0.6 or 0.7 to be more selective.
-
Improve Lighting: Inconsistent lighting can cause shadows that resemble faces.
-
Check for Face-Like Patterns: Posters, photos, or patterns that resemble faces can trigger false detections. Adjust zones to exclude these areas.
Missing Detections
-
Lower Confidence Threshold: Try reducing to 0.3 or 0.4 to catch more detections.
-
Increase Runtime: Allow more time for detection by increasing Max Runtime Seconds.
-
Check Camera Coverage: Ensure people are facing the camera when they enter the detection zone.
Best Practices
-
Camera Placement: Position cameras at face height (approximately 1.5-1.8 meters) for optimal face capture.
-
Consistent Lighting: Use even, front-facing lighting. Avoid backlighting and harsh shadows.
-
Clear Signage: Inform people that face/mask detection is in use for transparency and compliance.
-
Regular Testing: Periodically verify the system is detecting correctly, especially after camera adjustments or lighting changes.
-
Combine with Object Detection: For better reliability, use Object Detection to first confirm a person is present, then run Face Detection on the cropped person image.