Image positioning method, device, computer equipment and storage medium

By performing contour extraction and Hu moment calculation on the image, the problem of low image matching accuracy is solved, and higher positioning accuracy is achieved, especially suitable for images with solid colors or strong symmetry.

CN115331035BActive Publication Date: 2025-08-12GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211137154.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-19
Publication Date
2025-08-12
Estimated Expiration
2042-09-19

AI Technical Summary

Technical Problem

In the prior art, image matching accuracy is low and mismatch problems are prone to occur.

Method used

By extracting the contours of the to-positioned image and the test interface image, calculate the Hu moments of the target subject contour and each second contour, determine the matching degree based on the difference of the Hu moment, and determine the matching profile when the matching degree threshold is satisfied, and then position the image position.

Benefits of technology

Improves the accuracy of image positioning, especially for solid colors or strong symmetry images, and enhances the accuracy of matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115331035B_ABST
    Figure CN115331035B_ABST
Patent Text Reader

Abstract

The present application provides an image positioning method, apparatus, computer device, and storage medium. The method includes: performing contour extraction on an image to be positioned to obtain multiple first contours, and determining the target subject contour of the image to be positioned from the multiple first contours, where the target subject contour is the main contour of the image to be positioned; performing contour extraction on a test interface image to obtain multiple second contours; calculating the Hu moment of the target subject contour and each second contour; determining the degree of matching between the target subject contour and each second contour based on the difference between the Hu moment of the target subject contour and the Hu moment of each second contour, so as to determine a matching contour corresponding to the target subject contour from the multiple second contours; the degree of matching between the target subject contour and the corresponding matching contour is greater than a matching threshold; and determining the position of the image to be positioned in the test interface image based on the matching contour corresponding to the target subject contour. This method has high positioning accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition technology, and in particular to an image positioning method, apparatus, computer equipment, and storage medium. Background Art

[0002] As web applications update, their UI (User Interface) interfaces need to be tested. Currently, automated UI testing can be implemented using certain automated testing frameworks. During automated testing, image recognition can be used to match the control to be located with the UI controls as a template, thereby identifying the position of the control to be located within the UI and automating the operation of the control to be located. However, image positioning in traditional technologies has low accuracy and is prone to mispositioning. Summary of the Invention

[0003] The purpose of this application is to solve at least one of the above technical defects, especially the technical defects in the prior art that image matching accuracy is low and mismatching is prone to occur.

[0004] In a first aspect, an embodiment of the present application provides an image positioning method, comprising:

[0005] Performing contour extraction on the image to be positioned to obtain a plurality of first contours, and determining a target subject contour of the image to be positioned from the plurality of first contours, wherein the target subject contour is a subject contour of the image to be positioned;

[0006] Performing contour extraction on the test interface image to obtain a plurality of second contours;

[0007] Calculate the Hu moment of the target main contour and each second contour;

[0008] determining, based on differences between the Hu moments of the target subject contour and the Hu moments of the second contours, a degree of matching between the target subject contour and the second contours, so as to determine a matching contour corresponding to the target subject contour from the plurality of second contours; the degree of matching between the target subject contour and the corresponding matching contour being greater than a matching degree threshold;

[0009] The position of the image to be located in the test interface image is determined according to the matching contour corresponding to the target body contour.

[0010] In one embodiment, determining the position of the image to be positioned in the test interface image according to the position of the matching contour corresponding to the target body contour includes:

[0011] If the target subject contour corresponds to multiple matching contours, the multiple matching contours corresponding to the target subject contour are selected as the matching contours to be selected;

[0012] Determine whether there is a matching sub-contour inside each candidate matching contour; the matching sub-contour is the second contour inside the candidate matching contour, and the matching degree with the sub-contour of the target main contour is greater than the matching degree threshold, and the sub-contour of the target main contour is the first contour inside the target main contour;

[0013] Determine the candidate matching contour with a matching sub-contour inside as the target matching contour;

[0014] According to the position of the target matching contour, the position of the image to be positioned in the test interface image is determined.

[0015] In one embodiment, determining the position of the image to be positioned in the test interface image according to the matching contour corresponding to the target body contour includes:

[0016] If the target body contour corresponds to a matching contour, then determining the matching contour corresponding to the target body contour as the target matching contour;

[0017] According to the position of the target matching contour, the position of the image to be positioned in the test interface image is determined.

[0018] In one embodiment, determining the contour of the target subject in the image to be positioned from a plurality of first contours includes:

[0019] The first contour with the largest contour size among the multiple first contours is taken as the target main contour, or the first contour with the highest hierarchical structure among the multiple first contours is taken as the target main contour.

[0020] In one embodiment, before calculating the Hu moments of the target body contour and each second contour, the method further includes:

[0021] Contours whose inner areas are smaller than an area threshold value are filtered out from the plurality of first contours and the plurality of second contours.

[0022] In one embodiment, before determining the position of the image to be positioned in the test interface image based on the position of the target matching contour, the method further includes:

[0023] Extracting feature points from the image to be positioned to obtain a first feature point set, and extracting feature points from the test interface image to obtain a second feature point set;

[0024] Traversing all feature points in the first feature point set, each time a feature point in the first feature point set is traversed, determining whether there is a matching feature point corresponding to the feature point in the second feature point set according to a similarity threshold, and if so, taking the feature point and the corresponding matching feature point as a pair of matching points;

[0025] Determine the target area based on each matching feature point when the number of matching point pairs is greater than or equal to a preset number;

[0026] According to the position of the target matching contour, the position of the image to be positioned in the test interface image is determined, including:

[0027] The position of the image to be positioned in the test interface image is determined according to the position of the target matching contour and the position of the target area.

[0028] In one embodiment, before performing contour extraction on the image to be positioned, the method further includes:

[0029] Perform binarization processing on the image to be positioned;

[0030] Before performing contour extraction on the test interface image, the following steps are also included:

[0031] Perform binarization on the test interface image.

[0032] In a second aspect, an embodiment of the present application provides an image positioning device, comprising:

[0033] A first contour extraction module is used to extract contours from the image to be positioned, obtain multiple first contours, and determine a target subject contour from the multiple first contours, where the target subject contour is the subject contour of the image to be positioned;

[0034] A second contour extraction module is used to extract the contour of the test interface image to obtain multiple second contours;

[0035] A calculation module, used to calculate the Hu moment of the target body contour and each second contour;

[0036] a matching module, configured to determine a degree of matching between the target subject contour and each of the second contours based on a difference between a Hu moment of the target subject contour and a Hu moment of each of the second contours, so as to determine a matching contour corresponding to the target subject contour from the plurality of second contours; the degree of matching between the target subject contour and the corresponding matching contour being greater than a matching degree threshold;

[0037] The positioning module is used to determine the position of the image to be positioned in the test interface image according to the matching contour corresponding to the target body contour.

[0038] In a third aspect, an embodiment of the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the image positioning method in any of the above embodiments.

[0039] In a fourth aspect, an embodiment of the present application provides a computer device, comprising: one or more processors, and a memory;

[0040] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the steps of the image positioning method in any of the above embodiments are performed.

[0041] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0042] Based on any of the above embodiments, the main contour of the image to be located is matched against multiple second contours extracted from the test interface image. Once a matching contour similar to the main contour is found, the position of the image to be located within the test interface image can be determined, as the position of the matching contour within the test interface image is known. Because contour matching is based on the scale-invariant properties of the Hu moments, matching accuracy is greatly improved, making it particularly suitable for locating images with solid colors or strong symmetry. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0044] Figure 1 A flowchart of an image positioning method provided in one embodiment of the present application;

[0045] Figure 2 This is a schematic diagram of a test page image in one embodiment of the present application;

[0046] Figure 3 This is a schematic diagram of a process for positioning according to the matching contour of the target subject contour in one embodiment of the present application;

[0047] Figure 4 This is a schematic diagram of a test page image in yet another embodiment of the present application;

[0048] Figure 5 This is a module diagram of an image positioning device in one embodiment of the present application;

[0049] Figure 6 This is a diagram of the internal structure of a computer device in one embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0051] In the first aspect, the present application provides an image positioning method, see Figure 1 , including steps S102 to S110.

[0052] S102: Perform contour extraction on the image to be positioned to obtain a plurality of first contours, and determine a target subject contour from the plurality of first contours. The target subject contour is the subject contour of the image to be positioned.

[0053] S104: Perform contour extraction on the test interface image to obtain a plurality of second contours.

[0054] Because many test interface controls have symmetrical outlines and are typically solid colors, these images may contain fewer feature points. Using feature point matching often results in misjudgments and low processing efficiency. Given the symmetry and solid colors of test interface controls, outline matching is more suitable.

[0055] When performing automated testing on a test interface, it's necessary to locate the position of each control within the test interface. The image of the control to be operated, whose position is unknown, is used as the image to be located. A control typically consists of multiple parts, so when performing contour extraction on the image to be located, a first contour corresponding to each part is obtained. The main contour of a control is the operable area. To facilitate simulated operations during automated testing, positioning is performed based on the main contour of the image to be located—that is, based on the target main contour.

[0056] like Figure 2As shown, the test interface is the purchase interface of a commodity on an online trading platform. The controls in this test interface include, but are not limited to, a commodity display control, an add-to-cart control, and a purchase control. The main outline of the commodity display control is a rectangle in the upper half of the test interface. The main outline of the add-to-cart control is a rectangle in the lower right corner and slightly to the left. The main outline of the purchase control is a rectangle in the lower right corner and slightly to the right. In order to test whether the purchase control in this interface is normal, the screenshot of the purchase control is used as the image to be located, and the screenshot of this purchase interface is used as the test interface image. After contour extraction is performed on the image to be located, multiple first contours will be obtained. Among them, some correspond to the two characters "Purchase", and one corresponds to the target main outline. Select the one corresponding to the target main outline from the multiple first contours. After contour extraction is performed on the test interface image, multiple second contours will be obtained. Among them, some correspond to the string "Purchase", some correspond to the string "Add to Cart", some correspond to the displayed commodity, and some correspond to the main outlines of each control.

[0057] Before performing contour extraction on the image to be located and the test interface image respectively, the image to be located and the test interface image can be binarized first. The image edge is a reflection of the discontinuity of the local characteristics of the image. Through binarization, the difference between the edge and the areas inside and outside the edge can be highlighted. It can be carried out using a relatively mature binarization algorithm or the binarization function in an open-source software library, such as the threshold() function in Opencv.

[0058] There are also many mature techniques for contour extraction, such as the method of hollowing out internal points, the boundary tracking method, etc. The open-source software library also encapsulates contour extraction functions, such as findContours() in Opencv. It is worth mentioning that the initial first contours and second contours may contain many parts that are not related to the main outline, such as some fine strokes in Chinese characters. The contour data with an area smaller than the area threshold inside the contours in the first contours and the second contours can be filtered out to speed up the processing.

[0059] S106, calculate the Hu moments of the target main outline and each second contour.

[0060] S108, determine the matching degree between the target main outline and each second contour according to the difference between the Hu moments of the target main outline and the Hu moments of each second contour, so as to determine the matching contour corresponding to the target main outline from multiple second contours. The matching degree between the target main outline and the corresponding matching contour is greater than the matching degree threshold.

[0061] Since the first contour is generally obtained by taking a separate screenshot of the control to be located and performing contour extraction, while the second contour is obtained by taking a screenshot of the test interface and then performing image segmentation and contour extraction, the first contour and the second contour may be deformed to a certain extent due to reasons such as resolution, resulting in a low matching accuracy. Hu moments can remain invariant after operations such as image rotation, translation, and scaling, so Hu moments are often used to represent image features. When the Hu moments of two contours are not much different, the two contours can be considered to be relatively similar. Therefore, the difference in Hu moments between the first contour and each second contour can be used to calculate the matching degree. When the difference in matching degree between the second contour and the target body contour is greater than the matching degree threshold, the second contour can be considered similar to the target body contour.

[0062] S110 , determining the position of the image to be positioned in the test interface image according to the matching contour corresponding to the target body contour.

[0063] The position of the matching contour corresponding to the target main contour in the test interface image is known. If the target main contour has only one corresponding matching contour, then this matching contour is used as the target matching contour. The target matching contour is the main contour of the test control in the test interface image that has the same function as the control corresponding to the image to be located. If it is necessary to operate the control corresponding to the image to be located, this can be achieved by operating in the area within the target matching contour on the test interface. That is, after obtaining the position of the target matching contour, the positioning of the control to be located is achieved. If there is more than one matching contour corresponding to the target main contour, the matching contours corresponding to the target main contour can be further screened to find the unique target matching contour.

[0064] This image localization method performs contour matching on the main outline of the image to be located with multiple secondary contours extracted from the test interface image. Once a matching contour similar to the main outline is found, the position of the image to be located within the test interface image can be determined, as the matching contour's position within the test interface image is known. Because contour matching is based on the scale-invariant properties of the Hu moment, matching accuracy is greatly improved, making it particularly suitable for localizing images with solid colors or strong symmetry.

[0065] In one embodiment, when the target subject contour corresponds to multiple matching contours, further screening can be performed in the following manner. Figure 3 , according to the position of the matching contour corresponding to the target body contour, determining the position of the image to be positioned in the test interface image, including steps S302 to S308.

[0066] S302: If the target subject contour corresponds to multiple matching contours, the multiple matching contours corresponding to the target subject contour are selected as matching contours to be selected.

[0067] The target body contour and the corresponding matching contours are relatively similar and may be the target matching contours, so these candidate matching contours need to be further screened.

[0068] like Figure 4 As shown, still taking the purchase interface of a product as an example, in addition to the product display control, add to cart control, and purchase control, it also includes a return control, a share control, and a quick entry control. The main outline of the return control is a circle in the upper left corner. The main outline of the share control is a circle on the left side of the upper right corner. The main outline of the quick entry control is a circle on the right side of the upper right corner. If the screenshot of the return control is used as the image to be located, then when the contour is extracted from the test interface image, the second contour will include the main contours of the three test controls: the return control, the share control, and the quick entry control. The second contour corresponding to the main contours of these three test controls will be identified as the matching contour corresponding to the target main contour. In addition, the main contours of the add to cart control, the purchase control, and the product display control are all rectangular, but the size or aspect ratio is different. When one of these test controls is used as the control to be located, further screening may also be required.

[0069] S304: Determine whether there is a matching sub-contour inside each candidate matching contour.

[0070] The matching sub-contour is the second contour inside the selected matching contour, and its matching degree with the sub-contour of the target main contour is greater than the matching degree threshold. The sub-contour of the target main contour is the first contour inside the target main contour.

[0071] S306: Determine the candidate matching contour with a matching sub-contour inside as the target matching contour.

[0072] This embodiment targets the case where the image to be located is a nested graphic. That is, there is a graphic inside the target main outline, and the sub-outline of the target main outline is the outline of the graphic inside the target main outline. Since the main outline and the sub-outline of the main outline are generally not similar in the control, even if the main outline is similar, the sub-outlines will be quite different, making it easier for users to distinguish. Figure 4 It can be seen that the internal graphics of each control with similar main contours are quite different. Based on this, on the basis of the similarity of the main contours, the similarity of the sub-contours is further judged to screen out the target matching contour. Specifically, taking any candidate matching contour as an example, if there is no second contour inside the candidate matching contour, it can be directly excluded. If there is a second contour inside the candidate matching contour, the matching degree between the sub-contour of the target main contour and the sub-contour of the candidate matching contour is calculated based on the Hu moment. If the matching degree between the sub-contours is also greater than the matching degree threshold, the candidate matching contour is determined as the target matching contour. Otherwise, the next candidate matching contour is judged until the target matching contour is screened out.

[0073] S308: Determine the position of the image to be positioned in the test interface image according to the position of the target matching contour.

[0074] After determining the unique target matching contour, since the position of the target matching contour in the test interface image is known, the image to be positioned can be positioned based on the position of the target matching contour.

[0075] In one embodiment, the first contour with the largest outline size among multiple first contours is used as the target subject contour, or the first contour at the highest level in the hierarchy among multiple first contours is used as the target subject contour. It is understood that the outline size can be, for example, the contour perimeter or the area within the contour. The contour of the subject in the image to be located should be the outermost of the multiple first contours, so its outline size should be the largest. During contour extraction, the hierarchical structure of each first contour can also be obtained. The hierarchical structure reflects the nested relationship between the first contours, with first contours higher in the hierarchy being located in the outermost layer. The first contour at the highest level in the hierarchy among the first contours is therefore located in the outermost layer.

[0076] In one embodiment, since the feature point matching method may cause positioning failure due to too few feature points, in order to further improve positioning accuracy, the feature point matching and contour matching methods can be combined under certain conditions. Specifically, before determining the position of the image to be positioned in the test interface image based on the position of the target matching contour, the following steps are also included:

[0077] 1) Extracting feature points from the image to be positioned to obtain a first feature point set, and extracting feature points from the test interface image to obtain a second feature point set.

[0078] Image feature points can reflect the essential characteristics of an image, such as points where the grayscale value changes dramatically or points with large curvature along an image edge. The number of image feature points is generally much smaller than the number of pixels in the image. Comparing image feature points alone does not affect comparison accuracy and can speed up processing.

[0079] Currently, there are many feature extraction algorithms that can extract features from images, such as the SIFT (Scale-invariant feature transform) algorithm, the SURF (Speeded Up Robust Features) algorithm, and so on. The feature points extracted by the SIFT algorithm are scale-invariant feature transform (SIFT) feature points, and the feature points extracted by the SURF algorithm are speeded up robust features (SURF) feature points. Based on this, a preset feature extraction algorithm is used to extract features from the image to be matched, and a first feature point set is obtained. The first feature point set includes all feature points in the image to be matched. And the same feature extraction algorithm is used to extract features from the test page image to obtain a second feature point set. The second feature point set includes all feature points in the test page image.

[0080] 2) Traverse all feature points in the first feature point set. Whenever a feature point in the first feature point set is traversed, determine whether there is a matching feature point corresponding to the feature point in the second feature point set based on the similarity threshold. If so, take the feature point and the corresponding matching feature point as a pair of matching points.

[0081] Specifically, to determine whether each feature point in the first feature point set has a similar feature point in the second feature point set, each feature point in the first feature point set must be compared with the feature points in the second feature point set. Taking a feature point in the first feature point set as the target feature point, the similarity between the target feature point and each feature point in the second feature point set is calculated, and the feature points in the second feature point set whose similarity exceeds a similarity threshold are used as matching feature points corresponding to the target feature point. The target feature point and its corresponding matching feature point are thus a matching point pair. Once every feature point in the first feature point set has been selected as the target feature point, the traversal of the first feature point set is complete.

[0082] 3) Determine the target area based on each matching feature point when the number of matching point pairs is greater than or equal to a preset number.

[0083] If the number of matching point pairs is less than the preset number, it indicates that there are insufficient matching points, and the feature point matching method has failed, which means that feature point matching is not applicable to the current scene. Only when the number of matching point pairs is greater than or equal to the preset number can the target area be locked with high accuracy. Only then can the position of the target area and the target matching contour be cross-validated to further improve positioning accuracy.

[0084] According to the position of the target matching contour, the position of the image to be positioned in the test interface image is determined, including: according to the position of the target matching contour and the position of the target area, the position of the image to be positioned in the test interface image is determined. Specifically, the degree of overlap between the area encircled by the target matching contour and the target area can be calculated. If the degree of overlap is greater than or equal to the overlap threshold, it means that the positioning results of the two methods are similar. The position of the overlapping area between the area encircled by the target matching contour and the target area can be used as the position of the image to be positioned in the test interface image. If the degree of overlap is less than the overlap threshold, re-positioning is required.

[0085] In the second aspect, the embodiment of the present application provides an image positioning device, see Figure 5 , including a first contour extraction module 201, a second contour extraction module 202, a calculation module 203, a matching module 204 and a positioning module 205.

[0086] The first contour extraction module 201 is used to perform contour extraction on the image to be positioned, obtain multiple first contours, and determine the target subject contour from the multiple first contours, where the target subject contour is the subject contour of the image to be positioned. The second contour extraction module 202 is used to perform contour extraction on the test interface image, obtain multiple second contours. The calculation module 203 is used to calculate the Hu moment of the target subject contour and each second contour. The matching module 204 is used to determine the matching degree between the target subject contour and each second contour based on the difference between the Hu moment of the target subject contour and the Hu moment of each second contour, so as to determine the matching contour corresponding to the target subject contour from the multiple second contours; the matching degree between the target subject contour and the corresponding matching contour is greater than the matching degree threshold. The positioning module 205 is used to determine the position of the image to be positioned in the test interface image based on the matching contour corresponding to the target subject contour.

[0087] For the specific definition of the image positioning device, please refer to the definition of the image positioning method above, which will not be repeated here. The various modules in the above-mentioned image positioning device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0088] In a third aspect, an embodiment of the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the image positioning method in any of the above embodiments.

[0089] In a fourth aspect, an embodiment of the present application provides a computer device, comprising: one or more processors, and a memory;

[0090] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the steps of the image positioning method in any of the above embodiments are performed.

[0091] Schematically, as Figure 6 As shown, Figure 6 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 can be provided as a server. Figure 6 Computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions executable by processing component 302, such as applications. The applications stored in memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, processing component 302 is configured to execute instructions to perform the control location method or interface automation testing method of any of the above-mentioned embodiments.

[0092] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or the like.

[0093] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0094] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0095] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referenced to each other.

[0096] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An image positioning method, characterized in that: include: Performing contour extraction on the image to be positioned to obtain a plurality of first contours, and determining a target body contour from the plurality of first contours, wherein the target body contour is the body contour of the image to be positioned; Performing contour extraction on the test interface image to obtain a plurality of second contours; Calculating the Hu moment of the target body contour and each of the second contours; determining, based on a difference between the Hu moment of the target subject contour and the Hu moments of each of the second contours, a degree of matching between the target subject contour and each of the second contours, so as to determine a matching contour corresponding to the target subject contour from the plurality of second contours; wherein the degree of matching between the target subject contour and the corresponding matching contour is greater than a matching degree threshold; Determine the position of the image to be positioned on the test interface image according to the matching contour corresponding to the target body contour; Before determining the position of the image to be located on the test interface image based on the matching contour corresponding to the target body contour, the method further includes: Extracting feature points from the image to be positioned to obtain a first feature point set, and extracting feature points from the test interface image to obtain a second feature point set; Traversing all feature points in the first feature point set, and whenever a feature point in the first feature point set is traversed, determining whether there is a matching feature point corresponding to the feature point in the second feature point set according to a similarity threshold, and if so, taking the feature point and the corresponding matching feature point as a matching point pair; determining a target area according to each of the matching feature points when the number of matching point pairs is greater than or equal to a preset number; The determining, based on the matching contour corresponding to the target body contour, the position of the image to be positioned in the test interface image includes: The position of the image to be positioned in the test interface image is determined according to the position of the matching contour and the position of the target area.

2. The method according to claim 1, characterized in that The determining, based on the matching contour corresponding to the target body contour, the position of the image to be positioned in the test interface image includes: If the target subject contour corresponds to multiple matching contours, the multiple matching contours corresponding to the target subject contour are selected as matching contours to be selected; Determine whether there is a matching sub-contour within each of the candidate matching contours; the matching sub-contour is the second contour within the candidate matching contour, and the matching degree with the sub-contour of the target main contour is greater than the matching degree threshold, and the sub-contour of the target main contour is the first contour within the target main contour; Determine the candidate matching contour having the matching sub-contour inside as the target matching contour; The position of the image to be positioned in the test interface image is determined according to the position of the target matching contour.

3. The method according to claim 1, characterized in that The determining, based on the matching contour corresponding to the target body contour, the position of the image to be positioned in the test interface image includes: If the target body contour corresponds to a matching contour, determining the matching contour corresponding to the target body contour as the target matching contour; The position of the image to be positioned in the test interface image is determined according to the position of the target matching contour.

4. The method according to claim 1, wherein The determining of the target subject contour from the plurality of first contours comprises: The first contour with the largest contour size among the plurality of first contours is taken as the contour of the target subject, or the first contour at the highest level in the hierarchy among the plurality of first contours is taken as the contour of the target subject.

5. The method according to claim 1, wherein Before calculating the Hu moments of the target body contour and each of the second contours, the method further includes: Contours whose inner areas are smaller than an area threshold among the plurality of first contours and the plurality of second contours are filtered out.

6. The method according to claim 1, characterized in that Before contour extraction is performed on the image to be positioned, the following steps are also included: performing binarization processing on the image to be located; Before performing contour extraction on the test interface image, the following steps are also included: The test interface image is binarized.

7. An image positioning device, characterized in that: include: A first contour extraction module is configured to perform contour extraction on the image to be positioned to obtain a plurality of first contours, and determine a target subject contour from the plurality of first contours, wherein the target subject contour is a subject contour of the image to be positioned; A second contour extraction module is used to extract the contour of the test interface image to obtain multiple second contours; A calculation module, configured to calculate the Hu moment of the target body contour and each of the second contours; a matching module, configured to determine a degree of matching between the target subject contour and each of the second contours based on a difference between the Hu moment of the target subject contour and the Hu moment of each of the second contours, so as to determine a matching contour corresponding to the target subject contour from the plurality of second contours; the degree of matching between the target subject contour and the corresponding matching contour being greater than a matching degree threshold; A target area determination module is configured to extract feature points from the image to be positioned to obtain a first feature point set, and extract feature points from the test interface image to obtain a second feature point set; traverse all feature points in the first feature point set, and whenever a feature point in the first feature point set is traversed, determine whether there is a matching feature point corresponding to the feature point in the second feature point set based on a similarity threshold; if so, use the feature point and the corresponding matching feature point as a matching point pair; and determine a target area based on each matching feature point when the number of matching point pairs is greater than or equal to a preset number; A positioning module is used to determine the position of the image to be positioned in the test interface image according to the position of the matching contour and the position of the target area.

8. A storage medium, characterized in that: The storage medium stores computer-readable instructions, which, when executed by one or more processors, enable the one or more processors to perform the steps of the image positioning method according to any one of claims 1 to 6.

9. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the image positioning method according to any one of claims 1 to 6 are performed.

Citation Information

Patent Citations

  • Image contour identification method and device, equipment and medium

    CN110222703A

  • Rectangular control identification method and device, terminal and storage medium

    CN110503682A