41 #include <boost/thread/mutex.hpp> 43 using namespace boost;
48 DevicePrimesense::DevicePrimesense (xn::Context& context,
const xn::NodeInfo& device_node,
const xn::NodeInfo& image_node,
const xn::NodeInfo& depth_node,
const xn::NodeInfo& ir_node)
throw (
OpenNIException)
49 :
OpenNIDevice (context, device_node, image_node, depth_node, ir_node)
52 enumAvailableModes ();
53 setDepthOutputMode (getDefaultDepthMode ());
54 setImageOutputMode (getDefaultImageMode ());
55 setIROutputMode (getDefaultIRMode ());
57 unique_lock<mutex> image_lock(image_mutex_);
58 XnStatus
status = image_generator_.SetIntProperty (
"InputFormat", 5);
59 if (status != XN_STATUS_OK)
60 THROW_OPENNI_EXCEPTION (
"Error setting the image input format to Uncompressed 8-bit BAYER. Reason: %s", xnGetStatusString (status));
62 status = image_generator_.SetPixelFormat (XN_PIXEL_FORMAT_YUV422);
63 if (status != XN_STATUS_OK)
64 THROW_OPENNI_EXCEPTION (
"Failed to set image pixel format to YUV422. Reason: %s", xnGetStatusString (status));
68 lock_guard<mutex> depth_lock(depth_mutex_);
69 status = depth_generator_.SetIntProperty (
"RegistrationType", 1);
70 if (status != XN_STATUS_OK)
74 DevicePrimesense::~DevicePrimesense () throw ()
76 setDepthRegistration (
false );
77 setSynchronization (
false );
80 depth_generator_.UnregisterFromNewDataAvailable (depth_callback_handle_);
81 depth_mutex_.unlock ();
84 image_generator_.UnregisterFromNewDataAvailable (image_callback_handle_);
85 image_mutex_.unlock ();
88 bool DevicePrimesense::isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw ()
90 return ImageYUV422::resizingSupported (input_width, input_height, output_width, output_height);
136 XnMapOutputMode output_mode;
137 available_image_modes_.clear();
138 available_depth_modes_.clear();
141 output_mode.nFPS = 30;
142 output_mode.nXRes = XN_VGA_X_RES;
143 output_mode.nYRes = XN_VGA_Y_RES;
144 available_depth_modes_.push_back (output_mode);
146 output_mode.nFPS = 25;
147 output_mode.nXRes = XN_VGA_X_RES;
148 output_mode.nYRes = XN_VGA_Y_RES;
149 available_depth_modes_.push_back (output_mode);
151 output_mode.nFPS = 25;
152 output_mode.nXRes = XN_QVGA_X_RES;
153 output_mode.nYRes = XN_QVGA_Y_RES;
154 available_depth_modes_.push_back (output_mode);
156 output_mode.nFPS = 30;
157 output_mode.nXRes = XN_QVGA_X_RES;
158 output_mode.nYRes = XN_QVGA_Y_RES;
159 available_depth_modes_.push_back (output_mode);
161 output_mode.nFPS = 60;
162 output_mode.nXRes = XN_QVGA_X_RES;
163 output_mode.nYRes = XN_QVGA_Y_RES;
164 available_depth_modes_.push_back (output_mode);
167 output_mode.nFPS = 30;
168 output_mode.nXRes = XN_VGA_X_RES;
169 output_mode.nYRes = XN_VGA_Y_RES;
170 available_image_modes_.push_back (output_mode);
172 output_mode.nFPS = 25;
173 output_mode.nXRes = XN_VGA_X_RES;
174 output_mode.nYRes = XN_VGA_Y_RES;
175 available_image_modes_.push_back (output_mode);
182 output_mode.nFPS = 25;
183 output_mode.nXRes = XN_QVGA_X_RES;
184 output_mode.nYRes = XN_QVGA_Y_RES;
185 available_image_modes_.push_back (output_mode);
187 output_mode.nFPS = 30;
188 output_mode.nXRes = XN_QVGA_X_RES;
189 output_mode.nYRes = XN_QVGA_Y_RES;
190 available_image_modes_.push_back (output_mode);
192 output_mode.nFPS = 60;
193 output_mode.nXRes = XN_QVGA_X_RES;
194 output_mode.nYRes = XN_QVGA_Y_RES;
195 available_image_modes_.push_back (output_mode);
208 if (isDepthStreamRunning ())
210 if (isDepthRegistered ())
213 setDepthRegistration (
false);
216 setDepthRegistration (
true);
219 setDepthRegistration (
false);
222 OpenNIDevice::startImageStream ();
225 setDepthRegistration (
true);
230 setDepthRegistration (
true);
232 setDepthRegistration (
false);
235 OpenNIDevice::startImageStream ();
240 OpenNIDevice::startImageStream ();
245 if (isDepthRegistered ())
248 setDepthRegistration (
false);
251 OpenNIDevice::startDepthStream ();
254 setDepthRegistration (
true);
258 OpenNIDevice::startDepthStream ();
#define THROW_OPENNI_EXCEPTION(format,...)
Concrete implementation of the interface Image for a YUV 422 image used by Primesense devices...
Class representing an astract device for Primesense or MS Kinect devices.