locate_ndl_in_hay {screenshot}R Documentation

Locate needle image matrix position in a haystack_image matrix. Helper function for locate_image().

Description

Locate needle image matrix position in a haystack_image matrix. Helper function for locate_image().

Usage

locate_ndl_in_hay(ndl_mt, hay_mt, exact = TRUE, timeout = 5)

Arguments

ndl_mt, hay_mt

A matrix

exact

A logical. Check matching exactly or not.

timeout

A numeric for timeout seconds.

Value

    A numeric pair of xy location for needle image.

Examples

haystack_image <- imager::load.example("parrots")
w <- 100
h <- 50
needle_image <- hay2needle(haystack_image, 129, 257, w, h)
hay_mt <- image2gray_matrix(haystack_image)
ndl_mt <- image2gray_matrix(needle_image)
(pos <- locate_ndl_in_hay(ndl_mt, hay_mt))

found <- hay2needle(haystack_image, pos[1], pos[2], w, h)
layout(c(1:3))
plot(haystack_image)
plot(needle_image)
plot(found)


[Package screenshot version 0.9.0 Index]