uv坐标反投影到相机坐标系

根据针孔相机模型,一个在相机坐标系下的 三维点
( X , Y , Z ) (X,Y,Z) (X,Y,Z)
投影到 uv 坐标的过程如下所示
{ u = f x X Z + c x v = f y Y Z + c y \left\{ \begin{aligned} u & = & f_x \frac{X}{Z}+c_x\\ v & = & f_y \frac{Y}{Z}+c_y \\ \end{aligned} \right. uv==fxZX+cxfyZY+cy
其中, f x , f y , c x , c y f_x,f_y,c_x,c_y fx,fy,cx,cy的单位是像素

反投影

{ X = Z u − c x f x Y = Z v − c y f y \left\{ \begin{aligned} X & = & Z\frac{u-c_x}{f_x}\\ Y & = & Z\frac{v-c_y}{f_y}\\ \end{aligned} \right. XY==ZfxucxZfyvcy
常见地,
f x = f y = f f_x=f_y=f fx=fy=f
c x = W 2 c_x = \frac{W}{2} cx=2W
c y = H 2 c_y = \frac{H}{2} cy=2H
则上式简化为
{ X = Z u − W / 2 f Y = Z v − H / 2 f \left\{ \begin{aligned} X & = & Z\frac{u-W/2}{f}\\ Y & = & Z\frac{v-H/2}{f}\\ \end{aligned} \right. XY==ZfuW/2ZfvH/2
注意:在实际编程中可能增加
Z = d e p t h = d e p t h / d e p t h _ s c a l e Z = depth = depth/depth\_scale Z=depth=depth/depth_scale
d e p t h = 1 depth=1 depth=1
还可能出现坐标轴不一样的情况。

比如在 NeRF 的代码中

dirs = np.stack([(i-W*.5)/focal, -(j-H*.5)/focal, -np.ones_like(i)], -1)

This is just a process of converting pixel coordinates to camera coordinates.
And notice that it needs to convert the camera coordinates to opengl coordinates
( x right y up z back),so y should add a “-” and also z = -1 rather than 1

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

培之

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值