base
Public Types | Public Member Functions | Public Attributes | List of all members
base::samples::DistanceImage Struct Reference

#include <DistanceImage.hpp>

Public Types

typedef float scalar
 

Public Member Functions

 DistanceImage ()
 
 DistanceImage (uint16_t width, uint16_t height)
 
void clear ()
 
template<class Scalar_ >
bool getScenePoint (size_t x, size_t y, Eigen::Matrix< Scalar_, 3, 1 > &point) const
 
template<class Scalar_ >
bool getImagePoint (const Eigen::Matrix< Scalar_, 3, 1 > &point, size_t &x, size_t &y) const
 
base::samples::Pointcloud getPointCloud () const
 
template<class Scalar_ >
Eigen::Matrix< Scalar_, 3, 3 > getIntrinsic () const
 
void setIntrinsic (double f_x, double f_y, double c_x, double c_y)
 set the intrinsic camera parameters. More...
 
void setSize (uint16_t width, uint16_t height)
 set the size of the distance image More...
 

Public Attributes

base::Time time
 original timestamp of the camera image More...
 
uint16_t width
 width (x) value in pixels More...
 
uint16_t height
 height (y) value in pixels More...
 
scalar scale_x
 scale value to apply to the x axis More...
 
scalar scale_y
 scale value to apply to the y axis More...
 
scalar center_x
 center offset to apply to the x axis More...
 
scalar center_y
 center offset to apply to the y axis More...
 
std::vector< scalardata
 distance values stored in row major order. NaN is used as the no value type. More...
 

Detailed Description

2D array structure representing a distance image for a pinhole camera model.

The grid pixels are scaled such that (x*scale_x)+center_x = p_x are the projective plane coordinates given a grid index x. This of course applies to y as well.

The data array is a row major flattened version of the image matrix, giving the distance value d of the image points. The relation is such that for a point on the projection plane, the 3D point z can be calculated as (p_x,p_y,1)*d = z.

NOTE: unfortunately the scale and center is directly inverse to the convention used in: http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html for the time being, scale_x and scale_y are kept public for legacy code. It is recommended to use the functions operating on it instead.

Member Typedef Documentation

◆ scalar

Constructor & Destructor Documentation

◆ DistanceImage() [1/2]

base::samples::DistanceImage::DistanceImage ( )
inline

◆ DistanceImage() [2/2]

base::samples::DistanceImage::DistanceImage ( uint16_t  width,
uint16_t  height 
)
inline

Member Function Documentation

◆ clear()

void base::samples::DistanceImage::clear ( )

resets all values in the distance image to nan

◆ getImagePoint()

template<class Scalar_ >
bool base::samples::DistanceImage::getImagePoint ( const Eigen::Matrix< Scalar_, 3, 1 > &  point,
size_t &  x,
size_t &  y 
) const
inline

transforms a 3d scene point onto an image coordinate

Parameters
point- [in] 3d-scene point
x- [out] x image coordinate
y- [out] y image coordinate

◆ getIntrinsic()

template<class Scalar_ >
Eigen::Matrix<Scalar_,3,3> base::samples::DistanceImage::getIntrinsic ( ) const
inline

The intrinsic matrix has the following form

| f_x 0 c_x | | 0 f_y c_y | | 0 0 1 |

where f_x and f_y are the focal length expressed in pixel and c_x and c_y are the center in pixel. This matrix can be used to convert screen coordinates (x, y, z) into homogenous image coordinates (u, v, w) in the following way:

(u,v,w) = F * (x, y, z)

Note, that f and c are the inverse of the center and scale parameters.

Returns
the intrinsic camera matrix

◆ getPointCloud()

Pointcloud base::samples::DistanceImage::getPointCloud ( ) const

◆ getScenePoint()

template<class Scalar_ >
bool base::samples::DistanceImage::getScenePoint ( size_t  x,
size_t  y,
Eigen::Matrix< Scalar_, 3, 1 > &  point 
) const
inline

Transforms a x, y pixel coordinates into a 3d scene point, using the distance value of that point if available

Parameters
x- [in] x coordinate
y- [in] y coordinate
point- [out] resulting 3d scene point
Returns
true if the scene point has a corresponding distance value

◆ setIntrinsic()

void base::samples::DistanceImage::setIntrinsic ( double  f_x,
double  f_y,
double  c_x,
double  c_y 
)

set the intrinsic camera parameters.

see getIntrinsic() for a more detailed explanation.

Parameters
f_xfocal length in x
f_yfocal length in y
c_xcenter point in x
c_ycenter point in y

◆ setSize()

void base::samples::DistanceImage::setSize ( uint16_t  width,
uint16_t  height 
)

set the size of the distance image

This will also rescale the internal data array to hold the appropriate number of pixels.

Parameters
widthwidth of the image
heightheight of the image

Member Data Documentation

◆ center_x

scalar base::samples::DistanceImage::center_x

center offset to apply to the x axis

◆ center_y

scalar base::samples::DistanceImage::center_y

center offset to apply to the y axis

◆ data

std::vector<scalar> base::samples::DistanceImage::data

distance values stored in row major order. NaN is used as the no value type.

◆ height

uint16_t base::samples::DistanceImage::height

height (y) value in pixels

◆ scale_x

scalar base::samples::DistanceImage::scale_x

scale value to apply to the x axis

◆ scale_y

scalar base::samples::DistanceImage::scale_y

scale value to apply to the y axis

◆ time

base::Time base::samples::DistanceImage::time

original timestamp of the camera image

◆ width

uint16_t base::samples::DistanceImage::width

width (x) value in pixels


The documentation for this struct was generated from the following files: