Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update YUV format codes and documentation #214

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions sensor_msgs/include/sensor_msgs/image_encodings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,22 @@ const char BAYER_BGGR16[] = "bayer_bggr16";
const char BAYER_GBRG16[] = "bayer_gbrg16";
const char BAYER_GRBG16[] = "bayer_grbg16";

// Miscellaneous
// YUV formats
// YUV 4:2:2 encodings with an 8-bit depth
// UYUV version: http://www.fourcc.org/pixel-format/yuv-uyvy
const char YUV422[] = "yuv422";
// YUYV version: http://www.fourcc.org/pixel-format/yuv-yuy2/
const char YUV422_YUY2[] = "yuv422_yuy2";
// https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-packed-yuv.html#id1
// fourcc: UYVY
const char UYVY[] = "uyvy";
const char YUV422[] = "yuv422"; // deprecated
// fourcc: YUYV
const char YUYV[] = "yuyv";
const char YUV422_YUY2[] = "yuv422_yuy2"; // deprecated

// YUV 4:2:0 encodings with an 8-bit depth
// NV21: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html
// NV21: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html#nv12-nv21-nv12m-and-nv21m
const char NV21[] = "nv21";

// YUV 4:4:4 encodings with 8-bit depth
// NV24: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html
// NV24: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html#nv24-and-nv42
const char NV24[] = "nv24";

// Prefixes for abstract image encodings
Expand Down Expand Up @@ -184,6 +189,8 @@ static inline int numChannels(const std::string & encoding)

if (encoding == YUV422 ||
encoding == YUV422_YUY2 ||
encoding == UYVY ||
encoding == YUYV ||
encoding == NV21 ||
encoding == NV24)
{
Expand Down Expand Up @@ -234,6 +241,8 @@ static inline int bitDepth(const std::string & encoding)

if (encoding == YUV422 ||
encoding == YUV422_YUY2 ||
encoding == UYVY ||
encoding == YUYV ||
encoding == NV21 ||
encoding == NV24)
{
Expand Down