2D坐标到3D世界坐标 [英] 2D Coordinate to 3D world coordinate

查看:189
本文介绍了2D坐标到3D世界坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将2D图像坐标转换为3D世界坐标.我使用的是立体摄像机ZED摄像机,并且随附的sdk提供了视差图.因此,我有深度.两个摄像机彼此平行.尽管这个问题是微不足道的,但我无法弄清楚转换背后的数学原理.我有以下信息

I want to convert 2D Image coordinates to 3D world coordinates. I am using the ZED camera which is a stereo camera and the sdk shipped with it, provides the disparity map. Hence I have depth. The two cameras are parallel to each other. Although this problem is of trivial nature, I am unable to figure out the mathematics behind the conversion. I have the following information

1)我有像素信息(即用u和v表示的行数和列数)以及该像素处的深度D(以米为单位).

1) I have the pixel information (i.e. the row and column number denoted by u and v) and the depth D at that pixel in meters.

2)我也知道两个摄像机的焦距和cx,cy值

2) I also know the focal length and cx, cy values of both the cameras

3)已知投影B的两个中心(基线)之间的距离.

3) The distance between the two centers of projection B(baseline) is known.

我想知道如何从图像中的像素(行,列,深度)到世界坐标中的(X,Y,Z).

I want to know how can one go from pixel(row, column, depth) in image to (X,Y,Z) in world coordinate.

将世界坐标系的原点假定为两个摄像机之间的中心点,并垂直向下位于地面上. (相机的高度称为H).

Assume origin of world coordinate system as the central point between two cameras and vertically below on the ground. (The height at which camera is known as H).

谢谢.

推荐答案

您已经知道每个像素的深度D(以米为单位),因此不需要摄像机之间的基线B(您需要从中计算深度B)视差值).实际上,D已经是您搜索到的Z坐标.

As you already know the depth D in meters for each pixel, you don't need the baseline B between cameras (which you would need to compute the depth from the disparity value). In fact, D is already your searched Z coordinate.

针孔相机模型的通用公式(假设没有失真)为:

The general formula for the pinhole camera model (assuming there is no distortion) is:

u = fx * (X / Z) + cx
v = fy * (Y / Z) + cy

因此可以轻松地计算3D坐标:

So it is then straightforward to compute the 3D-coordinates:

X = Z / fx * (u - cx)
Y = Z / fy * (v - cy)
[Z = D]

请注意,这仅在使用校正后的图像(或失真低的图像)时才是正确的.

Note that this only is correct if you are working with a rectified image (or an image with low distortion).

这篇关于2D坐标到3D世界坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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