Consumer-grade color cameras suffer from significant optical nonlinearities, often referred to as vignetting effects. For example, in Asus Xtion Pro Live cameras the pixels in the corners are two times darker than those in the center of the image. The vignetting effects in Intel RealSense cameras are less severe, but are still noticeable, as can be seen below:
Luckily, it is possible to calibrate the camera and remove the effects from the images:
This repository contains a collection of apps to calibrate radiometric and vignetting responses of a camera and a runtime library that you can link into your project to load calibration files and radiometrically rectify the images delivered by the camera.
You need a compiler that supports C++11.
- OpenCV (2 or 3)
- OpenCV (2 or 3)
- Boost
- OpenNI2 (optional, only if you want to calibrate an Asus Xtion camera)
- librealsense (optional, only if you want to calibrate a RealSense camera)
- Pylon SDK (optional, only if you want to calibrate a Pylon camera)
- Ceres (optional, needed for radiometric calibration with Debevec method and for vignetting calibration with polynomial vignetting model)
-
Clone this repository.
-
Configure the project. By default, both runtime library and calibration apps will be built. If only the runtime library is needed, then configure as follows:
cmake .. -DBUILD_APPS=OFF
Note that if you want to enable support for Debevec camera response function calibration and fitting of polynomial vignetting model in the calibration app, you need to tell CMake where Ceres is installed:
cmake .. -DCeres_DIR=<CERES_INSTALL_PATH>/share/Ceres
-
Install the project with
make install
.
In order to radiometrically rectify images (e.g. invert the non-linear camera response function and correct the vignetting effects), one needs to calibrate the camera. Refer to the instructions below:
In your CMakeLists.txt find the library as follows:
find_package(radical CONFIG REQUIRED)
And link it to your target:
target_link_libraries(your_target radical)
When configuring your project provide the path where radical was installed:
cmake .. -Dradical_DIR=<RADICAL_INSTALL_PATH>/lib/cmake/radical
In you app include the headers:
#include <radical/radiometric_response.h>
#include <radical/vignetting_response.h>
Load calibration files:
radical::RadiometricResponse rr("calibration-file-path.crf");
radical::VignettingResponse vr("calibration-file-path.vgn");
Undo vignetting effects in frames coming from the camera:
cv::Mat frame; // color image from the camera
cv::Mat irradiance, radiance; // temporary storage
cv::Mat frame_corrected; // output image with vignette removed
rr.inverseMap(frame, irradiance);
vr.remove(irradiance, radiance);
rr.directMap(radiance, frame_corrected);
If you use this in the academic context, please cite the following paper:
Calibration and Correction of Vignetting Effects with an Application to 3D Mapping, S. V. Alexandrov, J. Prankl, M. Zillich, M. Vincze, IROS'16
MIT