libfreenect2 0.4
Open source driver for the Kinect for Windows v2 (K4W2) sensor
Loading...
Searching...
No Matches

Combine frames of depth and color camera. More...

#include <libfreenect2/registration.h>

Public Member Functions

 Registration (Freenect2Device::IrCameraParams depth_p, Freenect2Device::ColorCameraParams rgb_p)
 ~Registration ()
void apply (int dx, int dy, float dz, float &cx, float &cy) const
 Undistort and register a single depth point to color camera.
void apply (const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter=true, Frame *bigdepth=0, int *color_depth_map=0) const
 Map color images onto depth images.
void undistortDepth (const Frame *depth, Frame *undistorted) const
 Undistort depth.
void getPointXYZRGB (const Frame *undistorted, const Frame *registered, int r, int c, float &x, float &y, float &z, float &rgb) const
 Construct a 3-D point with color in a point cloud.
void getPointXYZ (const Frame *undistorted, int r, int c, float &x, float &y, float &z) const
 Construct a 3-D point in a point cloud.

Detailed Description

Combine frames of depth and color camera.

Right now this class uses a reverse engineered formula that uses factory preset extrinsic parameters. We do not have a clear understanding of these particular extrinsic parameters and do not know how to calibrate them by hand.

If you want to perform registration with standard camera extrinsic matrix, you probably need something else.

Constructor & Destructor Documentation

◆ Registration()

Parameters
depth_pDepth camera parameters. You can use the factory values, or use your own.
rgb_pColor camera parameters. Probably use the factory values for now.

Referenced by getPointXYZ().

◆ ~Registration()

Member Function Documentation

◆ apply() [1/2]

void apply ( int dx,
int dy,
float dz,
float & cx,
float & cy ) const

Undistort and register a single depth point to color camera.

Parameters
dxDistorted depth coordinate x (pixel)
dyDistorted depth coordinate y (pixel)
dzDepth value (millimeter)
[out]cxUndistorted color coordinate x (normalized)
[out]cyUndistorted color coordinate y (normalized)

◆ apply() [2/2]

void apply ( const Frame * rgb,
const Frame * depth,
Frame * undistorted,
Frame * registered,
const bool enable_filter = true,
Frame * bigdepth = 0,
int * color_depth_map = 0 ) const

Map color images onto depth images.

Parameters
rgbColor image (1920x1080 BGRX or RGBX)
depthDepth image (512x424 float)
[out]undistortedUndistorted depth image (512x424 float)
[out]registeredColor image for the depth image (512x424); its format inherits rgb.
enable_filterFilter out pixels not visible to both cameras.
[out]bigdepthIf not NULL, return mapping of depth onto colors (1920x1082 float). 1082 not 1080, with a blank top and bottom row.
[out]color_depth_mapIndex of mapped color pixel for each depth pixel (512x424).

◆ undistortDepth()

void undistortDepth ( const Frame * depth,
Frame * undistorted ) const

Undistort depth.

Parameters
depthDepth image (512x424 float)
[out]undistortedUndistorted depth image

◆ getPointXYZRGB()

void getPointXYZRGB ( const Frame * undistorted,
const Frame * registered,
int r,
int c,
float & x,
float & y,
float & z,
float & rgb ) const

Construct a 3-D point with color in a point cloud.

Parameters
undistortedUndistorted depth frame from apply().
registeredRegistered color frame from apply().
rRow (y) index in depth image.
cColumn (x) index in depth image.
[out]xX coordinate of the 3-D point (meter).
[out]yY coordinate of the 3-D point (meter).
[out]zZ coordinate of the 3-D point (meter).
[out]rgbPacked color of the 3-D point in the registered frame's BGRX or RGBX channel order. To unpack BGRX data, use
const uint8_t *p = reinterpret_cast<uint8_t*>(&rgb);
uint8_t b = p[0];
uint8_t g = p[1];
uint8_t r = p[2];

◆ getPointXYZ()

void getPointXYZ ( const Frame * undistorted,
int r,
int c,
float & x,
float & y,
float & z ) const

Construct a 3-D point in a point cloud.

Parameters
undistortedUndistorted depth frame from apply().
rRow (y) index in depth image.
cColumn (x) index in depth image.
[out]xX coordinate of the 3-D point (meter).
[out]yY coordinate of the 3-D point (meter).
[out]zZ coordinate of the 3-D point (meter).

References Registration().