-
-
Notifications
You must be signed in to change notification settings - Fork 56.3k
Added support for 4B RGB V4L2 pixel formats #21992
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
Conversation
Added support for V4L2_PIX_FMT_XBGR32 and V4L2_PIX_FMT_ABGR32 pixel formats.
Thanks a lot for the contribution. Could you point camera models that produce ARGB frames? |
Well, I only know the one I'm working on, the Digiteq Automotive FrameGrabber4, which is a video grabber card for automotive LVDS. The card is in a "pre-production" state at the moment, so there is no fancy product page yet, but if you are interested, you can get the linux driver (which should go to the mainline kernel when ready) on the "beta" product page. Just a note to the ARGB frames - the driver uses V4L2_PIX_FMT_ABGR32, but there is no real transparency in the pixel data, the color is always fully opaque in our case (the 4B alignment is required by some FPGA constraints/algorithms we use in the HW). V4L2_PIX_FMT_XBGR32 would probably be more appropriate, but some NVIDIA CUDA libraries we came accross do not support V4L2_PIX_FMT_XBGR32, so we use V4L2_PIX_FMT_ABGR32 for compatability. |
According to documentation (like this https://www.kernel.org/doc/html/v4.9/media/uapi/v4l/pixfmt-packed-rgb.html) |
Well, right now I'm looking at an (patched) opencv camera image/stream that displays correctly, so there must be some error in your understanding of the pixel data alignment either in the kernel or in opencv... Various other SW like qv4l2 or VLC also show the camera image correct, so there is almost for sure no problem in the driver. So the only explanation for me seeing a correct image and the patch code being wrong is either the opencv documentation or the opencv implementation is wrong. I have however not tested the driver/opencv patch on a big-endian system as I do not have access to such HW. So on big-endian systems it may be wrong. |
That's not true. The alpha channel (or the unused byte) is the last byte in memory according to the kernel documentation. |
Sorry, I was confused by columns order. Looks good to me then. |
Broken CentOS 7 build:
Reuse approach similar to |
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.
Well done! Thank you for contribution 👍
* Added support for 4B RGB V4L2 pixel formats Added support for V4L2_PIX_FMT_XBGR32 and V4L2_PIX_FMT_ABGR32 pixel formats. * Added workaround for missing V4L2_PIX_FMT_ABGR32 and V4L2_PIX_FMT_XBGR32 defines
Added support for V4L2_PIX_FMT_XBGR32 and V4L2_PIX_FMT_ABGR32 pixel
formats.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.