> For the complete documentation index, see [llms.txt](https://docs.auterion.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.auterion.com/app-development/auterion-sdk/system-state-api-1.md).

# Camera API

{% hint style="info" %}
Related C++ Header in the Auterion SDK:`<auterion_sdk/camera/camera.hpp>`
{% endhint %}

Auterion SDK provides an interface for enumerating and subscribing to cameras and images.

In the simplest case (useful for testing), we can open the first found camera, and register a callback for image updates:

```cpp
std::optional<auterion::Camera> camera = auterion::Camera::openFirst(sdk);
if (camera) {
    printf("Got camera: %s, model=%s\n", camera->descriptor().unique_name.c_str(),
           camera->descriptor().camera_model.c_str());

    camera->subscribeImage([](const auterion::Image& image) {
        // The image data is available as image.data(),
        // encoded as image.header().encoding
        printf("Got image: size=%dx%d\n", image.width(), image.height());
    });
} else {
    printf("Timeout, no camera found\n");
}

```

As the set of available cameras depends on the system, each camera provides a descriptor, which can be used to select a camera based on its properties, such as the model name, mount orientation or purpose.

For example to select the camera used for surveys:

```cpp
std::optional<auterion::Camera> camera = auterion::Camera::open(
    sdk,
    [](const auterion::CameraDescriptor& descriptor) {
        // The camera will be selected for the first descriptor that returns true here
        return descriptor.primary_purpose ==
            auterion::CameraDescriptor::PrimaryPurpose::Survey;
    });
if (camera) {
    // ...
}
```

## Image Data

The raw image data can be accessed from the callback via `image.data()`.

The image can be converted to an OpenCV structure like this:

```cpp
const cv::Mat cv_mat = image.asOpenCVMat();
```

{% hint style="danger" %}
If you want to use the image outside of the callback, or make modifications, it is required to make a copy of the image data.
{% endhint %}

## CameraMonitor

In addition, there's also a `CameraMonitor` class that can be used to get notified when cameras are attached or removed from the system:

```cpp
auto monitor = auterion::CameraMonitor(
    sdk,
    [](const auterion::CameraDescriptor& descriptor) {
        printf("Camera found: %s\n", descriptor.camera_model.c_str());
    },
    [](const auterion::CameraDescriptor& descriptor) {
        printf("Camera removed: %s\n", descriptor.camera_model.c_str());
    });
```


---

# 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:

```
GET https://docs.auterion.com/app-development/auterion-sdk/system-state-api-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
