Giter VIP home page Giter VIP logo

gosser's Introduction

Gosser

The Go Seven Segment Display Reader.

Takes one image (preferably in greyscale) and tries to convert it to numbers readable by a computer. This is performed by taking a central pixel as reference and looking north, south, west and east for segments shich should have a significantly darker (lower) value.

Providing a source image

Using a image converting library such as imagemagick a source image can be enhanced to facilitate reading. Gosser works only with the red channel of the image, so converting the source image to greyscale is recommended. A minimum difference of 50% between active segment and reference pixel is needed. So increasing contrast is sometimes necessary.

This is an example of using imagemagick to crop and enhance a source image:

convert source.jpg -rotate -5.8 -crop 100x22+311+206 -modulate 100,0 -level 25%,70% crop.jpg

Positioning

--positions tells gosser how many digits should be located. Gosser assumes even spacing between digits. Gosser works best if there is a bit of room on each side of the digits.

Positioning using manifest file

You can tell gosser where to look for digits using a manifest.json file. This file holds simple x,y coordinates for the north and south reference pixel of each digit. Look at the example for details.

[{
    "north": [6, 7],
    "south": [6, 15]
}, {
    ...
}]

Output

The output can be either in :

  • raw string, where each digit is sent to stdout. This is the default.
  • number mode, where the string is parsed to a int and sent to stdout. In this mode leading zeroes will be removed, and --pedantic mode enforced.

Since no separators are detected, in numbers mode --div can be used to divide the result before output.

Debugging the reader

Getting the reader to properly decode an image can be tricky if the image is small, fuzzy, or otherwise not tip top. There are some options available to help Gosser decode, such as the manifest file.

With the --debug option the inner workings of gosser can be examined. This can greatly help when the output is not what you expect.

If you also create a folder named debug gosser will write out the individual segments used in analysis. Overlaid are the search paths originating from the north and south reference pixels.

0.png 1.png 2.png 3.png 4.png 5.png 6.png

The std output will tell you which segments are considered active. In this example the south-west segment of the numer 2 has been missed, making the result unintelligible. In --pedantic mode this will result in a error and no output.

*** *** *** ***   * *** *** 
* * * *   *   *   *   *   * 
* * * *   * ***   * *** *** 
* * * *   *       *   * *   
*** ***   * ***   * *** *** 
007-132

Options

GLOBAL OPTIONS:
   --input, -i            input file
   --manifest, -m         Manifest file with coordinates for segments
   --positions, -p '0'    Number of digits in the image
   --output, -o 'string'  Output type, number or string
   --pedantic             Pedantic mode will output an error rather than let you see a invalid result
   --div '1'              Divide the result by a factor (only int output)
   --debug                Enable debug output
   --help, -h             show help
   --version, -v          print the version

gosser's People

Contributors

dhogborg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.