Development of a machine vision system for fluids metrology

1 UFF, Computational and Dimensional Metrology Laboratory, Rua Passo da Patria, 156 Niteroi, Brazil 2 Inmetro, Radiometry and Photometry Laboratory, Rua Nossa Senhora das Graças, 50 Duque de Caxias, Brazil 3 Inmetro, Dimensional Metrology Laboratory, Rua Nossa Senhora das Graças, 50 Duque de Caxias, Brazil 4 Inmetro, Fluids Metrology Laboratory, Rua Nossa Senhora das Graças, 50 Duque de Caxias, Brazil


Introduction
Machine vision is a field in constant development. From the digital camera sensors' conception in the late 1960s to this day, their resolution has greatly increased, and nowadays every smartphone has a sensor with at least 5 MPixel resolution.
However, traditional cameras are hardly sought to be used on scientifically applied machine vision inspection or measurement systems. Digital single-lens reflex (DSLR) cameras enable users to have control over many of the cameras' operational parameters, such as aperture, exposure, etc. With such control, there's a wide variety of parameters to determine in order to find the best conditions needed. Machine Vision Systems (MVS) in general can provide different types of measurements, direct or indirect, with the end result being a matter of choosing the correct combination of hardware (camera, lenses, lighting, etc.) [1].
Metrology is the science of measurement and is responsible for providing reliability in the results on all measurements, including those of the industrial production. It is in constant evolution, always in search of innovations for its measurement procedures, with new techniques and instruments, to lower the measurement uncertainty of the results. The usage of an MVS in a Metrological application leads to the creation of an Image Metrology System (IMS), constituting the same steps of a regular MVS, but with Metrological reliability and traceability.
The quantities of kinematic viscosity and density, both from the Fluids Metrology Laboratory (Laflu) of Brazil's National Metrology Institute (National Institute for Metrology, Quality and Technology), require dimensional measurements to determine their respective results, which an IMS is capable of providing with traceability and reliability.
The purpose of this paper is to outline the steps necessary to develop a Fluids Metrology IMS, from the acquisition step to the uncertainty report.

The Fluids Metrology IMS
The measurement of kinematic viscosity using capillary viscometers and density with hydrometers have, among their influence quantities, several dimensional parameters, some of which are not measurable with conventional methods, such as calipers, micrometers or Coordinate Measuring Machines.
An IMS may consist of the following steps, all from regular MVS': acquisition, image processing, feature extraction, recognition, classification and decision making [1]. The most critical of those steps for an IMS are the acquisition and image processing, which are in charge of providing the Metrological traceability. The latter steps revolve around providing a measurement result and its accompanying measurement uncertainty.

Acquisition and lighting
The acquisition step involves both the camera acquisition hardware and the lighting system. With the numerous possibilities of a DSLR camera parameters, they must be analyzed with caution to determine the best possible combinations in order to have an exact and reliable results. Methodologies have been developed in order to determine the best aperture [2] and exposure time [3] for image acquisition of glassware.
Lighting conditions have also been studied [4,5] and a proper lighting system has been developed for glassware, as can be seen in Figure 1. This is an Open Access article distributed under the terms of the Creative Commons Attribution License 4.0, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Image processing
The image processing step consists on manipulating the acquired image in order to separate the mensurand from everything else in the image (which is considered background). This is done first by image segmentation which, using Otsu's algorithm [6], will provide a binary image in which every pixel with the value 0 is background and every pixel with the value 1 is the mensurand.
However, after segmenting the image, the mensurand will not appear ready to be measured. For example, the inside of the mensurand may appear "hollow" or even areas in the image which had higher light intensities may be mistaken for the mensurand by the algorithm. The processing step ensures that the image to be measured contains only the mensurand with pixel values of 1. Figure 2 shows both cases and the result of processing.

Measurement
After the image has been processed, the object is ready to be measured. Considering an image I with H lines and L columns in which the mensurand is centered in it, its diameter d(i) is given by summing, for each line i, the pixels of said line. Since pixels will either have a value of 1 (object) or 0 (background), d(i) will, therefore, be the measurement of object's diameter, as can be seen in Figure 3 and equation (1).
This measurement, however, is given in pixels and thus needs to be expressed in a proper lenght unit. For this, the dimension of the pixel must be determined. In order to create a proper metrological traceability chain another object, with known dimensions -a dimensional standard, must be measured in the same conditions. The pixel length (l p ) is, then, the ratio between the dimension of the standard in millimeters (p mm ) and the same dimension in pixels (p pixel ), as shown in equation (2).
This measurement methodology ensures that the measurement will have metrological traceability, as can be seen in figure x.

Uncertainty evaluation
By combining equations (2) and (3), a mathematical model for image measurement can be obtained, as seen by equation x.  (4) With this equation and following the guidelines of ISO GUM [7], an expanded uncertainty can be determined, with 95,45% coverage probability and infinite degrees of freedom.

Web of Conferences
For this case in particular, the sources of uncertainty are each of the components of the mathematical model (the object's diameter in pixel, the standard's dimension in millimeters and the standard's dimension in pixel) and the repeatability of the measurements of d mm .

Application of the IMS
In order to analyze this methodology, two hydrometers and two capillary viscometers were used. For the repeatability analysis, each object was measured five times in three different positions, rotated around its own axis to ensure that the measurement is homogenous.
For the acquisition step, the camera was configured for an aperture of f/5.6 [2] and an exposure time of 1/80 [3].
The mensurand of the hydrometers was the diameter of its stem. For the capillary viscometers, the mensurands were both upper and lower traces.  The results from the IMS for each instrument are show below, with Table 1 for the hydrometers and Table  2 for the capillary viscometers.

Measurement uncertainty
The measurement uncertainty analysis of the IMS is shown below in Table 3 for the hydrometers and Table 4 for the viscometers. The tables show the combined uncertainty for all uncertainty sources (as determined in item 2.4) as well as the effective degrees of freedom and coverage factor that allow for the calculation of the expanded uncertainty [7].

IMS Analysis
With the uncertainty for all the sources, it is possible to evaluate how each source contributes to the final expanded uncertainty.
In an IMS that which contributes the most is the pixel measurement itself, followed by the measurement repeatability [8]. The pixel measurement itself, as stated above, consists of the lighting, acquisition and image processing steps.
It can be observed in the zoomed images of Figure 6 that this measurement is sensitive to all sorts of irregularities of the object. These may be from the material itself or even a result of the segmentation algorithm, that defined those border pixels as image or background based on its value.

Conclusion
Throughout this paper, the importance of every step in a Machine Vision System (MVS) has been thoroughly explored for such a system to be used in Metrology. This led to the creation of a special MVS, called an Image Metrology System (IMS).
An IMS for Fluids Metrology has been proposed in this paper, developing a complete methodology that encompasses from lighting and acquisition to the expression of the measurement uncertainty.
Two types of Fluids Metrology instruments were used as a case study for this IMS: a hydrometer and a capillary viscometer. By measuring certain dimensional parameters of both instruments, it was possible to not only extract a result for it with metrological traceability, but also express a measurement uncertainty.
By detailing the uncertainty result, it is possible to determine that the pixel measurement is the uncertainty source that contributes the most for the final expanded uncertainty. This measurement is the direct result of the acquisition and image processing steps, which only serves to stress the importance of using a reliable methodology for measurement, since the slightest mistake can lead to a high expanded uncertainty.
However, a high uncertainty may not be disregarded as a bad result. It is only the result of a much thorough measurement, which will analyze pieces of the object in the order of the hundredth of a millimeter, in this case.