# Camera configuration

{% hint style="info" %}
More detailed information about this can be found on the NVIDIA [Camera adaption guide ](https://docs.nvidia.com/jetson/archives/r35.1/DeveloperGuide/text/SD/CameraDevelopment/CameraSoftwareDevelopmentSolution.html)& [manual pages](https://manpages.debian.org/stretch/v4l-utils/v4l2-ctl.1) for the used commands bellow
{% endhint %}

## Introduction

The Video4Linux-API (V4L in short) is the Linux interface that is used to manage the CSI video input from the CSI-Camera. Most of those cameras are using I2C for futher configurations for the camera, which can be changed over the V4L-API in the following ways.

{% hint style="warning" %}
`v4l-utils` is required in order to execute the following examples properly by using

{% code title="Install" lineNumbers="true" %}

```bash
 test@test-desktop:~$ sudo apt update & sudo apt install v4l-utils
```

{% endcode %}
{% endhint %}

## Video4Linux Controls

V4L allows the user to make further configurations on the Camera sensor to alter/improve the video stream settings.&#x20;

The video device can be found in the `/dev/` directory. If the camera correctly plugged in then there should be a device called `/dev/videoX`, where `X` is the camera id.

### List available controls

Returns a list of available camera controls to change

Syntax: `sudo v4l2-ctl --device /dev/videoX -l`

{% code title="" lineNumbers="true" %}

```bash
test@test-desktop:~$ sudo v4l2-ctl --device /dev/video0 -l

Camera Controls

                     group_hold 0x009a2003 (bool)   : default=0 value=0 flags=execute-on-write
                    sensor_mode 0x009a2008 (int64)  : min=0 max=3 step=1 default=0 value=1 flags=slider
                           gain 0x009a2009 (int64)  : min=16 max=356 step=1 default=16 value=16 flags=slider
                       exposure 0x009a200a (int64)  : min=13 max=683709 step=1 default=2495 value=26011 flags=slider
                     frame_rate 0x009a200b (int64)  : min=2000000 max=60000000 step=1 default=60000000 value=21000000 flags=slider
                    bypass_mode 0x009a2064 (intmenu): min=0 max=1 default=0 value=1
                override_enable 0x009a2065 (intmenu): min=0 max=1 default=0 value=1
                   height_align 0x009a2066 (int)    : min=1 max=16 step=1 default=1 value=1
                     size_align 0x009a2067 (intmenu): min=0 max=2 default=0 value=0
               write_isp_format 0x009a2068 (int)    : min=1 max=1 step=1 default=1 value=1
       sensor_signal_properties 0x009a2069 (u32)    : min=0 max=4294967295 step=1 default=0 [30][18] flags=read-only, has-payload
        sensor_image_properties 0x009a206a (u32)    : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
      sensor_control_properties 0x009a206b (u32)    : min=0 max=4294967295 step=1 default=0 [30][36] flags=read-only, has-payload
              sensor_dv_timings 0x009a206c (u32)    : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
               low_latency_mode 0x009a206d (bool)   : default=0 value=0
               preferred_stride 0x009a206e (int)    : min=0 max=65535 step=1 default=0 value=0
                   sensor_modes 0x009a2082 (int)    : min=0 max=30 step=1 default=30 value=3 flags=read-only
test@test-desktop:~$ 
```

{% endcode %}

### Set control value

For this example we use the `exposure` controls from the list above

{% code title="available control output" lineNumbers="true" %}

```
exposure 0x009a200a (int64)  : min=13 max=683709 step=1 default=2495 value=26011 flags=slider
```

{% endcode %}

This control can be changed by using the following command\
Syntax: `sudo v4l2-ctl --device /dev/videoX --set-ctrl=<control>=<value>`

{% code title="set exposure control " lineNumbers="true" %}

```bash
test@test-desktop:~$ sudo v4l2-ctl --device /dev/video0 --set-ctrl=exposure=600000
```

{% endcode %}

### Get control value

For this example we use the `exposure` controls from the list above.&#x20;

This control can be read by using the following command\
Syntax: `sudo v4l2-ctl --device /dev/videoX --get-ctrl=<control>`

{% code title="get exposure control " lineNumbers="true" %}

```bash
test@test-desktop:~$ sudo v4l2-ctl --device /dev/video0 --get-ctrl=exposure
exposure: 19999
```

{% endcode %}

{% hint style="warning" %}
Pleas note that other streaming tools can also intervene and change those settings and  might be overwritten or not applied correctly.
{% endhint %}

## Example Stream

The following screenshots are showing the difference between different exposure settings on a [Raspberry PI IMX477](https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/) camera sensor that is connected via CSI on our JNX30M Carrierboard

| default setting                  | custom setting                                                      |
| -------------------------------- | ------------------------------------------------------------------- |
| ![](/files/Uawu7AarTo1itWxoywHA) | <img src="/files/JXhWeXStl9pDH8L78VHl" alt="" data-size="original"> |


---

# Agent Instructions: 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://auvidea.gitbook.io/csi-camera/guide/camera-configuration.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.
