Screen

scalacv.vision.Screen
object Screen

Screen (and screenshot) analysis: finding a known sub-image, and spotting what changed between two captures.

The staple of screen automation and visual testing — "is this button on screen, and where?", "what changed since the last frame?". It is ordinary template matching and differencing, no model involved.

import scalacv.*
OpenCv.load()

for
 screen   <- Image.read("screenshot.png")
 template <- Image.read("button.png")
yield
 try Screen.locate(screen, template) // Option[TemplateMatch]
 finally { screen.close(); template.close() }

Attributes

Source
Screen.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Screen.type

Members list

Value members

Concrete methods

def diff(before: Image, after: Image, threshold: Int = ..., minArea: Int = ...): Seq[Rect]

The regions that changed between two same-size captures — a one-shot screen diff. Both are borrowed; the result is plain Rect data (largest first).

The regions that changed between two same-size captures — a one-shot screen diff. Both are borrowed; the result is plain Rect data (largest first).

Value parameters

minArea

changed blobs smaller than this are ignored.

threshold

per-pixel intensity delta that counts as changed.

Attributes

Source
Screen.scala
def findAll(image: Image, template: Image, minScore: Double = ..., maxMatches: Int = ...): Seq[TemplateMatch]

Finds up to maxMatches non-overlapping occurrences of template, best first, each at or above minScore. After each hit all overlapping top-left positions are excluded.

Finds up to maxMatches non-overlapping occurrences of template, best first, each at or above minScore. After each hit all overlapping top-left positions are excluded.

Attributes

Source
Screen.scala
def locate(image: Image, template: Image, minScore: Double = ...): Option[TemplateMatch]

Finds the single best occurrence of template in image, or None if nothing matches at or above minScore. Both images are borrowed. minScore is a normalised correlation in [-1, 1]; 0.8+ is a confident match.

Finds the single best occurrence of template in image, or None if nothing matches at or above minScore. Both images are borrowed. minScore is a normalised correlation in [-1, 1]; 0.8+ is a confident match.

Attributes

Source
Screen.scala