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

查看:20
本文介绍了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(您需要从视差值).事实上,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天全站免登陆