1 #ifndef IMAGE_BUFFER_6RYGHM2V 2 #define IMAGE_BUFFER_6RYGHM2V 5 #include <boost/thread/mutex.hpp> 6 #include <boost/shared_ptr.hpp> 7 #include <boost/lexical_cast.hpp> 9 #include <libfreenect.h> 37 return RGB_FOCAL_LENGTH_SXGA * scale;
44 const freenect_registration& registration,
int width) {
46 float depth_focal_length_sxga =
47 registration.zero_plane_info.reference_distance /
48 registration.zero_plane_info.reference_pixel_size;
50 return depth_focal_length_sxga * scale;
58 const freenect_video_format& format,
59 const freenect_resolution& resolution,
60 const freenect_registration& registration) {
65 boost::lock_guard<boost::mutex> buffer_lock(buffer.
mutex);
72 case FREENECT_VIDEO_RGB:
73 case FREENECT_VIDEO_BAYER:
74 case FREENECT_VIDEO_YUV_RGB:
75 case FREENECT_VIDEO_IR_8BIT:
76 case FREENECT_VIDEO_IR_10BIT:
77 case FREENECT_VIDEO_IR_10BIT_PACKED:
79 case FREENECT_RESOLUTION_HIGH:
80 case FREENECT_RESOLUTION_MEDIUM:
82 freenect_find_video_mode(resolution, format);
84 throw std::runtime_error(
"libfreenect: Invalid video fmt, res: " +
85 boost::lexical_cast<std::string>(format) +
"," +
86 boost::lexical_cast<std::string>(resolution));
90 throw std::runtime_error(
"libfreenect: Invalid video resolution: " +
91 boost::lexical_cast<std::string>(resolution));
95 throw std::runtime_error(
"libfreenect: Invalid video format: " +
96 boost::lexical_cast<std::string>(format));
102 case FREENECT_VIDEO_RGB:
103 case FREENECT_VIDEO_BAYER:
104 case FREENECT_VIDEO_YUV_RGB:
107 case FREENECT_VIDEO_IR_8BIT:
108 case FREENECT_VIDEO_IR_10BIT:
109 case FREENECT_VIDEO_IR_10BIT_PACKED:
114 throw std::runtime_error(
"libfreenect: shouldn't reach here");
124 const freenect_depth_format& format,
125 const freenect_resolution& resolution,
126 const freenect_registration& registration) {
131 boost::lock_guard<boost::mutex> buffer_lock(buffer.
mutex);
138 case FREENECT_DEPTH_11BIT:
139 case FREENECT_DEPTH_10BIT:
140 case FREENECT_DEPTH_11BIT_PACKED:
141 case FREENECT_DEPTH_10BIT_PACKED:
142 case FREENECT_DEPTH_REGISTERED:
143 case FREENECT_DEPTH_MM:
144 switch (resolution) {
145 case FREENECT_RESOLUTION_MEDIUM:
147 freenect_find_depth_mode(resolution, format);
149 throw std::runtime_error(
"libfreenect: Invalid depth fmt, res: " +
150 boost::lexical_cast<std::string>(format) +
"," +
151 boost::lexical_cast<std::string>(resolution));
155 throw std::runtime_error(
"libfreenect: Invalid depth resolution: " +
156 boost::lexical_cast<std::string>(resolution));
160 throw std::runtime_error(
"libfreenect: Invalid depth format: " +
161 boost::lexical_cast<std::string>(format));
167 case FREENECT_DEPTH_11BIT:
168 case FREENECT_DEPTH_10BIT:
169 case FREENECT_DEPTH_11BIT_PACKED:
170 case FREENECT_DEPTH_10BIT_PACKED:
171 case FREENECT_DEPTH_MM:
176 case FREENECT_DEPTH_REGISTERED:
181 throw std::runtime_error(
"libfreenect: shouldn't reach here");
void fillImage(const ImageBuffer &buffer, void *data)
float getRGBFocalLength(int width)
float getDepthFocalLength(const freenect_registration ®istration, int width)
void allocateBufferDepth(ImageBuffer &buffer, const freenect_depth_format &format, const freenect_resolution &resolution, const freenect_registration ®istration)
boost::shared_array< unsigned char > image_buffer
Holds an image buffer with all the metadata required to transmit the image over ROS channels...
const float RGB_FOCAL_LENGTH_SXGA
void allocateBufferVideo(ImageBuffer &buffer, const freenect_video_format &format, const freenect_resolution &resolution, const freenect_registration ®istration)
freenect_frame_mode metadata