Yoti.FCM 1.0.1

dotnet add package Yoti.FCM --version 1.0.1
NuGet\Install-Package Yoti.FCM -Version 1.0.1
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="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Yoti.FCM --version 1.0.1
#r "nuget: Yoti.FCM, 1.0.1"
#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=1.0.1

// Install Yoti.FCM as a Cake Tool
#tool nuget:?package=Yoti.FCM&version=1.0.1

Yoti Face Capture

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

Dependencies

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

Usage

  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.
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.
CameraResolution Resolution Resolution.HD720P Resolution requested to the camera video capabilities. Must be a valid resolution for the webcam.
CameraAverageFrameRate int 30 Average frame rate requested to the camera video capabilities. Must match what the webcam provide for the selected resolution.

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.

Localisation

Set the FCM localisation by running the following code:

CultureInfo cultureInfo = new CultureInfo(SelectedLanguage);
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
Application.Current.MainWindow.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);

Where SelectedLanguage can be chosen from the following list:

  • ar-XM
  • bg-BG
  • cs-CZ
  • da-DK
  • de-DE
  • el-GR
  • en
  • es-419
  • es-ES
  • et-EE
  • fa-IR
  • fi-FI
  • fr-FR
  • he-IL
  • hi-IN
  • hu-HU
  • hy-AM
  • id-ID
  • it-IT
  • ja-JP
  • ko-KR
  • lt-LT
  • lv-LV
  • ms-MY
  • nb-NO
  • nl-NL
  • pl-PL
  • pt-BR
  • pt-PT
  • ro-RO
  • ru-RU
  • sv-SE
  • th-TH
  • tr-TR
  • uk-UA
  • ur-PK
  • vi-VN

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.
Resolution selector

The package exports the method Yoti.FCM.WebcamStream.WebcamCapabilities.GetValidCapabilities(string webcamMoniker) to get all the capabilities compatible with the FCM for the provided device. It also provides a user control to select capabilities set:

<controls:ResolutionSelector Width="300" Height="24" SelectedWebcam="{Binding CurrentWebcam.MonikerString}" SelectionChanged="ResolutionSelector_SelectionChanged"/>

The properties for the webcam selector are the following:

Property name Type Default value Description
SelectedWebcam string null The current webcam ID from which the capabilities are going to be selected.
SelectedCapabilities WebcamCapabilities null The current selected capabilities.
SelectionChanged EventHandler<ResolutionSelectionEventArgs> 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 241 4/17/2023
1.0.0 256 2/8/2023
0.1.0-beta2 156 12/2/2022
0.1.0-beta1 170 11/7/2022

- Fix typo in Estonian language code: 'et-ET' to 'et-EE'.
- Fix bug preventing the FCM to clean last frame when stopped.