oni_grabber.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2011-2012, Willow Garage, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  */
00036 
00037 #include <pcl/pcl_config.h>
00038 #ifdef HAVE_OPENNI
00039 
00040 #ifndef __PCL_IO_ONI_PLAYER__
00041 #define __PCL_IO_ONI_PLAYER__
00042 
00043 #include <Eigen/Core>
00044 #include <pcl/io/grabber.h>
00045 #include <pcl/io/openni_camera/openni_driver.h>
00046 #include <pcl/io/openni_camera/openni_device_oni.h>
00047 #include <pcl/io/openni_camera/openni_image.h>
00048 #include <pcl/io/openni_camera/openni_depth_image.h>
00049 #include <pcl/io/openni_camera/openni_ir_image.h>
00050 #include <string>
00051 #include <deque>
00052 #include <boost/thread/mutex.hpp>
00053 #include <pcl/common/synchronizer.h>
00054 
00055 
00056 namespace pcl
00057 {
00058   struct PointXYZ;
00059   struct PointXYZRGB;
00060   struct PointXYZRGBA;
00061   struct PointXYZI;
00062   template <typename T> class PointCloud;
00063 
00067   class PCL_EXPORTS ONIGrabber : public Grabber
00068   {
00069     public:
00070       //define callback signature typedefs
00071       typedef void (sig_cb_openni_image) (const boost::shared_ptr<openni_wrapper::Image>&);
00072       typedef void (sig_cb_openni_depth_image) (const boost::shared_ptr<openni_wrapper::DepthImage>&);
00073       typedef void (sig_cb_openni_ir_image) (const boost::shared_ptr<openni_wrapper::IRImage>&);
00074       typedef void (sig_cb_openni_image_depth_image) (const boost::shared_ptr<openni_wrapper::Image>&, const boost::shared_ptr<openni_wrapper::DepthImage>&, float constant) ;
00075       typedef void (sig_cb_openni_ir_depth_image) (const boost::shared_ptr<openni_wrapper::IRImage>&, const boost::shared_ptr<openni_wrapper::DepthImage>&, float constant) ;
00076       typedef void (sig_cb_openni_point_cloud) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZ> >&);
00077       typedef void (sig_cb_openni_point_cloud_rgb) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> >&);
00078       typedef void (sig_cb_openni_point_cloud_rgba) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&);
00079       typedef void (sig_cb_openni_point_cloud_i) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZI> >&);
00080 
00086       ONIGrabber (const std::string& file_name, bool repeat, bool stream);
00087 
00089       virtual ~ONIGrabber () throw ();
00090 
00094       virtual void 
00095       start ();
00096 
00100       virtual void 
00101       stop ();
00102 
00106       virtual std::string 
00107       getName () const;
00108 
00112       virtual bool 
00113       isRunning () const;
00114 
00116       virtual float 
00117       getFramesPerSecond () const;
00118 
00119     protected:
00121       void
00122       imageCallback (boost::shared_ptr<openni_wrapper::Image> image, void* cookie);
00123 
00125       void
00126       depthCallback (boost::shared_ptr<openni_wrapper::DepthImage> depth_image, void* cookie);
00127 
00129       void
00130       irCallback (boost::shared_ptr<openni_wrapper::IRImage> ir_image, void* cookie);
00131 
00133       void
00134       imageDepthImageCallback (const boost::shared_ptr<openni_wrapper::Image> &image,
00135                                const boost::shared_ptr<openni_wrapper::DepthImage> &depth_image);
00136 
00138       void
00139       irDepthImageCallback (const boost::shared_ptr<openni_wrapper::IRImage> &image,
00140                             const boost::shared_ptr<openni_wrapper::DepthImage> &depth_image);
00141 
00143       boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >
00144       convertToXYZPointCloud (const boost::shared_ptr<openni_wrapper::DepthImage> &depth) const;
00145 
00147       boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >
00148       convertToXYZRGBPointCloud (const boost::shared_ptr<openni_wrapper::Image> &image,
00149                                  const boost::shared_ptr<openni_wrapper::DepthImage> &depth_image) const;
00150 
00152       boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> >
00153       convertToXYZRGBAPointCloud (const boost::shared_ptr<openni_wrapper::Image> &image,
00154                                   const boost::shared_ptr<openni_wrapper::DepthImage> &depth_image) const;
00155 
00157       boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >
00158       convertToXYZIPointCloud (const boost::shared_ptr<openni_wrapper::IRImage> &image,
00159                                const boost::shared_ptr<openni_wrapper::DepthImage> &depth_image) const;
00160 
00162       Synchronizer<boost::shared_ptr<openni_wrapper::Image>, boost::shared_ptr<openni_wrapper::DepthImage> > rgb_sync_;
00163 
00165       Synchronizer<boost::shared_ptr<openni_wrapper::IRImage>, boost::shared_ptr<openni_wrapper::DepthImage> > ir_sync_;
00166 
00168       boost::shared_ptr<openni_wrapper::DeviceONI> device_;
00169       std::string rgb_frame_id_;
00170       std::string depth_frame_id_;
00171       bool running_;
00172       unsigned image_width_;
00173       unsigned image_height_;
00174       unsigned depth_width_;
00175       unsigned depth_height_;
00176       openni_wrapper::OpenNIDevice::CallbackHandle depth_callback_handle;
00177       openni_wrapper::OpenNIDevice::CallbackHandle image_callback_handle;
00178       openni_wrapper::OpenNIDevice::CallbackHandle ir_callback_handle;
00179       boost::signals2::signal<sig_cb_openni_image >*            image_signal_;
00180       boost::signals2::signal<sig_cb_openni_depth_image >*      depth_image_signal_;
00181       boost::signals2::signal<sig_cb_openni_ir_image >*         ir_image_signal_;
00182       boost::signals2::signal<sig_cb_openni_image_depth_image>* image_depth_image_signal_;
00183       boost::signals2::signal<sig_cb_openni_ir_depth_image>*    ir_depth_image_signal_;
00184       boost::signals2::signal<sig_cb_openni_point_cloud >*      point_cloud_signal_;
00185       boost::signals2::signal<sig_cb_openni_point_cloud_i >*    point_cloud_i_signal_;
00186       boost::signals2::signal<sig_cb_openni_point_cloud_rgb >*  point_cloud_rgb_signal_;
00187       boost::signals2::signal<sig_cb_openni_point_cloud_rgba >*  point_cloud_rgba_signal_;
00188 
00189     public:
00190       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00191   };
00192 
00193 } // namespace
00194 
00195 #endif // __PCL_IO_ONI_PLAYER__
00196 #endif // HAVE_OPENNI
00197 


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:15:58