Depth estimation: when does a depth map mean meters?
深度估计
Train every parameter of a tiny RGB depth network; derive reprojection gradients and test scale ambiguity, masks and evaluation.
depth-estimationA convincing shape can still be the wrong size
A depth model puts a chair at two meters and a wall at four. The actual distances are one and two meters. It has preserved which surface is closer and the ratio between their depths. A robot using those numbers to decide where to stop would still be wrong.
Depth estimation assigns depth values to image locations. Before comparing methods, ask what those values mean: distance along the camera’s optical axis, distance along a viewing ray, inverse depth, or a relative ordering? A colorful depth map does not answer that question.
| Available information | What constrains depth | What still needs checking |
|---|---|---|
| One image | Perspective cues and learned regularities | Absolute scale and unfamiliar scenes |
| Several images with camera motion | Geometric correspondence and motion | Translation scale, occlusion and moving objects |
| A calibrated stereo pair with known baseline | Correspondence plus a physical length | Matching, calibration and depth uncertainty |
| Images paired with depth measurements | The supervision’s definition and units | Measurement gaps, noise and domain differences |
For a single image, a larger object farther away can have the same projection as a smaller object nearby. Learning can use regularities in its training data to choose an answer; it does not remove that geometric ambiguity. Eigen and colleagues learn a coarse depth prediction and refine it; later work studies how supervision, reprojection and dataset mixing change what a model can recover. Single-image prediction Dataset mixing
A useful baseline predicts one constant depth estimated from the training set. It has no scene geometry, but it establishes whether a learned model improves the chosen metric without using test labels. A second diagnostic rescales predictions using test ground truth: useful for studying relative structure, but unsuitable as an unaided metric-depth result.
Here we implement a complete, tiny RGB-to-depth network and the geometry needed to inspect self-supervision. There are no pretrained weights or hidden model calls. The examples show why scale, masks and coordinate conventions matter; they do not establish performance on photographs.
Define the distance before choosing the loss
Pixels, camera points and two different distances
Let p be the homogeneous pixel vector, K the invertible camera intrinsic matrix, and X a point in camera coordinates. In the distortion-free pinhole model:
Here focal lengths and the optional skew s are in pixel units, and Z is the optical-axis depth. The program allows skew; the usual zero-skew OpenCV form sets s to zero. Lens distortion must be removed or modeled before applying this ideal geometry to measured image coordinates. Camera model and coordinate conventions
The Euclidean distance to the camera center is a different quantity:
Away from the principal point, the ray vector generally has length greater than one. In the example, Z=2 gives a range of about 2.29129. Replacing the ray by a unit vector while keeping the same Z changes the reconstructed point.
Coordinate resizing also needs a definition. Under u’=a u and v’=a v, multiply the first two rows of K by a; the same scene point retains its depth. Cropping subtracts the crop offset from the principal point. Real image resamplers may use a half-pixel convention, which needs the corresponding coordinate transform. Eigen’s training augmentation interprets an image scaling as moving the camera closer and adjusts the depth labels; that is a different assumption from merely changing image coordinates. Intrinsics under resizing Training augmentation, physical page 5
Supervision: learn log depth without erasing the scale question
Let the network predict a log depth l_i, with positive ground-truth depth y_i. For n valid pixels, write e_i=l_i−log(y_i). A useful family of losses is:
At lambda=0 this is mean squared log error. At lambda=1 a common additive shift of all log predictions has no effect, so a common multiplicative depth scale is unpenalized. At lambda=0.5, used in the original training formulation, a scale-sensitive term remains. The derivative at a valid pixel is 2(e_i−lambda mean(e))/n; invalid pixels receive zero gradient. A mask with no valid ground truth is an error, not a zero-loss success. Loss and scale-invariant error
For lambda=1, three equivalent expressions make the meaning precise:
The middle sum includes all ordered pairs. Its factor of one half is essential. The inspected first arXiv version prints 1/n² in its pairwise Eq. (2), although its Eqs. (1) and (3) give the centered form. For errors [0,1], the centered loss is 0.25; the unhalved ordered-pair expression gives 0.5. The implementation and tests use the explicitly derived identity above rather than treating those printed expressions as interchangeable. Version-specific equation check, physical page 4
Our network has a 2×2 convolution from three input channels to two hidden channels, tanh activations, and a shared linear log-depth output:
A 3×4 RGB image produces a 2×3 output: valid convolution reduces each spatial dimension by one. There are 24 convolution weights, two hidden biases, two output weights and one output bias, totaling 29 parameters. Given the output gradient g, the hidden preactivation gradient is g v_c(1−h²); summing its products with input patches gives the kernel gradient. Overlapping patches add their contributions to the input gradient. The code implements every step, and finite differences check every parameter and input scalar.
This small network is an original teaching model. It is not Eigen’s coarse/fine architecture: that work trains the coarse network before training the fine stage with the coarse output fixed. Nor does this example establish that a single local patch suffices for realistic scene understanding. Architecture and training sequence
Self-supervision: ask whether predicted geometry explains another image
Suppose a target pixel p has depth Z, and the transform from the target camera to a source camera is X_s=R X_t+t. With known intrinsics, the sampling coordinate is:
Sample the source image at u_s and compare its appearance with the target pixel. This reasoning assumes compatible camera geometry and sufficiently stable appearance; a moving object, an occlusion or a reflection can violate it. Monodepth2 uses a mixture of SSIM and L1 appearance error, along with an edge-aware smoothness term on normalized inverse depth. Our code isolates a masked MSE example with fixed pose and equal target/source intrinsics. Reprojection and losses
The depth derivative can be checked without a neural network. Put a=K R K^-1 p and b=K t, so the projected homogeneous point is Za+b. For its first image coordinate:
The vertical derivative has the same form with y in place of x. If t=0, both vanish: a pure camera rotation does not provide this depth signal. If Z and t are multiplied by the same positive constant, the image projection also stays unchanged. Unknown translation scale therefore remains coupled to depth scale; the tests check both properties with an actual nonidentity rotation.
For a sample inside a source-image cell, bilinear interpolation uses its four corners:
Within the cell its spatial derivative is explicit. For valid-pixel MSE, the depth gradient follows the chain from image error through sampling coordinates to Z:
Our sampler accepts only coordinates whose four neighbors are in bounds, excludes the final row/column boundary, and masks points behind the source camera. It uses no border padding. The derivative is local: crossing a cell boundary or changing the valid set is not covered by one smooth branch of the formula. The program does not learn pose or handle visibility with a full scene renderer.
With several source images, minimum reprojection chooses the smallest source error at each target pixel. A strict automask additionally asks whether warping improves on using the source images without the geometric warp:
This can avoid forcing a pixel to agree with an occluded source and can suppress uninformative stationary-view explanations. It cannot guarantee correct depth. Our numerical example returns minimum errors [0.1,0.2] and mask [true,false]. Equal errors fail the strict test. The fixed Monodepth2 code adds small random noise to identity errors to break ties, takes the minimum across candidates, and averages the selected loss; our boolean selector is deliberately not a reproduction of that whole reduction. Paper method Pinned training code
Evaluate the prediction you actually intend to use
Common metrics include absolute relative error, RMSE, and a threshold accuracy:
RMSE carries the depth unit. AbsRel and the ratio threshold are dimensionless. The threshold is strict: a ratio equal to 1.25 does not pass. Invalid ground-truth pixels, crops, clipping and evaluation depth range must be specified before comparing results. In the pinned evaluation code, masking/cropping precedes median scaling, and prediction clipping follows it. Metrics code Evaluation ordering
Median scaling uses median(Z)/median(prediction), not the median of per-pixel ratios. A prediction exactly twice the truth has AbsRel=1 and delta1=0 in our example; ground-truth scaling by 0.5 makes both perfect. That is evidence about relative structure, not unaided recovery of meters.
MiDaS considers incompatible supervision in a common inverse-depth/disparity space, including scale and shift ambiguity. Least-squares affine alignment in a stated domain solves:
Here q must be declared: an affine transformation of inverse depth is not generally a common scale of depth. Constant predictions do not identify both parameters, so our function rejects that case. MiDaS also studies robust alignment and losses; its robust scale uses mean absolute deviation about a median location, which should not be confused with a median absolute deviation. Our program demonstrates ordinary least-squares alignment only. Alignment objectives, physical pages 5–6
Run the geometry and train all 29 parameters
Save the following as depth.py and run it with Python and NumPy. It was checked with Python 3.12.4 and NumPy 1.26.4. The input is synthetic, generated with stated seeds. Depth labels are positive; log predictions remain unconstrained until interpreted through an exponential. No external model, image download or GPU is required.
"""Original depth teaching computations. No pretrained model or external data."""
import json
import numpy as np
def finite(value, shape=None):
a=np.asarray(value,dtype=float)
if not np.isfinite(a).all() or (shape is not None and a.shape!=shape):
raise ValueError('Finite values with the stated shape required')
return a
def intrinsics(k):
k=finite(k,(3,3))
if not np.allclose(k[2],[0,0,1]) or k[0,0]<=0 or k[1,1]<=0 or k[1,0]!=0:
raise ValueError('Pinhole intrinsics with positive focal lengths required')
return k
def rays(pixels,k):
p=finite(pixels)
if p.ndim!=2 or p.shape[1]!=2:raise ValueError('Pixel array must be N by 2')
return np.linalg.solve(intrinsics(k),np.c_[p,np.ones(len(p))].T).T
def backproject(pixels,depth,k):
ray=rays(pixels,k);z=finite(depth,(len(ray),))
if np.any(z<=0):raise ValueError('Positive optical-axis depth required')
return ray*z[:,None]
def project(points,k):
x=finite(points)
if x.ndim!=2 or x.shape[1]!=3 or np.any(x[:,2]<=0):raise ValueError('Points must be in front of the camera')
q=x@intrinsics(k).T
return q[:,:2]/q[:,2:]
def warp_coordinates(pixels,depth,k,rotation,translation):
"""Target-to-source rigid transform; derivative of source pixels w.r.t. Z."""
k=intrinsics(k);ray=rays(pixels,k);z=finite(depth,(len(ray),));r=finite(rotation,(3,3));t=finite(translation,(3,))
if np.any(z<=0) or not np.allclose(r.T@r,np.eye(3),atol=1e-9) or not np.isclose(np.linalg.det(r),1):
raise ValueError('Positive depths and a proper rotation required')
direction=(ray@r.T)@k.T
q=direction*z[:,None]+t@k.T
visible=q[:,2]>0
denom=np.where(visible,q[:,2],1)
uv=q[:,:2]/denom[:,None]
derivative=(direction[:,:2]*q[:,2:]-q[:,:2]*direction[:,2:])/(denom[:,None]**2)
uv[~visible]=np.nan;derivative[~visible]=0
return uv,derivative,visible
def bilinear(image,coordinates):
"""Interior samples only. No border padding; last row/column are excluded."""
image=finite(image);uv=np.asarray(coordinates,dtype=float)
if image.ndim!=2 or min(image.shape)<2 or uv.ndim!=2 or uv.shape[1]!=2:
raise ValueError('At least 2 by 2 image and N by 2 coordinates required')
h,w=image.shape
valid=np.isfinite(uv).all(1)&(uv[:,0]>=0)&(uv[:,0]<w-1)&(uv[:,1]>=0)&(uv[:,1]<h-1)
safe=np.where(np.isfinite(uv),uv,0)
x=np.clip(safe[:,0],0,w-2);y=np.clip(safe[:,1],0,h-2)
# Keep fractional coordinates up to the last interior cell.
x=np.where(valid,safe[:,0],x);y=np.where(valid,safe[:,1],y)
ix=np.floor(x).astype(int);iy=np.floor(y).astype(int);u=x-ix;v=y-iy
a,b,c,d=image[iy,ix],image[iy,ix+1],image[iy+1,ix],image[iy+1,ix+1]
value=(1-u)*(1-v)*a+u*(1-v)*b+(1-u)*v*c+u*v*d
gradient=np.c_[(1-v)*(b-a)+v*(d-c),(1-u)*(c-a)+u*(d-b)]
value[~valid]=0;gradient[~valid]=0
return value,gradient,valid
def photometric_depth_loss(pixels,depth,target,source,k,rotation,translation):
uv,duv,front=warp_coordinates(pixels,depth,k,rotation,translation)
sampled,image_gradient,inside=bilinear(source,uv);target=finite(target,(len(sampled),))
mask=front&inside;n=int(mask.sum())
if not n:raise ValueError('No valid photometric samples')
error=sampled-target;grad=np.zeros(len(sampled))
grad[mask]=2*error[mask]*np.sum(image_gradient[mask]*duv[mask],axis=1)/n
return float(np.mean(error[mask]**2)),grad,mask
def reprojection_selection(warped_errors,identity_errors):
"""Paper-style strict auto-mask; no random tie noise and no loss reduction."""
a=finite(warped_errors);b=finite(identity_errors,a.shape)
if a.ndim!=2 or not min(a.shape) or np.any(a<0) or np.any(b<0):
raise ValueError('Nonnegative source-by-pixel errors required')
minimum=a.min(axis=0)
return minimum,minimum<b.min(axis=0)
def log_depth_loss(log_prediction,truth,mask=None,lam=0.5):
"""Mean squared log error minus lambda times squared mean log error.
lambda=1 is invariant to global log shifts; lambda=.5 retains a scale term.
"""
p=finite(log_prediction);y=np.asarray(truth,dtype=float)
valid=np.ones(p.shape,dtype=bool) if mask is None else np.asarray(mask,dtype=bool)
if y.shape!=p.shape or valid.shape!=p.shape or not valid.any() or not 0<=lam<=1:
raise ValueError('Compatible shapes, nonempty mask and lambda in [0,1] required')
if not np.isfinite(y[valid]).all() or np.any(y[valid]<=0):raise ValueError('Valid truth depths must be positive')
error=p[valid]-np.log(y[valid]);mean=error.mean();grad=np.zeros_like(p)
grad[valid]=2*(error-lam*mean)/len(error)
return float(np.mean(error**2)-lam*mean*mean),grad
def initialize(seed=31):
rng=np.random.default_rng(seed)
return {'kernel':rng.normal(0,.15,(2,2,3,2)), 'bias':rng.normal(0,.05,2),
'head':rng.normal(0,.2,2),'offset':np.array([.1])}
def forward(image,parameters):
x=finite(image)
if x.ndim!=3 or x.shape[2]!=3 or min(x.shape[:2])<2:raise ValueError('At least 2 by 2 RGB image required')
w=finite(parameters['kernel'],(2,2,3,2));b=finite(parameters['bias'],(2,))
head=finite(parameters['head'],(2,));offset=finite(parameters['offset'],(1,))
a=np.empty((x.shape[0]-1,x.shape[1]-1,2))
for y,z in np.ndindex(a.shape[:2]):
a[y,z]=np.tanh(np.tensordot(x[y:y+2,z:z+2],w,axes=3)+b)
prediction=a@head+offset[0]
return prediction,(x,a,parameters)
def backward(incoming,cache):
x,a,p=cache;g=finite(incoming,a.shape[:2])
dz=g[:,:,None]*p['head']*(1-a*a)
dw=np.zeros_like(p['kernel']);dx=np.zeros_like(x)
for y,z in np.ndindex(g.shape):
dw+=x[y:y+2,z:z+2,:,None]*dz[y,z]
dx[y:y+2,z:z+2]+=np.tensordot(p['kernel'],dz[y,z],axes=([3],[0]))
gradients={'kernel':dw,'bias':dz.sum((0,1)),'head':np.sum(g[:,:,None]*a,axis=(0,1)),
'offset':np.array([g.sum()])}
return dx,gradients
def depth_metrics(prediction,truth,mask=None):
p=np.asarray(prediction,dtype=float);y=np.asarray(truth,dtype=float)
valid=np.ones(p.shape,dtype=bool) if mask is None else np.asarray(mask,dtype=bool)
if y.shape!=p.shape or valid.shape!=p.shape or not valid.any():raise ValueError('Nonempty compatible mask required')
p,y=p[valid],y[valid]
if not np.isfinite(p).all() or not np.isfinite(y).all() or np.any(p<=0) or np.any(y<=0):
raise ValueError('Positive finite valid predictions and truth required')
ratio=np.maximum(p/y,y/p)
return {'AbsRel':float(np.mean(np.abs(p-y)/y)),'SqRel':float(np.mean((p-y)**2/y)),
'RMSE':float(np.sqrt(np.mean((p-y)**2))),'log_RMSE':float(np.sqrt(np.mean((np.log(p)-np.log(y))**2))),
'delta1':float(np.mean(ratio<1.25))}
def median_scale(prediction,truth):
p=finite(prediction);y=finite(truth,p.shape)
if not p.size or np.any(p<=0) or np.any(y<=0):raise ValueError('Positive nonempty depths required')
scale=float(np.median(y)/np.median(p))
return scale*p,scale
def affine_alignment(prediction,target):
"""OLS scale/shift in the caller's stated domain; not metric calibration."""
p=finite(prediction);y=finite(target,p.shape)
if p.size<2:raise ValueError('At least two values required')
centered=p-p.mean();den=float(np.sum(centered**2))
if den<=np.finfo(float).eps*max(1.,float(np.sum(p*p))):raise ValueError('Scale is not identifiable for constant predictions')
scale=float(np.sum(centered*(y-y.mean()))/den);shift=float(y.mean()-scale*p.mean())
return scale*p+shift,scale,shift
def demo():
k=np.array([[4.,0,3],[0,4,2],[0,0,1]])
pixels=np.array([[1.,1.],[2.,1.],[3.,1.],[1.,2.],[2.,2.],[3.,2.]])
z=np.full(6,2.);r=np.eye(3);t=np.array([.2,0,0])
uv,_,_=warp_coordinates(pixels,z,k,r,t)
rescaled,_,_=warp_coordinates(pixels,7*z,k,r,7*t)
angle=.1;rotation=np.array([[np.cos(angle),0,np.sin(angle)],[0,1,0],[-np.sin(angle),0,np.cos(angle)]])
pure1,d_pure,_=warp_coordinates(pixels,z,k,rotation,np.zeros(3))
pure2,_,_=warp_coordinates(pixels,3*z,k,rotation,np.zeros(3))
yy,xx=np.mgrid[:5,:7];source=.1*xx+.04*yy+.01*xx*yy
target=bilinear(source,uv)[0]
photo_before,photo_gradient,_=photometric_depth_loss(pixels,np.ones(6),target,source,k,r,t)
photo_after=photometric_depth_loss(pixels,np.ones(6)-photo_gradient,target,source,k,r,t)[0]
image=np.random.default_rng(13).normal(size=(3,4,3));p=initialize();truth=np.array([[1.,2.,3.],[2.,3.,4.]])
pred,cache=forward(image,p);loss,grad=log_depth_loss(pred,truth);dx,dp=backward(grad,cache)
trained={key:value-.2*dp[key] for key,value in p.items()};new,_=forward(image,trained)
invariant_before=log_depth_loss(pred,truth,lam=1)[0];invariant_after=log_depth_loss(pred+2,truth,lam=1)[0]
aligned,scale=median_scale(2*truth,truth)
inverse=np.array([1.,2.,4.]);inverse_target=2*inverse+1
_,s,b=affine_alignment(inverse,inverse_target)
mins,mask=reprojection_selection([[.1,10],[5,.2]],[[.3,.1],[.4,.8]])
return {'camera_scale_uv_max_difference':float(np.max(np.abs(uv-rescaled))),
'pure_rotation_depth_uv_max_difference':float(np.max(np.abs(pure1-pure2))),
'pure_rotation_depth_derivative_max':float(np.max(np.abs(d_pure))),
'ray_depth_two_range':np.linalg.norm(backproject(pixels[:1],[2.],k),axis=1).tolist(),
'photometric_loss_before':photo_before,'photometric_loss_after_depth_update':photo_after,
'network_parameters':sum(v.size for v in p.values()),'supervised_loss_before':loss,
'supervised_loss_after':log_depth_loss(new,truth)[0],'input_gradient_norm':float(np.linalg.norm(dx)),
'lambda_one_loss_before_log_shift':invariant_before,'lambda_one_loss_after_log_shift':invariant_after,
'raw_twice_depth':depth_metrics(2*truth,truth),'median_scale':scale,'aligned_twice_depth':depth_metrics(aligned,truth),
'inverse_depth_alignment':[s,b],'minimum_reprojection':mins.tolist(),'auto_mask':mask.tolist()}
if __name__=='__main__':print(json.dumps(demo(),indent=2))
The actual output is:
{
"camera_scale_uv_max_difference": 2.220446049250313e-16,
"pure_rotation_depth_uv_max_difference": 4.440892098500626e-16,
"pure_rotation_depth_derivative_max": 0.0,
"ray_depth_two_range": [
2.29128784747792
],
"photometric_loss_before": 0.00212,
"photometric_loss_after_depth_update": 0.0021079592191263186,
"network_parameters": 29,
"supervised_loss_before": 0.4889422306498121,
"supervised_loss_after": 0.3554711005377543,
"input_gradient_norm": 0.04371739294210714,
"lambda_one_loss_before_log_shift": 0.21924115718239046,
"lambda_one_loss_after_log_shift": 0.21924115718239,
"raw_twice_depth": {
"AbsRel": 1.0,
"SqRel": 2.5,
"RMSE": 2.6770630673681683,
"log_RMSE": 0.6931471805599452,
"delta1": 0.0
},
"median_scale": 0.5,
"aligned_twice_depth": {
"AbsRel": 0.0,
"SqRel": 0.0,
"RMSE": 0.0,
"log_RMSE": 0.0,
"delta1": 1.0
},
"inverse_depth_alignment": [
2.0,
1.0
],
"minimum_reprojection": [
0.1,
0.2
],
"auto_mask": [
true,
false
]
}
The supervised loss drops from approximately 0.48894 to 0.35547 after one update. The photometric example makes a smaller improvement because it updates the explicit depth values, not the network or pose. A tiny loss decrease checks the implemented derivative; it is not an estimate of real-world accuracy.
For an H×W image, a dense k×k convolution with Cin inputs and Cout outputs takes order HW k² Cin Cout operations. Its parameter storage is order k² Cin Cout, with order HW Cout hidden activations for this layer. A warp, bilinear sample, valid-pixel loss or metric is linear in the number of evaluated pixels; comparing S sources costs order SHW. Memory can be reduced by processing source errors sequentially when only their minimum is needed. These costs describe the operators here, not a full foundation model.
The companion checks cover scalar convolution, all 29 parameter derivatives and 36 input derivatives, camera round trips, resizing/cropping, pure rotation, joint depth/translation scaling, warp and sampling derivatives, masks, threshold boundaries, alignment degeneracy and the ordered-pair loss identity. Stereo-specific calculations are developed in the separate stereo-vision topic.
What a good-looking map leaves unresolved
- Scale: training priors can suggest meters, but a test-time correction using true depths cannot count as independent scale recovery. Report corrected and uncorrected results separately.
- Visibility and appearance: a photometric minimum can select a coincidental match. Automasking and smoothness do not prove the selected surface is visible or correctly reconstructed.
- Supervision: measured depths have masks and noise; synthetic depth has its own scene-coverage and rendering assumptions. A dense target should not automatically be called perfect ground truth.
- Coordinates: lens distortion, image resizing, focal changes and pixel-center conventions affect projection. The inspected code normalizes by width−1/height−1, while its
grid_samplecall omits an explicitalign_corners; reproducing it requires the intended framework version. Our pixel-coordinate sampler has its own explicit convention. Pinned layers Pinned sampler call - Generalization: new cameras, transparent surfaces, unusual object scales or a shifted scene distribution require tests on appropriate held-out data. This tiny network and its synthetic losses provide none of those validations.
Four checks before trusting a depth map
- Distance: a pixel has ray K^-1 p=[0.5,0,1] and optical depth 2. What is its camera point and range?
Answer: The point is [1,0,2], with range sqrt(5), approximately 2.236. Multiplying a unit ray by 2 would instead produce range 2 and a smaller optical depth. State which distance the model predicts before backprojecting.
- Scale and loss: errors in log depth are [0,1]. Compute the lambda=1 loss. Then add 3 to both errors. Does the lambda=0.5 loss have the same invariance?
Answer: Centering gives [−0.5,0.5], so the first loss is 0.25 before and after the shift. For lambda=0.5 it is 0.5−0.5×0.25=0.375 initially, and 12.5−0.5×12.25=6.375 after shifting to [3,4]. The scale term remains. Summing all ordered pair differences without the factor one half would incorrectly give 0.5 for the invariant loss.
- Self-supervision: two images differ only by a known camera rotation. Can a depth update reduce a geometry-based warp error in this ideal model? What changes with a translated camera?
Answer: With t=0, the Z factor cancels in the homogeneous projection, so the warp has zero depth derivative. Nonzero translation can supply depth-dependent parallax, but occlusion and appearance failures still matter. If translation itself has unknown scale, jointly scaling it and depth preserves the warp.
- Evaluation: every predicted depth is twice the truth. After per-image median scaling, all displayed errors vanish. What should the result say, and what small experiment exposes the distinction?
Answer: State that evaluation used ground-truth median scaling and recovered perfect relative structure in this constructed example. Report the raw result alongside it: AbsRel=1 and delta1=0. Re-run with median scaling disabled, and keep the same valid mask and depth units. Neither a changed mask nor a hidden crop should explain the comparison.
From scale-aware losses to depth and ray models
Eigen’s first arXiv submission was 2014-06-09. It combined coarse and fine prediction with an explicit discussion of scale-invariant error. Monodepth2’s first submission was 2018-06-04, whereas the paper version used here is ICCV2019. Its minimum reprojection and automasking address failure modes in appearance-based supervision rather than eliminating all depth ambiguity. Eigen history Monodepth2 history
MiDaS first appeared on arXiv on 2019-07-02 and investigates mixing heterogeneous datasets while evaluating transfer to unseen datasets. Depth Anything V2, first submitted on 2024-06-13, uses a strong synthetic-data teacher to label real images for student training. That bridge targets the gap between accurate supervision and diverse real imagery; it is not evidence that all synthetic labels or every new scene are reliable. MiDaS history V2 method V2 history
Depth Anything 3, first submitted on 2025-11-13, extends the input setting to single images or multiple views, optionally with known camera poses. Its inspected formulation predicts depth together with unnormalized world-space rays: a world point is origin plus optical depth times ray direction. This differs from calling the depth a range along a unit ray. The same page’s camera-recovery paragraph uses a matrix convention that does not directly agree with the preceding ray equation; this article therefore does not reproduce that recovery derivation or infer the behavior of uninspected code. Depth/ray formulation, physical page6 DA3 history
Read these approaches as answers to different constraints: available supervision, camera knowledge, relative versus metric scale, and transfer across datasets. Their paper names alone do not define a fair comparison. A useful next project fixes an evaluation protocol, runs the constant baseline, trains a small model, and separates geometry errors from scale errors before trying a larger architecture.
Make a prediction, then check
A prediction is twice the true depth everywhere. Ground-truth median scaling makes its error zero. What has been demonstrated?
Learning objectives
- Distinguish optical depth, ray range, relative structure and metric scale.
- Derive masked log-depth loss, reprojection and bilinear depth gradients.
- Train and gradient-check all parameters of a complete tiny RGB depth network.
- Evaluate raw and aligned predictions without hiding ground-truth scaling.
Prerequisites & connections
Explore related knowledge →References
- OpenCV 4.12.0 — Camera Calibration and 3D Reconstruction
OpenCV contributors - Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
Eigen, David; Puhrsch, Christian; Fergus, Rob · 2014 - Digging Into Self-Supervised Monocular Depth Estimation
Godard, Clément; Mac Aodha, Oisin; Firman, Michael; Brostow, Gabriel · 2019 - Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer
Ranftl, René; Lasinger, Katrin; Hafner, David; Schindler, Konrad; Koltun, Vladlen · 2020 - Depth Anything V2
Yang, Lihe; Kang, Bingyi; Huang, Zilong; Zhao, Zhen; Xu, Xiaogang; Feng, Jiashi; Zhao, Hengshuang · 2024 - Depth Anything 3: Recovering the Visual Space from Any Views
Lin, Haotong; Chen, Sili; Liew, Junhao; Chen, Donny Y.; Li, Zhenyu; Shi, Guang; Feng, Jiashi; Kang, Bingyi · 2025 - Monodepth2 — layers.py
Niantic and Monodepth2 contributors · 2022 - Monodepth2 — trainer.py
Niantic and Monodepth2 contributors · 2022 - Monodepth2 — evaluate_depth.py
Niantic and Monodepth2 contributors · 2022 - Depth Map Prediction from a Single Image using a Multi-Scale Deep Network — submission history
arXiv · 2014 - Digging Into Self-Supervised Monocular Depth Estimation — submission history
arXiv · 2018 - Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer — submission history
arXiv · 2019 - Depth Anything V2 — submission history
arXiv · 2024 - Depth Anything 3: Recovering the Visual Space from Any Views — submission history
arXiv · 2025
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-08 · Codex single-AI-author technical check: scoped original papers, official camera documentation and applicable pinned code; 28 numerical, bilingual and figure checks; 12 equations per language, complete program and actual output, four explained exercises, original computed figures with four-font boundary checks. Not human peer review, a full foundation model or a real-data benchmark.
- 28 formal checks cover independent geometry/gradient/boundary calculations, bilingual/reference/exercise consistency and this topic’s computed figures. The two-topic total of 54 includes 42 numerical tests, not 54 independent numerical reproductions.
- Twelve display equations match exactly across languages; the complete embedded program reproduces the displayed output, and four explained answers are checked. Reading scopes and source-equation ambiguities are explicit; unreconciled derivations are not adopted.
- Four original SVGs across languages and desktop/mobile layouts were inspected with four-font boundary checks. Figures use outputs checked against the program; synthetic inputs, scale assistance and failure cases are not presented as benchmark performance.
- Checked 29 parameter and 36 input gradients, pure-rotation/scale ambiguity, warp gradients, masks, strict thresholds and the one-half factor in the ordered-pair loss.
- Final static inspection found visible strong-emphasis delimiters in Chinese list headings. Converted nine exact spans to strong tags; reversing those substitutions reproduces the original text exactly, with equations, code, references and wording unchanged. Original article/review records are archived and the six-file freeze is unchanged.
Source locations checked:
- OpenCV 4.12.0 — Camera Calibration and 3D Reconstruction · Pinhole introduction web lines 16-57; epipolar equations 1914-1917 and 2002-2007; stereoRectify 3196-3234; triangulatePoints 3267-3289. Retrieved with web tool; no local HTML fingerprint recorded.
- Depth Map Prediction from a Single Image using a Multi-Scale Deep Network · Physical pages 3-5 fully read; page 4 visually inspected; page 1 first 16 extracted lines. Coarse/fine architecture and sequential training; log-scale metric Eq1-3 and training loss Eq4. First arXiv version only. Eq2 coefficient conflicts with Eq1/3 if i,j means all ordered pairs; independently checked rather than copied.
- Digging Into Self-Supervised Monocular Depth Estimation · Physical pages 3-4 fully read; page 1 first 16 extracted lines. Target-to-source reprojection, bilinear warp, SSIM/L1 photometric error, normalized inverse-depth smoothness, minimum reprojection and strict automask. Toy MSE and fixed pose are explicitly different. Full-resolution multiscale details on later pages not yet reviewed.
- Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer · Physical pages 5-6 fully read; page 1 first 16 extracted lines. Common inverse-depth/disparity domain, affine scale/shift alignment Eq2-4, robust median location with mean absolute deviation Eq5-6, trimmed loss and mixed datasets. No dataset rights or reported performance adopted.
- Depth Anything V2 · Physical pages 3-4 fully read; page 1 first 16 extracted lines. Label noise, synthetic teacher to pseudo-labeled real images to student; remaining synthetic domain gap and coverage limits. Perfect synthetic labels, privacy guarantees and reported scores are not adopted as facts. Later implementation sections not fully read.
- Depth Anything 3: Recovering the Visual Space from Any Views · Physical pages 5-6 fully read; page 6 visually inspected; page 1 first 16 extracted lines. Input-adaptive cross-view transformer, depth/ray heads, optional camera tokens; unnormalized world ray R inv(K) p and P=t+D*d. Camera recovery paragraph later states H=K R; under the preceding convention these are not interchangeable. No recovery implementation or benchmark claims adopted.
- Monodepth2 — layers.py · Pinned commit b676244e5a1ca55564eb5d16ab521a48f823af31; read lines 139-198; 248-270. Read only; not executed or copied. Non-commercial restriction noted in license opening.
- Monodepth2 — trainer.py · Pinned commit b676244e5a1ca55564eb5d16ab521a48f823af31; read lines 375-391; 460-485. Read only; not executed or copied. Non-commercial restriction noted in license opening.
- Monodepth2 — evaluate_depth.py · Pinned commit b676244e5a1ca55564eb5d16ab521a48f823af31; read lines 180-214. Read only; not executed or copied. Non-commercial restriction noted in license opening.
- Depth Map Prediction from a Single Image using a Multi-Scale Deep Network — submission history · Title, authors and submission history checked. First submitted 2014-06-09; not a conference publication date.
- Digging Into Self-Supervised Monocular Depth Estimation — submission history · Title, authors and submission history checked. First submitted 2018-06-04; not a conference publication date.
- Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer — submission history · Title, authors and submission history checked. First submitted 2019-07-02; not a conference publication date.
- Depth Anything V2 — submission history · Title, authors and submission history checked. First submitted 2024-06-13; not a conference publication date.
- Depth Anything 3: Recovering the Visual Space from Any Views — submission history · Title, authors and submission history checked. First submitted 2025-11-13; not a conference publication date.
Related topics