当前位置:网站首页>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>
边栏推荐
猜你喜欢
Introduction to CLS-PEG-FITC Fluorescein-PEG-CLS Cholesterol-PEG-Fluorescein
机器学习和深度学习概述
UR3机器人雅克比矩阵
[已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config
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.
日志jar包冲突,及其解决方法
如何修改数据库密码
UR3机器人运动学分析之逆运动学分析
cv2.imread()
Numpy常用函数
随机推荐
Introduction to CLS-PEG-FITC Fluorescein-PEG-CLS Cholesterol-PEG-Fluorescein
解决background-size:cover时图片铺满但显示不完整?
Tensorflow相关list
Cholesterol-PEG-NHS NHS-PEG-CLS 胆固醇-聚乙二醇-活性酯可修饰小分子材料
crontab的定时操作
Natural language processing related list
机器学习和深度学习概述
DingTalk H5 micro-app login authentication
Cholesterol-PEG-Thiol CLS-PEG-SH 胆固醇-聚乙二醇-巯基
用pytorch里的children方法自定义网络
VTK:Could not locate vtkTextRenderer object.
Chemical Reagent Phospholipid-Polyethylene Glycol-Amino, DSPE-PEG-amine, CAS: 474922-26-4
MySQL 出现 The table is full 的解决方法
Virtual machine view port number process
Wangeditor rich text editor to upload pictures and solve cross-domain problems
DSPE-PEG-Biotin,CAS:385437-57-0,磷脂-聚乙二醇-生物素可延长循环半衰期
2021年软件测试面试题大全
Log jar package conflict, and its solution
Podspec automatic upgrade script
2021-09-30