37#ifndef PCL_DISPARITY_MAP_CONVERTER_IMPL_H_
38#define PCL_DISPARITY_MAP_CONVERTER_IMPL_H_
40#include <pcl/common/intensity.h>
41#include <pcl/console/print.h>
42#include <pcl/stereo/disparity_map_converter.h>
48template <
typename Po
intT>
61template <
typename Po
intT>
65template <
typename Po
intT>
72template <
typename Po
intT>
79template <
typename Po
intT>
86template <
typename Po
intT>
93template <
typename Po
intT>
100template <
typename Po
intT>
107template <
typename Po
intT>
114template <
typename Po
intT>
121template <
typename Po
intT>
124 const float disparity_threshold_min)
129template <
typename Po
intT>
136template <
typename Po
intT>
139 const float disparity_threshold_max)
144template <
typename Po
intT>
151template <
typename Po
intT>
165template <
typename Po
intT>
171 return image_pointer;
174template <
typename Po
intT>
178 std::fstream disparity_file;
181 disparity_file.open(file_name.c_str(), std::fstream::in);
182 if (!disparity_file.is_open()) {
183 PCL_ERROR(
"[pcl::DisparityMapConverter::loadDisparityMap] Can't load the file.\n");
194 disparity_file >> disparity;
203template <
typename Po
intT>
206 const std::size_t width,
207 const std::size_t height)
217template <
typename Po
intT>
220 const std::vector<float>& disparity_map)
225template <
typename Po
intT>
228 const std::vector<float>& disparity_map,
229 const std::size_t width,
230 const std::size_t height)
238template <
typename Po
intT>
245template <
typename Po
intT>
256 PCL_ERROR(
"[pcl::DisparityMapConverter::compute] Memory for the image was not "
275 intensity_accessor.
set(new_point,
276 static_cast<float>((*
image_)[disparity_point].r +
277 (*
image_)[disparity_point].g +
278 (*
image_)[disparity_point].b) /
287 new_point.x = point_3D.x;
288 new_point.y = point_3D.y;
289 new_point.z = point_3D.z;
292 new_point.x = std::numeric_limits<float>::quiet_NaN();
293 new_point.y = std::numeric_limits<float>::quiet_NaN();
294 new_point.z = std::numeric_limits<float>::quiet_NaN();
297 out_cloud[disparity_point] = new_point;
302template <
typename Po
intT>
306 float disparity)
const
311 if (disparity != 0.0f) {
315 point_3D.z = z_value;
323#define PCL_INSTANTIATE_DisparityMapConverter(T) \
324 template class PCL_EXPORTS pcl::DisparityMapConverter<T>;
std::vector< float > disparity_map_
float getBaseline() const
Get baseline.
float focal_length_
Focal length.
std::vector< float > getDisparityMap()
Get the disparity map.
pcl::PointCloud< pcl::RGB >::ConstPtr image_
Color image of the scene.
pcl::PointCloud< PointT > PointCloud
float disparity_threshold_max_
float getImageCenterY() const
Get y-coordinate of the image center.
void setDisparityThresholdMax(const float disparity_threshold_max)
Set max disparity threshold.
float getImageCenterX() const
Get x-coordinate of the image center.
void setImage(const pcl::PointCloud< pcl::RGB >::ConstPtr &image)
Set an image, that will be used for coloring of the output cloud.
PointXYZ translateCoordinates(std::size_t row, std::size_t column, float disparity) const
Translate point from image coordinates and disparity to 3D-coordinates.
pcl::PointCloud< RGB >::Ptr getImage()
Get the image, that is used for coloring of the output cloud.
virtual void compute(PointCloud &out_cloud)
Compute the output cloud.
bool loadDisparityMap(const std::string &file_name)
Load the disparity map.
void setImageCenterX(const float center_x)
Set x-coordinate of the image center.
virtual ~DisparityMapConverter()
Empty destructor.
DisparityMapConverter()
DisparityMapConverter constructor.
std::size_t disparity_map_height_
Y-size of the disparity map.
float center_y_
Y-coordinate of the image center.
void setDisparityMap(const std::vector< float > &disparity_map)
Set the disparity map.
bool is_color_
Is color image is set.
void setDisparityThresholdMin(const float disparity_threshold_min)
Set min disparity threshold.
float getDisparityThresholdMax() const
Get max disparity threshold.
float getDisparityThresholdMin() const
Get min disparity threshold.
void setBaseline(const float baseline)
Set baseline.
float getFocalLength() const
Get focal length.
void setFocalLength(const float focal_length)
Set focal length.
float center_x_
X-coordinate of the image center.
std::size_t disparity_map_width_
X-size of the disparity map.
float disparity_threshold_min_
Thresholds of the disparity.
void setImageCenterY(const float center_y)
Set y-coordinate of the image center.
PointCloud represents the base class in PCL for storing collections of 3D points.
void resize(std::size_t count)
Resizes the container to contain count elements.
std::uint32_t width
The point cloud width (if organized as an image-structure).
std::uint32_t height
The point cloud height (if organized as an image-structure).
void clear()
Removes all points in a cloud and sets the width and height to 0.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
Defines all the PCL implemented PointT point type structures.
A point structure representing Euclidean xyz coordinates.
void set(PointT &p, float intensity) const
sets the intensity value of a point