Locate images on your screen using template matching in nut.js or standalone
npm install @udarrr/template-matcher!Tested
!Released
!Supported node LTS versions
The best template matcher for node js ever with handlers
- Invariant Rotating
- Over Writing
- Scale Images
- Non Maximum Suppression
``nodejs`
npm i @udarrr/template-matcher
`typescript
import finder from "@udarrr/template-matcher";
(async () => {
const matcheImages = await finder.findMatch({haystack: 'pathToImage', needle: 'pathToTemplate'});
const matcheWithScreen = await finder.findMatch({needle: pathToTemplate});
const matchesImages = await finder.findMatches({haystack: 'pathToImage', needle: 'pathToTemplate'});
const matchesWithScreen = await finder.findMatches({needle: 'pathToTemplate'});
})();
`
#### @udarrr/template-matcher standalone API
`typescript`
{
haystack?: string | Image,
needle: string | Image,
confidence?: number,
providerData?: {
methodType?: MethodNameType;
scaleSteps?: Array
searchMultipleScales: boolean,
isRotation: boolean,
rotationOption?: { range?: number; overLap?: number; minDstLength?: number, subPixEstimation?: boolean };
roi?: Region;
debug?: boolean
},
}
`nodejs`
npm i @udarrr/template-matcher
`typescript
import { imageResource, screen } from '@nut-tree/nut-js';
import {OptionsSearchParameterType} from '@udarrr/template-matcher/lib/types'
import "@udarrr/template-matcher"; //once wherever
(async () => {
const img = await screen.find
const imgs = await screen.findAll
})();
`
#### @udarrr/template-matcher providerData nutjs v3 Api
`typescript`
{
searchInput: RegionResultFindInput | Promise
params?: {
searchRegion?: Region | Promise
confidence?: number | undefined;
abort?: AbortSignal | undefined;
providerData?: {
methodType?: MethodNameType;
scaleSteps?: Array
searchMultipleScales: boolean,
isRotation: boolean,
rotationOption?: { range?: number; overLap?: number; minDstLength?: number, subPixEstimation?: boolean };
debug?: boolean;
roi?: Region;
}
}
};
#### Values by default
`typescript``
methodType: "TM_CCOEFF_NORMED"
scaleSteps: [1, 0.9, 0.8, 0.7, 0.6, 0.5]
debug: false
searchMultipleScales: true,
isRotation: false,
rotationOption: {
range: 180, //-180 +180
overLap: 0.1, //inverted scale 0.1 = scaleSteps[0.9]
minDstLength: 32, //quality matching up to 4096
subPixEstimation: false //for low quality pics
}
confidence: 0.8 //0.98 for TM_SQDIFF