-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conversation
Use format codes instead of ambiguous names. Signed-off-by: Christian Rauch <[email protected]>
The naming of the format was discussed in #76. As mentioned there, one of the reasons of adding the format was to be able to then extend cv_bridge to be able to perform the right conversion. OpenCV defines: cv::COLOR_YUV2RGB_YUY2 = 115,
cv::COLOR_YUV2BGR_YUY2 = 116, and then the aliases: cv::COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2,
cv::COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2,
cv::COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2,
cv::COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2, so hinting they treat YUY2 as the canonical name, but also YUYV and YUNV as alternative names, seemingly following the table that used to be at fourcc.org. It is true that this doesn't follow the V4L2 codes and that V4L2 drivers return the code FWIW, Windows seems to use YUY2 as well and does not use YUYV as an alias AFAICT. Also see RFC2361. FFmpeg mixes things a bit: running
so they use the YUY2 FourCC, which they then map to the internal yuyv422 type. With all that said, I'd agree that YUYV would be clearer and I wouldn't be against adopting that per se, I had that name in mind initially as well. But for almost everywhere I look except for V4L2, YUY2 is the common default name to refer to this encoding. |
Thanks for the detailed response. That means that I wouldn't so much rely on OpenCV for choosing those names. It is more important that they properly specify the precise memory layout so that the image can be reconstructed manually from the raw data. When you get a data stream from the camera with a given fourcc, then the mapping to the ROS "encodings" should be unambiguous (see also #204). But in any case, I find the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks cleaner and more clearly documented.
Use format codes instead of ambiguous names. Signed-off-by: Christian Rauch <[email protected]> Signed-off-by: Tom Noble <[email protected]>
The YUV formats seem to be ambiguous. With this PR, I would like to clarify this and properly document their memory layout. There is no "yuv422_yuy2" format and the "yuv422" format refers to the format code
YU16
. The documentation mentions a "UYUV" format, which does not exist. Additionally, the website http://www.fourcc.org is not reachable anymore.With the wayback machine, I compared the documented memory layout from http://www.fourcc.org with the one from the Linux kernel documentation from https://www.kernel.org/doc/html/latest/. I found that for the
yuv422
the memory layout described at fourcc.org matchesV4L2_PIX_FMT_UYVY
at kernel.org andyuv422_yuy2
matchesV4L2_PIX_FMT_YUYV
.The NV21 and NV24 formats have unambiguous format codes across the kernel documentation. For the YUV 4:2:2 formats, different sources seem to use different names, hence I propose to use the fourcc instead of an ambiguous name.
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/videodev2.h for a list of codes used with video devices.
@sgvandijk Since you added the "yuv422_yuy2" format via #78, can you comment if my changes make sense to you?