Skip to main content
Version: 3.24.0 (latest)

Face identification/verification on camera video stream

The bin/csharp_demo/video_recognition_demo directory contains the video_recognition_demo executables:

The following dependencies are required to build and run the C# samples:

To build the demo project in VisualStudio:

  1. Create an empty C# console application
  2. Add the sample source files to the project
  3. Add references to the FacerecCSharpWrapper.dll library and OpenCvSharp4

video_recognition_demo

The program demonstrates tracking, detection and identification/verification of faces from a database on a video stream from a camera.

Note: if you are using a RealSense sensor, we recommend that you use the video_recognition_demo_realsense sample. In this sample, the DepthLivenessEstimator object is used via the RealSense SDK. For more information on determining whether a face belongs to a real person using a depth map, see DepthLivenessEstimator Class.

To quickly run the sample with default parameters and test face recognition on Windows:

  1. Create a database that will be used for face search (See p.1 of C++ Video Recognition Demo).
  1. To run the sample, go to the bin/csharp_demo/video_recognition_demo folder and double-click the run.bat file

Расположение C# video_recognition_demo

  1. Tracking and identification results are displayed in windows (one for each source). Found faces are highlighted with a green circle. The upper right part of the window displays the recognition results: on the left is the found face in the video, on the right is the face from the database and the name.

You can also run the C# video_recognition_demo sample by specifying certain parameters.

To build the sample, run the following commands:

cd examples/csharp_demos/video_recognition_demo
dotnet publish -o publish

To run the sample, specify the path to the csharp_video_recognition_demo.dll library, launch parameters (optional) and the video source:

dotnet csharp_video_recognition_demo.dll [OPTIONS] <video_source>...

Launch examples:

  • Webcam: dotnet csharp_video_recognition_demo.dll –config_dir ../../../conf/facerec 0
  • RTSP stream: dotnet csharp_video_recognition_demo.dll –config_dir ../../../conf/facerec rtsp://localhost:8554/

Launch parameters:

[--config_dir=<config_dir>] [--license_dir=<license_dir>] [--database_dir=<database_dir>] [--method_config=<method_config>] [--recognition_far_threshold=<recognition_distance_threshold>] [--frame_fps_limit=<frame_fps_limit>] (<camera_id> | <rtsp_url>)...

Where:

  • config_dir – path to the conf/facerec directory
  • license_dir – path to the license directory (specify if you need to change the default license directory)
  • database_dir – path to the face database directory
  • method_config – name of the configuration file recognizer
  • recognition_far_threshold – recognition threshold (real number)
  • camera_id | rtsp_url – one or more sources, each source is a number (webcam number) or a string (video stream URL or path to video file)
  • frame_fps_limit – FPS limit

Add the path to the directory containing facerec.dll to the PATH environment variable.

set PATH=%PATH%;..\...\..\bin
dotnet publish/csharp_video_recognition_demo.dll --config_dir=../../../conf/facerec --database_dir=../../../bin/base --method_config=method6v7_recognizer.xml --recognition_far_threshold=7000 --frame_fps_limit=25 0

The console displays the database loading status and error messages if any occur.

Source code: examples/csharp/video_recognition_demo [examples/csharp/video_recognition_demo_realsense](https://github.com/3DiVi/face-sdk/tree/master/examples/csharp/video _recognition_demo_realsense)