Skip to main content

Basic video surveillance system controlled through a telegram bot.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surveillance_bot-1.1.1.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

surveillance_bot-1.1.1-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file surveillance_bot-1.1.1.tar.gz.

File metadata

  • Download URL: surveillance_bot-1.1.1.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for surveillance_bot-1.1.1.tar.gz
Algorithm Hash digest
SHA256 1354ae359c3060f090bd42babc070c60ad82ccb0784d2f94ff02ce74c80f6704
MD5 33fdb3edcd973c3373cc82dd844759b6
BLAKE2b-256 920bb1caec88d16a144fb4edb2e7f6ac1d30df378f0e913231ab43d19e37f850

See more details on using hashes here.

File details

Details for the file surveillance_bot-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: surveillance_bot-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for surveillance_bot-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b0734fbeb4a87373881c40a759b3ffa80e91a1542b87194ffd6e7ff49ddd6ef
MD5 bb73da38ef34239cdef08fcdf06f1d75
BLAKE2b-256 1f5d9ce24c71ae3578922ca7d45cb88487cb5ad2f0673c818150423408184e6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page