base
|
#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< scalar > | data |
distance values stored in row major order. NaN is used as the no value type. More... | |
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.
typedef float base::samples::DistanceImage::scalar |
|
inline |
|
inline |
void base::samples::DistanceImage::clear | ( | ) |
resets all values in the distance image to nan
|
inline |
transforms a 3d scene point onto an image coordinate
point | - [in] 3d-scene point |
x | - [out] x image coordinate |
y | - [out] y image coordinate |
|
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.
Pointcloud base::samples::DistanceImage::getPointCloud | ( | ) | const |
|
inline |
Transforms a x, y pixel coordinates into a 3d scene point, using the distance value of that point if available
x | - [in] x coordinate |
y | - [in] y coordinate |
point | - [out] resulting 3d scene point |
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.
f_x | focal length in x |
f_y | focal length in y |
c_x | center point in x |
c_y | center point in y |
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.
width | width of the image |
height | height of the image |
scalar base::samples::DistanceImage::center_x |
center offset to apply to the x axis
scalar base::samples::DistanceImage::center_y |
center offset to apply to the y axis
std::vector<scalar> base::samples::DistanceImage::data |
distance values stored in row major order. NaN is used as the no value type.
uint16_t base::samples::DistanceImage::height |
height (y) value in pixels
scalar base::samples::DistanceImage::scale_x |
scale value to apply to the x axis
scalar base::samples::DistanceImage::scale_y |
scale value to apply to the y axis
base::Time base::samples::DistanceImage::time |
original timestamp of the camera image
uint16_t base::samples::DistanceImage::width |
width (x) value in pixels