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
findImageParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Device ID |
| sprite | string/Buffer | Yes | Template image (base64 string) |
| 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 |
| multiple | boolean | No | Whether to find all matches, default false |
| distance | number | No | Minimum 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 resultsFeature Description
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
Multiple Results Finding
Use multiple = true to find all matching locations:
- Automatically sorted by similarity in descending order
- Use
distanceparameter 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.