4
$\begingroup$

I have a simple gauge displaying analog values ranging from 0 to 4. Here is an image of the gauge. Unfortunately there is no way to get a analog or digital signal for the value.

How do I read the value of the gauge?

My idea is to make an image every 5 minutes and get the value by analyzing it. I am thinking of manually generating reference images with the black needle in different positions and then compare it to the real image.

Since all the processing should be done on a raspberry pi without internet connectivity, a good approach would be a preconfigured docker image for image comparison which helps doing the image comparison locally, maybe supported by a python or php script.

How to proceed?

$\endgroup$
  • $\begingroup$ Why the heck a -1 voting? What's wrong with this question? $\endgroup$ – WeSee Nov 2 '17 at 17:55
  • $\begingroup$ Is this too simple? Please give me a hint, where this has already been solved... $\endgroup$ – WeSee Nov 2 '17 at 17:55
  • 1
    $\begingroup$ Downvotes without explanation (and often without obvious reason) are common here, don't worry about it. It might have been because your question is not a real AI question, but can rather be solved with a simple image processing algorithm. Nevertheless, Computer Vision is considered an important part of AI development right now, so I think it can be argued that the question is still on topic. +1 from my side for the interesting challenge. $\endgroup$ – Demento Nov 2 '17 at 20:15
1
$\begingroup$

This is a simple digital image processing task. I am proposing a quite efficient solution without any error correction mechanism, so this is not a production quality approach. But as a first proof of concept it should do the trick.

The easiest approach would be splitting the image in two channels - one for the color red and one for the color black. You can neglect the rest outside a certain threshold. If the lighting is good, this should also deal with the background.

Step 1: Crop away everything outside the gauge to simplify your life. The easiest way to do this is just putting the camera close enough that it only captures the gauge. That way you don't have to implement it in your algorithm.

Step 2: The center of your image will be the red dot in the middle of the gauge. You can easily identify it with a filter looking for the largest concentration of red in the red channel of your image. Calculate the center and remember the coordinates.

Step 3: Do the same for the largest concentration of black in the black channel. This will be the thick end part of the black needle. Calculate the center as well and remember the coordinates.

Step 4: Calculate the vector between those two coordinates. The angle of the vector will tell you the angle of the needle (take care of the direction of the vector). Once you have the angle of the needle, you can easily derive the number it is pointing to.

There are obviously much more elegant approaches to solve this problem, but this quick and dirty algorithm should do the trick without a lot of hassle. You need to make sure that the camera is positioned in the right angle, because we haven't implemented any error corrections in our algorithm. You also need to make sure the lighting is sufficient and that there aren't any other significant influences on the image quality. As long as the orientation is stable and the image quality high, this should enable you to read the gauge with good precision.

$\endgroup$
  • $\begingroup$ I have made something similar that could run on a Pi. Python and the OpenCV library work very well for this if the camera position, light and gauge are similar in all the images. $\endgroup$ – mjul Nov 5 '17 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.