Coder Social home page Coder Social logo

telegram-surveillance-bot's Introduction

Surveillance Bot

Build status Coverage PyPI - Python Version License

Surveillance Bot is a Telegram bot that uses a camera (such a webcam) for surveillance. Photos and videos can be taken from the camera and sent via Telegram instantly. Those actions can be triggered by commands sent by the user or when motion is detected.

All files in this project are covered under the GPLv3 LICENSE, if you modify this project in any way you MUST publish the changes you made and submit your contribution to the community under the same license.

Features

  • Motion detection.
  • Real time notification.
  • Motion tracking.
  • Photo and video capture on demand.
  • Bot configuration via telegram chat.
  • Timestamp in photos and videos.
  • H264 video encoding (when codec is available).
  • Multi-platform: Linux, Windows and MacOS.
  • Dockerized.

Requirements

  • python (supported versions: 3.6, 3.7, 3.8 and 3.9)
  • OpenCV
  • python-telegram-bot

Quick-start

  1. Install package with pip:

    pip install surveillance-bot
    
  2. Set application configuration variables (see Advanced configuration):

    export BOT_API_TOKEN=<api_token>
    export AUTHORIZED_USER=<username>
    
  3. Run script:

    surveillance_bot
    

Advanced configuration

The application is configured using this environment variables:
  • BOT_API_TOKEN (mandatory)

    The Telegram bot API token of a telegram bot.

  • AUTHORIZED_USER (mandatory)

    The Telegram username (without @) of the user authorized to interact with the bot.

  • PERSISTENCE_DIR

    If this variable is set the bot configuration (set via telegram chat) will persist on disk into a file placed in this directory.

  • LOG_LEVEL

    Global log level for application and libraries using the python standard logging library.

  • BOT_LOG_LEVEL

    Specific Bot application log level.

H264 Encoding

This application generates MP4 video files, if H264 codec is available it will use it to generate smaller files.

The OpenCV library provided by the PyPi package (installed with pip) doesn't have H264 support so if you wish to use H264 encoding you have to do a manual build or use a precompiled library with H264 support (some distributions, like Ubuntu, have OpenCV library supporting this codec).

Docker

Dockerfile

A Surveillance Bot docker image can be created, using the Dockerfile provided, running this command:

docker build -t telegram-surveillance-bot .

This docker image has H264 support. The image will be created with UTC timezone by default (so photo and video timestamp will use this timezone) it can be overridden mounting /etc/localtime file (see docker-compose.yml example).

docker-compose

A docker-compose example file is also provided, you must previously export the required configuration variables or modify this docker-compose template.

Screenshots

Start command

Start command

Config command

Config command

Surveillance sequence screencast

Surveillance sequence

Video taken in surveillance mode

Motion video

telegram-surveillance-bot's People

Contributors

pchinea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

telegram-surveillance-bot's Issues

Customize resolution /frame size/ codecs...

Hello.. Thanks for this project, it simply works! Just one question..is it possible to choose the resolution of the saved pictures or videos? Nowadays cameras are supporting different resolutions/frame size/codecs.. It would be great the possibility to choose between them. I don't need something "interactive" via bot commands, but some way to specify the resolution inside the camera.py section. Thank you all in advance!

opencv error ? need help

Hi there!
i have installed this interesting piece of sw but this is the error i get - it does not work - there must be something which i forgot to install or something.... any help appreciated.

[ERROR:[email protected]] global /io/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2767) open Could not find encoder for codec_id=27, error: Encoder not found
[ERROR:[email protected]] global /io/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2839) open VIDEOIO/FFMPEG: Failed to initialize VideoWriter

My system is: Linux abcd 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux

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.