Skip to content

Commit 29d9523

Browse files
authored
Add main calibration loop, UI and output files (#40)
This patch adds the main calibration logic, the CLI behavior and the logic to generate the calibration output files.
1 parent 3cd6dde commit 29d9523

34 files changed

+1852
-218
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ Build
5858
build
5959
install
6060
log
61+
62+
images/

README.md

Lines changed: 92 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,103 @@
1-
![Kalibr](https://raw.githubusercontent.com/wiki/ethz-asl/kalibr/images/kalibr_small.png)
1+
# Kalibr2
22

3-
[![ROS1 Ubuntu 20.04](https://github.com/ethz-asl/kalibr/actions/workflows/docker_2004_build.yaml/badge.svg)](https://github.com/ethz-asl/kalibr/actions/workflows/docker_2004_build.yaml)
4-
[![ROS1 Ubuntu 18.04](https://github.com/ethz-asl/kalibr/actions/workflows/docker_1804_build.yaml/badge.svg)](https://github.com/ethz-asl/kalibr/actions/workflows/docker_1804_build.yaml)
5-
[![ROS1 Ubuntu 16.04](https://github.com/ethz-asl/kalibr/actions/workflows/docker_1604_build.yaml/badge.svg)](https://github.com/ethz-asl/kalibr/actions/workflows/docker_1604_build.yaml)
3+
A modern multi-camera calibration toolbox built on ROS 2.
64

75
## Introduction
8-
Kalibr is a toolbox that solves the following calibration problems:
9-
10-
1. **Multi-Camera Calibration**: Intrinsic and extrinsic calibration of a camera-systems with non-globally shared overlapping fields of view with support for a wide range of [camera models](https://github.com/ethz-asl/kalibr/wiki/supported-models).
11-
1. **Visual-Inertial Calibration (CAM-IMU)**: Spatial and temporal calibration of an IMU w.r.t a camera-system along with IMU intrinsic parameters
12-
1. **Multi-Inertial Calibration (IMU-IMU)**: Spatial and temporal calibration of an IMU w.r.t a base inertial sensor along with IMU intrinsic parameters (requires 1-aiding camera sensor).
13-
1. **Rolling Shutter Camera Calibration**: Full intrinsic calibration (projection, distortion and shutter parameters) of rolling shutter cameras.
14-
15-
To install follow the [install wiki page](https://github.com/ethz-asl/kalibr/wiki/installation) instructions for which you can either use Docker or install from source in a ROS workspace.
16-
Please find more information on the [wiki pages](https://github.com/ethz-asl/kalibr/wiki) of this repository.
17-
For questions or comments, please open an issue on Github.
18-
19-
20-
## News / Events
21-
22-
* **Nov 24, 2022** - Some new visualization of trajectory and IMU rate for the generated report along with fixed support for exporting poses to file (see PR [#578](https://github.com/ethz-asl/kalibr/pull/578),[#581](https://github.com/ethz-asl/kalibr/pull/581),[#582](https://github.com/ethz-asl/kalibr/pull/582))
23-
* **May 3, 2022** - Support for Ubuntu 20.04 along with Docker scripts have been merged into master via PR [#515](https://github.com/ethz-asl/kalibr/pull/515). A large portion was upgrading to Python 3. A special thanks to all the contributors that made this possible. Additionally, contributed fixes for the different validation and visualization scripts have been merged.
24-
* **Febuary 3, 2020** - Initial Ubuntu 18.04 support has been merged via PR [#241](https://github.com/ethz-asl/kalibr/pull/241). Additionally, support for inputting an initial guess for focal length can be provided from the cmd-line on failure to initialize them.
25-
* **August 15, 2018** - Double sphere camera models have been contributed to the repository via PR [#210](https://github.com/ethz-asl/kalibr/pull/210). If you are interested you can refer to the [paper](https://arxiv.org/abs/1807.08957) for a nice overview of the models in the repository.
26-
* **August 25, 2016** - Rolling shutter camera calibration support was added as a feature via PR [#65](https://github.com/ethz-asl/kalibr/pull/65). The [paper](https://www.cv-foundation.org/openaccess/content_cvpr_2013/papers/Oth_Rolling_Shutter_Camera_2013_CVPR_paper.pdf) provides details for those interested.
27-
* **May 18, 2016** - Support for multiple IMU-to-IMU spacial and IMU intrinsic calibration was released.
28-
* **June 18, 2014** - Initial public release of the repository.
29-
30-
31-
## Authors
32-
* Paul Furgale
33-
* Hannes Sommer
34-
* Jérôme Maye
35-
* Jörn Rehder
36-
* Thomas Schneider ([email](thomas.schneider@voliro.com))
37-
* Luc Oth
386

7+
Kalibr2 is a camera calibration toolbox that provides:
8+
9+
- **Multi-Camera Calibration**: Intrinsic and extrinsic calibration of multi-camera systems with support for various camera models (pinhole, omni-directional, EUCM, double sphere)
10+
- **ROS 2 Integration**: Native support for ROS 2
11+
- **Modern C++**: Built with C++17 and modern CMake practices
12+
13+
This is a modernized version based on the original [Kalibr](https://github.com/ethz-asl/kalibr) calibration toolbox developed at ETH Zurich.
14+
15+
## Build it using docker
16+
17+
```bash
18+
cd docker/
19+
docker compose build kalibr2_ros
20+
docker compose run kalibr2_ros
21+
```
22+
23+
## Building on Ubuntu 24.04
24+
25+
### Prerequisites
26+
- **ROS 2 Jazzy Desktop** - Install following the [official ROS 2 installation instructions](https://docs.ros.org/en/jazzy/Installation.html)
27+
28+
### Install System Dependencies
29+
```bash
30+
# Install all required packages
31+
sudo apt update && sudo apt install -y $(cat /tmp/packages.txt)
32+
```
33+
34+
### Build
35+
```bash
36+
# Source ROS 2 environment
37+
source /opt/ros/jazzy/setup.bash
38+
39+
# Build with colcon
40+
colcon build
41+
42+
# Source the workspace
43+
source install/setup.bash
44+
```
45+
46+
## Usage
47+
48+
### Camera Calibration
49+
```bash
50+
# Calibrate cameras from a ROS 2 bag file
51+
ros2 run kalibr2_ros kalibr_calibrate_cameras \
52+
--config path/to/calibration_config.yaml \
53+
--output-dir path/to/output/directory
54+
```
55+
56+
### Calibration file example
57+
58+
```yaml
59+
board:
60+
target_type: 'aprilgrid' # grid type
61+
tagCols: 6 # number of apriltags in the x direction
62+
tagRows: 5 # number of apriltags in the y direction
63+
tagSize: 0.088 # size of apriltag, edge to edge [m]
64+
tagSpacing: 0.2954 # ratio of space between tags to tagSize
65+
66+
cameras:
67+
camera_1_name:
68+
model: 'pinhole-radtan'
69+
focal_length_fallback: 881.0
70+
source:
71+
rosbag_path: '/path/to/your.mcap'
72+
topic: '/camera_1_topic/image'
73+
camera_2_topic:
74+
model: 'pinhole-radtan'
75+
focal_length_fallback: 881.0
76+
source:
77+
rosbag_path: '/path/to/your.mcap'
78+
topic: '/camera_2_topic/image'
79+
```
80+
81+
### Output files
82+
Calibration results are exported as:
83+
- `calibration_camera_name.yaml` - Camera intrinsics in ROS CameraInfo format
84+
- `transform_camera_0_to_camera_1.yaml` - Extrinsic transform (for 2-camera systems)
85+
- `camera_chain_transforms.yaml` - All extrinsic transforms in TF2 format (for multi-camera systems)
3986

4087
## References
41-
The calibration approaches used in Kalibr are based on the following papers. Please cite the appropriate papers when using this toolbox or parts of it in an academic publication.
4288

43-
1. <a name="joern1"></a>Joern Rehder, Janosch Nikolic, Thomas Schneider, Timo Hinzmann, Roland Siegwart (2016). Extending kalibr: Calibrating the extrinsics of multiple IMUs and of individual axes. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pp. 4304-4311, Stockholm, Sweden.
44-
1. <a name="paul1"></a>Paul Furgale, Joern Rehder, Roland Siegwart (2013). Unified Temporal and Spatial Calibration for Multi-Sensor Systems. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Tokyo, Japan.
45-
1. <a name="paul2"></a>Paul Furgale, T D Barfoot, G Sibley (2012). Continuous-Time Batch Estimation Using Temporal Basis Functions. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pp. 2088–2095, St. Paul, MN.
46-
1. <a name="jmaye"></a> J. Maye, P. Furgale, R. Siegwart (2013). Self-supervised Calibration for Robotic Systems, In Proc. of the IEEE Intelligent Vehicles Symposium (IVS)
47-
1. <a name="othlu"></a>L. Oth, P. Furgale, L. Kneip, R. Siegwart (2013). Rolling Shutter Camera Calibration, In Proc. of the IEEE Computer Vision and Pattern Recognition (CVPR)
89+
The calibration approaches in Kalibr2 are based on the original Kalibr toolbox. Please cite the appropriate papers when using this toolbox in academic work:
90+
91+
1. Paul Furgale, Joern Rehder, Roland Siegwart (2013). Unified Temporal and Spatial Calibration for Multi-Sensor Systems. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Tokyo, Japan.
92+
2. Paul Furgale, T D Barfoot, G Sibley (2012). Continuous-Time Batch Estimation Using Temporal Basis Functions. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pp. 2088–2095, St. Paul, MN.
4893

49-
## Acknowledgments
50-
This work is supported in part by the European Union's Seventh Framework Programme (FP7/2007-2013) under grants #269916 (V-Charge), and #610603 (EUROPA2).
94+
## Original Kalibr Authors
95+
- Paul Furgale
96+
- Hannes Sommer
97+
- Jérôme Maye
98+
- Jörn Rehder
99+
- Thomas Schneider
100+
- Luc Oth
51101

52102
## License (BSD)
53103
Copyright (c) 2014, Paul Furgale, Jérôme Maye and Jörn Rehder, Autonomous Systems Lab, ETH Zurich, Switzerland<br>

aslam_cv/aslam_cameras/src/GridDetector.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <sm/logging.hpp>
99
#include <aslam/cameras/GridDetector.hpp>
1010

11+
#include <chrono>
12+
1113
namespace aslam {
1214
namespace cameras {
1315

@@ -90,22 +92,23 @@ bool GridDetector::findTarget(const cv::Mat & image,
9092
}
9193

9294
bool GridDetector::findTargetNoTransformation(const cv::Mat & image, const aslam::Time & stamp,
93-
GridCalibrationTargetObservation & outObservation) const {
95+
GridCalibrationTargetObservation & outObservation) const {
9496
bool success = false;
9597

9698
// Extract the calibration target corner points
9799
Eigen::MatrixXd cornerPoints;
98100
std::vector<bool> validCorners;
101+
99102
success = _target->computeObservation(image, cornerPoints, validCorners);
100103

101104
// Set the image, target, and timestamp regardless of success.
102105
outObservation.setTarget(_target);
103106
outObservation.setImage(image);
104107
outObservation.setTime(stamp);
105108

106-
// Set the observed corners in the observation
107-
for (int i = 0; i < cornerPoints.rows(); i++) {
108-
if (validCorners[i])
109+
// time the loop that updates observed corners
110+
for (int i = 0; i < cornerPoints.rows(); ++i) {
111+
if (i < static_cast<int>(validCorners.size()) && validCorners[i])
109112
outObservation.updateImagePoint(i, cornerPoints.row(i).transpose());
110113
}
111114

@@ -133,7 +136,7 @@ bool GridDetector::findTarget(const cv::Mat & image, const aslam::Time & stamp,
133136
//calculate reprojection errors
134137
auto compute_stats = [&](double &mean, double &std, Eigen::MatrixXd &reprojection_errors_norm,
135138
std::vector<cv::Point2f> &corners_reproj, std::vector<cv::Point2f> &corners_detected) {
136-
139+
137140
corners_reproj.clear();
138141
corners_detected.clear();
139142
outObservation.getCornerReprojection(_geometry, corners_reproj);
@@ -211,17 +214,17 @@ bool GridDetector::findTarget(const cv::Mat & image, const aslam::Time & stamp,
211214
Eigen::MatrixXd reprojection_errors_norm;
212215
std::vector<cv::Point2f> corners_reproj, corners_detected;
213216
compute_stats(mean, std, reprojection_errors_norm, corners_reproj, corners_detected);
214-
217+
215218
// show the on the rendered image
216219
auto format_str = [](double data) {
217220
std::ostringstream ss;
218221
ss << std::setprecision(3) << data;
219222
return ss.str();
220223
};
221-
cv::putText(imageCopy1, "reproj err mean: " + format_str(mean),
224+
cv::putText(imageCopy1, "reproj err mean: " + format_str(mean),
222225
cv::Point(50, 50), cv::FONT_HERSHEY_SIMPLEX, 0.8,
223226
CV_RGB(0,255,0), 3, 8, false);
224-
cv::putText(imageCopy1, "reproj err std: " + format_str(std),
227+
cv::putText(imageCopy1, "reproj err std: " + format_str(std),
225228
cv::Point(50, 100), cv::FONT_HERSHEY_SIMPLEX, 0.8,
226229
CV_RGB(0,255,0), 3, 8, false);
227230

0 commit comments

Comments
 (0)