7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 1/15
School of Electrical &ElectronicEngineering
ACADEMIC SESSION 2013/2014
EEE 355 Robotics and Machine Vision
Mini project
PCB Defects detection
Name : VINCENT KOK CHIN KEONG ([email protected])
MATRIC NO. : 112195
Date of submission : 3rd
june 2014
SUPERVISED BY: Dr. khoo bee ee
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 2/15
Table of contents
Chapter Description Page
1. 1.0 Abstract1
2. 2.0 Introduction2
3. 3.0 Methodology
A. Inspection Flow Chart
B. Image Subtraction Operation
C. OpenCV function used 3 - 5
4. 4.0 Results and Discussion6 - 10
5. 5.0 Limitation11
6. 6.0 Future Improvements11
7. 7.0 Conclusion11
8. 8.0 References 11
9. 9.0 Appendix12 - 13
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 3/15
EEE 355 Robotics & Machine Vision
1 | P a g e
1.0 Abstract
The main objective of this project is to let students apply the image processing techniques
that been taught in class in a given conditions based on their title. This particular project
involved the detection of the defect exist in a PCB board. A Printed Circuit Board (PCB) is a
circuit board consists of electronics components mounted on the surface. Basically, to
produce a perfect bare PCB board, inspection of PCB is necessary to reduce defects. We
apply the machine vision concept to inspect the bare PCB. We first compare a standard PCB
image with a PCB image to be inspected using a simple subtraction algorithm that can
detect the defected region. Our focus is to detect the defect on the PCB, such as broken
track. There are so many algorithms out there to detect the defect on the PCB board.
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 4/15
EEE 355 Robotics & Machine Vision
2 | P a g e
2.0 Introduction
Nowadays, PCB manufacturing is getting more and more important for the electronics
industry such as mobile phones, tablets, washing machines and prototyping boards. Hence,
it is very important to have machine vision inspection of the PCB to improve the quality of
the PCBs. As you know, in manufacturing industry, there are errors such as defects,
misalignment and orientation error. Hence we need automated inspection to analysed for
the errors. There are plenty of such algorithms out there now.
There are 3 main processes in inspection of PCBs : defect detection, defect classification,
and the location of the defect.
Of course, automated inspection system is better than human inspection in which
subjectivity, fatigue, slowness and high cost is involved. The technology is moving very fast
and hence a fast and efficient inspection system is required to make sure 100% quality PCBs
are produced. These conclude that automated systems are preferred in manufacturing
industry nowadays for higher productivity.
In my case study, I am going to investigate about how to detect a broken track on the PCB.
This project required us to only use the images captured by the laboratory camera or our
own digital camera devices. In this project, Visual Studio C++ 2010 was used as the main
compiler with linked libraries to the OpenCV image processing library.
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 5/15
EEE 355 Robotics & Machine Vision
3 | P a g e
3.0 Methodology
A. Inspection Flow Chart
Load the image fromcomputer
Convert the images
to grayscale image
Threshold the image
Convert to binary
image
XOR operation on
the images
Resultant image
where defect
detected
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 6/15
EEE 355 Robotics & Machine Vision
4 | P a g e
B. Image Subtraction Operation
Well, this is the simplest algorithm that we can find to detect the
difference between the two images, i.e. to detect the defect on the PCB. In other word,
image subtraction is performed in order to get the difference between two images. Inthis algorithm, we need to use two images – reference image and the inspected image.
In this method, we compare both the images pixel-by-pixel using XOR logic
operator. After performing the operation, we will get the resulting image that consist of
the defects. The subtract operation produces either negative or positive pixel value.
Therefore the outcome of this operation is divided into negative image and positive
image.
Pixel [Image 1] Pixel [Image 2] Pixel [Output
Image]0 0 0
0 1 1
1 0 1
1 1 0
The overview of the XOR/Subtraction operation process is shown below :
To perform the image subtraction operation, it is required that both images has same size in
terms of pixels. The logical XOR operation will show us the defect in inspected image as
compared with reference image
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 7/15
EEE 355 Robotics & Machine Vision
5 | P a g e
C. OpenCV Functions Used
OpenCV function Explanation
Mat im_gray; Define the image matrix for “im_gray”
Mat im_rgb = imread( "PCB_no_defect.tif" ); Load the image “PCB_no_defect.tif” from
the disk and read it as RGB image.
cvtColor(im_rgb,im_gray,CV_RGB2GRAY); Convert the RGB image read to grayscale
image.
Mat result = img_bw_1^img_bw; Define the image matrix for result. The result
is obtained by XOR the reference image with
defected image.
namedWindow( "Display window1" ,
WINDOW_AUTOSIZE );
Create a window for display. The name of
the window is “Display window1”. The
window size is made to adjust automaticallyaccording to the size of image.
imshow( "Display window1" , result); Show the image “result” at “Display
window1”
imwrite( "Defect.jpg" ,result); Write the image “result” to the project
folder.
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 8/15
EEE 355 Robotics & Machine Vision
6 | P a g e
4.0 Results And Discussion
A) Top Lighting
RGB Image ( Reference image ) RGB Image ( Defected image )
Grayscale Image (Reference Image ) Grayscale Image (Defected Image )
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 9/15
EEE 355 Robotics & Machine Vision
7 | P a g e
Binary Image (Reference Image ) Binary Image (Defected Image )
Resultant image ( Defect detected)
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 10/15
EEE 355 Robotics & Machine Vision
8 | P a g e
B) Top and 2 Sides Lighting
RGB Image ( Reference image ) RGB Image ( Defected image )
Grayscale Image (Reference Image ) Grayscale Image (Defected Image )
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 11/15
EEE 355 Robotics & Machine Vision
9 | P a g e
Binary Image (Reference Image ) Binary Image (Defected Image)
Resultant image ( Defect detected)
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 12/15
EEE 355 Robotics & Machine Vision
10 | P a g e
As you can see from the result, we first load the RGB image, both reference and defected
image. Next we will then grayscale both image. The reason for differentiating such images
from any other sort of colour image is that less information needs to be provided for each
pixel. In fact a `gray' colour is one in which the red, green and blue components all have
equal intensity in RGB space, and so it is only necessary to specify a single intensity value foreach pixel, as opposed to the three intensities needed to specify each pixel in a full colour
image.
Next, we convert the grayscale image to binary image that consist only binary pixel ‘1’ or ‘0’
for easy operation process later on.
Now, after we get both the binary image, we perform the XOR operation to detect the
defected region on the image.
If there is no defect detected, the window will show as below :
No defects detected !
Comparison between two different lighting
As you can see from the result of two different lighting A) Top Lighting and B) Top and 2
Sides Lighting, the result is kind deviate a little under different lighting with constant
threshold value of 138. The result for B) are subjected to more noise. However, both the
type of lighting are able to detect the defect and show it at the final result.
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 13/15
EEE 355 Robotics & Machine Vision
11 | P a g e
5.0 Limitations
This image subtraction algorithm actually has a lot of disadvantages and limitations :
It only can detect for the broken track but cannot detect like short circuit, missing
components.
The images size must be the same (i.e. the reference image and defected image
must have same size)
Both the inspected image and reference image must have the same orientation.
6.0 Further Improvement
This project can be further improved by upgrading defect detection algorithm to suit a
variety of lighting conditions. Besides, we could improve the algorithm to detect different
kind of defects such as missing components or short circuits. Improvement can be made on
stating the location for the defect and calculate the size of the defect.
7.0 Conclusion
In conclusion, we manage to complete the project with a great success in testing and
coding for the defect detection on the bare PCB. Indeed, throughout this project, we have
learnt how to use the OpenCV library in Visual Studio C++ 2010. We were also exposed to
the effects of different kind of lighting condition which could affect the performance of the
algorithm.
This project enable us to apply the knowledge and theory that we learnt in class to solve
real life problems.
8.0 Reference
1. Convert RGB to Black & White in OpenCV
- http://stackoverflow.com/questions/1585535/convert-rgb-to-black-
white-in-opencv 2. Load, Display and Save Image
- http://opencvexamples.blogspot.com/2013/09/opencv-example-to-
load-and-display-image.html#.U4lu8vmSz2P
3. Detection of Bare PCB Defects by Image Subtraction Method using
Machine Vision
- http://www.iaeng.org/publication/WCE2011/WCE2011_pp1597-
1601.pdf
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 14/15
EEE 355 Robotics & Machine Vision
12 | P a g e
9.0 Appendix
#include<opencv2\opencv.hpp>
using namespace cv;
int main ( int argc, char **argv )
{
Mat dst;
Mat im_gray;
Mat im_gray_1;
//Mat im_gray = imread("PCB_no_defect.tif",CV_LOAD_IMAGE_GRAYSCALE);
Mat im_rgb = imread("PCB_no_defect.tif");
//Mat im_gray_1 = imread("PCB_defect.tif",CV_LOAD_IMAGE_GRAYSCALE);
Mat im_rgb_1 = imread("PCB_defect.tif");
cvtColor(im_rgb,im_gray,CV_RGB2GRAY);
cvtColor(im_rgb_1,im_gray_1,CV_RGB2GRAY);
equalizeHist( im_gray, dst );
Mat img_bw = im_gray > 138;
Mat img_bw_1 = im_gray_1 > 138;
Mat result = img_bw_1-img_bw;
namedWindow( "Display window1", WINDOW_AUTOSIZE );// Create a window
for display.
imshow( "Display window1", result); // Show
namedWindow( "Display window2", WINDOW_AUTOSIZE );// Create a window
for display.
imshow( "Display window2",img_bw ); // Show our image
inside it.
namedWindow( "Display window3", WINDOW_AUTOSIZE );// Create a window for
display.
7/18/2019 Machine Vision Project Report
http://slidepdf.com/reader/full/machine-vision-project-report 15/15
EEE 355 Robotics & Machine Vision
13 | P a g e
imshow( "Display window3", img_bw_1);
imwrite("im_gray.jpg", im_gray);
imwrite("im_gray_1.jpg", im_gray_1);
imwrite("im_bw.jpg", img_bw);
imwrite("im_bw_1.jpg", img_bw_1);
imwrite("Defect.jpg",result);
waitKey(0); // Wait for a
keystroke in the window
return 0;
return 0;}
Top Related