kookoo121
kookoo121

Reputation: 1136

camera calibration and Bird's Eye Projection in OpenCV

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());

enter image description here

enter image description here enter image description here

Upvotes: 4

Views: 1938

Answers (1)

Micka
Micka

Reputation: 20130

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.

enter image description here

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.

Upvotes: 5

Related Questions