单目标定(相机棋盘法标定)

### 1. How to Calibrate a Monocular Camera

http://www.vision.caltech.edu/bouguetj/calib_doc/ 

Description: This tutorial cover using thecamera_calibration'scameracalibrator.py node to calibrate a monocular camera with a raw image over ROS.
Keywords: monocular, camera, calibrate
Tutorial Level: BEGINNER

Content

Before Starting

Make sure that you have the following:

  • a large  checkerboard with known dimensions. This tutorial uses a 8x6 checkerboard with 108mm squares. Calibration uses the interior vertex points of the checkerboard, so an "8x6" board is nine squares wide and seven high, like the example below.

  • a well lit 5m x 5m area clear of obstructions and check board patterns
  • a monocular camera publishing images over ROS

Compiling

Start by getting the dependencies and compiling the driver.

$ rosdep install camera_calibration
确定camera_calibration安装成功,运行,系统会有提示

Make sure that your monocular camera is publishing images over ROS. Let's list the topics to check that the images are published:

$ rostopic list
如果报错,你就运行roslaunch usb_cam usb_cam-test.launch

If you have multiple cameras or are running the driver in its own namespace, your topic names may differ.

### 2. Running the Calibration Node

To start the calibration you will need to load the image topics that will be calibrated:

$ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/camera/image_raw camera:=/camera
或者执行一下命令:完全根据自己的实际环境配置以及摄像头的使用和驱动的安装的配置
$ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/usb_cam/image_raw usb_cam:=/usb_cam

This will open up the calibration window which will highlight the checkerboard:

If it does not open up the window try the following parameter:

 --no-service-check

If you can't see any colored dots make sure you count the interior vertex points, not the squares!

### 3. Dual Checkerboards

New in D

Starting in Diamondback, you will be able to use multiple size checkerboards to calibrate a camera.

To use multiple checkerboards, give multiple --size and --square options for additional boards. Make sure the boards have different dimensions, so the calibration system can tell them apart.

### 4. Moving the Checkerboard

In order to get a good calibration you will need to move the checkerboard around in the camera frame such that:

  • checkerboard on the camera's left, right, top and bottom of field of view
    • X bar - left/right in field of view
    • Y bar - top/bottom in field of view
    • Size bar - toward/away and tilt from the camera
  • checkerboard filling the whole field of view
  • checkerboard tilted to the left, right, top and bottom (Skew)

At each step, hold the checkerboard still until the image is highlighted in the calibration window.

找一个电脑或者平板将这个图片打开;上下左右移动直至打开的窗口收集到足够的数据,随着相机位姿的改变,数据会不断地被采集,直至达到一定的量,灰色窗口的第一个CALIBRATE会变色,这样就可以了:

As you move the checkerboard around you will see three bars on the calibration sidebar increase in length. When theCALIBRATE button lights, you have enough data for calibration and can clickCALIBRATE to see the results.

Calibration can take about a minute. The windows might be greyed out but just wait, it is working.

  • Calibration Results:$ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/usb_cam/image_raw usb_cam:=/usb_cam
    *** Added sample 1, p_x = 0.781, p_y = 0.302, p_size = 0.526, skew = 0.337

  • 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
  • *** Added sample 44, p_x = 0.266, p_y = 0.142, p_size = 0.659, skew = 0.046
    *** Added sample 45, p_x = 0.496, p_y = 0.000, p_size = 0.544, skew = 0.062
     

After the calibration is complete you will see the calibration results in the terminal and the calibrated image in the calibration window:

A successful calibration will result in real-world straight edges 
appearing straight in the corrected image.

A failed calibration usually results in blank or unrecognizable 
images, or images that do not preserve straight edges.

After a successful calibration, you can use the slider at the top of the calibration window to change the size of the rectified image. A scale 
of 0.0 means that the image is sized so that all pixels in the 
rectified image are valid. The rectified image has no border, 
but some pixels from the original image are discarded. A scale of
 1.0 means that all pixels in the original image are visible, 
but the rectified image has black borders where there are no input 
pixels in the original image.

成功之后会生成大量校准数据:

('D = ', [0.14541604393850213, -0.664216792171563, 0.0009853065435147885, -0.003652439022776437, 0.0])
('K = ', [1228.9125932956754, 0.0, 327.8485995310994, 0.0, 1229.8469532267163, 266.52514792190664, 0.0, 0.0, 1.0])
('R = ', [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0])
('P = ', [1239.1102294921875, 0.0, 326.8031573488115, 0.0, 0.0, 1241.7911376953125, 266.73810591941947, 0.0, 0.0, 0.0, 1.0, 0.0])
None
# oST version 5.0 parameters
[image]
width  640
height  480
[narrow_stereo]
camera matrix
1228.912593 0.000000 327.848600
0.000000 1229.846953 266.525148
0.000000 0.000000 1.000000
distortion
0.145416 -0.664217 0.000985 -0.003652 0.000000
rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
projection
1239.110229 0.000000 326.803157 0.000000
0.000000 1241.791138 266.738106 0.000000
0.000000 0.000000 1.000000 0.000000

('D = ', [0.14541604393850213, -0.664216792171563, 0.0009853065435147885, -0.003652439022776437, 0.0])
('K = ', [1228.9125932956754, 0.0, 327.8485995310994, 0.0, 1229.8469532267163, 266.52514792190664, 0.0, 0.0, 1.0])
('R = ', [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0])
('P = ', [1239.1102294921875, 0.0, 326.8031573488115, 0.0, 0.0, 1241.7911376953125, 266.73810591941947, 0.0, 0.0, 0.0, 1.0, 0.0])
None
# oST version 5.0 parameters


[image]

width
640
height
480
[narrow_stereo]

camera matrix
1228.912593 0.000000 327.848600
0.000000 1229.846953 266.525148
0.000000 0.000000 1.000000

distortion
0.145416 -0.664217 0.000985 -0.003652 0.000000

rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000

projection
1239.110229 0.000000 326.803157 0.000000
0.000000 1241.791138 266.738106 0.000000
0.000000 0.000000 1.000000 0.000000



参考资料见官网icon-default.png?t=M3K6http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大江东去浪淘尽千古风流人物

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值