gpt4 book ai didi

image - 从 3 个静态摄像机的角度来看如何恢复其在 3d 空间中的位置?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:52:58 26 4
gpt4 key购买 nike

我们有相同的rectangle position relative to 3 same type of staticly installed web cameras不在同一条线上。说在平坦的篮球场上。因此,我们将它们全部放在一个 3d 空间内,并且 (x, y, z); (ax, ay, az); 为所有这些设置位置和方向。

我们有一个球的颜色,我们在所有 3 张图像 im1、im2、im3 上找到了它的位置。现在在 2d 帧 (p1x, p1y);(p2x, p2y);(p3x, p3y) 和相机 pos\orientations 上有位置如何在 3d 空间中获得球的位置?

最佳答案

  1. 您需要取消投影 2D 屏幕坐标到空间中的 3D 坐标。
  2. 您需要求解方程组以从第一步获得的 3 条射线中找到 3D 中的真实点。

您可以找到gluUnProject 的源代码here .我还在这里提供了我的代码:

public Vector4 Unproject(float x, float y, Matrix4 View)
{
var ndcX = x / Viewport.Width * 2 - 1.0f;
var ndcY = y / Viewport.Height * 2 - 1.0f;
var invVP = Matrix4.Invert(View * ProjectionMatrix);
// We don't z-coordinate of the point, so we choose 0.0f for it.
// We are going to find out it later.
var screenPos = new Vector4(ndcX, -ndcY, 0.0f, 1.0f);
var res = Vector4.Transform(screenPos, invVP);
return res / res.W;
}

Vector3 ComputeRay(Camera camera, Vector2 p)
{
var worldPos = Unproject(p.X, p.Y, camera.View);
var dir = new Vector3(worldPos) - camera.Eye;
return new Ray(camera.Eye, Vector3.Normalize(dir));
}

现在您需要找到三个这样的射线的交点。从理论上讲,仅使用两条射线就足够了。这取决于相机的位置。

如果我们有无限精度的浮点运算并且输入没有噪声,那将是微不足道的。但实际上,您可能需要利用一些简单的数值方案来找到具有适当精度的点。

关于image - 从 3 个静态摄像机的角度来看如何恢复其在 3d 空间中的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54048940/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com