RSTP网页摄像头Demo

这篇主要介绍如何在Ubuntu20.04上通过RSTP流使用摄像头。

安装依赖

Demo主要使用了opencv以及flask框架。

  1. 安装opencv
khadas@Khadas:~$ sudo apt install libopencv-dev python3-opencv
  1. 安装flask
khadas@Khadas:~$ sudo apt install python3-pip
khadas@Khadas:~$ pip3 instal flask

运行Demo

  1. Clone代码
khadas@Khadas:~$ git clone git@github.com:yan-wyb/rtsp-web-appliation.git
  1. 确认摄像头节点。

插入摄像头前,

khadas@Khadas:~$ ls /dev/video*
/dev/video0  /dev/video10  /dev/video11  /dev/video12  /dev/video13  /dev/videosync

插入摄像头后,

khadas@Khadas:~$ ls /dev/video*
/dev/video0  /dev/video1  /dev/video10  /dev/video11  /dev/video12  /dev/video13  /dev/videosync

确认摄像头节点为/dev/video1

  1. 运行Demo
khadas@Khadas:~$ cd rtsp-web-appliation/
khadas@Khadas:~/rtsp-web-appliation$ python3 rtsp.py --device 1
 * Serving Flask app 'rtsp' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 707-481-604

打开链接就能看到Demo的效果

rtsp-camera.png