使用warpPerspective()opencv生成道路的顶部视图 [英] generate a top-dow view of a road using warpPerspective() opencv

查看:1129
本文介绍了使用warpPerspective()opencv生成道路的顶部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施反向透视映射可计算与道路上其他车辆的距离。我知道我需要在应用函数 warpPerspective()之前生成一个源点和目标点的变换矩阵,但是我不知道如何计算目标点。 / p>

我在此论坛和其他网站搜索,但我无法将第一张图片转换为第二张图片:





解决方案

你想要实现需要你计算地平面之间的地理位置,它在摄像机所看到的图像中的位置和它在鹰视图中的位置。



通过提取大多数计算机视觉管线中的特征(角点或关键点)来处理,但这在这里是不切实际的:在道路上没有特征(或改变的特征)。




  1. 将相机放在自己的相机上,可以在校准步骤中计算这些单应性目标车辆。把一个已知的矩形图案(通常是棋盘)放在汽车前面的平地上。如果你想要公制距离,那么你还需要知道图案的尺寸,否则你将只测量相对距离。



  2. 在模式的图像中,您需要检测它。这可以通过几种方式完成:如果您有一个模式的参考图像,您可以自动检测,或者您可以手动点击4个外角。这将给你至少四点对应(模式的每个外角为1)。在图像点(例如,4个角)和参考位置之间建立点对应,参考位置是图案的参考图像中的所述点的位置(如果oyu具有一个)或者是该位置


  3. 根据对应关系,估计单应性 H H 是一个3x3矩阵(参见任何Computer Vision参考,无论是在线还是教科书)。


这将输出您在相机看到的内容和校准图案的参考位置之间的转换。
如果你参考一个正交平行视图的模式或其在鹰视图中的所需坐标,你有你正在寻找的单应性。如果没有,您需要估计第二个单应性并链接它们的结果。



请注意,此应用程序在 Gary Bradski的学习OpenCV书。你可以在书中更多地了解它,并且在线找到原始代码。


I'm tryng to implement Inverse Perspective Mapping to calculate the distance to another vehicle on a road. I know that I need to generate a transformation matrix with source points and destination points before applying the function warpPerspective(), but I don't know how to calculate destination points.

I searched in this forum and other sites but I can't transform the first image to the second image:

解决方案

The goal that you want to achieve requires you to compute the honography between the ground plane, its position in the image as viewed by the camera, and its position in the eagle view.

This is traditionnaly handled by extracting features (corners or keypoints) in most Computer Vision pipelines, but this is impractical here: theere are no feature (or changing features) on the road.

What you can do instead is computing these homographies in a calibration step, with the following procedure:

  1. Put your camera on the target vehicle. Put a known rectangular pattern (usually a chessboard) lying on flat ground in front of the car. If you want metric distances, then you also need to know the size of the pattern, otherwise you will measure relative distances only.

  2. Take a picture of the calibration pattern with this setup.

  3. In the image of the pattern, you need to detect it. This can be done in several ways: if you have a reference image of the pattern, you can detect it automatically, or you can manually click onthe 4 outer corners. This will give you at least four point correspondences (1 for each outer corner of the pattern). The point correspondences are established between image points (e.g., the 4 corners) and a reference position, which is either the position of the said point in the referenc eimage of the pattern (if oyu have one) or the position that you want for this point in the eagle view.

  4. From the correspondences, estimate a homography H. His a 3x3 matrix (see any Computer Vision reference, either online or textbook).

This will output you the transform between what the camera is seeing and the reference position of the calibration pattern. If you took as reference a fronto-parallel view of the pattern or its desired coordinates in the eagle view, you have the homography that you are looking for. If not, you need to estimate a second homography and chain their results.

Note that this application is considered in Gary Bradski's Learning OpenCV book. You can read more about it in the book, and probbaly find the original code online.

这篇关于使用warpPerspective()opencv生成道路的顶部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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