2

I took the example of code for calibrating a camera and undistorting images from this book: shop.oreilly.com/product/9780596516130.do

As far as I understood the usual camera calibration methods of OpenCV work perfectly for "normal" cameras. When it comes to Fisheye-Lenses though we have to use a vector of 8 calibration parameters instead of 5 and also the flag CV_CALIB_RATIONAL_MODEL in the method cvCalibrateCamera2. At least, that's what it says in the OpenCV documentary

So, when I use this on an array of images like this (Sample images from OCamCalib) I get the following results using cvInitUndistortMap: abload.de/img/rastere4u2w.jpg

Since the resulting images are cut out of the whole undistorted image, I went ahead and used cvInitUndistortRectifyMap (like it's described here stackoverflow.com/questions/8837478/opencv-cvremap-cropping-image). So I got the following results: abload.de/img/rasterxisps.jpg

And now my question is: Why is not the whole image undistorted? In some pics of my later results you can recognize that the laptop for example is still totally distorted. How can I acomplish even better results using the standard OpenCV methods?

I'm new to stackoverflow and I'm new to OpenCV as well, so please excuse any of my shortcomings when it comes to expressing my problems.

Community
  • 1
  • 1
VollNoob
  • 267
  • 4
  • 15
  • Sorry about the links in my question, but because I'm new to stackoverflow I'm only allowed to use a maximum of 2 links. – VollNoob Dec 11 '13 at 11:55
  • I've not so much experience with undistortion and calibration (although I use it quite often), but a problem might be that your checkerboard pattern only covers a (small) part of the image (over all images), so your calibration and undistortion only works for that part of the image. – Micka Dec 11 '13 at 12:10
  • 1
    Remembering a project of some former colleagues, I found their shortpaper, mentioning that common calibration techniques might not work with extreme fish-eye cameras. But the paper is from 2008 so no idea whether openCV already uses "better" techniques: http://www.lfb.rwth-aachen.de/bibtexupload/pdf/STE08b.pdf – Micka Dec 11 '13 at 12:18
  • Thanks for the replies, I assume that @Micka was right, since I have images where no chessboard pattern could be found. Now I wonder how this can be done in order to further improve the results. – VollNoob Jan 06 '14 at 10:50
  • http://abload.de/img/cvfindchessboardcornezoa5z.png Does anybody know why the chessboard cannot be found in the last two pics? I know that it's pretty distorted, but the squares are still clearly visible. Can I improve the OpenCV methods with flags or anything? – VollNoob Jan 06 '14 at 11:16
  • I'm not sure how openCV detects the checkerboard... they might extract the corners and try to track lines through two corners to find the next one (along the pattern). Maybe they miss the corners because of too much distortion, but that's just a guess. – Micka Jan 06 '14 at 11:22
  • Unfortunately, I'm not able to find any solution on how to improve the results of the cvFindChessboardCorners-Method either – VollNoob Jan 29 '14 at 09:30
  • Maybe, someone could help me out with this question: http://stackoverflow.com/questions/21428124/improve-cvfindchessboardcorners – VollNoob Jan 30 '14 at 19:43

1 Answers1

2
  1. All chessboard corners should be visible to be found. The algorithm expect a certain size of chessboard such as 4x3 or 7x6 (for example). The white border around a chess board should be visible too or dark squares may not be defined precisely.

  2. You still have high distortions at the image periphery after undistort() since distortions are radial (that is they increase with the radius) and your found coefficients are wrong. The latter are wrong since a calibration process minimizes the sum of squared errors in pixel coordinates and you did not represent the periphery with enough samples.

TODO: You have to have 20-40 chess board pattern images if you use 8 distCoeff. Slant your boards at different angles, put them at different distances and spread them around, especially at the periphery. Remember, the success of calibration depends on sampling and also on seeing vanishing points clearly from your chess board (hence slanting and tilting).

Vlad
  • 4,425
  • 1
  • 30
  • 39