Point Cloud Library (PCL)  1.14.1-dev
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 #pragma once
39 
40 #include <pcl/cuda/point_cloud.h>
41 #include <pcl/cuda/io/cloud_to_pcl.h>
42 #include <pcl/io/openni_camera/openni_image.h>
43 #include <pcl/io/openni_camera/openni_depth_image.h>
44 //#include <pcl/CameraInfo.h>
45 //#include <pcl/PCLImage.h>
46 
47 #include <cstdint>
48 
49 namespace pcl
50 {
51 namespace cuda
52 {
53  /** \brief Compute the XYZ values for a point based on disparity information. */
54  struct ComputeXYZ
55  {
56  int width, height;
58  float constant;
59  float bad_point;
60 
61  ComputeXYZ (int w, int h, int cx, int cy, float con) :
62  width(w), height(h), center_x(cx), center_y(cy), constant(con)
63  {
64  bad_point = std::numeric_limits<float>::quiet_NaN ();
65  }
66 
67  template <typename Tuple> __inline__ __host__ __device__ PointXYZRGB
68  operator () (const Tuple &t);
69  };
70 
71  /** \brief Compute the XYZ and RGB values for a point based on disparity information. */
73  {
74  int width, height;
76  float constant;
77  float bad_point;
78 
79  ComputeXYZRGB (int w, int h, int cx, int cy, float con) :
80  width(w), height(h), center_x(cx), center_y(cy), constant(con)
81  {
82  bad_point = std::numeric_limits<float>::quiet_NaN ();
83  }
84 
85  template <typename Tuple> __inline__ __host__ __device__ PointXYZRGB
86  operator () (const Tuple &t);
87  };
88 
89  /** \brief Disparity to PointCloudAOS generator.
90  */
92  {
93  public:
94 // // compute using ROS images, Device output
95 // void
96 // compute (const pcl::PCLImage::ConstPtr &depth_image,
97 // const pcl::PCLImage::ConstPtr &rgb_image,
98 // const pcl::CameraInfo::ConstPtr &info,
99 // PointCloudAOS<Device>::Ptr &output);
100 //
101 // // compute using ROS images, Host output
102 // void
103 // compute (const pcl::PCLImage::ConstPtr &depth_image,
104 // const pcl::PCLImage::ConstPtr &rgb_image,
105 // const pcl::CameraInfo::ConstPtr &info,
106 // PointCloudAOS<Host>::Ptr &output);
107 
108  // compute using OpenNI images, Device output
109  template <template <typename> class Storage> void
111  const openni_wrapper::Image::Ptr& image,
112  float constant,
113  typename PointCloudAOS<Storage>::Ptr &output,
114  bool downsample = false, int stride = 2, int smoothing_nr_iterations = 0, int smoothing_filter_size = 2);
115 
116  template <template <typename> class Storage> void
117  compute (const std::uint16_t* depth_image,
118  const OpenNIRGB* rgb_image,
119  int width, int height,
120  float constant,
121  typename PointCloudAOS<Storage>::Ptr &output,
122  int smoothing_nr_iterations = 0, int smoothing_filter_size = 2);
123 
124  // compute using OpenNI images, Host output
125 /* void
126  compute (const openni_wrapper::DepthImage::Ptr& depth_image,
127  const openni_wrapper::Image::Ptr& image,
128  float constant,
129  PointCloudAOS<Host>::Ptr &output);*/
130 
131  // ...
132 // void
133 // compute (const pcl::PCLImage::ConstPtr &depth_image,
134 // const pcl::CameraInfo::ConstPtr &info,
135 // PointCloudAOS<Device>::Ptr &output);
136 //
137 // void
138 // compute (const pcl::PCLImage::ConstPtr &depth_image,
139 // const pcl::CameraInfo::ConstPtr &info,
140 // PointCloudAOS<Host>::Ptr &output);
141 
142  void
144  float constant,
146 
147  void
149  float constant,
150  PointCloudAOS<Host>::Ptr &output);
151  };
152 
153 } // namespace
154 } // namespace
pcl::shared_ptr< DepthImage > Ptr
pcl::shared_ptr< Image > Ptr
Definition: openni_image.h:61
Disparity to PointCloudAOS generator.
void compute(const std::uint16_t *depth_image, const OpenNIRGB *rgb_image, int width, int height, float constant, typename PointCloudAOS< Storage >::Ptr &output, int smoothing_nr_iterations=0, int smoothing_filter_size=2)
void compute(const openni_wrapper::DepthImage::Ptr &depth_image, float constant, PointCloudAOS< Device >::Ptr &output)
void compute(const openni_wrapper::DepthImage::Ptr &depth_image, float constant, PointCloudAOS< Host >::Ptr &output)
void compute(const openni_wrapper::DepthImage::Ptr &depth_image, const openni_wrapper::Image::Ptr &image, float constant, typename PointCloudAOS< Storage >::Ptr &output, bool downsample=false, int stride=2, int smoothing_nr_iterations=0, int smoothing_filter_size=2)
shared_ptr< PointCloudAOS< Storage > > Ptr
Definition: point_cloud.h:199
#define PCL_EXPORTS
Definition: pcl_macros.h:323
Compute the XYZ values for a point based on disparity information.
__inline__ __host__ __device__ PointXYZRGB operator()(const Tuple &t)
ComputeXYZ(int w, int h, int cx, int cy, float con)
Compute the XYZ and RGB values for a point based on disparity information.
__inline__ __host__ __device__ PointXYZRGB operator()(const Tuple &t)
ComputeXYZRGB(int w, int h, int cx, int cy, float con)
Simple structure holding RGB data.
Definition: point_cloud.h:56
Default point xyz-rgb structure.
Definition: point_types.h:49