Point Cloud Library (PCL)  1.9.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
disparity_to_cloud.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id$
35  *
36  */
37 
38 #ifndef PCL_CUDA_DISPARITY_TO_CLOUD_H_
39 #define PCL_CUDA_DISPARITY_TO_CLOUD_H_
40 
41 #include <pcl/cuda/point_cloud.h>
42 #include <pcl/cuda/io/cloud_to_pcl.h>
43 #include <pcl/io/openni_camera/openni_image.h>
44 #include <pcl/io/openni_camera/openni_depth_image.h>
45 //#include <pcl/CameraInfo.h>
46 //#include <pcl/PCLImage.h>
47 
48 #include <boost/cstdint.hpp>
49 
50 namespace pcl
51 {
52 namespace cuda
53 {
54  /** \brief Compute the XYZ values for a point based on disparity information. */
55  struct ComputeXYZ
56  {
57  int width, height;
59  float constant;
60  float bad_point;
61 
62  ComputeXYZ (int w, int h, int cx, int cy, float con) :
63  width(w), height(h), center_x(cx), center_y(cy), constant(con)
64  {
65  bad_point = std::numeric_limits<float>::quiet_NaN ();
66  }
67 
68  template <typename Tuple> __inline__ __host__ __device__ PointXYZRGB
69  operator () (const Tuple &t);
70  };
71 
72  /** \brief Compute the XYZ and RGB values for a point based on disparity information. */
74  {
75  int width, height;
77  float constant;
78  float bad_point;
79 
80  ComputeXYZRGB (int w, int h, int cx, int cy, float con) :
81  width(w), height(h), center_x(cx), center_y(cy), constant(con)
82  {
83  bad_point = std::numeric_limits<float>::quiet_NaN ();
84  }
85 
86  template <typename Tuple> __inline__ __host__ __device__ PointXYZRGB
87  operator () (const Tuple &t);
88  };
89 
90  /** \brief Disparity to PointCloudAOS generator.
91  */
92  class PCL_EXPORTS DisparityToCloud
93  {
94  public:
95 // // compute using ROS images, Device output
96 // void
97 // compute (const pcl::PCLImage::ConstPtr &depth_image,
98 // const pcl::PCLImage::ConstPtr &rgb_image,
99 // const pcl::CameraInfo::ConstPtr &info,
100 // PointCloudAOS<Device>::Ptr &output);
101 //
102 // // compute using ROS images, Host output
103 // void
104 // compute (const pcl::PCLImage::ConstPtr &depth_image,
105 // const pcl::PCLImage::ConstPtr &rgb_image,
106 // const pcl::CameraInfo::ConstPtr &info,
107 // PointCloudAOS<Host>::Ptr &output);
108 
109  // compute using OpenNI images, Device output
110  template <template <typename> class Storage> void
111  compute (const boost::shared_ptr<openni_wrapper::DepthImage>& depth_image,
112  const boost::shared_ptr<openni_wrapper::Image>& image,
113  float constant,
114  typename PointCloudAOS<Storage>::Ptr &output,
115  bool downsample = false, int stride = 2, int smoothing_nr_iterations = 0, int smoothing_filter_size = 2);
116 
117  template <template <typename> class Storage> void
118  compute (const boost::uint16_t* depth_image,
119  const OpenNIRGB* rgb_image,
120  int width, int height,
121  float constant,
122  typename PointCloudAOS<Storage>::Ptr &output,
123  int smoothing_nr_iterations = 0, int smoothing_filter_size = 2);
124 
125  // compute using OpenNI images, Host output
126 /* void
127  compute (const boost::shared_ptr<openni_wrapper::DepthImage>& depth_image,
128  const boost::shared_ptr<openni_wrapper::Image>& image,
129  float constant,
130  PointCloudAOS<Host>::Ptr &output);*/
131 
132  // ...
133 // void
134 // compute (const pcl::PCLImage::ConstPtr &depth_image,
135 // const pcl::CameraInfo::ConstPtr &info,
136 // PointCloudAOS<Device>::Ptr &output);
137 //
138 // void
139 // compute (const pcl::PCLImage::ConstPtr &depth_image,
140 // const pcl::CameraInfo::ConstPtr &info,
141 // PointCloudAOS<Host>::Ptr &output);
142 
143  void
144  compute (const boost::shared_ptr<openni_wrapper::DepthImage>& depth_image,
145  float constant,
147 
148  void
149  compute (const boost::shared_ptr<openni_wrapper::DepthImage>& depth_image,
150  float constant,
151  PointCloudAOS<Host>::Ptr &output);
152  };
153 
154 } // namespace
155 } // namespace
156 
157 #endif //#ifndef PCL_CUDA_DISPARITY_TO_CLOUD_H_
ComputeXYZ(int w, int h, int cx, int cy, float con)
Disparity to PointCloudAOS generator.
Compute the XYZ and RGB values for a point based on disparity information.
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
ComputeXYZRGB(int w, int h, int cx, int cy, float con)
boost::shared_ptr< PointCloudAOS< Storage > > Ptr
Definition: point_cloud.h:201
Compute the XYZ values for a point based on disparity information.
__inline__ __host__ __device__ PointXYZRGB operator()(const Tuple &t)
Default point xyz-rgb structure.
Definition: point_types.h:49
__inline__ __host__ __device__ PointXYZRGB operator()(const Tuple &t)
Simple structure holding RGB data.
Definition: point_cloud.h:56