An open API service indexing awesome lists of open source software.

https://github.com/stevenrice99/unity-camera-calibration

Allows for configuring simulated physical cameras in Unity and extracting screenshots along with calibrated data for external use in pixel matching.
https://github.com/stevenrice99/unity-camera-calibration

camera camera-calibration camera-matrix camera-simulation cameras computer-vision csharp cv data-generation data-generator focal-length focal-lengths image-generation image-generator intrinsic-matrix pixel-match programming synthetic-data unity unity3d

Last synced: 4 months ago
JSON representation

Allows for configuring simulated physical cameras in Unity and extracting screenshots along with calibrated data for external use in pixel matching.

Awesome Lists containing this project

README

          

# Camera Calibration Generator

Allows for configuring simulated physical cameras in [Unity](https://unity.com "Unity") and extracting screenshots along with calibrated data for external use in pixel matching.

- [Setup](#setup "Setup")
- [Usage](#usage "Usage")
- [Data](#data "Data")
- [Textures](#textures "Textures")

# Setup

First, install [Unity](https://unity.com "Unity"). Then, either clone this project and open it in [Unity](https://unity.com "Unity") and open the [Main](Assets/Main.unity "Main") scene to see an example, or follow the below steps to add this to a new [Unity](https://unity.com "Unity") project:

1. Install [NaughtyAttributes](https://github.com/dbrizov/NaughtyAttributes "NaughtyAttributes") to your [Unity](https://unity.com "Unity") project.
2. Add the [CameraManager.cs](Assets/CameraManager.cs "CameraManager.cs") script from this repository to your [Unity](https://unity.com "Unity") project.
3. If you are planning to build for WebGL, in your project assets create the folder `Plugins/WebGL` and copy the [FileDownloader.jslib](Assets/Plugins/WebGL/FileDownloader.jslib "FileDownloader.jslib") file to it.

# Usage

1. Add a [Camera Manager](Assets/CameraManager.cs "CameraManager.cs") component to a `GameObject`.
2. Configure the properties on the [Camera Manager](Assets/CameraManager.cs "CameraManager.cs") as well as the `Camera` component itself within your scene.
- If in the editor, modify the properties on the [Camera Manager](Assets/CameraManager.cs "CameraManager.cs") and Camera component inspectors.
- If in a build, use the GUI to modify properties.
- The camera view you see is "between" where the left and right cameras will be, with the "Offset" field representing how far apart in meters the two screenshots will be.
- For example, an offset of 0.25 will mean the left screenshot will shift 0.25 meters to the left to take it, and the right screenshot will shift 0.25 meters to the right to take it.
3. Click the `Generate Data` button.
- If in the editor, this is on the [Camera Manager](Assets/CameraManager.cs "CameraManager.cs") component's inspector.
- If in a build, this is located at the bottom of the GUI.
- **This will cause the application to hang for a few seconds, with the higher your resolution the longer the hang.**
4. After a few seconds for the previous step to finish, you can find the [data](#data "Data") that was generated.
- In the editor or a desktop build, you can find the data in the root of your project under `Camera-Data/{scene}/{camera}` where `{scene}` is the name of the currently loaded scene and `{camera}` is the name of the [Camera Manager](Assets/CameraManager.cs "CameraManager.cs") component's GameObject.
- This will open automatically.
- If in a web build, this will download all the generated [data](#data "Data") as a ZIP file.

# Data

The generated data produces the following files where `{name}` is the name of the camera:

- `{name}-Left.png` and `{name}-Right.png` - The screenshots from the cameras.
- `{name}-Left-2D.txt` and `{name}-Right-2D.txt` - 2D pixel coordinates that correspond to matched world points from `{name}-Left-3D.txt` and `{name}-Right-3D.txt`.
- In the form of `X Y` on each line.
- `{name}-Left-3D.txt` and `{name}-Right-3D.txt` - 3D world coordinates that correspond to matched pixel points from `{name}-Left-2D.txt` and `{name}-Right-2D.txt`.
- In the form of `X Y Z` on each line.
- These are calculated relative to each given camera.
- `{name}-Left-Color.txt` and `{name}-Right-Color.txt` - Color values that correspond to matched pixel points from `{name}-Left-2D.txt` and `{name}-Right-2D.txt`.
- In the form of `R G B` on each line.
- `{name}-Focal-Length-X.txt` - The X focal length in pixels for matrix calculations.
- `{name}-Focal-Length-Y.txt` - The Y focal length in pixels for matrix calculations.
- `{name}-Principal-Point-X.txt` - The X principal point in pixels for matrix calculations.
- `{name}-Principal-Point-Y.txt` - The Y principal point in pixels for matrix calculations.
- `{name}-Intrinsic-Matrix.txt` - The intrinsic matrix of the cameras.
- `{name}-Offset.txt` - The horizontal offset in meters between the two cameras.

# Textures

All sample textures are from [PolyHaven](https://polyhaven.com "PolyHaven") licenced under [CC0](https://polyhaven.com/license "CC0").