前期准备

   
$ cd catkin_ws/src  
$ git clone  https://github.com/ros-perception/image_pipeline.git  
$ cd ..  
$ rosdep install --from-paths src --ignore-src   # 安装image_pipeline 所需的依赖
$ catkin_make
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
 

第一步:启动相机

 
 roslaunch usb_cam usb_cam-test.launch
 
  • 这一句是根据前期准备中安装相机驱动而来。
 

第二步:查看相机话题名称

 
  • 用rostopic list命令查看,本人电脑的image的topic名称为:/usb_cam/image_raw
 

第三步:启动校正程序

 
rosrun camera_calibration cameracalibrator.py --size 7x6 --square 0.0232 image:=/usb_cam/image_raw camera:=/camera
  输入如下命令重新尝试  
rosrun camera_calibration cameracalibrator.py --size 7x6 --square 0.0232 image:=/usb_cam/image_raw camera:=/camera --no-service-check
 
  • 如果成功,会有如下结果。
  • 移动标定板,使得标定板需遍历整个图像区域,之后CALIBRATE会变绿。点击即可进行校正运算,结果在终端有显示,也可以选择保存。
  微信图片_20210123153351  
  • 结果展示
 
('D = ', [-0.04483935850269598, 0.21668635011274098, -7.511409441343408e-06, -0.014566337456272171, 0.0])
('K = ', [657.954311720957, 0.0, 297.0047475623269, 0.0, 653.7091694249858, 236.35301154477284, 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 = ', [664.5278930664062, 0.0, 290.7184962020892, 0.0, 0.0, 667.2344970703125, 236.43032880130704, 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
657.954312 0.000000 297.004748
0.000000 653.709169 236.353012
0.000000 0.000000 1.000000

distortion
-0.044839 0.216686 -0.000008 -0.014566 0.000000

rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000

projection
664.527893 0.000000 290.718496 0.000000
0.000000 667.234497 236.430329 0.000000
0.000000 0.000000 1.000000 0.000000
 

总结

  在做实验的过程中,就算严格按照网上的教程也会出现各种各样的错误。这时候不要急着否定这种方法,分析一下自己所遇到的问题,找出问题的原因,并自己尝试去解决。如果不行,在网上搜索相似的教程进行比较,是否是步骤缺少还是步骤写错。不断提高自己分析问题和解决问题的能力。  

参考资料

http://wiki.ros.org/camera_calibration