LogoVisionLog

Face Recognition

Real-time face recognition from camera, images, and video

The recognition system processes input from cameras, images, or videos to identify enrolled persons in real-time.

Input Modes

ModeDescription
CameraReal-time recognition from webcam
ImageSingle image analysis
VideoVideo file processing

Camera Mode

Real-time recognition from webcam with live display.

Keyboard Controls

KeyAction
ESC / QQuit
SSave screenshot
RReload face database
TToggle confidence display

Display Information

The live view shows:

  • Green boxes around recognized faces
  • Red boxes around unknown faces
  • Person name and confidence score
  • FPS counter (30-frame average)

Image Mode

Analyze a single image for faces.

Output includes:

  • Number of faces detected
  • Person name for each recognized face
  • Confidence score for each match

Video Mode

Process video files for face recognition.

Controls during playback:

KeyAction
ESC / QStop processing
SPACEPause/Resume

Recognition Parameters

Similarity Threshold

Adjust the matching threshold to balance precision and recall.

ThresholdUse Case
0.35Maximum recall, more false positives
0.45Balanced (default)
0.55High precision, may miss some
0.65Very strict, minimal false positives

GPU Acceleration

Enable CUDA for faster processing.

Requirements:

  • NVIDIA GPU with CUDA support
  • onnxruntime-gpu installed

Technical Workflow Diagram

The following diagram illustrates the complete logic for identifying a person's face within the application:

Face Recognition Logic

1. Frame Capture

Video frames are captured from the source (camera, image, or video file).

2. Face Detection

InsightFace SCRFD detects all faces. Each face includes:

  • Bounding box coordinates
  • Detection confidence
  • 512-d embedding vector

3. Embedding Comparison

Each detected face is compared against the enrolled database using cosine similarity.

4. Threshold Check

If the similarity score meets the threshold, the face is identified; otherwise marked as unknown.

Performance Optimization

Frame Rate

Default camera settings:

  • Resolution: 1280x720
  • FPS: 30

For faster processing on slower hardware:

  • Reduce resolution
  • Skip frames using video processor

Detection Size

The model uses 640x640 input size. Larger images are automatically resized internally.

Headless Mode

Run without GUI for server deployments. Output is printed to console only.

Database Reload

If you enroll new faces while recognition is running:

  1. Press R to reload the database
  2. New persons will be recognized immediately

Or restart to load updated embeddings.

Result Data

Each recognition result contains:

FieldDescription
NamePerson name or "Unknown"
ConfidenceSimilarity score (0-1)
Bounding BoxFace location coordinates
Is KnownWhether face was matched

Visualization

Bounding Box Colors

StatusColor
Known personGreen
UnknownRed

Label Format

Shows name and confidence score when enabled.

Troubleshooting

No faces detected

  • Ensure adequate lighting
  • Face should be at least 50 pixels
  • Verify camera is working properly

Low confidence scores

  • Re-enroll with more/better images
  • Check lighting conditions match enrollment
  • Try lowering threshold slightly

Slow performance

  • Enable GPU if available
  • Reduce camera resolution
  • Check CPU usage for other processes

Wrong identifications

  • Increase threshold (e.g., 0.55)
  • Re-enroll with diverse angles/lighting
  • Ensure enrollment images are high quality

On this page