ros相机标定

1、安装相机驱动
通过以下命令安装
安装地址在(/opt/ros/kinetic/share)

sudo apt-get install ros-kinect-usb-cam

2、启动相机

roslaunch usb_cam usb_cam-test.launch 

运行结果如下

... logging to /home/feng/.ros/log/710dbc78-17ea-11e9-a8a9-000c291fe232/roslaunch-ubuntu-3332.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:42333/

SUMMARY
========

PARAMETERS
 * /image_view/autosize: True
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /usb_cam/camera_frame_id: usb_cam
 * /usb_cam/image_height: 480
 * /usb_cam/image_width: 640
 * /usb_cam/io_method: mmap
 * /usb_cam/pixel_format: yuyv
 * /usb_cam/video_device: /dev/video0

NODES
  /
    image_view (image_view/image_view)
    usb_cam (usb_cam/usb_cam_node)

auto-starting new master
process[master]: started with pid [3342]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 710dbc78-17ea-11e9-a8a9-000c291fe232
process[rosout-1]: started with pid [3355]
started core service [/rosout]
process[usb_cam-2]: started with pid [3363]
process[image_view-3]: started with pid [3373]
[ INFO] [1547463130.570905947]: using default calibration URL
[ INFO] [1547463130.571047645]: camera calibration URL: file:///home/feng/.ros/camera_info/head_camera.yaml
[ INFO] [1547463130.571764985]: Starting 'head_camera' (/dev/video0) at 640x480 via mmap (yuyv) at 30 FPS
[ WARN] [1547463130.660184950]: unknown control 'white_balance_temperature_auto'

[ WARN] [1547463130.663434875]: unknown control 'focus_auto'

[ INFO] [1547463131.121984924]: Using transport "raw"


3、修改launch文件
直接在文件夹里面修改不了,可以在终端上通过以下命令打开gedit修改

sudo gedit /opt/ros/kinetic/share/usb_cam/launch/usb_cam-test.launch 

launch文件内容如下:


  
    
    
    
    
    
    
  
  
    
    
  

video0代表笔记本原本相机,video1代表USB连接的相机,依据情况直接修改。
4、标定相机
打开新终端,运行如下程序

rosrun camera_calibration cameracalibrator.py --size 7x5 --square 0.030 image:=/usb_cam/image_raw camera:=/usb_cam

其中,
size表示所用棋盘格内部角点数
square表示棋盘格的变长,单位为米
image和camera表示设置摄像头发布的图像话题

程序运行图如下
ros相机标定_第1张图片
调整棋盘格在摄像机视野中的位置,直至程序中calibration亮起,然后点击calibration,等待标定结束,此过程有可能时间较长,标定结束后可以通过save 和commit保存标定结果和标定图。地址会在终端上显示。

你可能感兴趣的:(ROS学习)