Skip to content

Relative Depth to Absolute through Interpolation #253

@panagiotamoraiti

Description

@panagiotamoraiti

Hello,

I am trying to estimate the true depth in cm from the relative depth and i found out i need to do some kind of calibration based on known depths.

I use the following code:

  # Use depth anything model to generate depth map
  depth = model.infer_image(img) # HxW raw depth map in numpy

  # Relative depth normalized
  depth = (depth - depth.min()) / (depth.max() - depth.min())
  depth = 1 - depth

  # Get relative depth
  relative_depth = depth[center_y, center_x]

  # Convert relative to absolute depth
  rel_depths = np.array([0.04, 0.202, 0.205, 0.92])
  abs_depths = np.array([85, 110, 117, 180])

  
  # Estimate calibration function
  calibration_fn = interp1d(rel_depths, abs_depths, kind='linear', fill_value="extrapolate") 

  # Absolute depth calculation
  absolute_depth = calibration_fn(relative_depth)

I use interp1d method to find out the depth and my code works very well.
I want to ask what is the difference between the lstsq method mentioned on issue #157.

Is my approach correct??? I tried lstsq method but didn't get good results and i don't know why.
If someone can give some intuition it will be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions