5 #ifndef VISIONX_KINECTV1DEVICE_HPP
6 #define VISIONX_KINECTV1DEVICE_HPP
10 #include <boost/thread/mutex.hpp>
12 #include <libfreenect.hpp>
18 Freenect::FreenectDevice(_ctx, _index),
20 freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB).bytes),
22 freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED).bytes /
24 m_new_rgb_frame(false),
25 m_new_depth_frame(false)
27 setDepthFormat(FREENECT_DEPTH_REGISTERED);
34 boost::mutex::scoped_lock lock(m_rgb_mutex);
35 uint8_t* rgb =
static_cast<uint8_t*
>(_rgb);
36 copy(rgb, rgb + getVideoBufferSize(), m_buffer_video.begin());
37 m_new_rgb_frame =
true;
44 boost::mutex::scoped_lock lock(m_depth_mutex);
45 uint16_t* depth =
static_cast<uint16_t*
>(_depth);
46 copy(depth, depth + getDepthBufferSize() / 2, m_buffer_depth.begin());
47 m_new_depth_frame =
true;
53 boost::mutex::scoped_lock lock(m_rgb_mutex);
60 buffer.swap(m_buffer_video);
61 m_new_rgb_frame =
false;
69 boost::mutex::scoped_lock lock(m_depth_mutex);
71 if (!m_new_depth_frame)
76 buffer.swap(m_buffer_depth);
77 m_new_depth_frame =
false;
83 mutable boost::mutex m_rgb_mutex;
84 mutable boost::mutex m_depth_mutex;
85 std::vector<uint8_t> m_buffer_video;
86 std::vector<uint16_t> m_buffer_depth;
88 bool m_new_depth_frame;
91 #endif //VISIONX_KINECTV1DEVICE_HPP