深度估计:深度图里的数,什么时候才是米?
Depth estimation
训练小型RGB深度网络的全部参数,推导重投影梯度,用反例检查尺度歧义、掩码和评估。
depth-estimation形状看着对,尺寸仍可能错
一个深度模型说:椅子在两米外,墙在四米外。实际距离却是一米和两米。它保留了谁近谁远,也保留了深度的比例。机器人若用这些数决定在哪儿停车,仍然会判断错误。
深度估计为图像位置赋予深度值。比较方法之前,先问这些数表示什么:沿相机光轴的深度、沿视线的距离、逆深度,还是只有远近次序?一张颜色漂亮的深度图并没有回答这个问题。
| 已有信息 | 什么在约束深度 | 还要检查什么 |
|---|---|---|
| 单张图像 | 透视线索和学到的规律 | 绝对尺度与陌生场景 |
| 相机运动下的多张图像 | 几何对应和运动 | 平移尺度、遮挡与运动物体 |
| 已标定且基线已知的双目图像 | 对应关系与一个实际长度 | 匹配、标定和深度不确定性 |
| 与深度测量配对的图像 | 监督数据的定义和单位 | 测量缺失、噪声和数据域差异 |
对单张图像而言,远处的大物体可以与近处的小物体产生相同投影。学习能够利用训练数据里的规律选一个答案,却没有消除这个几何歧义。Eigen等人的方法先预测粗深度,再细化结果;后续工作研究监督、重投影和数据混合如何改变模型能够恢复的信息。单图深度预测 数据混合
一个有用的基线是:用训练集估计一个常数深度,在所有位置输出它。它没有场景几何,却能检验学习模型是否在不使用测试标签的情况下改进了指定指标。另一项诊断会利用测试真值缩放预测:它适合研究相对结构,却不能当作未经辅助的米制深度结果。
下面实现一个完整的小型RGB到深度网络,以及检查自监督所需的几何计算。没有预训练权重,也没有藏在接口里的模型调用。例子用于说明尺度、掩码和坐标约定的作用,不用于证明照片上的性能。
先定义距离,再选择损失
像素、相机点与两种距离
设p为齐次像素向量,K为可逆的相机内参矩阵,X为相机坐标中的三维点。无畸变针孔模型给出:
焦距和可选的斜切参数s使用像素单位,Z是沿光轴的深度。程序允许斜切项;OpenCV常用的零斜切形式令s=0。把这套理想几何用于测得的图像坐标前,需要消除镜头畸变,或把畸变纳入模型。相机模型与坐标约定
到相机中心的欧氏距离则是另一个量:
偏离主点时,射线向量的长度通常大于1。程序例子里,Z=2对应的距离约为2.29129。若把射线单位化,却继续乘同一个Z,重建点就变了。
缩放坐标也需要定义。在u’=a u、v’=a v的约定下,把K的前两行乘a,同一场景点的深度不变。裁剪则从主点坐标中减去裁剪偏移。真实图像重采样可能使用半像素约定,此时还要使用对应的坐标变换。Eigen的训练增强把图像放大解释为相机靠近,并调整深度标签;它采用了另一种假设,不能与单纯改变图像坐标混为一谈。缩放后的内参 训练增强,物理第5页
监督学习:预测对数深度,保留尺度问题
让网络预测对数深度l_i,正的真值深度为y_i。在n个有效像素上,记e_i=l_i−log(y_i)。可以使用下面这族损失:
lambda=0时,它是对数误差的均方。lambda=1时,给所有对数预测加同一个数不会影响结果,也就是不惩罚所有深度共同乘一个比例。原始训练形式使用的lambda=0.5仍保留了对尺度敏感的项。有效像素的导数是2(e_i−lambda mean(e))/n;无效像素的梯度为0。若一个有效真值也没有,应报告输入错误,而不能把它当成损失为0的成功样本。损失与尺度不变误差
在lambda=1时,三个等价表达式把含义写得更清楚:
中间一项遍历全部有序对,因此不能少掉二分之一。所核读的首个arXiv版本,在成对形式的式(2)前印了1/n²,但式(1)与式(3)给出的是中心化形式。取误差[0,1],中心化损失为0.25;没有除以2的有序对表达式则是0.5。实现与测试采用上面明确推导的恒等式,不把这几个印刷表达式直接当成等价式。具体版本的公式核对,物理第4页
小网络使用2×2卷积,把三个输入通道变成两个隐藏通道,经tanh后,以共享线性输出预测对数深度:
一张3×4的RGB图像得到2×3输出:valid卷积让两个空间尺寸各减1。参数包括24个卷积权重、两个隐藏偏置、两个输出权重和一个输出偏置,共29个。给定输出梯度g,隐藏层激活前的梯度为g v_c(1−h²);把它与输入块的乘积求和,就得到卷积核梯度。输入块重叠时,要把各处贡献加到同一个输入梯度上。代码实现了所有步骤,有限差分逐个检查参数和输入标量。
这个小网络是原创教学模型,并非Eigen的粗细两阶段架构。后者先训练粗网络,再固定粗网络输出训练细阶段。本例也不能证明只看一个局部小块就足以理解真实场景。架构与训练顺序
自监督:预测的几何能解释另一张图吗?
设目标像素p的深度为Z,从目标相机到源相机的坐标变换是X_s=R X_t+t。内参已知时,采样坐标为:
在源图的u_s位置采样,再与目标像素比较外观。这要求相机几何相容,外观也足够稳定;运动物体、遮挡或反射都可能破坏假设。Monodepth2使用SSIM与L1混合的外观误差,以及作用于归一化逆深度的边缘感知平滑项。我们的代码只取出一个带掩码的MSE例子,固定相机姿态,并让目标、源相机使用相同内参。重投影与损失
不用神经网络,也能核对深度导数。令a=K R K^-1 p、b=K t,投影前的齐次点便是Za+b。第一个图像坐标的导数为:
竖直坐标的导数把x换成y即可。t=0时,两项都为0:纯相机旋转不会提供这里的深度信号。若把Z和t同时乘同一个正常数,像素投影也不变。因此,未知的平移尺度仍与深度尺度耦合;测试用真正的非恒等旋转检查了这两种性质。
采样点位于源图某个像素格内部时,双线性插值使用四个角:
格子内部的空间导数可以直接写出。对于有效像素MSE,沿着图像误差、采样坐标、Z这条链求导:
采样器只接受四个邻居都在图像内的坐标,不包括最后一行、列的边界,并屏蔽位于源相机后方的点。它没有边界填充。这个导数是局部的:跨越像素格或改变有效集合,不属于同一条光滑分支的公式。程序没有学习相机姿态,也没有使用完整场景渲染器处理可见性。
有多张源图时,最小重投影在每个目标像素选择最小的源图误差。严格自动掩码还要比较:几何变换后的采样,是否优于直接使用未变换的源图?
这样可以避免强迫像素与某张遮挡它的源图一致,也能抑制一些没有信息的静止视图解释,但不能保证深度正确。数值例子得到最小误差[0.1,0.2]与掩码[true,false];误差相等时,严格比较不通过。固定版本的Monodepth2代码会给恒等误差加小随机噪声以打破平局,再在候选中取最小值、求损失均值;这里的布尔选择器明确不复现整套归约。论文方法 固定训练代码
评估你真正打算使用的预测
常见指标包括绝对相对误差、RMSE和阈值准确率:
RMSE带有深度单位,AbsRel和比例阈值没有单位。阈值是严格不等式:比例恰好为1.25时不能算通过。比较结果前,必须明确真值无效像素、裁剪、截断和评估深度范围。固定评估代码先掩码、裁剪,再作中位数缩放,随后才截断预测值。指标代码 评估顺序
中位数缩放采用median(Z)/median(prediction),而不是逐像素比值的中位数。本例中,预测处处为真值两倍时,AbsRel=1、delta1=0;利用真值乘0.5后,两项都达到完美结果。这说明相对结构正确,不代表模型独立恢复了米制距离。
MiDaS把不相容的监督放到共同的逆深度/视差空间中,考虑尺度和偏移歧义。在已声明的域里,最小二乘仿射对齐求解:
这里必须说明q是什么:逆深度的仿射变换通常不等于深度共同乘一个尺度。常数预测不能同时确定两个参数,函数因此拒绝这个退化输入。MiDaS也研究稳健对齐与损失,其中稳健尺度使用相对中位数位置的平均绝对偏差,不能误叫成绝对偏差的中位数。程序只演示普通最小二乘对齐。对齐目标,物理第5—6页
运行几何计算,训练全部29个参数
把下面代码保存为depth.py,用Python和NumPy运行。实际检查环境为Python3.12.4、NumPy1.26.4。输入是按明确种子生成的合成数据;深度标签为正,对数预测本身不受正值约束,解释成深度时再取指数。不需要外部模型、下载图像或GPU。
"""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))
实际输出如下:
{
"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
]
}
一次更新后,监督损失从约0.48894降到0.35547。光度例子的改进较小,因为它更新的是显式深度值,没有更新网络或相机姿态。小规模损失下降用于检查实现的导数,不是在估计真实场景准确率。
对H×W图像,输入通道Cin、输出通道Cout的稠密k×k卷积需要约HW k² Cin Cout次运算。参数存储约为k² Cin Cout,保存本层隐藏激活需要约HW Cout空间。一次变换、双线性采样、有效像素损失或指标计算,都随处理像素数线性增长;比较S张源图需要约SHW计算。若只需源图误差的最小值,可以依次处理源图来减少内存。这些开销对应本例算子,不代表完整基础模型。
配套检查覆盖标量卷积参照、29个参数导数和36个输入导数、投影往返、缩放/裁剪、纯旋转、深度与平移同时缩放、变换与采样导数、掩码、阈值边界、对齐退化,以及有序对损失恒等式。立体匹配的计算另在“立体视觉”主题展开。
一张好看的深度图还没有回答什么
- 尺度:训练先验可以给出米制距离的猜测,但利用真实深度作测试时修正,不能计作独立恢复尺度。修正前后应分别报告。
- 可见性与外观:光度最小值可能选中碰巧相似的位置。自动掩码和平滑项不能证明所选表面可见,或重建正确。
- 监督数据:实测深度有缺失和噪声,合成深度也有场景覆盖和渲染假设。不能因为目标值稠密,就自动称其为完美真值。
- 坐标:镜头畸变、图像缩放、焦距变化和像素中心约定会影响投影。所核读代码以width−1、height−1归一化,而
grid_sample调用没有显式设置align_corners;复现时需要锁定相应框架版本。本例像素坐标采样器另有明确约定。固定几何代码 固定采样调用 - 泛化:新相机、透明表面、异常物体尺寸或变化的场景分布,都需要适当的留出数据测试。这个小网络及其合成损失并没有提供这些验证。
相信深度图之前,做四次检查
- 距离:某像素的射线K^-1 p=[0.5,0,1],光轴深度为2。相机点和到相机的距离分别是多少?
答案: 点为[1,0,2],距离为sqrt(5),约2.236。若把单位射线乘2,得到的距离才是2,光轴深度会更小。反投影前应先明确模型预测的是哪一种距离。
- 尺度与损失:对数深度误差为[0,1],求lambda=1的损失。给两个误差都加3后会怎样?lambda=0.5是否同样不变?
答案: 中心化后为[−0.5,0.5],因此平移前后的第一项损失都是0.25。lambda=0.5时,原损失为0.5−0.5×0.25=0.375;平移到[3,4]后,损失为12.5−0.5×12.25=6.375,尺度项仍在。若遍历全部有序对却漏掉二分之一,尺度不变损失就会被错误算成0.5。
- 自监督:两张图之间只有已知的相机旋转。在这个理想模型里,更新深度能降低几何变换的误差吗?相机发生平移时又怎样?
答案: t=0时,Z在齐次投影中约掉,变换对深度的导数为0。非零平移能够提供依赖深度的视差,但仍要考虑遮挡和外观假设失败。若平移本身的尺度未知,同时缩放它和深度不会改变重投影。
- 评估:所有预测深度都是真值两倍,逐图中位数缩放后显示误差为0。结果应怎样描述?用什么小实验暴露区别?
答案: 明确说明评估使用了真值中位数缩放,在这个构造例子中相对结构完全正确。同时报告未经缩放的AbsRel=1、delta1=0。关闭中位数缩放重跑,保持有效掩码和深度单位一致,不能让改了掩码或隐藏的裁剪替代这个比较。
从尺度损失,到深度与射线模型
Eigen论文的首次arXiv提交是2014-06-09,把粗细预测与尺度不变误差的讨论结合起来。Monodepth2首次提交于2018-06-04,本文使用的论文版本则来自ICCV2019。它的最小重投影和自动掩码针对外观监督的具体失败条件,并没有消除所有深度歧义。Eigen提交记录 Monodepth2提交记录
MiDaS首次于2019-07-02提交arXiv,研究如何混合不同数据集,并检查向未见数据集的迁移。Depth Anything V2首次提交于2024-06-13,用在合成数据上训练的强教师为真实图像生成标签,再训练学生。这种连接试图同时利用准确监督和多样真实图像,不代表所有合成标签或每个新场景都可靠。MiDaS提交记录 V2方法 V2提交记录
Depth Anything 3首次提交于2025-11-13,把输入扩展到单张或多视图图像,也可以提供已知相机姿态。所核读的形式同时预测深度与未归一化世界射线:世界点等于射线原点加上光轴深度乘射线方向。这与“沿单位射线的距离”不同。同一页后面的相机恢复段使用了与前文射线方程不能直接对应的矩阵约定;因此,本文不复述那段恢复推导,也不推断尚未核读的代码行为。深度与射线形式,物理第6页 DA3提交记录
读这些工作时,可以分别看它们回应了什么条件:可用监督、相机知识、相对还是米制尺度,以及跨数据集迁移。论文名字本身并不能定义公平比较。下一步练习可以先固定评估协议,运行常数基线,训练小模型,区分几何误差与尺度误差,再尝试更大的架构。
先判断,再看解释
预测深度处处为真值两倍,使用真值中位数缩放后误差为零,这证明了什么?
学习目标
- 区分光轴深度、射线距离、相对结构与米制尺度。
- 推导带掩码的对数深度损失、重投影和双线性深度梯度。
- 训练完整小型RGB深度网络,并核对全部参数梯度。
- 分别评估原始和对齐预测,说明是否使用真值缩放。
先修与延伸
查看知识关联图 →参考文献
- 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
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(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项正式检查;包含独立几何/梯度/边界计算、双语/引用/习题核对及该主题计算图检查。双主题54项中数值测试42项,不能把全部检查称作独立数值复现。
- 中英文12个展示公式逐字对应;完整程序与正文输出真实执行一致,各四道解释答案核对。研究范围与原文公式歧义明确记录,没有采用未协调的推导。
- 两语言桌面/手机四张原创SVG已检查,四字体边界通过;图示由实际程序核对后的输出生成。保留合成场景、尺度辅助及失败条件,不写成模型基准成绩。
- 核对29参数和36输入梯度、纯旋转/尺度歧义、重投影梯度、掩码、严格阈值和有序对损失二分之一系数。
- 最终静态检查发现中文列表标题的粗体分隔符可见;仅将九处确切标题改为strong标签,逐字逆变换还原原稿,公式、代码、引用及全部正文措辞不变。原稿和原审校另存纠错目录,六文件冻结原件不改。
核对的来源位置:
- 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.
相关主题