# Focus Estimation Methods for Use in Industrial SFF Imaging Systems
## 1 Introduction  
One of the rapidly growing fields of application of 3D imaging is the quality control (QC) of products on industrial manufacturing lines. QC tasks are carried out by using different vision systems and imaging methods. The selection of the imaging method depends on the range of inspection tasks to be carried out on the image, the required imaging resolution and the options for installation on the production line. Product inspection using a vision system is present in many industries for measurement tasks [1; 2], inspection tasks [3; 4], and production planning [5]. The main 3D imaging methods used in QC are laser triangulation [6], stereovision [7; 8] and time of flight (ToF) [9]. The scope of the application of each method varies due to hardware configuration, required imaging resolutions, and the influence of interference on the ability to produce a 3D image [10]. Laser triangulation imaging requires the use of a camera and a laser illuminator and the selection of a system geometry [11]. Regardless of the selected system geometry, the 3D image contains no-data areas, occlusions, resulting from the impossibility of illuminating or imaging all points on the surface. Stereovision imaging requires two cameras or a camera with structured light illumination. Significantly better images are captured by using additional structured light illumination. However, this only partially prevents the formation of occlusion areas in the 3D image. The ToF method is used for imaging in workspace inspection tasks. It allows for the reading of spatial information by measuring the wave propagation time. The method allows large spaces to be imaged but with significantly worse measurement resolution. This study uses the Shape-From-Focus (SFF) method to determine spatial information by analysing a stack of 2D images. Images are captured when the position of the image plane is modified. Images in the stack are captured at a different position in the image plane relative to the scanned object (Figure 1). By changing the position of the image plane, the focus of specific areas changes in the subsequent raw image. The analysis and selection of focused areas, together with information on the image plane position, allow the reconstruction of a 3D image. The development of the SFF method expands the potential for quality control of products under industrial conditions. Research on the SFF method is expected to increase the range of measurements that automatic inspection and measurement systems can achieve. Classic solutions were based on moving the imaging plane with the optics and camera on the \(z\)-axis. This method allowed the capture of image series of the XY-plane from different heights due to the camera's movement in the \(z\)-axis (Figure 1a). The time required to register the image series depended on the number of images and the speed of the camera. The disadvantage of this solution is the presence of a motor installed on the \(z\)-axis of the vision system which propagates vibrations when the position of the image plane changes [12; 13]. This paper presents an alternative solution for changing the position of the image plane in the \(z\)-axis without the need to move the camera. The use of a tunable liquid lens was proposed. Such a lens allows the optical power of the lens to be changed without camera movement and in a significantly shorter time (Figure 1b) [14; 15; 16]. An image stack was captured on a stand where the camera sensor was positioned parallel to the surface under examination. Using a tunable lens, the \(Z\) position of the image plane was changed, and successive images were registered. The tests were carried out on three flat surfaces made of different materials. The materials were selected based on an analysis of industrial QC tasks performed by vision systems. The test stand includes industrial-grade cameras, lenses, and illuminators. Industrial-grade materials were also selected for the stand to reproduce industrial conditions and possible interference accurately.