## 2 Methodological Approach
### Object Detection Based on CNN  
The first step of the algorithm is the detection of the gauge in an image using a trained CNN. Therefore, a dataset was created with a small number of images--204 images from 3 different sources. Due to the limited number of available datasets, most images were taken from a phone camera in the shop floor of the Institute of Science and Innovation in Mechanical and Industrial Engineering (INEGI) and the other two sources, as shown in Table 1. The dataset was composed of different types of circular gauges, such as gauges with two pointers, multiple scales, multi-color dials, and gauges with different ranges of scale values. There were also images with long-distance and short-distance shots, various shooting angles, and even some with reflections in the dial. Moreover, to create a consistent dataset, all the images were modified to obtain a 1:1 aspect ratio and a resolution of \(800\times 800\) pixels, then they were manually split into a train and a test set using a 70:30 ratio.  
Several data augmentation techniques were applied while training the CNN models to mitigate the problems of a small dataset. These augmentations can be divided into position and color augmentation. In position augmentation, the pixel position of an image is changed, such as cropping and padding images, which helps to imitate the zoom in and out effects. Another example is the common augmentation of flipping the image. On the other hand, color augmentation only alters the values of the pixels, maintaining the same position. Good examples of this are the manipulation of the contrast, saturation, hue, and brightness of the image but also adding noise, which is considered a powerful augmentation method that improves robustness without compromising accuracy [22]. The augmented images show notable changes from the original images, as illustrated in Figure 3, which help to create a diverse set of training images from a small dataset.  
The model used to detect gauges was selected from a tensorFlow collection of object detection models pre-trained on the COCO 2017 dataset [19]. First, a selection was made by choosing only models with an input image resolution close to the resolution of the dataset (\(800\times 800\) px), and the ones with the highest Mean Average Precision (mAP). Afterward, the models selected were trained until 7000 steps with the target dataset to determine the best-performing model. To avoid overfitting, the evaluation and train loss functions were continuously monitored to verify their convergence. These functions are shown in Figure 11, where it is noticeable that the training and the evaluation loss stay close and decrease over time, which indicates that the models do not have overfitting problems.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Source** & **Nr. of Images** & **Types of Gauges** \\ \hline INEGI & 118 & 21 \\ AWS [20] & 37 & 1 \\ jfcvision [21] & 49 & 3 \\ \hline Total & 204 & 25 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Dataset composition.  
Figure 2: Flowchart of the proposed steps to read analog gauges.  
The results in Figure A2 demonstrate that most of the models reached close to peak performance in as early as 1000 steps, which can be explained by the small dataset that these models were trained on. Furthermore, the maximum mAP and recall for most models were above 90 % and very close to each other, which indicates that choosing any of these gauge detection algorithms would yield good results. However, for the proposed algorithm, the model selected was the CenterNet HourGlass104, which yielded the best performance out of all the models tested; these results are shown in Figure 4. Therefore, this model was implemented as the first step in the algorithm to find the Regions of interest (ROIs), as shown in Figure 5.