Go to the documentation of this file.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 
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   
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   
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     
00128     setDepthRegistration (false);
00129 
00130     
00131     OpenNIDevice::startDepthStream ();
00132 
00133     
00134     setDepthRegistration (true);
00135   }
00136   else
00137     
00138     OpenNIDevice::startDepthStream ();
00139 }
00140 
00141 #endif