openni_device_xtion.cpp
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, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 #include <pcl/pcl_config.h>
00039 #ifdef HAVE_OPENNI
00040 
00041 #ifdef __GNUC__
00042 #pragma GCC diagnostic ignored "-Wold-style-cast"
00043 #endif
00044 
00045 #include <pcl/io/openni_camera/openni_device_xtion.h>
00046 #include <sstream>
00047 #include <pcl/io/boost.h>
00048 
00050 openni_wrapper::DeviceXtionPro::DeviceXtionPro (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node)
00051 : OpenNIDevice (context, device_node, depth_node, ir_node)
00052 {
00053   // setup stream modes
00054   enumAvailableModes ();
00055   setDepthOutputMode (getDefaultDepthMode ());
00056   setIROutputMode (getDefaultIRMode ());
00057 
00058   boost::lock_guard<boost::mutex> depth_lock (depth_mutex_);
00059   XnStatus status = depth_generator_.SetIntProperty ("RegistrationType", 1);
00060   if (status != XN_STATUS_OK)
00061     THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
00062 }
00063 
00065 openni_wrapper::DeviceXtionPro::~DeviceXtionPro () throw ()
00066 {
00067   depth_mutex_.lock ();
00068   depth_generator_.UnregisterFromNewDataAvailable (depth_callback_handle_);
00069   depth_mutex_.unlock ();
00070 }
00071 
00073 bool 
00074 openni_wrapper::DeviceXtionPro::isImageResizeSupported (unsigned, unsigned, unsigned, unsigned) const throw ()
00075 {
00076   return (false);
00077 }
00078 
00080 void 
00081 openni_wrapper::DeviceXtionPro::enumAvailableModes () throw ()
00082 {
00083   XnMapOutputMode output_mode;
00084   available_image_modes_.clear();
00085   available_depth_modes_.clear();
00086 
00087   // Depth Modes
00088   output_mode.nFPS = 30;
00089   output_mode.nXRes = XN_VGA_X_RES;
00090   output_mode.nYRes = XN_VGA_Y_RES;
00091   available_depth_modes_.push_back (output_mode);
00092 
00093   output_mode.nFPS = 25;
00094   output_mode.nXRes = XN_VGA_X_RES;
00095   output_mode.nYRes = XN_VGA_Y_RES;
00096   available_depth_modes_.push_back (output_mode);
00097 
00098   output_mode.nFPS = 25;
00099   output_mode.nXRes = XN_QVGA_X_RES;
00100   output_mode.nYRes = XN_QVGA_Y_RES;
00101   available_depth_modes_.push_back (output_mode);
00102 
00103   output_mode.nFPS = 30;
00104   output_mode.nXRes = XN_QVGA_X_RES;
00105   output_mode.nYRes = XN_QVGA_Y_RES;
00106   available_depth_modes_.push_back (output_mode);
00107 
00108   output_mode.nFPS = 60;
00109   output_mode.nXRes = XN_QVGA_X_RES;
00110   output_mode.nYRes = XN_QVGA_Y_RES;
00111   available_depth_modes_.push_back (output_mode);
00112 }
00113 
00115 boost::shared_ptr<openni_wrapper::Image> 
00116 openni_wrapper::DeviceXtionPro::getCurrentImage (boost::shared_ptr<xn::ImageMetaData>) const throw ()
00117 {
00118   return (boost::shared_ptr<Image> (reinterpret_cast<Image*> (0)));
00119 }
00120 
00122 void 
00123 openni_wrapper::DeviceXtionPro::startDepthStream ()
00124 {
00125   if (isDepthRegistered ())
00126   {
00127     // Reset the view point
00128     setDepthRegistration (false);
00129 
00130     // Start the stream
00131     OpenNIDevice::startDepthStream ();
00132 
00133     // Register the stream
00134     setDepthRegistration (true);
00135   }
00136   else
00137     // Start the stream
00138     OpenNIDevice::startDepthStream ();
00139 }
00140 
00141 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:23