Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openni_depth_image.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011 Willow Garage, Inc.
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  */
36 #include <pcl/pcl_config.h>
37 #ifdef HAVE_OPENNI
38 
39 #ifndef __OPENNI_DEPTH_IMAGE__
40 #define __OPENNI_DEPTH_IMAGE__
41 
42 #include <XnCppWrapper.h>
43 
44 //#include <pcl/pcl_macros.h> // <-- because current header is included in NVCC-compiled code and contains <Eigen/Core>. Consider <pcl/pcl_exports.h>
45 #include <pcl/pcl_exports.h>
46 #include "openni_exception.h"
47 #include <boost/shared_ptr.hpp>
48 
49 namespace openni_wrapper
50 {
51 
57  class PCL_EXPORTS DepthImage
58  {
59  public:
60  typedef boost::shared_ptr<DepthImage> Ptr;
61  typedef boost::shared_ptr<const DepthImage> ConstPtr;
62 
74  inline DepthImage (boost::shared_ptr<xn::DepthMetaData> depth_meta_data, float baseline, float focal_length, XnUInt64 shadow_value, XnUInt64 no_sample_value) throw ();
75 
80  inline virtual ~DepthImage () throw ();
81 
87  inline const xn::DepthMetaData& getDepthMetaData () const throw ();
88 
98  void fillDisparityImage (unsigned width, unsigned height, float* disparity_buffer, unsigned line_step = 0) const;
99 
109  void fillDepthImage (unsigned width, unsigned height, float* depth_buffer, unsigned line_step = 0) const;
110 
120  void fillDepthImageRaw (unsigned width, unsigned height, unsigned short* depth_buffer, unsigned line_step = 0) const;
121 
127  inline float getBaseline () const throw ();
128 
134  inline float getFocalLength () const throw ();
135 
141  inline XnUInt64 getShadowValue () const throw ();
142 
148  inline XnUInt64 getNoSampleValue () const throw ();
149 
154  inline unsigned getWidth () const throw ();
155 
160  inline unsigned getHeight () const throw ();
161 
167  inline unsigned getFrameID () const throw ();
168 
175  inline unsigned long getTimeStamp () const throw ();
176  protected:
177  boost::shared_ptr<xn::DepthMetaData> depth_md_;
178  float baseline_;
179  float focal_length_;
180  XnUInt64 shadow_value_;
181  XnUInt64 no_sample_value_;
182  } ;
183 
184  DepthImage::DepthImage (boost::shared_ptr<xn::DepthMetaData> depth_meta_data, float baseline, float focal_length, XnUInt64 shadow_value, XnUInt64 no_sample_value) throw ()
185  : depth_md_ (depth_meta_data)
186  , baseline_ (baseline)
187  , focal_length_ (focal_length)
188  , shadow_value_ (shadow_value)
189  , no_sample_value_ (no_sample_value) { }
190 
191  DepthImage::~DepthImage () throw () { }
192 
193  const xn::DepthMetaData&
194  DepthImage::getDepthMetaData () const throw ()
195  {
196  return *depth_md_;
197  }
198 
199  float
200  DepthImage::getBaseline () const throw ()
201  {
202  return baseline_;
203  }
204 
205  float
206  DepthImage::getFocalLength () const throw ()
207  {
208  return focal_length_;
209  }
210 
211  XnUInt64
212  DepthImage::getShadowValue () const throw ()
213  {
214  return shadow_value_;
215  }
216 
217  XnUInt64
218  DepthImage::getNoSampleValue () const throw ()
219  {
220  return no_sample_value_;
221  }
222 
223  unsigned
224  DepthImage::getWidth () const throw ()
225  {
226  return depth_md_->XRes ();
227  }
228 
229  unsigned
230  DepthImage::getHeight () const throw ()
231  {
232  return depth_md_->YRes ();
233  }
234 
235  unsigned
236  DepthImage::getFrameID () const throw ()
237  {
238  return depth_md_->FrameID ();
239  }
240 
241  unsigned long
242  DepthImage::getTimeStamp () const throw ()
243  {
244  return static_cast<unsigned long> (depth_md_->Timestamp ());
245  }
246 } // namespace
247 #endif
248 #endif //__OPENNI_DEPTH_IMAGE