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:
- .NET Framework (recommended version: 8.0.100)
- .NET Wrapper for OpenCV
To build the demo project in VisualStudio:
- Create an empty C# console application
- Add the sample source files to the project
- 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:
- Create a database that will be used for face search (See p.1 of C++ Video Recognition Demo).
- Windows
- Linux
- To run the sample, go to the bin/csharp_demo/video_recognition_demo folder and double-click the
run.bat
file
- To run the application on Linux, go to the bin/csharp_demos/video_recognition_demo directory and run the
run.sh
command <path_to_opencv_csharp>, where
<path_to_opencv_csharp>` is the path to the directory with the OpenCvSharp library.
Расположение C# video_recognition_demo
- 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 directorylicense_dir
– path to the license directory (specify if you need to change the defaultlicense
directory)database_dir
– path to the face database directorymethod_config
– name of the configuration file recognizerrecognition_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
- Windows
- Linux
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
Add the path to the directory containing libfacerec.so
and the path to the directory with the OpenCVSharp library compiled for Linux to the LD_LIBRARY_PATH
environment variable.
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}: ../../../lib:~/opencv/lib/x86_64-linux-gnu dotnet publish/csharp_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)