A method for generating detection frame overlap, target detection method and device

By rigidly transforming the rotated detection box to generate a simple rectangular box, the calculation of the overlap between rotated detection boxes is simplified, the problem of high computational complexity of the intersection-union ratio of rotated rectangular boxes is solved, and the efficiency and accuracy of target detection are improved.

CN114419333BActive Publication Date: 2025-01-10ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111501244.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-01-10
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

In existing object detection networks, the intersection-union ratio of rotated rectangles has high computational complexity, leading to an increase in overall computational complexity.

Method used

By performing a rigid transformation on the rotated detection box, a simple rectangular box parallel to the coordinate axes is generated. The intersection points and the set of internal vertices are calculated, simplifying the calculation of the overlap between the rotated detection boxes.

Benefits of technology

This reduces the complexity of calculating the overlap between rotating detection boxes and improves the calculation speed and accuracy of target detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114419333B_ABST
    Figure CN114419333B_ABST
Patent Text Reader

Abstract

The present application discloses a detection frame overlap generation method, target detection method and device, the method comprising: obtaining a first rotation detection frame and a second rotation detection frame; transforming the first rotation detection frame and the second rotation detection frame to obtain the first detection frame to the fourth detection frame, the upper boundary of the first detection frame and the upper boundary of the fourth detection frame are parallel to the horizontal direction, and the left boundary of the first detection frame and the left boundary of the fourth detection frame are parallel to the vertical direction; calculating the intersection of the first detection frame and the second detection frame or the intersection of the third detection frame and the fourth detection frame to obtain an intersection set; obtaining the vertices of the second detection frame located inside the first detection frame and the vertices of the third detection frame located inside the fourth detection frame to obtain an internal vertex set; based on the intersection set and the internal vertex set, calculating the overlap of the first rotation detection frame and the second rotation detection frame. In the above manner, the present application can reduce the complexity of calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of deep learning technology, and in particular to a method for generating detection frame overlap, a target detection method and a device. Background Art

[0002] In the target detection network, after detecting the candidate boxes, if there is regional overlap between the candidate boxes, the non-maximum suppression (NMS) algorithm needs to be used to select the target with the highest local credibility as the final output target; when using the NMS algorithm, the intersection over union (IOU) of the two candidate boxes needs to be calculated. If the IOU is greater than the specified threshold, only the target with higher credibility is retained, and the target with lower credibility is suppressed. However, the detection results of many detection networks are not rectangular boxes parallel to the coordinate axis, but a tilted rectangle (i.e., a rotated rectangular box). The calculation process of the IOU of the rotated rectangular box is relatively complicated, and there is a problem of high computational complexity. Summary of the invention

[0003] The present application provides a detection frame overlap generation method, a target detection method and a device, which can reduce the complexity of calculation.

[0004] In order to solve the above technical problems, the technical solution adopted in the present application is: to provide a method for generating the overlap of detection frames, the method comprising: obtaining a first rotation detection frame and a second rotation detection frame; transforming the first rotation detection frame and the second rotation detection frame to obtain a first detection frame corresponding to the first rotation detection frame and a second detection frame corresponding to the second rotation detection frame, the upper boundary of the first detection frame is parallel to the horizontal direction, and the left boundary of the first detection frame is parallel to the vertical direction; transforming the first rotation detection frame and the second rotation detection frame to obtain a third detection frame corresponding to the first rotation detection frame and a fourth detection frame corresponding to the second rotation detection frame, the upper boundary of the fourth detection frame is parallel to the horizontal direction, and the left boundary of the fourth detection frame is parallel to the vertical direction; when the second detection frame or the third detection frame meets a preset condition, calculating the intersection of the first detection frame and the second detection frame or the intersection of the third detection frame and the fourth detection frame to obtain an intersection set; obtaining the vertices of the second detection frame located inside the first detection frame and the vertices of the third detection frame located inside the fourth detection frame to obtain an internal vertex set; and calculating the overlap of the first rotation detection frame and the second rotation detection frame based on the intersection set and the internal vertex set.

[0005] To solve the above technical problems, another technical solution adopted in the present application is: to provide a target detection method, the method comprising: performing target detection processing on the image to be detected to obtain multiple detection frames; calculating the overlap between the detection frame and another detection frame; based on the overlap, selecting the target detection frame from all detection frames, and the method for calculating the overlap between the detection frame and another detection frame is the method for generating the detection frame overlap in the above technical solution.

[0006] To solve the above-mentioned technical problems, another technical solution adopted in the present application is: to provide a target detection device, which includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the method for generating the detection frame overlap in the above-mentioned technical solution.

[0007] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the method for generating the detection frame overlap in the above technical solution.

[0008] Through the above scheme, the beneficial effect of the present application is: first obtain the first rotation detection frame and the second rotation detection frame; then perform rigid transformation on the first rotation detection frame and the second rotation detection frame to obtain the first detection frame, the second detection frame, the third detection frame and the fourth detection frame, and the first detection frame and the fourth detection frame are simple rectangular frames; when the second detection frame or the third detection frame meets the preset conditions, calculate the intersection of the first detection frame and the second detection frame or the intersection of the third detection frame and the fourth detection frame to obtain an intersection set; then obtain the vertices of the second detection frame located inside the first detection frame and the vertices of the third detection frame located inside the fourth detection frame to obtain an internal vertex set; then use the intersection set and the internal vertex set to calculate the overlap between the first rotation detection frame and the second rotation detection frame; since the first detection frame and the fourth detection frame are both simple rectangular frames, the calculation is relatively simple when calculating the intersection of the first detection frame and the second detection frame and the internal vertices between the first detection frame and the second detection frame, thereby simplifying the calculation of the intersection area between the two rotation detection frames, which helps to reduce the complexity of calculating the overlap. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0010] Figure 1It is a flowchart of an embodiment of a method for generating detection frame overlap provided by the present application;

[0011] Figure 2 is a schematic diagram of a first rotation detection frame and a second rotation detection frame of the present application;

[0012] Figure 3 Yes Figure 2 Schematic diagram of the two rotated detection frames after rigid transformation;

[0013] Figure 4 Yes Figure 2 Another schematic diagram of the two rotation detection frames shown after rigid transformation;

[0014] Figure 5 is a flowchart of another embodiment of a method for generating detection frame overlap provided by the present application;

[0015] Figure 6 is a schematic diagram of a first detection frame and a second detection frame provided by the present application;

[0016] Figure 7 It is a flowchart of an embodiment of a target detection method provided by the present application;

[0017] Figure 8 is a structural schematic diagram of an embodiment of a target detection device provided by the present application;

[0018] Fig. 9 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION

[0019] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0020] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0021] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.

[0022] First, the coordinate system, the method for calculating the area of ​​the intersection region and the intersection-union ratio involved in this application are introduced.

[0023] 1) This application uses the representation method of traditional mathematical concepts. The positive direction of the x-axis points to the right side of the image, the positive direction of the y-axis is the top of the image, the angle is positive when rotating in the counterclockwise direction, and one rotation is 360 degrees. These representations can be easily converted to the representation method of computer images and can be equally applicable.

[0024] 2) For general polygons, their vertex coordinates can be used to represent them. A polygon is one in which, except for adjacent boundaries, no other boundaries intersect or connect. The vertices of a polygon can be arranged in a counterclockwise direction. Assume that the coordinates of an N-sided polygon are (x0, y0), (x1, y1), ..., (x N-1 ,y N-1 ), (x N ,y N ), x N =x0,y N =y0, then the area calculation formula is:

[0025]

[0026] 3) The calculation formula of the intersection and union ratio of target boxes A and B is:

[0027]

[0028] Wherein, in formula (2), Intersection(A, B) is the area of ​​the intersection of target boxes A and B (i.e., the intersection area); if target boxes A and B do not intersect, IOU(A, B)=0; if target boxes A and B completely overlap, IOU(A, B)=1; if target boxes A and B intersect and do not completely overlap, IOU(A, B) is a value in the interval (0, 1).

[0029] See also Figure 1 , Figure 1 : is a flow chart of an embodiment of a method for generating detection frame overlap provided by the present application, the method comprising:

[0030] S11: Acquire a first rotation detection frame and a second rotation detection frame.

[0031] The multiple candidate boxes output by the target detection network can be used as the first rotated detection box and the second rotated detection box. The target detection network is a network model commonly used in related technologies for detecting targets, such as Yolo (You only look once) or Single Shot MultiBox Detector (SSD).

[0032] In a specific embodiment, Figure 2 As shown, the two input rotation detection frames (i.e., the first rotation detection frame and the second rotation detection frame) are denoted as A and B. The first rotation detection frame A is represented as ((x A ,y A ),(w A ,h A ),θ A ), (x A ,y A ) is the coordinate of the center point of the first rotation detection frame A, w A is the width of the first rotation detection frame A, h A is the height of the first rotation detection frame A, θ A is the angle of the first rotation detection frame A, which is the length of w A The angle between the boundary of the first rotation detection frame B and the x-axis is expressed as ((x B ,y B ),(w B ,h B ),θ B ), (x B ,y B ) is the coordinate of the center point of the second rotation detection frame B, w B is the width of the second rotation detection frame B, h B is the height of the second rotation detection frame B, θ Bis the angle of the second rotation detection frame B, which is the length of w B The angle between the boundary and the x-axis.

[0033] In order to facilitate subsequent calculations, the angle can be normalized; specifically, the angle is recorded as θ, if the angle is greater than or equal to 180°, then it is continuously subtracted by 180° until its value is less than 180°. If the angle is less than 0°, then it is continuously added by 180° until its value is greater than or equal to 0°. Due to the central symmetry of the rotation detection frame, the above operation will not affect the actual position of the rotation detection frame; after the above operation is completed, the angle will be limited to the range of [0, 180), that is, 0≤θ<180°; if θ≥90°, the following transformation is performed:

[0034] ((x,y),(w,h),θ)→((x,y),(h,w),θ–90) (3)

[0035] Among them, from formula (3), we can know that the same rotation detection frame is represented before and after the transformation, and the angle after the transformation satisfies: 0≤θ<90°. In order to avoid introducing too many symbols, we can still use ((x A ,y A ),(w A ,h A ),θ A ) and ((x B ,y B ),(w B ,h B ),θ B ) represents the result of angle normalization of the two rotation detection frames.

[0036] S12: performing transformation processing on the first rotation detection frame and the second rotation detection frame to obtain a first detection frame corresponding to the first rotation detection frame and a second detection frame corresponding to the second rotation detection frame.

[0037] like Figure 2 and Figure 3 As shown, the first rotation detection frame A and the second rotation detection frame B are rigidly transformed to obtain the first detection frame A1 and the second detection frame B1. The upper boundary of the first detection frame A1 is parallel to the horizontal direction, and the left boundary of the first detection frame A1 is parallel to the vertical direction, that is, the first detection frame A1 is a simple rectangular frame (a simple rectangular frame is a rectangular frame whose boundary is parallel to the coordinate axis), and its tilt angle is 0°; specifically, the first detection frame A and the second detection frame B are regarded as a whole and translated so that the center of the first detection frame A coincides with the coordinate origin, and then rotated clockwise around the origin by an angle θ A , we get the first detection frame A1 and the second detection frame B1; after the transformation, the width and height of the detection frame remain unchanged, so w A1 =wA ,h A1 =h A , w B1 =w B ,h B1 =h B ; For the convenience of description, the symbol w without numbers is used in the following A 、h A 、w B and h B To express it, no distinction is made, and the transformation of the remaining parameters is as follows:

[0038] x A1 =0,x B1 =(x B –x A )cosθ A +(y B –y A )sinθ A (4)

[0039] y A1 =0,y B1 =(x A –x B )sinθ A +(y B –y A )cosθ A (5)

[0040] θ A1 =0,θ B1 =θ B –θ A (6)

[0041] S13: performing transformation processing on the first rotation detection frame and the second rotation detection frame to obtain a third detection frame corresponding to the first rotation detection frame and a fourth detection frame corresponding to the second rotation detection frame.

[0042] like Figure 2 and Figure 4 As shown in FIG. 1 , the first rotation detection frame A and the second rotation detection frame B are rigidly transformed to obtain the third detection frame A2 and the fourth detection frame B2. The upper boundary of the fourth detection frame B2 is parallel to the horizontal direction, and the left boundary of the fourth detection frame B2 is parallel to the vertical direction. That is, the fourth detection frame B2 is a simple rectangular frame, and its tilt angle is 0°. Specifically, the first rotation detection frame A and the second rotation detection frame B are regarded as a whole and translated so that the center of the second rotation detection frame B coincides with the coordinate origin, and then rotated clockwise along the origin by an angle θ B , and obtain the third detection frame A2 and the fourth detection frame B2; after the transformation, the width and height of the detection frame remain unchanged, so w A2 =wA ,h A2 =h A , w B2 =w B ,h B2 =h B ; For the convenience of description, the symbol w without numbers is used in the following A ,h A , w B and h B To express it, no distinction is made, and the transformation of the remaining parameters is as follows:

[0043] x B2 =0,x A2 =(x A –x B )cosθ B +(y A –y B )sinθ B (7)

[0044] y B2 =0,y A2 =(x B –x A )sinθ B +(y A –y B )cosθ B (8)

[0045] θ B2 =0,θ A2 =θ A –θ B (9)

[0046] Among them, θ B1 and θ A2 They are in the range of (–90, 90) and are opposite to each other.

[0047] S14: When the second detection frame or the third detection frame meets a preset condition, an intersection point between the first detection frame and the second detection frame or an intersection point between the third detection frame and the fourth detection frame is calculated to obtain an intersection point set.

[0048] After the rotation detection frame is rigidly transformed, it can be determined whether the second detection frame meets a preset condition. The preset condition can be a condition related to the angle of the second detection frame and used to determine whether the second detection frame is a rotation detection frame. For example, the preset condition is that the angle is 0°. If the second detection frame meets the preset condition, it indicates that the second detection frame is a rotation detection frame, that is, its angle is not 0. In order to calculate the overlap, the intersection of the first detection frame and the second detection frame can be calculated to obtain an intersection set. For example, Figure 3 As shown, the intersection point set includes {D1, D2}.

[0049] It can be understood that since both the second detection frame and the third detection frame are possibly tilted rotation detection frames, the third detection frame is also used as a judgment reference, that is, to judge whether the third detection frame meets the preset conditions; if the third detection frame meets the preset conditions, it indicates that the third detection frame is a rotation detection frame, and the intersection point of the third detection frame and the fourth detection frame can be calculated to obtain an intersection point set; for example, Figure 4 As shown, the intersection point set is {D1, D2}.

[0050] S15: Acquire vertices of the second detection box located inside the first detection box and vertices of the third detection box located inside the fourth detection box to obtain an internal vertex set.

[0051] like Figure 3 and Figure 4 As shown, since the first detection frame A1 and the fourth detection frame B2 are simple rectangular frames, calculation is convenient, so the vertices of the second detection frame B1 located inside the first detection frame A1 can be detected to obtain vertex E1; the vertices of the third detection frame A2 located inside the fourth detection frame B2 can be detected to obtain vertices E2 and E3, that is, the internal vertex set is {E1, E2, E3}. It can be understood that the vertices of the first detection frame A1 located inside the second detection frame B1 and the vertices of the fourth detection frame B2 located inside the third detection frame A2 can also be obtained.

[0052] S16: Calculate the overlap between the first rotated detection frame and the second rotated detection frame based on the intersection point set and the internal vertex set.

[0053] The overlap degree may be an intersection-and-union ratio. If the intersection point set and the internal vertex set are obtained, then the set of vertices in the intersection area of ​​the first rotation detection frame and the second rotation detection frame is obtained; for example, Figure 3 As shown, the area enclosed by points E1-E3 and D1-D2 is the intersection area. Formula (1) is first used to calculate the area of ​​the intersection area (i.e., the intersection area), and then the overlap between the first rotation detection frame and the second rotation detection frame is obtained by substituting it into the above formula (2).

[0054] This embodiment provides a method for quickly calculating the intersection area and intersection-over-augmentation ratio of a rotated detection frame, and rigidly transforms the first rotated detection frame and the second rotated detection frame as a whole, so that the angle of one of the detection frames is 0° after the transformation. Since the detection frame is a simple rectangular frame, the calculation of the intersection area between the two rotated detection frames can be simplified, which helps to reduce the complexity of the calculation, and can be applied to the detection of tilted targets to reduce the computational complexity of target detection.

[0055] See also Figure 5 , Figure 5: is a flow chart of another embodiment of a method for generating detection frame overlap provided by the present application, the method comprising:

[0056] S501: Acquire a first rotation detection frame and a second rotation detection frame.

[0057] S501 is the same as S11 in the above embodiment and will not be described again.

[0058] S502: Determine whether there is an intersection area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame.

[0059] The first outer enclosing rectangular frame is a rectangular frame enclosing the first rotation detection frame, and the second outer enclosing rectangular frame is a rectangular frame enclosing the second rotation detection frame; specifically, assuming that the rotation detection frame (including the first rotation detection frame and the second rotation detection frame) is recorded as ((x, y), (w, h), θ), the coordinates of the four vertices of the rotation detection frame can be calculated using the following formula:

[0060] (x0,y 0 )=(x–0.5w*cosθ–0.5h*sinθ, y–0.5w*sinθ+0.5h*cosθ) (10)

[0061] (x 1 ,y 1 )=(x–0.5w*cosθ+0.5h*sinθ, y–0.5w*sinθ–0.5h*cosθ) (11)

[0062] (x 2 ,y 2 )=(x+0.5w*cosθ+0.5h*sinθ, y+0.5w*sinθ–0.5h*cosθ) (12)

[0063] (x 3 ,y 3 )=(x+0.5w*cosθ–0.5h*sinθ, y+0.5w*sinθ+0.5h*cosθ) (13)

[0064] Among them, (x 0 ,y 0 ) is the coordinate of the first vertex of the rotation detection box, (x 1 ,y 1 ) is the coordinate of the second vertex of the rotation detection box, (x 2 ,y 2 ) is the coordinate of the third vertex of the rotation detection box, (x 3 ,y 3 ) is the coordinate of the fourth vertex of the rotation detection box.

[0065] Furthermore, the vertices of the rotation detection frame are arranged in a counterclockwise direction. When 0≤θ<90°, the left and right boundaries of its outer enclosing rectangular frame are obtained as follows:

[0066] left=x–0.5w*cosθ–0.5h*sinθ (14)

[0067] right=x+0.5w*cosθ+0.5h*sinθ (15)

[0068] The upper and lower boundaries are:

[0069] top=y+0.5w*sinθ+0.5h*cosθ (16)

[0070] bottom=y+0.5w*sinθ+0.5h*cosθ (17)

[0071] Among them, by substituting the parameters of the first rotation detection frame and the parameters of the second rotation detection frame into the above formulas (14)-(17) respectively, the vertex coordinates of the outer enclosing rectangular frames of the two can be obtained; since the two outer enclosing rectangular frames are simple rectangular frames, it is easy to determine whether the two outer enclosing rectangular frames intersect (that is, whether there is an intersecting area).

[0072] It can be understood that S502 is optional and is mainly used to terminate the calculation process in advance under special circumstances. Even if this step is not executed, it will not affect the subsequent calculation process.

[0073] S503: If there is no intersection area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame, determine that there is no intersection area between the first rotation detection frame and the second rotation detection frame, and the overlap degree is a preset overlap degree.

[0074] The preset overlap is 0. If there is no intersection area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame, it means that the overlap area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame is 0; since the first rotation detection frame is located inside the first outer enclosing rectangular frame and the second rotation detection frame is located inside the second outer enclosing rectangular frame, there is no intersection area between the first rotation detection frame and the second rotation detection frame, and their overlap area is 0.

[0075] S504: If there is an intersection area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame, transform the first rotation detection frame and the second rotation detection frame to obtain a first detection frame, a second detection frame, a third detection frame and a fourth detection frame.

[0076] If there is an intersection area between the first outer enclosing rectangular frame and the second outer enclosing rectangular frame, it means that there is an intersection area between the first rotation detection frame and the second rotation detection frame. At this time, further analysis can be performed by using the solution in the above embodiment to perform a rigid transformation on the first rotation detection frame and the second rotation detection frame to obtain the first detection frame to the fourth detection frame.

[0077] Through rigid transformation, a rotated detection frame is transformed into a simple rectangular frame parallel to the coordinate axis, which simplifies the positional relationship judgment of another detection frame and the simple rectangular frame and the calculation method of the intersection coordinates; moreover, through another rigid transformation, the roles of the two detection frames are interchanged to complete more positional relationship judgments, and finally the first detection frame to the fourth detection frame are generated to facilitate the subsequent calculation of the intersection area.

[0078] S505: Determine whether the second detection frame or the third detection frame meets a preset condition.

[0079] In order to determine whether the second detection frame or the third detection frame is a simple rectangular frame, it is possible to determine whether the angle of the second detection frame falls within a preset angle range or whether the angle of the third detection frame falls within a preset angle range. Specifically, the preset angle range is an angle range of 0° or close to 0°, that is, to determine whether the angle of the second detection frame and the angle of the third detection frame are zero or close to zero; since the angle of the second detection frame and the angle of the third detection frame are opposite numbers, any one of the angles can be used for determination. If the second detection frame is a simple rectangular frame, the intersection area of ​​the first detection frame and the second detection frame can be easily calculated.

[0080] For example, taking the preset angle range of 0° as an example, determine whether the upper boundary / lower boundary of the second detection frame is parallel to the horizontal direction, whether the left boundary / right boundary of the second detection frame is parallel to the vertical direction, and whether the upper boundary / lower boundary of the third detection frame is parallel to the horizontal direction or whether the left boundary / right boundary of the third detection frame is parallel to the vertical direction; if so, determine that the second detection frame or the third detection frame meets the preset conditions.

[0081] S506: When the second detection frame or the third detection frame meets a preset condition, calculate the area of ​​the intersection region of the first detection frame and the second detection frame to obtain the intersection area.

[0082] For a simple rectangular box whose border is parallel to the coordinate axis, the calculation of the intersection ratio is relatively simple, because its intersection area is also a rectangular area parallel to the coordinate axis. It is only necessary to calculate the length of the intersection area in the x-axis direction and the y-axis direction respectively to calculate the intersection area; specifically, the intersection area Intersection(A, B) = w I *h I , use the following formula to calculate w I With h I:

[0083] w I =max(min(x A +w A / 2,x B +w B / 2)–max(x A –w A / 2,x B –w B / 2), 0) (18)

[0084] h I =max(min(y A +h A / 2,y B +h B / 2)–max(y A –h A / 2,y B –h B / 2), 0) (19)

[0085] Among them, "min" means calculating the minimum value of all inputs, and "max" means calculating the maximum value of all inputs.

[0086] S507: If the second detection frame and the third detection frame do not meet the preset condition, determine whether the first detection frame and the second detection frame have an intersection area or whether the third detection frame and the fourth detection frame have an intersection area.

[0087] Determining whether the first detection frame and the second detection frame are separated (i.e., whether they intersect), and whether the third detection frame and the fourth detection frame are separated is divided into the following two parts:

[0088] 1) Since the first detection frame is a simple rectangular frame, it is convenient to determine whether the second detection frame is entirely located on the left side (left boundary to the left), right side (right boundary to the right), top side (top boundary to the top) or bottom side (bottom boundary to the bottom) of the first detection frame.

[0089] The coordinates of the vertices of the second detection frame can be obtained by using the calculation formula of the rigid transformation. When these four vertices are simultaneously located on a certain side of the first detection frame, it means that the entire second detection frame is located on that side of the first detection frame.

[0090] 2) Since the fourth detection frame is a simple rectangular frame, a similar method can be used to determine whether the third detection frame is located on the left, right, top or bottom of the fourth detection frame.

[0091] If any one (or more) of the above 8 situations occurs, it means that the first rotated detection frame and the second rotated detection frame are non-intersecting, and their intersection area is 0; compared with directly using the parameters of the first rotated detection frame and the second rotated detection frame for separation judgment, the judgment logic for separation judgment based on the rotated detection frame is very simple, which can reduce the complexity of the calculation.

[0092] S508: If there is an intersection area between the first detection frame and the second detection frame or there is an intersection area between the third detection frame and the fourth detection frame, determine whether there is an inclusion relationship between the first detection frame and the second detection frame and whether there is an inclusion relationship between the third detection frame and the fourth detection frame.

[0093] Determine whether there is an inclusion relationship between the first detection box and the second detection box, and between the third detection box and the fourth detection box, which is divided into the following two parts:

[0094] 1) Determine whether the second detection frame is located inside the rectangular first detection frame.

[0095] When the vertex coordinates of the second detection frame and the position and size of the first detection frame are obtained, it is easy to determine whether the second detection frame is located inside the first detection frame. It is only necessary to determine whether each vertex of the second detection frame is located inside the first detection frame.

[0096] 2) Determine whether the third detection frame is located inside the rectangular fourth detection frame, the method is similar to determining whether the second detection frame is located inside the rectangular first detection frame.

[0097] In a specific embodiment, when there is an inclusion relationship between the first detection frame and the second detection frame or there is an inclusion relationship between the third detection frame and the fourth detection frame, it can be determined whether the first detection frame contains the second detection frame; if the first detection frame contains the second detection frame, the area of ​​the second detection frame is the intersection area; if the second detection frame contains the first detection frame, the area of ​​the first detection frame is the intersection area.

[0098] Since the positional relationship between the first rotation detection frame and the second rotation detection frame is consistent with the positional relationship between the first detection frame and the second detection frame and the positional relationship between the third detection frame and the fourth detection frame, if the second detection frame is located inside the first detection frame, it means that the second rotation detection frame is located inside the first rotation detection frame, that is, the intersection area of ​​the two is the second rotation detection frame; if the third detection frame is located inside the fourth detection frame, it means that the first rotation detection frame is located inside the second rotation detection frame, that is, the intersection area of ​​the two is the first rotation detection frame. Compared with directly judging whether there is an inclusion relationship between the first rotation detection frame and the second rotation detection frame based on the parameters of the first rotation detection frame and the second rotation detection frame, the calculation complexity is much reduced.

[0099] After excluding the above-mentioned special cases, it can be determined that there is an intersection between the boundaries of the first rotation detection frame and the second rotation detection frame. The following describes a method for calculating the intersection and a method for generating vertices of the intersection area.

[0100] S509: If it is determined that there is no inclusion relationship between the first detection frame and the second detection frame and there is no inclusion relationship between the third detection frame and the fourth detection frame, the intersection of the first detection frame and the second detection frame is calculated to obtain an intersection set.

[0101] Number each boundary of the second detection frame in counterclockwise order; traverse all boundaries of the second detection frame and extract the current boundary from all boundaries of the second detection frame in ascending order of numbers; calculate the intersection points of the current boundary and all boundaries of the first detection frame; determine whether the number of intersection points is a first preset number; if the number of intersection points is the first preset number, determine the order of the intersection points in the intersection point set based on the starting point of the current boundary; if the number of intersection points is not the first preset number, put the intersection points into the intersection point set. Specifically, the first preset number can be 2, calculate the distance between the intersection point and the starting point of the current boundary; put the starting point into the intersection point set in ascending order of distance.

[0102] In a specific embodiment, the vertices and boundaries of the first rotation detection frame and the second rotation detection frame are numbered first, and the four vertices are numbered 0, 1, 2, and 3 in sequence according to the vertex calculation formula, that is, the coordinates of the kth vertex are (x k ,y k ), and number 4 and number 0 represent the same point. Similarly, the four edges are numbered 0, 1, 2, and 3. The kth edge connects the two vertices numbered k and k+1. Vertex k is the starting point of this edge, and vertex k+1 is the end point of this edge. In the order of numbering, the vertices and edges are arranged counterclockwise.

[0103] Since the first detection frame, the second detection frame, the third detection frame and the fourth detection frame are obtained by rigid transformation of the first rotated detection frame and the second rotated detection frame, there is a strict one-to-one correspondence between their vertices and boundaries, that is, the vertices numbered k on the first rotated detection frame, the first detection frame and the third detection frame are obtained by translation and rotation of the same vertex, so the intersections of the boundaries are also one-to-one corresponding, for example: if boundary 1 of the first rotated detection frame and boundary 2 of the second rotated detection frame have an intersection, then boundary 1 of the first detection frame and boundary 2 of the second detection frame also have an intersection, and boundary 1 of the third detection frame and boundary 2 of the fourth detection frame also have an intersection; if vertex 3 of the first rotated detection frame is located inside the second rotated detection frame, then vertex 3 of the first detection frame is also located inside the second detection frame, and vertex 3 of the third detection frame is also located inside the fourth detection frame.

[0104] Based on the above numbering information, the intersection of the boundaries of the first detection frame and the second detection frame is calculated. Of course, the effect of using the third detection frame and the fourth detection frame for calculation is the same.

[0105] The equations of the four sides of the first detection box are as follows:

[0106] x=–w A / 2, y = –h A / 2, x = w A / 2,y=h A / 2 (20)

[0107] Since the case of a simple rectangular box has been ruled out, the second detection box is not a simple rectangular box, so its boundary is not parallel to the coordinate axis. Its equation can be expressed by the slope. The slopes of the four boundaries are:

[0108] s 0 =s 2 =–cosθ B1 / sinθ B1 ,s 1 =s 3 = sinθ B1 / cosθ B1 (twenty one)

[0109] Therefore, the equations of the four boundaries of the second detection box are:

[0110] y=y k B1 +s k (x–x k B1 ), x=x k B1 +(1 / s k )(y–y k B1 ) (twenty two)

[0111] Among them, k∈{0, 1, 2, 3}, (x k B1 ,y k B1 ) are the coordinates of the four vertices of the second detection box.

[0112] Since the boundary of the first detection frame is parallel to the coordinate axis, and the boundary of the second detection frame has been expressed by the slope equation, it is convenient to determine whether any boundary of the first detection frame intersects with any boundary of the second detection frame, and calculate the coordinates of the intersection point by using the coordinate substitution method. It can be understood that there is at most one intersection point between two boundaries, and there are at most two intersection points between one boundary and the boundary of another detection frame.

[0113] Traverse each boundary of the second detection box in order k , calculate the boundary e k The intersection with the boundary of the first detection box. If there are two intersections, the distance e k The intersection points closer to the starting point are placed in front, and the numbers of the two sides corresponding to each intersection point in the first detection frame and the second detection frame are recorded. After traversing the boundary of the second detection frame, m intersection points (m ≥ 2) will be obtained, and they will be arranged in a counterclockwise direction on the boundary of the second detection frame. At the same time, the number p of the boundary of the first detection frame corresponding to the intersection point i is obtained. i and the number q of the boundary of the second detection box i .

[0114] S510: Acquire vertices of the second detection box located inside the first detection box and vertices of the third detection box located inside the fourth detection box to obtain an internal vertex set.

[0115] The process of obtaining internal vertices is also divided into two parts. The first part is to determine the vertices of the second detection frame located inside the first detection frame, and the second part is to determine the vertices of the third detection frame located inside the fourth detection frame. Since the first detection frame and the fourth detection frame are simple rectangular frames, it is easy to obtain internal vertices. After completing the judgment of the internal vertices, 8 states are obtained, namely, whether each vertex of the first rotation detection frame (first detection frame / third detection frame) is located inside the second rotation detection frame (second detection frame / fourth detection frame) and whether each vertex of the second rotation detection frame (second detection frame / fourth detection frame) is located inside the first rotation detection frame (first detection frame / third detection frame).

[0116] S511: Determine whether the number of internal vertices in the internal vertex set is a second preset number.

[0117] S512: If the number of internal vertices in the internal vertex set is a second preset number, calculating the degree of overlap based on the intersection point set.

[0118] The second preset number is 0, that is, when the number of internal vertices in the internal vertex set is 0, it indicates that the polygon formed by the intersection points is the intersection area. At this time, the position information of the intersection points in the intersection point set can be used to calculate the area of ​​the intersection area between the first detection frame and the second detection frame to obtain the intersection area; then, based on the intersection area, the overlap degree is calculated. For example, Figure 6 As shown, the vertices of the intersection area of ​​the first detection frame K1 and the second detection frame K2 are H1-H4 respectively, and the intersection area can be calculated using the above formula (1).

[0119] Furthermore, the sum of the area of ​​the first detection frame and the area of ​​the second detection frame is calculated to obtain a first value; then the difference between the first value and the intersection area is calculated to obtain a second value; then the ratio of the intersection area to the second value is calculated to obtain the overlap, that is, the overlap is calculated using the above formula (2).

[0120] S513: If the number of internal vertices in the internal vertex set is not the second preset number, all intersections and all internal vertices are sorted based on the position information of the intersections and the position information of the vertices to obtain an overlapping set.

[0121] Sort the intersection points and internal vertices to obtain the final intersection area vertices (i.e., vertices in the overlap set). If the number of internal vertices in the internal vertex set is not zero, first set the overlap set to empty, and then perform the following steps:

[0122] (1) Traverse the intersection point set and extract the current intersection point from the intersection point set in ascending order of the intersection point numbers in the intersection point set.

[0123] (2) Put the current intersection point into the overlap set.

[0124] (3) Sort the internal vertices based on the first detection box corresponding to the current intersection.

[0125] Get the boundary corresponding to the current intersection in the first detection frame (that is, the boundary number is p i The boundary), and determine the end point of the boundary (that is, the number mod(p i +1, 4) is an internal vertex, "mod" is the remainder function; if the end point of the boundary is an internal vertex, the end point is recorded as the first point to be processed, and the first point to be processed is placed behind the current intersection in the overlapping set; determine whether the next vertex of the first point to be processed is an internal vertex; if the next vertex of the first point to be processed is an internal vertex, the next vertex is placed behind the first point to be processed in the overlapping set, and the next vertex is used as the first point to be processed, and the step of whether the next vertex of the first point to be processed is an internal vertex is returned until the next vertex is not an internal vertex.

[0126] (4) Sort the internal vertices based on the second detection box corresponding to the current intersection.

[0127] Get the boundary corresponding to the current intersection in the second detection frame (that is, the boundary number is q i The boundary of the i+1, 4) is an internal vertex; if the end point of the boundary is an internal vertex, the end point is recorded as the second point to be processed, and the second point to be processed is placed behind the current intersection in the overlapping set; determine whether the next vertex of the second point to be processed is an internal vertex; if the next vertex of the second point to be processed is an internal vertex, the next vertex is placed behind the first point to be processed in the overlapping set, and the next vertex is used as the second point to be processed, and the step of whether the next vertex of the second point to be processed is an internal vertex is returned, until the next vertex is not an internal vertex.

[0128] It can be understood that in the above process, at most only one condition can be met in steps (3) to (4), and the order of addition ensures that the vertices of the intersection area are arranged in a counterclockwise direction.

[0129] After processing all intersections, the sorting of all vertices in the intersection area is completed, and an overlap set is obtained, which includes all intersections in the intersection set and all internal vertices in the internal vertex set; the intersection set includes the position information of at least two intersections, and the internal vertex set includes the position information of at least one internal vertex. This embodiment can quickly arrange the vertices in the intersection area in a specific order by marking the corresponding relationship between the intersection and the boundary.

[0130] For example, Figure 3 As shown, the intersection point set is {D1, D2}, and the internal vertex set is {E1, E2, E3}; first put the intersection point D1 into the overlap set, and the overlap set is {D1}; the intersection point D1 is at the boundary e of the first detection frame A1 0 On, that is, p i =0, determine the boundary e of the first detection frame A1 0 The end point (i.e., vertex Q1) of the second detection frame B1 is an internal vertex. Since vertex Q1 is not an internal vertex, the judgment is terminated and the above step (4) is executed. The intersection point D2 is at the boundary e of the second detection frame B1. 0 Up, that is, q i = 0, determine the boundary e of the second detection frame B1 0 Whether the end point (i.e., vertex E1) is an internal vertex. Since vertex E1 is an internal vertex, vertex E1 is put into the overlapping set, and the overlapping set is {D1, E1}; then determine whether the next vertex of vertex E1 (i.e., vertex Q2) is an internal vertex. Since vertex Q2 is not an internal vertex, the current judgment is terminated and the next intersection in the intersection set is processed.

[0131] The intersection point D2 is placed in the overlap set, and the overlap set is {D1, E1, D2}; the intersection point D2 is at the boundary e of the first detection frame A1. 2 On, that is, p i =2, determine the boundary e of the first detection frame A1 2Whether the end point (i.e., vertex E3) is an internal vertex, since vertex E3 is an internal vertex, vertex E3 is put into the overlapping set, and the overlapping set is {D1, E1, D2, E3}; determine whether the next vertex of vertex E3 (i.e., vertex E2) is an internal vertex, since vertex E2 is an internal vertex, vertex E2 is put into the overlapping set, and the overlapping set is {D1, E1, D2, E3, E2}; determine whether the next vertex of vertex E2 (i.e., vertex Q1) is an internal vertex, since vertex Q1 is not an internal vertex, the determination is terminated; and since the entire intersection set has been traversed, the entire sorting process is completed, and the generated overlapping set is {D1, E1, D2, E3, E2}.

[0132] S514: Calculate the degree of overlap based on the position information of the intersection points in the overlap set and the position information of the internal vertices in the overlap set.

[0133] After obtaining the overlapping set, the area of ​​the intersection region can be calculated using the above formula (1); for example, Figure 3 As shown, by substituting the coordinates of D1, E2, E3, D2, and E1 into formula (1), the intersection area of ​​the first detection frame A1 and the second detection frame B1 can be obtained.

[0134] In other embodiments, after calculating the vertex coordinates of the intersection area of ​​the first detection frame and the second detection frame, the coordinates of the intersection area of ​​the first rotation detection frame and the second rotation detection frame can be obtained by the inverse transformation of the rigid transformation; specifically, the inverse process of the rigid transformation is to first rotate the figure counterclockwise around the origin by an angle θ A , and then translate the origin to (x A ,y A ) coordinates, the specific formula is:

[0135] x=x1cosθ A –y1sinθ A +x A (twenty three)

[0136] y=x1sinθ A +y1cosθ A +y A (twenty four)

[0137] Among them, (x1, y1) is the vertex coordinates of the intersection area of ​​the first detection frame and the second detection frame, and (x, y) is the vertex coordinates of the intersection area of ​​the first rotated detection frame and the second rotated detection frame.

[0138] By calculating the vertex coordinates of the intersection area of ​​the first detection frame and the second detection frame, and obtaining the vertex coordinates of the intersection area of ​​the first rotation detection frame and the second rotation detection frame through the inverse transformation of the rigid transformation, the vertex coordinates of the intersection area of ​​the first rotation detection frame and the second rotation detection frame are calculated.

[0139] This embodiment proposes a method for calculating the intersection area and intersection-over-augment ratio of a rotated detection frame, which adopts a rigid transformation (rotation and translation). By recording the corresponding relationship between the intersection point and the boundary, the vertices of the intersection area can be conveniently arranged in order (i.e., counterclockwise); through the inverse transformation of the rigid transformation, the vertex coordinates of the intersection area of ​​the two detection frames can be quickly calculated; by converting a rotated detection frame into a simple rectangular frame parallel to the coordinate axis, the judgment logic of the positional relationship with the other rotated detection frame and the boundary intersection coordinate calculation method are simplified, the calculation speed is improved, and the intersection area can be calculated accurately instead of an approximate calculation; in addition, if a special positional relationship (separation or inclusion) is judged, the area of ​​the intersection part (0 or the area of ​​the inner rectangle) and the vertices of the intersection area (empty set or vertices of the inner rectangle) can be directly obtained without calculating the boundary intersection points, which can further simplify the calculation.

[0140] See also Figure 7 , Figure 7 : is a flow chart of an embodiment of a target detection method provided by the present application, the method comprising:

[0141] S71: Perform target detection processing on the image to be detected to obtain multiple detection frames.

[0142] The image to be detected can be obtained from an image database, or can be shot in real time using a camera to generate the image to be detected; then the target detection method in the relevant technology is used to process the image to be detected to generate multiple detection frames.

[0143] S72: Calculate the overlap between the detection frame and another detection frame.

[0144] For the acquired detection frame, the detection frame overlap generation method in the above embodiment is used to calculate the overlap between the detection frame and another detection frame.

[0145] S73: Selecting a target detection frame from all detection frames based on the degree of overlap.

[0146] After obtaining the overlap, the NMS algorithm is used to filter out the target detection frame from all detection frames based on the overlap between the detection frames. The specific implementation process of the NMS algorithm is the same as that in the related art and will not be repeated here.

[0147] The target detection method provided in this embodiment utilizes the area invariance of rigid transformation and transforms the two rotated detection frames through rigid transformation with the same parameters to generate two new rotated detection frames (i.e., the second detection frame and the third detection frame) and two simple rectangular frames (i.e., the first detection frame and the fourth detection frame); it can simplify the calculation of the intersection area, reduce the complexity of calculating the intersection-over-union ratio of the rotated detection frames, and has high calculation accuracy, which helps to improve the accuracy of target detection and reduce the complexity of target detection.

[0148] See also Figure 8 , Figure 8 It is a structural diagram of an embodiment of a target detection device provided in the present application. The target detection device 80 includes a memory 81 and a processor 82 connected to each other. The memory 81 is used to store a computer program. When the computer program is executed by the processor 82, it is used to implement the method for generating the detection frame overlap in the above embodiment.

[0149] See also Fig. 9 , Fig. 9 It is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 90 is used to store a computer program 91. When the computer program 91 is executed by a processor, it is used to implement the method for generating the detection frame overlap in the above embodiment.

[0150] The computer-readable storage medium 90 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other media that can store program codes.

[0151] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0152] The units described as separate components may or may not be physically separated, and the components shown as units 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 units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0154] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for generating detection frame overlap, characterized in that: include: Obtain a first rotation detection frame and a second rotation detection frame; Transforming the first rotation detection frame and the second rotation detection frame to obtain a first detection frame corresponding to the first rotation detection frame and a second detection frame corresponding to the second rotation detection frame, wherein an upper boundary of the first detection frame is parallel to a horizontal direction, and a left boundary of the first detection frame is parallel to a vertical direction; Transforming the first rotation detection frame and the second rotation detection frame to obtain a third detection frame corresponding to the first rotation detection frame and a fourth detection frame corresponding to the second rotation detection frame, wherein an upper boundary of the fourth detection frame is parallel to the horizontal direction, and a left boundary of the fourth detection frame is parallel to the vertical direction; When the second detection frame or the third detection frame meets a preset condition, calculating an intersection point between the first detection frame and the second detection frame or an intersection point between the third detection frame and the fourth detection frame to obtain an intersection point set; Acquire vertices of the second detection frame that are located inside the first detection frame and vertices of the third detection frame that are located inside the fourth detection frame to obtain an internal vertex set; Based on the intersection point set and the internal vertex set, the overlap degree between the first rotation detection frame and the second rotation detection frame is calculated.

2. The method for generating detection frame overlap according to claim 1, characterized in that: The intersection point set includes position information of at least two intersection points, the internal vertex set includes position information of at least one internal vertex, and the step of calculating the overlap between the first rotation detection frame and the second rotation detection frame based on the intersection point set and the internal vertex set includes: Based on the position information of the intersection points and the position information of the vertices, all the intersection points and all the internal vertices are sorted to obtain an overlapping set, where the overlapping set includes all the intersection points in the intersection point set and all the internal vertices in the internal vertex set; The degree of overlap is calculated based on the position information of the intersection points in the overlap set and the position information of the internal vertices in the overlap set.

3. The method for generating detection frame overlap according to claim 2, characterized in that: The step of sorting all the intersection points and all the internal vertices based on the position information of the intersection points and the position information of the vertices to obtain an overlapping set comprises: Traversing the intersection point set, and extracting the current intersection point from the intersection point set in ascending order of the sequence numbers of the intersection points in the intersection point set; Putting the current intersection point into an overlap set; sorting the internal vertices based on a first detection box corresponding to the current intersection; The internal vertices are sorted based on a second detection box corresponding to the current intersection.

4. The method for generating detection frame overlap according to claim 3, characterized in that: The step of sorting the internal vertices based on the first detection box corresponding to the current intersection includes: Obtaining a boundary in the first detection frame corresponding to the current intersection point, and determining whether an end point of the boundary is the internal vertex; If the end point of the boundary is the internal vertex, the end point is recorded as the first point to be processed, and the first point to be processed is placed behind the current intersection point in the overlap set; Determine whether the next vertex of the first to-be-processed point is the internal vertex; If the next vertex of the first to-be-processed point is the internal vertex, the next vertex is placed behind the first to-be-processed point in the overlapping set, and the next vertex is used as the first to-be-processed point, and the step of returning to whether the next vertex of the first to-be-processed point is the internal vertex is returned until the next vertex is not the internal vertex; The step of sorting the internal vertices based on the second detection box corresponding to the current intersection point includes: Obtaining a boundary in the second detection frame corresponding to the current intersection point, and determining whether an end point of the boundary is the internal vertex; If the end point of the boundary is the internal vertex, the end point is recorded as the second point to be processed, and the second point to be processed is placed behind the current intersection point in the overlap set; Determine whether the next vertex of the second point to be processed is the internal vertex; If the next vertex of the second point to be processed is the internal vertex, put the next vertex behind the first point to be processed in the overlapping set, and use the next vertex as the second point to be processed, and return to the step of whether the next vertex of the second point to be processed is the internal vertex, until the next vertex is not the internal vertex.

5. The method for generating detection frame overlap according to claim 1, characterized in that: The method further comprises: Determining whether the second detection frame or the third detection frame satisfies the preset condition; If the second detection frame and the third detection frame do not satisfy the preset condition, determining whether there is an intersection area between the first detection frame and the second detection frame or whether there is an intersection area between the third detection frame and the fourth detection frame; If the first detection frame and the second detection frame have an intersecting area or the third detection frame and the fourth detection frame have an intersecting area, determine whether the first detection frame and the second detection frame have a containment relationship and whether the third detection frame and the fourth detection frame have a containment relationship; If it is determined that there is no inclusion relationship between the first detection frame and the second detection frame and there is no inclusion relationship between the third detection frame and the fourth detection frame, the intersection of the first detection frame and the second detection frame is calculated to obtain the intersection set.

6. The method for generating detection frame overlap according to claim 5, characterized in that: The step of calculating the intersection points of the first detection frame and the second detection frame to obtain the intersection point set includes: Numbering each boundary of the second detection frame in a counterclockwise order; Traversing all the boundaries of the second detection frame, and extracting the current boundary from all the boundaries of the second detection frame in ascending order of numbers; Calculating the intersection of the current boundary and all boundaries of the first detection frame; Determining whether the number of intersection points is a first preset number; If so, determining the order of the intersection points in the set of intersection points based on the starting point of the current boundary; If not, the intersection point is put into the intersection point set.

7. The method for generating detection frame overlap according to claim 6, characterized in that: The step of determining the order of the intersection points in the intersection point set based on the starting point of the current boundary comprises: Calculating the distance between the intersection point and the starting point of the current boundary; The starting points are placed into the intersection point set in order of distance from small to large.

8. The method for generating detection frame overlap according to claim 5, characterized in that: The method further comprises: Determining whether the number of internal vertices in the internal vertex set is a second preset number; If yes, then based on the intersection point set, calculating the overlap degree; If not, the overlap degree between the first rotation detection frame and the second rotation detection frame is calculated based on the intersection point set and the internal vertex set.

9. The method for generating detection frame overlap according to claim 8, characterized in that: The step of calculating the degree of overlap based on the intersection point set comprises: Using the position information of the intersection points in the intersection point set, calculating the area of ​​the intersection region between the first detection frame and the second detection frame to obtain the intersection area; Based on the intersection area, the overlap degree is calculated.

10. The method for generating detection frame overlap according to claim 5, characterized in that: The step of determining whether the second detection frame or the third detection frame satisfies the preset condition comprises: Determine whether the angle of the second detection frame falls within a preset angle range; if so, determine that the second detection frame meets the preset condition; or Determine whether the angle of the third detection frame falls within the preset angle range; if so, determine that the third detection frame meets the preset condition.

11. The method for generating detection frame overlap according to claim 5, characterized in that: The method further comprises: When there is an inclusion relationship between the first detection frame and the second detection frame or there is an inclusion relationship between the third detection frame and the fourth detection frame, determining whether the first detection frame includes the second detection frame; If so, the area of ​​the second detection frame is the intersection area; If not, the area of ​​the first detection frame is the intersection area.

12. The method for generating detection frame overlap according to claim 1, characterized in that: The method further comprises: When the second detection frame or the third detection frame meets the preset condition, the area of ​​the intersection region of the first detection frame and the second detection frame is calculated to obtain the intersection area.

13. The method for generating detection frame overlap according to claim 1, characterized in that: Before the step of transforming the first rotation detection frame and the second rotation detection frame, the method includes: Determine whether there is an intersection area between a first outer enclosing rectangular frame and a second outer enclosing rectangular frame, wherein the first outer enclosing rectangular frame is a rectangular frame enclosing the first rotation detection frame, and the second outer enclosing rectangular frame is a rectangular frame enclosing the second rotation detection frame; If yes, performing transformation processing on the first rotation detection frame and the second rotation detection frame; If not, it is determined that there is no intersection area between the first rotation detection frame and the second rotation detection frame, and the overlap degree is a preset overlap degree.

14. A target detection method, characterized in that: include: Perform target detection processing on the image to be detected to obtain multiple detection frames; Calculating the overlap between the detection frame and another detection frame; Based on the overlap, selecting a target detection frame from all the detection frames; The method for calculating the overlap between the detection frame and another detection frame is the method for generating the detection frame overlap according to any one of claims 1 to 13.

15. A target detection device, characterized in that: It comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the method for generating the detection frame overlap described in any one of claims 1 to 13 or the target detection method described in claim 14.

16. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by a processor, it is used to implement the method for generating the detection frame overlap degree according to any one of claims 1 to 13 or the target detection method according to claim 14.

Citation Information

Patent Citations

  • Rotating target detection method based on YOLOv5

    CN113326734A

  • Rotating rectangular frame representation and regression method for target detection

    CN113569194A