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
Getting depth from the camera/aligned_depth_to_color/image_raw/compressed topic #2361
Comments
Hi @rakshith95 Once a depth topic (including compressed ones) is published then typically a script would be used to subscribe to it and retrieve the distance values, like in #1790 and in #2140 (which demonstrates subscribing to /camera/depth/image_rect_raw/compressed to obtain distance). |
Hello @MartyG-RealSense , issue #1790 is for the raw depth topic, which is trivial, but I'm trying to get it to work with the
But I get the error: |
My knowledge of using ROS compressed depth topics is limited, unfortunately. A discussion in the link below suggests using image_transport when accessing compressed depth with OpenCV, which you are already doing. It is notable that the advice in that case links to compressed_image_transport, a plugin package for image_transport, as Intel provide official ROS compressed topic documentation at the link below that also recommends having compressed_image_transport installed. https://dev.intelrealsense.com/docs/ros-wrapper#section-compression-packages |
Hello, I do have the compressed_image_transport plugin installed, so I don't think that's the problem. Can you link me to the file where the compressed depth image is created and published? Maybe I can find or work with something there. |
Are you using ROS1 or ROS2 please? #2140 (comment) mentions that there have been problems with accessing compressed topics in ROS2 Foxy in general, not just with RealSense. I'm not involved in ROS wrapper development but I cannot see any code in the main wrapper files (base_realsense.node.cpp and realsense_node_factory.cpp) that is involved in compression. It is likely handled by ROS itself or the transport plugins. |
@MartyG-RealSense I'm using ROS1. I recorded some data with the compressed topics, and I've been trying to get it to work ever since. If you have any suggestions, it'd be super helpful |
The developer of the ROS1 wrapper posted at #714 (comment) a Python node script that they created called my_depth_subscriber.py that retrieves the distance by subscribing to the aligned topic /camera/aligned_depth_to_color/image_raw The script was posted as a text file, so I have put the script below in case you cannot access the file.
Could you try changing the subscribed topic in that script to /camera/aligned_depth_to_color/image_raw/compressed/ to see whether it produces the desired distance values, please. |
I think I tried this script before with the compressed topic and it didn't work, but I don't remember exactly. Will try it again tomorrow and let you know |
But even my program works perfectly for the |
Hello @MartyG-RealSense , I tried the script with the compressed image topic, and compressedimage message type, with bridge.compressed_imgmsg_to_cv2, but the depth values are capped at 255 (0.255 m) which suggests that it only contains 8 bit values. |
In another case where a RealSense user was using cv2 to get depth values and was restricted to 255, a RealSense team member suggested code at IntelRealSense/librealsense#6101 (comment) for converting to CV_32FC1 You could try editing that script to convert to CV_16UC1 instead. Though the linked to script was C++ so it would need to be converted to Python for use in a Python node script in ROS. |
@MartyG-RealSense I think I figured out the issue. The format of the compressed topic is: "16UC1; jpeg compressed " and for some reason 16 bit jpeg does not work as intended with Cv bridge.
I get the output:
But if I change the dst_format to "jpeg" instead of "png", I get:
|
Great to hear that you made significant progress. Thanks so much for sharing your code! |
Unfortunately, this progress only leaves me with more questions xD. Do you have any idea on whether compressed depth data saved in the jpeg format is useable? |
On this note, why is it that the depth/compressed topic messages are stored in the jpeg format by realsense-ros, and not the png format? |
My understanding of the difference between jpg and png in compression is that jpg has 'lossy' compression (where you lose some quality due to loss of data in exchange for the benefit of smaller data size) whilst png is 'lossless' and so has higher quality but at the cost of a larger data size. In regard to RealSense specifically, I am not familiar with the principles of how compression is handled in the RealSense ROS wrapper though, so cannot offer advice about its format. |
Is there someone who can comment on it? AFAIK there is no support for 16-bit jpeg compression, so this is all the more confusing. |
@MartyG-RealSense any information on where and how the compressed image topics are published would also be super helpful in understanding this further, if you can point me to it. |
As far as I am aware, compressed depth topics are generated when ROS compressed transport plugins are installed and compression is not generated by code in the RealSense ROS wrapper itself. The section of a transport tutorial linked to below may be helpful in explaining how compression is produced in ROS outside of the wrapper. https://github.com/ros-perception/image_transport_tutorials#adding-new-transports |
Hi @rakshith95 Do you require further assistance with this case, please? Thanks! |
Hello |
There is not any further information that I can add to the references provided above, unfortunately. |
Ok can you keep the issue open then, since this seems to be still an open question on whether or not it could work? |
I added a wait to close label to the case as a reminder to keep it open. |
I encountered the same issue. I am using C++, ROS noetic, and RealSense D435. In my program, I use a synchronizer to subscribe 4 topics When I tried to get the distance from topic,
Most of the cases, I get the value Thanks |
@zhangbaozhe I was doing something very similar. I was using a synchronizer for the compressed image, and compressed depth. Unfortunately, I think (90% sure) that the |
Thanks very much @rakshith95 for your advice to @zhangbaozhe :) |
@rakshith95 Thanks for the information. I tried the 8-bit way but it is too small. I haven't tried the |
Hi @zhangbaozhe Do you require further assistance with your compression problem, please? Thanks! |
Hi @rakshith95 Did you make any progress with your compression problems, please? |
@MartyG-RealSense No, unfortunately. I had to give up on using the data, and will have to re-capture with the /.../compressedDepth topic rather than the /.../compressed topic. |
Thanks very much @rakshith95 for the update. |
Case closed due to change of approach. |
|
@Szy20000721 maybe the above helps. |
Hello,
I've seen this issue or some variant of this pop up multiple times, but I don't think any of them have a solution. Is it possible to get the depth from the compressed topic, or is it possible only from the raw topic?
The text was updated successfully, but these errors were encountered: