Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions sensor_msgs/include/sensor_msgs/image_encodings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ const char BAYER_GBRG16[] = "bayer_gbrg16";
const char BAYER_GRBG16[] = "bayer_grbg16";

// Miscellaneous
// This is the UYVY version of YUV422 codec http://www.fourcc.org/yuv.php#UYVY
// with an 8-bit depth
// 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";

// Prefixes for abstract image encodings
const char ABSTRACT_ENCODING_PREFIXES[][5] = {
Expand Down Expand Up @@ -186,7 +188,9 @@ static inline int numChannels(const std::string & encoding)
}
}

if (encoding == YUV422) {
if (encoding == YUV422 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add tests to https://github.com/ros2/common_interfaces/blob/81663c07b93889c3d0afda9b99cd5f1c7c98c1f2/sensor_msgs/test/test_image_encodings.cpp for numChannels and bitDepth? It looks like this was missed when the YUV422 one was added as well, so we may as well add tests for both that one and the new one. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll run CI on this now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks! I guess the failures are not related to this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Linux failures were an infrastructure issue; the job got automatically restarted, but it doesn't propagate that back to the issue, so I just manually updated it. It looks good now.

The Windows failure was because of a typo in how I launched it. I've now fixed that typo and its running again.

encoding == YUV422_YUY2)
{
return 2;
}

Expand Down Expand Up @@ -244,7 +248,9 @@ static inline int bitDepth(const std::string & encoding)
}
}

if (encoding == YUV422) {
if (encoding == YUV422 ||
encoding == YUV422_YUY2)
{
return 8;
}

Expand Down
4 changes: 4 additions & 0 deletions sensor_msgs/test/test_image_encodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ TEST(sensor_msgs, NumChannels)
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC"), 1);
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC3"), 3);
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC10"), 10);
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("yuv422"), 2);
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("yuv422_yuy2"), 2);
}

TEST(sensor_msgs, bitDepth)
Expand All @@ -70,4 +72,6 @@ TEST(sensor_msgs, bitDepth)
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC"), 64);
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC3"), 64);
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC10"), 64);
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("yuv422"), 8);
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("yuv422_yuy2"), 8);
}