根据原点更改前后的相机旋转/平移确定点位置

发布于 2024-11-16 11:34:28 字数 265 浏览 2 评论 0原文

如果这是一个愚蠢的问题,我深表歉意,我对 3D 工作还很陌生。

我有许多带有 3x3 旋转矩阵和基于原点 (0,0,0) 的平移向量的针孔相机。

我正在使用的系统可以移动原点并旋转相机(尽管所有相机都保持相对于彼此),从而为每个相机生成一个新的旋转矩阵和平移向量,我可以访问它们。

那么我的问题是:给定原始空间中具有 3D 位置的点,如何使用同一相机(或多个相机)的新旋转/平移来计算新空间中同一点的 3D 位置?

当我提出问题时,是否有更有效的方法?

Apologies if this is a dumb question, i'm very new to working in 3D.

I have a number of pinhole cameras with a 3x3 rotation matrix and a translation vector based around the origin (0,0,0).

The system I'm working with can move the origin point and rotate the cameras (though all kept relative to one another), resulting in a new rotation matrix and translation vector for each camera, which I can access.

My question then, is: given a point with a 3D position in the original space, how does one compute the 3D position of the same point in the new space using the new rotation/translation of the same camera (or cameras)?

And while I'm asking questions, is there a more efficient means of doing so?

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

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

发布评论

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

评论(2

迷路的信 2024-11-23 11:34:28

我假设你的点的位置是相对于原点矩阵的,你说它可以平移/旋转。

假设所有这些都是必要的,则您的点的新位置由下式给出:

pos_newCoord = R^-1 * T^-1 * pos_oldCoord

您所做的就是获取新原点,将其转换回旧原点,然后取消旋转。另一种写法:

newOrigin = myTranslation(myRotation(oldOrigin))
def newCoordinates(point):
    return inverse(myRotation)(inverse(myTranslation)(point))

您可以预先计算逆运算,尤其是在使用 4d 矩阵时。


如何根据相机的旋转和平移变化来确定原点的旋转和平移变化?” –OP

如果您没有被告知此信息,您可以按如下方式恢复。我们将使用 4d 点和 4v4 仿射变换矩阵 ( en.wikipedia.org/wiki/Affine_transformation )。

  • 取任意 4 个摄像机。
  • 考虑原始相机点与它们的平移/旋转点。
  • 可能有更好的线性代数方法来做到这一点,但如果您访问维基百科链接,我们注意到有一个 3x3 子矩阵 A 和一个 3x1 子矩阵 b,因此有 12 个未知数。 4 个点,每个点有 3 个方程,总共有 12 个方程。有一个解决方案,因为这种形式的矩阵是可逆的*。使用您最喜欢的线性方程组求解技术进行求解,例如 12x12 矩阵上的高斯消元法。

I assume that the position of your points are relative to the origin matrix, which you say can be translated/rotated.

Assuming all this is necessary, the new positions of your points are given by:

pos_newCoord = R^-1 * T^-1 * pos_oldCoord

What you're doing is you're taking your new origin, translating it back to the old origin, and unrotating it. Written another way:

newOrigin = myTranslation(myRotation(oldOrigin))
def newCoordinates(point):
    return inverse(myRotation)(inverse(myTranslation)(point))

You can pre-calculate the inverse operations, especially if you're using 4d matrices.


"how to determine the change in rotation and translation for the origin based around the changes of rotation and translation for the cameras?" –OP

If you are not told this information, you can recover it as follows. We'll be using 4d points and a 4v4 affine transformation matrix ( en.wikipedia.org/wiki/Affine_transformation ).

  • Take the any 4 cameras.
  • Consider the original camera points vs their translated/rotated points.
  • There's probably a nicer linear algebra way to do it, but if you visit the Wikipedia link, we notice there's a 3x3 submatrix A and a 3x1 submatrix b, and thus 12 unknowns. 4 points with 3 equations per point gives you 12 equations. There's a solution because matrices of this form are invertible*. Solve using your favorite system-of-linear-equation solving technique, e.g. Gaussian elimination on a 12x12 matrix.
泛泛之交 2024-11-23 11:34:28

我建议使用 齐次坐标 来跟踪矩阵和变换。我认为你的问题是如何在不同的相机视图之间来回转换点。

如果将相机变换表示为单个矩阵运算M,那么向后就是inverse(M)。更好的是,如果您的相机矩阵是由多个步骤组成的,您可以反转这些步骤。例如,如果 M=rotatex(theta) * scale(sx, sy, sz) * translate(x, y, z),则 inverse(M) = translate(-x, - y,-z)*缩放(1/sx,1/sy,1/sz)*旋转x(-theta)。请注意,您还必须颠倒顺序。这是“袜子/鞋子”属性。你穿上袜子,然后穿上鞋子。要反转,请脱掉鞋子,然后脱掉袜子。

一旦您可以从每个摄像机向前和向后移动,您就可以轻松地在任何摄像机视图之间交换点。

I would recommend using homogeneous coordinates to keep track of matrices and transformations. I think your question is how do you transform points back and forth between different camera views.

If you represent a camera transformation as a single matrix operation M, then going backwards is just inverse(M). Even better, if your camera matrix is the composition of several steps you can invert the steps. For example if M=rotatex(theta) * scale(sx, sy, sz) * translate(x, y, z), then inverse(M) = translate(-x, -y, -z) * scale(1/sx, 1/sy, 1/sz) * rotatex(-theta). Notice you also have to reverse the order. It's the "socks/shoes" property. You put on your socks, then put on your shoes. To reverse you take off your shoes, then take off your socks.

Once you can go forward and backward from each camera, you can swap points between any camera view easily.

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