网页显示摄像头数据的方法---基于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

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

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ios swift5 collectionView 瀑布流(两列)

文章目录 1.瀑布流1.1 demo地址1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和文字的高度 1.瀑布流 1.1 demo地址 CollectionViewWaterfallLayout - github 1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和…

【Android Framework系列】第10章 PMS之Hook实现广播的调用

1 前言 前面章节我们学习了【Android Framework系列】第4章 PMS原理我们了解了PMS原理&#xff0c;【Android Framework系列】第9章 AMS之Hook实现登录页跳转我们知道AMS可以Hook拦截下来实现未注册Activity页面的跳转&#xff0c;本章节我们来尝试一下HookPMS实现广播的发送。…

Stable Diffusion + Deform制作指南

1.安装sd以及deform插件,更新后记得重启 需要安装ffmpeg https://ffmpeg.org/download.html 选择对应版本然后安装 如果是windows需要解压后将ffmpeg的bin目录配置在电脑的环境变量里面。 2.准备一张初始开始图片 3.填写参数,这里面参数要注意,宽高一定是32的倍数。如果填写…

matplotlib绘制位置-时序甘特图

文章目录 1 前言2 知识点2.1 matplotlib.pyplot.barh2.2 matplotlib.legend的handles参数 3 代码实现4 绘制效果5 总结参考 1 前言 这篇文章的目的是&#xff0c;总结记录一次使用matplotlib绘制时序甘特图的经历。之所以要绘制这个时序甘特图&#xff0c;是因为22年数模研赛C…

电力能源管理系统在生物制药行业的应用

安科瑞 华楠 摘要&#xff1a;根据生物制品类企业的电力能源使用特点&#xff0c;制定了符合公司实际情况的能源管理系统&#xff0c;介绍了该系统的架构及其在企业的应用情况&#xff0c;提升了公司能源数据的实时监控能力&#xff0c;优化了公司能源分配&#xff0c;降低了公…

【数据结构】八大排序详解

&#x1f680; 作者简介&#xff1a;一名在后端领域学习&#xff0c;并渴望能够学有所成的追梦人。 &#x1f40c; 个人主页&#xff1a;蜗牛牛啊 &#x1f525; 系列专栏&#xff1a;&#x1f6f9;数据结构、&#x1f6f4;C &#x1f4d5; 学习格言&#xff1a;博观而约取&…

Python实现透明隧道爬虫ip:不影响现有网络结构

作为一名专业爬虫程序员&#xff0c;我们常常需要使用隧道代理来保护个人隐私和访问互联网资源。本文将分享如何使用Python实现透明隧道代理&#xff0c;以便在保护隐私的同时不影响现有网络结构。通过实际操作示例和专业的解析&#xff0c;我们将带您深入了解透明隧道代理的工…

物联网和不断发展的ITSM

物联网将改变社会&#xff0c;整个技术行业关于对机器连接都通过嵌入式传感器、软件和收集和交换数据的电子设备每天都在更新中。Gartner 预测&#xff0c;全球将有4亿台互联设备投入使用。 无论企业采用物联网的速度如何&#xff0c;连接设备都将成为新常态&#xff0c;IT服务…

Dubbo1-架构的演变

分布式系统上的相关概念 项目&#xff1a;传统项目、互联网项目 传统项目&#xff1a; 一般为公司内部使用&#xff0c;或者小群体小范围的使用&#xff0c;一般不要求性能&#xff0c;美观&#xff0c;并发等 互联网项目的特点&#xff1a; 1.用户多 2.流量大&#xff0c;并…

【CSS】透明背景的圆角渐变边框实现方案

css的渐变边框可以用下面方式实现 border-image: linear-gradient(rgb(89, 0, 255),pink) 30 30; css的圆角边框可以用下面方式实现 border-radius: 20px; 那想要实现一个圆角的渐变边框呢&#xff0c;可能会以为&#xff0c;两个都用上不就可以了&#xff0c;但事实是&…

JSON字符串转换

大家好 , 我是苏麟 , 今天带来一个JSON序列化库 Gson . GitHub 地址 : GitHub - google/gson: A Java serialization/deserialization library to convert Java Objects into JSON and back java 中 json 序列化库有很多&#xff1a; gson (谷歌的) fastjson (阿里的) jack…

Python——添加照片边框

原图&#xff1a; 添加边框后&#xff1a; 添加边框会读取照片的exif信息如时间、相机型号、品牌以及快门焦段等信息&#xff0c;将他们显示在下面的边框中。 获取当前py文件路径 import os #get path that py file located def Get_Currentpath():file_path os.path.abspa…

软考:中级软件设计师:文件管理,索引文件结构,树型文件结构,位示图,数据传输方式,微内核

软考&#xff1a;中级软件设计师: 提示&#xff1a;系列被面试官问的问题&#xff0c;我自己当时不会&#xff0c;所以下来自己复盘一下&#xff0c;认真学习和总结&#xff0c;以应对未来更多的可能性 关于互联网大厂的笔试面试&#xff0c;都是需要细心准备的 &#xff08;1…

sudo免密码设置以及设置失败解决方法

使用sudo visudo修改\etc\sudoers文件 打开后有很多已有的设置大致格式username ALL(ALL:ALL) ALL&#xff0c;都不要动&#xff01; 在文件结尾加上一句话&#xff1a; username ALL(ALL:ALL) NOPASSWD: ALLusername就是目前你这个账户的名字&#xff0c;开机时会输密码登录…

数据库内日期类型数据大于小于条件查找注意事项

只传date格式的日期取查datetime的字段的话默认是 00:00:00 日期类型字符串需要使用 ’ ’ 单引号括住 使用大于小于条件查询某一天的日期数据 前后判断条件不能是同一天 一个例子 数据库内数据&#xff1a; 查询2023-08-14之后的数据&#xff1a; select * from tetst…

互联网发展历程:从中继器口不够到集线器的引入

互联网的发展&#xff0c;就像一场不断演进的技术盛宴&#xff0c;每一步的变革都在推动着我们的世界向前。然而&#xff0c;在网络的早期&#xff0c;一项重要的技术问题曾困扰着人们&#xff1a;当中继器的接口数量不足时&#xff0c;如何连接更多的设备&#xff1f;这时&…

移动端预览指定链接的pdf文件流

场景 直接展示外部系统返回的获取文件流时出现了跨域问题&#xff1a; 解决办法 1. 外部系统返回的请求头中调整&#xff08;但是其他系统不会给你改的&#xff09; 2. 我们系统后台获取文件流并转为新的文件流提供给前端 /** 获取传入url文件流 */ GetMapping("/get…

【MySQL】MySQL不走索引的情况分析

未建立索引 当数据表没有设计相关索引时&#xff0c;查询会扫描全表。 create table test_temp (test_id int auto_incrementprimary key,field_1 varchar(20) null,field_2 varchar(20) null,field_3 bigint null,create_date date null );expl…

springboot整合kafka多数据源

整合kafka多数据源 项目背景依赖配置生产者消费者消息体 项目背景 在很多与第三方公司对接的时候&#xff0c;或者处在不同的网络环境下&#xff0c;比如在互联网和政务外网的分布部署服务的时候&#xff0c;我们需要对接多台kafka来达到我们的业务需求&#xff0c;那么当kafk…

读书笔记 |【项目思维与管理】➾ 项目成为一种生存方式

读书笔记 |【项目思维与管理】➾ 项目成为一种生存方式 一、理解项目固有的挑战二、项目对企业的价值三、知识型企业的经营逻辑四、做项目管理的推进者 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 项目无处不在&#xff0c;项目已经成为…