1 #ifndef __BASE_SAMPLES_DISTANCE_IMAGE_H__ 2 #define __BASE_SAMPLES_DISTANCE_IMAGE_H__ 4 #include <base/Time.hpp> 5 #include <base/Eigen.hpp> 8 #include <boost/math/special_functions/fpclassify.hpp> 56 DistanceImage(): width(0), height(0), scale_x(1.0), scale_y(1.0), center_x(0.0), center_y(0.0)
60 DistanceImage(uint16_t width, uint16_t height): width(width), height(height), scale_x(1.0), scale_y(1.0), center_x(0.0), center_y(0.0)
79 template <
class Scalar_>
80 bool getScenePoint(
size_t x,
size_t y, Eigen::Matrix<Scalar_,3,1>& point )
const 83 if( (x >= width) || (y >= height) )
87 const scalar d = data[width*y+x];
88 if( boost::math::isnormal( d ) )
90 point = Eigen::Matrix<Scalar_,3,1>( (x*
scale_x)+center_x, (y*scale_y)+
center_y, 1.0 );
103 template <
class Scalar_>
104 bool getImagePoint(
const Eigen::Matrix<Scalar_,3,1>& point,
size_t &x,
size_t &y )
const 109 size_t u = ((point.x() / point.z()) - center_x) /
scale_x;
110 size_t v = ((point.y() / point.z()) - center_y) /
scale_y;
113 if( (u >= width) || (v >=
height) )
142 template <
class Scalar_>
147 Eigen::Matrix<Scalar_,3,3> result;
165 void setIntrinsic(
double f_x,
double f_y,
double c_x,
double c_y );
175 void setSize( uint16_t width, uint16_t height );
DistanceImage(uint16_t width, uint16_t height)
Definition: DistanceImage.hpp:60
bool getScenePoint(size_t x, size_t y, Eigen::Matrix< Scalar_, 3, 1 > &point) const
Definition: DistanceImage.hpp:80
bool getImagePoint(const Eigen::Matrix< Scalar_, 3, 1 > &point, size_t &x, size_t &y) const
Definition: DistanceImage.hpp:104
uint16_t height
height (y) value in pixels
Definition: DistanceImage.hpp:40
scalar scale_y
scale value to apply to the y axis
Definition: DistanceImage.hpp:46
Definition: Pointcloud.hpp:13
void setSize(uint16_t width, uint16_t height)
set the size of the distance image
Definition: DistanceImage.cpp:39
void clear()
Definition: DistanceImage.cpp:8
Eigen::Matrix< Scalar_, 3, 3 > getIntrinsic() const
Definition: DistanceImage.hpp:143
void setIntrinsic(double f_x, double f_y, double c_x, double c_y)
set the intrinsic camera parameters.
Definition: DistanceImage.cpp:31
uint16_t width
width (x) value in pixels
Definition: DistanceImage.hpp:38
scalar scale_x
scale value to apply to the x axis
Definition: DistanceImage.hpp:44
scalar center_x
center offset to apply to the x axis
Definition: DistanceImage.hpp:49
base::Time time
original timestamp of the camera image
Definition: DistanceImage.hpp:35
DistanceImage()
Definition: DistanceImage.hpp:56
Definition: LinearAngular6DCommand.hpp:8
scalar center_y
center offset to apply to the y axis
Definition: DistanceImage.hpp:51
std::vector< scalar > data
distance values stored in row major order. NaN is used as the no value type.
Definition: DistanceImage.hpp:54
Definition: DistanceImage.hpp:32
float scalar
Definition: DistanceImage.hpp:42
base::samples::Pointcloud getPointCloud() const
Definition: DistanceImage.cpp:13