Yoti.FCM 0.1.0-beta2

This is a prerelease version of Yoti.FCM.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Yoti.FCM --version 0.1.0-beta2
NuGet\Install-Package Yoti.FCM -Version 0.1.0-beta2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yoti.FCM" Version="0.1.0-beta2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Yoti.FCM --version 0.1.0-beta2
#r "nuget: Yoti.FCM, 0.1.0-beta2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Yoti.FCM as a Cake Addin
#addin nuget:?package=Yoti.FCM&version=0.1.0-beta2&prerelease

// Install Yoti.FCM as a Cake Tool
#tool nuget:?package=Yoti.FCM&version=0.1.0-beta2&prerelease

Yoti Face Capture

Face capture user control handles the camera and validates the video stream frame by frame until it finds a valid face.


The package uses C++ libraries so the machines that run the face capture will need to install the Microsoft Visual C++ Redistributable packages.


  1. Add the package dependency in your project.

  2. Add the reference xmlns:yotiFCM="clr-namespace:Yoti.FCM;assembly=Yoti.FCM" in the view that will integrate the user control.

  3. Render the user control:

    <yotiFCM:FaceCapture FaceDetected="<FaceCapture_FaceDetectedHandler>" />

It does not send the image to the Yoti AI service. The FaceDetected event will provide the base64 encoded image ready to be processed by the service. Use the .NET Yoti SDK or any other Yoti SDK (if the image is propagated to a back-end) to send the image and run a prediction.

This is the properties list for the FaceCapture:

Property name Type Default value Range Description
FaceDetected EventHandler<FacesDetectedEventArgs> null Event that the face capture will trigger each time it detects a face.
OnError EventHandler<ExceptionEventArgs> null Event to handle all inner exceptions from the face capture.
ReadyToCapture EventHandler null Event to handle when the camera is ready to start the streaming and capture a face.
ProbabilityThreshold FaceConfidenceThreshold FaceConfidenceThreshold.Medium Face probability score threshold used to detect faces.
CroppingRelativeMargin float 0.5F 0.2 - 1.0 Relative margin applied to crop around the detected face.
GrayScaleThreshold float 23.0F 20.0 - 30.0 Image grayscale threshold.
MultiFaceAreaThreshold int 200 180 - 250 Minimum face area size to check for multiple faces.
FaceOverlapingThreshold float 0.3F 0.2 - 0.35 Threshold to check if there is another face in the result face area.
LowBrightnessThreshold float 50.0F 40 - 60 Lowest brightness level allowed.
HighBrightnessThreshold float 200.0F 180 - 210 Highest brightness level allowed.
MinMainFaceArea int 20000 10000 - 60000 Minimum main face size in pixels.
MinRelativeAreaAroundFace float 0.3F 0.25 - 0.4 Minimum distance from the image edges relative to the face. It is measured as a percentage of the face size.
MinFaceRelativeSize float 0.005F 0.0025 - 0.05 Minimum size for the main face relative to the frame.
MaxFaceRelativeSize float 0.25F 0.1 - 0.6 Maximum size for the main face relative to the frame.
OutputFormat ImageFormat ImageFormat.JPEG Format to encode the output Image (JPEG, PNG).
OutputQuality ImageQuality ImageQuality.High JPEG compression quality (High, Medium, Low).
NumberStableFrames int 4 1 - 12 NumberStableFrames is the consecutive valid frames of a face needed to consider it valid.
StabilityConfidenceThreshold float 0.9F 0.8 - 0.95 StabilityConfidenceThreshold is the required stability score for each frame with the previous.
Crop bool true If the final image result will be a cropped version of the webcam frame where the focus will be on the main face.
Debug bool false If the face capture will render the face debug information.
FaceDetectionTickerInterval int 160 100 - 500 The interval that the face capture will use to detect a face in the webcam frame.
WebcamIndex int? 0 The webcam index that the face capture will use to get the stream frames.
WebcamStartTimeout int? 5000 1000 - 30000 Webcam timeout in milliseconds to detect if the webcam stream has started or not.

Note: FaceCapture implements the interface IFaceCapture:

/// <summary>
/// Represents an entity that is able to detect a face from a stream like a webcam.
/// </summary>
public interface IFaceCapture
    /// <summary>
    /// Event that the face capture will trigger each time it detects a face.
    /// </summary>
    event EventHandler<FacesDetectedEventArgs> FaceDetected;

    /// <summary>
    /// Event to handle all inner exceptions from the face capture.
    /// </summary>
    event EventHandler<ExceptionEventArgs> OnError;

    /// <summary>
    /// Event to handle when the camera is ready to start the streaming and capture a face.
    /// </summary>
    event EventHandler ReadyToCapture;

    /// <summary>
    /// Starts the webcam stream and the face detection.
    /// </summary>
    void Play();

    /// <summary>
    /// Stops the webcam stream and the face detection.
    /// </summary>
    void Stop();

The package also provides the DefaultConfig class that implements all the configuration fields for the face capture user control.

Error handling

The OnError event provides the custom ExceptionEventArgs information with the exceptions that the FCM can throw. It is triggered in the following scenarios:

  • The integrator provides an invalid configuration (Yoti.FCM.FaceDetection.Exceptions.ConfigurationException).
  • The webcam index is out of range (System.ArgumentOutOfRangeException).
  • If the current webcam streaming is disconnected (Yoti.FCM.Exceptions.WebcamStreamException).
  • Unexpected exceptions (System.Exception).

Other controls

Webcam selector

The package exports the method Yoti.FCM.WebcamStream.WebcamInfo.GetWebcamDevices() to get all webcam devices that are available. It also provides a user control to select a webcam:

<controls:WebcamSelector Width="300" Height="24" SelectionChanged="WebcamSelector_SelectionChanged" />

The properties for the webcam selector are the following:

Property name Type Default value Description
SelectedIndex int? 0 The current webcam index.
SelectionChanged EventHandler<WebcamSelectionEventArgs> null The event that the webcam selector will trigger when the user changes the webcam selected.
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 277 4/17/2023
1.0.0 267 2/8/2023
0.1.0-beta2 157 12/2/2022
0.1.0-beta1 171 11/7/2022

- Provide new Min/MaxFaceRelativeSize configuration fields.
- MinMainFaceArea default value is 20000 now.
- New data type for ProbabilityThreshold property.
- The OnError callback will return a new ConfigurationException entity for configuration errors.
- Start and Stop methods do not throw an exception if the camera is already running or stopped.
- Camera dropdown updates the webcam items each time the user opens the list.
- New camera resolution property.
- New WebcamStartTimeout property.
- Change the font style for feedback messages.
- Improve package documentation.