Make a surveillance camera from your raspberry pi!

Overview

rpi-surveillance

Make a surveillance camera from your Raspberry Pi 4!

The surveillance is built as following: the camera records 10 seconds video and if a motion was detected - sends the video to telegram channel.

The timestamp is printed on videos, so it is better to set the correct time on your Raspberry Pi.

The motion detection works in the following way: the camera’s H.264 encoder calculates motion vector estimates while generating compressed video. Using these vectors we threshold them by --magnitude-th argument. If more than --vectors-quorum vectors thresholded - mark current frame as containing motion. If there are more than --detection-frames consecutive frames with motion - motion detected.

Tested on Raspberry Pi 4 (4 RAM) + NoIR Camera V2.

Installation

Install package

Install Python 3 requirements:

pip3 install --user -r requirements.txt

Install provided .deb package:

sudo dpkg -i <path/to/downloaded/rpi-surveillance.deb>
sudo apt install -f

Note: the installation supposes that you already enabled camera module on your Raspberry Pi.

Create telegram bot and chat

  1. Write to @BotFather in telegram and create a bot:
/start
/newbot
<name of your bot>
<username of your bot>_bot

You will get the TOKEN. Save it for future use.

  1. Create a private channel where you will receive video sequences with motion.
  2. Add created bot to the channel (rerquires only "post messages" permission).
  3. Send message test to the channel.
  4. Run /usr/lib/rpi-surveillance/get_channel_id to get the CHANNEL_ID. Save it for future use.

Usage

To launch surveillance just run rpi-surveillance with your TOKEN and CHANNEL_ID, for example:

rpi-surveillance --token 1259140266:WAaqkMycra87ECzRZwa6Z_8T9KB4N-8OPI --channel-id -1003209177928

You can set various parameters of the surveillance:

usage: rpi-surveillance [-h] [--config CONFIG] --token TOKEN --channel-id
                        CHANNEL_ID [--temp-dir TEMP_DIR] [--log-file LOG_FILE]
                        [--resolution {640x480,1280x720,1920x1080}]
                        [--fps {25,30,60}] [--rotation {0,90,180,270}]
                        [--duration DURATION] [--magnitude-th MAGNITUDE_TH]
                        [--vectors-quorum VECTORS_QUORUM]
                        [--detection-frames DETECTION_FRAMES]

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG       Path to config file.
  --token TOKEN         Token for your telegram bot.
  --channel-id CHANNEL_ID
                        Telegram channel ID. If you don't have it please, send
                        a message to your channel and run /usr/lib/rpi-
                        surveillance/get_channel_id with your token.
  --temp-dir TEMP_DIR   Path to temporary directory for video saving before
                        sending to channel. Don't change it if you don't know
                        what you're doing.
  --log-file LOG_FILE   Path to log file for logging.
  --resolution {640x480,1280x720,1920x1080}
                        Camera resolution. Default - 640x480.
  --fps {25,30,60}      Frames per second. Default - 25.
  --rotation {0,90,180,270}
                        Frame rotation. Default - 0.
  --duration DURATION   Duration of videos in seconds. Default - 10.
  --magnitude-th MAGNITUDE_TH
                        Magnitude threshold for motion detection (lower - more
                        sensitive). Defaults: for 640x480 - 15, for 1280x720 -
                        40, for 1920x1080 - 65.
  --vectors-quorum VECTORS_QUORUM
                        Vectors quorum for motion detection (lower - more
                        sensitive). Defaults: for 640x480 - 10, for 1280x720 -
                        20, for 1920x1080 - 40.
  --detection-frames DETECTION_FRAMES
                        The number of consecutive frames with detected motion
                        to send an alert.

Build

Build was done using dpkg-buildpackage.

You might also like...
Make your master artistic punk avatar through machine learning world famous paintings.
Make your master artistic punk avatar through machine learning world famous paintings.

Master-art-punk Make your master artistic punk avatar through machine learning world famous paintings. 通过机器学习世界名画制作属于你的大师级艺术朋克头像 Nowadays, NFT is beco

Python-experiments - A Repository which contains python scripts to automate things and make your life easier with python
Python-experiments - A Repository which contains python scripts to automate things and make your life easier with python

Python Experiments A Repository which contains python scripts to automate things

A very lightweight monitoring system for Raspberry Pi clusters running Kubernetes.
A very lightweight monitoring system for Raspberry Pi clusters running Kubernetes.

OMNI A very lightweight monitoring system for Raspberry Pi clusters running Kubernetes. Why? When I finished my Kubernetes cluster using a few Raspber

Run object detection model on the Raspberry Pi

Using TensorFlow Lite with Python is great for embedded devices based on Linux, such as Raspberry Pi.

 Tutorial to set up TensorFlow Object Detection API on the Raspberry Pi
Tutorial to set up TensorFlow Object Detection API on the Raspberry Pi

A tutorial showing how to set up TensorFlow's Object Detection API on the Raspberry Pi

An air quality monitoring service with a Raspberry Pi and a SDS011 sensor.

Raspberry Pi Air Quality Monitor A simple air quality monitoring service for the Raspberry Pi. Installation Clone the repository and run the following

A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!
A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!

A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!

🍅🍅🍅YOLOv5-Lite: lighter, faster and easier to deploy. Evolved from yolov5 and the size of model is only 1.7M (int8) and 3.3M (fp16). It can reach 10+ FPS on the Raspberry Pi 4B when the input size is 320×320~
🍅🍅🍅YOLOv5-Lite: lighter, faster and easier to deploy. Evolved from yolov5 and the size of model is only 1.7M (int8) and 3.3M (fp16). It can reach 10+ FPS on the Raspberry Pi 4B when the input size is 320×320~

YOLOv5-Lite:lighter, faster and easier to deploy Perform a series of ablation experiments on yolov5 to make it lighter (smaller Flops, lower memory, a

A facial recognition doorbell system using a Raspberry Pi

Facial Recognition Doorbell This project expands on the person-detecting doorbell system to allow it to identify faces, and announce names accordingly

Releases(v2.2.2)
Owner
Vladyslav
Machine learning and computer vision developer.
Vladyslav
SatelliteSfM - A library for solving the satellite structure from motion problem

Satellite Structure from Motion Maintained by Kai Zhang. Overview This is a libr

Kai Zhang 190 Dec 08, 2022
[ICLR'21] Counterfactual Generative Networks

This repository contains the code for the ICLR 2021 paper "Counterfactual Generative Networks" by Axel Sauer and Andreas Geiger. If you want to take the CGN for a spin and generate counterfactual ima

88 Jan 02, 2023
Code for "Primitive Representation Learning for Scene Text Recognition" (CVPR 2021)

Primitive Representation Learning Network (PREN) This repository contains the code for our paper accepted by CVPR 2021 Primitive Representation Learni

Ruijie Yan 76 Jan 02, 2023
PyTorch implementation of paper: HPNet: Deep Primitive Segmentation Using Hybrid Representations.

HPNet This repository contains the PyTorch implementation of paper: HPNet: Deep Primitive Segmentation Using Hybrid Representations. Installation The

Siming Yan 42 Dec 07, 2022
Causal estimators for use with WhyNot

WhyNot Estimators A collection of causal inference estimators implemented in Python and R to pair with the Python causal inference library whynot. For

ZYKLS 8 Apr 06, 2022
[ICME 2021 Oral] CORE-Text: Improving Scene Text Detection with Contrastive Relational Reasoning

CORE-Text: Improving Scene Text Detection with Contrastive Relational Reasoning This repository is the official PyTorch implementation of CORE-Text, a

Jingyang Lin 18 Aug 11, 2022
Code in conjunction with the publication 'Contrastive Representation Learning for Hand Shape Estimation'

HanCo Dataset & Contrastive Representation Learning for Hand Shape Estimation Code in conjunction with the publication: Contrastive Representation Lea

Computer Vision Group, Albert-Ludwigs-Universität Freiburg 38 Dec 13, 2022
Supporting code for the paper "Dangers of Bayesian Model Averaging under Covariate Shift"

Dangers of Bayesian Model Averaging under Covariate Shift This repository contains the code to reproduce the experiments in the paper Dangers of Bayes

Pavel Izmailov 25 Sep 21, 2022
UMEC: Unified Model and Embedding Compression for Efficient Recommendation Systems

[ICLR 2021] "UMEC: Unified Model and Embedding Compression for Efficient Recommendation Systems" by Jiayi Shen, Haotao Wang*, Shupeng Gui*, Jianchao Tan, Zhangyang Wang, and Ji Liu

VITA 39 Dec 03, 2022
Kaggle Lyft Motion Prediction for Autonomous Vehicles 4th place solution

Lyft Motion Prediction for Autonomous Vehicles Code for the 4th place solution of Lyft Motion Prediction for Autonomous Vehicles on Kaggle. Discussion

44 Jun 27, 2022
Fully Convolutional DenseNets for semantic segmentation.

Introduction This repo contains the code to train and evaluate FC-DenseNets as described in The One Hundred Layers Tiramisu: Fully Convolutional Dense

485 Nov 26, 2022
This is the official implementation for the paper "(Almost) Free Incentivized Exploration from Decentralized Learning Agents" in NeurIPS 2021.

Observe then Incentivize Experiments This is the code used for the paper "(Almost) Free Incentivized Exploration from Decentralized Learning Agents",

Cong Shen Research Group 0 Mar 08, 2022
Convert ONNX model graph to Keras model format.

Convert ONNX model graph to Keras model format.

Grigory Malivenko 175 Dec 28, 2022
Principled Detection of Out-of-Distribution Examples in Neural Networks

ODIN: Out-of-Distribution Detector for Neural Networks This is a PyTorch implementation for detecting out-of-distribution examples in neural networks.

189 Nov 29, 2022
This is the implementation of our work Deep Extreme Cut (DEXTR), for object segmentation from extreme points.

This is the implementation of our work Deep Extreme Cut (DEXTR), for object segmentation from extreme points.

Sergi Caelles 828 Jan 05, 2023
Official repository of "Investigating Tradeoffs in Real-World Video Super-Resolution"

RealBasicVSR [Paper] This is the official repository of "Investigating Tradeoffs in Real-World Video Super-Resolution, arXiv". This repository contain

Kelvin C.K. Chan 566 Dec 28, 2022
Code for T-Few from "Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning"

T-Few This repository contains the official code for the paper: "Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learni

220 Dec 31, 2022
Official code for "Mean Shift for Self-Supervised Learning"

MSF Official code for "Mean Shift for Self-Supervised Learning" Requirements Python = 3.7.6 PyTorch = 1.4 torchvision = 0.5.0 faiss-gpu = 1.6.1 In

UMBC Vision 44 Nov 21, 2022
A human-readable PyTorch implementation of "Self-attention Does Not Need O(n^2) Memory"

memory_efficient_attention.pytorch A human-readable PyTorch implementation of "Self-attention Does Not Need O(n^2) Memory" (Rabe&Staats'21). def effic

Ryuichiro Hataya 7 Dec 26, 2022
Implementing a simplified copy of Shazam application from scratch using MinHashing and LSH.

Building Shazam from scratch In this repository we tried to implement a simplified copy of the Shazam application able to tell you the name of a song

Arturo Ghinassi 0 Nov 17, 2022