Realeyes.DemographicEstimation 1.2.0

dotnet add package Realeyes.DemographicEstimation --version 1.2.0
                    
NuGet\Install-Package Realeyes.DemographicEstimation -Version 1.2.0
                    
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.DemographicEstimation" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Realeyes.DemographicEstimation" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Realeyes.DemographicEstimation" />
                    
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.DemographicEstimation --version 1.2.0
                    
#r "nuget: Realeyes.DemographicEstimation, 1.2.0"
                    
#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.DemographicEstimation@1.2.0
                    
#: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.DemographicEstimation&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Realeyes.DemographicEstimation&version=1.2.0
                    
Install as a Cake Tool

Realeyes Demographic Estimation Library - .NET Wrapper

C# wrapper for the Realeyes Demographic Estimation Library, providing face detection and demographic estimation (age, gender, age uncertainty) capabilities.

Features

  • Face Detection: Detect faces in images with bounding boxes, landmarks, and confidence scores
  • Demographic Estimation: Estimate age, gender, and age uncertainty for detected faces
  • Asynchronous API: Non-blocking callback-based operations for high performance
  • Cross-platform: Supports Windows (x64), Linux (x64, ARM64)
  • Type-safe: Strongly-typed C# wrapper over native C API

Installation

dotnet add package Realeyes.DemographicEstimation

Quick Start

using Realeyes.DemographicEstimation;

// Create estimator with model file
using var estimator = new DemographicEstimator("model.realZ");

// Prepare image
var imageHeader = new ImageHeader(
    data: imageBytes,
    width: 640,
    height: 480,
    stride: 640 * 3,
    format: ImageFormat.RGB
);

// Detect faces
using var faces = await estimator.DetectFacesAsync(imageHeader);

// Estimate demographics for each face
foreach (var face in faces)
{
    var result = await estimator.EstimateAsync(face);

    Console.WriteLine($"Age: {result.Age}");
    Console.WriteLine($"Gender: {result.Gender}");
    Console.WriteLine($"Age Uncertainty: {result.AgeUncertainty}");
}

Concurrent Operations

The library supports concurrent face detection and estimation:

using var estimator = new DemographicEstimator("model.realZ");

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

Detection Quality

Check the quality of detected faces:

await using var faces = await estimator.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 estimator = new DemographicEstimator("model.realZ");

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

// Process faces - they'll be automatically disposed when the block ends
foreach (var face in faces)
{
    var result = await estimator.EstimateAsync(face);
    // Process results...
}

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

2. Reuse DemographicEstimator Instance

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

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

3. Handle Errors

try
{
    using var estimator = new DemographicEstimator("model.realZ");
    var faces = await estimator.DetectFacesAsync(imageHeader);
}
catch (DemographicEstimationException ex)
{
    Console.WriteLine($"Demographic estimation 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.2.0 472 12/15/2025
1.1.1 772 3/25/2025
1.0.3 233 3/19/2025