locate_image {screenshot}R Documentation

Locate needle image position on a screenshot image.

Description

Locate needle image position on a screenshot image.

Usage

locate_image(
  needle_image,
  center = TRUE,
  exact = TRUE,
  timeout = 5,
  bin_dir = ""
)

Arguments

needle_image

A string of image file path or a cimg class object of imager library.

center

A logical. TRUE returns center position of needle_image.

exact

A logical. Check matching exactly or not.

timeout

A numeric for timeout seconds.

bin_dir

A string for directory name of screenshot.exe on Win.

Value

   A numeric pair of xy location.

Examples

if(interactive()){

sc <- screenshot()
if(sc != ""){
  sc_image <- imager::load.image(sc)
  w <- 100
  h <- 80
  pos_x <- 1
  pos_y <- imager::height(sc_image) - h
  needle <- hay2needle(sc_image, pos_x, pos_y, w, h)
  (locate_image(needle)) # center location
  pos <- locate_image(needle, center = FALSE)
  found <- hay2needle(sc_image, pos[1], pos[2], w, h)
  layout(c(1:3))
  plot(sc_image)
  plot(needle)
  plot(found)
}

}


[Package screenshot version 0.9.0 Index]