当前位置:网站首页>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>
边栏推荐
- VTK:Could not locate vtkTextRenderer object.
- 计算图像数据集均值和方差
- cocos2d-x-3.2 image graying effect
- Picture-in-Picture API in the browser
- DSPE-PEG-COOH CAS: 1403744-37-5 Phospholipid-polyethylene glycol-carboxy lipid PEG conjugate
- Cholesterol-PEG-Amine CLS-PEG-NH2 Cholesterol-Polyethylene Glycol-Amino Research Use
- Tensorflow边用边踩坑
- 四种常见的POST提交数据方式
- softmax函数详解
- Cholesterol-PEG-NHS NHS-PEG-CLS cholesterol-polyethylene glycol-active ester can modify small molecular materials
猜你喜欢

MySQL 入门:Case 语句很好用

Multi-Modal Face Anti-Spoofing Based on Central Difference Networks学习笔记
![[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config](/img/53/8b5a12e7ed551dca52ada5dbb5d6b5.png)
[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config

The content of the wangeditor editor is transferred to the background server for storage

Cholesterol-PEG-NHS NHS-PEG-CLS 胆固醇-聚乙二醇-活性酯可修饰小分子材料

Cholesterol-PEG-DBCO 胆固醇-聚乙二醇-二苯基环辛炔化学试剂

After unicloud is released, the applet prompts that the connection to the local debugging service failed. Please check whether the client and the host are under the same local area network.

Embedding前沿了解

学习JDBC之获取数据库连接的方式

DC-CDN学习笔记
随机推荐
Natural language processing related list
The browser looks for events bound or listened to by js
我的训练函数模板(动态修改学习率、参数初始化、优化器选择)
[已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config
OpenCV中的图像数据格式CV_8U定义
CAS: 1403744-37-5 DSPE-PEG-FA Phospholipid-Polyethylene Glycol-Folic Acid for Scientific Research
Evaluating Machine Learning Models - Excerpt
Fluorescein-PEG-DSPE 磷脂-聚乙二醇-荧光素荧光磷脂PEG衍生物
2022 SQL big factory high-frequency practical interview questions (detailed analysis)
qt:cannot open C:\Users\XX\AppData\Local\Temp\main.obj.15576.16.jom for write
pytorch模型微调finetuning训练image_dog(kaggle)
MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid
二进制转换成十六进制、位运算、结构体
MySQL 入门:Case 语句很好用
ROS 之订阅多个topic时间同步问题
cocos2d-x implements cross-platform directory traversal
VS2017 connects to MYSQL
超参数优化-摘抄
ROS之service传输图片
活体检测PatchNet学习笔记