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.
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
--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.
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]
}, {
...
}]
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.
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.
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
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