OpenNIGrabber.H

Go to the documentation of this file.
00001 /*!@file Devices/OpenNIGrabber.H Definition and access functions for OpenNI grabber */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Eric Hu <ehu@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/OpenNIGrabber.H $
00035 // $Id: OpenNIGrabber.H 14046 2010-09-25 05:58:24Z itti $
00036 //
00037 
00038 #ifndef OPENNIGRABBER_H_DEFINED
00039 #define OPENNIGRABBER_H_DEFINED
00040 
00041 #ifdef INVT_HAVE_OPENNI
00042 
00043 //OPENNI Libraries
00044 #include <XnOS.h>
00045 #include <XnCppWrapper.h>
00046 
00047 #include "Component/ModelParam.H"
00048 #include "Transport/FrameIstream.H"
00049 #include "Raster/GenericFrame.H"
00050 //---------------------------------------------------------------------------
00051 // Defines
00052 //---------------------------------------------------------------------------
00053 #define SAMPLE_XML_PATH "../Data/SamplesConfig.xml"
00054 
00055 #define GL_WIN_SIZE_X 640
00056 #define GL_WIN_SIZE_Y 480
00057 
00058 
00059 
00060 //! Definition and access functions for Kinect frame grabber
00061 class OpenNIGrabber : public FrameIstream
00062 {
00063 public:
00064   //! Constructor
00065   OpenNIGrabber(OptionManager& mgr,
00066                 const std::string& descrName = "OpenNI Frame Grabber Driver",
00067                 const std::string& tagName = "OpenNIFrameGrabber",
00068                 const ParamFlag flags = USE_MY_VAL);
00069 
00070   //! Destructor
00071   virtual ~OpenNIGrabber();
00072 
00073   /// Install a FrameListener
00074   /** We call the listener's onRawFrame() inside each readFrame(). */
00075   virtual void setListener(rutz::shared_ptr<FrameListener> listener);
00076 
00077   //! Return the specifications of the next frame to be returned
00078   virtual GenericFrameSpec peekFrameSpec();
00079 
00080   //! Get the next frame from the frame-grabber
00081   /*! Returns grabbed frame. This call will block until a frame is
00082       ready and has been grabbed.
00083 
00084       Beware that the integrity of the GenericFrame object may not
00085       last "very long"; basically, try to be finished using the
00086       GenericFrame object before you attempt to grab the next frame in
00087       the stream. If you need it for longer than that, then you should
00088       use GenericFrame::deepCopyOf() to make a copy of the frame that
00089       can be safely held indefinitely. */
00090   virtual GenericFrame readFrame();
00091 
00092   xn::Context* getContext();
00093 
00094 protected:
00095   //! get started
00096   virtual void start1();
00097 
00098   //! get stopped
00099   virtual void stop2();
00100 
00101 
00102 private:
00103   OModelParam<Dims> itsDims; //!< Dims of grabbed frames
00104   rutz::shared_ptr<FrameListener> itsListener;
00105 
00106   //OPENNI related variables
00107   XnUInt16* NI_DMap;
00108   unsigned int NI_DMapX;
00109   unsigned int NI_DMapY;
00110 
00111   xn::Context NI_context;
00112   xn::DepthGenerator NI_depth;
00113   xn::ImageGenerator NI_image;
00114   xn::DepthMetaData NI_depthMD;
00115   xn::ImageMetaData NI_imageMD;
00116 
00117   Image<PixRGB<byte> > itsColorImage;
00118   Image<uint16> itsDepthImage;
00119 };
00120 
00121 #endif
00122 
00123 #endif
00124 
00125 // ######################################################################
00126 /* So things look consistent in everyone's emacs... */
00127 /* Local Variables: */
00128 /* indent-tabs-mode: nil */
00129 /* End: */
Generated on Sun May 8 08:04:45 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3