Find Images (Multi)
Search multiple template images in a single screenshot using OpenCV template matching. Compared with findImage, this interface accepts a sprites array and returns the match result with the corresponding template index.
Interface Description
Interface Type
findImagesParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Device ID |
| sprites | array | Yes | Template images array (base64 string array) |
| threshold | number | No | Similarity threshold (0-1), default 0.9 |
| rect | array | No | Search area [x1, y1, x2, y2], default full screen |
| direction | number | No | Search direction 0-3, default 0 |
| findAll | boolean | No | Whether to return all matches, default false (returns as soon as any match is found) |
| distance | number | No | Minimum distance between results (pixels), default 8 |
Return Value
Best match (findAll = false):
- Returns
nullif nothing matches. - Returns an object when matched:
javascript
{
x: 100, // Match center X
y: 200, // Match center Y
confidence: 0.95,// Similarity (0-1)
index: 0 // Index of matched template in sprites
}All matches (findAll = true):
- Returns an empty array
[]if nothing matches. - Returns an array of results when matched:
javascript
[
{ x: 100, y: 200, confidence: 0.95, index: 0 },
{ x: 150, y: 250, confidence: 0.92, index: 2 },
{ x: 200, y: 300, confidence: 0.90, index: 1 }
]
// Sorted by confidence in descending order, max 88 resultsFeature Description
Search Strategy (findAll = false)
- When
direction = 0(default): picks the global best match across allsprites. - When
direction != 0: tries templates inspritesorder, returns the first template that matches according to the direction preference.
Search Direction
| direction | Description | Applicable Scenario |
|---|---|---|
| 0 | Best match | Find highest similarity position (default) |
| 1 | Right to left | Prefer finding target on right side of screen |
| 2 | Bottom to top | Prefer finding target at bottom of screen |
| 3 | Bottom-right to top-left | Prefer finding target at bottom-right corner |
Similarity Threshold
threshold controls matching precision:
1.0- Exactly the same (hard to match)0.95- Almost identical0.9- Highly similar (recommended, default)0.85- Similar0.8- Basically similar< 0.8- Possible false match
Result De-duplication (distance)
When findAll = true, results that are too close (both X and Y within distance pixels) will be filtered to reduce duplicates, and only the higher-confidence point is kept.
💡 Tip
To improve accuracy and speed, keep template images small and distinctive (avoid large solid-color areas or repetitive patterns). It’s recommended to set rect to limit the search area whenever possible.