2

I need to obtain a new view of an image from a desired point of view (a general case of bird's eye view). Imagine we change the camera's position with a known rotation and transformation. what would be the new image of the same scene?

We may put it in another way: how can we compute homography matrix by having the rotation and translation matrices?

Here is a sample image:

sample image

I really appreciate any help!

Community
  • 1
  • 1
Ali
  • 73
  • 5
  • 10
  • I have previously used getPerspectiveTransform to create a mapping from 4 corresponding points in each image. Did you find any help in the documentation at: http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html – Trygve May 13 '14 at 17:20
  • If you want to infer the homography associated with a given 3D transformation, you need to have a calibrated camera. Is it your case? – BConic May 13 '14 at 18:16
  • @Trygve Thank you! I saw the function however, my case is different. I have an image and I need to have it's view from a few different point of views (similar to Bird's eye case). So I don't think getPerspectiveTransform could be a help. I am working of a model base object detection algorithm, That's why i need to have different views of a same scene. – Ali May 14 '14 at 11:44
  • @AldurDisciple Thank you! yes, the camera is calibrated. As I mentioned in the last comment; I am working of a model base object detection algorithm, That's why I need to have different views of the same scene. – Ali May 14 '14 at 11:45
  • There is something unclear: do you want to transform an input image using an homography or do you want to obtain a new image of a given scene viewed from a different viewpoint? These are two different things, since an homography can only help generate images obtained from the same viewpoint (with "arbitrary" rotation around this viewpoint). – BConic May 14 '14 at 17:32
  • @AldurDisciple The first one. Sorry for unclear explanation, it comes from my lack of knowledge in this area. what I want to do is basically the bird eye's case. I have an image and I like to build a perpendicular view. The thing is, I do not know the pose. So, I generate different guess for R and T and try to find the actual pose using an evolutionary algorithm. This could be done by using a flat object (a sign, like checkerboard) in the scene and try to find it in each try. – Ali May 14 '14 at 17:46
  • Can you show your input images in your question? – BConic May 14 '14 at 18:24
  • @AldurDisciple I found your answer to [this question](http://stackoverflow.com/questions/23275877/opencv-get-perspective-matrix-from-translation-rotation/23293723#23293723) quit useful. It seems to deal with a pretty same issue. However, I have some questions mostly about Ht: where does it come from? (Cz means the third element of C, right?) I tried it with your formula and also the suggestion made by Dave. Nevertheless, when I define T anything else than 0, in most of the cases I have just a black image as output. do you have any idea about this problem? Thanks! – Ali May 15 '14 at 21:09
  • That could be because the R and T you use are between the 2 camera positions, whereas the R and T used in that other answer are related to the relative pose between the camera and the checkerboard. Another question: do you have one single image that you want to transform, or several images ? – BConic May 16 '14 at 12:13

1 Answers1

0

Here is some same sample code that i create as a part of PlayChessWithAWebCam

see https://github.com/WolfgangFahl/play-chess-with-a-webcam/blob/master/examples/opencv/warp.py

Input: Chessboard

Command:

python3 warp.py

Result: Warped image

The code is originally from https://www.pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186