Dumb thermometer gets digital output

14 Comments

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.

Setup

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

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

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

Comments ( 14 )

  1. Frank
    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?
    • saulius
      Good point, Frank. It was a good excuse to spend a day with Python and OpenCV.
      • Walms
        A day! This only took you a day! Wow that's impressive. Also cool project.
        • saulius
          Thank you, Walms!
  2. agilob
    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.
    • saulius
      Indeed I have not trained it. I think tesseract deserves second chance!
  3. acta
    I tested this code and it works. However it seems that if the first number is "1", then error occurs.
    • saulius
      Hi Acta, what kind of error do you receive?
  4. naveen
    It's not working for me error occurred at 00_distortions.py , displaycnt - reshape error...
    • saulius
      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.
  5. Iman
    Hi, Sorry I'm completely new with python. I just run the code with vs code no error but nothing pop up. what should I expect? a webcam window or what? Thanks
    • saulius
      Hi Iman, there are few scripts that are too complicated to describe in detail. But shortly file names are self explanatory. Python script covers: video reading, distortion correction, digit location and recognition. I guess this is a good chance to learn Python.
  6. nataraj
    In 00_distortions.py used lcd.json. anyone can share the lcd.json file.
    • saulius
      Hi, lcd.json should be created by 00_distortions.py script. This configuration file is used by other scripts later.

Leave a reply

Your email address will not be published.