Skip to main content

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

ParameterTypeDefaultDescription
StreamsTable SelectionRequiredCamera(s) to analyze
Confidence ThresholdNumber (0-1)0.5Minimum confidence required to report a face
Max Runtime SecondsNumber60How long to search before giving up

Results

ResultMeaning
face_detectedAt least one face was found in the video stream
no_face_detectedNo 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

ParameterTypeDefaultDescription
Confidence ThresholdNumber (0-1)0.5Minimum confidence required to report detection

Results

ResultMeaning
head work clothes detectedMask or headwear was found in the image
no head work clothes detectedNo mask or headwear was detected

Typical Workflow

A complete PPE compliance workflow might look like this:

  1. Object Detection: Detect a person entering the work area
  2. Face Detection: Confirm a face is visible (person facing camera)
  3. Mask Detection: Check if the person is wearing required PPE
  4. 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

  1. Lighting Issues: Ensure faces are well-lit from the front. Backlighting (bright light behind the person) severely impacts accuracy.

  2. Camera Angle: Face detection works best when faces are relatively frontal. Extreme angles (top-down or side views) reduce accuracy.

  3. Distance: Faces that are too small in the frame (person far from camera) may not be detected. Adjust camera zoom or position.

  4. Obstructions: Sunglasses, large hats, or hair covering the face can interfere with detection.

Mask Detection Not Working

  1. Check Workflow Order: Mask detection requires a previous action that provides an image. Ensure Face Detection or Object Detection runs first.

  2. Image Quality: Blurry or low-resolution images make mask detection difficult.

  3. Mask Types: The system is trained on common mask styles. Unusual designs may not be recognized.

  4. Partial Visibility: If the mask is only partially visible (person turning away), detection may fail.

Model Loading Errors

  1. Check Model Files: Verify that the required model files are present on the server:

    • face_detection.pt for face detection
    • mask_detection_model.h5 for mask detection
  2. Memory Issues: Large AI models require sufficient RAM. Check server memory availability.

  3. File Permissions: Ensure the ResEngine process has read access to model files.

Too Many False Positives

  1. Increase Confidence Threshold: Raise the threshold to 0.6 or 0.7 to be more selective.

  2. Improve Lighting: Inconsistent lighting can cause shadows that resemble faces.

  3. Check for Face-Like Patterns: Posters, photos, or patterns that resemble faces can trigger false detections. Adjust zones to exclude these areas.

Missing Detections

  1. Lower Confidence Threshold: Try reducing to 0.3 or 0.4 to catch more detections.

  2. Increase Runtime: Allow more time for detection by increasing Max Runtime Seconds.

  3. Check Camera Coverage: Ensure people are facing the camera when they enter the detection zone.


Best Practices

  1. Camera Placement: Position cameras at face height (approximately 1.5-1.8 meters) for optimal face capture.

  2. Consistent Lighting: Use even, front-facing lighting. Avoid backlighting and harsh shadows.

  3. Clear Signage: Inform people that face/mask detection is in use for transparency and compliance.

  4. Regular Testing: Periodically verify the system is detecting correctly, especially after camera adjustments or lighting changes.

  5. 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.