BombusCV
![GitHub releases](https://img.shields.io/github/downloads/marcoradocchia/bombuscv-rs/total?color=%23a9b665&logo=github)
![GitHub source size](https://img.shields.io/github/languages/code-size/marcoradocchia/bombuscv-rs?color=ea6962&logo=github)
![GitHub open issues](https://img.shields.io/github/issues-raw/marcoradocchia/bombuscv-rs?color=%23d8a657&logo=github)
![GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/marcoradocchia/bombuscv-rs?color=%2389b482&logo=github)
![GitHub sponsors](https://img.shields.io/github/sponsors/marcoradocchia?color=%23d3869b&logo=github)
![Crates.io downloads](https://img.shields.io/crates/d/bombuscv-rs?label=crates.io%20downloads&logo=rust)
![Crates.io version](https://img.shields.io/crates/v/bombuscv-rs?logo=rust&color=%23d8a657)
![Discord](https://img.shields.io/discord/985154521946816595?label=chat%20support&logo=discord&logoColor=%23ffff&color=%2389b482)
![GitHub license](https://img.shields.io/github/license/marcoradocchia/bombuscv-rs?color=%23e78a4e)
Motion detection & video recording software based on OpenCV, built for research
on **Bumblebees** (hence the name).
## Index
- [Use case](#use-case)
- [Examples](#examples)
- [Install](#install)
- [Usage](#usage)
- [Configuration](#configuration)
- [Changelog](#changelog)
- [ToDo](#todo)
- [Chat Support](#chat-support)
- [License](#license)
## Use case
This software was built to meet the need of tracking, and/or recording clips of
marked Bumblebee individuals in a scientific research project. It has been used
with a
[Raspberry Pi 4](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/)[^1]
and a
[Raspberry Pi HQ Camera](https://www.raspberrypi.com/products/raspberry-pi-high-quality-camera/)[^2]
pointed at the entrance of a _Bombus terrestris_ nest, in order to record clips
of the entry/exit events, based on motion. This considerably reduced the
storage space required for the recordings and completely removed the need of
post processing work, since it was only recording clips in which individuals
appeared in the video frame.
`bombuscv-rs` offers realtime motion detection & video recording[^3] using
camera input and can be directly used on fieldwork. However, using the `video`
option, live camera input can be replaced with a pre-recorded video file: this
is useful to _remove dead moments_ from videos and reduce/remove the need of
manual video trimming.
[^1]: 4GB of RAM memory, powered by a 30000mAh battery power supply, which
means this setup can be also reproduced in locations where no AC is available
[^2]: 12.3 megapixel _Sony IMX477_ sensor
[^3]: Based on hardware (RasberryPi 4 at the moment of writing can handle
640x480 resolution at 60fps)
## Examples
Below a brief example of the produced video output:
https://user-images.githubusercontent.com/74802223/171311278-c5caf303-832f-46f6-a4cc-a3e05f823349.mp4
More examples can be found on [YouTube](https://www.youtube.com/channel/UCkSjz-EAjhEvtUcY-ruYkrA).
## Install
For installation on *RaspberryPi* check [Install on RaspberryPi
4](#install-on-raspberrypi-4).
### Requirements
This program requires a working installation of **OpenCV** (`>=4.5.5`).
Building OpenCV from source is recommended (if you're going to build OpenCV
from source make sure to also install OpenCV dependencies), although it should
work with precompiled packages in your distro's repositories (it has been
tested with success on *ArchLinux* with the `extra/opencv` package).
### Using Cargo
A package is available at [crates.io](https://crates.io/crates/bombuscv-rs). In
order to install it run `cargo install bombuscv-rs` in your shell[^4].
[^4]: Assuming Rust installed
### Install on RaspberryPi 4
It is strongly recommended to use a RaspberryPi 4 with at least 4GB of RAM.
Also, before trying to install, please enable *Legacy Camera* support under
*Interface options* running `raspi-config` and reboot. Since installation on a
RaspberryPi may be a little bit *tricky*, an installation script is
provided[^5]. It takes care of updating & preparing the system, compiling
*OpenCV* and installing *Rustup* and finally **BombusCV**. You can run the
[instllation script](bombuscv-raspi.sh) using `curl`:
```sh
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/marcoradocchia/bombuscv-rs/master/bombuscv-raspi.sh | sh
```
[^5]: RaspberryPi OS 64 bits required in order to install using the script
## Usage
```
bombuscv-rs 0.3.0
Marco Radocchia
OpenCV based motion detection/recording software built for research on bumblebees.
USAGE:
bombuscv [OPTIONS]
OPTIONS:
-d, --directory Output video directory
-f, --framerate Video capture framerate
--format Output video filename format (see
for valid specifiers)
-h, --help Print help information
-H, --height Video capture frame height
-i, --index /dev/video capture camera index
--no-color Disable colored output
-o, --overlay Date&Time video overlay
-q, --quiet Mute standard output
-v, --video