图像坐标到世界坐标opencv
image coordinate to world coordinate opencv
我使用 opencv 校准了我的单声道相机。现在我知道相机的相机固有矩阵和畸变系数 [K1, K2, P1 ,P2,K3 ,K4, K5, K6]。假设相机放置在 [x, y, z] 中并具有 [Roll, Pitch, Yaw] 旋转。当相机在地板上看时,如何获得世界坐标中的每个像素 [z=0]。
我建议你从研究针孔相机模型开始,它使用相机固有参数对 3D 世界中的一个点映射到图像平面的过程进行建模。正如你所看到的,这个过程不是一对一的,因此它通常不能被反转(图像到 3D),除非你有深度信息(你有,因为你说这些点位于 z=0 ). this presentation. Previous lectures explain in details the image formation process, and can be used as a first reference to actually determine the transformation from image to world coordinates. Szeliski's book and this PDF 幻灯片 27 中提到的这个特殊案例也是很好的资源。
你说你校准了你的相机,它给了你:
- 内部参数
- 外部参数(旋转、平移)
- 失真系数
首先,要补偿失真,您可以使用 undistort function and get an undistorted image. Now, what you are left with is the intrinsic/extrinsic parameters and the pinhole camera model. The equation below taken from the OpenCV documentation 说明如何使用这些参数将 3D 世界坐标转换为 2D 图像坐标:
基本上,您将 3D 坐标乘以投影矩阵,投影矩阵又是内部参数(等式中的第一个矩阵)和外部参数(等式中的第二个矩阵)的组合。外部参数矩阵包含旋转和平移分量 [R|T]
.
假设您的相机根据世界参考具有 T=[x y x]' 平移,并且正如您告诉您的相机具有 R=[roll, pitch yawn] 旋转并且您的相机 instrics 参数以 K 为单位。任何像素 ([ px py] 在图像平面上)在世界平面上有 W=[X,Y] 坐标并且 W 可以用下面的 Matlab 代码计算
R = rotationVectorToMatrix(R)'
H=K*[R T];`
Q=inv([H(:,1) H(:,2) -[px;py;1]])*-H(:,4);
W=Q(1:2)
在这里,文件的结尾很好地说明了我的意思,https://github.com/muhammetbalcilar/Stereo-Camera-Calibration-Orthogonal-Planes
我使用 opencv 校准了我的单声道相机。现在我知道相机的相机固有矩阵和畸变系数 [K1, K2, P1 ,P2,K3 ,K4, K5, K6]。假设相机放置在 [x, y, z] 中并具有 [Roll, Pitch, Yaw] 旋转。当相机在地板上看时,如何获得世界坐标中的每个像素 [z=0]。
我建议你从研究针孔相机模型开始,它使用相机固有参数对 3D 世界中的一个点映射到图像平面的过程进行建模。正如你所看到的,这个过程不是一对一的,因此它通常不能被反转(图像到 3D),除非你有深度信息(你有,因为你说这些点位于 z=0 ). this presentation. Previous lectures explain in details the image formation process, and can be used as a first reference to actually determine the transformation from image to world coordinates. Szeliski's book and this PDF 幻灯片 27 中提到的这个特殊案例也是很好的资源。
你说你校准了你的相机,它给了你:
- 内部参数
- 外部参数(旋转、平移)
- 失真系数
首先,要补偿失真,您可以使用 undistort function and get an undistorted image. Now, what you are left with is the intrinsic/extrinsic parameters and the pinhole camera model. The equation below taken from the OpenCV documentation 说明如何使用这些参数将 3D 世界坐标转换为 2D 图像坐标:
基本上,您将 3D 坐标乘以投影矩阵,投影矩阵又是内部参数(等式中的第一个矩阵)和外部参数(等式中的第二个矩阵)的组合。外部参数矩阵包含旋转和平移分量 [R|T]
.
假设您的相机根据世界参考具有 T=[x y x]' 平移,并且正如您告诉您的相机具有 R=[roll, pitch yawn] 旋转并且您的相机 instrics 参数以 K 为单位。任何像素 ([ px py] 在图像平面上)在世界平面上有 W=[X,Y] 坐标并且 W 可以用下面的 Matlab 代码计算
R = rotationVectorToMatrix(R)'
H=K*[R T];`
Q=inv([H(:,1) H(:,2) -[px;py;1]])*-H(:,4);
W=Q(1:2)
在这里,文件的结尾很好地说明了我的意思,https://github.com/muhammetbalcilar/Stereo-Camera-Calibration-Orthogonal-Planes