41 #include <boost/thread/mutex.hpp>
43 using namespace boost;
48 DeviceKinect::DeviceKinect (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)
50 , debayering_method_ (ImageBayerGRBG::EdgeAwareWeighted)
53 enumAvailableModes ();
54 setDepthOutputMode (getDefaultDepthMode ());
55 setImageOutputMode (getDefaultImageMode ());
56 setIROutputMode (getDefaultIRMode ());
61 unique_lock<mutex> image_lock(image_mutex_);
63 status = image_generator_.SetIntProperty (
"InputFormat", 6);
64 if (
status != XN_STATUS_OK)
68 status = image_generator_.SetPixelFormat (XN_PIXEL_FORMAT_GRAYSCALE_8_BIT);
69 if (
status != XN_STATUS_OK)
73 lock_guard<mutex> depth_lock(depth_mutex_);
75 status = depth_generator_.SetIntProperty (
"RegistrationType", 2);
76 if (
status != XN_STATUS_OK)
80 DeviceKinect::~DeviceKinect () throw ()
83 depth_generator_.UnregisterFromNewDataAvailable (depth_callback_handle_);
84 depth_mutex_.unlock ();
87 image_generator_.UnregisterFromNewDataAvailable (image_callback_handle_);
88 image_mutex_.unlock ();
91 bool DeviceKinect::isImageResizeSupported (
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw ()
93 return ImageBayerGRBG::resizingSupported (input_width, input_height, output_width, output_height);
98 XnMapOutputMode output_mode;
99 available_image_modes_.clear();
100 available_depth_modes_.clear();
102 output_mode.nFPS = 30;
103 output_mode.nXRes = XN_VGA_X_RES;
104 output_mode.nYRes = XN_VGA_Y_RES;
105 available_image_modes_.push_back (output_mode);
106 available_depth_modes_.push_back (output_mode);
108 output_mode.nFPS = 15;
109 output_mode.nXRes = XN_SXGA_X_RES;
110 output_mode.nYRes = XN_SXGA_Y_RES;
111 available_image_modes_.push_back (output_mode);
130 bool DeviceKinect::isSynchronizationSupported ()
const throw ()
140 void DeviceKinect::setDepthCropping (
unsigned x,
unsigned y,
unsigned width,
unsigned height)
throw (
OpenNIException)
142 if (width != 0 && height != 0)
146 bool DeviceKinect::isDepthCroppingSupported ()
const throw ()