Documentation
¶
Overview ¶
Package vision finds a picture on a screenshot and reads text with Tesseract. Both run on the PC; the phone only sends the screenshot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrTooBig = errors.New("the image is larger than the screen") ErrFlat = errors.New("the image is a single flat color, so there is nothing to match") )
var ErrNoTesseract = errors.New("Tesseract is not installed")
ErrNoTesseract means OCR was asked for but Tesseract is not installed.
var ErrRegion = errors.New("region must be four numbers, left, top, right and bottom, inside the screen")
Functions ¶
Types ¶
type Line ¶
Line is one line of text Tesseract read, in screenshot pixels.
func FindText ¶
FindText returns the bounds of text: a word equal to it first, else a line that contains it.
type Match ¶
type Match struct {
Bounds [4]int // left, top, right, bottom
Score float64 // normalised cross-correlation, 1 is a perfect match
}
Match is where a template was found, in screenshot pixels.
func Find ¶
Find looks for template on screen at the same scale. The best match is returned even below threshold, with ok false.
func FindAll ¶ added in v0.1.11
func FindAll(screen, template image.Image, threshold float64, o Options, limit int) ([]Match, error)
FindAll returns every place the template matches at or above threshold, best first, without overlaps, at most limit of them.
type Options ¶ added in v0.1.11
type Options struct {
Region []int // left, top, right, bottom in screenshot pixels; empty means the whole screen
Scales []float64 // template sizes to try, 1 being the size it was cut at; empty means just 1
Color bool // also require the average color to agree, so a red and a green button differ
}
Options narrow or widen a search. The zero value searches the whole screen, at the size the template was cut, comparing brightness only.