prettyprint

2021年8月18日 星期三

Integrate Raspberry Pi, ESP32-CAM , ONVIF compliant cameras and Shinobi Software to build a Video Surveillance System

 實驗目標:

  1. 以Raspberry Pi 3B+架設NVR系統,使用Shinobi free, open source software。
  2. ESP32-CAM串流輸出MPEG video到NVR,儲存在硬碟中。
  3. 使用D-Link DCS-8300LHV2 Wi-Fi ONVIF camera儲存影音到NVR。
  4. 連續錄影與移動偵測錄影。


一、NVR系統架設步驟:
    使用raspberry Pi 3B+板子,使用外接USB硬碟為儲存設備。
  • 下載Raspberry Pi Imager,執行安裝Raspberry Pi OS。
選擇安裝Rapberry Pi OS Lite(32 bit),Write to SD card

  • 設定Rapberry Pi:
    1. 啟用SSH:
      sudo raspi-config
      Interface Options
      SSH


    2. 設定固定IP:
      $ sudo nano /etc/dhcpcd.conf

      #static ip_address=192.168.1.23/24
      #static routers=192.168.1.1
      #static domain_name_servers=192.168.1.1
      取消註解,並更改你要的 IP address

    3. 安裝Shinobi:
      $ sudo wget https://gitlab.com/Shinobi-Systems/Shinobi-Installer/raw/master/shinobi-install.sh
      $ sudo chmod +x shinobi-install.sh
      $ sudo ./shinobi-install.sh

      Install the Development branch?
      (y)es or (N)o? Default : No

      Select your OS
      If your OS is not on the list please refer to the docs.
      ========
      1. Ubuntu - Fast and Touchless
      2. Ubuntu - Advanced
      3. CentOS
      4. CentOS - Quick Install
      5. MacOS
      6. FreeBSD
      7. OpenSUSE
      ========
      1

      Shinobi - Do you want to temporarily disable IPv6?
      Sometimes IPv6 causes Ubuntu package updates to fail. Only do this if your machine doesn't rely on IPv6.
      (y)es or (N)o
      N

       Use `pm2 show <id|name>` to get more details about an app
      =====================================
      ||=====   Install Completed   =====||
      =====================================
      || Login with the Superuser and create a new user!!
      ||===================================
      || Open http://192.168.1.23:8080/super in your web browser.
      ||===================================
      || Default Superuser : admin@shinobi.video
      || Default Password : admin
      =====================================


      以上列網址與帳號密碼建立一個使用者後,開啟http://192.168.1.23:8080,以新建使用者開啟管理NVR介面

    4. 設定連接USB HDD:
      Raspberry Pi NVR外接1TB USB HDD採用NTFS檔案系統儲存攝影機影像。
      a: 安裝Raspberry Pi NTFS software
      $ sudo apt install ntfs-3g

      b:列出外接USB HDD block device id,以便後續掛載Device
      $ sudo blkid

      /dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5DE4-665C" TYPE="vfat" PARTUUID="347dad1e-01"
      /dev/mmcblk0p2: LABEL="rootfs" UUID="7295bbc3-bbc2-4267-9fa0-099e10ef5bf0" TYPE="ext4" PARTUUID="347dad1e-02"
      /dev/sda1: LABEL="TOSHIBA EXT" UUID="BA96216F96212CF7" TYPE="ntfs" PTTYPE="atari" PARTUUID="0f80c3ad-01"
      /dev/mmcblk0: PTUUID="347dad1e" PTTYPE="dos"

      c: mount USB HDD
      # create mount point
      $ sudo mkdir /mnt/nvr

      #check shinobi running by which user
      $ ps -aux | grep shinobi
      pi        3548  0.0  0.0   7348   552 pts/0    S+   02:33   0:00 grep --color=auto shinobi

      # mount device
      $ sudo mount -t ntfs-3g -o uid=pi,gid=root,umask=007 /dev/sda1 /mnt/nvr

      #add the information need to mount the disk in fstab
      $ sudo nano /etc/fstab
      UUID=BA96216F96212CF7   /mnt/nvr        ntfs-3g uid=pi,gid=root,umask=007     0      0

      #add two directories esp32 and dcs8300 to store vedios
      $sudo mkdir /mnt/nvr/esp32
      $sudo mkdir /mnt/nvr/dcs8300 

      ##login in shinobi super to add additional storages: esp32 and dcs8300,步驟請參閱文章最後影片展示。

      安裝成功後,Shinobi 開啟畫面。

二、ESP32-CAM 攝影鏡頭設定:
  • 開啟Arduino IDE,選擇開發版。
    工具 >> ESP32 Arduino  >> ESP32 Wrove Module


  • 開啟範例檔:
    檔案 >> 範例 >> ESP32 >> Camera >> CameraWebServer

    註解//#define CAMERA_MODEL_WROVER_KIT
    取消註解 #define CAMERA_MODEL_AI_THINKER
    填入Wi-Fi SSID and Password
    const char* ssid = "your-ssid";
    const char* password = "your-passwd";

    連接FTDI(USB-TTL)上傳範例程式
    FTDI      ESP32-CAM 
    GND       GND
    VCC       5V
    TX          UOR(IO3)
    RX          UOT(IO1)
    上傳程式時IO0 接GND,上傳後拔除後按reset鍵即開始執行ESP32-CAM,Stream server Port為81,連接shinobi NVR時使用stream port。

    測試web server,成功取得畫面


     

三、Shinobi 加入 ESP32-CAM與ONVIF compliant camera device
.加入 ESP32-CAM



.加入使用D-Link DCS-8300LHV2 Wi-Fi IP Camera測試。
下載mydlink APP 完成設定後,由Shinobi ONVIF search 設備即可加入,詳細步驟請參閱文章最後影片







詳細安裝步驟影片:


沒有留言:

張貼留言