This project transforms a Raspberry Pi 4B into a compact, real-time object detection system using YOLOv5. Housed in a custom 3D-printed prototyping case from JUSTWAY, the setup is ideal for edge AI experiments, smart surveillance, and educational demos. We’ll walk through hardware setup, software installation, model optimization, and GUI integration.
🧰 Hardware ComponentsJUSTWAY is a maker-focused manufacturing service that specializes in rapid prototyping and custom enclosures for embedded systems, IoT devices, and edge AI builds. Whether you're an educator, developer, or startup innovator, JUSTWAY offers a suite of fabrication options designed to bring your ideas to life with polish and practicality.
- 3D Printing: High-resolution prints in PLA, ABS, and flexible materials. Ideal for sensor housings, camera mounts, and modular cases.
- CNC Machining: Precision-milled parts for mechanical assemblies, robotics, and rugged enclosures.
- Sheet Metal Fabrication: Custom brackets, panels, and heat-dissipating structures for industrial-grade builds.
- Injection Molding: Scalable production for finalized designs—perfect for product launches and institutional deployments.
- Urethane Casting: Low-volume, high-detail replicas for testing, demos, and client presentations.
The JUSTWAY prototyping case is more than just a shell—it’s a thoughtfully engineered enclosure that enhances both form and function:
- 🎯 Camera Mounting Slot: Designed to align perfectly with the Raspberry Pi camera module, ensuring stable imaging and easy lens swaps.
- 🌬️ Ventilation Grids: Prevents thermal throttling during long inference sessions, especially when running YOLOv5 models.
- 🔌 GPIO Accessibility: Side cutouts allow quick access to GPIO pins for OLEDs, buttons, sensors, and expansion boards.
- 🧩 Modular Design: Snap-fit panels make it easy to swap components or upgrade hardware without disassembling the entire unit.
- 🎨 Aesthetic Finish: Matte texture and clean lines make it ideal for public demos, classroom use, or maker fairs.
💡 JUSTWAY’s design philosophy aligns perfectly with modular embedded systems—making this case a natural fit for expressive AI builds.
🖥️ Software Stack
- Raspberry Pi OS (Bookworm or Bullseye)
- Python 3.11+
- OpenCV
- Ultralytics YOLOv5
- Tkinter (for GUI
- Pillow (for image rendering)
- Flash Raspberry Pi OS using Raspberry Pi Imager
- Enable SSH, camera interface, and I2C via
raspi-config - Connect to Wi-Fi and update packages:
sudo apt-get update && sudo apt-get upgrade2.Install Dependenciespip3 install ultralytics opencv-python pillow3.Download YOLOv5 Modelwget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5n.ptTip: Use yolov5n.pt (nano) for faster inference on Raspberry Pi.4.Connect and Test Cameralibcamera-helloIf using USB webcam:
fswebcam test.jpg5. Build the Detection ScriptUse the optimized version with Tkinter GUI and frame skipping for performance:
import time
import cv2
from ultralytics import YOLO
from PIL import Image, ImageTk
import tkinter as tk
from picamera2 import Picamera2
# Step 1: Capture image from Raspberry Pi camera
picam2 = Picamera2()
config = picam2.create_still_configuration(main={"size": (640, 480)})
picam2.configure(config)
picam2.start()
time.sleep(2) # Allow camera to adjust
picam2.capture_file("test.jpg")
picam2.stop()
# Step 2: Load YOLOv5 model
model = YOLO("yolov5s.pt")
# Step 3: Load captured image and run inference
image_path = "test.jpg"
frame = cv2.imread(image_path)
results = model.predict(source=frame, save=False)
# Step 4: Annotate image
annotated = results[0].plot()
annotated_rgb = cv2.cvtColor(annotated, cv2.COLOR_BGR2RGB)
image_pil = Image.fromarray(annotated_rgb)
# Step 5: Create GUI window and display result
root = tk.Tk()
root.title("YOLOv5 Detection Result")
image_tk = ImageTk.PhotoImage(image_pil)
label = tk.Label(root, image=image_tk)
label.pack()
root.mainloop()Save this as object_detection_gui.p
python object_detection_gui.pyYou’ll see a live GUI window with annotated frames and feedback.
7. Output
The above image shows that the Object Detection of Pi 4B captures and analyzes images in real time.
🛒 How to Order Your Raspberry Pi Case from JUSTWAYOrdering your case is simple and maker friendly. Here’s how:
📝 Step-by-Step Ordering Guide- Visit JUSTWAY’s Official Store or Contact Page You can browse their catalog or reach out for custom requests.
- Select the Raspberry Pi 4B Prototyping Case
- Choose Your Color and Finish Matte black, translucent, or custom colors available depending on stock.
- Place Your Order and the delivery typically take 3–7 days within India.
- Receive and Assemble - The case arrives ready to use—just insert your Pi, mount the camera, and snap the panels together.
🧠 Performance Tips
- Use
yolov5su.ptfor better accuracy if you upgrade to Pi 5 or use Coral TPU - Resize frames to
(320, 240)for faster processing - Skip every 2nd or 3rd frame to maintain responsiveness
- Use
cv2.VideoCapture(0)for live webcam detection
- Add OLED display for detection summaries
- Log detections to CSV or MQTT dashboard
- Integrate with ESP32-CAM for wireless feeds
- Use buttons to toggle model modes or save frames
This project blends edge AI with modular design, making it perfect for classrooms, maker fairs, or IoT deployments. The JUSTWAY case adds polish and practicality, while YOLOv5 brings powerful detection to the Pi ecosystem.
Whether you're building a smart pet monitor, a DIY security system, or a vision-enabled robot, this setup gives you a solid foundation to explore and expand.





Comments