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