23 #include "depth_thread.h" 24 #include "utils/setup.h" 26 #include <core/threading/mutex_locker.h> 27 #include <fvutils/ipc/shm_image.h> 28 #include <fvutils/color/colorspaces.h> 45 :
Thread(
"OpenNiDepthThread",
Thread::OPMODE_WAITFORWAKEUP),
62 __depth_gen =
new xn::DepthGenerator();
63 #if __cplusplus >= 201103L 64 std::unique_ptr<xn::DepthGenerator> depthgen_uniqueptr(__depth_gen);
66 std::auto_ptr<xn::DepthGenerator> depthgen_uniqueptr(__depth_gen);
71 fawkes::openni::find_or_create_node(
openni, XN_NODE_TYPE_DEPTH, __depth_gen);
72 fawkes::openni::setup_map_generator(*__depth_gen,
config);
74 __depth_md =
new xn::DepthMetaData();
76 __depth_gen->GetMetaData(*__depth_md);
78 __depth_width = __depth_md->XRes();
79 __depth_height = __depth_md->YRes();
82 __depth_md->XRes(), __depth_md->YRes());
83 __depth_bufsize = colorspace_buffer_size(RAW16,
84 __depth_md->XRes(), __depth_md->YRes());
86 __depth_gen->StartGenerating();
91 __depth_gen->WaitAndUpdateData();
94 *__capture_start -= (
long int)__depth_gen->GetTimestamp();
97 depthgen_uniqueptr.release();
116 bool is_depth_new = __depth_gen->IsDataNew();
117 __depth_gen->GetMetaData(*__depth_md);
118 const XnDepthPixel *
const depth_data = __depth_md->Data();
119 fawkes::Time ts = *__capture_start + (
long int)__depth_gen->GetTimestamp();
122 if (is_depth_new && (__depth_buf->
num_attached() > 1)) {
123 memcpy(__depth_buf->
buffer(), depth_data, __depth_bufsize);
LockPtr< xn::Context > openni
Central OpenNI context.
Time & stamp_systime()
Set this time to the current system time.
Fawkes library namespace.
A class for handling time.
virtual void loop()
Code to execute in the thread.
Thread class encapsulation of pthreads.
virtual void finalize()
Finalize the thread.
unsigned char * buffer() const
Get image buffer.
Clock * clock
By means of this member access to the clock is given.
Thread aspect to use blocked timing.
Mutex * objmutex_ptr() const
Get object mutex.
Shared memory image buffer.
OpenNiDepthThread()
Constructor.
virtual ~OpenNiDepthThread()
Destructor.
unsigned int num_attached() const
Get number of attached processes.
Configuration * config
This is the Configuration member used to access the configuration.
void set_capture_time(fawkes::Time *time)
Set the capture time.
virtual void init()
Initialize the thread.