Realeyes.FaceVerification 1.5.2

dotnet add package Realeyes.FaceVerification --version 1.5.2
                    
NuGet\Install-Package Realeyes.FaceVerification -Version 1.5.2
                    
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="Realeyes.FaceVerification" Version="1.5.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Realeyes.FaceVerification" Version="1.5.2" />
                    
Directory.Packages.props
<PackageReference Include="Realeyes.FaceVerification" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Realeyes.FaceVerification --version 1.5.2
                    
#r "nuget: Realeyes.FaceVerification, 1.5.2"
                    
#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.
#:package Realeyes.FaceVerification@1.5.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Realeyes.FaceVerification&version=1.5.2
                    
Install as a Cake Addin
#tool nuget:?package=Realeyes.FaceVerification&version=1.5.2
                    
Install as a Cake Tool

Realeyes Face Verification Library - .NET Wrapper

Idiomatic C# wrapper for the Realeyes Face Verification Library, providing face detection, embedding extraction, and face comparison capabilities.

Features

  • Async/Await Support: All I/O-bound operations use modern async patterns
  • Type Safety: Strong typing with records and enums
  • Resource Management: Proper IDisposable implementation with SafeHandle
  • Cross-Platform: Works on Windows, Linux, and macOS

Installation

dotnet add package Realeyes.FaceVerification

Note: The package includes native libraries for multiple platforms (Windows, Linux, macOS) in the standard NuGet layout (runtimes/{rid}/native/). The library automatically resolves the correct native library for your platform.

Quick Start

using Realeyes.FaceVerification;

// Load the face verification model
using var verifier = new FaceVerifier("model.realZ");

// Prepare image data (example: BGR format)
byte[] imageData = LoadImageData(); // Your image loading logic
var imageHeader = new ImageHeader(
    data: imageData,
    width: 640,
    height: 480,
    stride: 640 * 3,
    format: ImageFormat.BGR
);

// Detect faces (use 'await using' for automatic disposal)
await using var faces = await verifier.DetectFacesAsync(imageHeader);
Console.WriteLine($"Detected {faces.Count} face(s)");

// Process each detected face
foreach (var face in faces)
{
    Console.WriteLine($"Face at ({face.BoundingBox.X}, {face.BoundingBox.Y})");
    Console.WriteLine($"Confidence: {face.Confidence:F2}");
    Console.WriteLine($"Quality: {face.DetectionQuality}");

    // Extract face embedding
    var embedding = await verifier.EmbedFaceAsync(face);
    Console.WriteLine($"Embedding size: {embedding.Length}");
}

// Faces are automatically disposed at the end of the block

Face Comparison Example

using Realeyes.FaceVerification;

using var verifier = new FaceVerifier("model.realZ");

// Detect faces in two images
await using var faces1 = await verifier.DetectFacesAsync(image1Header);
await using var faces2 = await verifier.DetectFacesAsync(image2Header);

if (faces1.Count > 0 && faces2.Count > 0)
{
    // Extract embeddings
    var embedding1 = await verifier.EmbedFaceAsync(faces1[0]);
    var embedding2 = await verifier.EmbedFaceAsync(faces2[0]);

    // Compare faces
    var match = verifier.CompareFaces(embedding1, embedding2);

    if (match.ExceedsThreshold(0.3f))
    {
        Console.WriteLine($"Same person! Similarity: {match.Similarity:F3}");
    }
    else
    {
        Console.WriteLine($"Different people. Similarity: {match.Similarity:F3}");
    }
}

// Faces are automatically disposed at the end of the block

Concurrent Operations

The library supports concurrent face detection and embedding:

using var verifier = new FaceVerifier("model.realZ");

// Process multiple images concurrently
var tasks = images.Select(img => verifier.DetectFacesAsync(img));
var results = await Task.WhenAll(tasks);

Detection Quality

Check the quality of detected faces:

await using var faces = await verifier.DetectFacesAsync(imageHeader);

foreach (var face in faces)
{
    switch (face.DetectionQuality)
    {
        case DetectionQuality.Good:
            Console.WriteLine("Good quality face");
            break;
        case DetectionQuality.BadQuality:
            Console.WriteLine("Warning: Low quality face detected");
            break;
        case DetectionQuality.MaybeRolled:
            Console.WriteLine("Warning: Face may be rolled, embeddings could be inaccurate");
            break;
    }
}

Image Format Support

The library supports various image formats:

// Grayscale (1 byte per pixel)
var grayImage = new ImageHeader(data, width, height, width, ImageFormat.Grayscale);

// RGB (3 bytes per pixel)
var rgbImage = new ImageHeader(data, width, height, width * 3, ImageFormat.RGB);

// RGBA (4 bytes per pixel)
var rgbaImage = new ImageHeader(data, width, height, width * 4, ImageFormat.RGBA);

// BGR (3 bytes per pixel) - common in OpenCV
var bgrImage = new ImageHeader(data, width, height, width * 3, ImageFormat.BGR);

// BGRA (4 bytes per pixel)
var bgraImage = new ImageHeader(data, width, height, width * 4, ImageFormat.BGRA);

Best Practices

1. Always Dispose Resources

// Use 'using' statements for automatic disposal
using var verifier = new FaceVerifier("model.realZ");

// Use 'await using' for FaceList returned from DetectFacesAsync
await using var faces = await verifier.DetectFacesAsync(imageHeader);

// Process faces - they'll be automatically disposed when the block ends
foreach (var face in faces)
{
    var embedding = await verifier.EmbedFaceAsync(face);
    // Process embedding...
}

// Or explicitly dispose if needed
var facesManual = await verifier.DetectFacesAsync(imageHeader);
try
{
    // Process faces...
}
finally
{
    facesManual.Dispose(); // Disposes all Face objects in the collection
}

2. Reuse FaceVerifier Instance

// Create once, reuse for multiple operations
using var verifier = new FaceVerifier("model.realZ");

foreach (var imagePath in imagePaths)
{
    var imageData = LoadImage(imagePath);
    var faces = await verifier.DetectFacesAsync(imageData);
    // Process faces...
}

3. Handle Errors

try
{
    using var verifier = new FaceVerifier("model.realZ");
    var faces = await verifier.DetectFacesAsync(imageHeader);
}
catch (FaceVerificationException ex)
{
    Console.WriteLine($"Face verification error: {ex.Message}");
}

License

Copyright Realeyes OU 2012-2025. All rights reserved. Proprietary software.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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.5.2 82 3/2/2026
1.5.1 272 12/19/2025
1.5.0 383 12/15/2025
1.4.6 1,060 3/26/2025
1.4.5 515 3/26/2025
1.4.4 522 2/12/2024