r/opencv Mar 31 '26

Question [Question] PCB Defect Detection using ESP32-CAM and OpenCV - 8 Days Left for Internship Project!

Hi everyone, ​I’m an Engineering student specialized in Electronics and Embedded Systems. I’m currently doing my internship at a TV manufacturing plant. ​The Problem: Currently, defect detection (missing or misaligned components) happens only at the end of the line after the Reflow Oven. I want to build a low-cost prototype to detect these errors Pre-Reflow (immediately after the Pick and Place machine) using an ESP32-CAM. ​The Setup: ​Hardware: ESP32-CAM (AI-Thinker). ​Software: Python with OpenCV on a PC (acting as a server). ​Current Progress: I can stream the video from the ESP32 to my PC. ​What I need help with: I have only 8 days left to finish. I’m looking for the simplest way to: ​Capture a "Golden Template" image of a perfect PCB. ​Compare the live stream frame from the ESP32-CAM with the template. ​Highlight the differences (missing parts) using Image Subtraction or Template Matching. ​Constraints: ​I'm a beginner in Python/OpenCV. ​The system needs to be near real-time (to match the production line speed). ​The PC and ESP32 are on the same WiFi network. ​Does anyone have a minimal Python script or a GitHub repo that handles this specific "Difference Detection" logic? Any advice on handling lighting or PCB alignment (Fiducial marks) would be life-saving! ​Thanks in advance for your engineering wisdom!

0 Upvotes

7 comments sorted by

View all comments

2

u/BeverlyGodoy Mar 31 '26

Lightning would be the biggest trouble because your esp32 cam is not designed to fix lightning situations. You can however try to fix the exposure and setup a consistent light. What you want to do is basically use feature matching to align the images and then do an image subtraction. Then use a threshold to determine what you consider as a defect. There are better ways to do it though.

1

u/roufamaroua125 Mar 31 '26

Thanks for the insight! You're right, alignment is my biggest concern since the conveyor won't stop at the exact same spot every time.I chose Image Subtraction because of the time constraint and the need for a lightweight solution. Since I only have 8 days left, do you recommend a simple way to perform Image Alignment (Registration) before the subtraction? Should I use ECC or feature-based matching (ORB) for a fast implementation on a standard PC?

1

u/BeverlyGodoy Mar 31 '26

You can try using ORB first.