给定摄像机和视图平面的2D点的3D坐标 [英] 3D coordinate of 2D point given camera and view plane

查看:122
本文介绍了给定摄像机和视图平面的2D点的3D坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过观察平面产生来自相机的光线。为了做到这一点,我需要我的相机位置(眼睛),向上,向右和向量(其中向是来自相机的对象的方向上相机正在看的矢量)和P,在观察平面上的点。一旦我有这些,产生的光线是:

I wish to generate rays from the camera through the viewing plane. In order to do this, I need my camera position ("eye"), the up, right, and towards vectors (where towards is the vector from the camera in the direction of the object that the camera is looking at) and P, the point on the viewing plane. Once I have these, the ray that's generated is:

ray = camera_eye + t*(P-camera_eye);

其中t是沿光线的距离(假设现在t = 1)。

where t is the distance along the ray (assume t = 1 for now).

我的问题是,如果点P位于观察平面上的位置(i,j),如何获得点P的3D坐标?假设给出了视平面的左上角和右下角。

My question is, how do I obtain the 3D coordinates of point P given that it is located at position (i,j) on the viewing plane? Assume that the upper left and lower right corners of the viewing plane are given.

注意:观察平面实际上不是一个平面,它不延伸无限在所有方向。相反,人们可以认为这个平面是宽高度图像。在x方向上,范围是0->宽度,并且在y方向上,范围是0-> height。我希望找到第(i,j)个元素的3D坐标,0

NOTE: The viewing plane is not actually a plane in the sense that it doesn't extend infinitely in all directions. Rather, one may think of this plane as a widthxheight image. In the x direction, the range is 0-->width and in the y direction the range is 0-->height. I wish to find the 3D coordinate of the (i,j)th element, 0

推荐答案

当我直接插入建议的公式到我的程序,我没有得到正确的结果(也许一些调试需要做)。我最初的问题似乎是对内插角点的(x,y,z)坐标的误解。我分别处理x,y,z坐标,其中我不应该(这可能是特定于应用程序,因为相机可以在任何方向取向)。相反,解决方案是对观察平面的角点的简单插值:

When I directly plugged in suggested formulas into my program, I didn't obtain correct results (maybe some debugging needed to be done). My initial problem seemed to be in the misunderstanding of the (x,y,z) coordinates of the interpolating corner points. I was treating x,y,z-coordinates separately, where I should not (and this may be specific to the application, since the camera can be oriented in any direction). Instead, the solution turned out to be a simple interpolation of the corner points of the viewing plane:


  • 插入视角中的底角点方向获取P1

  • 在第i个方向上插入顶点角点以获得P2

  • 在j方向插值P1和P2,最终点的坐标

这篇关于给定摄像机和视图平面的2D点的3D坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆