Skip to content

Find Image

Use OpenCV template matching technology to find specified image template in device screenshot, supports similarity control and multiple results finding.

Interface Description

Interface Type

findImage

Parameters

ParameterTypeRequiredDescription
deviceIdstringYesDevice ID
spritestring/BufferYesTemplate image (base64 string)
thresholdnumberNoSimilarity threshold (0-1), default 0.9
rectarrayNoSearch area [x1, y1, x2, y2], default full screen
directionnumberNoSearch direction 0-3, default 0
multiplebooleanNoWhether to find all matches, default false
distancenumberNoMinimum distance between results (pixels), default 8

Return Value

Single Match (multiple = false):

javascript
{
    x: 100,          // Match area center point X coordinate
    y: 200,          // Match area center point Y coordinate
    confidence: 0.95 // Similarity (0-1)
}

Multiple Matches (multiple = true):

javascript
[
    { x: 100, y: 200, confidence: 0.95 },
    { x: 150, y: 250, confidence: 0.92 },
    { x: 200, y: 300, confidence: 0.90 }
]
// Sorted by similarity in descending order, max 88 results

Feature Description

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

Multiple Results Finding

Use multiple = true to find all matching locations:

  • Automatically sorted by similarity in descending order
  • Use distance parameter to filter results too close together
  • Max 88 results returned

💡 Tip

Image matching uses OpenCV template matching algorithm based on grayscale images, so it has certain tolerance for color changes. It's recommended that template images contain obvious features and avoid solid colors or repetitive patterns to improve matching accuracy and speed.

Cooperation: try.catch@foxmail.com