41 using namespace boost;
46 DeviceONI::DeviceONI(xn::Context& context,
const std::string& file_name,
bool repeat,
bool streaming)
throw (
OpenNIException)
48 , streaming_ (streaming)
49 , depth_stream_running_ (
false)
50 , image_stream_running_ (
false)
51 , ir_stream_running_ (
false)
54 status = context_.OpenFileRecording(file_name.c_str());
55 if (status != XN_STATUS_OK)
58 status = context.FindExistingNode(XN_NODE_TYPE_DEPTH, depth_generator_);
59 if (status != XN_STATUS_OK)
60 THROW_OPENNI_EXCEPTION(
"could not find depth stream in file %s. Reason: %s", file_name.c_str(), xnGetStatusString(status));
63 available_depth_modes_.push_back(getDepthOutputMode());
64 depth_generator_.RegisterToNewDataAvailable ((xn::StateChangedHandler)NewONIDepthDataAvailable,
this, depth_callback_handle_);
67 status = context.FindExistingNode(XN_NODE_TYPE_IMAGE, image_generator_);
68 if (status == XN_STATUS_OK)
70 available_image_modes_.push_back(getImageOutputMode());
71 image_generator_.RegisterToNewDataAvailable ((xn::StateChangedHandler)NewONIImageDataAvailable,
this, image_callback_handle_);
74 status = context.FindExistingNode(XN_NODE_TYPE_IR, ir_generator_);
75 if (status == XN_STATUS_OK)
76 ir_generator_.RegisterToNewDataAvailable ((xn::StateChangedHandler)NewONIIRDataAvailable,
this, ir_callback_handle_);
78 status = context.FindExistingNode(XN_NODE_TYPE_PLAYER, player_);
79 if (status != XN_STATUS_OK)
82 device_node_info_ = player_.GetInfo();
86 player_.SetRepeat(repeat);
88 player_thread_ = boost::thread (&DeviceONI::PlayerThreadFunction,
this);
91 DeviceONI::~DeviceONI() throw ()
96 player_thread_.join();
102 if (hasImageStream() && !image_stream_running_)
103 image_stream_running_ =
true;
108 if (hasImageStream() && image_stream_running_)
109 image_stream_running_ =
false;
114 if (hasDepthStream() && !depth_stream_running_)
115 depth_stream_running_ =
true;
120 if (hasDepthStream() && depth_stream_running_)
121 depth_stream_running_ =
false;
126 if (hasIRStream() && !ir_stream_running_)
127 ir_stream_running_ =
true;
132 if (hasIRStream() && ir_stream_running_)
133 ir_stream_running_ =
false;
138 return image_stream_running_;
143 return depth_stream_running_;
148 return ir_stream_running_;
175 void __stdcall DeviceONI::NewONIDepthDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ()
182 void __stdcall DeviceONI::NewONIImageDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ()
189 void __stdcall DeviceONI::NewONIIRDataAvailable (xn::ProductionNode& node,
void* cookie)
throw ()
201 bool DeviceONI::isImageResizeSupported(
unsigned input_width,
unsigned input_height,
unsigned output_width,
unsigned output_height)
const throw ()
203 return ImageRGB24::resizingSupported (input_width, input_height, output_width, output_height);
void notify_all() BOOST_NOEXCEPT
#define THROW_OPENNI_EXCEPTION(format,...)
boost::condition_variable depth_condition_
This class provides methods to fill a RGB or Grayscale image buffer from underlying RGB24 image...
bool image_stream_running_
bool depth_stream_running_
boost::condition_variable ir_condition_
boost::condition_variable image_condition_
Concrete implementation of the interface OpenNIDevice for a virtual device playing back an ONI file...
Class representing an astract device for Primesense or MS Kinect devices.