# C++ API Documentation

## Estimator class

### class del::DemographicEstimator

The Demographic Estimator class

#### Constructors

```cpp
DemographicEstimator(const std::string& modelFile, int maxConcurrency = 0)
```

Constructor: loads model file, sets up the processing.

**Parameters:**
- `modelFile` - path for the used model
- `maxConcurrency` - maximum allowed concurrency, 0 means automatic (using all cores), default: 0

```cpp
~DemographicEstimator()
```

Destructor

#### Methods

```cpp
std::future<std::vector<del::Face>> detectFaces(const del::ImageHeader& imageHeader)
```

Detects the faces on an image with the std::future API.

**Note:** The given ImageHeader doesn't own the image data, and it is safe to delete the data after the call, a copy is happening internally. See del::ImageHeader for details.

**Note:** Calling this function is non-blocking, so calling it again with the next image without waiting for the result is possible. Also see getConcurrentCalculations().

**Note:** This is the std::future based API, for callback API see `del::DemographicEstimator::detectFaces(const del::ImageHeader&, std::function<void (ResultOrError<std::vector<Face>>)>)`.

**Parameters:**
- `imageHeader` - image descriptor

---

```cpp
void detectFaces(const del::ImageHeader& imageHeader,
                 std::function<void (ResultOrError<std::vector<Face>>)> callback)
```

Detects the faces on an image with a callback API.

**Note:** The given ImageHeader doesn't own the image data, and it is safe to delete the data after the call, a copy is happening internally. See del::ImageHeader for details.

**Note:** Calling this function is non-blocking, so calling it again with the next frame without waiting for the result is possible. Also see getConcurrentCalculations().

**Note:** This is the callback based API, for std::future API see `del::DemographicEstimator::detectFaces(const del::ImageHeader&)`.

**Parameters:**
- `imageHeader` - image descriptor
- `callback` - callback to call with the result

**Returns:** tracked landmarks and emotions

---

```cpp
std::future<std::vector<del::Output>> estimate(const del::Face& face)
```

Returns the demographic estimation of the detected face.

**Note:** Calling this function is non-blocking, so calling it again with the next frame without waiting for the result is possible. Also see getConcurrentCalculations().

**Note:** This is the std::future based API, for callback API see `del::DemographicEstimator::estimate(const del::Face&, std::function<void (ResultOrError<std::vector<del::Output>>)>)`.

**Parameters:**
- `face` - the previously detected face to embed

**Returns:** estimations

---

```cpp
void estimate(const del::Face& face,
              std::function<void (ResultOrError<std::vector<del::Output>>)> callback)
```

Returns the demographic estimation of the detected face.

**Note:** Calling this function is non-blocking, so calling it again with the next frame without waiting for the result is possible. Also see getConcurrentCalculations().

**Note:** This is the callback based API, for std::future API see `del::DemographicEstimator::estimate(const del::Face&)`.

**Parameters:**
- `face` - the previously detected face to embed
- `callback` - callback to call with the result

---

```cpp
int getConcurrentCalculations() const
```

Returns the value of the atomic counter for the number of calculations currently running concurrently. You can use this to limit the number of concurrent calculations.

**Returns:** The (approximate) number of calculations currently in-flight.

---

```cpp
std::string getModelName() const
```

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

**Returns:** name of the model

---

```cpp
static del::Version getSDKVersion()
```

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

**Returns:** version of the SDK

---

```cpp
static std::string getSDKVersionString()
```

Returns the version string of the SDK (and not the model)

**Returns:** version string of the SDK

## Image header class

### struct del::ImageHeader

Descriptor class for image data (non-owning)

**Members:**
- `const uint8_t* data` - pointer to the byte array of the image
- `int width` - width of the image in pixels
- `int height` - height of the image in pixels
- `int stride` - length of one row of pixels in bytes (e.g: 3*width + padding)
- `del::ImageFormat format` - image format

### enum class del::ImageFormat

**Values:**
- `Grayscale = 0` - 8-bit grayscale
- `RGB = 1` - 24-bit RGB
- `RGBA = 2` - 32-bit RGBA or 32-bit RGB_
- `BGR = 3` - 24-bit BGR
- `BGRA = 4` - 32-bit BGRA or 32-bit BGR_

## Result classes

### Face

See also: [landmarks specification](overview.md#target-to-face-specs).

#### class del::Face

Face Class

##### Constructors

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

Constructor for the Face object to support 3rd party face detectors

**Parameters:**
- `imageHeader` - image descriptor
- `landmarks` - face landmarks
- `bbox` - face bounding box
- `confidence` - face detection confidence

```cpp
~Face()
```

Destructor

##### Methods

```cpp
BoundingBox boundingBox() const
```

Returns the bounding box of the detected face

**Returns:** BoundingBox

---

```cpp
float confidence() const
```

Returns the confidence value of the detected face

**Returns:** float

---

```cpp
std::vector<del::Point2d> landmarks() const
```

Returns the landmarks of the face

**Returns:** std::vector<del::Point2d>

### Point2d

#### struct del::Point2d

Point2d class for landmarks

**Members:**
- `float x` - x coordinate of the point
- `float y` - y coordinate of the point

### BoundingBox

#### struct del::BoundingBox

Bounding Box class for the faces

**Members:**
- `int x` - x coordinate of the top-left corner
- `int y` - y coordinate of the top-left corner
- `int width` - width of the bounding box in pixels
- `int height` - height of the bounding box in pixels

### OutputType

#### enum class del::OutputType

Type of the output in Output struct.

**Values:**
- `AGE = 0`
- `GENDER = 1`
- `AGE_UNCERTAINTY = 2`

### Gender

#### enum class del::Gender

Gender enum.

**Values:**
- `FEMALE = 0`
- `MALE = 1`

### Output

#### struct del::Output

Output struct for various estimated outputs.

**Members:**
- `del::OutputType type` - type of the output
- `std::variant<Gender, float> value` - value of the output
- `std::string name` - name of the output
