Face tracking and face estimation
The bin directory contains the executable file demo:
The following dependencies are required to build and run C# demos:
- .NET Core Platform (recommended version: 8.0.100)
- .NET Wrapper for OpenCV (recommended version: 4.8.0)
- Manual build of OpenCvSharp for Linux is required.
To build the demo project in VisualStudio, follow the instructions below:
- Create an empty C# console application.
- Add the source files of the demo to the project.
- Add links to
FacerecCSharpWrapper.dll
and OpenCvSharp4.
demo
The sample demonstrates tracking, detection and cropping of faces, detection of anthropometric points and angles, as well as estimation of face quality, age and gender, emotions, and liveness (by processing an RGB image from your camera).
- Windows
- Linux
To make a quick run of the demo with default parameters on Windows, go to the bin/csharp_demo/demo folder and double-left-click run.bat
.
Location of C# demo
Tracking results and information about each face are displayed in a window. The upper left corner shows Face SDK components, which you can turn on and off by left mouse click. This sample is similar to C++ demo. See the detailed description of the components in C++ demo.
- Windows
- Linux
To run the application, go to the bin/csharp_demos/video_recognition_demo directory and execute
run.bat <path_to_opencv_csharp>
run.sh <path_to_opencv_csharp>
where <path_to_opencv_csharp>
is the path to the directory with the OpenCvCsharp library.
You can also run C# demo, specifying some parameters (for example, the path to your online license).
To build the demo, run the following commands:
cd examples/csharp_demos/demo
dotnet publish -o publish
Startup parameters:
[--config_dir=<config_dir>] [--license_dir=<license_dir>] [--capturer_config=<capturer_config>]
Where:
config_dir
– Path to the conf/facerec directory.capturer_conf
– Path to theCapturer
config file (learn more about Capturer config files.license_dir
– Path to the directory with a license; provide this parameter if you need to change a default directory license.
- Windows
- Linux
Add the path to the directory that includes facerec.dll
to the PATH
environment variable.
set PATH=%PATH%; ..\...\..\bin
dotnet publish\csharp_demo.dll --config_dir=../../../conf/facerec --capturer_config=common_capturer_ssyv_fda_v2.xml
Add the path to the directory that includes libfacerec.so
, and path to the directory with the OpenCVSharp library built for Linux to the LD_LIBRARY_PATH
environment variable.
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../../lib:/path/to/opencvsharp/native/libs dotnet publish/csharp_demo.dll --config_dir=../../../conf/facerec --capturer_config=common_capturer_ssyv_fda_v2.xml
Error messages (if any) are printed in the console.
Source code: examples/csharp/demo