Image matching method and device, electronic device and storage medium
By determining the center point and extending the line in image matching, and judging the number of intersections or the intersection-union ratio, the problem of high computational cost is solved, and the efficiency of image detection and analysis is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-07-07
AI Technical Summary
The computational cost of acquiring the target region in existing technologies is high, resulting in low efficiency in image detection and analysis.
By obtaining the center points of the reference region and the region to be matched, the line to be matched is extended along a preset direction, and the intersection point of the line to be matched and the reference region is determined. The number of intersection points or the intersection-union ratio is judged to determine the region matching, thus avoiding the need to analyze individual pixels.
It improves the matching efficiency between the region to be matched and the reference region, reduces the computational cost, and enhances the efficiency of image detection and analysis.
Smart Images

Figure CN116051871B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular to an image matching method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the continuous development of information technology, computer vision and image processing technologies are being used more and more widely in fields such as autonomous driving, remote sensing satellites, and security monitoring. In the process of image detection and analysis, the selection of the target region within the detected image significantly affects the accuracy of the final detection results.
[0003] To obtain the target region of a target object within a region of interest (ROI), related techniques first segment the image to be detected, obtaining a foreground portion that includes all target objects. Based on the foreground portion, the target contour of the target object is obtained. Further, a pre-defined circumscribed region is used to cover the target contour, resulting in the circumscribed region. Finally, based on the intersection-union ratio (IU) between the circumscribed region and the ROI, the circumscribed region with the higher IU is selected as the target region of the target object within the ROI. However, the above methods require analysis of every pixel in the image to be detected, which leads to excessive computational costs under high concurrency, resulting in low efficiency in obtaining the target region.
[0004] There is currently no effective solution to the technical problem of high computational cost in acquiring the target area in related technologies. Summary of the Invention
[0005] This embodiment provides an image matching method, apparatus, electronic device, and storage medium to address the problem of high computational cost in acquiring target regions in related technologies.
[0006] Firstly, this embodiment provides an image matching method, the method comprising:
[0007] Obtain a reference region and a region to be matched, wherein the reference region and the region to be matched are located on the same reference image;
[0008] Determine the center point of the region to be matched;
[0009] Extend the center point along a preset direction to obtain the straight line to be matched;
[0010] The intersection points of the line to be matched with each edge of the reference region are determined, and whether the region to be matched matches the reference region is determined based on the intersection points.
[0011] In some embodiments, obtaining the reference region and the region to be matched includes:
[0012] In response to a user instruction, the reference area is determined;
[0013] The reference image is input into the detection model to determine the region to be matched.
[0014] In some embodiments, determining the center point of the region to be matched includes:
[0015] Obtain multiple vertices of the region to be matched;
[0016] The center point of the region to be matched is determined based on the positions of the multiple vertices.
[0017] In some embodiments, determining the intersection points of the line to be matched with each edge of the reference region includes:
[0018] Determine the reference coordinate system;
[0019] The function expressions for determining the line to be matched and each edge segment of the reference region are based on the reference coordinate system.
[0020] The intersection points of the line to be matched and each edge of the reference region are determined based on the function expression.
[0021] In some embodiments, determining whether the region to be matched matches the reference region based on the intersection point includes:
[0022] Determine whether any of the intersection points coincide with the vertices of the reference region; if not, determine the number of intersection points.
[0023] If the number of intersection points is odd, then the reference region matches the region to be matched;
[0024] If the number of intersection points is even, then the reference region does not match the region to be matched.
[0025] In some embodiments, after determining whether there is an intersection point that coincides with a vertex of the reference region, the method further includes:
[0026] If it exists, then determine the intersection-union ratio between the reference region and the region to be matched;
[0027] The cross-union ratio is used to determine whether the region to be matched matches the reference region.
[0028] In some embodiments, after determining whether the region to be matched matches the reference region based on the intersection point, the method further includes:
[0029] If the reference region and the region to be matched match, then the region to be matched is determined to be the target region.
[0030] Secondly, this embodiment provides an image matching device, including:
[0031] The acquisition module is used to acquire a reference region and a region to be matched, wherein the reference region and the region to be matched are located on the same reference image;
[0032] The determination module is used to determine the center point of the region to be matched;
[0033] The extension module is used to extend the center point along a preset direction to obtain the straight line to be matched;
[0034] The matching module is used to determine the intersection points of the line to be matched with each edge of the reference area, and to determine whether the area to be matched matches the reference area based on the intersection points.
[0035] Thirdly, this embodiment provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the image matching method described in the first aspect above.
[0036] Fourthly, this embodiment provides a storage medium storing a computer program that, when executed by a processor, implements the image matching method described in the first aspect above.
[0037] Compared with related technologies, this embodiment provides an image matching method, apparatus, electronic device, and storage medium. The method includes: acquiring a reference region and a region to be matched, wherein the reference region and the region to be matched are located on the same reference image; determining the center point of the region to be matched; extending the center point along a preset direction to obtain a line to be matched; determining the intersection points of the line to be matched with each edge of the reference region, and determining whether the region to be matched matches the reference region based on the intersection points. By determining the intersection points of the line to be matched extending from the center point of the region to be matched along a preset direction with each edge of the reference region, it is possible to directly determine whether the region to be matched overlaps with the reference region. Thus, the region to be matched that is determined to overlap is identified as the region that matches the reference region. This eliminates the need to analyze the pixels of the region to be matched and the reference region, solving the technical problem of high computational cost in acquiring the target region in related technologies, improving the matching efficiency between the region to be matched and the reference region, and thereby improving the efficiency of image detection and analysis.
[0038] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0039] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0040] Figure 1 This is a hardware structure block diagram of a terminal for an image matching method according to an embodiment of the present invention;
[0041] Figure 2 This is a schematic flowchart of an image matching method according to an embodiment of the present invention;
[0042] Figure 3 This is a schematic diagram of a reference area and a region to be matched according to an embodiment of the present invention;
[0043] Figure 4 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0044] Figure 5 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0045] Figure 6 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0046] Figure 7 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0047] Figure 8 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0048] Figure 9 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention;
[0049] Figure 10 This is a structural block diagram of an image matching device according to an embodiment of the present invention. Detailed Implementation
[0050] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0051] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning as understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these,” used in this application, do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to such processes, methods, products, or devices. The terms “connected,” “linked,” and “coupled,” used in this application, are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. The term “multiple” used in this application refers to two or more. The "and / or" operator describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: A alone, A and B simultaneously, and B alone. Typically, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," and "third," etc., used in this application are merely for distinguishing similar objects and do not represent a specific ordering of the objects.
[0052] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal for the image matching method in this embodiment. For example... Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.
[0053] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the image matching method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0054] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0055] Please see Figure 2 , Figure 2 This is a schematic flowchart of an image matching method according to an embodiment of the present invention.
[0056] In one embodiment, the image matching method includes:
[0057] S202: Obtain the reference region and the region to be matched, which are located on the same reference image.
[0058] For example, a reference region and a region to be matched are obtained based on the same reference image. The reference region is a manually selected region, i.e., the region of interest; the region to be matched is the boundary region generated after detecting the reference image. The overlap between the reference region and the region to be matched is used to determine whether they match, thereby obtaining the region to be matched that has a high overlap with the reference region.
[0059] Specifically, the outlines of the reference area and the area to be matched can be composed of the edge segments of straight lines and / or curves. The shapes of the reference area and the area to be matched can be concave or convex. This embodiment does not limit the reference area and the area to be matched, as long as they are closed areas.
[0060] S204: Determine the center point of the region to be matched.
[0061] For example, the center point of the region to be matched is determined, and the degree of overlap between the reference region and the region to be matched is determined by the positional relationship between the center point and the reference region. For instance, if the center point is located within the reference region, the degree of overlap between the reference region and the region to be matched is determined to be high, and the two are matched; if the center point is located outside the reference region, the degree of overlap between the reference region and the region to be matched is determined to be low, and the two are not matched.
[0062] Specifically, the center point of the region to be matched is its geometric center. For example, if the region is circular, its center point is the center of the circle; if the region is rectangular, its center point is the intersection of its diagonals. More specifically, selecting any point within the region to be matched, the lower the dispersion of the distances from that point to multiple boundary points of the region, the closer that point is to the center point. Understandably, the selection of multiple boundary points is based on their ability to describe the contour of the region to be matched; the more boundary points there are and the more evenly distributed they are, the clearer the contour of the region to be matched will be.
[0063] S206: Extend the center point along the preset direction to obtain the line to be matched.
[0064] For example, a ray is drawn along a preset direction based on the center point of the region to be matched, thus obtaining the line to be matched, which is actually represented as a ray in the image. The preset direction is not limited and can be set according to the actual scene. It is preferable to choose the line to be matched with less computational cost.
[0065] S208: Determine the intersection points of the line to be matched with each edge of the reference area, and determine whether the area to be matched matches the reference area based on the intersection points.
[0066] For example, the intersection points of the line to be matched with all the edges of the reference area are determined. Based on parameters such as the number of intersection points, the degree of overlap between the area to be matched and the reference area is determined, and then it is determined whether the two match.
[0067] Please see Figure 3 , Figure 3 This is a schematic diagram of a reference area and a region to be matched according to an embodiment of the present invention.
[0068] In one specific embodiment, region ABCD is a reference region, and the center points of the regions to be matched are M and N, respectively. Center points M and N are extended along a preset direction to obtain two lines L1 and L2 to be matched corresponding to center point M, and two lines L1' and L2' to be matched corresponding to center point N. Figure 3It can be seen that when the number of intersection points is 1, the line to be matched must pass through an edge line from within the reference area to enter outside the reference area (as shown in L1 and L2), and the center point is located within the reference area (as shown in M). When there are two intersection points, the line to be matched must first pass through an edge line from outside the reference area to enter the reference area, and then pass through another edge line to enter outside the reference area (as shown in L1'), and the center point is located outside the reference area (as shown in N). When there are 0 intersection points, the line to be matched must not pass through any edge line of the reference area (as shown in L2'), and the center point is also located outside the reference area (as shown in N). Therefore, based on the characteristics of the number of intersection points, it can be directly determined that the area to be matched corresponding to the center point M is within the reference area, that is, the two match, while the area to be matched corresponding to the center point N is outside the reference area, that is, the two do not match.
[0069] In one specific embodiment, the reference image is a group photo image. The user can directly define a region of interest (reference region) on the group photo image. The region of interest includes the target object that the user wants to highlight. The group photo image is then detected to obtain the target bounding box regions (matching regions) of all objects. The region of interest and the target bounding box regions are matched using the method of this embodiment to obtain a target bounding box region with a high degree of overlap with the region of interest. This target bounding box region is the target object region that the user wants to highlight.
[0070] In another specific embodiment, the reference image is a sample image during the training process of the network detection model. The sample image includes a labeled region (reference region). The network detection model to be trained detects the sample image to obtain multiple detection box regions (regions to be matched). The labeled region and the detection box regions are matched using the method of this embodiment to obtain the detection box region with the highest overlap with the labeled region. The parameters of the network detection model to be trained are adjusted based on the detection box region.
[0071] This embodiment acquires a reference region and a region to be matched, both located on the same reference image. It determines the center point of the region to be matched, extends the center point along a preset direction to obtain a matching line, and determines the intersection points of the matching line with each edge of the reference region. Based on these intersection points, it determines whether the region to be matched matches the reference region. By determining the intersection points of the matching line extending from the center point of the region to be matched along a preset direction with each edge of the reference region, it is possible to directly determine whether the region to be matched overlaps with the reference region. The region to be matched that is determined to overlap is then identified as the region that matches the reference region. This eliminates the need to analyze the pixels of the region to be matched and the reference region, solving the technical problem of high computational cost in acquiring the target region in related technologies, improving the matching efficiency between the region to be matched and the reference region, and thus improving the efficiency of image detection and analysis.
[0072] In another embodiment, obtaining the reference region and the region to be matched includes:
[0073] Step 1: In response to user instructions, determine the reference area;
[0074] Step 2: Input the reference image into the detection model to determine the region to be matched.
[0075] For example, the system obtains user input instructions and determines a reference region based on the parameters in the user instructions. These parameters include, but are not limited to, line parameters, curve parameters, number of vertices, vertex coordinates, curvature, and slope.
[0076] In one specific embodiment, relevant parameters from the input instructions are directly obtained, and a reference region is generated based on these parameters; in another specific embodiment, the user can directly define a region, obtain the parameters from the user-defined region, and generate a reference region.
[0077] For example, the region to be matched is the region containing the target object output after image detection of the reference image. The detection model for detecting the reference image includes deep learning models and handcrafted feature models. Deep learning models refer to detection models based on neural networks, including but not limited to algorithms such as YOLOv3 and Faster R-CNN. Handcrafted features refer to detection models built based on manually extracted image features, including but not limited to algorithms such as HOG and SIFT.
[0078] This embodiment determines the reference region based on user instructions and the region to be matched based on the detection model, thereby improving the accuracy of the reference region and the region to be matched, and thus improving the accuracy of image matching.
[0079] In another embodiment, determining the center point of the region to be matched includes:
[0080] Step 1: Obtain multiple vertices of the region to be matched;
[0081] Step 2: Determine the center point of the region to be matched based on the positions of multiple vertices.
[0082] For example, multiple vertices of the region to be matched are obtained, and the position coordinates of the center point of the region to be matched are calculated based on the coordinates of the multiple vertices in the reference image.
[0083] Specifically, the vertices of the region to be matched are preferably set as points where the slope or curvature of the region's contour changes abruptly. If the contour of the region to be matched does not have such points (for example, the contour of the region to be matched is a smooth contour that is nearly circular or nearly elliptical), then multiple evenly distributed boundary points are selected as the vertices of the region to be matched.
[0084] Specifically, select any point within the region to be matched, calculate multiple distances from that point to multiple vertices, and further calculate the dispersion of these multiple distances based on standard deviation or variance. When the dispersion of the multiple distances is the lowest (e.g., the variance is the smallest), then that point is determined as the center point.
[0085] In one specific embodiment, if the area to be matched is a rectangle, the intersection of the diagonals of the area to be matched is the center point; if the area to be matched is a circle or an ellipse, the center of the circle is the center point; if the area to be matched is a triangle, the centroid of the triangle is the center point.
[0086] This embodiment determines the center point of the region to be matched based on multiple vertices of the region to be matched, thereby ensuring that the method in this embodiment has high adaptability when the region to be matched is of any shape.
[0087] In another embodiment, determining the intersection points of the line to be matched with each edge of the reference region includes:
[0088] Step 1: Determine the reference coordinate system;
[0089] Step 2: Determine the function expressions for the line to be matched and each edge segment of the reference region based on the reference coordinate system;
[0090] Step 3: Determine the intersection points of the line to be matched with each edge of the reference area based on the function expression.
[0091] For example, to facilitate the determination of parameters for each edge and intersection point, a reference coordinate system is first established in the reference image. Preferably, the x-axis of the reference coordinate system extends along the horizontal direction of the reference image, and the y-axis extends along the vertical direction of the reference image, for ease of calculation.
[0092] For example, after establishing a reference coordinate system, the function expression of the line to be matched and the function expression of each edge segment of the reference region are determined respectively. Since the line to be matched is a ray, the range of the independent variable x in the function expression of the line to be matched is a semi-closed interval, such as (-∞, 10]. Since each edge segment of the reference region is a straight line segment or a closed curve with endpoints, the range of the independent variable x in the function expression of the edge segment is a fully closed interval, such as [10, 32].
[0093] For example, after determining the function expressions for the line to be matched and each edge segment of the reference area, the common solution of the two function expressions is obtained based on the function expressions of the line to be matched and each edge segment. This common solution is the coordinate of the intersection point between the line to be matched and the edge segment. If the two function expressions do not have a common solution, it indicates that the line to be matched and the edge segment do not intersect.
[0094] Please see Figure 4 , Figure 4 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention.
[0095] Specifically, such as Figure 4 As shown, each edge segment of the selected reference area is expressed using a function. Taking edge segment AB as an example, when the edge segment is a straight line, the coordinates of point A are (x...). a y a The coordinates of point B are (x, y). b y b ), thus obtaining its function expression:
[0096]
[0097] Obtain the center point M of the region to be matched, where the coordinates of point M are (x, y, y). m y m Extending the center point M horizontally towards the y-axis, we obtain the function expression for the line L1 to be matched:
[0098] y = y m , where x≤x m
[0099] Since the entire reference region lies within the first quadrant of the reference coordinate system, the case of x < 0 does not need to be considered. Therefore, the functional expression of the line L1 to be matched can be further simplified to:
[0100] y = y m , where 0≤x≤x m (2)
[0101] Substituting formula (2) into formula (1), we obtain the common solution (x, y), at which point x simultaneously satisfies x a ≤x≤x b and 0≤x≤x m Two conditions: the edge line segment intersects with the line to be matched.
[0102] Further, obtain the edge segments BC, CD, and AD, and repeat the above steps until it is determined whether each edge segment intersects with the line to be matched. Figure 4It can be seen that only the edge line segment AB intersects with the line L1 to be matched, that is, the number of intersections between the line L1 to be matched and the reference area ABCD is 1.
[0103] For example, if the aforementioned edge segment is a curve, then the function expression of the curve is calculated, or the function expression of the curve is fitted by a computer. The calculation method for the intersection point of the curve edge segment and the line to be matched is the same as the calculation method for the edge segment of the line, and will not be repeated in this embodiment.
[0104] This embodiment determines the function expressions of the line to be matched and each edge segment of the reference area, and calculates the coordinates of their intersection by solving the function expressions. The calculation process is easy to implement through computer logic, thereby reducing the cost of calculating the intersection coordinates.
[0105] In another embodiment, determining whether the region to be matched matches the reference region based on the intersection point includes:
[0106] Step 1: Determine if any of the intersection points coincide with the vertices of the reference region. If not, determine the number of intersection points.
[0107] Step 2: If the number of intersection points is odd, then the reference region is matched with the region to be matched;
[0108] Step 3: If the number of intersection points is even, then the reference area and the area to be matched do not match.
[0109] For example, after obtaining all intersection points between the reference region and the line to be matched, it is determined whether there are any boundary points among the intersection points that coincide with the vertices of the reference region. Here, the vertices of the reference region are the endpoints of the edge line segments of the reference region.
[0110] Please see Figures 5-6 , Figure 5 and Figure 6 These are schematic diagrams of the reference area and the area to be matched, respectively, according to another embodiment of the present invention.
[0111] For example, if there are no boundary points that coincide with vertices in the reference region, then the number of intersection points is obtained. Figure 5 as well as Figure 6 As shown, when the reference region is convex, if the center point is located within the reference region (e.g., ... Figure 5 and Figure 6 If the center point is located outside the reference area (e.g., point M), then the line to be matched must pass through one of the edge segments from within the reference area to outside the reference area, in which case the number of intersection points is 1; if the center point is located outside the reference area (e.g., point M), then the line to be matched must pass through one of the edge segments from within the reference area to outside the reference area, in which case the number of intersection points is 1; Figure 5 and Figure 6If the line to be matched intersects the reference area (N points), then the line must first pass through one edge segment from outside the reference area to enter the reference area, and then pass through another edge segment from the reference area to return to the outside of the reference area. In this case, the number of intersection points must be 2. Alternatively, the line to be matched and the reference area may not intersect, in which case the number of intersection points is 0. Based on this, when the number of intersection points is 1 (odd), the center point is located within the reference area, and the reference area and the area to be matched overlap, meaning they match. When the number of intersection points is 0 or 2 (even), the center point is located outside the reference area, and the reference area and the area to be matched do not overlap, meaning they do not match.
[0112] Please see Figure 7 , Figure 7 This is a schematic diagram of a reference area and a region to be matched according to another embodiment of the present invention.
[0113] For example, such as Figure 7 As shown, when the reference region is concave, there may be situations where the line to be matched intersects the reference region at more than two points. It is understandable that when the line to be matched extends to a certain extent, the points on the extension line will inevitably lie outside the reference region. Therefore, when the center point is within the reference region (e.g., ... Figure 7 In the case of point M in the reference area, the line to be matched must first pass through one of the edge segments from the reference area to outside the reference area. Afterwards, each time the line to be matched enters the reference area (creating one intersection point), it will inevitably extend out of the reference area (creating another intersection point). The number of intersection points generated at this time will always be 2K+1 (an odd number), where K is a natural number. When the center point is located outside the reference area (e.g., ... Figure 7 For each point N in the reference region (creating an intersection point), the line to be matched will inevitably extend out of the reference region (creating another intersection point) every time it enters the reference region. The total number of intersection points will be 2K (an even number). Therefore, when the number of intersection points is odd, the center point is within the reference region, and the reference region overlaps with the region to be matched, meaning they match. When the number of intersection points is even, the center point is outside the reference region, and the reference region does not overlap with the region to be matched, meaning they do not match.
[0114] Based on the above analysis, if there are no intersection points that coincide with vertices in the reference region, the parity of the number of intersection points can be used to determine whether the center point is located within or outside the reference region, and thus whether the reference region matches the region to be matched corresponding to the center point. If the number of intersection points is odd, the reference region matches the region to be matched; if the number of intersection points is even, the reference region does not match the region to be matched.
[0115] In this embodiment, when the intersection point does not coincide with the vertex of the reference region, the positional relationship between the center point and the reference region is determined directly by whether the number of intersection points is odd or even, thereby determining whether the reference region matches the region to be matched. This reduces the computational load of region matching and improves the speed of image matching.
[0116] In another embodiment, after determining whether there is an intersection point that coincides with a vertex of the reference region, the method further includes:
[0117] Step 1: If it exists, determine the intersection-union ratio (IUU) between the reference region and the region to be matched;
[0118] Step 2: Determine whether the region to be matched matches the reference region based on the intersection-union ratio.
[0119] Please see Figures 8-9 , Figure 8 as well as Figure 9 These are schematic diagrams of the reference area and the area to be matched, respectively, according to another embodiment of the present invention.
[0120] For example, when there is an intersection point that coincides with a vertex of the reference region, regardless of whether the number of these coinciding intersection points is considered 1 or 2, the relationship between the center point and the reference region cannot be determined based on the parity of the number of intersection points. For instance, if the number of these coinciding intersection points is considered 2, then... Figure 8 The number of intersection points is 3 (leading to the conclusion that the center point N is within the reference region). Figure 9 The number of intersection points is 4 (leading to the conclusion that the center point N is outside the reference area), but in reality... Figure 8 and Figure 9 The center point N in the reference area is outside the reference area.
[0121] For example, if there is an intersection point that coincides with the vertex of the reference region, the degree of overlap between the region to be matched and the reference region is determined based on the intersection-union ratio of the region to be matched and the reference region corresponding to the center point, and then it is determined whether the region to be matched and the reference region match.
[0122] In this embodiment, when there is an intersection point that coincides with the vertex of the reference region, the degree of overlap between the region to be matched and the reference region is determined by calculating the intersection-union ratio, thereby determining whether the two are matched. This avoids judging the matching ability based on the parity of the intersection points, thus solving the problem of misidentification under accidental conditions and improving the accuracy of image matching.
[0123] In another embodiment, after determining whether the region to be matched matches the reference region based on the intersection point, the process further includes:
[0124] If the reference region and the region to be matched match, then the region to be matched is determined as the target region.
[0125] For example, when the reference region and the region to be matched have a high degree of overlap, that is, when the two match, the region to be matched is determined as the target region, and the target region is highlighted in the reference image.
[0126] In one specific embodiment, when multiple target objects exist in the reference image, the user can directly select the region of interest as the reference region. When multiple target objects are detected and matched using the detection model, the method in this embodiment is used to determine whether each region to be matched matches the reference region. If they match, the corresponding region to be matched is determined as the target region and displayed in the reference image.
[0127] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0128] This embodiment also provides an image matching device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below refer to combinations of software and / or hardware that perform predetermined functions. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0129] Figure 10 This is a structural block diagram of the image matching device in this embodiment, as shown below. Figure 10 As shown, the device includes:
[0130] The acquisition module 10 is used to acquire the reference region and the region to be matched, which are located on the same reference image;
[0131] The acquisition module 10 is also used to determine the reference area in response to user instructions;
[0132] The reference image is input into the detection model to determine the region to be matched;
[0133] Module 20 is used to determine the center point of the region to be matched;
[0134] The determination module 20 is also used to obtain multiple vertices of the region to be matched;
[0135] Determine the center point of the region to be matched based on the positions of multiple vertices;
[0136] Extension module 30 is used to extend the center point along a preset direction to obtain the straight line to be matched;
[0137] The matching module 40 is used to determine the intersection points of the line to be matched with each edge of the reference area, and to determine whether the area to be matched matches the reference area based on the intersection points;
[0138] Matching module 40 is also used to determine the reference coordinate system;
[0139] The function expression for determining the line to be matched and each edge segment of the reference region based on the reference coordinate system;
[0140] The intersection points of the line to be matched with each edge of the reference area are determined based on the function expression;
[0141] The matching module 40 is also used to determine whether there are any intersection points that coincide with the vertices of the reference region. If not, it determines the number of intersection points.
[0142] If the number of intersection points is odd, then the reference region matches the region to be matched;
[0143] If the number of intersection points is even, then the reference region and the region to be matched do not match;
[0144] The matching module 40 is also used to determine the intersection-union ratio of the reference region and the region to be matched, if it exists.
[0145] The intersection-union ratio (IUU) is used to determine whether the region to be matched matches the reference region.
[0146] The image matching device also includes a target region determination module;
[0147] The target region determination module is used to determine the region to be matched as the target region if the reference region and the region to be matched match.
[0148] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0149] This embodiment also provides an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0150] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0151] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0152] S1: Obtain the reference region and the region to be matched, which are located on the same reference image;
[0153] S2: Determine the center point of the region to be matched;
[0154] S3: Extend the center point along the preset direction to obtain the line to be matched;
[0155] S4: Determine the intersection points of the line to be matched with each edge of the reference area, and determine whether the area to be matched matches the reference area based on the intersection points.
[0156] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.
[0157] Furthermore, in conjunction with the image matching methods provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the image matching methods described in the above embodiments.
[0158] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0159] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.
[0160] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0161] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.
Claims
1. An image matching method, characterized in that, The method includes: Obtain a reference region and a region to be matched, wherein the reference region and the region to be matched are located on the same reference image; Determine the center point of the region to be matched; Extend the center point along a preset direction to obtain the straight line to be matched; Determine the intersection points of the line to be matched with each edge of the reference region, and determine whether the region to be matched matches the reference region based on the intersection points; Determining whether the region to be matched matches the reference region based on the intersection point includes: Determine whether there is an intersection point among the intersection points that coincides with the vertex of the reference region. If so, determine the intersection-union ratio between the reference region and the region to be matched. Based on the intersection-union ratio, determine whether the region to be matched matches the reference region; Determining the center point of the region to be matched includes: Obtain multiple vertices of the region to be matched; Select any point within the region to be matched, and calculate multiple distances from that point to multiple vertices; The dispersion of multiple distances is calculated based on the standard deviation or variance. The point with the lowest dispersion among the multiple distances is determined as the center point.
2. The method according to claim 1, characterized in that, The acquisition of the reference region and the region to be matched includes: In response to a user instruction, the reference area is determined; The reference image is input into the detection model to determine the region to be matched.
3. The method according to claim 1, characterized in that, Determining the intersection points of the line to be matched with each edge of the reference region includes: Determine the reference coordinate system; The function expressions for determining the line to be matched and each edge segment of the reference region are based on the reference coordinate system. The intersection points of the line to be matched and each edge of the reference region are determined based on the function expression.
4. The method according to claim 1, characterized in that, Determining whether the region to be matched matches the reference region based on the intersection point includes: Determine whether any of the intersection points coincide with the vertices of the reference region; if not, determine the number of intersection points. If the number of intersection points is odd, then the reference region matches the region to be matched; If the number of intersection points is even, then the reference region does not match the region to be matched.
5. The method according to claim 1, characterized in that, After determining whether the region to be matched matches the reference region based on the intersection point, the process further includes: If the reference region and the region to be matched match, then the region to be matched is determined to be the target region.
6. An image matching device, characterized in that, include: The acquisition module is used to acquire a reference region and a region to be matched, wherein the reference region and the region to be matched are located on the same reference image; The determination module is used to determine the center point of the region to be matched; The extension module is used to extend the center point along a preset direction to obtain the straight line to be matched; The matching module is used to determine the intersection points of the line to be matched with each edge of the reference area, and to determine whether the area to be matched matches the reference area based on the intersection points; The matching module is also used to determine whether there are any intersection points that coincide with the vertices of the reference region. If so, it determines the intersection-union ratio between the reference region and the region to be matched; and determines whether the region to be matched matches the reference region based on the intersection-union ratio. The determining module is also used to obtain multiple vertices of the region to be matched; Select any point within the region to be matched, and calculate multiple distances from that point to multiple vertices; calculate the dispersion of these multiple distances based on the standard deviation or variance, and determine the point as the center point when the dispersion of the multiple distances is the lowest.
7. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the image matching method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the image matching method according to any one of claims 1 to 5.