当前位置: 首页 > news >正文

网页显示摄像头数据的方法---基于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 branchdevelop
* 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 thisproject 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.cmakeasync_web_server_cpp-config.cmakeAdd the installation prefix of "async_web_server_cpp" to CMAKE_PREFIX_PATHor set "async_web_server_cpp_DIR" to a directory containing one of theabove files.  If "async_web_server_cpp" provides a separate developmentpackage 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_server1 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 here6163 | 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 here6163 | 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 here2050 | 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 here2050 | 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 here885 |     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 here885 |     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 here885 |     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

相关文章:

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

1. 背景&#xff1a; 在ros系统中有发布摄像头的相关驱动rgb数据&#xff0c;需求端需要将rgb数据可以直接在网页上去显示。 问题解决&#xff1a; web_video_server功能包&#xff0c;相关链接&#xff1a; web_video_server - ROS Wiki 2. 下载&#xff0c;安装和编译&a…...

SIFT 算法 | 如何在 Python 中使用 SIFT 进行图像匹配

介绍 人类通过记忆和理解来识别物体、人和图像。你看到某件事的次数越多,你就越容易记住它。此外,每当一个图像在你的脑海中弹出时,它就会将该项目或图像与一堆相关的图像或事物联系起来。如果我告诉你我们可以使用一种称为 SIFT 算法的技术来教机器做同样的事情呢? 尽管…...

K8S系列四:服务管理

写在前面 本文是K8S系列第四篇&#xff0c;主要面向对k8s新手同学。阅读本文需要读者对k8s的基本概念&#xff0c;比如Pod、Deployment、Service、Namespace等基础概念有所了解&#xff0c;尚且不了解的同学推荐先阅读本系列的第一篇文章《K8S系列一&#xff1a;概念入门》[1]…...

冠达管理:融券卖出交易规则?

融券卖出买卖是指投资者在没有实际持有某只股票的情况下&#xff0c;经过借入该股票并卖出来取得赢利的一种股票买卖方式。融券卖出买卖规矩针对不同市场、不同证券公司之间可能会存在一些差异&#xff0c;但基本的规矩包含如下几个方面。 一、融资融券的资历要求 在进行融券卖…...

图像变形之移动最小二乘算法(MLS)

基本原理 基于移动最小二乘的图像变形是通过一组源控制点和目标控制点来控制变形&#xff0c;对于每一个待求变形后位置的点而言&#xff0c;根据预设的形变类型&#xff08;如仿射变换、相似变换、刚性变换&#xff09;求解一个最小二乘优化目标函数估计一个局部的坐标变换矩阵…...

搭建一个功能齐全的网站

搭建一个功能齐全的网站,需要准备和掌握的一些关键技术和功能可概括如下: 前端技术: HTML/CSS - 网页内容结构和样式JavaScript - 实现网页交互功能前端框架(Vue、React等) - 更高效开发交互页面响应式设计 - 网站适配移动端 后端技术: 服务器(Linux、Nginx等) - 提供网站访…...

Java-jar和war包的区别

jar包和war包的区别&#xff1a; 1、war是一个web模块&#xff0c;其中需要包括WEB-INF&#xff0c;是可以直接运行的WEB模块&#xff1b;jar一般只是包括一些class文件&#xff0c;在声明了Main_class之后是可以用java命令运行的。 2、war包是做好一个web应用后&#xff0c;通…...

分类预测 | MATLAB实现CNN-BiGRU-Attention多输入分类预测

分类预测 | MATLAB实现CNN-BiGRU-Attention多输入单输出分类预测 目录 分类预测 | MATLAB实现CNN-BiGRU-Attention多输入单输出分类预测预测效果基本介绍模型描述程序设计参考资料 预测效果 基本介绍 Matlab实现CNN-BiGRU-Attention多特征分类预测&#xff0c;卷积双向门控循环…...

C#小轮子:Visual Studio自动编译Sass文件

文章目录 前言插件安装插件使用compilerconfig.jsonsass输入和css输出&#xff08;自动生成&#xff09;默认配置&#xff08;我不懂就不去动他了&#xff09; 解决Blazor热重载Bug 前言 我们知道css文件用起来太麻烦&#xff0c;如果样式一多&#xff0c;嵌套起来用css样式就…...

iOS字体像素与磅的对应关系

注意&#xff1a;低于iOS10的系统&#xff0c;显示的字宽和字高比高于iOS10的系统小。 这就是iOS10系统发布时&#xff0c;很多app显示的内容后面出现…&#xff0c;因而出现很多app为了适配iOS10系统而重新发布新版本。 用PS设计的iOS效果图中&#xff0c;字体是以像素&#x…...

阿里云ACP知识点

前言&#xff1a;记录ACP错题 1、在创建阿里云ECS时&#xff0c;每台服务器必须要包含_______用来存储操作系统和核心配置。 系统盘&#xff08;不是实例&#xff0c;实例是一个虚拟的计算环境&#xff0c;由CPU、内存、系统盘和运行的操作系统组成&#xff1b;ESC实例作为云…...

小视频AI智能分析系统解决方案

2022下半年一个项目&#xff0c;我司研发一个基于接收小视频录像文件和图片进行算法分析抓拍的系统&#xff0c;整理了一下主要思想如下&#xff1a; 采用C开发一个AI识别服务&#xff0c;该服务具有如下功能: 创建各类算法模型服务引擎池&#xff0c;每类池内可加载多个模型…...

简单谈谈 EMP-SSL:自监督对比学习的一种极简主义风

论文链接&#xff1a;https://arxiv.org/pdf/2304.03977.pdf 代码&#xff1a;https://github.com/tsb0601/EMP-SSL 其他学习链接&#xff1a;突破自监督学习效率极限&#xff01;马毅、LeCun联合发布EMP-SSL&#xff1a;无需花哨trick&#xff0c;30个epoch即可实现SOTA 主要…...

nginx的负载均衡

nginx的负载均衡 文章目录 nginx的负载均衡1.以多台虚拟机作服务器1.1 在不同的虚拟机上安装httpd服务1.2 在不同虚拟机所构建的服务端的默认路径下创建不同标识的文件1.3 使用windows本机的浏览器分别访问3台服务器的地址 2.在新的一台虚拟机上配置nginx实现反向代理以及负载均…...

linux系统服务学习(四)Linux系统下数据同步服务RSYNC

文章目录 Linux系统下数据同步服务RSYNC一、RSYNC概述1、什么是rsyncrsync的好姐妹数据同步过程 2、rsync特点3、rsync与scp的区别 二、RSYNC的使用1、基本语法2、本地文件同步3、远程文件同步思考&#xff1a;4、rsync作为系统服务Linux系统服务的思路&#xff1a; 三、任务解…...

走进 Linux

一、开关机 开机&#xff1a; 开机会启动许多程序。他们在windows叫做“服务”(service),在Linux就叫做“守护进程”&#xff08;daemon&#xff09;开机成功后&#xff0c;它会显示一个文本登录界面&#xff0c; 这个界面就是我们经常看到的登录界面&#xff0c;在这个登录界…...

Docker高级——Docker Swarm集群和部署应用

创建 Swarm 集群 初始化管理节点 [rootk8s-master ~]# docker swarm init --advertise-addr 192.168.192.133 Swarm initialized: current node (vy95txqo3pglh478e4qew1h28) is now a manager.To add a worker to this swarm, run the following command:docker swarm join …...

【SA8295P 源码分析】74 - QNX secpol 安全策略文件配置详解 及 secpol.bin 编译过程分析

【SA8295P 源码分析】74 - QNX secpol 安全策略文件配置详解 及 secpol.bin 编译过程分析 一、secpol 的编译流程:编译生成 secpol.bin 打包在 ifs2_la.img 中二、QNX 开启 secpol 功能三、为新进程 创建 新的secpol 安全策略:以 vmm_service 为例四、secpol 配置示例,以 I2…...

Docker入门使用

用一个hello world的小例子来入门docker 在 Docker 容器中部署 Python Flask 的简单 Hello World 项目&#xff0c;需要遵循以下流程&#xff1a; 编写应用程序 首先&#xff0c;在本地计算机上编写一个简单的 PythonFlask 应用程序&#xff0c;例如&#xff1a; # hello.…...

在SAP上使用 LiquidUI Android 扫描条形码/QR 码

LiquidUI Android 可使用安卓移动设备的内置摄像头扫描条形码和二维码&#xff0c;为输入框填充数值。因此&#xff0c;无需附加任何第三方设备进行扫描。 LiquidUI Android 还提供了扫描功能&#xff0c;如 Accessible-Enter&#xff08;俗称自动输入&#xff09;和 Accessib…...

AI-调查研究-01-正念冥想有用吗?对健康的影响及科学指南

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; &#x1f680; AI篇持续更新中&#xff01;&#xff08;长期更新&#xff09; 目前2025年06月05日更新到&#xff1a; AI炼丹日志-28 - Aud…...

MPNet:旋转机械轻量化故障诊断模型详解python代码复现

目录 一、问题背景与挑战 二、MPNet核心架构 2.1 多分支特征融合模块(MBFM) 2.2 残差注意力金字塔模块(RAPM) 2.2.1 空间金字塔注意力(SPA) 2.2.2 金字塔残差块(PRBlock) 2.3 分类器设计 三、关键技术突破 3.1 多尺度特征融合 3.2 轻量化设计策略 3.3 抗噪声…...

使用VSCode开发Django指南

使用VSCode开发Django指南 一、概述 Django 是一个高级 Python 框架&#xff0c;专为快速、安全和可扩展的 Web 开发而设计。Django 包含对 URL 路由、页面模板和数据处理的丰富支持。 本文将创建一个简单的 Django 应用&#xff0c;其中包含三个使用通用基本模板的页面。在此…...

Unity3D中Gfx.WaitForPresent优化方案

前言 在Unity中&#xff0c;Gfx.WaitForPresent占用CPU过高通常表示主线程在等待GPU完成渲染&#xff08;即CPU被阻塞&#xff09;&#xff0c;这表明存在GPU瓶颈或垂直同步/帧率设置问题。以下是系统的优化方案&#xff1a; 对惹&#xff0c;这里有一个游戏开发交流小组&…...

JavaScript 中的 ES|QL:利用 Apache Arrow 工具

作者&#xff1a;来自 Elastic Jeffrey Rengifo 学习如何将 ES|QL 与 JavaScript 的 Apache Arrow 客户端工具一起使用。 想获得 Elastic 认证吗&#xff1f;了解下一期 Elasticsearch Engineer 培训的时间吧&#xff01; Elasticsearch 拥有众多新功能&#xff0c;助你为自己…...

UE5 学习系列(三)创建和移动物体

这篇博客是该系列的第三篇&#xff0c;是在之前两篇博客的基础上展开&#xff0c;主要介绍如何在操作界面中创建和拖动物体&#xff0c;这篇博客跟随的视频链接如下&#xff1a; B 站视频&#xff1a;s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...

【解密LSTM、GRU如何解决传统RNN梯度消失问题】

解密LSTM与GRU&#xff1a;如何让RNN变得更聪明&#xff1f; 在深度学习的世界里&#xff0c;循环神经网络&#xff08;RNN&#xff09;以其卓越的序列数据处理能力广泛应用于自然语言处理、时间序列预测等领域。然而&#xff0c;传统RNN存在的一个严重问题——梯度消失&#…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

python如何将word的doc另存为docx

将 DOCX 文件另存为 DOCX 格式&#xff08;Python 实现&#xff09; 在 Python 中&#xff0c;你可以使用 python-docx 库来操作 Word 文档。不过需要注意的是&#xff0c;.doc 是旧的 Word 格式&#xff0c;而 .docx 是新的基于 XML 的格式。python-docx 只能处理 .docx 格式…...

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中&#xff0c;新增了一个本地验证码接口 /code&#xff0c;使用函数式路由&#xff08;RouterFunction&#xff09;和 Hutool 的 Circle…...