Closed FangLinHe closed 2 years ago
The same for me!
I was really irritated when I sent the image retrieved by zed camera to our Image Viewer and saw the swapped colors. After debugging I can confirm the issue described above. The memory layout of color channels in LEFT mode is not RGBA, but BGRA.
The issue was opened one year ago. But still no answer and no updates in the documentation.
@adujardin, please check this issue!
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days
Some information first:
We recently noticed some confusion of the color order of retrieved images by
Camera::retrieveImage
function. It seems to us the retrieved image is in RGBA format, based on:your document - Sharing image data between ZED SDK and OpenCV:
in the
sl_zed/defines.hpp
, inenum VIEW
, theVIEW_LEFT
which is passed as a parameter ofCamera::retrieveImage
, also has the comment:and your example code:
I also had a look at the headers, and even found in
sl_core/utils/types.hpp
:where
struct { T r, g, b, a; };
indicates the pixel value order is RGBA. (This struct is used in the docstring ofERROR_CODE retrieveImage(Mat& mat, VIEW view = VIEW_LEFT, MEM type = MEM_CPU, int width = 0, int height = 0);
insl_zed/Camera.hpp
, which is the returned type ofsl::Mat::getValue
:After testing a bit, we finally confirmed the pixel values are actually in BGRA order instead of RGBA order. However, searching in the documentations, code, issues, etc., we didn't find any information about this fact. I'd be nice if you could confirm the values are truly in BGRA order but not RGBA order and update the document to prevent similar confusion in the future. Thank you in advance for the reading and look forward to hearing from you.