Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mobile_robotics
ADC
external
libuvc_ros
Commits
069bc5b5
Commit
069bc5b5
authored
Jul 09, 2019
by
Ryosuke Tajima
Committed by
Ken Tossell
Jul 08, 2019
Browse files
Add monochrome format support (#54)
parent
a56465ac
Changes
1
Show whitespace changes
Inline
Side-by-side
libuvc_camera/src/camera_driver.cpp
View file @
069bc5b5
...
...
@@ -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"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment