简体   繁体   English

在二维图像上查找 3d 透视图

[英]Find 3d perspective on 2d image

I have an image like this:我有这样的图像: 在此处输入图像描述

I want to find a perpendicular line to the red line (I mean perpendicular line to the track).我想找到一条与红线垂直的线(我的意思是与轨道垂直的线)。 How can I do this using OpenCV and Python?如何使用 OpenCV 和 Python 执行此操作? Problem is that the height of the camera is unknown and a visible angle of 90 degrees is not a real 90 degrees angle.问题是相机的高度是未知的,可见的 90 度角不是真正的 90 度角。 I have found here an option to use OpenCV .projectPoints() method, but looks like it needs to know the position of the resulting point and pass some vector there.我在这里找到了一个使用 OpenCV .projectPoints()方法的选项,但看起来它需要知道结果点的 position 并在那里传递一些向量。 Can somebody help how can achieve this?有人可以帮助如何实现这一目标吗? Or is that even possible?或者这甚至可能吗?

@Chiefir, you don't have enough data to get the perpendicular line you ask for. @Chiefir,您没有足够的数据来获得您要求的垂直线。

I believe your best chance is to find some parallel line in the image, like those marks in the grass (right where the green eleven is).我相信你最好的机会是在图像中找到一些平行线,比如草地上的那些标记(就在绿色十一号所在的位置)。

Some methods look for parallels in the image automatically, assuming a perpendicular straight lines world (like a city of roads and buildings), and get a 3D pose.一些方法会自动在图像中寻找平行线,假设一个垂直的直线世界(如道路和建筑物的城市),并获得 3D 姿势。 I don't think those work on you image.我认为这些对你的形象不起作用。

There is very little information in this one image (almost none, in fact) to accomplish your goal, so every solution will necessarily be imprecise.这张图片中几乎没有信息(实际上几乎没有)来实现您的目标,因此每个解决方案都必然是不精确的。 If this is a frame of a video sequence, you can apply the method below to a sequence of frames around this one to improve its accuracy.如果这是视频序列的一帧,您可以将下面的方法应用于围绕该帧的一系列帧,以提高其准确性。

One way is to assume that一种方法是假设

  1. The height of the rail from the ground is small (compared to their distance from the camera).轨道离地面的高度很小(与它们与相机的距离相比)。
  2. The long edges of the "11" number cut in the grass are perpendicular to the red line.草丛中剪出的“11”号的长边与红线垂直。

You can then estimate the vanishing point V of the "11".然后,您可以估计“11”的消失点V。 Then, any line drawn from V to a point of your red line is, by construction, the image of a line on the ground plane orthogonal to the one represented by the red line.然后,从 V 到红线的一点绘制的任何线,通过构造,都是与红线表示的线正交的地平面上的线的图像。

You can improve a little the accuracy by using, instead of your (presumably) hand-drawn red line, a line joining the bottom points of the supports of the rails, since this would be really on the ground.您可以通过使用(可能是)手绘红线而不是使用连接轨道支撑底部点的线来提高准确性,因为这实际上是在地面上。

If the poles supporting the railing were vertical (they aren't, as evidenced by the ones supported by the other rail higher in the image), you could compute their vanishing point P, then use in place of V in the method above.如果支撑栏杆的杆是垂直的(它们不是,如图中另一条轨道支撑的杆所证明的那样),您可以计算它们的消失点 P,然后在上述方法中使用 V 代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM