網頁顯示攝像頭數據的方法---基于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.pswp.cn/news/39633.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/39633.shtml
英文地址,請注明出處:http://en.pswp.cn/news/39633.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Ubuntu20 ctrl+alt+T無法打開終端

事情是這樣的&#xff0c;某天改了下python版本&#xff0c;發現linux默認打開終端的快捷鍵ctrlaltT寄了&#xff0c;網上給出的都是修改快捷鍵不出意外肯定沒用 但是幸好我們是會分析的&#xff0c;我看到&#xff0c;很多回答說新增一個快捷鍵運行的命令是gnome-terminal&…

21、stm32使用LTDC驅動LCD

注&#xff1a;本文基于stm32使用FMC驅動SDRAM(IS42S32800G-6BLI)工程繼續開發 本例使用安富萊的H743XIH板子驅動LTDC點亮7寸LCD 硬件接線&#xff1a;RGB888 一、cubemx配置 1、LTDC配置 注意此引腳應于上面的硬件接線圖一致 2、配置DMA2D 3、背光引腳和觸摸引腳 4、時鐘…

在 IntelliJ IDEA 中使用 Docker 開發指南

目錄 一、IDEA安裝Docker插件 二、IDEA連接Docker 1、Docker for Windows 連接 2、SSH 連接 3、Connection successful 連接成功 三、查看Docker面板 四、使用插件生成鏡像 一、IDEA安裝Docker插件 打開 IntelliJ IDEA&#xff0c;點擊菜單欄中的 "File" -&g…

LeetCode 778. Swim in Rising Water【最小瓶頸路;二分+BFS或DFS;計數排序+并查集;最小生成樹】2096

本文屬于「征服LeetCode」系列文章之一&#xff0c;這一系列正式開始于2021/08/12。由于LeetCode上部分題目有鎖&#xff0c;本系列將至少持續到刷完所有無鎖題之日為止&#xff1b;由于LeetCode還在不斷地創建新題&#xff0c;本系列的終止日期可能是永遠。在這一系列刷題文章…

cs231n assignment 3 Q2 Image Captioning with Vanilla RNNs

文章目錄 嫌啰嗦直接看代碼Q2 Image Captioning with Vanilla RNNs一個給的工具代碼里的bug問題展示問題解決思路解決辦法 rnn_step_forward題面解析代碼輸出 rnn_step_backward題面解析代碼輸出 rnn_forward題面解析代碼輸出 rnn_backward題面解析代碼輸出 word_embedding_for…

使用 BERT 進行文本分類 (02/3)

? 一、說明 在使用BERT&#xff08;1&#xff09;進行文本分類中&#xff0c;我向您展示了一個BERT如何標記文本的示例。在下面的文章中&#xff0c;讓我們更深入地研究是否可以使用 BERT 來預測文本是使用 PyTorch 傳達積極還是消極的情緒。首先&#xff0c;我們需要準備數據…

3.1 Qt樣式選擇器

本期內容 3.1 樣式選擇器 3.1.1 Universal Selector (通用選擇器) 3.1.2 Type Selector (類型選擇器) 3.1.3 Property Selector (屬性選擇器) 3.1.4 Class Selector (類選擇器) 3.1.5 ID Selector (ID選擇器) 3.1.6 Descendant Selector (后裔選擇器) 3.1.7 Chil…

前端跨域的原因以及解決方案(vue),一文讓你真正理解跨域

跨域這個問題,可以說是前端的必需了解的,但是多少人是知其然不知所以然呢&#xff1f; 下面我們來梳理一下vue解決跨域的思路。 什么情況會跨域&#xff1f; ? 跨域的本質就是瀏覽器基于同源策略的一種安全手段。所謂同源就是必須有以下三個相同點&#xff1a;協議相同、域名…

WinCC V7.5 中的C腳本對話框不可見,將編輯窗口移動到可見區域的具體方法

WinCC V7.5 中的C腳本對話框不可見&#xff0c;將編輯窗口移動到可見區域的具體方法 由于 Windows 系統更新或使用不同的顯示器&#xff0c;在配置C動作時&#xff0c;有可能會出現C腳本編輯窗口被移動到不可見區域的現象。 由于該窗口無法被關閉&#xff0c;故無法進行進一步…

KafkaStream:Springboot中集成

1、在kafka-demo中創建配置類 配置kafka參數 package com.heima.kafkademo.config;import lombok.Data; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.StreamsConfig; import org.springframework.boot.context.properties.Configu…

8月11日上課內容 nginx的多實例和動靜分離

多實例部署 在一臺服務器上有多個tomcat的服務。 配置多實例之前&#xff0c;看單個實例是否訪問正常。 1.安裝好 jdk 2.安裝 tomcat cd /opt tar zxvf apache-tomcat-9.0.16.tar.gz mkdir /usr/local/tomcat mv apache-tomcat-9.0.16 /usr/local/tomcat/tomcat1 cp -a /u…

Linux系統管理:虛擬機ESXi安裝

目錄 一、理論 1.VMware Workstation 2.VMware vSphere Client 3.ESXi 二、實驗 1.ESXi 7安裝 一、理論 1.VMware Workstation 它是一款專業的虛擬機軟件&#xff0c;可以在一臺物理機上運行多個操作系統&#xff0c;支持Windows、Linux等操作系統&#xff0c;可以模擬…

使用selenium如何實現自動登錄

回顧使用requests如何實現自動登錄一文中&#xff0c;提到好多網站在我們登錄過后&#xff0c;在之后的某段時間內訪問該網頁時&#xff0c;不會給出請登錄的提示&#xff0c;時間到期后就會提示請登錄&#xff01;這樣在使用爬蟲訪問網頁時還要登錄&#xff0c;打亂我們的節奏…

item_get_sales-獲取商品銷量詳情

一、接口參數說明&#xff1a; item_get_sales-獲取商品銷量詳情&#xff0c;點擊更多API調試&#xff0c;請移步注冊API賬號點擊獲取測試key和secret 公共參數 請求地址: https://api-gw.onebound.cn/taobao/item_get_sales 名稱類型必須描述keyString是調用key&#xff08…

ACM模式刷Leetcode題目

139題單詞拆分 鏈接: link #include<iostream> #include<sstream> #include<string> #include<vector> #include<algorithm> #include<unordered_set> using namespace std;int main() {// 實現輸入第一行為s字符串。// 第二行為wordDic…

【代碼隨想錄day22】爬樓梯

題目 假設你正在爬樓梯。需要 n 階你才能到達樓頂。 每次你可以爬 1 或 2 個臺階。你有多少種不同的方法可以爬到樓頂呢&#xff1f; 示例 1&#xff1a; 輸入&#xff1a;n 2 輸出&#xff1a;2 解釋&#xff1a;有兩種方法可以爬到樓頂。 1. 1 階 1 階 2. 2 階 示例 2…

Spring的三種異常處理方式

1.SpringMVC 異常的處理流程 異常分為編譯時異常和運行時異常&#xff0c;編譯時異常我們 try-cache 進行捕獲&#xff0c;捕獲后自行處理&#xff0c;而運行時異常是不 可預期的&#xff0c;就需要規范編碼來避免&#xff0c;在SpringMVC 中&#xff0c;不管是編譯異常還是運行…

java:JDBC

文章目錄 什么是JDBCJDBC使用步驟詳解各個對象DriverManagerConnectionStatementResultSetPreparedStatement JDBC控制事務操作步驟示例 什么是JDBC 我們知道&#xff0c;數據庫有很多種&#xff0c;比如 mysql&#xff0c;Oracle&#xff0c;DB2等等&#xff0c;如果每一種數…

C# WPF 中 外部圖標引入iconfont,無法正常顯示問題 【小白記錄】

wpf iconfont 外部圖標引入&#xff0c;無法正常顯示問題。 1. 檢查資源路徑和引入格式是否正確2. 檢查資源是否包含在程序集中 1. 檢查資源路徑和引入格式是否正確 正確的格式&#xff0c;注意字體文件 “xxxx.ttf” 應寫為 “#xxxx” <TextBlock Text"&#xe7ae;…

不重啟Docker能添加自簽SSL證書鏡像倉庫嗎?

應用背景 在企業應用Docker規劃初期配置非安全鏡像倉庫時&#xff0c;有時會遺漏一些倉庫沒配置&#xff0c;但此時應用程序已經在Docker平臺上部署起來了&#xff0c;體量越大就越不會讓人去直接重啟Docker。 那么&#xff0c;不重啟Docker能添加自簽SSL證書鏡像倉庫嗎&…