Skip to content

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 ​

findImages

Parameters ​

ParameterTypeRequiredDescription
deviceIdstringYesDevice ID
spritesarrayYesTemplate images array (base64 string array)
thresholdnumberNoSimilarity threshold (0-1), default 0.9
rectarrayNoSearch area [x1, y1, x2, y2], default full screen
directionnumberNoSearch direction 0-3, default 0
findAllbooleanNoWhether to return all matches, default false (returns as soon as any match is found)
distancenumberNoMinimum distance between results (pixels), default 8

Return Value ​

Best match (findAll = false):

  • Returns null if 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 results

Feature Description ​

Search Strategy (findAll = false) ​

  • When direction = 0 (default): picks the global best match across all sprites.
  • When direction != 0: tries templates in sprites order, returns the first template that matches according to the direction preference.

Search Direction ​

directionDescriptionApplicable Scenario
0Best matchFind highest similarity position (default)
1Right to leftPrefer finding target on right side of screen
2Bottom to topPrefer finding target at bottom of screen
3Bottom-right to top-leftPrefer finding target at bottom-right corner

Similarity Threshold ​

threshold controls matching precision:

  • 1.0 - Exactly the same (hard to match)
  • 0.95 - Almost identical
  • 0.9 - Highly similar (recommended, default)
  • 0.85 - Similar
  • 0.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.

Cooperation: try.catch@foxmail.com