Image Matching Operations¶
This chapter introduces how to use template matching to find and click elements. FIRERPA supports both template matching and feature point matching (SIFT). Before you begin, you need to understand the basics of image matching. Image matching is divided into template matching and feature point matching. Template matching is suitable for devices with the same resolution and is more efficient. Feature point matching is suitable for screens with different resolutions, but some thresholds may need to be fine-tuned according to the screen size of different devices.
Hint
Matching API¶
The image matching API is a slightly complex interface, but in most cases, you only need to adjust the threshold and distance parameters. You can find the meaning of each parameter in the parameter descriptions below. The main form of the API is as follows. By default, it performs a full-screen match using the template matching method. This API is primarily designed to save your host's computing resources. If you have specific requirements for performance or recognition results, you can also use the screenshot API to perform matching yourself.
d.find_similar_image(data, threshold=0.0, distance=250, scale=1.0, area=FindImageArea.FIA_WHOLE_SCREEN, method=FindImageMethod.FIM_TEMPLATE)
| Field | Description |
|---|---|
| data | Byte data of the image to be matched (template image) |
| threshold | Discard threshold (similarity) |
| distance | Maximum feature point distance (for feature matching only) |
| scale | Scale matching (improves performance, not applicable to template matching) |
| area | Matching area (restricting the area improves performance) |
| method | Matching method |
Matching Methods¶
The matching methods support both template and feature point matching. Template matching is suitable for situations where the texture is distinct and the target shape is fixed, but it is not robust against rotation, scale changes, and lighting variations. Feature point matching works by detecting image feature points such as corners and edges, describing these features, and then matching them between two images. It is highly robust against rotation, scale changes, and lighting variations, making it suitable for complex matching tasks.
| Matching Method | Description |
|---|---|
| FindImageMethod.FIM_TEMPLATE | Template matching |
| FindImageMethod.FIM_FEATURE | Feature point matching |
Matching Area¶
The matching area is mainly used to balance performance on mobile devices. In most cases, the item to be matched is in a fixed area of the screen. You can specify its area to reduce the image size, thereby decreasing the computational load during matching.
| Matching Area | Description |
|---|---|
| FindImageArea.FIA_WHOLE_SCREEN | Full-screen matching |
| FindImageArea.FIA_LEFT | Match the left half of the screen |
| FindImageArea.FIA_TOP_LEFT | Match the top-left corner of the screen |
| FindImageArea.FIA_TOP | Match the top half of the screen |
| FindImageArea.FIA_TOP_RIGHT | Match the top-right corner of the screen |
| FindImageArea.FIA_RIGHT | Match the right half of the screen |
| FindImageArea.FIA_BOTTOM_RIGHT | Match the bottom-right corner of the screen |
| FindImageArea.FIA_BOTTOM | Match the bottom half of the screen |
| FindImageArea.FIA_BOTTOM_LEFT | Match the bottom-left corner of the screen |