-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
How to write aligned 16-bit-depth and color images for L515 camera in C++ #7081
Comments
Is there anyone can help me to write single band 16bit depth image correctly? Thanks |
Hi, I use opencv like
and imwrite works fine for me |
@hduonggithub, the issue is with the export call:
It assumes the input buffer being Big-endian according to PNG spec, while |
@ev-mp Can you give me a sample code to swap the bytes? Thanks |
@hduonggithub , you can do std::vector<uint16_t> values(w*h);
memcpy((uint8_t*)values.data(),vf_depth.get_data(),values.size() * sizeof(uint16_t));
std::for_each(values.begin(), values.end(), [](uint16_t& val){ val=((val<<8)|(val>>8)); });
stbi_write_png(... ,values.data,() ... ) |
@ev-mp
|
@hduonggithub , the input data is 16bpp. Is the tool you're using for snapshot it capable of handling 16bit data channels? |
@ev-mp Test dataset shows correctly info: single band 16 bit image, BSQ format, Uint data type I am so confused now. The data values look rounded and very small compared to test dataset (see profiles red color). Any help is really welcome. Thanks! |
@hduonggithub , the difference is in the data header -
The PNG image appears stored incorrectly as 2-channel 8-bit rather than single-channel 16 bit data.
We'll look for alternatives for librealsense/common/model-views.cpp Lines 346 to 360 in f7cdf6e
|
@cdb0y511 If I comment out the imwrite, the code was compiled successfully. The code:--------------- The error:------------------- Any help to fix this, Thanks! |
@hduonggithub
It does not relate with the SDK. I think you modified the sample directly. |
@cdb0y511 When I make the new project, using my opencv (4.4.0) (not using opencv from C:\Program Files (x86)\Intel RealSense SDK 2.0\third-party\opencv-3.4\include\opencv2), then I am able to compile and write depth image correctly in single band 16 bit format. |
I use 3.4 from GitHub. The warp from SDK third party may not include the full function of open CV ,I guess. |
Hi, Will you be needing further help with this? If we don’t hear from you in 7 days, this issue will be closed. Thanks |
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
Issue Description
Hi Support Team,
I am trying to write to images for both color and 16-bit depth from L515 camera. The color and depth image must be aligned and the same dimension. The depth should be in 16-bit format.
I have played with rs-capture and rs-save-to-disk, but my depth images did not look right. I did check the format which is shown as below:
Please advise, Thanks!
Here is my code which is modified from rs-capture and rs-save-to-disk
Here is result
CASE 1: //rs2::align align_to(RS2_STREAM_DEPTH)
CASE 2;s2::align align_to(RS2_STREAM_COLOR); /////////////CASE 2
The text was updated successfully, but these errors were encountered: