当前位置:网站首页>Use usb_cam to open multiple cameras at the same time
Use usb_cam to open multiple cameras at the same time
2022-07-31 06:32:00 【xp_fangfei】
最近由于项目需要,Multiple cameras need to be turned on at the same time,虽然可以用opencvTo write the corresponding camera to open the program ; 但是,还是想用ros中提供的usb_camto open multiple cameras.
通过usb_camGo open a camera,不用下载源码,可以直接安装usb_cam去调用launchFile open camera.
- 安装方式:(ubuntu16.04)
sudo apt-get install ros-kinetic-usb-cam
- 打开摄像头(The default open index is 0的摄像头)
roslaunch usb_cam usb_cam-test.launch
- How to view camera index
ls /dev/video*
- Open cameras of other indexes need to be modified usb_cam-test.launch文件中“video_device”这一项;Modify the index to the camera index you want to open.
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" /> #修改此处
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<!--<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>-->
</launch>
Install the source code to open the camera:
- 下载源码
git clone https://github.com/bosch-ros-pkg/usb_cam.git
- 创建工作空间
详情参照https://blog.csdn.net/xp_fangfei/article/details/123412772?spm=1001.2014.3001.5502 - 把下载好的usb_caminto the newly created workspacesrc下,进行编译即可.
- usb_cam树结构
.
├── AUTHORS.md
├── CHANGELOG.rst
├── CMakeLists.txt
├── include
│ └── usb_cam
│ └── usb_cam.h
├── launch
│ ├── usb_cam-test.launch
├── LICENSE
├── mainpage.dox
├── nodes
│ └── usb_cam_node.cpp
├── package.xml
├── README.md
└── src
├── LICENSE
└── usb_cam.cpp
- Opening multiple cameras at the same time only needs to increase accordinglyusb_cam_node.cpp节点即可;usb_cam_node.cppThe contents that need to be changed are as follows:
# 修改内容一
usb_cam_node.cpp 中第89行 topic名称进行修改:
89 image_pub_ = it.advertiseCamera("image_raw", 1);
# 修改内容二
usb_cam_node.cpp 271line the node tomasterModify the node name registered in ,In order to avoid the registration of the same name,编译错误
271 ros::init(argc, argv, "usb_cam");
Example 1:
我新建了一个名为usb_cam_node1.cpp的节点,修改如下:
89 image_pub_ = it.advertiseCamera("image_raw_new", 1);
271 ros::init(argc, argv, "usb_cam1");
- 对应的CMakeLists.txt进行修改
add_executable #Add the executable file name corresponding to the node name
Example 1:
#CMakeLists.txteach time a node is added,Correspondingly add the following two parts
add_executable(${PROJECT_NAME}_node1 nodes/usb_cam_node1.cpp)
target_link_libraries(${PROJECT_NAME}_node1
${PROJECT_NAME}
${avcodec_LIBRARIES}
${swscale_LIBRARIES}
${catkin_LIBRARIES}
)
- 对应的launch文件进行修改
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
name="usb_cam" # Change it to the appropriate topic name,Used to communicate with other node topic names
type="usb_cam_node" #Modify it to the corresponding node name
Example 1:
usb_cam-test1.launch 内容如下
<launch>
<node name="usb_cam_node1" pkg="usb_cam" type="usb_cam_node1" output="screen" >
<param name="video_device" value="/dev/video1" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<!--<node name="image_view_node1" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam_node1/image_raw_new"/>
<param name="autosize" value="true" />
</node>-->
</launch>
- 每增加一个节点,对应一个launch文件;最后写一个launchfile to start several cameras at the same timelaunch文件,就可以实现usb_camTurn on the function of multiple cameras.
Example 1:
usb_cam-total.launch 内容如下:
<launch>
<include file="$(find usb_cam)/launch/usb_cam-test.launch" />
<include file="$(find usb_cam)/launch/usb_cam-test1.launch" />
</launch>
边栏推荐
- IDEA概述和安装及调试
- DingTalk H5 micro-app login authentication
- 拒绝采样小记
- 四种常见的POST提交数据方式
- 变分自编码器VAE实现MNIST数据集生成by Pytorch
- Natural language processing related list
- Podspec verification dependency error problem pod lib lint , need to specify the source
- MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid
- [已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config
- mPEG-DMPE Methoxy-polyethylene glycol-bismyristyl phosphatidylethanolamine for stealth liposome formation
猜你喜欢

pytorch模型微调finetuning训练image_dog(kaggle)

Phospholipids-Polyethylene Glycol-Active Esters for Scientific Research DSPE-PEG-NHS CAS: 1445723-73-8

Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives

IDEA控制台不能输入信息的解决方法

CAS:474922-22-0 Maleimide-PEG-DSPE Phospholipid-Polyethylene Glycol-Maleimide Brief Description
![[已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config](/img/53/8b5a12e7ed551dca52ada5dbb5d6b5.png)
[已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config

【Rhapsody学习笔记】3:Dishwasher

Embedding前沿了解

Numpy常用函数

计算图像数据集均值和方差
随机推荐
Learn how to get a database connection with JDBC
活体检测FaceBagNet阅读笔记
数据分析之SQL面试真题
虚拟机查看端口号进程
IDEA概述和安装及调试
Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400
使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)
opencv之图像二值化处理
科学研究用磷脂-聚乙二醇-活性酯 DSPE-PEG-NHS CAS:1445723-73-8
这些数组技巧,我爱了
The solution to the IDEA console not being able to enter information
2021-09-30
Tensorflow——demo
多元线性回归方程原理及其推导
Podspec automatic upgrade script
wangeditor富文本编辑器上传图片以及跨域问题解决
Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives
数据预处理、特征工程和特征学习-摘抄
RuntimeError: CUDA error: no kernel image is available for execution on the device问题记录
MySQL 出现 The table is full 的解决方法