Kalibrering af Scorpion robotternes kamera

From ImageWiki

(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
-
Scorpion robotterne kan kalibreres, .
+
This page describes how to calibrate the camera on the Scorpion robots, some results of a calibration plus example usage.
-
''ikke'' Computer Vision .
+
The theory behind camera calibration will ''not'' be explained here, so if you need to perform a calibration you should probably pick up a book on Computer Vision and read the sections on calibration.
-
== Resultater ==
+
== Results ==
-
640x480:
+
Using the toolbox (see next section) gives the following results for 640x480 images:
  Calibration results after optimization (with uncertainties):
  Calibration results after optimization (with uncertainties):
Line 16: Line 16:
  Note: The numerical errors are approximately three times the standard deviations (for reference).
  Note: The numerical errors are approximately three times the standard deviations (for reference).
-
, .
+
If you perform a calibration and get better results, please update this page.
-
== Anvendelser ==
+
== Usage ==
-
. Her kan funktionen 'cvUndistort2' fra [[OpenCV]] benyttes (program ). :
+
The most important usage of the calibration is to get rid of barrel distortion. The [[OpenCV]] function 'cvUndistort2' does this for us (read the documentation of this function if you want to speed up your program). The following code snippet shows how to get rid of the distortion:
  // Camera parameters from the caibration
  // Camera parameters from the caibration
Line 41: Line 41:
  cvUndistort2(im, undistorted, intrinsic_matrix, distortion_coeffs);
  cvUndistort2(im, undistorted, intrinsic_matrix, distortion_coeffs);
-
Her er 'im' inddata billedet mens 'undistorted' kommer til at indeholder uddata.
+
Here, 'im' is the input image, while 'undistorted' contains the rectified output image.
-
== Hvordan foretages en kalibrering? ==
+
== How to Perform a Calibration? ==
-
Her er det valgt at benytte en matlab toolbox . [http://www.vision.caltech.edu/bouguetj/calib_doc/]. Der er tale om en gratis toolbox, men jeg er ikke klar over under hvilken licens den udgives.
+
Here we use a matlab toolbox for camera calibration as it appears to be the most common choice. You can get the toolbox at [http://www.vision.caltech.edu/bouguetj/calib_doc/].
-
, . . ''xfig'' og udskrive dette. 14x13 .
+
To perform the calibration, you need a calibration object. In this case we'll be using a chess board. We've got a couple of those in the image lab that are made out of paper. You can always create new ones be drawing them in programs like 'xfig' or 'inkscape' and printing the result. The current chess board contains 14x13 internal corners with 2cm between each.
-
. [[OpenCV]] program:
+
Once you have a calibration object you need to take pictures of it from several angles. I've used the following [[OpenCV]] program for that:
  #include "cv.h"
  #include "cv.h"
Line 86: Line 86:
  }
  }
-
Dette program 'q' . Du skal regne med at tage omkring 20 billeder af kalibreringsobjektet fra forskellige vinkler. Jo flere billeder desto bedre, .
+
This program exits when you press 'q' and saves the current image when you press any other key. You should expect to take approx. 20 images of your calibration object from several view points.
 +
The more pictures the better, but the amount of manual and computational work does increase with each image.
-
Nu hvor du har billeder skal du foretage kalibreringen. , .
+
Now that you have the images, you can follow the toolbox tutorial. This is well described on the toolbox webpage, so I won't bother. The short story is: install the toolbox from [http://www.vision.caltech.edu/bouguetj/calib_doc/] and following this guide [http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/example.html].
-
Kort sagt: installer toolboxen fra [http://www.vision.caltech.edu/bouguetj/calib_doc/] [http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/example.html].
+
-
 
+
-
 
+
-
Alternativt:
+
-
 
+
-
.
+

Latest revision as of 09:47, 11 August 2009

This page describes how to calibrate the camera on the Scorpion robots, some results of a calibration plus example usage.

The theory behind camera calibration will not be explained here, so if you need to perform a calibration you should probably pick up a book on Computer Vision and read the sections on calibration.

Results

Using the toolbox (see next section) gives the following results for 640x480 images:

Calibration results after optimization (with uncertainties):

Focal Length:          fc = [ 476.36883   482.93459 ] : [ 7.75839   7.66304 ]
Principal point:       cc = [ 239.23852   245.90425 ] : [ 5.36202   4.41832 ]
Skew:             alpha_c = [ 0.00000 ] : [ 0.00000  ]   => angle of pixel axes = 90.00000 : 0.00000 degrees
Distortion:            kc = [ -0.29624   0.13749   -0.01171   0.01984  0.00000 ] : [ 0.01248   0.01664   0.00120   0.00163  0.00000 ]
Pixel error:          err = [ 0.70369   0.80146 ]

Note: The numerical errors are approximately three times the standard deviations (for reference).

If you perform a calibration and get better results, please update this page.

Usage

The most important usage of the calibration is to get rid of barrel distortion. The OpenCV function 'cvUndistort2' does this for us (read the documentation of this function if you want to speed up your program). The following code snippet shows how to get rid of the distortion:

// Camera parameters from the caibration
CvMat *intrinsic_matrix = cvCreateMat(3, 3, CV_64FC1);
       CV_MAT_ELEM(*intrinsic_matrix, double, 0, 1) = 0;
       CV_MAT_ELEM(*intrinsic_matrix, double, 1, 0) = 0;
       CV_MAT_ELEM(*intrinsic_matrix, double, 2, 0) = 0;
       CV_MAT_ELEM(*intrinsic_matrix, double, 2, 1) = 0;
       CV_MAT_ELEM(*intrinsic_matrix, double, 2, 2) = 1;
       CV_MAT_ELEM(*intrinsic_matrix, double, 0, 0) = 476.36883;
       CV_MAT_ELEM(*intrinsic_matrix, double, 0, 2) = 239.23852;
       CV_MAT_ELEM(*intrinsic_matrix, double, 1, 1) = 482.93459;
       CV_MAT_ELEM(*intrinsic_matrix, double, 1, 2) = 245.90425;
CvMat *distortion_coeffs = cvCreateMat(1,4, CV_64FC1);
       CV_MAT_ELEM(*distortion_coeffs, double, 0, 0) = -0.29624;
       CV_MAT_ELEM(*distortion_coeffs, double, 0, 1) =  0.13749;
       CV_MAT_ELEM(*distortion_coeffs, double, 0, 2) = -0.01171;
       CV_MAT_ELEM(*distortion_coeffs, double, 0, 3) =  0.01984;
   
// The actual undistortion.
cvUndistort2(im, undistorted, intrinsic_matrix, distortion_coeffs);

Here, 'im' is the input image, while 'undistorted' contains the rectified output image.

How to Perform a Calibration?

Here we use a matlab toolbox for camera calibration as it appears to be the most common choice. You can get the toolbox at [1].

To perform the calibration, you need a calibration object. In this case we'll be using a chess board. We've got a couple of those in the image lab that are made out of paper. You can always create new ones be drawing them in programs like 'xfig' or 'inkscape' and printing the result. The current chess board contains 14x13 internal corners with 2cm between each.

Once you have a calibration object you need to take pictures of it from several angles. I've used the following OpenCV program for that:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <stdio.h>

int main() {
    // Create window
    const char *window = "Camera";
    cvNamedWindow(window, CV_WINDOW_AUTOSIZE);

    // Get Camera Handle
    CvCapture *cam = cvCaptureFromCAM(-1);

    // Do the actual work
    int i = 1;
    char buffer[100];
    while (true) {
        IplImage *im = cvQueryFrame(cam);
        
        // Show result
        cvShowImage(window, im);

        // What should we do?
        int action = cvWaitKey(4);
        if (action == 'q') break;
        else if (action > 0) {
            // Save image
            sprintf(buffer, "image%.3d.tif", i);
            cvSaveImage(buffer, im);
            i++;
        }
    }

    return 0;
}

This program exits when you press 'q' and saves the current image when you press any other key. You should expect to take approx. 20 images of your calibration object from several view points. The more pictures the better, but the amount of manual and computational work does increase with each image.

Now that you have the images, you can follow the toolbox tutorial. This is well described on the toolbox webpage, so I won't bother. The short story is: install the toolbox from [2] and following this guide [3].

Personal tools