网页显示摄像头数据的方法---基于web video server

1. 背景:

在ros系统中有发布摄像头的相关驱动rgb数据,需求端需要将rgb数据可以直接在网页上去显示。

问题解决:

web_video_server功能包,相关链接:

web_video_server - ROS Wiki

2. 下载,安装和编译:

由于我们项目使用的是ros2系统,所以下载web video server在ros2的分支,可以根据自己的实际需求来下载:

git clone https://github.com/RobotWebTools/web_video_server.git

下载之后可以查看分支,并且编译代码:

cindy@ubuntu:~/web_video_server$ git branch
  develop
* ros2
cindy@ubuntu:~/web_video_server$ colcon build --packages-select web_video_server
Starting >>> web_video_server
--- stderr: web_video_server                         
CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "Findasync_web_server_cpp.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "async_web_server_cpp", but CMake did not find one.

  Could not find a package configuration file provided by
  "async_web_server_cpp" with any of the following names:

    async_web_server_cppConfig.cmake
    async_web_server_cpp-config.cmake

  Add the installation prefix of "async_web_server_cpp" to CMAKE_PREFIX_PATH
  or set "async_web_server_cpp_DIR" to a directory containing one of the
  above files.  If "async_web_server_cpp" provides a separate development
  package or SDK, be sure it has been installed.


---
Failed   <<< web_video_server [1.22s, exited with code 1]

Summary: 0 packages finished [1.49s]
  1 package failed: web_video_server
  1 package had stderr output: web_video_server
cindy@ubuntu:~/web_video_server$ 

可以看到编译的过程中无法找到async_web_server_cpp的数据包:

 Could not find a package configuration file provided by
  "async_web_server_cpp"

3. async_web_server_cpp的下载,安装

后面要安装async_web_server_cpp的相关服务包:

代码下载:

git clone https://github.com/fkie/async_web_server_cpp.git

cindy@ubuntu:~/ros2_ws$ git clone https://github.com/fkie/async_web_server_cpp.git
Cloning into 'async_web_server_cpp'...
remote: Enumerating objects: 594, done.
remote: Counting objects: 100% (110/110), done.
remote: Compressing objects: 100% (64/64), done.
remote: Total 594 (delta 52), reused 76 (delta 35), pack-reused 484
Receiving objects: 100% (594/594), 113.65 KiB | 440.00 KiB/s, done.
Resolving deltas: 100% (358/358), done.

(1)首先,确保您已经安装了git和cmake。如果没有,请使用以下命令安装:

sudo apt-get install git cmake
(2)进入async_web_server_cpp目录并创建一个名为build的新目录:
cd async_web_server_cpp
mkdir build
cd build
(3)使用cmake命令生成Makefile:
cmake ..
(4)编译async_web_server_cpp:
make

 

(5)安装async_web_server_cpp:
sudo make install

完成后,您应该能够成功安装async_web_server_cpp,并且可以在video web server中使用它。

4. 再次编译web video server

cindy@ubuntu:~/web_video_server$ colcon build --packages-select web_video_server
Starting >>> web_video_server
--- stderr: web_video_server                                
/home/cindy/web_video_server/src/libav_streamer.cpp: In constructor ‘web_video_server::LibavStreamer::LibavStreamer(const async_web_server_cpp::HttpRequest&, async_web_server_cpp::HttpConnectionPtr, rclcpp::Node::SharedPtr, const string&, const string&, const string&)’:
/home/cindy/web_video_server/src/libav_streamer.cpp:65:55: warning: ‘int av_lockmgr_register(int (*)(void**, AVLockOp))’ is deprecated [-Wdeprecated-declarations]
   65 |   av_lockmgr_register(&ffmpeg_boost_mutex_lock_manager);
      |                                                       ^
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:11,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavcodec/avcodec.h:6163:5: note: declared here
 6163 | int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
      |     ^~~~~~~~~~~~~~~~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp:65:55: warning: ‘int av_lockmgr_register(int (*)(void**, AVLockOp))’ is deprecated [-Wdeprecated-declarations]
   65 |   av_lockmgr_register(&ffmpeg_boost_mutex_lock_manager);
      |                                                       ^
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:11,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavcodec/avcodec.h:6163:5: note: declared here
 6163 | int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
      |     ^~~~~~~~~~~~~~~~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp:66:19: warning: ‘void av_register_all()’ is deprecated [-Wdeprecated-declarations]
   66 |   av_register_all();
      |                   ^
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:12,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavformat/avformat.h:2050:6: note: declared here
 2050 | void av_register_all(void);
      |      ^~~~~~~~~~~~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp:66:19: warning: ‘void av_register_all()’ is deprecated [-Wdeprecated-declarations]
   66 |   av_register_all();
      |                   ^
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:12,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavformat/avformat.h:2050:6: note: declared here
 2050 | void av_register_all(void);
      |      ^~~~~~~~~~~~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp: In member function ‘virtual void web_video_server::LibavStreamer::initialize(const cv::Mat&)’:
/home/cindy/web_video_server/src/libav_streamer.cpp:160:35: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
  160 |   codec_context_ = video_stream_->codec;
      |                                   ^~~~~
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:12,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavformat/avformat.h:885:21: note: declared here
  885 |     AVCodecContext *codec;
      |                     ^~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp:160:35: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
  160 |   codec_context_ = video_stream_->codec;
      |                                   ^~~~~
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:12,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavformat/avformat.h:885:21: note: declared here
  885 |     AVCodecContext *codec;
      |                     ^~~~~
/home/cindy/web_video_server/src/libav_streamer.cpp:160:35: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
  160 |   codec_context_ = video_stream_->codec;
      |                                   ^~~~~
In file included from /home/cindy/web_video_server/include/web_video_server/libav_streamer.h:12,
                 from /home/cindy/web_video_server/src/libav_streamer.cpp:1:
/usr/include/aarch64-linux-gnu/libavformat/avformat.h:885:21: note: declared here
  885 |     AVCodecContext *codec;
      |                     ^~~~~
/usr/bin/ld: warning: libopencv_imgcodecs.so.4.2, needed by /opt/ros/foxy/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.4.5
/usr/bin/ld: warning: libopencv_imgproc.so.4.2, needed by /opt/ros/foxy/lib/libcv_bridge.so, may conflict with libopencv_imgproc.so.4.5
/usr/bin/ld: warning: libopencv_core.so.4.2, needed by /opt/ros/foxy/lib/libcv_bridge.so, may conflict with libopencv_core.so.4.5
---
Finished <<< web_video_server [20.5s]

Summary: 1 package finished [20.8s]
  1 package had stderr output: web_video_server

可以发现已经可以正常编译了

5.图像显示:

 编译好之后可以直接使用可执行文件:

cindy@ubuntu:~/web_video_server$ ./build/web_video_server/web_video_server
[INFO] [1692002533.657719757] [web_video_server]: Waiting For connections on 10.141.5.154:8080

 打开ros2驱动摄像头,就可以直接在网页上看到相关的图像了

相关用法和详细配置:
web_video_server打开一个本地端口并等待传入的HTTP请求。一旦通过HTTP请求ROS图像主题的视频流,它就会订阅相应的主题并创建视频编码器的实例。编码的原始视频分组被提供给客户端。可以通过将其他参数添加到查询字符串中来指定参数。要使用浏览器连接到节点,请使用以下URL:

Available URLs

  • Overview of available ROS topics: http://localhost:8080/

  • Webpage showing a video stream: http://localhost:8080/stream_viewer?topic={ROS_TOPIC}

  • Video stream URL: http://localhost:8080/stream?topic={ROS_TOPIC}

  • Snapshot of next image: http://localhost:8080/snapshot?topic={ROS_TOPIC}

Several parameters can be configure via the video stream URL - Example: http://localhost:8888/stream?topic=depthcloud_encoded&bitrate=250000&type=vp8

 

Image Parameters

These are the parameters that can be used to configure a stream or snapshot:

width (integer, default: original width)

  • The image stream will be resized to a new width and height. This parameter has to be used in conjunction with the height parameter.

height (integer, default: original height)

  • The image stream will be resized to a new width and height. This parameter has to be used in conjunction with the height parameter.

quality (integer, default: 90)

  • The jpeg image quality (1...100). This parameter can be used to reduce the size of the resulting stream.

invert (none, default: )

  • Rotates the image by 180 degrees before streaming.

default_transport (string, default: "raw")

  • The image transport to use (raw, compressed, theora).

Snapshot Parameters

These are the parameters that can be used to configure a snapshot:

quality (integer, default: 95)

  • The jpeg image quality (1...100). This parameter can be used to reduce the size of the resulting stream.

Stream Parameters

These are the parameters that can be used to configure a stream:

type (string, default: mjpeg)

  • The encoding method for the stream (mjpeg, vp8, ros_compressed, png, h264).

Additional parameters can be specified for each encoding type as described below.

Mjpeg Stream Parameters

These are the parameters that can be used to configure a mjpeg stream:

quality (integer, default: 95)

  • The jpeg image quality (1...100). This parameter can be used to reduce the size of the resulting stream.

VP8 Stream Parameters

These are the parameters that can be used to configure a vp8 stream:

bitrate (integer, default: 100000)

  • Maximum bitrate setting. Note that a small bitrate could significantly increase the latency due to a delayed transmission of larger intra frames.

qmin (integer, default: 10)

  • Minimum quantizer.

qmax (integer, default: 42)

  • Maximum quantizer.

gop (integer, default: 250)

  • Keyframe interval, this determines the maximum distance between I-frames.

quality (string, default: realtime)

  • The encoding quality.

More information on the quality and profile parameter of the VP8 codec can be found here: http://www.webmproject.org/docs/encoder-parameters

Unsupported customizations

Control image subscription rate

Rate at which web_video_server subscribes a image topic depends on the publisher's publish rate. With a fast publish rate, a client host may unintentionally get busy.

As of version 0.2.1, web_video_server does not come with a feature to control the rate at which the frontend subscribes to an image topic. You can work this around on your client.

One way is to republish the image topic with a lower rate. You can use throttle from topic_tools package.

ROS-Compressed Stream Example

rostopic list output:

$ rostopic list
/usb_cam/camera_info
/usb_cam/image_raw/compressed

View compressed stream at: http://localhost:8080/stream?topic=/usb_cam/image_raw&type=ros_compressed

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/74259.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Java算法_ 二叉树的最大深度(LeetCode_Hot100)

题目描述&#xff1a;给定一个二叉树 &#xff0c;返回其最大深度。root 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 获得更多&#xff1f;算法思路:代码文档&#xff0c;算法解析的私得。 运行效果 完整代码 /*** 2 * Author: LJJ* 3 * Date: 2023/…

Rx.NET in Action 第四章学习笔记

Part 2 核心思想 《Rx.NET in Action》这一部共分八章&#xff0c;涵盖了Rx 关键模块——**Observable(可观察序列)和Observer(观察者)**的全部功能&#xff0c;以及如何创建它们、连接它们和控制它们之间的关系。 然后&#xff0c;您将学习如何使用强大的 Rx 处理器构建复杂…

2023年京东按摩仪行业数据分析(京东销售数据分析)

近年来&#xff0c;小家电行业凭借功能与颜值&#xff0c;取代黑电和白电&#xff0c;成为家电市场的主要增长点。在这一市场背景下&#xff0c;颜值更高、功能更丰富、品种更齐全的各类按摩仪&#xff0c;借助新消费和电子商务的风潮&#xff0c;陆续被推上市场。今年&#xf…

VSCode使用SSH无密码连接Ubuntu

VSCode使用SSH无密码连接Ubuntu 前提条件&#xff1a; 1. 能够正常使用vscode的Remote-ssh连接Ubuntu 2. Ubuntu配置静态ip&#xff08;否则经常需要修改Remote-ssh的配置文件里的IP&#xff09; 链接-> ubuntun 18.04设为静态ip&#xff08;.net模式&#xff0c;可连接…

LVGL学习笔记 30 - List(列表)

目录 1. 添加文本 2. 添加按钮 3. 事件 4. 修改样式 4.1 背景色 4.2 改变项的颜色 列表是一个垂直布局的矩形&#xff0c;可以向其中添加按钮和文本。 lv_obj_t* list1 lv_list_create(lv_scr_act());lv_obj_set_size(list1, 180, 220);lv_obj_center(list1); 部件包含&…

手机的发展历史

目录 一.人类的通信方式变化 二.手机对人类通信的影响 三.手机的发展过程 四.手机对现代人的影响 一.人类的通信方式变化 人类通信方式的变化是一个非常广泛和复杂的话题&#xff0c;随着技术的进步和社会的发展&#xff0c;人类通信方式发生了许多重大的变化。下面是一些主…

【Linux命令详解 | ps命令】 ps命令用于显示当前系统中运行的进程列表,帮助监控系统状态。

文章标题 简介一&#xff0c;参数列表二&#xff0c;使用介绍1. 基本用法2. 显示所有进程3. 显示进程详细信息4. 根据CPU使用率排序5. 查找特定进程6. 显示特定用户的进程7. 显示进程内存占用8. 查看进程树9. 实时监控进程10. 查看特定进程的详细信息11. 查看特定用户的进程统计…

哪种电容笔更好用?学生党开学值得买电容笔推荐

在过半个月就马上要到开学季了&#xff0c;随着平板电脑在大学校园内的普及&#xff0c;对电容笔提出了更高的要求。而苹果的正版电容笔产品&#xff0c;虽然有着强大的功能&#xff0c;但由于其具有更加昂贵的价格&#xff0c;让其只能作为一种学习和记录的工具&#xff0c;由…

HCIP-OpenStack

1、OpenStack概述 OpenStack是一种云操作系统&#xff0c;OpenStack是虚拟机、裸金属和容器的云基础架构。可控制整个数据中心的大型计算、存储和网络资源池&#xff0c;所有资源都通过API或Web界面进行管理。 为什么称OpenStack是云操作系统&#xff1f; 云一般指云计算&…

七、dokcer-compose部署springboot的jar

1、准备 打包后包名为 ruoyi-admin.jar 增加接口 httpL//{ip}:{port}/common/test/han #环境变量预application.yml 中REDIS_HOSTt的值&#xff0c;去环境变量去找&#xff1b;如果找不到REDIS_HOST就用myredis 1、Dockerfile FROM hlw/java:8-jreRUN ln -sf /usr/share/z…

使用vscode进行远程调试

官方调试手册&#xff1a;vscode官方调试手册 1.安装python扩展 如果是远程连接的话&#xff0c;一定要在ssh上启用扩展。不然创建基于python的配置文件时就会提示&#xff0c;无python扩展。 2.新建配置文件&#xff0c;并修改参数 点击左侧第四个按钮&#xff0c;运行与调试…

【数据结构】二叉树篇|超清晰图解和详解:二叉树的最近公共祖先

博主简介&#xff1a;努力学习的22级计算机科学与技术本科生一枚&#x1f338;博主主页&#xff1a; 是瑶瑶子啦每日一言&#x1f33c;: 你不能要求一片海洋&#xff0c;没有风暴&#xff0c;那不是海洋&#xff0c;是泥塘——毕淑敏 目录 一、题目二、题解三、代码 一、题目 …

约数个数(质因子分解)

思路&#xff1a; &#xff08;1&#xff09;由数论基本定理&#xff0c;任何一个正整数x都能写作&#xff0c;其中p1,p2..pk为x的质因子。 &#xff08;2&#xff09;由此可以推断&#xff0c;要求一个数约数的个数&#xff0c;注意到约数就是p1,p2...pk的一种组合&#xff…

toB 业务分析

1、 如何透彻分析B端客户的需求&#xff1f; - 知乎我在讲《如何分析客户需求》这门课时&#xff0c;经常会问学员&#xff1a;“开发客户的最大困难是什么&#xff1f;”有人说价格高不好卖&#xff0c;有人说客户需求不好把握&#xff0c;有人说客户地处偏远&#xff0c;素养…

windows程序基础

一、windows程序基础 1. Windows程序的特点 1&#xff09;用户界面统一、友好 2&#xff09;支持多任务:允许用户同时运行多个应用程序(窗口) 3&#xff09;独立于设备的图形操作 使用图形设备接口( GDI, Graphics Device Interface )屏蔽了不同硬件设备的差异&#…

深入理解 go协程 调度机制

Thread VS Groutine 这里主要介绍一下Go的并发协程相比于传统的线程 的不同点&#xff1a; 创建时默认的stack大小 JDK5 以后Java thread stack默认大小为1MC 的thread stack 默认大小为8MGrountine 的 Stack初始化大小为2K 所以Grountine 大批量创建的时候速度会更快 和 …

一百五十四、Kettle——Linux上安装Kettle9.3(踩坑,亲测有效,附截图)

一、目的 由于kettle8.2在Linux上安装后&#xff0c;共享资源库创建遇到一系列问题&#xff0c;所以就换成kettle9.3 二、kettle版本以及安装包网盘链接 kettle9.3.0安装包网盘链接 链接&#xff1a;https://pan.baidu.com/s/1MS8QBhv9ukpqlVQKEMMHQA?pwddqm0 提取码&…

《封神第一部》票房已破21亿,商朝真有大象,苏妲己可能是周文王的恩人

随着《封神第一部&#xff1a;朝歌风云》的持续大火&#xff0c;我周六也去电影院贡献了一票&#xff0c;重温中国神话经典&#xff0c;感受历史史诗的震撼&#xff0c;改编的非常棒&#xff0c;我很喜欢。 针对影片中的一些故事和疑问&#xff0c;做些总结。 1、影片中有几处镜…

无需停服!PostgreSQL数据迁移工具-NineData

PostgreSQL 是一种备受开发者和企业青睐的关系型数据库&#xff0c;其丰富的数据类型、地理空间负载和强大的扩展能力等特性使其备受欢迎。然而&#xff0c;在企业使用 PostgreSQL 承载应用的过程中&#xff0c;由于业务需要上云、跨云、下云、跨机房迁移、跨地域迁移、数据库版…

初识Redis

目录 认识Redis分布式系统Redis的特性Redis的应用场景Redis客户端Redis命令 认识Redis 上面一段话是官网给出的对Redis的介绍&#xff0c;in-memory data store表明Redis是在内存中存储数据的&#xff0c;这和我们接触的其他数据库就有很大的不同&#xff0c;比如MySQL&#xf…