23 #include "depth_thread.h"
25 #include "utils/setup.h"
27 #include <core/threading/mutex_locker.h>
28 #include <fvutils/color/colorspaces.h>
29 #include <fvutils/ipc/shm_image.h>
34 using namespace firevision;
46 :
Thread(
"OpenNiDepthThread",
Thread::OPMODE_WAITFORWAKEUP),
61 depth_gen_ =
new xn::DepthGenerator();
62 #if __cplusplus >= 201103L
63 std::unique_ptr<xn::DepthGenerator> depthgen_uniqueptr(depth_gen_);
65 std::auto_ptr<xn::DepthGenerator> depthgen_uniqueptr(depth_gen_);
70 fawkes::openni::find_or_create_node(
openni, XN_NODE_TYPE_DEPTH, depth_gen_);
71 fawkes::openni::setup_map_generator(*depth_gen_,
config);
73 depth_md_ =
new xn::DepthMetaData();
75 depth_gen_->GetMetaData(*depth_md_);
77 depth_width_ = depth_md_->XRes();
78 depth_height_ = depth_md_->YRes();
82 depth_bufsize_ = colorspace_buffer_size(RAW16, depth_md_->XRes(), depth_md_->YRes());
84 depth_gen_->StartGenerating();
89 depth_gen_->WaitAndUpdateData();
92 *capture_start_ -= (
long int)depth_gen_->GetTimestamp();
94 depthgen_uniqueptr.release();
105 delete capture_start_;
112 bool is_depth_new = depth_gen_->IsDataNew();
113 depth_gen_->GetMetaData(*depth_md_);
114 const XnDepthPixel *
const depth_data = depth_md_->Data();
115 fawkes::Time ts = *capture_start_ + (
long int)depth_gen_->GetTimestamp();
119 memcpy(depth_buf_->
buffer(), depth_data, depth_bufsize_);
OpenNiDepthThread()
Constructor.
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
virtual ~OpenNiDepthThread()
Destructor.
Thread aspect to use blocked timing.
Clock * clock
By means of this member access to the clock is given.
Configuration * config
This is the Configuration member used to access the configuration.
Mutex * objmutex_ptr() const
Get object mutex.
void unlock()
Unlock the mutex.
LockPtr< xn::Context > openni
Central OpenNI context.
unsigned int num_attached() const
Get number of attached processes.
Thread class encapsulation of pthreads.
A class for handling time.
Time & stamp_systime()
Set this time to the current system time.
Shared memory image buffer.
void set_capture_time(fawkes::Time *time)
Set the capture time.
unsigned char * buffer() const
Get image buffer.
Fawkes library namespace.