> For the complete documentation index, see [llms.txt](https://docs.degirum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.degirum.com/face-recognition/complete-api-reference/face_utils.md).

# Face Utils

{% hint style="info" %}
This API Reference is based on DeGirum Face version 1.4.1.
{% endhint %}

## Functions <a href="#functions" id="functions"></a>

#### face\_align\_and\_crop(img, ...) <a href="#face_align_and_crop" id="face_align_and_crop"></a>

`face_align_and_crop(img, landmarks, image_size)`

Align and crop the face from the image based on the given landmarks.

Parameters:

| Name         | Type            | Description                                                                                                                          | Default    |
| ------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------- |
| `img`        | `ndarray`       | The full image (not the cropped bounding box).                                                                                       | *required* |
| `landmarks`  | `List[ndarray]` | List of 5 keypoints (landmarks) as (x, y) coordinates in the following order: \[left eye, right eye, nose, left mouth, right mouth]. | *required* |
| `image_size` | `int`           | The size to which the image should be resized.                                                                                       | *required* |

Returns:

| Type      | Description                        |
| --------- | ---------------------------------- |
| `ndarray` | np.ndarray: the aligned face image |

#### face\_is\_frontal(landmarks) <a href="#face_is_frontal" id="face_is_frontal"></a>

`face_is_frontal(landmarks)`

Check if the face is frontal based on the landmarks.

Parameters:

| Name        | Type            | Description                                                                                                                          | Default    |
| ----------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------- |
| `landmarks` | `List[ndarray]` | List of 5 keypoints (landmarks) as (x, y) coordinates in the following order: \[left eye, right eye, nose, left mouth, right mouth]. | *required* |

Returns:

| Name   | Type   | Description                                   |
| ------ | ------ | --------------------------------------------- |
| `bool` | `bool` | True if the face is frontal, False otherwise. |

#### face\_is\_shifted(bbox, ...) <a href="#face_is_shifted" id="face_is_shifted"></a>

`face_is_shifted(bbox, landmarks)`

Check if the face is shifted based on the landmarks.

Parameters:

| Name        | Type            | Description                                         | Default    |
| ----------- | --------------- | --------------------------------------------------- | ---------- |
| `bbox`      | `List[float]`   | Bounding box of the face as \[x1, y1, x2, y2].      | *required* |
| `landmarks` | `List[ndarray]` | List of keypoints (landmarks) as (x, y) coordinates | *required* |

Returns:

| Name   | Type   | Description                                                     |
| ------ | ------ | --------------------------------------------------------------- |
| `bool` | `bool` | True if the face is shifted to a side of bbox, False otherwise. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.degirum.com/face-recognition/complete-api-reference/face_utils.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
