A Camera for the Raspberry Pi

A Camera for the Raspberry Pi

July 19, 2024

Raspberry Pi + Camera

Hardware

  • Arducam OV5647 (5MP, 1080p) -

Taking Pictures and Streaming Video

Enable the camera:

sudo raspi-config #Interface Options -> I1 Enable (legacy) camera Support #bullseye 6.1kernel
#you will be prompt to reboot

Take a picture simply with:

raspistill -o pico.jpg
#scp yourraspbiuser@192.168.3.130:/home/reisipi/pico.jpg . #copy it to windows CMD

Save Pictures Every 60s

mkdir -p ~/growth
nano capture_images.sh
./capture_images.sh
ℹ️
  • And now video streaming with:
Card with tag
git clone https://github.com/meinside/rpi-mjpg-streamer #https://github.com/JAlcocerT/rpi-mjpg-streamer
cd rpi-mjpg-streamer
ℹ️
I forked it, just in case :)

Build the image:

sudo docker build -t streamer:latest \
		--build-arg PORT=9999 \
		--build-arg RESOLUTION=400x300 \
		--build-arg FPS=24 \
		--build-arg ANGLE=0 \
		--build-arg FLIPPED=false \
		--build-arg MIRRORED=false \
		--build-arg USERNAME=user \
		--build-arg PASSWORD=some-password \
		.

Deploy the image:

docker run -p 9999:9999 --device /dev/video0 -it streamer:latest
streamer Docker Compose 📌
version: '3'
services:
  streamer:
    image: streamer:latest
    container_name: streamer
    ports:
      - "9999:9999"
    devices:
      - "/dev/video0:/dev/video0"
    stdin_open: true
    tty: true

And we will have the interface ready at the specified port: localhost:9999 and user/password as per your specifications while building the image.

Working up to GNU v11 (not available in bookworm!)


More Software - Camera and CV

Pi NVR

An NVR stands for Network Video Recorder. It’s a specialized computer system designed to record and store video footage captured by IP (Internet Protocol) cameras.

Raspberry Pi NVR for home CCTV recording.

TensorFlow Lite

  • A)
git clone https://github.com/tensorflow/examples --depth 1 #https://github.com/JAlcocerT/tf-examples
cd examples

Create a Py venv:

python3 -m pip install virtualenv

# Successfully installed distlib-0.3.8 filelock-3.15.4 platformdirs-4.2.2 virtualenv-20.26.3

python3 -m venv tf
source tf/bin/activate
cd ./lite/examples/object_detection/raspberry_pi
sh setup.sh

Or a Conda one if you prefer:

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh

chmod +x Miniconda3-latest-Linux-armv7l.sh
./Miniconda3-latest-Linux-armv7l.sh
source ~/.bashrc
#conda --version

conda create --name myenv python=3.7.3
conda activate myenv
python --version

Once all dependencies are installed in the chose isolated environment:

python3 detect.py --model efficientdet_lite0.tflite
  • B) Raspberry Pi Object Detection Tutorial

OpenCV

PyTorch

Yolo (ultralytics)

With Yolo Models - https://github.com/ultralytics/yolov5

MotionEyeOS

A Video Surveillance OS For Single-board Computers

docker run --name="motioneye" \
    -p 8765:8765 \
    --hostname="motioneye" \
    -v /etc/localtime:/etc/localtime:ro \
    -v /etc/motioneye:/etc/motioneye \
    -v /var/lib/motioneye:/var/lib/motioneye \
    --restart="always" \
    --detach=true \
	ccrisan/motioneye:master-armhf
    #ccrisan/motioneye:master-amd64 #https://hub.docker.com/r/ccrisan/motioneye

Now, you will access MotionEye at localhost:8765 with default user: admin and blank (no password).

motionEyeOS is a Linux distribution that turns a single-board computer into a video surveillance system.

Frigate

A complete and local NVR designed for Home Assistant with AI object detection. Uses OpenCV and Tensorflow to perform realtime object detection locally for IP cameras.

NVR with realtime local object detection for IP cameras

Other Options for CV with RPi

https://www.youtube.com/watch?v=tT5gHNDBHXo


FAQ

HA Desktop - https://flathub.org/apps/com.cassidyjames.butler

AI

Best Performing LLMs for a RPi

How to use Ollama with a Raspberry Pi

You can SelfHost Ollama with Docker and choose a small enough model that it will fit in the RAM.

Build multimodal AI applications with cloud-native stack:

BI Tools for EDA

More

How to Install Raspberri Pi camera and Troubleshoot errors | Upgrade Bios Firmware on Raspberry Pi https://www.youtube.com/watch?v=Z8cs1cRrc5A

https://www.youtube.com/watch?v=tT5gHNDBHXo