本文介绍了相机校准和在OpenCV的鸟瞰投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做过相机校准。现在我想得到鸟瞰图的棋盘图片。如下所示。但结果很奇怪,它看起来不是一个正方形。你可以看到pic3.Every正方形是7.95x7.95。 do smoebody konw为什么?

  gpsPoints [0] = Point2f(..., 
gpsPoints [1] = Point2f(...,...);
gpsPoints [2] = Point2f(...,...);
gpsPoints [3] = Point2f(...,...);

dst [0] = Point2f(...,...);
dst [1] = Point2f(...,...);
dst [2] = Point2f(...,...);
dst [3] = Point2f(...,...);
Mat transmtx = getPerspectiveTransform(gpsPoints,dst);
warpPerspective(img,frame,transmtx,img.size());





因为你只提供了4个角,透视变换是唯一定义的。所以如果你确实选择了正确的4个角,但是在模式中的某个地方有错误的结构,那么这些结构在输入图像中必须是错误的。



这可以从透镜畸变发生,使得实际上的直线在(输入)图像中不可见为直线。或者你的输入图像中的线条在现实世界中不是直的,例如你的图案基础不是完全平面的,或者你的图案在飞机上没有粘好。



在GIMP中我已为您的图片添加了一些标记。





轮廓(绿色圆点)是从一个角到下一个角的单个直线。正如你所看到的,它们在图案底部的边框上的位置很好,这是一个暗示你的图像没有太多的镜头失真。



在另一个手,顶部红线由单线段组成,总是连接两个相邻的角。正如你可以看到的,在第二和第三线段有一个显着的弯曲,所以在整个模式上没有直线。
底部的红线(细)是从图案一侧到另一侧的直线,你可以看到有一些部分,白色像素在线的两边。所以你的模式在图像中似乎不是直的。



我想你的模式不是很好的产生,但这只是一个猜测,也有一些奇怪的镜头行为。您可以从不同的视图(相同的相机焦点等,如果可能的话)捕获相同模式的图像进一步分析。



如user3896254(thx)透视翘曲被强烈地放大。测量(或手动标记)错误(即使是亚像素精度)可能是另一个问题。


I have done the camera calibration. Now i want to get Bird's Eye view of a checkerboard picture.As i show as following. But the result is strange,it looks like not a square.You can see the pic3.Every square is 7.95x7.95. Do smoebody konw why?

gpsPoints[0] = Point2f(..., ...);
gpsPoints[1] = Point2f(..., ...);
gpsPoints[2] = Point2f(..., ...);
gpsPoints[3] = Point2f(..., ...);

dst[0] = Point2f(..., ...);
dst[1] = Point2f(..., ...);
dst[2] = Point2f(..., ...);
dst[3] = Point2f(..., ...);
Mat transmtx = getPerspectiveTransform(gpsPoints, dst);
warpPerspective(img, frame, transmtx, img.size());
解决方案

In general a homography will transform straight lines to straight lines.

Since you only provided 4 corners, the perspective transform is uniquely defined. So if you indeed have chosen the right 4 corners but somewhere within the patter therer are wrong structures, those structues must have been wrong in the input image already.

In your scenario this can either happen from lens distortion, so that straight lines in reality aren't visible as straight lines in the (input) image. Or your lines in the input image aren't straight in real world, for exampl your pattern base isn't perfectly planar, or your pattern isn't glued well on the plane.

in GIMP I've added some markers to your image.

the outline (green dots) are single straight lines from one corner to the next. As you can see, they are lying quite well on the pattern base's border, this is a hint that there isn't much lens distortion in your image.

On the other hand, the top red line is made from single line segments, connecting always two neighbored corners. As you can see, there is a significant "bend" in the 2nd and 3rd line segment, so there is not straight line over the whole pattern.The bottom red line (thin) is a straight line from one side of the pattern to the other side, as you can see there are some parts where white pixels are on both side of the line. So your pattern doesn't appear to be straight in the image.

I guess your pattern isn't well produced, but that's just a guess, in the end it could be some strange lens behaviour, too. You could capture images of the same pattern from different views (same camera focus etc if possible) to analyze that further.

as stated by user3896254 (thx), different errors might be amplified strongly by perspective warping. Measurement (or manual marking) errors (even in subpixel accuracy) might be another problem.

这篇关于相机校准和在OpenCV的鸟瞰投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 12:55