简体   繁体   English

通过点和线计算CV2 Homography

[英]Calculate CV2 Homography by points and line

I have a list of points in the field (like upper_goal_point / left_upper_outer_corner , etc.我有该字段中的点列表(如upper_goal_point / left_upper_outer_corner等。

在此处输入图像描述

I know their corresponding coordinates in destination image - so I can calculate the homography:我知道它们在目标图像中的对应坐标 - 所以我可以计算单应性:

h, status = cv2.findHomography(pts_src, pts_dst)

I also have blue points in the upper corner line (look at image above), which I only know that their destination's y coordinates are 0 (because they are in the upper line), but I don't know where exactly they lay in that line.我在上角线上也有蓝点(看上图),我只知道它们的目的地的y坐标为 0 (因为它们在上线),但我不知道它们到底在哪里线。

Can I use those blue points in order to improve the homography?我可以使用这些蓝点来改善单应性吗?

PS附言

You can see that the upper corner line in the homography is not horizontal line, it's diagonal, which of course is not correct:可以看到,单应性中的upper corner角线不是水平线,而是对角线,这当然是不正确的:

在此处输入图像描述

Actually it possible to use line correspondence in find homography.实际上可以在查找单应性中使用线对应。

https://www.researchgate.net/publication/220845575_Combining_Line_and_Point_Correspondences_for_Homography_Estimation https://www.researchgate.net/publication/220845575_Combining_Line_and_Point_Correspondences_for_Homography_Estimation

Several years ago we implement this approach in one project.几年前,我们在一个项目中实施了这种方法。 During simplification all math we come up with simple trick.在简化所有数学的过程中,我们想出了简单的技巧。 We transform every line a*x + b*y + c = 0 to point (a/c, b/c)我们将每一行a*x + b*y + c = 0转换为点(a/c, b/c)

// ***  Don't copy paste this code, read below!  ***//
Point2f convertPointsToHomogeneousLine(Point2f p1, Point2f p2) {
    Point3f p1h(p1.x, p1.y, 1);
    Point3f p2h(p2.x, p2.y, 1);
    Point3f lineHomo(p1h.y*p2h.z - p1h.z*p2h.y,
                     p1h.z*p2h.x - p1h.x*p2h.z,
                     p1h.x*p2h.y - p1h.y*p2h.x);
    
    Point2f lineHomoNorm(lineHomo.x / lineHomo.z,
                         lineHomo.y / lineHomo.z);
    return lineHomoNorm;
}

And pass this points inside.并通过这个点里面。 As I remember I also dig inside OpenCV implementation of findHomography and insert this lines somewhere inside to solve step.我记得我还挖掘了findHomography的 OpenCV 实现,并将这条线插入到里面的某个地方来解决步骤。 Inside OpenCV there some normalization applied to points before pass to solve step.在 OpenCV 内部,在通过求解步骤之前对点进行了一些归一化。 So you need to skip this step for this kind of points.因此,您需要跳过此步骤以获得此类积分。

We do not use it in production.我们不在生产中使用它。 User need to calibrate camera manually by providing lines and points on the image and in meter system.用户需要通过在图像和仪表系统中提供线和点来手动校准相机。 It has too complicated interface and bad stability.界面过于复杂,稳定性差。 But in your case I think it can work better.但在你的情况下,我认为它可以更好地工作。 If you will automatically find lines and correspondence.如果你会自动找到线路和信件。

PS Please note that in paper they use some normalization technique. PS请注意,在论文中他们使用了一些标准化技术。 It will improve stability.它将提高稳定性。 We faced with stability problem, do not solved it in our journey.我们面临稳定性问题,在我们的旅程中没有解决它。

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

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