This is a method for calibrating and aligning RGBD cameras.
- ubuntu 22.04
- GNU Tools 11.x
- OpenCV 4.x
- Eigen 3.x
- Boost
calib --> align
To satisfy the environment,run command
sudo apt install libopencv-dev \
libeigen3-dev \
libboost-all-dev \
build-essential \
cmake \
git
adn then clone the repository locally
git clone https://github.com/5p6/d2c.git
If the environment are linux,you need to change some varable in the CMakeLists
,which include the fmt and opencv path,the
cd project_path
and
bash build.sh
So you could make use of the executable file to calib
Run using the command line,for rgb images calibration
./build/rgbd_calib --rgb-dir /mnt/hgfs/share/dataset/calib/rgbd/calib/calib/rgb/ --depth-dir /mnt/hgfs/share/dataset/calib/rgbd/calib/calib/infrared/ -h 6 -w 7 -o . -s 20
this program will calculate the parameters,which needed by align program,those parameters will saved in align.yaml
,like
%YAML:1.0
---
rgbK: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 1.0330670202081678e+03, 0., 9.3046861250618576e+02, 0.,
1.0310455772701362e+03, 5.3662586300152179e+02, 0., 0., 1. ]
depthK: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 3.6013258447643722e+02, 0., 2.6048421452847896e+02, 0.,
3.5982078122427777e+02, 2.1293927876427088e+02, 0., 0., 1. ]
R: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 9.9976239492351493e-01, -7.7578583427777136e-03,
2.0370796025952997e-02, 7.8386493541675473e-03,
9.9996171422686042e-01, -3.8891717345808990e-03,
-2.0339844470890121e-02, 4.0479271747460499e-03,
9.9978492937855823e-01 ]
t: !!opencv-matrix
rows: 3
cols: 1
dt: d
data: [ 4.0526717379990224e+01, 3.5935658368717966e+00,
-4.0260805147425174e+00 ]
you could use the --help
option to check the help context,like
./build/rgbd_calib --help
Finally, the alignmentcommand is as follows
./build/rgbd_align -r /mnt/hgfs/share/dataset/calib/rgbd/calib/test/kehu/rgb.png -d /mnt/hgfs/share/dataset/calib/rgbd/calib/test/kehu/depth.png -p ./Register.yaml
align by inputting images, calibration parameters, and extrinsic data.This program will show the rgb image and aligned depth image.
The goal of alignmentis to convert
so we need to find H to satisfy the equation as (1).the specific principle of RGBD is introduced, and its mathematical formula is as follows.The projection equations for RGB cameras and depth cameras are as follows,rgb :
ir :
The mathematical formula above allows for simultaneous equations,Assuming
which
We can obtain the following equation from equation (3)
Convert the factors in the above equation into the following parameters
Or convert it into the following equation
then we could get
and convert the
so we could convert
- calibrate the rgb and ir camera,get data
- calculate the
and
- calculate the Point
- calculate the Point
- Finally, calculate the coordinates
remeber that