# Camera Calibration

The purpose of the camera calibration process is to accurately determine the intrinsic parameters of a camera system. This consists of the focal length, lens distortions, and other misalignments during the imaging process. These parameters can be found through lens calibration, which consists of imaging a known pattern, and analyzing the resulting footage. The Gyroflow lens calibrator looks like this:

## Video guide (outdated)

The calibration process between 0.3.0-beta and 1.0 is overall pretty similar, with the previously created presets being compatible with the new version of the software.

## Getting calibration footage

1. Display the calibration pattern on a flat computer monitor, preferably in full screen (available from the lens calibrator utility). You can also print it out if you prefer. In general, larger calibration patterns are preferred since focus will be closer to the focus during actual use. A bright screen with a slightly darkened room works well.
2. Select the desired camera settings to calibrate for. Most importantly the field of view/focal length and aspect ratio, if applicable. Framerate and resolution doesn't matter, only if the resolution changes the field of view. Too low shutter speed may also cause undesirable motion blur, but it's usually fine.
3. Record the pattern while slowly moving around to different angles and distances in one clip. 60 seconds is typically more than enough. Try to avoid motion blur by holding the camera still in each angles and with slow movements, and make sure the full chessboard is in view. The following angles are recommended for getting distortion information from the full frame:
4. Chessboard filling whole frame
5. Chessboard seen from distance.
6. Chessboard seen at an angle.
7. Each edge of video frame aligned with edge of chessboard.
8. Corner of chessboard aligned with corner of video.

The default (14x8) calibration pattern is also available below:

## Creating camera preset

1. Start the Gyroflow tool and click create new under the lens profile tab.
2. Open the previously recorded calibration video file.
3. Either begin auto calibration or manually add frames using add calibration point from the timeline context menu.
4. After either the automatic or manual calibration process, check the reprojection error. This value describes the overall error between the preset and actual lens distortion based on the expected features of the calibration pattern.
5. After all required frames are added and processed, the straight lines should be straight in the undistorted video. Reprojection error should typically be under 5 (pixels) with excellent calibrations giving values below 1.
6. Fill in the preset information and export the lens profile. Try to add all relevant information about the camera/lens combination including field of view setting and lens focal length if applicable.
7. If a successful calibration was achieved with a low reprojection error and no obvious artefacts, the profile can be submitted with the Upload lens profile to the database checkbox.
8. You're now ready to use the new lens preset. These are stored as .json files.

The lens calibrator contains additional options.

### Default output size

Radial lens undistortion typically results in the image being stretched more in the horizontal axis (use the FOV slider to see this). For instance, undistorted 4:3 GoPro video:

Notice that the area of the valid rectangle is close to a 16:9 aspect ratio as opposed to 4:3. In these cases, the default output size can be modified to a 16:9 one.

For cameras with minimal fisheye distortion, or even with pincushion distortion, the resulting valid aspect ratio is close to the original one. For these cameras, just use the input resolution for the default output size.

### Sharpness limit

Sets the minimum required sharpness for the calibration pattern. If the pattern failed to detect due to focus or blurriness, try increasing this limit.