Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011 Willow Garage, Inc. 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the copyright holder(s) nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 #include <pcl/pcl_config.h> 00037 #ifdef HAVE_OPENNI 00038 00039 #ifndef __OPENNI_IMAGE__ 00040 #define __OPENNI_IMAGE__ 00041 00042 #include <pcl/pcl_exports.h> 00043 #include "openni.h" 00044 #include "openni_exception.h" 00045 #include <pcl/io/boost.h> 00046 00047 namespace openni_wrapper 00048 { 00049 00050 /** 00051 * @brief Image class containing just a reference to image meta data. Thus this class 00052 * just provides an interface to fill a RGB or Grayscale image buffer. 00053 * @author Suat Gedikli 00054 * @date 02.january 2011 00055 * @param[in] image_meta_data 00056 * @ingroup io 00057 */ 00058 class PCL_EXPORTS Image 00059 { 00060 public: 00061 typedef boost::shared_ptr<Image> Ptr; 00062 typedef boost::shared_ptr<const Image> ConstPtr; 00063 00064 typedef enum 00065 { 00066 BAYER_GRBG, 00067 YUV422, 00068 RGB 00069 } Encoding; 00070 00071 /** 00072 * @author Suat Gedikli 00073 * @brief Constructor 00074 * @param[in] image_meta_data the actual image data from the OpenNI driver 00075 */ 00076 inline Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw (); 00077 00078 /** 00079 * @author Suat Gedikli 00080 * @brief virtual Destructor that never throws an exception. 00081 */ 00082 inline virtual ~Image () throw (); 00083 00084 /** 00085 * @author Suat Gedikli 00086 * @param[in] input_width width of input image 00087 * @param[in] input_height height of input image 00088 * @param[in] output_width width of desired output image 00089 * @param[in] output_height height of desired output image 00090 * @return wheter the resizing is supported or not. 00091 */ 00092 virtual bool isResizingSupported (unsigned input_width, unsigned input_height, 00093 unsigned output_width, unsigned output_height) const = 0; 00094 00095 /** 00096 * @author Suat Gedikli 00097 * @brief fills a user given buffer with the RGB values, with an optional nearest-neighbor down sampling and an optional subregion 00098 * @param[in] width desired width of output image. 00099 * @param[in] height desired height of output image. 00100 * @param[in,out] rgb_buffer the output RGB buffer. 00101 * @param[in] rgb_line_step optional line step in bytes to allow the output in a rectangular subregion of the output buffer. 00102 */ 00103 virtual void fillRGB (unsigned width, unsigned height, unsigned char* rgb_buffer, 00104 unsigned rgb_line_step = 0) const = 0; 00105 00106 /** 00107 * @author Suat Gedikli 00108 * @brief returns the encoding of the native data. 00109 * @return encoding 00110 */ 00111 virtual Encoding getEncoding () const = 0; 00112 00113 /** 00114 * @author Suat Gedikli 00115 * @brief fills a user given buffer with the raw values. 00116 * @param[in,out] rgb_buffer 00117 */ 00118 inline void 00119 fillRaw (unsigned char* rgb_buffer) const throw () 00120 { 00121 memcpy (rgb_buffer, image_md_->Data (), image_md_->DataSize ()); 00122 } 00123 00124 /** 00125 * @author Suat Gedikli 00126 * @brief fills a user given buffer with the gray values, with an optional nearest-neighbor down sampling and an optional subregion 00127 * @param[in] width desired width of output image. 00128 * @param[in] height desired height of output image. 00129 * @param[in,out] gray_buffer the output gray buffer. 00130 * @param[in] gray_line_step optional line step in bytes to allow the output in a rectangular subregion of the output buffer. 00131 */ 00132 virtual void fillGrayscale (unsigned width, unsigned height, unsigned char* gray_buffer, 00133 unsigned gray_line_step = 0) const = 0; 00134 00135 /** 00136 * @author Suat Gedikli 00137 * @return width of the image 00138 */ 00139 inline unsigned getWidth () const throw (); 00140 00141 /** 00142 * @author Suat Gedikli 00143 * @return height of the image 00144 */ 00145 inline unsigned getHeight () const throw (); 00146 00147 /** 00148 * @author Suat Gedikli 00149 * @return frame id of the image. 00150 * @note frame ids are ascending, but not necessarily synch'ed with other streams 00151 */ 00152 inline unsigned getFrameID () const throw (); 00153 00154 /** 00155 * @author Suat Gedikli 00156 * @return the time stamp of the image 00157 * @note the time value is not synche'ed with the system time 00158 */ 00159 inline unsigned long getTimeStamp () const throw (); 00160 00161 /** 00162 * @author Suat Gedikli 00163 * @return the actual data in native OpenNI format. 00164 */ 00165 inline const xn::ImageMetaData& getMetaData () const throw (); 00166 00167 protected: 00168 boost::shared_ptr<xn::ImageMetaData> image_md_; 00169 } ; 00170 00171 Image::Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw () 00172 : image_md_ (image_meta_data) 00173 { 00174 } 00175 00176 Image::~Image () throw () { } 00177 00178 unsigned 00179 Image::getWidth () const throw () 00180 { 00181 return image_md_->XRes (); 00182 } 00183 00184 unsigned 00185 Image::getHeight () const throw () 00186 { 00187 return image_md_->YRes (); 00188 } 00189 00190 unsigned 00191 Image::getFrameID () const throw () 00192 { 00193 return image_md_->FrameID (); 00194 } 00195 00196 unsigned long 00197 Image::getTimeStamp () const throw () 00198 { 00199 return static_cast<unsigned long> (image_md_->Timestamp ()); 00200 } 00201 00202 const xn::ImageMetaData& 00203 Image::getMetaData () const throw () 00204 { 00205 return *image_md_; 00206 } 00207 } // namespace 00208 #endif 00209 #endif //__OPENNI_IMAGE__