so, I coundn’t shut up about this on my social media, so some of you might be already sick and tired of me, but I am sharing it here, hoping to understand if the robotic community may benefit from this work.
By pure chance, I started exploring the topic of Lossless Image Compression, in particular in terms of speed, thinking about real-time streaming and recording.
I got very interesting results that I think may benefit some use cases in robotics.
Before moving forward releasing the code or more details about the algorithm (that is very much still work in progress) I wanted to:
share the binaries with the community to allow people with healthy dose of skepticism to replicate results on their computer.
understand what the actual use case for fast, but still better than PNG, lossless compression is.
These are my results: 3 codecs with 3 different tradeoffs (being Griffin the most balanced one in the 3 dimensions).
Also, if you think that you have a practical application for this, please DM me to discuss this, either here or contacting me on dfaconti@aurynrobotics.com
What’s your proposal here? Are you thinking of an alternative back end for ROS Bag? A new format for image pipeline? A lossless WebRTC-like a streaming utility for a UI? A super cool new fourth thing?
Since it is almost tax day here in the states, I want to know what kind of tax I’m paying to send uncompressed images over the wire in ROS versus using a video streaming codec.
Just some food for thought, if you are streaming series of images (i.e. frames from a camera) most video streaming codecs exploit inter-frame consistency to achieve higher compression ratios and de/compression speeds. What might be handy here is a bench mark on how well a lossless sequential image stream compares to something like a lossy video streaming codec. I would try using a dataset of 10-30s worth of images collected at 30-60 Hz from a ROS Bag (i.e. 300-1800 images taken sequentially) and compare the results against a video streaming codec. This would help determine the trade off between using something like a lossy real-time video streaming codec versus having a series of images with better per-image compression.
Video codec are not good for “random image access”. You have the keyframes and the “delta” from the last keyframe. In order to reconstruct a frame, you have to jump back to the previous keyframe and add the deltas on top. IMHO, I still see use for individual image messages.
I mostly use lossless compression for uint16 depth frames. But here, I need a 16-bit colour channel. This is possible with PNG. QOI officially does not support 16 bit channels (only 8 bit), and never will as the format is now fixed. I guess you could work around this by splitting your single values across multiple channels.
Does “Griffin” support 16 bit single channel images, that could be used for lossless compressed depth?
How does this compare to TIFF? I think you can already use TIFF as format in ROS compressed image transport.
If I could replace 16bit PNG with 16bit “Griffin” for depth images, and this is integrated into the ROS image transport and stays maintained, I would be interested.
You can use the TUM RGB-D dataset Computer Vision Group - Dataset Download. The “*.tgz” files contain colour and depth image. The depth is stored as PNG with 5000:1 scale, i.e. 5000 units are 1 metre.
In both cases, you can recompress the depth PNG images and recompress in any format that supports 16 bit channels. The TUM dataset has more depth typical noise and missing depth readings, while the ICL dataset is purely synthetic. So the TUM dataset is more realistic.
These days not many people seem to have multiple computers on the same robot anymore though. (Maybe that’s why nobody finished ROS2 multimachine launching)
“Griffin BEST” achieves 64% of the size of the PNG? That sounds good at first sight. Is this against the original PNG data? Can you also show the decode/encode speed against PNG and with the different PNG compression levels (0 … 9)?
Well, “Reviewer #3” also always asks me to implement additional baselines, run additional experiments, and squeeze them into non-existing space without a “Please”
But thanks for the results. Those are indeed impressive. I always have issues with high PNG compression rates, as those churn up the CPU and eventually result in frame drops.
Do you know how much of this performance gain stems from compiler optimisation (AVX, …)? If this lands in the ROS repos, then it probably will be compiled for some more generic target without additional CPU features.
Where can I find the reference implementation of “griffin”?
This reminded me there’s ongoing PR to add depth data to LeRobot datasets, and since ROS predates LeRobot by almost two decades, it might be beneficial if you could share some knowledge/tips with them (I have D455 on my robot so I’m also interested in getting this merged).
They want to quantize depth to 12 bit or provide some parameters for tweaking, but from my practical experience with Realsense the depth is super noisy so maybe some lossless compression like @facontidavide talked about could be better? Maybe veterans like @peci1@Katherine_Scott can also chime in
Lossless compression won’t help you with depth noise. In fact, it will preserve the depth noise perfectly. In order to reduce the noise with the RealSense, you have to tune the filter parameters. Or you just use a better ToF camera, such as the Orbbec Femto
Most video codecs (if not all?) use lossy compression. And they are mostly optimised for colour (RGB) data. Applying lossy 3-channel colour compression to single channel depth data will have weird effects. Colour images do not encode metric properties, so they can be compressed by removing subtle “imperceivable” details. Depth images on the other hand encode metric values, and you usually do not want to remove information in the same way you would do with colour images. There are some lossy compression approaches for depth and point clouds, but they do not seem to be widely used.
I don’t fully get how lerobot wants to do the lossy depth compression. They are mentioning “Streaming encoding is enforced for depth maps to avoid lossy PNG-based intermediate compression.”, but there is no “lossy PNG” AFAIK. Compressing depth via 16bit PNG is quite common.
Going from 16bit to 12bit and doing compression will probably produce some garbage values? I wasn’t commenting on denoising it or anything…
I also don’t know how lerobot wants to do lossy depth compression, therefore I just mentioned it here that you could have some insights I guess if you have depth data alongside RGB, you will eventually need to compress it somehow otherwise you’ll end up with insane amounts of data, that you will need to feed to VLA/VLMs for training…