查找用于拍摄 2D 图片的相机的 3D 位置

发布于 2024-12-12 03:07:54 字数 48 浏览 0 评论 0原文

给定 3D 场景和该场景部分的 2D 图像,是否可以找到用于制作图像的相机的位置?

Given a 3D scene and a 2D image of part of that scene, is it possible to find the position of the camera used to make the image?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

帅气尐潴 2024-12-19 03:07:54

我将从你的问题中假设你在 2D 空间中有四个点,你知道它们在 3D 空间中的位置。 (如果您真正的问题是识别这些点,我根本不知道从哪里开始。)

因此,您的问题是,相机在哪里可以产生从模型到图像的映射?

相机正在执行 M x + T = y 形式的仿射变换,其中 x 是 3 空间中的向量,表示模型中的点,y 是表示图像中的点的 2 空间向量。给定 x 和 y 的四个值,这是一个需要求解 M 和 T 的简单矩阵算术问题(可能最好让 MATLAB 来帮助您。)

现在,如何解决您是否将 M 和 T 转换为相机的位置、地点和焦距?那里有点毛茸茸的,但此页面应该对你有帮助(只是请记住,您所做的一切都是倒退)。

I'm going to assume from your question that you have four points in the 2-D space whose locations you know in the 3-D space. (If your real problem is identifying those point, I haven't the foggiest idea where to begin.)

Your question is therefore, where can the camera be to have produced this mapping from model to image?

The camera is performing an affine transformation of the form M x + T = y, where x is a vector in 3-space representing the point in the model and y is the 2-space vector representing the point in the image. Given four values for x and y, it's a straightforward matrix-arithmetic problem to solve for M and T (probably best to get MATLAB to help you here.)

Now, how do you translate M and T to position, location, and focal length of the camera? There it gets a little hairy but this page should help you (just remember, you are doing everything backwards).

允世 2024-12-19 03:07:54

如果您对相机参数进行随机采样,并使用每组参数渲染场景,则可以将最佳匹配作为起点。然后,您可以对相机参数执行局部优化,以找到最接近再现 2D 图像的参数。它并不快,但理论上只要有足够的时间你就可以做出很好的猜测。

If you take a random sampling of camera parameters, rendering the scene with each set of parameters, you can take the best matches as a starting point. You can then perform a local optimization of the camera parameters to find those parameters which reproduce the 2D image the closest. It isn't fast, but theoretically you could come up with very good guesses given enough time.

最美不过初阳 2024-12-19 03:07:54

您需要更多信息,但不需要更多信息。

最简单的事情是在场景中找到一个您知道其长度的物体或距离(例如,在图像中画一条虚拟线,说出您想要的任何单位的距离)。然后你还需要知道焦距(与视场角成反比)。

给定视角、已知长度的线段(或两条),您可以通过一些三角学非常接近地近似相机的确切位置。例如,对于粗略的距离估计:

   / |
  /  |
 /_d_I-segment
 \   |
  \  |
   \ |

distance "d", field of view angle "FoV"

picture.physicalsize/d == tan(FoV/2)
picture.physicalsize/segment.physicalsize == picture.pixelsize/segment.pixelsize

thus
d = segment.physicalsize*(picture.pixelsize/segment.pixelsize)/tan(FoV/2)

如果您想要更高的精度,您可能需要多个线段和更仔细的数学。

You need more information, but not necessary much more information.

The simplest thing to do would be to find an object or distance in the scene you know the length of (e.g. draw a virtual line in the image, say what the distance is in whatever units you want). Then you also need to know the focal length (inversely proportional to field of view angle).

Given the angle of view, a line segment (or perhaps two) with known length, you can very closely approximate the exact location of the camera with a bit of trigonometry. e.g. for a rough distance estimate:

   / |
  /  |
 /_d_I-segment
 \   |
  \  |
   \ |

distance "d", field of view angle "FoV"

picture.physicalsize/d == tan(FoV/2)
picture.physicalsize/segment.physicalsize == picture.pixelsize/segment.pixelsize

thus
d = segment.physicalsize*(picture.pixelsize/segment.pixelsize)/tan(FoV/2)

If you want even more precision, you may need more than one line segment and more careful math.

安稳善良 2024-12-19 03:07:54

是的,但这取决于情况。如果相机没有使图像扭曲得太严重,ninjagecko 的简单三角函数可能会起作用,但同样取决于您的应用程序。如果您想了解如何以更简洁的方式和更数学的方式执行此操作,请查看http://www.ces.clemson.edu/~stb/projective/

Yes, but it depends. If the camera does not distort the image too badly, the simple trigonometry by ninjagecko might work but again depends on your application. If you want to learn how to do this in a more cleaner way and more mathematical way, check this out http://www.ces.clemson.edu/~stb/projective/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文