Giter VIP home page Giter VIP logo

project-defender's Introduction

Defender

opencv raspberry-pi os: linux python: 3.6+ python style: google imports: isort code style: black code style: pycodestyle doc style: pydocstyle static typing: mypy linting: pylint testing: pytest security: bandit license: Apache 2.0 maintenance: inactive

Note: This project is no longer actively maintained. No support is provided for bugfixes, security updates, etc. It was originally started as a hobby, and built around Python versions 3.4-3.6, and original Angular. It has many examples for processing images, video, audio, HTTP requests, web apps, etc., although likely out of date. The project also contains a good baseline for code quality standards on new projects, so it remains available for referencing.

Defender is a Python and Javascript based Web Application/Rest API to manage streaming of audio and video from security cameras, and other devices, in a local network.

Security is currently achieved through a combination of HTTPS certificates, and a salted User/Password database with PBKDF2 SHA512 combo.

For simplicity and greater compatibility with low-end devices, video is streamed as MJPEG, and audio is streamed as WAV (meaning bandwidth usage is not optimized). Streams can be saved using separate applications with support for HTTP, such as FFMPEG, VLC, etc.

This application supports Video streaming through OpenCV:
http://opencv.org/

And audio through PyAudio:
https://pypi.python.org/pypi/PyAudio

Requirements

  • Python3.6+
  • System with video and/or audio capture device

Recommendations

  • Raspberry Pi 3 or equivalent hardware
  • Webcam with builtin microphone. Tested on Logitech C210.

Quick Start

  1. Setup OpenCV and Python environment with:
    How to set up Raspberry Pi

  2. Copy frontend demo data to local folder:

    cp -R defender/demodata ~/.defender
    cp -R defender/html ~/.defender
    
  3. Update the configuration file with values to match your environment and devices' capabilities:

    defender/scripts/defend.py --list-devices
    v4l2-ctl --list-devices
    vi ~/.defender/config.json
    
  4. Generate new custom HTTPS certificate:

    openssl req -newkey rsa:4096 -nodes -keyout ~/.defender/key.pem -x509 -days 365 -out ~/.defender/server.pem
    
  5. If setup for 'virtualenv' per Step 1, ensure you are working on that project:

    workon opencv
    
  6. Start server with:

    defender/scripts/defend.py -c ~/.defender/config.json
    
  7. Add a user and password to the database:

    # Skip add to use default:default
    user add <new user name>
    
    # If new user was added, remove default:
    user remove default
    
  8. Attempt to load the video stream in a browser by going to:

    https://<hostname or ip>:<port>/video
    

Known Limitations

  • For some reason HTTP traffic appears to fail loading page/serving API calls, until reason is determined HTTPS should always be used. Well, HTTPS should always be used.
  • Multiple concurrent connections to audio streams may overflow buffer and degrade playback.
  • Password hashing can lead to slowdown with the initial load of the provided HTML frontend unless the JS scripts are minified into one.

What does the future hold?

Note: This project is no longer actively maintained. No support is provided for bugfixes, security updates, etc. It was originally started as a hobby, and built around Python versions 3.4-3.6, and original Angular. It has many examples for processing images, video, audio, HTTP requests, web apps, etc., although likely out of date. The project also contains a good baseline for code quality standards on new projects, so it remains available for referencing.

  • Multiple streams per device.
  • Motion tracking.
  • Audio Playback (two way communication).
  • Support for controlling remote motorized devices, such as nerf turret cameras, drones, etc.
  • Builtin A/V recording through application, instead of with 3rd party applications (FFMPEG/VLC).
  • Possibly additional compression formats for A/V streams.
  • Migrate HTTP interfaces to Flask/FastAPI.
  • Implement API sessions to increase authorization speed on lower end devices.

project-defender's People

Contributors

dfrtz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.