Embedded systems · AI / 2026
Edge AI Security Camera
A Raspberry Pi 5 camera that runs YOLOv4-tiny locally and sends cloud alerts for selected detections.
Local object detection
I built a camera on a Raspberry Pi 5 that processes video locally and sends cloud alerts for detections such as people or vehicles. I wanted to avoid continuously uploading video for processing.
Frames come from a CSI camera module. The software uses Python and OpenCV to run YOLOv4-tiny, then filters the detections before sending an alert.
Running the model
I chose YOLOv4-tiny for its smaller model size and lower processing requirements. OpenCV’s DNN module loads the weights and runs inference on frames from the camera.
The excerpt below prepares a frame at 416 by 416 pixels, scales the color values, and passes it through the network.
# Prepare a frame and run the YOLOv4-tiny network.
import cv2
net = cv2.dnn.readNet("yolov4-tiny.weights", "yolov4-tiny.cfg")
output_layers = net.getUnconnectedOutLayersNames()
def process_frame(frame):
blob = cv2.dnn.blobFromImage(
frame, 1 / 255.0, (416, 416),
swapRB=True, crop=False
)
net.setInput(blob)
return net.forward(output_layers)
This excerpt covers inference only. The network outputs still need confidence filtering, bounding-box decoding, and non-maximum suppression before they can trigger an alert.