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