Digitally Reading Analog Gauges

analog gauge

While working on his masters degree in controls and robotics, Hack-A-Day reader [Kenn Sebesta] developed a cheap method for digitally reading analog gauges. This method was necessitated by needing to take over 3000 measurements using a dial indicator during his thesis work. The system is implemented in Matlab and uses a webcam to take a picture of the gauge. Once picture is taken it goes through several steps: First, it is reduced to a single color. Then, edge extraction is used to find the lines. Next, the lines are thickened. Finally, the Hough transform is applied to find the longest line: the needle. All that is left to do is measure the arc back to the zero point and match it to your scale. Using this method Kenn’s laptop can take 4 measurements per second.

19 thoughts on “Digitally Reading Analog Gauges

  1. Matlab is a fantastic program. I use it a lot at school (working toward mechanical engineering). I would recommend it strongly. After playing around with it you will find that it is very useful for things you hadn’t even considered before. However, the learning curve is pretty steep so be prepared for that.

  2. “Nice hack, but there are digital dial indicators available for under $30, sometimes under $20 on sale.”

    Hey, thanks for the find! I’ll have to look into buying one of these. However, I still think the matlab script can be really useful as A) only Americans have a harbor freight right next door, god bless its souless corprate soul, and B) once you start dealing with specialty equipement such as 10cm dial indicators, you don’t want to have to dish out hundreds of dollars again.

    Even better, you can use this to measure any kind of dial gage whatsoever. Need a cheap telemetry system for your car on SCCA weekends? Webcam!

  3. Just want to second matlab’s usefulness. If you’re familiar with programming in general the learning curve isn’t that bad, and it’s benefit is how quickly way complex mathematical analysis can be scripted (for example, fouier transforms and laplace transforms are included method) (it doesn’t generate “efficient” code though, no biggie)

    also, we did this digital reading project as undergrads at UC Riverside , cool.

  4. “Uh…how is “one color” both red and yellow?’

    There’s only one color there, what you’re seeing at is just a false-color image. With matlab, you can set the colormap to be use number of ranges, for instance colormap(gray) will show increasing values as lighter shades of gray, whereas colormap(jet) will show low values as blue and high values as red. So this was probably colormap(hot), which shows things on a reddish-yellowish scale.

  5. That’s redic. There’s clearly an area in the example image where there is a ring of black that only the needle passes through, all that needed to be done was to find the bright pixels in this ring…no “longest line” “thickening” “edged extraction” were needed, unless it is just to show off for the prof.

  6. He said he gets 99% acuracy by reading the gague just like it is now. My thought is that if you used an opaque tape and made a disk that would cover the innermost graduated scale and the short needle, then a second ring to cover the outermost scale it might reduce the number of errors?
    You would then only have one set of lines to measure and they would always be those of the main needle.

    Just a thought {:?D

  7. “That’s redic…”

    While that might be true for this one image, remember that you’re looking at about the best image I had. Many others are *not* so clear, and with a reflection in the glass, you could quite easily have another area of “mass”, which would give you a false positive.

    In fact, a better, more robust algorithm would incorporate your idea, using a barycenter to double check the accuracy of the hough transformation. I didn’t incorporate it out of sheer laziness on my part. The hough transformation is exactly one line in matlab. What you propose is much more complicated, believe it or not.

    What’s surprising about computer vision is that it’s incredibly hard for the computer to do what we do so naturallly. A slight shift in light can totally cripple your image analysis program. feel free to improve upon the program and send me your comments.

  8. “if you used an opaque tape and made a disk that would cover the innermost graduated scale and the short needle, then a second ring to cover the outermost scale it might reduce the number of errors?”

    And a good thought it was! in fact, I did almost exactly this for another experiment, when the face wasn’t quite so big, the light wasn’t quite so good, and the background was green instead of white. We just took the lens off, painted the background white, and put everything back together. Helped out enormously.

  9. Analogue gaugue and LCD/LED digit reading is definitely something there should be dirt cheap rf devices for. But I suppose there are a lot of things there should be dirt cheap devices for :-)

Leave a Reply to Wilks RendaiCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.