openni_device_xtion.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011 2011 Willow Garage, Inc.
5  * Suat Gedikli <gedikli@willowgarage.com>
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
38 #include <iostream>
39 #include <sstream>
40 #include <boost/thread/mutex.hpp>
41 
42 using namespace boost;
43 
44 namespace openni_wrapper
45 {
46 
47 DeviceXtionPro::DeviceXtionPro (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node) throw (OpenNIException)
48 : OpenNIDevice (context, device_node, depth_node, ir_node)
49 {
50  // setup stream modes
51  enumAvailableModes ();
52  setDepthOutputMode (getDefaultDepthMode ());
53  setIROutputMode (getDefaultIRMode ());
54 
55  lock_guard<mutex> depth_lock(depth_mutex_);
56  XnStatus status = depth_generator_.SetIntProperty ("RegistrationType", 1);
57  if (status != XN_STATUS_OK)
58  THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
59 }
60 
61 DeviceXtionPro::~DeviceXtionPro () throw ()
62 {
63  depth_mutex_.lock ();
64  depth_generator_.UnregisterFromNewDataAvailable (depth_callback_handle_);
65  depth_mutex_.unlock ();
66 }
67 
68 bool DeviceXtionPro::isImageResizeSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const throw ()
69 {
70  return false;
71 }
72 
73 void DeviceXtionPro::enumAvailableModes () throw (OpenNIException)
74 {
75  XnMapOutputMode output_mode;
76  available_image_modes_.clear();
77  available_depth_modes_.clear();
78 
79  // Depth Modes
80  output_mode.nFPS = 30;
81  output_mode.nXRes = XN_VGA_X_RES;
82  output_mode.nYRes = XN_VGA_Y_RES;
83  available_depth_modes_.push_back (output_mode);
84 
85  output_mode.nFPS = 25;
86  output_mode.nXRes = XN_VGA_X_RES;
87  output_mode.nYRes = XN_VGA_Y_RES;
88  available_depth_modes_.push_back (output_mode);
89 
90  output_mode.nFPS = 25;
91  output_mode.nXRes = XN_QVGA_X_RES;
92  output_mode.nYRes = XN_QVGA_Y_RES;
93  available_depth_modes_.push_back (output_mode);
94 
95  output_mode.nFPS = 30;
96  output_mode.nXRes = XN_QVGA_X_RES;
97  output_mode.nYRes = XN_QVGA_Y_RES;
98  available_depth_modes_.push_back (output_mode);
99 
100  output_mode.nFPS = 60;
101  output_mode.nXRes = XN_QVGA_X_RES;
102  output_mode.nYRes = XN_QVGA_Y_RES;
103  available_depth_modes_.push_back (output_mode);
104 }
105 
106 boost::shared_ptr<Image> DeviceXtionPro::getCurrentImage (boost::shared_ptr<xn::ImageMetaData> image_data) const throw ()
107 {
108  return boost::shared_ptr<Image> ((Image*)0);
109 }
110 
111 void DeviceXtionPro::startDepthStream () throw (OpenNIException)
112 {
113  if (isDepthRegistered ())
114  {
115  // Reset the view point
116  setDepthRegistration (false);
117 
118  // Start the stream
119  OpenNIDevice::startDepthStream ();
120 
121  // Register the stream
122  setDepthRegistration (true);
123  }
124  else
125  // Start the stream
126  OpenNIDevice::startDepthStream ();
127 }
128 
129 } //namespace
#define THROW_OPENNI_EXCEPTION(format,...)
Image class containing just a reference to image meta data. Thus this class just provides an interfac...
Definition: openni_image.h:54
General exception class.
string status
Definition: test_launch.py:51
Class representing an astract device for Primesense or MS Kinect devices.
Definition: openni_device.h:66


openni_camera
Author(s): Patrick Mihelich, Suat Gedikli, Radu Bogdan Rusu
autogenerated on Wed Jun 5 2019 20:15:22