Europe Union

Defect Detection with Computer Vision: How Does an Inspection System Work?

Defect detection with computer vision is using artificial intelligence and computer vision technology to automatically detect product defects on the surface level. Such defects can be cracks, size irregularities, uneven paint coating or other imperfections that impacts product quality, and that’s why this application of computer vision is part of manufacturing quality control processes.

It works like this. Cameras capture images of products which are then analyzed using computer vision system. The system detects defects and classifies them based on its learned patterns.

Computer vision defect detection can catch lower quality products and notify you of what kind of problems they encountered. Let’s explore how it works in more detail.

1. A Bit of Background on Computer Vision

Computer vision enables computers to interpret, analyze, and make sense of visual data that is captured by cameras. Its goal is to replicate human vision and recognizing objects, analyzing scenes, and understanding spatial relationships.

As Marek Tatara explained in one of our webinars, computer vision originates somewhere in the 1950s and 60s, two decades that also marked the development of artificial intelligence and machine learning. One of the earliest ways of how computer vision worked was edge detection which helped trace object boundaries in images and made the computer recognize what’s being examined. This era was also marked by the invention of the perceptron, an early artificial neural network model that set the ground for modern deep learning.

One notable breakthrough in computer vision was a machine that could scan documents and read them aloud for visually impaired individuals. If you consider the technological constraints of the time, this was an impressive achievement and demonstrated the potential of automated image processing. Nowadays, computer vision evolved and plays a crucial role in various industries. You may have heard about its application in the automotive sector where it is used to detect objects and determine their distances. In manufacturing, however, it is used for defect detection, which we will explain in this article.

A timeline of computer vision evolution that gives a reader a background information about computer vision

2. Why Is Computer Vision Used for Defect Detection?

Computer vision is used for defect detection because it offers several advantages that make it particularly effective in this area.

  • It’s precise: It can accurately analyze images to identify flaws on the surface of the product and inside of it.
  • It’s non-invasive: It can spot defects without damaging the product.
  • It can spot a wide range of defects at the same time: Computer vision can handle a variety of defects at the same time.
  • It can measure wastes generated by defects: The data from computer vision can be used to generate reports and analyses.
  • It can classify defects: Computer vision systems can categorize defects based on type when trained to do so.

Let’s Figure Out The Best AI Use Case for You.

Complex factory setups, space constraints, or unique integration needs? We can help you. Schedule a workshop with out experts will help you build a clear roadmap for introducing AI to your plant.

3. What Are Computer Vision Tasks in Defect Detection?

Computer vision performs several critical tasks in defect detection, each designed to analyze and interpret visual data to identify product flaws.

A graph that shows three images:example of classification, detection, segmentation, which are three computer vision's job.

Source: Object Segmentation vs. Object Detection – Which One Should You Use?

Classification

The system evaluates an image and tries to recognize whether any anomalies exist in the image as a whole. The classification can either be binary (defective vs. non-defective) or multiclass (classification with more than two classes).

Object Detection

Object detection goes a step further. It shows the exact location of defects. It highlights them with bounding boxes.

Read also about Foreign Object Detection.

Image Segmentation

Image segmentation isolates defective regions down to the pixel level.

Read our expert’s insights: Using Depth-Enhanced Segmentation in Forestry.

3. What Do You Need for Defect Detection with Computer Vision?

For this, you’ll need a camera for data acquisition, a processing algorithm, and an alarming system.

The camera provides the input. It captures images or videos of the product. The equipment should be stationary, installed above or at a fixed angle, so it can take the same pictures over and over.

Then, a processing algorithm takes the input from the camera and identifies defects in the product. Before it can do that, it needs to be trained with a referenced dataset that contains the pictures of a high-quality product as well as defective products.

Apart from detecting defects, some manufacturers request an alarming system that notifies them about the spotted defects. A system like that can also display an image, so it’s clear what the defect is and where it is located.

4. How Does Computer Vision Defect Detection Work?

Step 1:
Data collection

Defect detection with computer vision begins when a camera captures images or videos of a product that’s in the factory. The cameras can be installed in the production or assembly line, inside machines (machine vision), or at some other strategic points where manufacturers need to control quality like packing stations.

Step 2:
Data processing

What you see is an image. But what computer sees? It needs to process data to see. It uses a trained algorithm to do so. This algorithm is a neural network that consists of layers of artificial nurons that work together. There are two architectures for defect detection andwhich one will be used depends on the type of data we have. They can either be:

  • Convolutional Neural Networks (CNNs): CNNs are used for defect detection in static images. They use mathematical operations like convolution to identify patterns such as edges, textures, and shapes.
  • Recurrent Neural Networks (RNNs): RNNs process sequences of images to identify relationships over time.

Before the system can recognize defects, it goes thorugh a training phase. The model gets tons of labeled examples, marked as either “defective” or “non-defective.” Over time it learns to recognize patterns associated with defects. Every model needs to be trained and if you want to learn more about it, read our article about golden datasets.

Once the model is trained, it can inspect products and evaluate whether they are within acceptable quality standards. If a defect is identified, the system can flag the item for further inspection, reject it, or trigger an automated quality control action.

5. Examples of Defect Detection with Computer Vision

Example 1:
Bottle cap inspection

Let’s say you work in the beverage industry and need to check if your bottle caps are sealed before they can leave the production line. To check that, you install a computer vision system that inspects bottles that move through the production line. Your system uses hardware to capture images and AI algorithms to analyze these images and detect issues like missing caps, misaligned caps or problems with sealing. Once the system finds the defect, it triggers an alert to the quality inspector or automatically remove the faulty bottle from the line. This prevents PR nightmares and high returns. Read more about quality control in bottles.

Example 2:
Wood panel gaps identification

Now, you’re changing the line of work and start your job at furniture manufacturing. You need a system that spots uneven gaps between wood panels that indicate poor assembly. You install a camera-based computer vision system that scans wood planks to detect the gaps and flag panels that do not meet quality standards. We worked on a similar case. Read about wood inspection here.

Example 3:
Precast concrete inspection

What about concrete? Computer vision helps here too. We’ve created a vision system designed for this environment that inspects concrete elements during the manufacturing process. It detects precast concrete that strayed from design specifications. It does so because it compares images taken by a camera with BIM data. See how OkKast brings automation to industrial quality control.

6. Challenges in Defect Detection with Computer Vision

There are several challenges that must be addressed to achieve accurate and efficient defect detection results, namely the physical conditions, proper training, and scope of computer vision.

Challenge #1: Lighting Variations

One of the biggest challenges in defect detection with computer vision is dealing with lighting variations that affect image quality. Shadows, glare, reflections or insufficient brightness can make it harder for computer vision to identify defects accurately.

Poor lighting can also obscure important details. For example, glare from overhead lights may wash out fine cracks, while shadows can hide small imperfections. Additionally, changing light conditions throughout the day can create inconsistencies in the images captured by the system.

It’s important to train the algorithm on images taken under different lighting conditions. This helps the model adapt and recognize defects accurately. Proper lighting setups, such as diffused lighting, backlighting, or polarized filters, can also minimize shadows and reflections, improving detection accuracy.

Challenge #2: Need for Model Training

No two production lines are identical, and the types of defects encountered can vary widely depending on the material, product design, and environmental conditions. That’s why you need to train the model to address the specific defects, products, and conditions of the manufacturing site. 

To ensure that your system is effective, you need to train the model on a dataset that represents the variety of potential defects, normal products, and operational conditions in their unique environment. This includes variations in product appearance and realistic scenarios that reflect day-to-day challenges.

A well-trained model can accurately differentiate between true defects and acceptable variations, minimizing precision and recall. Some professionals use techniques like data augmentation to expand the training dataset. They manipulate the original images to artificially create new ones. The outcome? The data processing system is more accurate at spotting defects.

Computer Vision Development Process

Challenge #3 Occlusions

When placing a camera  for defect detection, one major challenge is occlusion which means that parts of an object are blocked from view. Objects may overlap or be partially hidden, making it difficult for the system to detect all defects accurately. This can result in missed flaws or incomplete inspections.

To overcome this issue, manufacturers can position multiple cameras, each at a different angle, to provide a more comprehensive view. Additionally, 3D imaging or depth sensors can help capture hidden defects by analyzing the shape and structure of objects to make the inspection process more reliable.

7. Build a Custom Defect Detection with Computer Vision with Us

Every manufacturing process has unique quality control requirements, and a one-size-fits-all solution may not be enough. If you feel that an off-the-shelf solution doesn’t fit your requirements, whether it’s the need for precise system, unique defect types or a customized production process – we’re here for you. By partnering with us, you get a tailor-fit solution that detects tiniest of defects.

Start with POC before the full roll-out. Build a Custom Computer Vision system with us.

Our experts in computer vision will be happy to help you find the best solution to meet your needs.