# .NET API Documentation

# DemographicEstimator class

# class Realeyes.DemographicEstimation.DemographicEstimator

Main entry point for face detection and demographic estimation operations. This class is thread-safe and supports concurrent asynchronous operations.

# Constructor

DemographicEstimator(string modelPath, int maxConcurrency = 0)

Creates a new DemographicEstimator instance

Parameters:

  • modelPath (string) - Path to the demographic estimation model file (.realZ)
  • maxConcurrency (int) - Maximum concurrency (0 for automatic/all cores), default: 0

Throws:

  • ArgumentNullException - When modelPath is null
  • DemographicEstimationException - When model loading fails

# Methods

# DetectFacesAsync(imageHeader)
Task<FaceList> DetectFacesAsync(ImageHeader imageHeader)

Detects faces in an image asynchronously. This method is non-blocking and thread-safe - multiple calls can be made concurrently.

Parameters:

  • imageHeader (ImageHeader) - Image to process

Returns: Task

Throws:

  • DemographicEstimationException - When detection fails
# EstimateAsync(face)
Task<EstimationResult> EstimateAsync(Face face)

Estimates demographic information (age, gender, age uncertainty) for a detected face asynchronously. This method is non-blocking and thread-safe - multiple calls can be made concurrently.

Parameters:

  • face (Face) - Previously detected face

Returns: Task

Throws:

  • ArgumentNullException - When face is null
  • DemographicEstimationException - When estimation fails

# Properties

# ConcurrentCalculations
int ConcurrentCalculations { get; }

Gets the number of calculations currently running concurrently. Use this to limit the number of concurrent calculations if needed.

# ModelName
string ModelName { get; }

Gets the name/version of the loaded model

# SdkVersion
static Version SdkVersion { get; }

Gets the SDK version (static property)

# SdkVersionString
static string SdkVersionString { get; }

Gets the SDK version as a string (static property)

# ImageHeader class

# class Realeyes.DemographicEstimation.ImageHeader

Image descriptor for passing image data to the Demographic Estimation Library

# Constructor

ImageHeader(byte[] data, int width, int height, int stride, ImageFormat format)

Creates a new image header

Parameters:

  • data (byte[]) - Image data bytes
  • width (int) - Width in pixels
  • height (int) - Height in pixels
  • stride (int) - Length of one row in bytes (e.g., 3*width + padding)
  • format (ImageFormat) - Pixel format

Throws:

  • ArgumentNullException - When data is null
  • ArgumentOutOfRangeException - When width, height, or stride is not positive

# Properties

  • Data (byte[]) - Image data bytes
  • Width (int) - Width of the image in pixels
  • Height (int) - Height of the image in pixels
  • Stride (int) - Length of one row of pixels in bytes (e.g: 3*width + padding)
  • Format (ImageFormat) - Image pixel format

# Result classes

# FaceList

# class Realeyes.DemographicEstimation.FaceList

A disposable collection of Face objects that automatically disposes all faces when disposed. Inherits from List.

# Methods
# Dispose()
void Dispose()

Disposes all Face objects in the collection synchronously

# DisposeAsync()

# Face

# class Realeyes.DemographicEstimation.Face

Represents a detected face with landmarks, bounding box, and confidence information

# Constructor
Face(ImageHeader imageHeader, Point2d[] landmarks, BoundingBox boundingBox, float confidence)

Creates a Face object from a third-party face detector

Parameters:

  • imageHeader (ImageHeader) - Image containing the face
  • landmarks (Point2d[]) - Face landmarks
  • boundingBox (BoundingBox) - Bounding box of the face
  • confidence (float) - Detection confidence score

Throws:

  • ArgumentNullException - When imageHeader or landmarks is null
  • DemographicEstimationException - When face creation fails
# Properties
  • BoundingBox (BoundingBox) - Gets the bounding box of this face
  • Confidence (float) - Gets the detection confidence score
# Methods
# GetLandmarks()
Point2d[] GetLandmarks()

Gets the facial landmarks

Returns: Point2d[]

# Clone()
Face Clone()

Creates a copy of this face

Returns: Face

Throws:

  • DemographicEstimationException - When cloning fails
# Dispose()
void Dispose()

Disposes the face and releases native resources

# Point2d

# struct Realeyes.DemographicEstimation.Point2d

2D point representing a landmark coordinate

# Properties
  • X (float) - X coordinate of landmark
  • Y (float) - Y coordinate of landmark

# BoundingBox

# struct Realeyes.DemographicEstimation.BoundingBox

Bounding box representing a rectangular region

# Properties
  • X (int) - X coordinate of the top-left corner
  • Y (int) - Y coordinate of the top-left corner
  • Width (int) - Width of the bounding box in pixels
  • Height (int) - Height of the bounding box in pixels
  • Right (int) - Gets the right edge X coordinate (computed property)
  • Bottom (int) - Gets the bottom edge Y coordinate (computed property)
  • Area (int) - Gets the area of the bounding box (computed property)

# EstimationResult

# class Realeyes.DemographicEstimation.EstimationResult

Result of demographic estimation containing optional age, gender, and age uncertainty values

# Properties
  • Age (float?) - Estimated age in years (if available)
  • Gender (Gender?) - Estimated gender (if available)
  • AgeUncertainty (float?) - Age uncertainty estimation (if available)
# Methods
# ToString()
string ToString()

Returns a string representation of the estimation result

Returns: string

# Enumerations

# OutputType

# enum Realeyes.DemographicEstimation.OutputType

Type of demographic estimation output

Values:

  • Age = 0 - Age estimation
  • Gender = 1 - Gender classification
  • AgeUncertainty = 2 - Age uncertainty estimation

# Gender

# enum Realeyes.DemographicEstimation.Gender

Gender classification

Values:

  • Female = 0 - Female
  • Male = 1 - Male

# ImageFormat

# enum Realeyes.DemographicEstimation.ImageFormat

Image pixel format

Values:

  • Grayscale = 0 - 8-bit grayscale
  • RGB = 1 - 24-bit RGB
  • RGBA = 2 - 32-bit RGBA or RGB with padding
  • BGR = 3 - 24-bit BGR
  • BGRA = 4 - 32-bit BGRA or BGR with padding

# Version

# struct Realeyes.DemographicEstimation.Version

Semantic version number

# Properties
  • Major (int) - Major version number
  • Minor (int) - Minor version number
  • Patch (int) - Patch version number
# Methods
# ToString()
string ToString()

Returns the version as a string

Returns: string

# Exceptions

# DemographicEstimationException

# class Realeyes.DemographicEstimation.DemographicEstimationException

Exception thrown when demographic estimation operations fail

Disposes all Face objects in the collection asynchronously