From c50214e77db84856bcdc027f62afe5b48d54f017 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Wed, 2 Sep 2020 11:45:27 +0800 Subject: [PATCH 1/2] Added YUV420 encoding support Signed-off-by: Luca Della Vedova --- sensor_msgs/include/sensor_msgs/image_encodings.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sensor_msgs/include/sensor_msgs/image_encodings.h b/sensor_msgs/include/sensor_msgs/image_encodings.h index e872bbae..76e86346 100644 --- a/sensor_msgs/include/sensor_msgs/image_encodings.h +++ b/sensor_msgs/include/sensor_msgs/image_encodings.h @@ -99,6 +99,7 @@ namespace sensor_msgs // This is the UYVY version of YUV422 codec http://www.fourcc.org/yuv.php#UYVY // with an 8-bit depth const std::string YUV422="yuv422"; + const std::string YUV420="yuv420"; // Prefixes for abstract image encodings const std::string ABSTRACT_ENCODING_PREFIXES[] = { @@ -176,6 +177,9 @@ namespace sensor_msgs if (encoding == YUV422) return 2; + if (encoding == YUV420) + return 1; + throw std::runtime_error("Unknown encoding " + encoding); return -1; } @@ -221,7 +225,7 @@ namespace sensor_msgs return atoi(prefix.c_str()); // valid encoding string } - if (encoding == YUV422) + if (encoding == YUV422 || encoding == YUV420) return 8; throw std::runtime_error("Unknown encoding " + encoding); From 47479137e1c64e02c92ebf2790a5996caddfe597 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Wed, 2 Sep 2020 12:31:15 +0800 Subject: [PATCH 2/2] Add comment for YUV420 Signed-off-by: Luca Della Vedova --- sensor_msgs/include/sensor_msgs/image_encodings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor_msgs/include/sensor_msgs/image_encodings.h b/sensor_msgs/include/sensor_msgs/image_encodings.h index 76e86346..24bd55bb 100644 --- a/sensor_msgs/include/sensor_msgs/image_encodings.h +++ b/sensor_msgs/include/sensor_msgs/image_encodings.h @@ -99,6 +99,7 @@ namespace sensor_msgs // This is the UYVY version of YUV422 codec http://www.fourcc.org/yuv.php#UYVY // with an 8-bit depth const std::string YUV422="yuv422"; + // YUV420 format, 12 bits per pixel const std::string YUV420="yuv420"; // Prefixes for abstract image encodings