Raspberry Pi: Reading 7-Segment Displays

Introduction: Raspberry Pi: Reading 7-Segment Displays

Reading Seven Segment Displays


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


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.


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


  • 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

Be the First to Share


    • Fruits and Veggies Speed Challenge

      Fruits and Veggies Speed Challenge
    • Leather Challenge

      Leather Challenge
    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge



    2 years 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.


    Question 3 years 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