Shinobi视频监控平台

前言:环境配置真痛苦,docker度你不迷糊!

参考网站:https://hub.docker.com/r/migoller/shinobidocker

 

主机系统:ubuntu16.04

配置目的:利用Shinobi组建局域网监控平台

所需软件:docker、Shinobi、ffserver

 

1.Shinobi配置(docker)

1.1 docker一键pull镜像

docker pull migoller/shinobidocker

1.2 按照网站中的步骤完成以下部分,其余部分忽略

Dock the "microservice" Shinobi Docker image

  • 创建Shinobi目录[Path to Shinobi direcory]及其子目录:
mkdir -p [Path to Shinobi direcory]/config [Path to Shinobi direcory]/datadir [Path to Shinobi direcory]/videos
  •  Shinobi目录下创建一个文件docker-compose.yml,内容如下:
 version: '2'
 services:
   db:
     image: mariadb
     env_file:
       - MySQL.env
     volumes:
       - ./datadir:/var/lib/mysql
   shinobi:
     image: migoller/shinobidocker:microservice-debian
     env_file:
       - MySQL.env
       - Shinobi.env
     volumes:
       - /etc/localtime:/etc/localtime:ro
       - /etc/timezone:/etc/timezone:ro
       - ./config:/config
       - ./videos:/opt/shinobi/videos
       - /dev/shm/shinobiDockerTemp:/dev/shm/streams
     ports:
       - "8080:8080"
  • Shinobi目录下创建MySQL.env文件:
 MYSQL_USER=majesticflame
 MYSQL_PASSWORD=password
 MYSQL_HOST=db
 MYSQL_DATABASE=ccio
 MYSQL_ROOT_PASSWORD=blubsblawoot
 MYSQL_ROOT_USER=root
  • Shinobi目录下创建Shinobi.env文件:
 ADMIN_USER=admin@shinobi.video
 ADMIN_PASSWORD=admin
 CRON_KEY=b59b5c62-57d0-4cd1-b068-a55e5222786f
 PLUGINKEY_MOTION=49ad732d-1a4f-4931-8ab8-d74ff56dac57
 PLUGINKEY_OPENCV=6aa3487d-c613-457e-bba2-1deca10b7f5d
 PLUGINKEY_OPENALPR=SomeOpenALPRkeySoPeopleDontMessWithYourShinobi
 MOTION_HOST=localhost
 MOTION_PORT=8080
  • 后台启动Shinobi stack:(关闭可以用sudo docker-compose down)
sudo docker-compose up -d
  • 运行mariadb:(YourMariaDbContainerName可以随便写,但是后面步骤必须与其一致;Shinobi目录下新建一个文件夹[Path to your MariaDB server data files];[Your very strong MariaDB root password]可以随便写,但一定要记住。)
docker run -d --name [YourMariaDbContainerName] -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v [Path to your MariaDB server data files]:/var/lib/mysql    -e MYSQL_ROOT_PASSWORD=[Your very strong MariaDB root password] -p 3306:3306 mariadb
  • 运行Shinobi:(YourMariaDbContainerName与上一步相同)
docker run -d --link [YourMariaDbContainerName]:db -p 8080:8080 -e ADMIN_USER=admin@shinobi.video -e ADMIN_PASSWORD=admin -e MYSQL_USER=majesticflame -e MYSQL_PASSWORD=password -e MYSQL_HOST=db -e MYSQL_DATABASE=ccio -e MYSQL_ROOT_PASSWORD=[Your very strong MariaDB root password] -e MYSQL_ROOT_USER=[Your MariaDB root username]      -e CRON_KEY=b59b5c62-57d0-4cd1-b068-a55e5222786f -e PLUGINKEY_MOTION=49ad732d-1a4f-4931-8ab8-d74ff56dac57 -e PLUGINKEY_OPENCV=6aa3487d-c613-457e-bba2-1deca10b7f5d -e PLUGINKEY_OPENALPR=SomeOpenALPRkeySoPeopleDontMessWithYourShinobi -e MOTION_HOST=localhost      -e MOTION_PORT=8080 -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro      -v [Path to your Shinobi data files]/config:/config -v [Path to your Shinobi data files]/datadir:/var/lib/mysql -v [Path to your Shinobi data files]/videos:/opt/shinobi/videos -v /dev/shm/shinobiDockerTemp:/dev/shm/streams      migoller/shinobidocker:microservice-debian
  • 浏览器登录:(xxx.xxx.xxx.xxx就是主机IP地址)
Web Address : http://xxx.xxx.xxx.xxx:8080/super
Username : admin@shinobi.video
Password : admin
  • 创建自己的账户,以后可直接登录自己的账户:
http://xxx.xxx.xxx.xxx:8080/

2.流媒体推送usb摄像头

配置流媒体服务,ffmpeg将usb摄像头获取的图像信息推送至局域网中的流媒体服务器(ffserver),局域网中其他用户可用rtsp的方式获取usb摄像头的图像流。

对于ffmpeg的流媒体推送理解:https://blog.csdn.net/zouli415/article/details/79652749

ffserver和ffmpeg配置:https://blog.csdn.net/zong596568821xp/article/details/88540455

运行ffserver:

 sudo ffserver -f /etc/ffserver.conf

运行ffmpeg:

sudo ffmpeg -f v4l2 -i /dev/video0 -s 640x480 -r 24 -vcodec libx264 -an http://127.0.0.1:8090/feed1.ffm

Shinobi服务器查看:

填写rtsp地址,Full URL PathThe full Stream URL.

选择查看流类型:

3.流媒体推送IntelRealSenseD435

参考网站1:https://blog.csdn.net/dieju8330/article/details/85420584

参考网站2:https://github.com/lam2003/v4l2_webstream_server/tree/f64a1f9429c74a110c57f519ac8658057203ca14

吐槽一下:

  • 光是一个usb摄像头要实现流媒体服务推送rtsp流(C++编程),就已经很麻烦了。IntelRealSenseD435是3个摄像头,需要用到librealsense SDK,所以就更加难搞,只能学习网站给的程序,搞个野路子!!!
  • 网站1网站2虽然给出了代码,但是librealsense、x264、FFmpeg、live555、都需要自己编译,所以还是需要一定的编译基础的!

野路子思路:

  • 获取:运用opencv正常读取IntelRealSenseD435深度图像,并保存为一个临时图片temp.jpg;
  • 编码:用FFmpeg+x264实现对temp.jpg的编码,编码为H264数据流;
  • 传输:用live555实现rtsp流服务,传输编码的H264数据流。

调试内容:

Intel RealSense D435的深度图为16bit-depth,RGB图为8bit-depth。

同时,用Intel RealSense D435采集640*480大小的图像,深度图采用CV_16U格式,RGB图采用CV_8UC3格式。

/*深度图*/
Mat depth_image(Size(depth_w,depth_h),
                             CV_16U,(void*)depth_frame.get_data(),Mat::AUTO_STEP);
/*RGB图*/
Mat color_image(Size(color_w,color_h),
                             CV_8UC3,(void*)color_frame.get_data(),Mat::AUTO_STEP);

gdb调试时可以看到,深度图dims=2, rows=480, cols=640, step[0]=1280,step[1]=2,RGB图dims=2, rows=480, cols=640, step[0]=1920,step[1]=3。(step[0]是矩阵中一行元素的字节数;step[1]是矩阵中一个元素的字节数),即深度图每一个元素都占用了2个字节存储,RGB图每个元素都占用的3字节存储(分别存储各通道数据)。

C++: int Mat::depth() const
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of matrix types contains the following values:

CV_8U - 8-bit unsigned integers ( 0..255 )
CV_8S - 8-bit signed integers ( -128..127 )
CV_16U - 16-bit unsigned integers ( 0..65535 )
CV_16S - 16-bit signed integers ( -32768..32767 )
CV_32S - 32-bit signed integers ( -2147483648..2147483647 )
CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )
CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值