Home Project guides ANPR Camera System
Advanced

ANPR Camera System

Estimated cost $150-300 · 5 parts

Bill of materials

Raspberry Pi CM4 + IO Board
Raspberry Pi Camera Module 3
IR LED array (for night)
PoE HAT or 12V supply
IP66 Housing

Source code

main.py / main.ino
# ANPR with OpenALPR / Ultralytics
import cv2
from picamera2 import Picamera2
from ultralytics import YOLO
import easyocr

# Load models
plate_detector = YOLO('yolov8n-plate.pt')  # Custom trained
ocr = easyocr.Reader(['en'])

picam2 = Picamera2()
picam2.configure(picam2.create_preview_configuration(
    main={"size": (1920, 1080)}
))
picam2.start()

def process_frame(frame):
    results = plate_detector(frame)
    
    for box in results[0].boxes:
        x1, y1, x2, y2 = map(int, box.xyxy[0])
        plate_img = frame[y1:y2, x1:x2]
        
        # OCR
        text = ocr.readtext(plate_img, detail=0)
        plate_number = ''.join(text).upper()
        
        if plate_number:
            print(f"Detected: {plate_number}")
            # Send to DENDAT API
            send_detection(plate_number, frame)
    
    return results

while True:
    frame = picam2.capture_array()
    process_frame(frame)

Build notes

Tips for ANPR: 1. Use 850nm IR LEDs (invisible to eye) 2. Camera angle: 15-30° to avoid reflection 3. Exposure: 1/500s to freeze motion 4. Train YOLO on local plate formats 5. Use hardware-accelerated encoding