# C++ API Reference

# Namespace

fvl


# Classes

# FaceVerifier

The main entry point for face detection, embedding, and verification operations.

# Constructor

FaceVerifier(const std::string& modelFile, int maxConcurrency = 0);

Loads the model file and sets up processing.

Parameter Type Description Default
modelFile const std::string& Path to the .realZ model file
maxConcurrency int Maximum allowed concurrency. 0 means automatic (using all cores) 0

# Destructor

~FaceVerifier();

# Methods

# detectFaces (Future)
std::future<std::vector<fvl::Face>> detectFaces(const fvl::ImageHeader& imageHeader);

Detects the faces on an image. Returns a future that resolves with the detected faces.

Parameter Type Description
imageHeader const ImageHeader& Image descriptor

Returns: std::future<std::vector<Face>> — the detected faces.

The given ImageHeader doesn't own the image data; it is safe to delete the data after the call — a copy is made internally.

This call is non-blocking. You can call it again with the next image without waiting for the result. See getConcurrentCalculations().

# detectFaces (Callback)
void detectFaces(const fvl::ImageHeader& imageHeader,
                 std::function<void(ResultOrError<std::vector<Face>>)> callback);

Detects the faces on an image and invokes the callback with the result.

Parameter Type Description
imageHeader const ImageHeader& Image descriptor
callback std::function<void(ResultOrError<std::vector<Face>>)> Callback invoked with the result
# embedFace (Future)
std::future<std::vector<float>> embedFace(const fvl::Face& face);

Returns the embedding of a detected face.

Parameter Type Description
face const Face& The previously detected face to embed

Returns: std::future<std::vector<float>> — the face embedding vector.

This call is non-blocking.

# embedFace (Callback)
void embedFace(const fvl::Face& face,
               std::function<void(ResultOrError<std::vector<float>>)> callback);

Returns the embedding of a detected face via callback.

Parameter Type Description
face const Face& The previously detected face to embed
callback std::function<void(ResultOrError<std::vector<float>>)> Callback invoked with the result
# compareFaces
fvl::Match compareFaces(const std::vector<float>& embedding1,
                        const std::vector<float>& embedding2);

Compares two face embeddings.

Parameter Type Description
embedding1 const std::vector<float>& Embedding of the first face
embedding2 const std::vector<float>& Embedding of the second face

Returns: Match — match result with the similarity metric.

# getConcurrentCalculations
int getConcurrentCalculations() const;

Returns the approximate number of calculations currently in-flight. Use this to limit the number of concurrent calculations.

Returns: int — the number of concurrent calculations.

# getModelName
std::string getModelName() const;

Returns the name (version, etc.) of the loaded model.

Returns: std::string — name of the model.

# getSDKVersion
static fvl::Version getSDKVersion();

Returns the version of the SDK (not the model).

Returns: Version — SDK version.

# getSDKVersionString
static std::string getSDKVersionString();

Returns the version of the SDK as a string.

Returns: std::string — SDK version string.


# Face

Represents a detected face with landmarks, bounding box, and quality information.

# Constructor

Face(const fvl::ImageHeader& imageHeader,
     const std::vector<fvl::Point2d>& landmarks,
     const fvl::BoundingBox& bbox = fvl::BoundingBox(),
     float confidence = 0.0f);

Creates a Face object to support 3rd party face detectors.

Parameter Type Description Default
imageHeader const ImageHeader& Image containing the face
landmarks const std::vector<Point2d>& Face landmarks (5 points)
bbox const BoundingBox& Bounding box of the face BoundingBox()
confidence float Detection confidence score 0.0f

# Methods

# detectionQuality
DetectionQuality detectionQuality() const;

Returns: DetectionQuality — the detection quality of the face.

# boundingBox
BoundingBox boundingBox() const;

Returns: BoundingBox — the bounding box of the face.

# confidence
float confidence() const;

Returns: float — the detection confidence score.

# landmarks
std::vector<fvl::Point2d> landmarks() const;

Returns: std::vector<Point2d> — the 5 facial landmarks. See landmarks specification.


# Types

# ImageHeader

Descriptor for image data (non-owning).

struct ImageHeader {
    const uint8_t* data;
    int width;
    int height;
    int stride;
    fvl::ImageFormat format;
};
Field Type Description
data const uint8_t* Pointer to the byte array of the image
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

# Point2d

2D point for landmark coordinates.

struct Point2d {
    float x;
    float y;
};
Field Type Description
x float X coordinate of the point
y float Y coordinate of the point

# BoundingBox

Bounding box for detected faces.

struct BoundingBox {
    int x;
    int y;
    int width;
    int height;
};
Field Type Description
x int X coordinate of the top-left corner
y int Y coordinate of the top-left corner
width int Width in pixels
height int Height in pixels

# Match

Result of face comparison.

struct Match {
    float similarity;
};
Field Type Description
similarity float Similarity score between the two faces

# Version

Semantic version number for the SDK.

struct Version {
    int major;
    int minor;
    int patch;
};
Field Type Description
major int Major version number
minor int Minor version number
patch int Patch version number

# ErrorType

Error information for the callback interface.

struct ErrorType {
    std::string errorString;
};
Field Type Description
errorString std::string Human-readable description of the error

# ResultOrError

Type representing the result or the error in the callback interface.

template <typename ResultType>
using ResultOrError = std::variant<ResultType, ErrorType>;

Use std::get_if or std::visit to extract the result or error:

if (auto* value = std::get_if<ResultType>(&result)) {
    // success
} else {
    auto& error = std::get<ErrorType>(result);
    // handle error
}

# Enums

# ImageFormat

enum class ImageFormat {
    Grayscale = 0,
    RGB       = 1,
    RGBA      = 2,
    BGR       = 3,
    BGRA      = 4,
};
Value Description
Grayscale 8-bit grayscale
RGB 24-bit RGB
RGBA 32-bit RGBA or RGB with padding
BGR 24-bit BGR
BGRA 32-bit BGRA or BGR with padding

# DetectionQuality

enum class DetectionQuality {
    Good        = 0,
    BadQuality  = 1,
    MaybeRolled = 2,
};
Value Description
Good No issues detected
BadQuality Bad quality detected
MaybeRolled Face may be rolled; embeddings could be incorrect

# Thread Safety

  • FaceVerifier methods can be called concurrently from multiple threads.
  • detectFaces() and embedFace() calls can execute concurrently.
  • Use getConcurrentCalculations() to monitor and limit concurrency.