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 #include <pcl/pcl_config.h>
00038 #ifdef HAVE_OPENNI
00039
00040 #include <pcl/io/openni_camera/openni_device_xtion.h>
00041
00042 #include <sstream>
00043 #include <boost/thread/mutex.hpp>
00044
00045 using namespace std;
00046 using namespace boost;
00047
00048 namespace openni_wrapper
00049 {
00050
00051 DeviceXtionPro::DeviceXtionPro (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node)
00052 : OpenNIDevice (context, device_node, depth_node, ir_node)
00053 {
00054
00055 enumAvailableModes ();
00056 setDepthOutputMode (getDefaultDepthMode ());
00057 setIROutputMode (getDefaultIRMode ());
00058
00059 lock_guard<mutex> depth_lock(depth_mutex_);
00060 XnStatus status = depth_generator_.SetIntProperty ("RegistrationType", 1);
00061 if (status != XN_STATUS_OK)
00062 THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
00063 }
00064
00065 DeviceXtionPro::~DeviceXtionPro () throw ()
00066 {
00067 depth_mutex_.lock ();
00068 depth_generator_.UnregisterFromNewDataAvailable (depth_callback_handle_);
00069 depth_mutex_.unlock ();
00070 }
00071
00072 bool DeviceXtionPro::isImageResizeSupported (unsigned, unsigned, unsigned, unsigned) const throw ()
00073 {
00074 return false;
00075 }
00076
00077 void DeviceXtionPro::enumAvailableModes () throw ()
00078 {
00079 XnMapOutputMode output_mode;
00080 available_image_modes_.clear();
00081 available_depth_modes_.clear();
00082
00083
00084 output_mode.nFPS = 30;
00085 output_mode.nXRes = XN_VGA_X_RES;
00086 output_mode.nYRes = XN_VGA_Y_RES;
00087 available_depth_modes_.push_back (output_mode);
00088
00089 output_mode.nFPS = 25;
00090 output_mode.nXRes = XN_VGA_X_RES;
00091 output_mode.nYRes = XN_VGA_Y_RES;
00092 available_depth_modes_.push_back (output_mode);
00093
00094 output_mode.nFPS = 25;
00095 output_mode.nXRes = XN_QVGA_X_RES;
00096 output_mode.nYRes = XN_QVGA_Y_RES;
00097 available_depth_modes_.push_back (output_mode);
00098
00099 output_mode.nFPS = 30;
00100 output_mode.nXRes = XN_QVGA_X_RES;
00101 output_mode.nYRes = XN_QVGA_Y_RES;
00102 available_depth_modes_.push_back (output_mode);
00103
00104 output_mode.nFPS = 60;
00105 output_mode.nXRes = XN_QVGA_X_RES;
00106 output_mode.nYRes = XN_QVGA_Y_RES;
00107 available_depth_modes_.push_back (output_mode);
00108 }
00109
00110 boost::shared_ptr<Image> DeviceXtionPro::getCurrentImage (boost::shared_ptr<xn::ImageMetaData>) const throw ()
00111 {
00112 return boost::shared_ptr<Image> (reinterpret_cast<Image*> (0));
00113 }
00114
00115 void DeviceXtionPro::startDepthStream ()
00116 {
00117 if (isDepthRegistered ())
00118 {
00119
00120 setDepthRegistration (false);
00121
00122
00123 OpenNIDevice::startDepthStream ();
00124
00125
00126 setDepthRegistration (true);
00127 }
00128 else
00129
00130 OpenNIDevice::startDepthStream ();
00131 }
00132
00133 }
00134 #endif