0

I am working with a fish-eye camera and need the reverse the distortion before any further calculation, In this question this is happening Correcting fisheye distortion

src = cv.LoadImage(src)
dst = cv.CreateImage(cv.GetSize(src), src.depth, src.nChannels)
mapx = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_32F, 1)
mapy = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_32F, 1)
cv.InitUndistortMap(intrinsics, dist_coeffs, mapx, mapy)
cv.Remap(src, dst, mapx, mapy, cv.CV_INTER_LINEAR + cv.CV_WARP_FILL_OUTLIERS,  cv.ScalarAll(0))

The problem with this is that this way the remap functions goes through all the points and creates a new picture out of. this is time consuming to do it every frame. They way that I am looking for is to have a point to point translation on the fish-eye picture to normal picture coordinates.

The approach we are taking is to do all the calculations on the input frame and just translate the result coordinates to the world coordinates so we don't want to go through all the points of a picture and create a new one out of it. (Time is really important for us)

In the matrices mapx and mapy there are some point to point translations but a lot of points are without complete translation. I tried to interpolate this matrices but the result was not what I was looking for.

Any help in would be much appreciated, even other approaches which are more time efficient than cv.Remap.

Thanks

Community
  • 1
  • 1
Khashayar
  • 2,014
  • 3
  • 22
  • 31
  • It is not clear from the question whether you want to undistort an image or just a set of discrete image positions (possibly not integers, i.e. with subpixel accuracy). If the latter, is the number pf positions expected to be much smaller than the image area? Please clarify. – Francesco Callari Jul 31 '13 at 20:49
  • @FrancescoCallari yes you are right I just want a small number of points, basically I want to pick up the contours will find their center point and will want this take this to undistorted position and afterwards bird-eye position – Khashayar Aug 01 '13 at 07:55

1 Answers1

3

I think what you want is cv.UndistortPoints().

Assuming you have detected some point features distorted in your distorted image, you should be able to do something like this:

cv.UndistortPoints(distorted, undistorted, intrinsics, dist_coeffs)

This will allow you to work with undistorted points without generating a new, undistorted image for each frame.

Aurelius
  • 11,111
  • 3
  • 52
  • 69
  • Thanks a lot for this, I looked into it. so basically in order to find the camera matrix and dist_coeffs I have to do the chessboard trick? We are doing something similar to this in order to get the bird-eye view out of the input! is it the same process? – Khashayar Aug 01 '13 at 08:03
  • @Khashayar How you get your camera and distortion parameters is up to you. Calibrating with a chessboard is one way to get them. Since you posted code which uses them, I assumed you had that data already. – Aurelius Aug 01 '13 at 16:16
  • Pretty neat. Thanks for this. – Selam Getachew Jul 13 '17 at 23:03