Friday, July 5, 2013

Camera calibration with OpenCV






What I need?

- Camera
     + Tested: USB Camera

- OpenCV
     + Tested: OpenCV 2.4.3 and OpenCV 2.4.5





Procedure

Step 0. Download the board from here ad print it (you will need it later).

Note: Next 2 steps are optional. You have to do them if you go to use shots of your camera instead live camera.

1. Copy the file in_VID.xml (OpenCV/samples/cpp/tutorial_code/calib3d/camera_calibration/in_VID.xml) to the following path: OpenCV/build/bin.

2. Rename it to default.xml.

3. Open a terminal and go to the path OpenCV/build/bin.

4. Write: 

$ ./calibration 0 -w 9 -h 6 -s 0.025 -o camera.yml -op -oe

Details:

* 0 is the parameter of your camera. To see what is the number of your camera, open a new terminal and write: ls /dev/video*. If you see /dev/video0 the number you have to write is 0; for /dev/video1, number 1; and so on ...

* - w 9. Is the width of your board, in my case 9.

* - h 6. Is the height of your board.

* - s 0.024. Size in meters of the squares.

* - o camera.yml. The output calibration file that will be created.

Next, you will see a window with the vision of your camera. You will have to put the printed chessboard in front of your camera in differents positions to calibrate.


And that's all!!!


8 comments:

  1. hello, where does the camera.yml file occurs?

    ReplyDelete
    Replies
    1. The camera.yml is the output file from calibration.

      Delete
  2. After I wrote
    ./calibration 0 -w 9 -h 6 -s 0.025 -o camera.yml -op -oe
    that appears is
    bash: ./calibration: No such file or directory
    what should I do?
    Please help me

    ReplyDelete
    Replies
    1. Try this --> ./cpp-example-calibration 0 -w 9 -h 6 -s 0.025 -o camera.yml -op -oe

      Delete
    2. Thank you for your tutorials and replies... I use OpenCV 2.4.9

      Delete
  3. hallo , now im trying to calibrate AR.Drone camera using ROS. do you have any idea how to do it? what proceduce should i do? please help me ..
    i want to use aruco in AR.Drone.

    ReplyDelete
  4. How to calibrate both AR Drone 2.0 camera using opencv?

    ReplyDelete