Commit 069bc5b5 authored by Ryosuke Tajima's avatar Ryosuke Tajima Committed by Ken Tossell
Browse files

Add monochrome format support (#54)

parent a56465ac
......@@ -192,6 +192,16 @@ void CameraDriver::ImageCallback(uvc_frame_t *frame) {
}
image->encoding = "bgr8";
memcpy(&(image->data[0]), rgb_frame_->data, rgb_frame_->data_bytes);
} else if (frame->frame_format == UVC_FRAME_FORMAT_GRAY8) {
image->encoding = "8UC1";
image->step = image->width;
image->data.resize(image->step * image->height);
memcpy(&(image->data[0]), frame->data, frame->data_bytes);
} else if (frame->frame_format == UVC_FRAME_FORMAT_GRAY16) {
image->encoding = "16UC1";
image->step = image->width*2;
image->data.resize(image->step * image->height);
memcpy(&(image->data[0]), frame->data, frame->data_bytes);
} else if (frame->frame_format == UVC_FRAME_FORMAT_YUYV) {
// FIXME: uvc_any2bgr does not work on "yuyv" format, so use uvc_yuyv2bgr directly.
uvc_error_t conv_ret = uvc_yuyv2bgr(frame, rgb_frame_);
......@@ -318,6 +328,8 @@ enum uvc_frame_format CameraDriver::GetVideoMode(std::string vmode){
return UVC_COLOR_FORMAT_MJPEG;
} else if (vmode == "gray8") {
return UVC_COLOR_FORMAT_GRAY8;
} else if (vmode == "gray16") {
return UVC_COLOR_FORMAT_GRAY16;
} else {
ROS_ERROR_STREAM("Invalid Video Mode: " << vmode);
ROS_WARN_STREAM("Continue using video mode: uncompressed");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment