ViGi: A camera surveillance system
Features
- Multiple camera support
- Motion detection
- Object recognition
- Web server to view the camera feed and recordings
- Notifications via SMS and email
Requirements
- Python 3.8 or higher. Tested with Python 3.12
- OpenCV
- A USB camera that can be accessed via OpenCV
Installation and usage
pip install vigi
vigi
Configuration
A detailed configuration options are available in the Configuration document.
The agent can be configured in two ways:
- Using the
vigi.inifile. This method is recommended for production use and when configuration is constant and does not change frequently. - Using command line arguments. This method is recommended for development and testing purposes:
usage: vigi [-h] [--debug] [--no-monitor] [--data-dir DATA_DIR] [--camera-id CAMERA_ID] [--host HOST] [--port PORT] [--max-errors MAX_ERRORS]
[--sensitivity SENSITIVITY] [--detection-model-file DETECTION_MODEL_FILE] [--disable-detection] [--inference-device INFERENCE_DEVICE]
[--http-basic-username HTTP_BASIC_USERNAME] [--http-basic-password HTTP_BASIC_PASSWORD] [--http-basic-hash HTTP_BASIC_HASH]
optional arguments:
-h, --help show this help message and exit
--debug Enable debug mode
--no-monitor Disable the camera monitor
--data-dir DATA_DIR Directory to store the recordings
--camera-id CAMERA_ID
Camera ID to monitor
--host HOST Host to run the web server
--port PORT Port to run the web server
--max-errors MAX_ERRORS
Maximum number of consecutive errors when reading a frame from the camera
--sensitivity SENSITIVITY
Sensitivity of the motion detector, should be a float between 0 and 1
--detection-model-file DETECTION_MODEL_FILE
Path to the detection model file (YOLO's yolov8n.pt, by default)
--disable-detection Disable object detection
--inference-device INFERENCE_DEVICE
Inference device for object detection (cpu or cuda)
--http-basic-username HTTP_BASIC_USERNAME
Username for HTTP basic authentication. Disabled by default
--http-basic-password HTTP_BASIC_PASSWORD
Password for HTTP basic authentication
--http-basic-hash HTTP_BASIC_HASH
Hashed password for HTTP basic authentication
You can configure additional cameras by adding a [CAMERAn] section to the vigi.ini file, where n is the camera ID. The only required parameter is the CameraID:
[CAMERA0]
CameraID = 0
[CAMERA1]
CameraID = 1
MaxErrors=50
Sensitivity=0.5
You can specify MaxErrors and Sensitivity for each camera separately. If these parameters are not specified, the default values will be used.
Installation on Raspberry Pi (Raspberry Pi OS)
64 bit OS is required for PyTorch to work. Tested with Raspberry Pi OS (Legacy, 64-bit).
Install the pip package:
pip install vigi
Run the agent:
./.local/bin/vigi --host 0.0.0.0
If the object detection is slow on your device, you can try to run the agent with the --disable-detection option to disable it.
Notifications
Consult the Notifications document for more information on how to configure notifications.
Development
Run from the sources
# Set up a virtual environment
python -m venv .venv
. .venv/bin/activate
# Install the required packages
pip install -r requirements.txt
# run the agent
python main.py
Build a pip package
pip install build
python -m build
Publish the package to PyPI
python -m pip install --upgrade twine
python -m twine upload dist/*
Run unit tests
Download a samples dataset for the motion detection tests from here and extract it to the agent/tests directory.
Then run the tests:
python -m unittest discover
Test coverage
To generate a coverage report, run the following command:
pip install coverage
coverage run -m unittest discover
coverage html
Run PyLint
pylint $(git ls-files '*.py')
Metadata
Release files for vigi 0.9.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vigi-0.9.2.tar.gz | 160.7 kB | Without provenance | Details for vigi-0.9.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vigi-0.9.2-py3-none-any.whl | Python 3 | none | any | Details for vigi-0.9.2-py3-none-any.whl |
Total release size: 312.8 kB
Release files / vigi-0.9.2.tar.gz
| Download URL | vigi-0.9.2.tar.gz |
|---|---|
| Size | 160.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5956c79117d1921a6c822d9ae60be3ef4dca157294a2a4e7bb48289a71f1b7c
|
|
BLAKE2b-256 checksum How to use checksums |
61cbcae00ea99f296523778f566f0c1dd368ef140bae95d6205f5cbfb1b2fd63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.19
|
Release files / vigi-0.9.2-py3-none-any.whl
| Download URL | vigi-0.9.2-py3-none-any.whl |
|---|---|
| Size | 152.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5bb4921de46c353956d2d8139a17c38197b2393e255f993d288c4b4f3e7c486
|
|
BLAKE2b-256 checksum How to use checksums |
def67afc63d76c3f0cea26f969f1f02f2c080a1c221d3631d6324424bab7248b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.19
|
Security for vigi 0.9.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.