Rotating target detection method, storage medium and electronic device
By adopting the design idea of division and conquer in rotation target detection, two neural networks are used to process the four-point coordinates and center coordinates of the rotating object respectively, and combined with the rectangular constraint correction in the post-processing stage, the problem of difficulty in accurately predicting the direction angle of the rotating target in the existing technology is solved, and high-precision rotation target detection is achieved.
Patent Information
- Application Number
- CN202210220243.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-03-08
AI Technical Summary
The prior art is difficult to accurately predict the direction angle of the rotating target, resulting in low detection accuracy of the rotating target, and the existing methods are complex in structure and difficult to understand.
Using the design idea of division and conquer, two neural networks are used to process the four-point coordinate prediction and the center coordinate and category prediction of rotating objects. The first neural network DarkNet53 is responsible for predicting the detection frame and four-point coordinates, and the second neural network CSPDarkNet53 is responsible for predicting the central coordinates and categories. In the post-processing stage, the detection box is corrected to generate the corrected rectangular box, and the output of the first neural network is used to correct the output of the first neural network to obtain the rotation angle of the object.
Accurate prediction of the direction angle of the rotation target is achieved, detection accuracy is improved, network structure is simplified, network training is easier to converge, and regularization and generalization capabilities are increased.
Smart Images

Figure CN114677498B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to the field of target detection technology. Background Art
[0002] Object detection is one of the basic tasks of computer vision. In recent years, with the continuous deepening of deep learning algorithm research and the upgrading of hardware resources, many high-performance object detectors have been born. The current popular object detection algorithms can generally be divided into two types, one is the two-stage detection algorithm based on candidate regions, and the other is the single-stage detection algorithm based on regression. Among them, the two-stage detection algorithm has achieved relatively good results in detection accuracy, while the single-stage detection algorithm has an advantage in detection speed.
[0003] However, conventional target detection algorithms currently predict horizontal boxes, which have more or less limitations in many practical application scenarios. For example, scene text detection and remote sensing target detection. In these scenarios, objects will show various directions, and the aspect ratio of the objects may be large and the distribution may be too dense. These factors will cause some commonly used processing techniques in horizontal box target detection algorithms to fail, such as intersection over union (IoU), coordinate regression, non-maximum suppression (NMS), etc. The target detection algorithm often uses the intersection over union to determine the deviation between the predicted box and the true box, but the rotating target has a variety of tilt angles, and the minimum circumscribed horizontal rectangular box surrounding such targets will contain more background content. The intersection over union of the predicted box and the horizontal box generated by the general algorithm cannot accurately reflect its deviation from the actual target. According to the relationship between the predicted box and the true box, target detection often regresses the center coordinates and width and height of the box (or the coordinates of the upper left corner and the lower right corner of the box) according to the relationship between the predicted box and the true box. However, the aspect ratio of a rotating target is large, and a small change in the angle prediction may lead to a large and oscillating change in the intersection-over-union ratio. It is often very difficult to directly add angle information to regress the rotating frame, or even fail to converge. Non-maximum suppression is often used in the post-processing stage of target detection to filter out detection frames that repeatedly predict the same target. The application of the horizontal frame target detection algorithm to the detection of rotating targets often results in a large overlap in the prediction frames of different targets, resulting in incorrect filtering of detection frames.
[0004] At present, some detection algorithms for rotated objects mainly use methods such as generating more rotated candidate boxes and adding multiple feature refinement modules. Most of these methods have shortcomings such as complex structure and difficulty in understanding. In actual application scenarios, the detection algorithm for rotated objects is not yet mature and needs further research and improvement. Summary of the invention
[0005] In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide a rotating target detection method, a storage medium and an electronic device, which are used to solve the technical problem in the prior art that it is difficult to accurately predict the direction angle of a rotating target.
[0006] To achieve the above-mentioned purpose and other related purposes, the present invention provides a rotating target detection method, which includes: determining an anchor frame based on a data set for rotating target detection; generating a detection frame of the object to be detected through a first neural network and the anchor frame, and predicting the four vertex coordinates of the detection frame; predicting the center coordinates and category of the detection frame through a second neural network; performing rectangular constraint correction on the detection frame and the four vertex coordinates of the detection frame to generate a first corrected rectangular frame; correcting the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame; and outputting the rotation angle of the object to be detected according to the coordinates of the second corrected rectangular frame.
[0007] In one embodiment of the present invention, a kmeans++ clustering algorithm is used to determine the anchor boxes.
[0008] In one embodiment of the present invention, the anchor frame determination based on the data set for rotating target detection includes: setting the number of cluster centers; randomly selecting a sample from the data set as the initial cluster center; calculating the shortest distance between each sample in the data set and the current cluster center, and calculating the probability of each sample being selected as the next cluster center, repeating this step to obtain a number of cluster centers corresponding to the number of cluster centers; calculating the distance from each sample to each cluster center, classifying it into the category corresponding to the cluster center with the smallest distance, and for each category, calculating the median of the samples currently belonging to the category as the new cluster center, repeating this step until the classification of each sample no longer changes, at which time the cluster center obtained is the anchor frame.
[0009] In one embodiment of the present invention, the shortest distance between each sample in the data set and the current cluster center is calculated using the intersection-over-union ratio of the data set label true box and the bounding box of the selected cluster center.
[0010] In one embodiment of the present invention, the neural network model of the first neural network is DarkNet53; the neural network model of the second neural network is CSPDarkNet53.
[0011] In one embodiment of the present invention, the rectangular constraint correction is performed on the detection frame and the four vertex coordinates of the detection frame to generate a first corrected rectangular frame, including: obtaining the predicted four vertex coordinates of the detection frame; calculating the minimum circumscribed rectangle of the four vertices of the detection frame according to the positional relationship of the predicted four vertex coordinates of the detection frame, which is the first corrected rectangular frame; and outputting the coordinates of the four corner points of the minimum circumscribed rectangle.
[0012] In one embodiment of the present invention, the position of the first corrected rectangular frame is corrected based on the predicted center coordinates to generate a second corrected rectangular frame, including: arranging the coordinates of the first corrected rectangular frame in the order of upper left, upper right, lower right, and lower left; selecting the coordinates of two points in the upper left and lower right or the upper right and lower left to calculate the center coordinates therebetween; using the predicted center coordinates to correct the center coordinates of the first corrected rectangular frame, and at the same time correcting the four vertex coordinates of the first corrected rectangular frame according to the deviation therebetween, to obtain the center coordinates and four vertex coordinates of the final second corrected rectangular frame.
[0013] In one embodiment of the present invention, the coordinates of two points on the upper left or upper right or on the lower left or lower right of the second corrected rectangular frame are selected to calculate the rotation angle of the object to be detected.
[0014] To achieve the above-mentioned purpose and other related purposes, the present invention further provides a storage medium storing program instructions, which implement the steps of the rotating target detection method as described above when executed.
[0015] To achieve the above-mentioned purpose and other related purposes, the present invention also provides an electronic device, including a memory for storing a computer program; and a processor for running the computer program to implement the steps of the rotating target detection method as described above.
[0016] To achieve the above-mentioned purpose and other related purposes, the present invention also provides a mobile robot using the electronic device as described above.
[0017] As described above, the rotating target detection method, storage medium and electronic device of the present invention have the following beneficial effects:
[0018] The present invention adopts the design concept of divide and conquer, and proposes to use two networks to respectively process the four-point coordinate prediction of the rotating object and the center coordinate and category prediction of the rotating object, taking into account the situation that it is difficult to converge the training optimization of the tilt intersection ratio by directly adding angle information of the rotating target; rectangular constraint correction is applied to the output of the first neural network in the post-processing stage, so that the first neural network can realize polygon corner point learning in the training stage, making the training of the first neural network easier to converge, and the design increases the regularization of the network and has stronger generalization ability; finally, the design concept of aggregation is adopted to effectively combine the outputs of the two networks, and the output of the first neural network is corrected with the output of the second neural network to obtain the category probability, center coordinates, width, height and rotation angle of the object. Therefore, the rotating target detection method provided by the present invention is mainly based on the idea of divide and conquer and then aggregate correction. The overall framework structure is simple and easy to understand, which can effectively solve the technical problem of the difficulty in accurately predicting the direction angle of the rotating target in the prior art, and effectively solve the problem of rotating target detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 Shown is a schematic diagram of the overall process of a rotating target detection method in an embodiment of the present application;
[0021] Figure 2 Shown is a schematic diagram of the principle of a rotating target detection method in an embodiment of the present application;
[0022] Figure 3 Shown is a comparative schematic diagram of coordinate transformation adapted to the second neural network in a data set label in a rotating target detection method in an embodiment of the present application;
[0023] Figure 4 Shown is a clustering example diagram in a rotating target detection method in an embodiment of the present application;
[0024] Figure 5 Shown is an example diagram of the prediction result of an irregular trapezoid in the rotating target detection method in one embodiment of the present application;
[0025] Figure 6 Shown is an example diagram of the result of rectangular frame correction in the rotating target detection method in one embodiment of the present application;
[0026] Figure 7 Shown is a comparative example diagram of coordinate correction in a rotating target detection method in an embodiment of the present application;
[0027] Figure 8 Shown is a schematic diagram of rotation angle calculation in a rotating target detection method in an embodiment of the present application;
[0028] Fig. 9 Shown is a schematic diagram of the detection effect of a rotating target detection method in an embodiment of the present application;
[0029] Fig.10 Shown is a principle block diagram of an electronic device in an embodiment of the present application.
[0030] Component number description
[0031] 101 Electronic Equipment
[0032] 1001 Processor
[0033] 1002 Memory
[0034] S100~S600 Steps DETAILED DESCRIPTION
[0035] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0036] The purpose of this embodiment is to provide a rotating target detection method, a storage medium and an electronic device, which are used to solve the technical problem that it is difficult to accurately predict the direction angle of a rotating target in the prior art.
[0037] The present invention adopts a divide-and-conquer design concept, and proposes to use two networks to respectively process the four-point coordinate prediction of a rotating object and the center coordinate and category prediction of a rotating object, taking into account the situation that it is difficult to converge the training optimization of the tilt intersection ratio by directly adding angle information of the rotating target; rectangular constraint correction is applied to the output of the first neural network in the post-processing stage, so that the first neural network can realize polygon corner point learning in the training stage, making the training of the first neural network easier to converge, and the design increases the regularization of the network and has stronger generalization ability; finally, the aggregation design concept is adopted to effectively combine the outputs of the two networks, and the output of the first neural network is corrected with the output of the second neural network to obtain the category probability, center coordinates, width, height and rotation angle of the object.
[0038] The principles and implementation methods of the rotating target detection method, storage medium and electronic device of the present invention will be described in detail below so that those skilled in the art can understand the rotating target detection method, storage medium and electronic device of the present invention without creative work.
[0039] Example 1
[0040] This embodiment provides a rotating target detection method, specifically, as follows Figure 1 As shown, the rotating target detection method in this embodiment includes:
[0041] Step S100, determining an anchor frame based on a dataset of rotation target detection;
[0042] Step S200, generating a detection frame of the object to be detected through the first neural network and the anchor frame, and predicting the coordinates of four vertices of the detection frame;
[0043] Step S300, predicting the center coordinates and category of the detection frame through a second neural network;
[0044] Step S400, performing rectangular constraint correction on the detection frame and the coordinates of four vertices of the detection frame to generate a first corrected rectangular frame;
[0045] Step S500, correcting the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame;
[0046] Step S600: outputting the rotation angle of the object to be detected according to the coordinates of the second corrected rectangular frame.
[0047] That is Figure 2 As shown, the rotating target detection method of this embodiment includes: designing an anchor frame; designing two neural network models, the first neural network is responsible for the generation of the detection frame and the prediction of the four-point coordinates, and the second neural network is responsible for the prediction of the center coordinates and the category prediction; for the detection frame and the four-point coordinates generated by the first neural network, a rectangular constraint correction is performed to generate a corresponding rectangular frame; the position of the rectangular frame is corrected using the center coordinates predicted by the second neural network; for the corrected rectangular frame, the center coordinates and the direction angle of the object to be detected are output according to the conversion relationship between the coordinates and the width, height and rotation angle.
[0048] The following combination Figures 3 to 9 Steps S100 to S600 of the rotating target detection method of this embodiment are described in detail.
[0049] Step S100, determining an anchor box based on a dataset of rotated object detection.
[0050] In this embodiment, the detection target is a directional object, and the kmeans++ clustering algorithm is used to determine the anchor box.
[0051] The dataset labels for rotating object detection usually include the center coordinates, width and height (width and height of the horizontal box in the non-traditional sense) and rotation angle, or the coordinates of the four corner points of the rotating box. Since the second neural network uses a general target detection framework to predict the center coordinates and categories, it is difficult to adapt to such labels. Therefore, the present invention proposes a coordinate transformation that adapts to the second neural network. Specifically, the minimum horizontal rectangular box surrounding the coordinates is mapped according to the coordinates of the original rotated real box. The coordinates of the horizontal rectangular box are the new data labels. Figure 3As shown, the solid line tilted box in the left figure is the bounding box of the original rotated target detection data set, and the solid line box in the right figure is the minimum horizontal rectangular box surrounding the tilted box. Since the mapping transformation from the tilted box to the horizontal box has an expansion of the coverage area, the new label expands more background context information on the basis of maintaining the original feature information. At the same time, the center coordinates and categories of the new label remain unchanged, which is conducive to the second neural network to predict the center coordinates and categories more accurately. In particular, the data set label processing only needs to be implemented in the training phase, and will not increase the time used in the reasoning phase.
[0052] In this embodiment, the width and height data in the data set are extracted, and the kmeans++ clustering algorithm is used to generate 9 anchor boxes of different scales based on the data set.
[0053] Specifically, in this embodiment, determining the anchor frame based on the data set of the rotation target detection includes:
[0054] 1) Set the number of cluster centers;
[0055] 2) Randomly select a sample from the data set as the initial cluster center;
[0056] 3) Calculate the shortest distance between each sample in the data set and the current cluster center, and calculate the probability of each sample being selected as the next cluster center, repeat this step to obtain a number of cluster centers corresponding to the number of cluster centers, wherein, in this embodiment, the intersection and union ratio of the true box of the data set label and the bounding box of the selected cluster center is used to calculate the shortest distance between each sample in the data set and the current cluster center.
[0057] 4) Calculate the distance from each sample to each cluster center, classify it into the category corresponding to the cluster center with the smallest distance, and for each category, calculate the median of the samples currently belonging to that category as the new cluster center, and repeat this step until the classification of each sample does not change. At this time, the cluster center obtained is the anchor box.
[0058] Furthermore, the process of generating anchor frames using the clustering algorithm in this embodiment is as follows:
[0059] Considering that the initial centers used by the kmeans clustering algorithm are randomly set, the clustering results obtained by different initial center settings may be quite different. This embodiment uses the kmeans++ clustering algorithm to generate anchor boxes. The kmeans++ algorithm: ① Set the k value as the number of cluster centers (the k value can be designed according to the elbow rule, or according to the number of categories of objects in the data set or the output of the network model. In the specific embodiment, k=9); ② Randomly select a sample from the data set as the initial cluster center c1; ③ Calculate the shortest distance between each sample in the data set and the current existing cluster center (that is, the distance to the nearest cluster center), expressed as d(x); ④ Calculate the probability of each sample being selected as the next cluster center. The probability expression is defined as Select the next cluster center according to probability; ⑤ Repeat steps ③ and ④ until k cluster centers c1, c2, ..., c k ;⑥ Calculate the distance between each sample and the k cluster centers, and classify it into the class corresponding to the center with the smallest distance; ⑦ For each category c i , calculate the median of the samples currently belonging to this category as the new cluster center; ⑧ Repeat steps ⑥ and ⑦ until the classification of each sample does not change. The cluster center obtained at this time is the anchor box (see the specific example). Figure 4 ).
[0060] In particular, in this embodiment, the distance d(x) is calculated using the intersection over union (IoU) of the ground truth box of the dataset label and the bounding box of the selected cluster center, so as to select an anchor box that better reflects the scale distribution of the target to be detected as prior knowledge. The calculation formula is:
[0061] d(x)=1-IoU(box,center).
[0062] Step S200, generating a detection frame of the object to be detected through the first neural network and the anchor frame, and predicting the coordinates of four vertices of the detection frame.
[0063] Among them, in this embodiment, the neural network model of the first neural network is DarkNet53. That is, in this embodiment, the first neural network responsible for the generation of the detection frame and the prediction of the four-point coordinates is DarkNet53, and FPN is used for further processing of the feature map in the first neural network.
[0064] Conventional target detection frameworks generally design loss functions based on the intersection-and-union ratio of predicted horizontal boxes and true horizontal boxes to achieve regression prediction of center coordinates and width and height. However, in the application scenario of rotating targets, the target has a variety of tilt angles, and the minimum circumscribed horizontal rectangular box surrounding such targets will contain more background content. The intersection-and-union ratio used by conventional algorithms cannot accurately reflect its deviation from the actual target. The tilt intersection-and-union ratio obtained by adding angle information is very sensitive to angles. Slight changes in angle prediction may cause large and oscillating changes in the intersection-and-union ratio, and it is difficult to converge effectively. This embodiment considers directly performing regression prediction on the four vertex coordinates of the rotating box, reducing the redundant calculation of the intermediate processing link based on the intersection-and-union ratio, and enabling the first neural network to learn the edge corner point features of the target more deeply during the training stage, thereby improving the adaptability to multi-angle targets. In particular, in order to speed up convergence, the four-point coordinates predicted in the training stage will not be corrected by rectangular constraints, but will directly participate in network training as input to the loss function.
[0065] Step S300: predicting the center coordinates and category of the detection box through a second neural network.
[0066] Among them, in this embodiment, the neural network model of the second neural network is CSPDarkNet53. That is, in this embodiment, the neural network model of the second neural network responsible for center coordinate prediction and category prediction is CSPDarkNet53, and PAN is used for further processing of the feature map in the second neural network.
[0067] In this embodiment, the second neural network uses CSPDarkNet53 as the backbone network, and PAN is used to further process the extracted features. The data set that has completed label processing is sent to the network. The specific training process is consistent with the open source single-stage detection algorithm. The center coordinates and categories of the object to be detected are obtained through the trained second neural network for subsequent rotation frame coordinate correction.
[0068] Step S400 , performing rectangular constraint correction on the detection frame and the coordinates of four vertices of the detection frame to generate a first corrected rectangular frame.
[0069] Specifically, in this embodiment, the method further includes: performing rectangular constraint correction on the detection frame and the four vertex coordinates of the detection frame to generate a first corrected rectangular frame includes:
[0070] Obtain the predicted coordinates of the four vertices of the detection frame; calculate the minimum circumscribed rectangle that envelops the four vertices of the detection frame according to the positional relationship of the predicted coordinates of the four vertices of the detection frame, which is the first corrected rectangular frame; and output the coordinates of the four corner points of the minimum circumscribed rectangle.
[0071] like Figure 5As shown in , due to the direct regression prediction of the four-point coordinates, the output generated by the trained model is generally an irregular quadrilateral box. In this embodiment, a rectangular constraint correction is designed in the post-processing stage to address this problem, such as Figure 6 As shown, specifically, the four-point coordinates (x1, y1), (x2, y2), (x3, y3) and (x4, y4) of the object bounding box output by the trained first neural network are used as input and converted into the minimum circumscribed rectangle vertex coordinates (x'1, y'1), (x'2, y'2), (x'3, y'3) and (x'4, y'4) surrounding the four-point coordinates according to their geometric position relationship.
[0072] Step S500: Correct the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame.
[0073] The detection frame corrected by the rectangular constraint may have a certain degree of positional deviation. According to the positional relationship of the four-point coordinates of the polygon, a sorting algorithm is designed to arrange the corner point coordinates of the minimum circumscribed rectangle in the order of upper left, upper right, lower right, and lower left. The coordinates of the two points of the upper left and lower right (or upper right and lower left) are selected to calculate the center coordinates therebetween. The predicted center coordinates are then used to correct the center coordinates of the minimum circumscribed rectangular frame. At the same time, the four-point coordinates of the circumscribed rectangular frame are corrected according to the deviation between the two.
[0074] Specifically, in this embodiment, the step of correcting the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame includes:
[0075] Arrange the coordinates of the first corrected rectangular frame in the order of upper left, upper right, lower right, and lower left; select the coordinates of two points in the upper left, lower right or upper right, lower left to calculate the center coordinates between them; use the predicted center coordinates to correct the center coordinates of the first corrected rectangular frame, and at the same time correct the four vertex coordinates of the first corrected rectangular frame according to the deviation between the two, to obtain the center coordinates and four vertex coordinates of the final second corrected rectangular frame.
[0076] like Figure 7 As shown in FIG. 1 , the predicted box corrected by the rectangular constraint may have an overall position offset. This embodiment proposes to use the center coordinates predicted by the second neural network to correct the rotated box. First, a sorting algorithm is designed according to the positional relationship of the bounding box coordinates corrected by the rectangular constraint to arrange them in the order of upper left, upper right, lower right, and lower left. The coordinates of the upper left and lower right (or upper right and lower left) points are selected to calculate the center coordinates between them. Then, the predicted center coordinates (x center ,y center) corrects the center coordinates of the bounding box corrected by the rectangular constraint, and corrects the four-point coordinates of the rectangular bounding box according to the deviation between the two, to obtain the final center coordinates (x, y) and four-point coordinates (x lt ,y lt )、(x rt ,y rt )、(x rb ,y rb )、(x lb ,y lb ). See the specific formula below.
[0077] x delta =x center -(x′1+x′3) / 2
[0078] y delta =y center -(y′1+y′3) / 2
[0079] x=x center ,y=y center
[0080] x lt =x′1+x delta ,y lt =y′1+y delta
[0081] x rt =x′2+x delta ,y rt =y′2+y delta
[0082] x rb =x′3+x delta ,y rb =y′3+y delta
[0083] x lb =x′4+x delta ,y lb =y′4+y delta .
[0084] Step S600: outputting the rotation angle of the object to be detected according to the coordinates of the second corrected rectangular frame.
[0085] In this embodiment, for the rectangular frame coordinates of the second corrected rectangular frame after they are sorted as upper left, upper right, lower right, and lower left, the coordinates of the upper left and upper right (or lower left and lower right) points are selected to calculate the width of the rectangular frame, the coordinates of the upper left and lower left (or upper right and lower right) points are selected to calculate the height of the rectangular frame, and the coordinates of the upper left and upper right (or lower left and lower right) points are selected to calculate the rotation angle of the rectangular frame.
[0086] In this embodiment, the coordinates of two points on the upper left, upper right or lower left, lower right of the second corrected rectangular frame are selected to calculate the rotation angle of the object to be detected.
[0087] For the rectangular bounding box coordinates sorted by upper left, upper right, lower right, and lower left, the coordinates of the upper left and upper right (or lower left and lower right) points are selected to calculate the rotation angle α of the rectangular box, such as Figure 8 As shown, the specific formula is as follows:
[0088]
[0089] The specific embodiment described in this embodiment uses the public dataset MVTec Screws dataset. The MVTecScrews dataset is a dataset specifically used for rotating object detection, which is produced by MVTec Software GmbH. The dataset contains 384 pictures based on wooden backgrounds. The objects in the pictures involve 13 types of screws and nuts, and all are marked with rotation bounding boxes and their categories. There are 4426 annotated instances in the dataset.
[0090] like Fig. 9 The figure shows the detection result of one of the images in the MVTec Screws dataset, where the correctly detected objects are framed by the colored bounding boxes of the corresponding categories. It can be seen that most objects are detected and completely surrounded by directed rectangular boxes, from which the accurate center coordinates and rotation angles can be obtained. At the same time, the overall framework structure of the method proposed in this embodiment is simple and easy to understand, and it is a very practical method.
[0091] Example 2
[0092] like Fig.10 As shown, this embodiment provides an electronic device 101, and the electronic device 101 includes: a processor 1001 and a memory 1002; the memory 1002 is used to store a computer program; the processor 1001 is used to execute the computer program stored in the memory 1002, so that the electronic device 101 performs the steps of the rotating target detection method in Example 1. Since the specific implementation process of the steps of the rotating target detection method has been described in detail in Example 1, it will not be repeated here.
[0093] The processor 1001 is a central processing unit. The memory 1002 is connected to the processor 1001 through a system bus and communicates with each other. The memory 1002 is used to store computer programs, and the processor 1001 is used to run the computer programs so that the processor 1001 executes the rotating target detection method. The memory 1002 may include a random access memory (Random Access Memory, referred to as RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.
[0094] In addition, this embodiment further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by the processor 1001, the steps in the rotating target detection method described in Embodiment 1 are implemented. Embodiment 1 has already described the rotating target detection method in detail, which will not be repeated here.
[0095] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0096] In summary, the present invention adopts the design idea of divide and conquer, proposes to use two networks to respectively process the four-point coordinate prediction of the rotating object and the center coordinate and category prediction of the rotating object, and considers the situation that it is difficult to converge the training optimization of the tilt intersection ratio by directly adding angle information to the rotating target; the output of the first neural network is corrected by applying rectangular constraints in the post-processing stage, so that the first neural network can realize polygon corner point learning in the training stage, making the training of the first neural network easier to converge, and the design increases the regularization of the network and has stronger generalization ability; finally, the design idea of aggregation is adopted to effectively combine the outputs of the two networks, and the output of the first neural network is corrected with the output of the second neural network to obtain the category probability, center coordinate, width and height and rotation angle of the object. Therefore, the rotating target detection method provided by the present invention is mainly based on the idea of divide and conquer and then aggregate correction, and the overall framework structure is simple and easy to understand, which can effectively solve the technical problem of the difficulty in accurately predicting the direction angle of the rotating target in the prior art, and effectively solve the problem of rotating target detection. Therefore, the present invention effectively overcomes the various shortcomings in the prior art and has a high industrial utilization value.
[0097] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical ideas disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A rotating target detection method, characterized in that: The method comprises: Determine anchor boxes based on a dataset of rotated object detection; Generate a detection frame of the object to be detected through the first neural network and the anchor frame, and predict the coordinates of four vertices of the detection frame; Predicting the center coordinates and category of the detection frame by a second neural network; Performing rectangular constraint correction on the detection frame and the coordinates of four vertices of the detection frame to generate a first corrected rectangular frame; Correcting the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame; Outputting the rotation angle of the object to be detected according to the coordinates of the second corrected rectangular frame; The performing rectangular constraint correction on the detection frame and the four vertex coordinates of the detection frame to generate a first corrected rectangular frame includes: Obtain the predicted coordinates of four vertices of the detection box; Calculate the minimum circumscribed rectangle of the four vertices of the detection frame according to the predicted positional relationship of the coordinates of the four vertices of the detection frame, which is the first corrected rectangular frame; Output the coordinates of the four corner points of the minimum circumscribed rectangle; The step of correcting the position of the first corrected rectangular frame based on the predicted center coordinates to generate a second corrected rectangular frame comprises: Arrange the coordinates of the first corrected rectangular frame in the order of upper left, upper right, lower right, and lower left; Select the coordinates of two points, upper left, lower right or upper right, lower left, to calculate the center coordinates between them; The center coordinates of the first corrected rectangular frame are corrected using the predicted center coordinates, and the four vertex coordinates of the first corrected rectangular frame are corrected according to the deviation between the two, so as to obtain the center coordinates and four vertex coordinates of the final second corrected rectangular frame.
2. The rotating target detection method according to claim 1, characterized in that: The kmeans++ clustering algorithm is used to determine the anchor box.
3. The rotating target detection method according to claim 1 or 2, characterized in that: The determining of the anchor frame based on the data set of the rotation target detection includes: Set the number of cluster centers; Randomly select a sample from the data set as the initial cluster center; Calculate the shortest distance between each sample in the data set and the current cluster center, and calculate the probability of each sample being selected as the next cluster center, repeat this step to obtain the number of cluster centers corresponding to the number of cluster centers; Calculate the distance from each sample to each cluster center, classify it into the category corresponding to the cluster center with the smallest distance, and for each category, calculate the median of the samples currently belonging to that category as the new cluster center, and repeat this step until the classification of each sample no longer changes. At this time, the cluster center obtained is the anchor box.
4. The rotating target detection method according to claim 3, characterized in that: The shortest distance between each sample in the dataset and the current cluster center is calculated by using the intersection of the dataset label ground truth box and the bounding box of the selected cluster center.
5. The rotating target detection method according to claim 1, characterized in that: The neural network model of the first neural network is DarkNet53; the neural network model of the second neural network is CSPDarkNet53.
6. The rotating target detection method according to claim 1, characterized in that: The coordinates of two points on the upper left, upper right or lower left, lower right of the second corrected rectangular frame are selected to calculate the rotation angle of the object to be detected.
7. A storage medium storing program instructions, characterized in that: When the program instructions are executed, the steps of the rotating target detection method according to any one of claims 1 to 6 are implemented.
8. An electronic device, characterized in that: It comprises a memory for storing a computer program; and a processor for running the computer program to implement the steps of the rotating target detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Target detection method for rotating object
CN111524095A
Hoisting object single-order detection method and device, electronic equipment and storage medium
CN112215308A