Raspberry Pi: Reading 7-Segment Displays

Reading Seven Segment Displays


Introduction

Many sensors do not have a simple way to plug directly into them -- and even when there is a way to hack it, it often involves mad-surface-mount soldering skills. Simply reading a seven segment diplay allows one to share one's tools with the robot and have the "hey, can you do this for me?" kind of feel. While normal black-and-white text is easy, seven-segment displays are super hard for bots! Thankfully and thanks to the creators of ssocr, there is a way we can give our bots this essential skill.

Installation Of Seven-Segment-Optical-Character-Recognition (ssocr)

First we must install the dependencies: sudo apt-get install libimlib2 libimlib2-dev Next we download the ssocr binary from the following site: http://www.unix-ag.uni-kl.de/~auerswal/ssocr/ Extract it, cd into the directory, then make the project with a simple: make ...that was simple. For good measure let's also install it into our system for use outside the folder: sudo make install

Example/Demo

Infrared Thermometer ssocr crop 190 73 80 100 -d 2 image.jpg -t 20 The code above resulted in 19 being placed into standard-out.

Usage

You will need to make sure that the number of digits is known, and the bounding box for the digits.

Notes

  • Bounding Box
    • grab x and y of top-left corner (pixels measured from top-left as per usual)
    • get the width and height in pixels respectively
  • Enter the number of digits after -d
  • Enter the black-white threshold in % after -t
ssocr crop top_left_x top_left_y width height -d number of digits expected the_image_name.jpg -t black_white_threshold_percent

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    2 Discussions

    None
    eastpole

    2 months ago

    Shree, from the ssocr man page: "An image of one row of digits is used for input ... " I think you are providing two lines. Note that a 0 above a 0 could easily be an 8, and many other complications, so try with just one line of input.

    None
    shreevidya

    Question 10 months ago

    Thanks for providing simple code to extract digits from seven segment dispaly.
    For the image you have used in your example has actual pixel width and height of 300 pixels,i just wanted to know how exactly your determining crop area whether you are doing it manually or through code.

    I tried the sample code with different image that i have attached below ,but i am getting error found too many digits ,so please let me know the solution and cause for this error

    sample1_crop.jpg