像素坐标到3D线(opencv) [英] Pixel coordinates to 3D line (opencv)

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

问题描述

我有一个图像显示在屏幕上,通过cvInitUndistortMap& cvRemap(已经完成相机校准),并且用户点击图像中的特征。所以我有(u,v)像素坐标的特征,我也有内在矩阵和失真矩阵。

I have an image displayed on screen which is undistorted via cvInitUndistortMap & cvRemap (having done camera calibration), and the user clicks on a feature in the image. So I have the (u,v) pixel coordinates of the feature, and I also have the intrinsic matrix and the distortion matrix.

我要找的是用户点击的特征必须位于的相机/真实世界坐标中的3D线的方程。我已经有相机的图像平面和特征之间的垂直距离,因此我可以将它与上述方程组合,给出空间中特征的(X,Y,Z)坐标。

What I'm looking for is the equation of the 3D line in camera/real-world coordinates on which the feature the user clicked must lie. I already have the perpendicular distance between the camera's image plane and the feature, so I can combine that with the aforementioned equation to give me the (X,Y,Z) coordinate of the feature in space.

听起来很容易(反向内在矩阵或某事?),但我不能在任何地方找到一步一步的说明。 C ++或C#代码。

Sounds easy (inverse intrinsic matrix or something?) but I can't find step-by-step instructions anywhere. C++ or C# code preferred.

推荐答案

这是一个有点旧的问题,但仍然可能对某人有用。
所有行都通过点(0,0,0),因此:

This is a bit old question but still might be usefull for someone. All lines go through the point (0,0,0), so:

line.x0 = 0;
line.y0 = 0;
line.z0 = 0;

line.x0 = 0; line.y0 = 0; line.z0 = 0;

方向向量如下:
line.A =(u / fx) - (cx / fx) ;
line.B =(v / fy) - (cy / fy);
line.C = 1;

direction vector is as follows: line.A = (u/fx) - (cx/fx); line.B = (v/fy) - (cy/fy); line.C = 1;

cx,cy,fx,fy是来自相机矩阵的参数。
方程式在Learning OpenCv书中解释。

cx,cy,fx,fy are parameters from camera matrix. Equations are explained in "Learning OpenCv" book.

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

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