本文主要是介绍ros_indigo机器视觉,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
机器视觉
ROS集成了Kinect的的驱动包OpenNI,而且使用OpenCV库可以进行多种多样的图像处理。
1、安装依赖
sudo apt-get install ros-indigo-openni-*
sudo apt-get install ros-indigo-openni2-*
sudo apt-get install ros-indigo-freenect-*
2、安装Webcam Driver
cd ~/catkin_ws/src
git clone https://github.com/bosch-ros-pkg/usb_cam.git
cd ~/catkin_ws
catkin_make
rospack profile
3、测试
kinect
roslaunch freenect_launch freenect-registered-xyzrgb.launch
Xtion Camera
roslaunch openni2_launch openni2.launch depth_registration:=true
rosrun image_view image_view image:=/camera/rgb/image_raw
rosrun image_view image_view image:=/camera/depth_registered/image_rect
4、测试USB Webcam
usb_cam.launch
1 <launch>2 <arg name="video_device" default="/dev/video0" />3 4 <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" clear_params="true" output="screen">5 6 <remap from="usb_cam/image_raw" to="/camera/rgb/image_raw" />7 <remap from="usb_cam/camera_info" to="/camera/rgb/camera_info" />8 9 <param name="video_device" value="$(arg video_device)" />10 <param name="image_width" value="640" />11 <param name="image_height" value="480" />12 <param name="framerate" value="30" />13 <param name="pixel_format" value="yuyv" />默认笔记本的输出14 <param name="contrast" value="128" />15 <param name="brightness" value="128" />16 <param name="saturation" value="70" />17 <param name="autofocus" value="true" />18 <param name="camera_frame_id" value="camera_link" />19 20 </node>21 </launch>
roslaunch rbx1_vision usb_cam.launch video_device:=/dev/video0
rosrun image_view image_view image:=/camera/rgb/image_raw
rqt 图像界面查看
5、uvc驱动
sudo apt-get install ros-indigo-uvc-camera
cd ~/catkin_ws/src
git clone https://github.com/ericperko/uvc_cam.git
rosmake uvc_cam
6、安装OpenCV
python2.7
OpenCV
安装依赖:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
安装cmake-gui(用于生成OpenCV编译文件):
CMake 2.8.12.2
sudo apt-get install cmake-qt-gui
cmake-gui
下载OpenCV源代码:
可以从OpenCV官网直接下载:http://opencv.org/downloads.html
也可以使用git命令行直接clone:
cd ~/
//比如工作目录为opencv即,cd ~/opencv-master
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
进入OpenCV源代码目录,创建build文件夹:
cd ~/opencv-master/opencv
mkdir build
使用cmake-gui生成编译文件:
打开cmake-gui后,在source code栏选择OpenCV源代码所在目录(例如:/home/username/workplace/opencv),在build栏中填写刚才新建的build文件夹(例如:/home/username/workplace/opencv/build)
接下来cmake会检查所有依赖库以及其他各可选部分版本,这个过程中cmake会下载一个名为ippicv的库,但经常会出现下载失败而导致configure失败,建议手动下载下载地址:
https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz
后放入/home/username/opencv-master/opencv/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e文件夹中。(备注:使用的在线下载)
修改完后再点击Configure按钮,如果依旧有红色高亮显示条目,则再次点击Configure按钮,等待所有条目均不再高亮显示后点击Generate按钮,退出cmake-gui程序,在命令行里进入/home/username/workplace/opencv/build目录,输入以下命令:
make -j8
sudo make install
sudo ldconfig
安装Numpy
Numpy:pip install numpy
sudo apt-get install python-numpy
sudo apt-get install python-scipy
PCL:先安装基本pcl库,再去git上下载python版pcl接口
1) 通过PPA安装完整PCL库
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
2) 安装python-pcl
在github上下载python-pcl(地址:https://github.com/strawlab/python-pcl)
下载后进入python-pcl目录,输入命令:
make
sudo python setup.py install即可
如果报错,可能缺少依赖库。使用命令sudo pip install cython安装python-pcl的依赖库后再执行安装命令即可。
参考备注:
http://www.ncnynl.com/archives/201609/849.html
http://blog.exbot.net/archives/2669
http://rosclub.cn/post-682.html
这篇关于ros_indigo机器视觉的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!