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 } Encoding;
00065
00066 inline Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw ();
00067 inline virtual ~Image () throw ();
00068 virtual bool isResizingSupported (unsigned input_width, unsigned input_height,
00069 unsigned output_width, unsigned output_height) const = 0;
00070 virtual void fillRGB (unsigned width, unsigned height, unsigned char* rgb_buffer,
00071 unsigned rgb_line_step = 0) const throw (OpenNIException) = 0;
00072
00073 virtual Encoding getEncoding () const = 0;
00074
00075 inline void
00076 fillRaw (unsigned char* rgb_buffer) const throw (OpenNIException)
00077 {
00078 memcpy (rgb_buffer, image_md_->Data(), image_md_->DataSize ());
00079 }
00080
00081 virtual void fillGrayscale (unsigned width, unsigned height, unsigned char* gray_buffer,
00082 unsigned gray_line_step = 0) const throw (OpenNIException) = 0;
00083
00084 inline unsigned getWidth () const throw ();
00085 inline unsigned getHeight () const throw ();
00086 inline unsigned getFrameID () const throw ();
00087 inline unsigned long getTimeStamp () const throw ();
00088 inline const xn::ImageMetaData& getMetaData () const throw ();
00089
00090 protected:
00091 boost::shared_ptr<xn::ImageMetaData> image_md_;
00092 };
00093
00094 Image::Image (boost::shared_ptr<xn::ImageMetaData> image_meta_data) throw ()
00095 : image_md_ (image_meta_data)
00096 {
00097 }
00098
00099 Image::~Image () throw ()
00100 {
00101 }
00102
00103 unsigned Image::getWidth () const throw ()
00104 {
00105 return image_md_->XRes ();
00106 }
00107
00108 unsigned Image::getHeight () const throw ()
00109 {
00110 return image_md_->YRes ();
00111 }
00112
00113 unsigned Image::getFrameID () const throw ()
00114 {
00115 return image_md_->FrameID ();
00116 }
00117
00118 unsigned long Image::getTimeStamp () const throw ()
00119 {
00120 return image_md_->Timestamp ();
00121 }
00122
00123 const xn::ImageMetaData& Image::getMetaData () const throw ()
00124 {
00125 return *image_md_;
00126 }
00127 }
00128 #endif //__OPENNI_IMAGE__