5 #ifndef VISIONX_KINECTV1DEVICE_HPP
6 #define VISIONX_KINECTV1DEVICE_HPP
8 #include <libfreenect.hpp>
9 #include <boost/thread/mutex.hpp>
18 : Freenect::FreenectDevice(_ctx, _index),
19 m_buffer_video(freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB).bytes),
20 m_buffer_depth(freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED).bytes / 2),
21 m_new_rgb_frame(false), m_new_depth_frame(false)
23 setDepthFormat(FREENECT_DEPTH_REGISTERED);
29 boost::mutex::scoped_lock lock(m_rgb_mutex);
30 uint8_t* rgb =
static_cast<uint8_t*
>(_rgb);
31 copy(rgb, rgb + getVideoBufferSize(), m_buffer_video.begin());
32 m_new_rgb_frame =
true;
38 boost::mutex::scoped_lock lock(m_depth_mutex);
39 uint16_t* depth =
static_cast<uint16_t*
>(_depth);
40 copy(depth, depth + getDepthBufferSize() / 2, m_buffer_depth.begin());
41 m_new_depth_frame =
true;
44 bool getRGB(std::vector<uint8_t>& buffer)
46 boost::mutex::scoped_lock lock(m_rgb_mutex);
53 buffer.swap(m_buffer_video);
54 m_new_rgb_frame =
false;
61 boost::mutex::scoped_lock lock(m_depth_mutex);
63 if (!m_new_depth_frame)
68 buffer.swap(m_buffer_depth);
69 m_new_depth_frame =
false;
75 mutable boost::mutex m_rgb_mutex;
76 mutable boost::mutex m_depth_mutex;
77 std::vector<uint8_t> m_buffer_video;
78 std::vector<uint16_t> m_buffer_depth;
80 bool m_new_depth_frame;
83 #endif //VISIONX_KINECTV1DEVICE_HPP