USB_camera单目相机的标定
单目相机官方标定流程:
标定的前提:在工作空间src中安装usb_cam包:git clone https://github.com/bosch-ros-pkg/usb_cam.git
- 启动ROS :
roscore
; - 进入工作空间 :
cd ~/catkin_ws2
source devel/setup.bash
; - 进入launch:
cd src/usb_cam/launch
; - 打开摄像头 :
cd src/usb_cam/launch
; - 重新打开终端,进入矫正窗口:
(未安装camera_calibration的需要检查是否安装:rosdep install camera_calibration
)
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0245 image:=/usb_cam/image_raw camera:=/usb_cam
; - 采集数据样本时,最好将上下左右远近倾斜等多个角度进行测试,将矫正窗口右侧x,y,size,skew全部铺满;
size:标定板在占视野的尺寸大小,也可以理解为标定板离摄像头的远近;
square:标定板方格边长(m);
skew:标定板在视野上下左右中的倾斜位置。
计算矫正参数:
点击CALIBRATE按钮,稍等1-2分钟,可以在命令窗中看到标定参数,点击COMMIT将结果保存到电脑路径:/home/sun/.ros/camera_info/head_camera.yaml,再次启动相机时就不会有Camera Calibration文件找不到的警告了。
矫正图像,请使用image_proc包。
如果没有自动载入矫正文件 ,那么就需要调用下image_proc这个包。两种解决方案:
1.在启动usb_cam的launch文件下面再加上。
2.或者启动usb_cam后,在终端命令窗口加上ROS_NAMESPACE=usb_cam rosrun image_proc image_proc。
摄像机标定的目的:求出相机的内、外参数,以及畸变参数
参矩阵: Intrinsic Matrix
焦距: Focal Length
主点: Principal Point
径向畸变: Radial Distortion
切向畸变: Tangential Distortion
旋转矩阵: Rotation Matrices
平移向量: Translation Vectors
平均重投影误差: Mean Reprojection Error
重投影误差: Reprojection Errors
重投影点: Reprojected Points
相机的各项Parameters:
~video_device (string, default: “/dev/video0”)
The device the camera is on.
~image_width (integer, default: 640)
Image width
~image_height (integer, default: 480)
Image height
~pixel_format (string, default: “mjpeg”)
Possible values are mjpeg, yuyv, uyvy
~io_method (string, default: “mmap”)
Possible values are mmap, read, userptr
~camera_frame_id (string, default: “head_camera”)
The camera's tf frame
~framerate (integer, default: 30)
The required framerate
~contrast (integer, default: 32)
Contrast of video image (0-255)
~brightness (integer, default: 32)
Brightness of video image (0-255)
~saturation (integer, default: 32)
Saturation of video image (0-255)
~sharpness (integer, default: 22)
Sharpness of video image (0-255)
~autofocus (boolean, default: false)
Enable camera's autofocus
~focus (integer, default: 51)
If autofocus is disabled, the focus of the camera (0=at infinity)
~camera_info_url (string, default: )
An url to the camera calibration file that will be read by the CameraInfoManager class
~camera_name (string, default: head_camera)
The camera name. This must match the name in the camera calibration