Dimensional inspection with camera

In terms of dimensions, a limited tolerance is defined for many parts or products produced in different industries. Product size is allowed to vary within this range. But how to do dimensional inspection of products? One solution is to select samples from the multitude of products. Measure different dimensions with the help of devices such as stencils, gauges, calipers or other measuring devices. In this method, since individual products are not checked, there are probably products that are not within the allowed tolerance range.

Inspection of dimensions

You might think that if we inspect each and every product in this way, the problem will be solved! But it is not. Regardless of the high cost of this work, we need to move the product in this type of inspection. At the same time, with the growth of automation in factories, the production speed of products is often so high that it does not allow moving and dimensional control of individual products in terms of time. But how to perform dimensional inspection at high speed and automatically on the production line?

Dimensional inspection with image processing on the production line

A quality inspector approves a product by observing its appearance and measuring its dimensions. By processing the image of a product, it is also possible to extract appearance features such as size. First of all, we need to take good pictures with an industrial camera and a suitable  lens , and in the next step, extract the dimensions of the product with the help of image processing software. In the figure below, you can see an industrial part whose size and internal radii are obtained by image processing.

Dimension inspection with vision system

How do we get the size of the product with the help of image processing?!

Let’s first talk about the concept of pixels. Pixel is actually the smallest part of any image that has constant color and brightness. The brightness is specified by a number between 0 and 250.

Pixel concept

In short, if we know the number of pixels between two points on the image and determine the size of each pixel in the real world by calibrating the camera, we can get the actual size by counting the number of pixels. But a question is raised here: Is the concept of pixel enough to specify the exact boundaries of an object?

Sub-pixel processing and the concept of edge detection

The borders of an object on the image appear as edges by changing the color and brightness. Edge detection is one of the most important and widely used techniques in image processing. Although an image is made up of thousands of pixels, the edges of an object, no matter how smooth, are rarely possible to precisely land on the boundary between pixels on a camera sensor. Therefore, the size of a pixel can limit the accuracy of the measurement.

Subpixel

To solve this issue, the researchers found methods to find the edges more accurately using the available data. The result of this research is to use the color change rate and intensity of adjacent pixels to convert a pixel into smaller pixels. These smaller pixels are called subpixels. In the case of edge detection with pixel component accuracy, the tolerances for measurements are reduced dramatically. In the figure below, the edge of the object is estimated using the above method. The red line is the line perpendicular to the edge along which the rate of change in the number of pixels is calculated.

Find the edge

Simultaneous role of camera resolution and lens magnification in dimensional measurement accuracy

One of the important parameters in a camera is the physical size of a pixel on the camera sensor chip. The size of each pixel on the sensor of a camera starts from about 10 x 10 microns and this size decreases with the increase of its resolution. One of the most important results that can be obtained from the two parameters of the pixel size in the sensor of a camera and the magnification of the lens used is the surface amount of the real environment that is received by a pixel.

Magnification / size of a pixel on the sensor = corresponding size of a pixel in the world

The calculated number will be the measurement accuracy (Resolution) when using this lens and camera. Of course, in software sections, using subpixel techniques, edges can be obtained with an accuracy of 5 to 11 times more accurate than this value.

The best lens for dimensional control: telecentric lens

The most important factors that have a negative impact on measurement accuracy are:

  1.  Inconstancy of magnification in normal lenses
  2.  image distortion
  3.  Problem caused by perspective
  4.  Lack of adequate contrast for reliable detection of edges.

By reducing or eliminating these problems , telecentric lenses have become a key component for the implementation and development of high-precision measurement systems. In the following, we will talk about the advantages of telecentric lenses that reduce the above problems.

Telecentric lenses

1. Constant magnification

In conventional lenses, when the object is moved, the size of the image obtained from the object changes according to the distance from the object to the lens, so that distant objects appear smaller and closer objects appear larger. In other words, the magnification of normal lenses is not constant and as shown in the figure below, the image of a distant object becomes smaller.

Change zoom

But as shown in the figure, in Telecentric lens the size of the image on the camera sensor remains unchanged by moving the object between points 1, 2 and 3. Of course, this property will exist in a certain range from the distance of the object to the lens, which is called depth of field or telecentric range. The reason for this is that in the telecentric lens, due to its internal structure, only light rays that are parallel to the axis of the lens pass through the lens, and the direction of these rays does not change when the image is moved.

Telecentric lens range

2. Reduction of sagging form (Distortion)

Distortion is defined as the percentage difference between the distance between one point of the image and the center of that image, in an image with distortion, and the distance between the same two points in an image without distortion. Positive circular deformation is called pincushion deformation and negative is also called barrel deformation. Two types of deformation are shown in the figure below.

From the form of image collapse

General optical systems show distortion in the range of a few percent to a few tens of percent, which makes the measurement significantly difficult.

3. Reduction of perspective effect

It was pointed out that in ordinary lenses, distant objects are seen smaller. As you can see in the figure on the left, the inner part of the hollow cylinder is visible, because every section of the object that is further away from the lens is seen smaller. But in telecentric lenses, which receive only light rays parallel to the axis of the lens, a two-dimensional match between the object and the image is created, which is very suitable for measuring the profile shape, by removing and not displaying one dimension.

Reducing the perspective effect

 4. Proper clarity of the image

Since the telecentric lens structure is compatible with high-resolution cameras, these lenses are a good choice for dimensional measurement applications.

Telecentric lens resolution

How to calibrate the camera with dimension processing software?

As mentioned, image distortion can be reduced by improving the equipment, in addition, these deviations can be reduced to an acceptable level with software calibration. For this, a specific pattern is placed in front of the camera. This pattern with exact dimensions is defined in the software. By calculating the difference between the default pattern and the image taken from it, the software finds parameters to compensate for deviations so that it can apply these parameters to other images. These parameters can be placed in two different categories.

Camera calibration

 1. Calibrate the camera’s internal parameters

When using any type of camera and lens, due to their internal structure, there are deviations in the obtained image. One of the most important of them is radial distortion. Circular distortion causes the straight lines in the image to bend. Another deviation is the stretching of the image in the parts far from the center of the image; which is called trapezoidal deviation. These deviations are defined in the form of 5 to 9 parameters depending on the technique used and can be calibrated. In the figure below, circular and trapezoidal deviations are shown from right to left.

Circular and trapezoidal deviation

 2. Calibrate external camera parameters

External parameters of the camera include all parameters that result from the position of the camera relative to the object. In simpler words, converting the dimensions obtained from the image with pixel units to real-world units such as millimeters requires the calibration of the external parameters of the camera.

Applications and advantages of dimensional measurement in machine vision systems

As mentioned, with the help of machine vision , different dimensions of objects can be measured at high speed and determine whether they are within the defined tolerance range or not. The following are common applications of machine vision in measurement:

  • Measuring the dimensions of parts or products
  • Measurement of internal or external diameters
  • Measuring the roundness or tip angle of metal parts
  • Measure the position of edges and labels
  • Measuring the width of sheet products and thin layers

In the figure below, you can see examples of measuring the position of the edges and the degree of roundness.

Dimensional control with image processing

Dimensional control with machine vision

In the image below, different dimensions of the bottle opening and a capacitor have been obtained with the help of machine vision.

Finding dimensions with image processing

Dimensional inspection using a machine vision system can check the size of products during production and 100%. This ensures the stability of product quality. At the same time, this system is much less expensive compared to most advanced dimension measurement methods, including optical comparators, GD&T measurement systems, and 3D measurement systems.

This type of inspection, in addition to dimensional errors of the product, also provides data on the exact size of different parts. This data can be easily stored and managed. Such information can be effectively used to manage production line errors or improve the process.

Leave a Reply

Your email address will not be published. Required fields are marked *