Skip to content

tillsva/raspberry-pi-studio-warning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Meeting Alert

This project performs real-time person detection using TFLite or ONNX models on a Raspberry Pi. The scripts are optimized for models created with OneAI. When a person is detected, it triggers a GPIO pin (e.g., for a light or relay) and plays an alarm sound.

We created the ai model using OneAI. Here you can find the setup for this demo.

Hardware Setup

  • Raspberry Pi (Pi 4 or 5 recommended)
  • Camera: USB Webcam or Raspberry Pi Camera Module.
  • Speaker/Audio Output: For the alarm sound (alarm.mp3).
  • GPIO:
    • Pin 14 (BCM): Connected to your alert device (LED, Relay, etc.).
    • GND: Connect ground.

Software Setup

1. Create a Virtual Environment

It is recommended to use a virtual environment with access to system packages (important for libraries like RPi.GPIO or if you want to use the picam).

# Create venv with system-site-packages
python3 -m venv --system-site-packages venv

# Activate the venv
source venv/bin/activate

2. Install Dependencies

Install the required Python libraries.

# Ensure you are in the project directory
pip install -r requirements.txt

# You also need mpg123 for sound playback
sudo apt-get install mpg123

3. Picamera & Python 3.13 Troubleshooting

If you use the Picamera, you may run into issues with TensorFlow dependencies in the system site-packages.

Fix for "No module named 'imp'" (Python 3.13): This error is caused by an old version of flatbuffers.

pip uninstall -y flatbuffers
pip install "flatbuffers>=23.0"

This should solve the error.

How to Find Your Camera Index

To find the correct index for your USB camera:

Method 1: List Devices

ls -l /dev/video*

Usually, /dev/video0 is index 0, /dev/video2 is index 2, etc. Note that many USB cameras create two devices (e.g., video0 and video1). Try the first one (even number) first.

Method 2: using v4l2-ctl (Recommended)

sudo apt-get install v4l-utils
v4l2-ctl --list-devices

This will show which camera maps to which /dev/videoX path.

Usage

The main script is meeting_alert.py, which handles both TFLite and ONNX models.

General Command

python meeting_alert.py --model models/your_model.tflite --cam 0

Parameters

Parameter Type Default Description
--model path Required Path to the .tflite or .onnx model file.
--cam int None USB Camera Index (e.g., 0 for /dev/video0).
--gui flag False Add this flag to open a window showing the camera feed and detection boxes.
--conf float 0.5 Confidence threshold (0.0 - 1.0) for triggering the alarm.

Examples

Run with a TFLite model on USB Camera 0 and show the GUI:

python meeting_alert.py --model models/person_model.tflite --cam 0 --gui --conf 0.6

Run headless (no GUI):

python meeting_alert.py --model models/detection_post.tflite --cam 0

Run using a Raspberry Pi Camera (Picamera2): If no --cam index is provided, the script attempts to use Picamera2 automatically.

python meeting_alert.py --model models/person_model.tflite

Alarm & GPIO Logic

  • Detected: GPIO 14 set to HIGH, alarm.mp3 plays in a loop.
  • Not Detected: GPIO 14 set to LOW, alarm stops.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages