Dumb thermometer gets digital output


Some time ago I purchased 4 channel thermometer. Soon after tried few optical character recognition (OCR) techniques on 7 segment symbols including pytesseract, they worked but I was not happy with results. Few days ago pyimagesearch published article detailing his approach. So I pushed it a bit forward and made solution more robust. Also added possibility to analyze video instead of single frame.


Not much was needed – camera, thermometer and bracket to keep them mechanically connected.

Attaching C-clamp directly to instrument is kind of cruel, but this is quick and dirty setup. Additional light was not needed, camera and algorithm worked fine with regular room lights.

Digitizing process

First we need to find where useful information is located. Algorithm searches for approximated polygon with 4 edges. If your device has rectangular high contrast frame there is a chance that LCD boundaries will be detected automatically, otherwise mask remaining frame except LCD itself with white trapezoid.

Then we need to find out where our digits are located. Take frame where where most of the segments are on (initial frame from power-up when all segments are turned on would be perfect) and process it with another script.

Two configuration files will be saved to disk. These files will be used during normal OCR operation.

Below is an animation how each segment is being located and recognized. Red highlighted clip is debug output to confirm correct segment location, threshold and identification. Green boundaries with recognized numbers is debug output of video stream.










Results are saved to CSV file and ready to be imported into LibreOffice. Graph below visualizes two cycles of reflow oven. Sensors were placed on:

  1. Top of PCB
  2. Below PCB on drawer bed
  3. Bottom oven wall
  4. Drawer handle

If you zoom-in graphic, some artifacts will be seen. This is an issue with cheap thermometer, seems like it has calculation problems when temperature ramp is too steep.


Code is really sketchy, but as usual I uploaded it to Github, feel free to explore.

Comments ( 10 )

  1. ReplyFrank
    This is a really neat project and ties in with some of the OCR work I've been doing. I have to ask though- why not just buy a logging unit, or use an Arduino or something to give nice digital output?
    • Replysaulius
      Good point, Frank. It was a good excuse to spend a day with Python and OpenCV.
      • ReplyWalms
        A day! This only took you a day! Wow that's impressive. Also cool project.
        • Replysaulius
          Thank you, Walms!
  2. Replyagilob
    You were not happy with results from pytesseract, but have you tried training tesseract with custom font? You can just download "digital clock font", train tesseract database with custom range of characters, in your case only with numbers.
    • Replysaulius
      Indeed I have not trained it. I think tesseract deserves second chance!
  3. Replyacta
    I tested this code and it works. However it seems that if the first number is "1", then error occurs.
    • Replysaulius
      Hi Acta, what kind of error do you receive?
  4. Replynaveen
    It's not working for me error occurred at 00_distortions.py , displaycnt - reshape error...
    • Replysaulius
      Hi Naveen, it's pretty old code and was written for Python 2.7. A lot has changed since, feel free use script as a reference and adapt it for Python 3.

Leave a reply

Your email address will not be published.