ros打开笔记本摄像头,单目标定

来源:互联网 发布:企业软件实施服务介绍 编辑:程序博客网 时间:2024/05/16 07:43

笔记本摄像头多是usb 镜头

下载包或者sudo apt-get install ros-indigo-usb-cam

git clone https://github.com/bosch-ros-pkg/usb_cam.git 

打开驱动

 rosrun usb_cam usb_cam_node

端口为/dev/video0, 如果你外接了usb摄像头,你应该把该端口改成video1,自行从/dev下验证
对应的话题

robot@ubuntu:/dev$ rostopic list/rosout/rosout_agg/usb_cam/camera_info/usb_cam/image_raw/usb_cam/image_raw/compressed/usb_cam/image_raw/compressed/parameter_descriptions/usb_cam/image_raw/compressed/parameter_updates/usb_cam/image_raw/compressedDepth/usb_cam/image_raw/compressedDepth/parameter_descriptions/usb_cam/image_raw/compressedDepth/parameter_updates/usb_cam/image_raw/theora/usb_cam/image_raw/theora/parameter_descriptions/usb_cam/image_raw/theora/parameter_updates

读取视频(重映射话题名)

 rosrun image_view image_view image:=/usb_cam/image_raw

保存图片序列,jpg+ini
rosrun image_view image_saver image:=/usb_cam/image_raw

launch

<launch>  <!-- Arguments -->  <!-- Show video output (both RAW and rectified) -->  <arg name="view" default="true"/>  <!-- Camera driver -->  <node pkg="usb_cam" type="usb_cam_node" name="camera"/>  <!-- Show video output -->  <group if="$(arg view)">    <!-- Image viewer (non-rectified image) -->    <node pkg="image_view" type="image_view" name="image_raw">      <remap from="image" to="usb_cam/image_raw"/>    </node>  </group></launch>

打开rviz 来看看视频吧
add->image
设置image topic 即可

接下来摄像头的标定
ros提供了单目和双目的标定程序,使用张正友标定法。
http://wiki.ros.org/camera_calibration
下载camera_calibraiton 包
或者rosdep install camera_calibraion

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/usb_cam/image_raw camera:=/usb_cam

–size 表示所使用棋盘格内部的行列角点数量,
–square 表示单个方格的大小,单位m

标定程序使用方法:
为了得到一个好的标定结果,应该使得标定板尽量出现在摄像头视野的各个位置里:
如标定板出现在视野中的左边,右边,上边和下边,标定板既有倾斜的,也有水平的,。
界面中的x:表示标定板在视野中的左右位置。
y:表示标定板在视野中的上下位置。
size:标定板在占视野的尺寸大小,也可以理解为标定板离摄像头的远近。
skew:标定板在视野中的倾斜位置。
并还要有棋盘占住大部分视野的图片,直到calibrate点亮
点击 commit 保存标定结果,保存在~/.ros/camera_info/hea_camera.yaml

camera_calibration_parsers创建yaml参数文件

$ rosrun camera_calibration_parsers convert in-file out-file 

http://blog.csdn.net/ArtistA/article/details/51125560?locationNum=15&fps=1
参数含义:
image_width、image_height代表图片的长宽
camera_name为摄像头名
camera_matrix规定了摄像头的内部参数矩阵
distortion_model指定了畸变模型
distortion_coefficients指定畸变模型的系数
rectification_matrix为矫正矩阵,一般为单位阵
projection_matrix为外部世界坐标到像平面的投影矩阵

原创粉丝点击