detect and classify insects on a raspberry pi
Project description
bugcam
Raspberry Pi insect detection CLI using Hailo AI accelerator and the edge26 processing pipeline. Records video, detects and classifies insects on-device, and uploads results to S3.
Default API endpoint: https://api.sensinggarden.com/v1
Prerequisites (Raspberry Pi with Hailo AI)
bugcam requires system-level Hailo packages that are not available via PyPI. Install them before running setup:
sudo apt update && sudo apt install python3-hailo-tappas hailo-tappas-core
If you encounter sudo password prompts during setup, enable passwordless sudo:
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$USER
Quick Start
curl -sSL https://raw.githubusercontent.com/MIT-Senseable-City-Lab/sensing-garden/main/install.sh | bash
bugcam setup
bugcam models list
bugcam models download <model-name>
bugcam run
Commands
| Command | Description |
|---|---|
bugcam run |
Full pipeline: record + process + upload + heartbeat + receiver |
bugcam run --no-receiver |
Run without DOT receiver server |
bugcam receive start |
Start DOT receiver server standalone |
bugcam record single |
Record a single video |
bugcam process |
Process existing videos with edge26 |
bugcam upload |
Upload processed output to S3 |
bugcam heartbeat |
Write a heartbeat snapshot |
bugcam environment |
Collect one environmental sensor reading |
bugcam dot-info |
Show DOT sensor setup instructions |
bugcam models list |
List available and installed models |
bugcam models download <name> |
Download a model bundle |
bugcam models info <name> |
Show model details |
bugcam models delete <name> |
Delete a model bundle |
bugcam status |
System diagnostics (hardware, deps, camera, Hailo) |
bugcam setup |
Device registration + Hailo installation |
bugcam autostart enable |
Enable systemd service for boot |
bugcam autostart disable |
Disable systemd service |
bugcam autostart status |
Show service status |
bugcam autostart logs |
View service logs |
bugcam update |
Update to latest version |
bugcam --version |
Show installed version |
bugcam run Options
| Option | Default | Description |
|---|---|---|
--with-receiver/--no-receiver |
True |
Start DOT receiver alongside pipeline |
--receiver-port |
5001 |
DOT receiver HTTP port |
--receiver-host |
0.0.0.0 |
DOT receiver bind address |
--mode |
continuous |
Recording mode: continuous or interval |
--interval |
5 |
Minutes between recordings (interval mode) |
--chunk-duration |
60 |
Length of each recorded chunk in seconds |
--model |
(from config) | Model bundle name or model.hef path |
Architecture
- edge26 pipeline lives in
bugcam/edge26/(vendored from the edge26 repo). Handles recording, processing, and output formatting. - BugSpot library handles motion detection and insect tracking.
- Hailo accelerator runs classification on detected insects.
- DOT Receiver (
bugcam/receiver/) is an HTTP server that receives insect track data from iOS devices (DOTs) and saves it in edge26-compatible format. Automatically started withbugcam run(can be disabled with--no-receiver). Can also run standalone viabugcam receive start. - Upload sends results to S3 via presigned URLs obtained from the backend API. No AWS credentials are stored on-device -- only a per-device API key issued during
bugcam setup. - S3 trigger Lambda indexes uploaded results into DynamoDB.
Configuration
Config file: ~/.config/bugcam/config.json
| Field | Description |
|---|---|
api_url |
Backend API endpoint |
api_key |
Per-device API key (from registration) |
flick_id |
FLICK device identifier |
dot_ids |
List of DOT device identifiers |
s3_bucket |
Output S3 bucket name |
input_dir |
DOT receiver input directory |
output_dir |
Processed video output directory |
state_dir |
State/pending directory |
pending_dir |
Classification queue directory |
Models are stored in ~/.cache/bugcam/models/<bundle>/ (each bundle contains model.hef + labels.txt).
Storage Configuration
By default, bugcam stores data on the SD card. For better performance (avoid "frame queue full" errors), use an external USB drive.
| Storage Type | Write Speed | Sustained Performance |
|---|---|---|
| SD Card (Class 10) | 10-40 MB/s | Degrades as it fills up |
| USB 3.0 Flash Drive | 20-100 MB/s | More consistent |
| USB 3.0 SSD | 200-500+ MB/s | Very stable |
Configuration Methods (in order of precedence):
-
CLI options (per run):
bugcam run --input-dir /media/pi/4549-BC23/bugcam/incoming \ --output-dir /media/pi/4549-BC23/bugcam/outputs
-
Config file (persistent, set during
bugcam setup):{ "input_dir": "/media/pi/4549-BC23/bugcam/incoming", "output_dir": "/media/pi/4549-BC23/bugcam/outputs", "state_dir": "/media/pi/4549-BC23/bugcam/state" }
-
Environment variables (persistent in shell):
export BUGCAM_INPUT_DIR="/media/pi/4549-BC23/bugcam/incoming" export BUGCAM_OUTPUT_DIR="/media/pi/4549-BC23/bugcam/outputs" export BUGCAM_STATE_DIR="/media/pi/4549-BC23/bugcam/state"
During bugcam setup, external drives are automatically detected and offered as storage locations.
Requirements
- Raspberry Pi 5 with 8GB RAM
- Raspberry Pi AI HAT+ (Hailo-8L or Hailo-8)
- Pi Camera (HQ Camera recommended)
- Optional SEN55 environmental sensor on I2C for
bugcam environmentand periodic environment uploads - Python 3.11+
- Raspberry Pi OS Bookworm 64-bit
build-essentialandlibcjson-devfor building the bundled SEN55 reader
DOT Sensors
DOTs are mobile devices (iPhones) that detect insects and send data to a FLICK (Raspberry Pi) for classification. Run bugcam dot-info on the FLICK to see full setup instructions.
The FLICK runs a DOT Receiver server (started by default with bugcam run) that accepts HTTP uploads from iOS devices on port 5001.
DOT Receiver Endpoints
| Endpoint | Method | Description |
|---|---|---|
/upload_crops |
POST | Receive crop images for a track |
/upload_labels |
POST | Receive bounding box labels |
/upload_done |
POST | Signal track completion |
/upload_background |
POST | Receive reference background image |
/upload_video |
POST | Receive video file |
/api/track |
POST | Alternative track telemetry endpoint |
/api/heartbeat |
GET/POST | Connection test |
/api/health |
GET | Health check |
Data Structure
Each DOT puts files in the FLICK's input folder using this structure:
{dot_id}_{YYYYMMDD}/
├── crops/{track_id}_{HHMMSS}/
│ ├── frame_000001.jpg
│ └── done.txt ← signals track is ready to process
├── labels/{track_id}.json ← bounding boxes per frame
├── videos/{dot_id}_{YYYYMMDD}_{HHMMSS}.mp4
└── {HHMMSS}_background.jpg ← reference frame without insects
DOTs also write heartbeat and environment data to the output folder:
{dot_id}/
├── heartbeats/{YYYYMMDD_HHMMSS}.json
└── environment/{YYYYMMDD_HHMMSS}.json
DOT IDs are auto-generated during bugcam setup (e.g. garden-london-1-dot01). The receiver automatically assigns DOT IDs to connecting iOS devices from the configured dot_ids list.
Development
git clone https://github.com/MIT-Senseable-City-Lab/sensing-garden.git
cd sensing-garden
poetry install
poetry run bugcam --help
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bugcam-0.5.0.tar.gz.
File metadata
- Download URL: bugcam-0.5.0.tar.gz
- Upload date:
- Size: 90.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.14.4 Linux/6.12.47+rpt-rpi-2712
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fddb5d2e5aa0fca3a0361b4be080314f2482312b54ebc38faa5f57925b9fb7b
|
|
| MD5 |
ffd9f7e46a1d25ca6c3f298e6c858e1c
|
|
| BLAKE2b-256 |
6c494df44d901f33783455b44fc18307e04590a33ab6b0a38c7980f0a3b38fd7
|
File details
Details for the file bugcam-0.5.0-py3-none-any.whl.
File metadata
- Download URL: bugcam-0.5.0-py3-none-any.whl
- Upload date:
- Size: 117.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.14.4 Linux/6.12.47+rpt-rpi-2712
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f0bfd46e16d8123ad490599fe2cd34cb0a2ba7d48ef0746394917888bc58608
|
|
| MD5 |
0ed327555f8818fce41b8bda80a41c2c
|
|
| BLAKE2b-256 |
5152cb1a8bfbfe617dbc48e79a77a89ba60fe0dab048f6f4a2e5995bd694a670
|