# Camera Calibration on Skynode

This page describes how to calibrate Skynode's camera using a calibration tool running on Skynode.

Running the calibration on Skynode is slower than running it on a connected computer. Where possible, we recommend running the calibration on a computer.

{% content-ref url="camera-calibration-on-a-computer" %}
[camera-calibration-on-a-computer](https://docs.auterion.com/hardware-integration/airframe-integration/camera-calibration/camera-calibration-on-a-computer)
{% endcontent-ref %}

## Required apps

Open the **Apps** page of the vehicle web UI on <http://10.41.1.1/apps> and ensure that the **video2ros** and **camera-calibration-service** apps are installed.

These can be downloaded from Auterion Suite: [video2ros](https://suite.auterion.com/store/developer?productId=133), [camera-calibration-service](https://suite.auterion.com/store/developer?productId=130)

## Before calibrating

### Prepare the calibration target

Download and print the checkerboard calibration pattern in the PDF file below and mount it to a flat, rigid surface.

Measure the width of one square as accurately as possible. If printed on an A4 page, the width should be close to 25mm (0.025m).

{% file src="<https://3329189600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFW1Ge1p1f6WHyiYCb146%2Fuploads%2Fgit-blob-35a51f9d9535299c055c778887116e723ba76eb5%2FCheckerboard-A4-25mm-8x6.pdf?alt=media>" %}

### Configure the calibration service

Open the **Apps** page of the vehicle web UI on <http://10.41.1.1/apps> and find the **camera-calibration-service** app. Click the gear icon and select **Settings**. Set the values as follows, then click **Save**.

| Setting          | Value                  | Description                                                                                                                                                            |
| ---------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Camera Topic     | /camera/image\_raw     | Camera topic from which to receive images. `camera/image_raw` is the default for images from the video2ros app.                                                        |
| Calibrate Camera | 1                      | Boolean flag, whether the calibration task should be run. Set to `1` to perform calibration.                                                                           |
| Pattern          | chessboard             | The pattern used for camera calibration. Only the chessboard pattern is currently supported.                                                                           |
| Size             | 8x6                    | Number of **inner corners** on the chessboard (width x height). The order of width and height doesn't matter (8x6 = 6x8). On one axis, this is `number_of_squares-1` . |
| Square Size      | <*for example: 0.025>* | Width of one square on the checkerboard, as measured above, **in metres**.                                                                                             |

### Configure video2ros

Open the settings for the **video2ros** app, under **System Services**.

Set **Use Custom Auto Exposure** to **false**, and click **Save**.

### Stop all other apps

To ensure the calibration runs smoothly, only the **camera-calibration-service** and **video2ros** apps must be running.

On the **Apps** page of the vehicle web UI, stop all other apps by clicking the gear icon and then **Stop**.

## Perform the calibration

Click the **video2ros** app's blue **Add calibration file** button to open the calibration webpage. Check the **Show Calibration Tool** checkbox and - when you are ready - click the **Start Sampling** button to begin recording calibration data.

A window will appear with the video stream from the camera. Position the checkerboard such that the entire pattern is visible in the image. If the pattern is recognised, a multi-coloured grid will be drawn on the checkerboard.

Move the checkerboard around in front of the camera, keeping the entire pattern visible. Data must be captured with the pattern at different positions and orientations:

1. at the **top and bottom** of the image,
2. at the **left and right** sides of the image,
3. **near and far** from the camera, and
4. with different angles of **skew** (where one corner of the pattern is closer to or further from the camera).

The coloured bars to the right of the image will indicate how many images have been captured at each of these positions. They will turn green when sufficient data has been captured.

<figure><img src="https://3329189600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFW1Ge1p1f6WHyiYCb146%2Fuploads%2Fgit-blob-b2b0d8130bf29ca7203e8fc20e6a7860e985502c%2Fcalibration_ui.png?alt=media" alt=""><figcaption><p>The calibration video stream in which the checkerboard pattern has been recognised.<br>On the right, the coloured bars show the coverage of different positions in the recorded calibration data.</p></figcaption></figure>

Once the data capture is complete, you will be prompted to click **Calibrate**. This will compute the calibration parameters for the camera, generate a calibration file from them, and save the file on Skynode.

Restart the **video2ros** app for the new calibration file to be applied.

## Restore all apps after calibration

Skynode should be restored to the state it was in before the calibration procedure was performed.

1. Stop the **camera-calibration-service** app and *disable auto-start*.
2. In the **video2ros** app settings, set **Use Custom Auto Exposure** back to **true**.
3. Restart all other apps.

{% hint style="danger" %}
Ensure that the **camera-calibration-service** app has been **stopped** and **auto-start** **disabled**.
{% endhint %}
