See how we are responding to COVID-19 and supporting our employees and customers

AI Inspection Using Analog Gauge as an Example

Analog Recognition with AI

Nowadays, AI visual inspection is widely used for defect detection and quality control. Solutions based on AI identifying and analyzing quality issues provide preventive maintenance and cut overhead expenses for business owners.

How does visual AI inspection related to analog gauge happen? One needs to read and verify analog gauges to spot errors concerning drift, environment, electrical supply, and so on.

In order to read information from the analog gauge, we need to do two things:

  • Detect the bounding box of the analog gauge in the picture
  • Read values from the analog gauge.

Since it’s a tedious and time-consuming task, automation seems like a plan. AI offers an automatic reading approach that simplifies the procedure and allows to detect anomalies and prevent production line stoppage.

Visual Inspection: Object Detection

The most efficient way to detect objects in an image for today is an approach based on convolutional neural networks. In general, the problem of object detection today can be considered solved, if you have a sufficiently large and sufficiently diverse dataset, then there is no problem to train the object detection model. Let’s take a quick look at what a complete learning process usually looks like. Typically, the process includes the following steps:

  • Unlabeled data preparation
  • Dataset labeling
  • Model Training

Object Detection

At each of these steps, there are many options for what tools to use to complete it, let’s dwell on each in more detail.

Unlabeled data preparation, at its best, assumes that data in your company came about in some natural way. For example, your company is engaged in AI-driven inspection and you already have many analog gauge images from practice. You even have computer vision predictive maintenance solutions. If there is no data, then you can always try to buy it from such companies or from companies that specialize in datasets labeling. There are other ways as well, but they are more likely to collect data in order to make a POC. This, for example, collecting data through crowdsourcing or using utilities such as google-images-download.

With dataset labeling, everything is easier, you can take almost any tool for labeling images, for example, labellmg or CVAT.

As for training the model, although this is not the most trivial task, a large number of frameworks are available and a lot of tutorials have already been written on how to use them. This is a big topic, so here are just some of the tools you can use during this step: mmdetection, detectron2, tensorflow object detection API, etc. These frameworks allow you to choose the right balance of processing speed and accuracy by providing different backbones. Including there are solutions that will allow you to work in real-time.


The second step today cannot be called a solved task. Let’s take a look at several options on how to do this.

Recognizing Analogs

Classical Computer Vision Approach

Let’s start with the classic approach. It essentially consists of two algorithms:

  • Circles detection
  • Lines detection

Further, having a circle, and knowing the position of the needle, knowing the model of the analog gauge, we can accurately find out the value to which the needle points.

This can be done using OpenCV. You can find more details on this here and there. Here’s how it looks on this pressure gauge image:

CV Based Approach

The bad thing about classical methods, however, is that they are not robust. Problems can arise from unusual or strong lighting, dirt, the specific shapes of the analog dials, and many other things. In any case, it is impossible to predict everything, and often, for the most unusual reasons, something may go wrong. Here are some examples:

For example, in this picture, a circle was detected incorrectly.

Recognized Analog
And here, the needle was detected from the opposite side. This may well be considered a false positive.

In addition to these errors, of course, the most frequent ones are when not a single circle or line was detected. For each specific picture, this can be corrected so that the algorithm works, but in the general case, it is impossible to foresee all the options. It is instability that makes the use of classical computer vision algorithms niche. This approach only works if you are completely confident in your data and that it will never change, and if it does, then within some reasonable limits. Therefore, for cases where the data may change significantly, other approaches are required.

AI-Based Visual Inspection

The advantage of deep learning and AI algorithms for predictive maintenance is that they are usually much more robust. This is achieved due to the fact that during the training of the algorithm, the model learns from the dataset all the variety of possible options that are there, and in the end, it turns out that the model learns to recognize key features, ignoring things like lighting, dirt, etc. Of course, it is possible only if the data is diverse enough.

There are at least several options for how you can solve this problem using neural networks. For example, a key-points detection-based approach, where you need to train the model to detect the center of the circle and the needle end. Knowing this, we can find the angle at which the needle is turned and, knowing the analog gauge model, determine what value the needle shows.

AI Visual Inspection

It is also a possible option when we need to detect the needle itself, and because we generally know the position of the center, due to the fact that the analog gauge always has the shape of an ellipse, which means that it is symmetrical. But since we have already detected it at the previous stage, then we can assume that the center of the circle will be right in the center of the object detected at the first stage. This option seems less accurate, but it is easier to train such a model.

AI Visual Inspection

The third option is to segment the dial and then try to predict the angle of rotation of the needle. This option is discussed in more detail here, and there are a lot of tricks that are improving efficiency, but in short, the advantage is that the data can be artificially generated by having examples of empty dials and turning the arrow artificially.

 Recognition of Analogs AI

But, as noted above, all variants based on CNN have a significant disadvantage – they require data and labels.

Using of OCR

We have not yet mentioned the fact that different sensors have different scales. This problem can be solved for example with the help of OCR. Even though not all values can be recognized, if we can restore the circle, using this machine learning technology it is possible to restore the values on the scales. Here’s an example of how the Google Vision API being within the Google Cloud ecosystem, works:

Analog Recognition

Why Build an AI Visual Inspection System? The Takeaway

Analog gauge recognition is only one example of how you can automate visual inspection. Using data science and especially deep learning it looks like it is possible to build an almost fully automated visual inspection system. At least it is definitely possible to remove the most annoying and routine visual checks which humans do manually. And although this will not help in rare cases with specific gauges or where some deep expertise is required, it still seems that AI-driven inspection can significantly reduce the costs on many manufactures.

Analog Recognition with Artificial Intelligence

Have a project related to analog recognition? Want to use AI for predictive maintenance? Get help from a team of skilled AI architects and engineers.