How to build an AI-powered Automatic Visual Inspection system from scratch Part 2 (WIP)

Jamie Geng
8 min readJul 6, 2024

--

Part 2: Hardware

In this chapter, I will introduce the necessary hardware components for an inspection machine. If you are building your own machine, this information can be highly helpful. But if you already have a fully functional automatic inspection machine, feel free to skip this chapter.

Light

“And God said, ‘Let there be light,’ and there was light. God saw that the light was good, and he separated the light from the darkness.” — Genesis 1:3–4

Whether for automatic visual inspection or manual inspection, light is probably the single most important element. With proper lighting, the details of the objects being inspected become clearly visible. Adequate lighting also enhances contrast, making it easier to distinguish defects.

On the other hand, an improper light setup may make the defects invisible, either because of insufficient lighting or too many reflections. Different kinds of lights and different positions of lights can have a huge impact on how the inspected items are displayed. Hence, it is important to pick the right setup based on your needs.

Different light sources can make the inspected item displayed differently (Cognex)

Light positions

Front Lights

Front light is the most common choice if one wants to inspect the surface of an object. It is a good choice when you need to examine for scratches, discolorations or cosmetic defects.

The angle between the camera and the light needs to be carefully calibrated when inspecting surfaces that reflect light, such as glass and metal. A wrongly positioned light can reflect all the light into the camera and completely blind it.

To reduce reflections from the surface one alternative is to use a method called dome lightning.

Dome Lightning (COGNEX)

Dome lighting provides uniform light from various angles which results in no glare, even on mirrored objects. It’s often referred to as “cloudy day” illumination since it removes uneven lighting (glare/shadows) and evenly spreads the lighting across the surface of the part.

In some cases, we would like to inspect the outline shape of measurement of an object, and do not really care about the apperance of the front surface. We could utilize back lightning for these scenarios.

Back Lightning

Normally with well diffused front lights and back lights you can visually inspect the majority types of defects. But there are many other options you can choose from, you can decide on which types of light to use or combine and mix up those lightning options based on your own needs.

Various other lightning options

Some other factors you also might want to test it out are distance and intensity. Do spend some time and experiment different set-ups and pick the ones that provides the most optimal visual appearance.

Light Color

The most common color used in machine vision is white, specifically strong, bright white light. However, in some circumstances, a light source with a different wavelength might produce the exact effect you are looking for.

A popular alternative to traditional LED white light is infrared(IR) light . Infrared(IR) light is more difficult to set up, but it does provide an advantageous edge over white light.

  • Reduced Glare and Reflection: IR light can reduce glare and reflections from shiny or reflective surfaces, making it easier to capture clear images of objects with such properties.
  • Improved Contrast: IR light can enhance the contrast between different materials and surfaces, especially those that have similar colors in the visible spectrum but different IR reflectance properties.
  • Penetration Through Materials: IR light can penetrate certain materials (e.g., plastics, fabrics) that are opaque to visible light, allowing for inspection of hidden features or subsurface defects.
  • Thermal Imaging: IR light can be used for thermal imaging, which is useful for detecting temperature variations, heat leaks, and other thermal properties.

Camera

Cameras are like eyes to the machine. A good camera captures high-quality images, provides precise and accurate data. There are various types of cameras to choose from, and once again, each type has its own optimal use cases. Therefore, select the camera that best fits your needs.

Mono vs Color

Color vs Grayscale

Monochrome cameras capture only the intensity of light in grayscale, while color cameras can capture color images in the form of Red, Green, and Blue (RGB) information at each pixel. RGB images provide more information for deep learning models, but they also require more computational resources. And as expected, a color camera is normally more expensive. For certain types of defects, when color is not important or does not help the model improve its decision-making, we should simply spend less money and use a monochrome camera.

Area-Scan vs Line-Scan

Another choice you can make is between area-scan camera and line-scan camera A simple way to understand the difference is that an area scan camera takes a single photo of a square or rectangle at a time, whereas a line scan camera takes hundreds of 1D pictures in a sequence and combines them into a picture of the same 2D area. This is extremely helpful when inspecting continuous or fast-moving objects, such as those on a conveyor belt, where high-resolution images of large surfaces are required without the distortion that might occur with an area-scan camera.

Camera Specifications

When you try to purchase a machine vision camera, you will run into one of those specification sheets. The amount of information might seem overwhelming at the beginning, and I will try to explain the important ones here.

An example specification page for a machine vision camera

Resolution

Low Resolution vs High Resolution

In digital photography, resolution is the level of detail contained in an image. More specifically, it refers to the number of pixels that exist within that image. The higher the resolution, and the richer the pixel count, the more detail and definition you will see. If you are looking for small elements such as particles and fibers, you should purchase a camera with high resolution.

Frame Rate

The frame rate, measured in frames per second (fps), indicates how many images the camera can capture per second. Higher frame rates are essential for capturing fast-moving objects.

Data Interface

The type of interface (e.g., USB, GigE, Camera Link, CoaXPress) affects the data transfer speed and the ease of integration with other systems.

  • Cable length: Different interfaces support different maximum cable lengths. For example, USB 3.0 typically supports up to 3 meters, while GigE can support up to 100 meters.
  • Ease of Integration: Consider the ease of integrating the camera with your existing systems. Some interfaces, like USB and GigE, are more plug-and-play, while others, like Camera Link and CoaXPress, may require specialized hardware and software.
  • Power Delivery: Some interfaces, like USB and PoE (Power over Ethernet), can provide power to the camera, reducing the need for additional power supplies and simplifying the setup.

Lens

Camera Lenses

If cameras are like our eyes, then lenses are like our, well, eye lenses. A lens can do things like:

  1. Focus Light: The lens helps to gather light from the scene you want to take a picture of and focuses it onto the camera’s sensor. This makes the picture clear and sharp.
  2. Zoom In and Out: Some lenses can zoom in to make faraway things look closer or zoom out to show more of the scene. It’s like using binoculars to see things far away or stepping back to see a whole room.
  3. Control Brightness: The lens can also control how much light gets into the camera. If it’s too bright, the lens can make it darker, and if it’s too dark, the lens can let in more light.

Without a lens your image will turn out like this.

So when you buy a camera, always remember to buy a compatible lens.

Lens setting and calibration

C Mount Lens For Machine Vision Camera , Manual Focus And Aperture Adjustment 16mm Lens

For the majority of lenses, users can manually adjust the focus and aperture. After installing the lenses onto the cameras, you should also perform a routine to calibrate the lenses.

  1. Focus: In photography, adjusting the focus means making the image of a subject as sharp as possible by changing the distance between the lens and the image sensor. You should set the right focus value through trial and error.
Out of Focus VS In Focus

2. Aperture:

Aperture refers to the opening in a camera lens through which light enters to reach the camera sensor. he size of the aperture can be adjusted to allow more or less light to pass through the lens.

Same object under different aperture value

3. Lens Calibration:

Geometric calibration refers to the ability of a camera to translate a 2D image into a 3D object to map the real-world field of view. This involves calibrating the camera to correct for lens distortions and to ensure accurate measurements. This is crucial for applications that require precise dimensional measurements. Normally you can use a checker board as the target to test on, but I am no expert in camera calibration. Please consult your robotics engineers or vision specialist to do it.

Calibrate the camera by using a target

Other Components

PLC

Conveyor belt

Rejection System

3D Printers

--

--

Jamie Geng
Jamie Geng

No responses yet