02 Opencv系列(二)ROS框架下的摄像头调用方法

基础步骤:

1.配置工作环境

构建catkin_ws工作空间(预先建立相应文件夹)

cd ~/catkin_ws/src

安装和编译usb_cam

git clone https://github.com/bosch-ros-pkg/usb_cam usb_cam
cd usb_cam
mkdir build 
cd build 
cmake ..
make 

2.启动和测试

roscore //启动ros
roslaunch usb_cam usb_cam-test.launch //单独终端下运行

3.报错解决方案

错误1:v4l2-ctl: not found

sudo apt-get install v4l-utils

错误2:[usb_cam-test.launch] is neither a launch file in package [usb_cam] nor is [usb_cam] a launch file name      The traceback for the exception was written to the log file2

source ~/catkin_ws/devel/setup.bash //编译完成后,一般要刷新环境,避免找不到工作环境,要在运行usb_cam usb_cam-test.launch 测试命令前,与测试命令同一终端下执行。

 4.使用外部USB摄像头方法

与前述方案相似,但需要查询设备编号,一般默认笔记本自带摄像头是video0。

在src/usb_cam-develop/launch文件中的launch文件进行设备号更改,并保存。

ls /dev/video*//查询出现在的设备号(我设备号是video3)

运行usb_cam 后,报错一般是设备号错误引起的

备注:参考部分博客内容总结整理,侵权请联系删除!

原文地址:https://www.cnblogs.com/Pygoupfs/p/15209851.html