当前位置:网站首页>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>
边栏推荐
- DingTalk H5 micro-app login authentication
- 【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton
- Multi-Modal Face Anti-Spoofing Based on Central Difference Networks学习笔记
- DSPE-PEG-Azide DSPE-PED-N3 磷脂-聚乙二醇-叠氮脂质PFG
- Cholesterol-PEG-Amine CLS-PEG-NH2 胆固醇-聚乙二醇-氨基科研用
- softmax函数详解
- Pytorch常用函数
- 如何修改数据库密码
- 活体检测PatchNet学习笔记
- Research reagents Cholesterol-PEG-Maleimide, CLS-PEG-MAL, Cholesterol-PEG-Maleimide
猜你喜欢

机器学习和深度学习概述

The browser looks for events bound or listened to by js

拒绝采样小记

crontab的定时操作
![[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

mPEG-DMPE Methoxy-polyethylene glycol-bismyristyl phosphatidylethanolamine for stealth liposome formation

2022年SQL大厂高频实战面试题(详细解析)

Pytorch学习笔记13——Basic_RNN

VTK环境配置

random.randint函数用法
随机推荐
这些数组技巧,我爱了
cocos2d-x-3.2 image graying effect
Fluorescein-PEG-DSPE Phospholipid-Polyethylene Glycol-Fluorescein Fluorescent Phospholipid PEG Derivatives
Tensorflow——demo
Redis-Hash
When solving background-size:cover, the picture is covered but not displayed completely?
DSPE-PEG-Thiol DSPE-PEG-SH phospholipid-polyethylene glycol-thiol liposome for later use
四种常见的POST提交数据方式
为数学而歌之伯努利家族
Software Testing Interview Questions 2021
cv2.imread()
MySQL 入门:Case 语句很好用
CAS:474922-22-0 Maleimide-PEG-DSPE Phospholipid-Polyethylene Glycol-Maleimide Brief Description
softmax函数详解
The content of the wangeditor editor is transferred to the background server for storage
ROS 之订阅多个topic时间同步问题
Pytorch实现ResNet
日志jar包冲突,及其解决方法
mysql 事务原理详解
DSPE-PEG-COOH CAS: 1403744-37-5 Phospholipid-polyethylene glycol-carboxy lipid PEG conjugate