top of page
Search

Camcalib - Command Line Interface





This article will show you how to use camcalib command line interface to calibrate the intrinsic and extrinsics of a multi-camera setup using the latest camcalib release (1.7).

You can download the latest version here.


Motivation


Using a command-line tool for automating camera calibration offers advantages in terms of efficiency, accuracy, reproducibility, scalability, integration, and customization. It simplifies the calibration process, reduces manual effort, and enhances the overall quality of the calibration results.


  1. Efficiency: Automating the camera calibration process through a command-line tool allows you to streamline the calibration workflow and save time. With a single command, you can initiate the calibration process without the need for manual intervention or repetitive actions.

  2. Accuracy: Camera calibration is a precise task that requires careful measurement and calibration parameter estimation. By using a command-line tool, you can ensure consistency and accuracy in the calibration process, as it eliminates the potential for human error or inconsistencies between manual calibration attempts.

  3. Reproducibility: With a command-line tool, you can easily reproduce the camera calibration process on multiple datasets or in different environments. This reproducibility is crucial for researchers, developers, or anyone working on computer vision or robotics projects, as it enables consistent results across different scenarios.

  4. Scalability: Command-line tools offer scalability, allowing you to automate camera calibration across a large number of cameras or datasets. This is particularly useful in applications such as multi-camera systems or visual sensor networks, where calibrating each camera individually would be time-consuming and impractical.

  5. Integration with workflows: Command-line tools can be easily integrated into existing automation or scripting workflows. They can be invoked from scripts or incorporated into larger software pipelines, making it easier to incorporate camera calibration into a larger data processing or computer vision pipeline.

  6. Customizability: Command-line tools often provide a range of options and parameters that can be adjusted to fit specific calibration requirements. This flexibility allows you to fine-tune the calibration process based on your specific camera setup, distortion model, or application needs.


How-To:

We offer camcalib CLI for windows and linux. Please find introductory example for the two operating systems below:


Windows:

  • Data preparation (ROSBAG or Data folder c.f.)

  • Getting help

First you need to change the directory to the camcalib.exe path which is usually under C:\Program Files (x86)\



C:\Users\Nicolas\Desktop>cd C:\Program Files (x86)\camcalib\
C:\Program Files (x86)\camcalib>camcalib.exe --help
Failed to load Python extension for LZ4 support. LZ4 compression will not be available.
usage: camcalib.exe [-h] {intrinsic,extrinsic} data settings [--calib CALIB] [-o O] [-opdf [OPDF]] [-olog OLOG]

Run Script for cam imu calibration

positional arguments:
  {intrinsic,extrinsic}
                        calibration mode
  data                  data source (ROS1 bag or directory
  settings              choose a settings file

optional arguments:
  -h, --help            show this help message and exit
  --calib CALIB, -c CALIB
                        choose a calib file
  -o O                  choose a output for calibration file
  -opdf [OPDF]          choose a output PDF calibration report
  -olog OLOG            choose a output calibration log file
C:\Program Files (x86)\camcalib>
  • Prepare your calibration configuration as *.yaml file

    • Camera model

    • Sensors model

    • Calibration Target


EXAMPLE: Multi camera with a Inertial Measurement Unit


Download the data set from here and extract it somewhere to your hard drive.


We have prepared an example settings file:

calibration:
    constrain_cam_extrinsics: false
    constrain_gravity: false
    gravity_norm: 9.806
    optimize_object_points: false
sensors:
    cams:
        '4103461409': KannalaBrandt
        '4103479456': KannalaBrandt
        '4103479460': KannalaBrandt
        '4103479461': KannalaBrandt
targets:
    - type: CharucoBoard
      properties:
        columns: 5
        rows: 7
        square_size: 0.055
        marker_size: 0.033
        marker_type: C6x6
      detection_error: 0.2

Now save this file somewhere on your hard drive as multicam.yaml


If you want to calibrate also IMUs this is possible by adding the imu with the noise parameters.

    cams:
        camera_16360206/pg_16360206/image_raw: KannalaBrandt
        camera_17082035/pg_17082035/image_raw: KannalaBrandt
        camera_18166571/pg_18166571/image_raw: KannalaBrandt
        camera_18166924/pg_18166924/image_raw: KannalaBrandt
    imus:
        xsens_imu/data:
            noise: {gyro: 0.0017, accel: 0.022}

where the sensor name is either the topic in rosbag (without the leading slash) or the relative folder path of the sensor data.


Supported camera models are Pinhole, PinholeRadTan, KannalaBrandt and DoubleSphere.

Possible calibration targets are either CharucoBoard or AprilBoard as you already know from the user interface.

These are some examples on how to define the boards for the settings file:

- type: CharucoBoard
      properties:
        columns: 5
        rows: 7
        square_size: 0.055
        marker_size: 0.033
        marker_type: C6x6
      detection_error: 0.2
    - type: AprilBoard
      properties:
          rows: 6
          columns: 6
          tag_size: 0.08
          tag_spacing: 0.3
      detection_error: 0.2

Intrinsic

Now you can calibrate the cameras intrinsically with the following command:

C:\Program Files (x86)\camcalib>camcalib.exe intrinsic C:\PATH\TO\multicam C:\PATH\TO\multicam.yaml
2023-05-10 15:17:16,732 INFO     Loading calibration data. 2023-05-10 15:17:16,733 INFO     Writing log messages to C:\PATH\TO\2023-02-09_10-42-49_281231\intrinsic_calibration_2023-05-10_15-17-16.log 2023-05-10 2023-05-10 15:17:16,736 INFO     Writing calibration result to C:\PATH\TO\2023-02-09_10-42-49_281231\intrinsic_result_2023-05-10_15-17-16.yaml 
...
2023-05-10 15:17:17,744 INFO     Use the following settings: 2023-05-10 15:17:17,744 INFO     constrain_cam_extrinsics: False 2023-05-10 15:17:17,753 INFO     constrain_gravity: False 2023-05-10 15:17:17,762 INFO     gravity_norm: 9.806 2023-05-10 15:17:17,770 INFO     optimize_object_points: False 2023-05-10 15:17:18,746 INFO     Processed 4103461409... 2023-05-10 15:17:19,615 INFO     Processed 4103479456... 2023-05-10 15:17:20,500 INFO     Processed 4103479460... 2023-05-10 15:17:21,100 INFO     Processed 4103479461... 2023-05-10 15:17:21,102 INFO     Saving processed data to C:\PATH\TO\2023-02-09_10-42-49_281231\ 2023-05-10 15:17:21,102 INFO     Loading cam data... 2023-05-10 15:17:21,103 INFO     Saving 4103461409 data... 2023-05-10 15:17:21,230 INFO     Saving 4103479456 data... 2023-05-10 15:17:21,321 INFO     Saving 4103479460 data... 2023-05-10 15:17:21,418 INFO     Saving 4103479461 data...
2023-05-10 15:17:21,526 INFO     Data saved. 2023-05-10 15:17:21,526 INFO     Provide the folder C:\PATH\TO\2023-02-09_10-42-49_281231\2023-05-10_15-17-17_777143 if you want to skip the target extraction. 2023-05-10 15:17:21,528 INFO     Start intrinsic calibration
...

Extrinsic

After the intrinsic calibration we can calibrate the extrinsic parameters of the cameras with the following command:


C:\Program Files (x86)\camcalib>camcalib.exe extrinsic C:\PATH\TO\multicam C:\PATH\TO\multicam.yaml --calib  

In addition to the dataset and the settings file, we have to provide the intrinsic calibration file. You can find the data file path from the console logs above:

2023-05-10 15:17:16,736 INFO     Writing calibration result to C:\PATH\TO\2023-02-09_10-42-49_281231\intrinsic_result_2023-05-10_15-17-16.yaml

If you use the same data for intrinsic and extrinsic calibration you can skip the feature extraction step by providing the processed data path that you can find in the logs.

2023-05-10 15:17:21,102 INFO     Saving processed data to C:\PATH\TO\2023-02-09_10-42-49_281231\

This produces the following output:


C:\Program Files (x86)\camcalib>camcalib.exe extrinsic C:\PATH\TO\2023-02-09_10-42-49_281231\2023-05-10_15-17-17_777143\ C:\PATH\TO\RHI_cli.yaml --calib C:\PATH\TO\2023-02-09_10-42-49_281231\intrinsic_result_2023-05-10_15-17-16.yaml

Failed to load Python extension for LZ4 support. LZ4 compression will not be available. 2023-05-10 16:08:57,664 INFO     Loading calibration data. 2023-05-10 16:08:57,665 INFO     Writing log messages to C:\PATH\TO\2023-02-09_10-42-49_281231\2023-05-10_15-17-17_777143\extrinsic_calibration_2023-05-10_16-08-57.log 2023-05-10 16:08:57,670 INFO     Writing calibration result to C:\PATH\TO\2023-02-09_10-42-49_281231\2023-05-10_15-17-17_777143\extrinsic_result_2023-05-10_16-08-57.yaml Loading 4103479461 data...
2023-05-10 16:08:58,193 INFO     Use the following settings: 2023-05-10 16:08:58,195 INFO     constrain_cam_extrinsics: False 2023-05-10 16:08:58,196 INFO     constrain_gravity: False 2023-05-10 16:08:58,197 INFO     gravity_norm: 9.806 2023-05-10 16:08:58,198 INFO     optimize_object_points: False 2023-05-10 16:09:01,053 INFO     Start optimizer 2023-05-10 16:09:01,107 INFO      
...
16:09:02,138 INFO     Reproj. error: 0.142 
C:\Program Files (x86)\camcalib>

If you want to specify the file path for the calibration YAML, log file or PDF report, you can do so by adding the following arguments


  -o O                  choose a output for calibration file
  -opdf [OPDF]          choose a output PDF calibration report
  -olog OLOG            choose a output calibration log file


Linux:


The command line interface works the same as for windows.

But instead of executing the camcalib.exe you pass the arguments either directly to the camcalib AppImage or



iviso@ubuntu:~/$ ./camcalib-latest-x86_64.AppImage intrinsic /PATH/TO/multicam /PATH/TO/multicam.yaml


Each call will take some time because the AppImage has to be extracted to the hard drive.

In order to sidestep this, you can extract the AppImage once and for all using this command:

iviso@ubuntu:~/$ ./camcalib-latest-x86_64.AppImage --appimage-extract

After that you will find a folder called squashfs-root and in that folder there will be an executable with the name ./AppRun Now simply run camcalib from terminal using


iviso@ubuntu:~/$ ./squashfs-root/AppRun intrinsic /PATH/TO/multicam /PATH/TO/multicam.yaml

This will produce the following output as before:


2023-05-11 13:49:04,932 INFO     Loading calibration data.
2023-05-11 13:49:04,932 INFO     Writing log messages to /PATH/TO/mulicam/intrinsic_calibration_2023-05-11_13-49-04.log
2023-05-11 13:49:04,933 INFO     Writing calibration result to /PATH/TO/mulicam/intrinsic_result_2023-05-11_13-49-04.yaml
Loading 4103479461 data...: 100%|█████████████████████| 100/100 [00:00<00:00, 106.24it/s]
2023-05-11 13:49:05,879 INFO     Use the following settings: 
2023-05-11 13:49:05,880 INFO     constrain_cam_extrinsics: False
2023-05-11 13:49:05,880 INFO     constrain_gravity: False
2023-05-11 13:49:05,880 INFO     gravity_norm: 9.806
2023-05-11 13:49:05,880 INFO     optimize_object_points: False
2023-05-11 13:49:05,880 INFO     Start intrinsic calibration
2023-05-11 13:49:06,040 INFO     Optimize for camera 4103461409
2023-05-11 13:49:06,061 INFO     Initial error: 2.013
RMSE error: 0.05416096257642151:  25%|████▌             | 25/100 [00:01<00:03, 23.83it/s]
2023-05-11 13:49:07,169 INFO     Reproj. error: 0.070
2023-05-11 13:49:07,298 INFO     Optimize for camera 4103479456
2023-05-11 13:49:07,319 INFO     Initial error: 2.093
RMSE error: 0.08784144783266151:  11%|█▉                | 11/100 [00:00<00:03, 25.88it/s]
2023-05-11 13:49:07,801 INFO     Reproj. error: 0.113
2023-05-11 13:49:08,490 INFO     Optimize for camera 4103479460
2023-05-11 13:49:08,511 INFO     Initial error: 1.623
RMSE error: 0.07272103997542695:  25%|████▌             | 25/100 [00:00<00:02, 25.12it/s]
2023-05-11 13:49:09,565 INFO     Reproj. error: 0.091
2023-05-11 13:49:10,241 INFO     Optimize for camera 4103479461
2023-05-11 13:49:10,262 INFO     Initial error: 1.872
RMSE error: 0.07220945103297152:  26%|████▋             | 26/100 [00:01<00:02, 25.52it/s]
2023-05-11 13:49:11,339 INFO     Reproj. error: 0.091

If you have any questions, don't hesitate to contact us!




136 views0 comments

Comments


Post: Blog2_Post
bottom of page