#
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.
#
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.
Returns: std::future<std::vector<Face>> — the detected faces.
The given ImageHeader
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.
#
embedFace (Future)
std::future<std::vector<float>> embedFace(const fvl::Face& face);
Returns the embedding of a detected face.
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.
#
compareFaces
fvl::Match compareFaces(const std::vector<float>& embedding1,
const std::vector<float>& embedding2);
Compares two face embeddings.
Returns: Match
#
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
#
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.
#
Methods
#
detectionQuality
DetectionQuality detectionQuality() const;
Returns: DetectionQuality
#
boundingBox
BoundingBox boundingBox() const;
Returns: BoundingBox
#
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;
};
#
Point2d
2D point for landmark coordinates.
struct Point2d {
float x;
float y;
};
#
BoundingBox
Bounding box for detected faces.
struct BoundingBox {
int x;
int y;
int width;
int height;
};
#
Match
Result of face comparison.
struct Match {
float similarity;
};
#
Version
Semantic version number for the SDK.
struct Version {
int major;
int minor;
int patch;
};
#
ErrorType
Error information for the callback interface.
struct ErrorType {
std::string errorString;
};
#
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,
};
#
DetectionQuality
enum class DetectionQuality {
Good = 0,
BadQuality = 1,
MaybeRolled = 2,
};
#
Thread Safety
methods can be called concurrently from multiple threads.FaceVerifier anddetectFaces() calls can execute concurrently.embedFace()- Use
to monitor and limit concurrency.getConcurrentCalculations()
See also
Welcome to the Face Verification Library documentation!
The Face Verification Library is a portable C++ library for face verification, designed for real-time processing on client devices (mobile and
C++17 compatible compiler