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

All matching processes are performed on the FIRERPA server and do not consume local machine resources. However, due to performance limitations on mobile devices, the efficiency is relatively low. For performance-critical tasks, you can take screenshots and perform matching on your local machine.

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)
FieldDescription
dataByte data of the image to be matched (template image)
thresholdDiscard threshold (similarity)
distanceMaximum feature point distance (for feature matching only)
scaleScale matching (improves performance, not applicable to template matching)
areaMatching area (restricting the area improves performance)
methodMatching 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 MethodDescription
FindImageMethod.FIM_TEMPLATETemplate matching
FindImageMethod.FIM_FEATUREFeature 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 AreaDescription
FindImageArea.FIA_WHOLE_SCREENFull-screen matching
FindImageArea.FIA_LEFTMatch the left half of the screen
FindImageArea.FIA_TOP_LEFTMatch the top-left corner of the screen
FindImageArea.FIA_TOPMatch the top half of the screen
FindImageArea.FIA_TOP_RIGHTMatch the top-right corner of the screen
FindImageArea.FIA_RIGHTMatch the right half of the screen
FindImageArea.FIA_BOTTOM_RIGHTMatch the bottom-right corner of the screen
FindImageArea.FIA_BOTTOMMatch the bottom half of the screen
FindImageArea.FIA_BOTTOM_LEFTMatch the bottom-left corner of the screen