Skip to content

5p6/d2c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1.introduction

This is a method for calibrating and aligning RGBD cameras.

2.Environment

  • ubuntu 22.04
  • GNU Tools 11.x
  • OpenCV 4.x
  • Eigen 3.x
  • Boost

3.Example

calib --> align

3.1 build

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

3.2 calibration

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

3.3 align

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.

Appendix

The goal of alignmentis to convert ( u i r , v i r ) to ( u r g b , v r g b ) ,as

H ( u i r , v i r ) = ( u r g b , v r g b )

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 :

[ u r g b   v r g b   1 ] = 1 Z r g b K r g b [ R r g b | t r g b ] [ X w   Y w   Z w   1 ]

ir :

[ u i r   v i r   1 ] = 1 Z i r K i r [ R i r | t i r ] [ X w   Y w   Z w   1 ]

The mathematical formula above allows for simultaneous equations,Assuming M r g b , M i r is a three-dimensional point in the coordinate system of relative camera RGB and depth

{ M r g b = [ R r g b | t r g b ] [ X w   Y w   Z w   1 ] = R r g b M w + t r g b M i r = [ R i r | t i r ] [ X w   Y w   Z w   1 ] = R i r M w + t i r

which

M w = [ X w   Y w   Z w ] , M r g b = [ X r g b   Y r g b   Z r g b ] , M i r = [ X i r   Y i r   Z i r ]

We can obtain the following equation from equation (3)

M i r = R i r R r g b T M r g b + t i r R i r R r g b T t r g b

Convert the factors in the above equation into the following parameters

{ R = R i r R r g b T t = t i r R i r R r g b T t r g b

Or convert it into the following equation

{ M r g b = R M i r + t R = R r g b R i r T t = t r g b R r g b T R i r t i r

then we could get M i r like

M i r = [ d ( u i r c x i r ) f x i r   d ( v i r c y i r ) f y i r   d ]

and convert the M i r to u r g b , v r g b ,

u r g b = f x r g b Z r g b X r g b + c x r g b v r g b = f y r g b Z r g b Y r g b + c y r g b

so we could convert ( u i r , v i r ) to ( u r g b , v r g b ) .To conclude,we

  • calibrate the rgb and ir camera,get data K r g b , R r g b , t r g b , K i r , R i r , t i r
  • calculate the R and t

{ R = R r g b R i r T t = t r g b R r g b R i r T t i r

  • calculate the Point M i r = ( X i r , Y i r , Z i r )

{ X i r = d ( u i r c x i r ) f x i r Y i r = d ( v i r c y i r ) f y i r Z i r = d M i r

  • calculate the Point M r g b = ( X r g b , Y r g b , Z r g b )

M r g b = R M i r + t

  • Finally, calculate the coordinates ( u r g b , v r g b )

u r g b = f x r g b Z r g b X r g b + c x r g b v r g b = f y r g b Z r g b Y r g b + c y r g b

remeber that Z r g b d .

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published