9

I'm given a plane (support vector and plane's normal vector), an image which was taken by a camera of which i know the intrinsic parameters (fx,fy,cx,cy). How do i obtain the transformation of this image to a bird-eye-view like image (so that birds view is collinear to the plane's normal vector). I'm confused with the coordinate systems i have to use, some matrices are in world coordinates and some in local. I know that there is warpPerspective() in OpenCV, would this do the job?

Im using OpenCV: 2.4.9

Thanks alot!

Update: Do I have to calculate 4 points with the camera facing normal, then 4 points from the bird eye view and pass them to findHomography() to obtain the transformation matrix?

Update: Solved. Got it to work!

Sean M.
  • 595
  • 1
  • 4
  • 21
  • What you need is the top view, right? I.e. angle between view/camera vector and plane normal will be straight angle (180°). OTOH [bird's eye view](https://en.wikipedia.org/wiki/Bird%27s-eye_view) will be not be so, it'll have some angle other than 0/180°. Top view will be an orthographic view while bird's eye is a perspective view. – legends2k Dec 10 '14 at 06:56
  • This may help in calculating the camera transform: [Deriving gluLookAt](http://stackoverflow.com/a/22715392/183120) – legends2k Dec 10 '14 at 13:36
  • 1
    you will either need: extrinsic parameters of your camera (at least the view-angle) OR 4 pixel positions of "known" points on the plane (would be enough to know the relative position between those points on the plane). – Micka Dec 10 '14 at 13:51
  • In my first image suppose the "height" line is an axis, the angle between the camera and this axis is known. – Sean M. Dec 10 '14 at 14:01
  • maybe view-angle isnt enough, I'm stuck there... but I see you got it to work yourself? =) – Micka Dec 11 '14 at 10:11

1 Answers1

2

A rectangle on the world plane will appear as a quadrangle in your image.
In a bird's eye view, you want it to appear as a rectangle again. You must know at least the aspect ratio of this world rectangle for the top view to be correctly and equally scaled along both axes.

Given the 4 quadrangle 2D points in your image, and the destination rectangle corners (for which you essentially choose the 2D coordinates) you can calculate the homography from your quadrangle to a rectangle and use warpPerspective() to render it.

This is often the easiest way to do it.

You can also go through the camera and matrices themselves. For this you will need to rotate the camera to be above the plane with orthographic projection. See the homography decomposition here.

Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
  • what is my quadrangle? and how would i calculate the homography after? – Sean M. Dec 08 '14 at 22:07
  • Is the quadrangle obtained by calculating 4 points on the plane? What do you mean by "calculate the homography from your quadrangle to a rectangle", which rectangle? Could you explain it in more detail please? Thanks! – Sean M. Dec 10 '14 at 00:29