Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __OPENNI_IMAGE__
00038 #define __OPENNI_IMAGE__
00039
00040 #include <XnCppWrapper.h>
00041 #include "openni_exception.h"
00042 #include <boost/shared_ptr.hpp>
00043
00044 namespace openni_wrapper
00045 {
00046
00054 class Image
00055 {
00056 public:
00057 typedef boost::shared_ptr<Image> Ptr;
00058 typedef boost::shared_ptr<const Image> ConstPtr;
00059
00060 typedef enum
00061 {
00062 BAYER_GRBG,
00063 YUV422,
00064 RGB
00065 } Encoding;
00066
00067 inline Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw ();
00068 inline virtual ~Image () throw ();
00069 virtual bool isResizingSupported (unsigned input_width, unsigned input_height,
00070 unsigned output_width, unsigned output_height) const = 0;
00071 virtual void fillRGB (unsigned width, unsigned height, unsigned char* rgb_buffer,
00072 unsigned rgb_line_step = 0) const throw (OpenNIException) = 0;
00073
00074 virtual Encoding getEncoding () const = 0;
00075
00076 inline void
00077 fillRaw (unsigned char* rgb_buffer) const throw (OpenNIException)
00078 {
00079 memcpy (rgb_buffer, image_md_->WritableData(), image_md_->DataSize ());
00080 }
00081
00082 virtual void fillGrayscale (unsigned width, unsigned height, unsigned char* gray_buffer,
00083 unsigned gray_line_step = 0) const throw (OpenNIException) = 0;
00084
00085 inline unsigned getWidth () const throw ();
00086 inline unsigned getHeight () const throw ();
00087 inline unsigned getFrameID () const throw ();
00088 inline unsigned long getTimeStamp () const throw ();
00089 inline const xn::ImageMetaData& getMetaData () const throw ();
00090 inline const boost::shared_ptr<xn::ImageMetaData> getMetaDataPtr () const;
00091
00092 protected:
00093 boost::shared_ptr<xn::ImageMetaData> image_md_;
00094 };
00095
00096 Image::Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw ()
00097 : image_md_ (image_meta_data)
00098 {
00099 }
00100
00101 Image::~Image () throw ()
00102 {
00103 }
00104
00105 unsigned Image::getWidth () const throw ()
00106 {
00107 return image_md_->XRes ();
00108 }
00109
00110 unsigned Image::getHeight () const throw ()
00111 {
00112 return image_md_->YRes ();
00113 }
00114
00115 unsigned Image::getFrameID () const throw ()
00116 {
00117 return image_md_->FrameID ();
00118 }
00119
00120 unsigned long Image::getTimeStamp () const throw ()
00121 {
00122 return (unsigned long) image_md_->Timestamp ();
00123 }
00124
00125 const xn::ImageMetaData& Image::getMetaData () const throw ()
00126 {
00127 return *image_md_;
00128 }
00129
00130 const boost::shared_ptr<xn::ImageMetaData> Image::getMetaDataPtr () const
00131 {
00132 return image_md_;
00133 }
00134 }
00135 #endif //__OPENNI_IMAGE__