在ROS 使用摄像头 WebCam 完成图像处理(1) -- 获取图像数据
我们要使用摄像头,先要能看到摄像头图像:(见附录)
然后我们这里是参考《ros_by_example》( volume1 hydro )书中的方法。这里要注意的是:虚拟机里的Ubuntu使用cheese, guvcview这样的工具是可以获取图像的,但ros里提供的摄像头驱动,比如uvc_camera, 就不能很好的工作了。
1. 环境搭建的准备工作
ROS组织发布的基础包
开始之前,安装Prerequisites:(是一些ROS组织发布的基础包)
-----$ sudo apt-get install ros-hydro-turtlebot-* \
ros-hydro-openni-camera ros-hydro-openni-launch \
ros-hydro-uvc-camera \
ros-hydro-openni-tracker ros-hydro-laser-* \
ros-hydro-audio-common ros-hydro-joystick-drivers \
ros-hydro-orocos-kdl ros-hydro-python-orocos-kdl \
ros-hydro-dynamixel-motor-* ros-hydro-pocketsphinx \
gstreamer0.10-pocketsphinx python-setuptools python-rosinstall \
ros-hydro-opencv2 ros-hydro-vision-opencv \
ros-hydro-depthimage-to-laserscan ros-hydro-arbotix-* \
git subversion mercurial
-----
这里有点洒拦河网的感觉,其实可以只安装这几个:
$ sudo apt-get install ros-hydro-openni-camera \
ros-hydro-openni-launch \
ros-hydro-uvc-camera \
python-setuptools \
python-rosinstall \
ros-hydro-opencv2 \
ros-hydro-vision-opencv \
git subversion mercurial
1. Installing Webcam Drivers(OPTIONAL)
To use a typical USB webcam, there are a number of possible driver packages available.
The one we will use here is from Eric Perko's repository. Type the following commands
to move into your personal ROS directory, retrieve the source code, then make the
package:
$ sudo apt-get install git-core
$ cd ~/catkin_ws/src
$ git clone https://github.com/ericperko/uvc_cam.git
$ cd ~/catkin_ws
$ catkin_make
Tips:如果你是ROS Electric, Fuerte, or Groovy, 自己看《ros_by_example》( volume1 hydro )书吧。如果你是Hydro,要用Git 工具下载 rbx1 代码再生成ROS Packages就像former教程写的一样.
Commands:
$ cd ~/catkin_ws/src && git clone
--depth=1
https://github.com/pirobot/rbx1.git$ cd rbx1 && git checkout hydro-devel
$ cd ~/catkin_ws && catkin_make
$ source ~/catkin_ws/devel/setup.bash
-----
git clone 太慢怎么办 ? 所以我这里使用了 --depth=l 进行浅复制
以上这几行命令,对于你应该很熟悉了,你是有基础的人。这里我们就用了'ROS By Example' 书提供的包了,All of the 'ROS By Example' packages begin with the letters rbx1。
===========
To list the packages,
move into the parent of the rbx1 meta-package and use the Linux ls command:
$ roscd rbx1 $ cd .. $ ls -F
which should result in the following listing:
rbx1/