r/computervision • • 2d ago

Help: Theory Questions about Depth Map Generation?

Hello,

I am trying to generate a (relative) depth map from an input image. The images depict outdoor scenes, meaning: buildings, cars, roads, trees, poles, other city and landscape elements. Images are taken with a phone camera (portrait mode), and are 3072 × 4080 in size.

What models are currently the most accurate? I tested Depth Anything 3 (DA3MONO-Large) and DepthPro2 H+, but I noticed that both are quite inaccurate when it comes to scenery around 30-40+ meters away. The model fails to separate different surfaces properly, and kind of "smears" details together.

Questions:

  1. How can I ensure details past 30ish meters are still decently distinguished by the model instead of being smeared together?
  2. What inference resolution to use? I tried different ones - with DepthPro, you can essentially use everything up to the native resolution if you have enough VRAM. With DA3, you are supposed to use certain multiples of I think 14 or something. I think I tried 1008 for example.
  3. What is the absolute best model for my task/environment, that yields the best results? Anything that outperforms DA3 and DP2?
  4. My goal is to generate a dense depth map, meaning a depth value for each image pixel. My idea was to generate a relative depth map with a model, and leverage sparse but accurate depth data (e.g. handmade laser-measurements/LIDAR data) to then infer the depth for every other pixel. I think that approach should be feasible? Thoughts? I am aware there are metric variants of these models, but my results with them weren't great, that is why I want to use sparse anchors to infer the rest.
  5. I was wondering about 1 vs 2 images - my setup (cameras on a ring) only allow 1 image per direction, - however, the neighboring cameras have some overlap - would that help with improving accuracy? I am basically wondering what are the best options with a single image, and if known camera intrinsic and extrinsics as well as overlap of neighboring cameras allow me to refine the output?
1 Upvotes

11 comments sorted by

2

u/FirstPrinciplesRobot 2d ago

Your anchor idea is sound. Relative models give depth up to an unknown scale and shift, so fit those per image with least squares or RANSAC against your laser points. Do the fit in inverse depth (disparity) space if the model outputs affine-invariant disparity, since fitting in metric depth tends to go wrong at long range.

For the smearing at 30+ m, the main thing is that those pixels are tiny in the model's input, so feeding the whole 12MP frame downsized loses them. Running overlapping crops at higher effective resolution and aligning each crop's output to the full-frame prediction with the same scale/shift fit usually sharpens distant surfaces a lot. Then you can use a guided or edge-aware filter with the RGB image to keep depth edges on object boundaries.

The overlap between neighbouring cameras can help as a sanity check, but with a 10 to 15 cm baseline the disparity at 40 m is only a few pixels, so I wouldn't expect stereo to beat the mono model out there. It's more useful for fixing scale in the near and mid range.

1

u/4bjmc881 1d ago

Thanks for your reply. Good to know that my general idea is right. I got a few follow up questions.

  1. Does it matter in which space the model outputs depth differences? In the end, it is just different scales, right? Even if the model outputs metric values directly, the general tuning process should be similar, correct?
  2. This tile-based approach seems interesting. So, you are saying, to get fine detail in far away parts of them image, cut out that section (tile), and then run the full resolution part of that tile through the model to get a more accurate depth output, and then slot that back into the final depth map? I can imagine a lot of overhead with this - now I would have to ensure that all these tiles agree with one another, no? Since two neighboring tiles might now have different depths so I again would have to least-squares fit that, no? Is there any advantage compared to running the image at full resolution through the model (if it supports that) vs the tiled approach?
  3. Yea, that's fair. I guess for my use-case classical stereo isn't really useful, since the baseline is no more than 15cm. So not really that helpful.

Some Remarks:

One model that seems to yield quite good results with very little to not smearing (especially when using higher inference resolution) is this one: https://microsoft.github.io/MoGe-3/ . It even preserve fine details quite well.

However, it outputs the depth map in metric values. Is that still viable? Can I fit this to my measured anchors points? Are there some important considerations to ensure a quality result? Or is it the same (outlier rejection, Huber Loss, ...?). Any useful recommendations?

2

u/FirstPrinciplesRobot 1d ago

It does matter a bit. If the model outputs affine-invariant disparity, the fit is depth = 1/(a*d + b), so I'd fit a and b in disparity space and invert afterwards, otherwise far points get weighted wrong. If it already outputs metric depth you mostly only need a global scale, maybe a small shift, so the fit is simpler and a robust loss like Huber is still a good idea for bad laser returns.

On tiling, yes, you'd have to align the tiles, and that's the overhead. Use overlapping tiles and fit each one's scale/shift against the full-frame prediction in the overlap, then feather the seams. If the model runs fine at full resolution on your GPU and the far detail looks good, just do that and skip tiling. I haven't tried that specific model, so I can't say how it behaves on your data.

2

u/block_intelligence 2d ago

one more angle on the smearing: those models downsample hard internally, so far objects end up covering a handful of pixels. try tiled inference. run the model on overlapping crops at near native res (say 2 to 4 tiles with decent overlap), then stitch by fitting scale and shift on the overlap region so the seams match. you get way more detail on distant stuff than one global pass at 1008.

also worth testing a global pass for layout plus tiled passes for detail, and blend with the global one as the prior. for the anchors, use robust fitting and keep a few laser points held out so you can measure the error honestly instead of eyeballing it.

if you want to compare a couple of pipelines properly, a small eval set with held-out lidar points beats picking by leaderboard. we build this kind of thing at Block Intelligence if you ever want a second pair of hands.

1

u/4bjmc881 1d ago

Hey, thanks for the reply. Yea, you are the second person that recommends this tiling approach. It seems like common practice for this, I suppose? But just like I wrote in my reply to the other poster, - doesn't the tile based approach introduce additional disagreement-errors between tiles? Say I have an area in my input image of buildings in the distance, perhaps 50m or so. I would now leverage this tile approach, by cutitng out small patches, finding that patch in the full resolution image and run inference on that, so there are more pixels to work with. I do that for multiple patches. At the end I get back small depth maps for these sections, I could scale back down to fit into the output depth map. But now, what if the two patches depth map have disagreements? Doesnt that mean running fitting again between each tile?

You mentioned performing a global pass first? I struggle to visualize how all these individual steps work together (patch-based depth map, global pass, anchors (on global pass?) etc.

Is there an advantage to this tile approach vs running inference on the full res input image (if the hardware and model are capable)? Seems like less overhead afterwards?

I understand that one shouldn't chase models, alone, but try to engineer within the constraints of the given environment. But I have to say, I am currently testing this model: https://microsoft.github.io/MoGe-3/ and the results are vastly better than Depth Anything 3 or DepthPro2, especially when using the giant variant.

1

u/block_intelligence 1d ago

yeah tiles do disagree, but you don't fit between every pair. use the global pass as the single reference and fit each tile to it (scale and shift, robust fit like RANSAC or huber, on the pixels where the global depth is trustworthy). since every tile is pinned to the same reference, they end up consistent with each other without pairwise fitting. then feather the blend across the overlap so seams don't show.

full res single pass is simpler and if your gpu can do it, try that first. the catch is most of these models run at a fixed internal res or lose detail in far regions anyway, so tiling mostly pays off when objects of interest are tiny in frame. tbh run both on a held out set of lidar points and see if the extra pipeline actually buys you anything.

and yeah MoGe style models being better is plausible, geometry-focused training helps a lot with far stuff. if it already looks good I'd just use it and skip the tiling.

1

u/blobules 2d ago

Given that you have calibrated cameras on a rigs, have you tried classical stereo? To achieve good results at long distance, you should increase the baseline (separation between two cameras) as much as possible.

1

u/4bjmc881 2d ago

I have not yet tried that. The separate is around 10cm, maybe 15cm at most. Also, the overlap region between neighboring cameras is only a small part of the images, so how would you leverage this to make the most out of it?

Would you combine these things? depth map + truth anchors + classical stereo? If so, how? Do you mind ellaborating a bit?