Manul AOI Using PCB-AOI Software
Manul AOI Using PCB-AOI Software
To automate visual inspection of PCBs by comparing each test board against a "golden sample" reference board
image.
To detect critical defects such as missing components, solder shorts, cold joints, insufficient solder, and
component misalignment.
To replace or supplement costly/hardware-dependent AOI systems, especially in scenarios where AOI or laser
inspection devices are not feasible.
To improve quality assurance by providing reliable, repeatable, and objective defect detection.
To save time and effort in manual inspection and reduce human error, ensuring higher product quality and
customer satisfaction.
To maintain traceability and defect records by linking inspection results with barcode data and test images.
Visit python.org
Run the installer and check "Add Python to PATH" before clicking Install.
Run:
text
Capture PCB board photos with your smartphone, ensuring barcode visibility.
From the command line, run the inspection script with a test image, e.g.:
text
The software compares the test image against the golden reference, detects defects, and outputs results.
The core software combines OpenCV for image processing, pyzbar for barcode detection, and Tkinter for a
desktop GUI (optional).
o Detecting components and solder joints via contour, thresholding, and edge detection.
o Comparing component positions between golden and test boards to find missing or misplaced parts.
o Analyzing solder joints for shorts and cold joints based on brightness and area.
o Saving results with timestamps, barcode IDs, and defect counts to Excel or CSV files.
Example snippets involve thresholding, contour detection, barcode decoding (pyzbar), and basic statistical
analysis of solder joint images.
Python Runtime environment Official site [python.org], add to PATH during install
OpenCV (opencv-
Computer vision processing pip install opencv-python
python)
GUI framework (usually included Included in most Python standard installs; if missing, install via
Tkinter
with Python) OS package manager
Image Quality: Use high-resolution, sharp images from consistent lighting environments to reduce noise.
Image Alignment: Implement feature-based image registration (using fiducial marks or feature matching) to align
test and golden board images precisely before comparison.
Threshold Calibration: Carefully tune parameters such as contour area thresholds, pixel distance for matching
components, and solder quality scores based on real boards.
Multiple Views and Lighting: If possible, capture multiple images with varied lighting to reveal defects better.
Training and Iteration: Test on many samples, adjusting sensitivity settings and thresholds to balance false
positives and false negatives.
Optional AI Integration: For higher accuracy, incorporate trained machine learning models to classify subtle
defects beyond pure CV methods.
Operator Review for Borderline Cases: Set defect thresholds allowing "REVIEW" status for uncertain boards
needing manual check, reducing false fails.
6) How to Save the Inspected Data and How Easily It Can Be Retrieved
o Timestamp of inspection.
o Counts of missing components, solder shorts, cold joints, and overall quality score.
Board images can be saved in a dedicated folder named by barcode or timestamp for traceability.
The Excel/CSV file can be opened anytime for historic inspection review or reporting.
Integration with simple database tools or Excel pivot tables allows filtering and querying by date, barcode, or
defect type for root-cause analysis.
The software GUI can list recent inspections and show detailed defect reports, speeding up data retrieval by
operators or quality engineers.
Final Notes
With this system, you get a free, easy-to-deploy solution for PCB inspection using only your phone camera and a
Windows PC, saving costs on expensive AOI machines but still achieving robust quality control through:
Barcode-based traceability.
If you want, I can provide direct code snippets, customization tips, or a more in-depth beginner guide to the software
GUI and scripting.
Would you like me to generate a ready-to-run minimal example code or help set up a step-by-step tutorial for this
software?
1. https://blog.roboflow.com/part-inspection-using-computer-vision/
2. https://blog.roboflow.com/pcb-defect-detection/
3. https://pysource.com/2025/06/04/build-an-accurate-visual-inspection-system-with-python/
4. https://www.youtube.com/watch?v=jF6b9WxTGMQ
5. https://github.com/swaralipaygude/Bare-PCB-defect-detection-using-OpenCV
6. https://github.com/Ixiaohuihuihui/Tiny-Defect-Detection-for-PCB
7. https://www.kaggle.com/code/pinokiokr/pcb-defect-detection
I will create a full Tkinter desktop GUI version of the minimal PCB Defect Inspector script you have, so that you and your
operators can load images, run inspections, and save results by just clicking buttons—no command line needed.
Lets you load a golden reference board image and a test board image (your phone photos).
Automatically reads the barcode from the test image (if visible).
Performs a basic defect detection by comparing the test and golden images.
python
import tkinter as tk
import cv2
import numpy as np
import pandas as pd
import os
class PCBInspectorGUI:
self.root = root
self.root.geometry("900x600")
# Initialize variables
self.golden_img = None
self.test_img = None
self.golden_img_path = None
self.test_img_path = None
# GUI Layout
self.setup_gui()
def setup_gui(self):
# Frames for buttons and images
btn_frame = tk.Frame(self.root)
self.load_golden_btn.pack(side=tk.LEFT, padx=10)
self.load_test_btn.pack(side=tk.LEFT, padx=10)
self.inspect_btn.pack(side=tk.LEFT, padx=10)
self.save_btn.pack(side=tk.LEFT, padx=10)
display_frame = tk.Frame(self.root)
self.golden_canvas.pack(fill=tk.BOTH, expand=True)
self.test_canvas.pack(fill=tk.BOTH, expand=True)
self.result_label.pack(pady=5)
def load_golden(self):
if filepath:
img = cv2.imread(filepath)
if img is None:
return
self.golden_img = img
self.golden_img_path = filepath
self.display_image(img, self.golden_canvas)
self.load_test_btn.config(state=tk.NORMAL)
def load_test(self):
if filepath:
img = cv2.imread(filepath)
if img is None:
return
self.test_img = img
self.test_img_path = filepath
self.display_image(img, self.test_canvas)
self.inspect_btn.config(state=tk.NORMAL)
h, w = rgb_img.shape[:2]
im_pil = Image.fromarray(resized)
imgtk = ImageTk.PhotoImage(image=im_pil)
canvas.delete("all")
def inspect(self):
return
self.display_image(marked_img, self.test_canvas)
barcode = self.read_barcode(self.test_img)
self.current_result = {
"barcode": barcode,
"defects": defects_count,
"image_path": self.test_img_path
self.save_btn.config(state=tk.NORMAL)
# Convert to grayscale
defects = 0
marked = test.copy()
area = cv2.contourArea(cnt)
x,y,w,h = cv2.boundingRect(cnt)
defects += 1
barcodes = pyzbar.decode(gray)
if barcodes:
return barcodes[0].data.decode('utf-8')
return "NO_BARCODE"
def save_results(self):
return
df = pd.DataFrame([[
self.current_result["timestamp"],
self.current_result["barcode"],
self.current_result["defects"],
self.current_result["image_path"]
self.save_btn.config(state=tk.DISABLED)
if __name__ == "__main__":
root = tk.Tk()
app = PCBInspectorGUI(root)
root.mainloop()
1. Run this Python script on your Windows PC (make sure dependencies are installed).
2. Click Load Golden Board Image and select your reference PCB photo.
3. Then click Load Test Board Image and pick the board photo to inspect.
5. Results show under the buttons with defects highlighted in the test image.
6. Click Save Results to log the inspection details (timestamp, barcode, defect count, image path) into
inspection_results.csv.
text
Would you like me to guide you on these next steps or help with deploying this app on your operator stations?
1. https://blog.roboflow.com/pcb-defect-detection/
2. https://www.youtube.com/watch?v=mop6g-c5HEY
3. https://www.digikey.com/en/maker/projects/python-gui-guide-introduction-to-tkinter/
d04a764c78114682aac9255056026338
4. https://robu.in/gui-designing-on-raspberry-pi-using-tkinter-and-python/
5. https://realpython.com/python-gui-tkinter/
6. https://www.geeksforgeeks.org/python/python-gui-tkinter/
7. https://www.youtube.com/watch?v=vusUfPBsggw
8. https://www.youtube.com/watch?v=lyoyTlltFVU
9. https://www.geeksforgeeks.org/python/create-first-gui-application-using-python-tkinter/
10. https://www.youtube.com/playlist?list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV