💡 PCB Visual Defect Inspection: https://github.com/AmmarMohammed01/Senior-Design/
- PCB stands for Printed Circuit Boards. They're used to house electrical components.
- The project aims to detect potential defects on a PCB.
- SSIM Difference Detection
- Compares a perfect/"golden" board to a "test" board.
- OpenCV allows us to scan differences between the two images of boards. If difference is noticed it is flagged as possible defect.
- Autocropping ML Model & Defect Detection Model.
- The Autocropping ML <odel allows the system to detect where a board or multiple boards is/are located within the camera frame.
- After the board is located the Defect Detection YOLO Model is run to identify the following defects:
- Misalligned Components
- Missing Components
- Tombstoning
- Solder Bridges
- Ammar: SSIM and ML code, dual-camera capture code, board-image filesystem, Raspberry Pi ringlight code.
- Isaac: Graphical User Interface (GUI) code.
- Mohammed: Arduino code interfacing relay.
- Open the folder
- In terminal run the following for installing libraries on Mac/Linux:
# Mac/Linux
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtor installing libraries on Raspberry Pi:
# Raspberry Pi
sudo apt install python3-picamera2
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
pip install -r requirements.txt- Now you can run the program:
python main.py- After finished running program, to close the Python Virtual Environment type in terminal
deactivate- Open the folder
- In terminal run:
source .venv/bin/activate- Now you can run the program:
python main.py- After finished running program, to close the Python Virtual Environment type in terminal
deactivatelabelImg is the labeling program used the label the golden boards. A caveat we face using it is that it need to run on Python 3.9 for stability. Hence, we need to create a Python 3.9 Virtual Environment (venv)
- Install Python 3.9
# Install using Homebrew
brew install [email protected]
# To check if installed
which python3.9 # should be /opt/homebrew/bin/python3.9- Create virtual environment w/ Python 3.9
python3.9 -m venv labelimg_env- Install labelImg program
source labelimg_env/bin/activate
pip install labelImg
deactivate- Create Python Virtual Environment on latest version
python -m venv labelimg_env --system-site-packages- Activate venv
source labelimg_env/bin/activate- Install labelImg program
pip install labelImg # Currently using labelImg-1.8.6- Make adjustments to code to fix "float" error
labelImg.py: line 965
canvas.py: 526, 530, 531
- Deactivate after installation and program setup complete
deactivate.
├── README.md
├── requirements.txt: required python libraries
├── main.py
├── menu.py
├── select_camera.py
├── take_image.py
├── take_image_picam.py
├── launch_image_labeler.py
├── image_comparison.py
└── map_errors.py
main.py:
- entry point of program
menu.py:
- user interface and options
select_camera.py:
- allow user to select usb or picam
take_image.py:
- capture golden and test board images
take_image_picam.py:
- capture golden and test board images with picamera
launch_image_labeler.py:
- launches labelImg to allow user to label golden board
image_comparison.py:
- compares golden board and test boards images
map_errors.py:
- map regions onto golden board found to be different,
- determine which are likely errors,
- suggest possible error types
Note: image save type for program is .jpg
.
├── boards
│ ├── arduino
│ │ ├── golden.jpg
│ │ └── roi.json
│ ├── power
│ │ ├── classes.txt
│ │ ├── golden.jpg
│ │ ├── golden.txt
│ │ └── roi.json
│ ├── buck
│ │ ├── classes.txt
│ │ ├── golden.jpg
│ │ ├── golden.txt
│ │ ├── next-test-img-num.json
│ │ ├── roi.json
│ │ ├── test1.jpg
│ │ ├── test2.jpg
│ │ ├── test23.jpg
│ │ ├── test24.jpg
│ │ ├── test25.jpg
│ │ ├── test26.jpg
│ │ ├── test27.jpg
│ │ ├── test28.jpg
│ │ ├── test29.jpg
│ │ └── test30.jpg
│ └── buck-boost
│ ├── golden.jpg
│ ├── next-test-img-num.json
│ ├── roi.json
│ ├── test1.jpg
│ └── test2.jpg
├── images
│ ├── board_golden.jpg
│ ├── board_golden.txt
│ ├── board_inferno.jpg
│ ├── board_test.jpg
│ ├── classes.txt
│ ├── golden.png
└ └── test1.png