Image matching method and device, electronic equipment and storage medium
By determining and normalizing the detection box in image matching technology, the problem of low efficiency of ultra-large-scale layout matching is solved, and faster and more accurate image matching is achieved.
Patent Information
- Application Number
- CN202411114469.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-29
AI Technical Summary
When existing image matching technology processes complex super-large-scale maps, it lacks multi-level matching, resulting in slow recognition and matching speed and low image matching efficiency.
By determining the detection boxes of the plurality of first sub-graphics in the image to be matched and the plurality of second sub-graphics in the template image, and normalizing the detection boxes, eliminating the scale differences, and initially determining the image matching result, Improve matching efficiency.
Through the preliminary processing of multi-level image matching, the efficiency of image matching is improved, the matching time is reduced, and the accuracy and robustness of image matching are improved.
Smart Images

Figure CN119049076A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image analysis, and in particular to an image matching method, device, electronic device and storage medium. Background Art
[0002] At present, in the process of circuit design, image matching technology is usually used to improve the circuit design drawing. For example, in very large scale integrated circuit (VLSI) design, template matching technology is usually used to determine the target design drawing to improve design efficiency, reduce design error rate and optimize manufacturing process. However, when dealing with complex and very large-scale layouts, the existing image matching technology has a slow recognition and matching speed due to the lack of multi-level matching, which leads to a longer overall matching time and inefficient image matching. Summary of the invention
[0003] In view of the above, it is necessary to propose an image matching method, device, electronic device and storage medium to solve the technical problem of low efficiency of image matching.
[0004] The present application provides an image matching method, which is applied to an electronic device, and the method includes: determining a first detection frame of multiple first sub-graphics in an image to be matched; determining a second detection frame of multiple second sub-graphics in a template image; normalizing all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames; when the third detection frame matches the fourth detection frame, determining an image matching result based on the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame.
[0005] In some embodiments, determining a first detection frame of at least one first sub-graphic in an image to be matched includes: converting the image to be matched into a grayscale image; extracting edge features in the grayscale image to obtain the multiple first sub-graphics; and determining a first detection frame corresponding to the first sub-graphic based on the edge features corresponding to the first sub-graphic.
[0006] In some embodiments, determining the first detection frame corresponding to the first sub-graph according to the edge feature corresponding to the first sub-graph includes: determining the coordinate information of the pixel point in the edge feature in the image coordinate system of the image to be matched; determining the maximum coordinate and the minimum coordinate of each dimension according to the coordinate information; determining the vertex coordinates according to the maximum coordinates and the minimum coordinates, and determining the first detection frame according to the vertex coordinates.
[0007] In some embodiments, the normalization processing of all the first detection frames and the second detection frames to obtain the third detection frame corresponding to each first detection frame and the fourth detection frame corresponding to each second detection frame includes: determining a reference point in the first detection frame and the second detection frame; calculating the coordinate offset of each pixel point in the first detection frame and the second detection frame according to the reference point and a preset scaling ratio; determining the third detection frame according to the coordinates of each pixel point in the first detection frame and the coordinate offset; and determining the fourth detection frame according to the coordinates of each pixel point in the second detection frame and the coordinate offset.
[0008] In some embodiments, the method also includes a step of determining that the third detection box matches the fourth detection box, and the step of determining that the third detection box matches the fourth detection box includes: when a first anchor point preset in the third detection box coincides with a second anchor point preset in the fourth detection box, and a pixel point in the third detection box coincides with a pixel point in the fourth detection box, determining that the third detection box coincides with the fourth detection box.
[0009] In some embodiments, determining the image matching result based on the first sub-graphic corresponding to the third detection box and the second sub-graphic corresponding to the fourth detection box includes: when each pixel point in the first sub-graphic coincides with each pixel point in the second sub-graphic, determining that the first sub-graphic matches the second sub-graphic; when any pixel point in the first sub-graphic does not coincide with all pixel points in the second sub-graphic, determining that the first sub-graphic does not match the second sub-graphic.
[0010] In some embodiments, the method further includes: when any one of the third detection frames does not match all of the fourth detection frames, determining that the image to be matched does not match the template image.
[0011] An embodiment of the present application also provides an image matching device, which includes: a determination module, used to determine a first detection frame of multiple first sub-graphics in an image to be matched; the determination module, used to determine a second detection frame of multiple second sub-graphics in a template image; a normalization module, used to normalize all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each first detection frame and a fourth detection frame corresponding to each second detection frame; and a matching module, used to determine the image matching result according to the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame when the third detection frame matches the fourth detection frame.
[0012] An embodiment of the present application also provides an electronic device, comprising: a memory storing at least one instruction; and a processor executing the instruction stored in the memory to implement the image matching method.
[0013] An embodiment of the present application also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the image matching method.
[0014] It can be seen from the above technical solutions that the embodiment of the present application provides data support for multi-level image matching by determining the first detection frames of multiple first sub-graphics in the image to be matched and the second detection frames of multiple second sub-graphics in the template image. In order to eliminate the negative impact of scale differences on image matching, all first detection frames and second detection frames are also normalized to obtain the third detection frame corresponding to each first detection frame and the fourth detection frame corresponding to each second detection frame. And preliminarily determine whether the image to be matched and the template image match based on the third detection frame and the fourth detection frame. When the third detection frame matches the fourth detection frame, the image matching result is determined based on the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame. In this way, the image to be matched and the template graphic can be preliminarily matched through the detection frame before graphic matching, thereby improving the efficiency of image matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is an application scenario diagram of an image matching method provided in one embodiment of the present application.
[0016] Figure 2 This is a flowchart of an image matching method provided in one embodiment of the present application.
[0017] Figure 3 This is a flowchart of a method for determining a first detection frame provided by an embodiment of the present application.
[0018] Figure 4 It is a flowchart of a method for determining a third detection frame and a fourth detection frame provided by an embodiment of the present application.
[0019] Figure 5 This is a flowchart of a method for determining a matching result provided in one embodiment of the present application.
[0020] Figure 6 It is a functional module diagram of an image matching device provided in one embodiment of the present application.
[0021] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to more clearly understand the purpose, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other. In the following description, many specific details are set forth to facilitate a full understanding of the present application, and the embodiments described are only a part of the embodiments of the present application, rather than all of the embodiments.
[0023] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0025] The embodiment of the present application provides an image matching method, which can be applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA), a digital processor (Digital Signal Processor, DSP), an embedded device, etc.
[0026] An electronic device can be any electronic product that can interact with a customer, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0027] The electronic device may also include a network device and / or a client device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0028] The network where the electronic device is located includes but is not limited to the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.
[0029] like Figure 1 As shown, an image matching method provided by the present application can be applied to an electronic device 100, and the electronic device 100 is connected to a server 200 for communication. The electronic device 100 is used to obtain an image to be matched and a template image from the server 200, determine a first detection frame of multiple first sub-graphs in the image to be matched; determine a second detection frame of multiple second sub-graphs in the template image; perform normalization processing on all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames; based on the template matching algorithm, when the third detection frame matches the fourth detection frame, determine the image matching result according to the first sub-graph corresponding to the third detection frame and the second sub-graph corresponding to the fourth detection frame.
[0030] Among them, the template matching algorithm is an image recognition method used to identify the location of a specific object in image processing. Specifically, it compares a known small image (template) with each area in a large image to find the area most similar to the template, thereby determining the location of the target object. Template matching methods include correlation method, error method, quadratic matching error method, etc., and in practical applications, algorithm optimization and improvement may be required according to specific circumstances.
[0031] In some embodiments, template matching can be used in the design phase of integrated circuits. Specifically, designers may need to verify whether certain functional modules or circuit layouts meet expectations, so some aspects of the design can be verified based on the idea of template matching. For example, designers can create an expected output template and compare it with actual simulation or test results to verify the correctness of the design.
[0032] In some embodiments, template matching can be used in the test phase of an integrated circuit. For example, during the test process, a template response of a normal operation can be created and compared with the response of the chip under test. If the difference exceeds a certain threshold, it may indicate that the chip is faulty.
[0033] In some embodiments, template matching can be used in the layout and routing stage of integrated circuits. Specifically, in the layout and routing stage of integrated circuits, designers need to ensure that the layout of the circuit is reasonable and the routing is correct. Although this usually relies on professional EDA (electronic design automation) tools, the idea of template matching can be used to verify whether certain layout or routing rules are correctly executed. For example, a designer can define a set of template rules for layout or routing, and use these rules to check whether the actual layout or routing meets expectations.
[0034] In some embodiments, during the packaging and testing phase of the integrated circuit, the idea of template matching can also be used to verify the integrity of the packaging and the accuracy of the test. For example, during the packaging process, a template image of the completed packaging can be created and compared with the actual packaging result to verify the correctness of the packaging. During the testing process, the idea of template matching can also be used to verify the consistency of the test results.
[0035] like Figure 2 , is a flow chart of an image matching method provided in an embodiment of the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. An image matching method provided in an embodiment of the present application includes the following steps.
[0036] S20, determining first detection frames of a plurality of first sub-graphics in the image to be matched.
[0037] In one embodiment of the present application, the image to be matched includes multiple first sub-graphs. Specifically, the image to be matched (also called a target image or a search image) may be an image that needs to be searched to find an area similar to or matching a given template image. The image to be matched is part of the algorithm input and is processed together with the template image (usually a small and known image fragment or feature). The purpose of template matching is to find the area in the image to be matched that is most similar to or matches the template image. This technology is widely used in computer vision and image processing fields, such as facial recognition, object detection, document processing, medical image analysis, etc. The image to be matched can be any type of image. For example, the image to be matched can be a natural scene image: such as landscape, street scene, portrait, etc., in which specific objects or features are searched; it can also be a medical image: such as X-ray, CT scan, MRI image, etc., used to find lesions, organs, tissue structures, etc.; it can also be a satellite image: search for cities, rivers, roads, forests and other geographical features in satellite images of the earth's surface; it can also be a document image: search for specific text, icons, signatures, etc. in scanned documents or photos; it can also be an industrial image: detect defects, measure dimensions, identify parts, etc. in product images on the production line.
[0038] In one embodiment of the present application, the template matching algorithm achieves matching by comparing the template image with small areas of all possible locations in the image to be matched (usually in a sliding window manner). These comparisons are usually based on similarity metrics (e.g., correlation coefficient, squared difference, normalized squared difference, etc.) to determine which area in the template and the image to be matched is most similar.
[0039] In one embodiment of the present application, in order to determine the first detection frame of multiple first sub-graphs in the image to be matched, the image processing library (such as OpenCV or Matlab's Image Processing Toolbox) can be used to read the image file containing the first sub-graph. Then the image to be matched is preprocessed to obtain the corresponding grayscale image; and the edge features in the grayscale image are determined to obtain the position of the first sub-graph; and then the first detection frame of the first sub-graph is determined based on the edge features, wherein the first detection frame can be the minimum circumscribed rectangle of the first sub-graph. For details, please refer to Figure 3 The corresponding detailed description.
[0040] S21, determining a second detection frame of a plurality of second sub-graphics in the template image.
[0041] In one embodiment of the present application, a template image is usually a known image fragment with specific features or patterns. This image fragment is used as a "template" to search for similar or matching areas in a larger image to be matched (or called a target image or a search image). The second sub-graph in the template image can be any small image with clearly defined features or shapes, which can be colors, textures, edges, shape contours, etc. The selection of the template image depends on the specific application scenario and the object to be detected or recognized. For example, in facial recognition, the template image may be an image of a specific part of a face (such as eyes, nose, mouth); in object detection, the template image may be a representative view of the object to be detected; in document processing, the template image may be an image of a specific text, icon or symbol to be recognized; in medical image processing, the template image may be a typical image of a certain lesion or tissue structure. The size and complexity of the template image can be adjusted according to the specific application. Smaller template images can be processed faster, but may not be easy to find matches in complex or noisy backgrounds. Larger template images may contain more feature information, thereby increasing the accuracy of matching, but also increase computational complexity and processing time.
[0042] In one embodiment of the present application, a method for determining a second detection frame of a plurality of second sub-images in a template image is the same as a method for determining a first detection frame, and is not described in detail herein.
[0043] S22, normalize all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames.
[0044] In one embodiment of the present application, in order to improve the robustness and accuracy of image matching, the template image and the image to be matched can be normalized. Specifically, the normalization process can eliminate the influence of illumination and brightness changes: the normalization process can limit the image data (including the template image and the image to be matched) to a certain range (such as [0, 1] or [-1, 1]), thereby eliminating the influence of brightness differences caused by changes in illumination conditions or uneven image brightness on the matching results. This helps to accurately find the position of the template image in the image to be matched when the illumination conditions change greatly. Normalization can also improve the stability of the matching algorithm, for example, reduce the adverse effects of singular samples (such as noise, extreme brightness values, etc.) in the image data on the matching results, and make the matching algorithm more stable. This helps to maintain a high matching accuracy rate when there is noise, occlusion or other interference factors in the image. Normalization can also optimize the calculation process. For example, in some template matching algorithms, such as the Normalized Cross-Correlation (NCC) algorithm, normalization is part of the algorithm itself. This processing can make the algorithm more efficient and accurate when calculating similarity because it eliminates the bias caused by image brightness differences. Normalization can also ensure that the image matching process adapts to different scale changes. Although normalization itself does not directly change the scale of the image, combined with multi-scale representation methods such as image pyramids, images of different scales can be normalized and template matching can be performed at multiple scales. This helps to find the best matching position of the template image when there are scale changes in the image. Specifically, the first detection box and the second detection box are normalized to obtain the third detection box corresponding to each first detection box and the fourth detection box corresponding to each second detection box. Please refer to Figure 4 The corresponding detailed description.
[0045] S23, when the third detection frame matches the fourth detection frame, determine an image matching result according to a first sub-graphic corresponding to the third detection frame and a second sub-graphic corresponding to the fourth detection frame.
[0046] In one embodiment of the present application, in order to improve the efficiency of image matching, the image to be matched and the template image may be preliminarily matched based on the third detection frame and the fourth detection frame. When any third detection frame can match one of the fourth detection frames among the fourth detection frames, it is determined that the similarity between the image to be matched and the template image is high, and image matching may continue to be performed based on the first sub-graph corresponding to the third detection frame and the second sub-graph corresponding to the fourth detection frame.
[0047] In one embodiment of the present application, determining that the third detection frame matches the fourth detection frame includes: when a first anchor point preset in the third detection frame coincides with a second anchor point preset in the fourth detection frame, and a pixel point in the third detection frame coincides with a pixel point in the fourth detection frame, determining that the third detection frame coincides with the fourth detection frame. Specifically, the preset first anchor point may be any pixel point in the third detection frame, and the preset second anchor point may be any pixel point in the fourth detection frame. And the relative position of the preset first anchor point in the third detection frame is the same as the relative position of the preset second anchor point in the fourth detection frame. Exemplarily, when the third detection frame is a rectangle and the preset first anchor point is the vertex of the upper left corner of the third detection frame, the preset second anchor point is the vertex of the upper left corner of the fourth detection frame.
[0048] In an embodiment of the present application, the method further includes: when any one of the third detection frames does not match all of the fourth detection frames, determining that the image to be matched does not match the template image.
[0049] In one embodiment of the present application, when any third detection frame can match one of the fourth detection frames in the plurality of fourth detection frames, it is determined that the similarity between the image to be matched and the template image is high, and image matching can be continued based on the first sub-graph corresponding to the third detection frame and the second sub-graph corresponding to the fourth detection frame. For a specific method of determining a matching result based on the first sub-graph and the second sub-graph, please refer to Figure 5 The corresponding detailed description.
[0050] It can be seen from the above technical solutions that the embodiment of the present application provides data support for multi-level image matching by determining the first detection frames of multiple first sub-graphics in the image to be matched and the second detection frames of multiple second sub-graphics in the template image. In order to eliminate the negative impact of scale differences on image matching, all first detection frames and second detection frames are also normalized to obtain the third detection frame corresponding to each first detection frame and the fourth detection frame corresponding to each second detection frame. And preliminarily determine whether the image to be matched and the template image match based on the third detection frame and the fourth detection frame. When the third detection frame matches the fourth detection frame, the image matching result is determined based on the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame. In this way, the image to be matched and the template graphic can be preliminarily matched through the detection frame before graphic matching, thereby improving the efficiency of image matching.
[0051] like Figure 3 , is a flow chart of a method for determining a first detection frame provided by an embodiment of the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. The method for determining a first detection frame provided by an embodiment of the present application includes the following steps.
[0052] S30, converting the image to be matched into a grayscale image.
[0053] In one embodiment of the present application, in the process of identifying the first detection frame, in order to improve the efficiency of edge features in the image to be matched, the image to be matched may be preprocessed to obtain a grayscale image. Each pixel in the grayscale image contains only the value of one channel, and the value of each pixel is 0 to 255. Exemplarily, the image to be matched may be converted into a grayscale image based on a pre-stored color conversion code. For example, the pre-stored color conversion code may be the code "gray = cv2.cvtColo r(image, cv2.COLOR_BGR2GRAY)" in the OpenCV framework.
[0054] S31, extracting edge features in the grayscale image to obtain the plurality of first sub-graphs.
[0055] In one embodiment of the present application, the edge features in the grayscale image are used to characterize the contour in the grayscale image, that is, the first sub-graph in the image to be matched. Specifically, the edge features in the grayscale image can be determined based on a preset edge detection algorithm. For example, the preset edge detection algorithm can be a Sobel operator or a Canny operator, which is not limited in the present application.
[0056] S32: Determine a first detection frame corresponding to the first sub-graphic according to an edge feature corresponding to the first sub-graphic.
[0057] In one embodiment of the present application, the minimum bounding rectangle of each first sub-graph can be determined according to the edge features corresponding to each first sub-graph, and the minimum bounding rectangle is determined as the first detection frame corresponding to the first sub-graph. Specifically, according to the edge features corresponding to the first sub-graph, determining the first detection frame corresponding to the first sub-graph includes: determining the coordinate information of the pixel points in the edge features in the image coordinate system of the image to be matched; determining the maximum coordinate and the minimum coordinate of each dimension according to the coordinate information; determining the vertex coordinates according to the maximum coordinates and the minimum coordinates, and determining the first detection frame according to the vertex coordinates.
[0058] like Figure 4 , is a flowchart of a method for determining a third detection frame and a fourth detection frame provided by an embodiment of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. The method for determining a third detection frame and a fourth detection frame provided by an embodiment of the present application includes the following steps.
[0059] S40: Determine reference points in the first detection frame and the second detection frame.
[0060] In an embodiment of the present application, the reference point may be any pixel point in the third detection frame and the fourth detection frame, and the relative position of the reference point in the third detection frame is the same as the relative position of the reference point in the fourth detection frame. Exemplarily, when the third detection frame is a rectangle, and the reference point in the third detection frame is the vertex of the upper left corner of the third detection frame, the reference point in the fourth detection frame is also the vertex of the upper left corner of the fourth detection frame.
[0061] S41, calculating the coordinate offset of each pixel point in the first detection frame and the second detection frame according to the reference point and a preset scaling ratio.
[0062] In one embodiment of the present application, the preset scaling ratio is used to characterize the ratio between the size of the first detection frame before scaling and the size after scaling. Specifically, the position of the reference point can be ensured to remain unchanged, the size of the first detection frame after scaling is determined according to the preset scaling ratio, and the coordinate offset of each pixel in the first detection frame is determined based on the position of the reference point and the size of the first detection frame after scaling. The size of the second detection frame after scaling is determined according to the preset scaling ratio, and the coordinate offset of each pixel in the second detection frame is determined based on the position of the reference point and the size of the second detection frame after scaling.
[0063] S42: Determine a third detection frame according to the coordinates of each pixel point in the first detection frame and the coordinate offset.
[0064] In one embodiment of the present application, the difference between the coordinates of each pixel point in the first detection frame and the coordinate offset can be determined, and the difference is determined as the coordinates corresponding to each pixel point in the first detection frame obtained after the first detection frame is scaled.
[0065] S43: Determine a fourth detection frame according to the coordinates of each pixel point in the second detection frame and the coordinate offset.
[0066] In one embodiment of the present application, the difference between the coordinates of each pixel point in the second detection frame and the coordinate offset can be determined, and the difference is determined as the coordinates corresponding to each pixel point in the second detection frame obtained after the second detection frame is scaled.
[0067] like Figure 5 , is a flow chart of a method for determining a matching result provided in an embodiment of the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. The method for determining a matching result provided in an embodiment of the present application includes the following steps.
[0068] S50: When each pixel point in the first sub-graph coincides with each pixel point in the second sub-graph, determine that the first sub-graph matches the second sub-graph.
[0069] In one embodiment of the present application, when each pixel in the first sub-graph coincides with each pixel in the second sub-graph, it indicates that the first sub-graph and the second sub-graph have the same shape, and it can be determined that the first sub-graph and the second sub-graph match.
[0070] S51: When any pixel point in the first sub-graph does not overlap with all pixel points in the second sub-graph, determine that the first sub-graph does not match the second sub-graph.
[0071] See also Figure 6 , Figure 6 6 is a functional module diagram of an image matching device provided in an embodiment of the present application. An image matching device 61 includes a determination module 610, a normalization module 611 and a matching module 612. The module / unit referred to in the present application refers to a series of computer-readable instruction segments that can be executed by the processor 13 and can complete a fixed function, which is stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0072] The determination module 610 is used to determine a first detection frame of a plurality of first sub-graphs in the image to be matched.
[0073] The determination module 610 is used to determine a second detection frame of a plurality of second sub-graphics in the template image.
[0074] The normalization module 611 is used to perform normalization processing on all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames.
[0075] The matching module 612 is used to determine the image matching result according to the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame when the third detection frame matches the fourth detection frame.
[0076] See also Figure 7 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 100 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 is used to execute the computer-readable instructions stored in the memory to implement an image matching method described in any of the above embodiments.
[0077] In an embodiment of the present application, the electronic device 100 further includes a bus, and a computer program stored in the memory 12 and executable on the processor 13, such as an image matching program.
[0078] Figure 7 Only the electronic device 100 having the memory 12 and the processor 13 is shown, and those skilled in the art can understand that Figure 7 The structure shown does not constitute a limitation on the electronic device 100 , and the electronic device 100 may include fewer or more components than shown in the figure, or combine some components, or arrange the components differently.
[0079] Combination Figure 2 The memory 12 in the electronic device 100 stores a plurality of computer-readable instructions to implement an image matching method, and the processor 13 can execute the plurality of instructions to implement: determining a first detection frame of a plurality of first sub-graphics in an image to be matched; determining a second detection frame of a plurality of second sub-graphics in a template image; normalizing all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames; and determining an image matching result according to a first sub-graphic corresponding to the third detection frame and a second sub-graphic corresponding to the fourth detection frame when the third detection frame matches the fourth detection frame.
[0080] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 2 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0081] Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 100 and does not constitute a limitation on the electronic device 100. The electronic device 100 may be a bus-type structure or a star-type structure. The electronic device 100 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the electronic device 100 may also include input and output devices, network access devices, etc.
[0082] It should be noted that the electronic device 100 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.
[0083] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium can be non-volatile or volatile. The readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 100, such as a mobile hard disk of the electronic device 100. In other embodiments, the memory 12 can also be an external storage device of the electronic device 100, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 100. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 100, such as a code of an image matching program, etc., but can also be used to temporarily store data that has been output or is to be output.
[0084] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 100, and uses various interfaces and lines to connect various components of the entire electronic device 100, and executes or executes programs or modules stored in the memory 12 (for example, executes an image matching program, etc.), and calls data stored in the memory 12 to execute various functions of the electronic device 100 and process data.
[0085] The processor 13 executes the operating system of the electronic device 100 and various installed applications. The processor 13 executes the applications to implement the steps in each of the above-mentioned image matching method embodiments, for example Figure 2 Steps shown.
[0086] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 100. For example, the computer program may be divided into a determination module 610, a normalization module 611, and a matching module 612.
[0087] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of an image matching method described in each embodiment of the present application.
[0088] If the module / unit integrated in the electronic device 100 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware devices to complete through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0089] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory and other memory, etc.
[0090] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0091] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. Figure 4 Only one arrow is used in the figure, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0092] An embodiment of the present application also provides a computer-readable storage medium (not shown), in which computer-readable storage medium is stored computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement an image matching method described in any of the above embodiments.
[0093] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0094] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0095] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0096] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. An image matching method, applied to an electronic device, characterized in that: The method comprises: Determine a first detection frame of a plurality of first sub-graphs in the image to be matched; Determine a second detection frame of a plurality of second sub-graphics in the template image; Normalizing all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames; In the case where the third detection frame matches the fourth detection frame, an image matching result is determined according to a first sub-graph corresponding to the third detection frame and a second sub-graph corresponding to the fourth detection frame.
2. The image matching method according to claim 1, characterized in that: The step of determining a first detection frame of at least one first sub-graph in the image to be matched comprises: Converting the image to be matched into a grayscale image; Extracting edge features in the grayscale image to obtain the plurality of first sub-graphs; A first detection frame corresponding to the first sub-graphic is determined according to an edge feature corresponding to the first sub-graphic.
3. The image matching method according to claim 2, characterized in that: The determining, according to the edge feature corresponding to the first sub-graphic, a first detection frame corresponding to the first sub-graphic comprises: Determine coordinate information of a pixel point in the edge feature in an image coordinate system of the image to be matched; Determine the maximum coordinate and the minimum coordinate of each dimension according to the coordinate information; Vertex coordinates are determined according to the maximum coordinates and the minimum coordinates, and the first detection frame is determined according to the vertex coordinates.
4. The image matching method according to claim 1, characterized in that: The normalizing process of all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames includes: Determining reference points in the first detection frame and the second detection frame; Calculating the coordinate offset of each pixel point in the first detection frame and the second detection frame according to the reference point and a preset scaling ratio; Determine a third detection frame according to the coordinates of each pixel point in the first detection frame and the coordinate offset; The fourth detection frame is determined according to the coordinates of each pixel point in the second detection frame and the coordinate offset.
5. The image matching method according to claim 1, characterized in that: The method further includes a step of determining that the third detection frame matches the fourth detection frame, wherein the step of determining that the third detection frame matches the fourth detection frame includes: When the first anchor point preset in the third detection frame coincides with the second anchor point preset in the fourth detection frame, and the pixel points in the third detection frame coincide with the pixel points in the fourth detection frame, it is determined that the third detection frame coincides with the fourth detection frame.
6. The image matching method according to claim 1, characterized in that: The determining of the image matching result according to the first sub-graphic corresponding to the third detection frame and the second sub-graphic corresponding to the fourth detection frame comprises: When each pixel point in the first sub-graph coincides with each pixel point in the second sub-graph, determining that the first sub-graph matches the second sub-graph; In the case where any pixel point in the first sub-graph does not overlap with all pixel points in the second sub-graph, it is determined that the first sub-graph does not match the second sub-graph.
7. The image matching method according to claim 5, characterized in that: The method further comprises: In the case that any one of the third detection frames does not match all of the fourth detection frames, it is determined that the image to be matched does not match the template image.
8. An image matching device, comprising a module for implementing the method according to any one of claims 1 to 7, characterized in that: The device comprises: A determination module, used to determine a first detection frame of a plurality of first sub-graphs in an image to be matched; The determination module is used to determine a second detection frame of a plurality of second sub-graphics in the template image; a normalization module, configured to perform normalization processing on all the first detection frames and the second detection frames to obtain a third detection frame corresponding to each of the first detection frames and a fourth detection frame corresponding to each of the second detection frames; A matching module is used to determine an image matching result according to a first sub-graphic corresponding to the third detection frame and a second sub-graphic corresponding to the fourth detection frame when the third detection frame matches the fourth detection frame.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, and the processor is used to implement the image matching method according to any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image matching method according to any one of claims 1 to 7 is implemented.
