ImageFinderInterface

ImageFinder plugins

Currently, there are two official ImageFinder implementations provided by nut.js.

@nut-tree/template-matcher


1npm i @nut-tree/template-matcher

Initial implementation for on-screen image search.

Attention: @nut-tree/template-matcher only supports node up to v16 and Electron up to v13.

In case you want to use image search in later versions of node/Electron, please consult the sponsoring profile for access to @nut-tree/nl-matcher.

Usage


Simply require / import the package to wire up the provider:

1const { screen, imageResource } = require("@nut-tree/nut-js");
2require("@nut-tree/template-matcher");
3
4(async () => {
5  const img = await screen.find(imageResource("..."));
6})();

@nut-tree/nl-matcher


1npm i @nut-tree/nl-matcher

Attention: @nut-tree/nl-matcher is only available to sponsors of nut.js.
In case you want to get access to it, please consult the sponsoring profile

Next Level module for image search.

Comes with additional features compared to @nut-tree/template-matcher:

  • It is future-proof and supports a wide range of current and future node and/or Electron versions
  • It works on Apple Silicon chips
  • Supports screen.findAll(...) to detect multiple instances of an image on screen
  • Is faster compared to @nut-tree/template-matcher
1hyperfine --warmup 3 'node template-matcher.js' 'node nl-matcher.js' --show-output
2Benchmark 1: node template-matcher.js
3  Time (mean ± σ):      1.575 s ±  0.016 s    [User: 1.469 s, System: 0.225 s]
4  Range (min … max):    1.545 s …  1.590 s    10 runs
5
6Benchmark 2: node nl-matcher.js
7  Time (mean ± σ):     917.3 ms ±  11.1 ms    [User: 1616.6 ms, System: 388.0 ms]
8  Range (min … max):   899.7 ms … 930.7 ms    10 runs
9
10Summary
11  'node nl-matcher.js' ran
12    1.72 ± 0.03 times faster than 'node template-matcher.js'

Usage


Simply require / import the package to wire up the provider:

1const { screen, imageResource } = require("@nut-tree/nut-js");
2require("@nut-tree/nl-matcher");
3
4(async () => {
5  const img = await screen.findAll(imageResource("..."));
6})();

© 2022