-
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 recover colorized depth images in python #9713
Comments
Hi @gachiemchiep Use of this technique to recover a colorized depth image may not be ideal because of the difficulties involved in recovering the image outside of the RealSense SDK and of converting the recovery logic to a programming language other than the C++ scripting provided in the paper. As such, I am not aware of any references about converting the technique for Python other than the discussion at #7930 that you quoted above. There is a detailed Python discussion about image compression alternatives to the recovery method at #8117 |
Hello @MartyG-RealSense |
The SDK's software_device() feature can be used to import a PNG image file and generate a synthetic depth frame from it using its create_synthetic_texture function, like in the C++ example program in the link below. I am not aware of an ability to generate a depth frame from a jpg file with software_device() though. https://github.com/IntelRealSense/librealsense/tree/master/examples/software-device Would it be possible to adapt your project to save depth to file in PNG format instead? Using software_device() on Python does not currently work well in its default state because it has problems with an instruction called dev.create_matcher(RS2_MATCHER_DLR_C) A RealSense user in the above-linked discussion did though provide a 'patch' that they created to try to fix some of the issues. https://support.intelrealsense.com/hc/en-us/community/posts/1500000934242/comments/4403012747923 |
Hi @gachiemchiep Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Just for futures references: The reason why this implementation doesn't work is cos is treating the individual channels (RGB) as bit8, therefore their addition cannot go higher than 255. Adding int() to each channel in the presented code solve the problem. |
@MartyG-RealSense Have you got a reverse example of your Python code, to encode depth values to color? We're making a system with a non-realtime Python encoder, and a realtime GLSL decoder. |
Hi @n1ckfg As you mention a 'reverse' example of encoding depth to color, are you aiming to convert a color image into RealSense depth data, please? Thanks! |
Ah, good point. I mean starting from a grayscale depth image, converting it into the RealSense color format, streaming it as an mp4, and decoding back to the original grayscale value on the other side. |
The main problem will be that once the depth data is converted then it will be very difficult to convert it back to accurate depth values on the other side due to loss of most of the depth information during the conversion. It is certainly possible to live-stream RealSense data as a video feed using tools such as the RealSense GStreamer plugin at the link below. https://github.com/WKDSMRT/realsense-gstreamer Once the original depth data has been converted though then you could likely not go back to those original values. It may be worth considering using RealSense's networking system so that you can transfer the depth data from one computer with the camera attached to another and then access the data in real-time on the destination computer as though it was directly accessing the camera. There is also an older RealSense networking tool called EtherSense that is for Python specifically. https://dev.intelrealsense.com/docs/depth-camera-over-ethernet-whitepaper |
+1 For a formula for DtoRGB. Even without compression, the formula presented in the paper fails for very simple examples. There must be an issue somewhere. |
If anyone has written python code for the encoding and decoding scheme it would be extremely appreciated for you to share it :) |
Yeah, you'll need to extract it from the other stuff but this is what I came up with: |
Agh!! You are a life savor, thanks so much!! What has your experience been like with this depth compression scheme? |
I'm considering this colorization scheme, this one, or some kind of lossless compression. However, I will be generating huge amounts of depth data and the last option is probably not possible. |
Issue Description
Helo @RealSenseCustomerSupport
How can we recover colorized depth images in python?
We follows the document at depth-image-compression-by-colorization-for-intel-realsense-depth-cameras and this issue, but we couldn't calculate correctly.
The code we used to recover colorized depth images
We used the C++ code as in the document but the result didn't make sense. For [ 0, 131, 255] input, the result should be 987 but the C++ code return 6
The text was updated successfully, but these errors were encountered: