A ship detection method and system for simulating changes in different angles
By simulating the detection method of different angle transformations and using angle, height and distance information for model training, the problem of inaccurate rectangular labeling boxes in drone detection is solved, and more accurate ship detection results are achieved.
Patent Information
- Application Number
- CN202410881427.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-03
AI Technical Summary
When existing drones detect ships, the rectangular labeling box cannot be accurately marked, the data fitting does not conform to the real object, and the loss calculation lacks angle information, resulting in inaccurate ship detection.
Using a detection method that simulates different angle transformations, by acquiring ship images at multiple angles, heights and distances, the vertex coordinates and edge angles are calibrated, binary processing and mapping transformation are performed, and model training is performed based on feature similarity and angle loss values. Add angle detection branch to achieve more accurate ship detection.
In the case of drone photography, the position and category of the ship can be accurately detected, which improves the accuracy and adaptability of detection.
Smart Images

Figure CN118411683B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of ship detection, and in particular to a ship detection method and system for simulating transformations at different angles. Background Art
[0002] As water transportation continues to develop, water transportation order is also constantly upgraded, and the workload of staff maintaining water transportation is increasing. Ship detection is one of the workloads of water transportation. However, since water transportation is not like road transportation, it is very complicated to install cameras. Based on this problem, the industry has proposed the use of drones to detect surface ships and monitor whether ships and crews on ships are wearing safety life jackets. Although drones can observe at close range, the current image detection methods have the following problems in drone applications:
[0003] ① The drone uses a bird's-eye view to observe ships and information on them, which results in the ships and objects on them being photographed by the drone being basically not rectangular, and the conventional rectangular annotation method cannot be used;
[0004] ② The drone is at a flying angle, so the features of the objects photographed by the drone may be different at different angles and positions. The existing rotation image processing method cannot simulate the real scene of the object being photographed;
[0005] ③ There are angle problems when drones photograph objects, and the current loss calculation method cannot effectively realize the learning of ship detection models.
[0006] With regard to the above-mentioned problem of using drones to detect the presence of ships, the marking boxes cannot be accurately marked using rectangular markings, the data cannot effectively fit the real objects, and the loss calculation lacks angle information, so accurate detection of ships cannot be achieved. No effective solution has been proposed so far. Summary of the invention
[0007] In an embodiment of the present invention, a ship detection method and system for simulating different angle transformations are provided to solve the problem that in the prior art, when drones are used to detect the presence of ships, the marking boxes cannot be accurately marked using rectangular markings, the data cannot effectively fit the real objects, and the loss calculation lacks angle information, thus making it impossible to accurately detect the ships.
[0008] To achieve the above-mentioned purpose, on the one hand, the present invention provides a ship detection method for simulating different angle transformations, the method comprising: S1, obtaining an original training set, the original training set comprising multiple ship pictures of the same ship at different angles, heights and distances; S2, selecting each ship in the original training set through a target frame, and calibrating the coordinates of each vertex and the angle of each edge to obtain a calibrated training set; S3, randomly extracting a picture from the calibrated training set as an original color picture; performing binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain Map the target calibration frame of the color image after the transformation; calculate the angle of each edge of the target calibration frame of the color image after the transformation; S4, input the original color image and the color image after the transformation into the backbone network of the original ship detection model, and obtain the original feature map and the feature map after the transformation respectively; perform feature serialization on the original feature map and the feature map after the transformation respectively to obtain the original feature vector and the feature vector after the transformation; input the original feature vector and the feature vector after the transformation into the modified detection head of the original ship detection model for prediction, and obtain the original predicted coordinates, categories and the angle of each edge, as well as the predicted coordinates, categories and the angle of each edge after the transformation; S5, calculate the feature similarity loss value according to the original feature vector and the feature vector after the transformation; calculate the original coordinate loss value, the original category loss value and the original angle loss value according to the target calibration coordinates, categories and the angle of each edge of the original color image, and the original predicted coordinates, categories and the angle of each edge; calculate the mapping coordinate loss value, according to the target calibration coordinates, categories and the angle of each edge of the color image after the transformation, and the predicted coordinates, categories and the angle of each edge after the transformation Mapping category loss values, mapping angle loss values; summing up feature similarity loss values, all coordinate loss values, all category loss values, and all angle loss values to obtain an iterative total loss value; back-propagating and updating the original ship detection model according to the iterative total loss value; S6, repeating S3-S5, training the calibration training set and performing multiple rounds of training until the iterative total loss value fluctuates within a preset range, stopping training, and obtaining a target ship detection model; S7, inputting the image of the ship to be detected into the target ship detection model for detection to obtain the ship's position and category.
[0009] Optionally, the binarization, pixel assignment and mapping transformation processing are performed on the original color image to obtain a target calibration frame of the mapped color image, including: establishing a binarized image of the same scale as the original color image; assigning a background value of 0 to the binarized image, and assigning values different from 0 to the pixels at the four corners of the ship in the binarized image; multiplying the original color image and the assigned binarized image by the same vertex mapping change matrix to respectively obtain a mapped color image and a mapped binary image; finding four pixel assignments different from 0 in the mapped binary image, and connecting them in sequence to form a target calibration frame; using the target calibration frame of the mapped binary image as the target calibration frame of the mapped color image.
[0010] Optionally, the same vertex mapping change matrix by which the original color image and the assigned binary image are multiplied is randomly selected from the following: multiple vertex mapping transformation matrices corresponding one to one from the original ship image of the same ship to ship images at multiple different angles, heights and distances are calculated respectively.
[0011] Optionally, the feature similarity loss value is calculated according to the following formula:
[0012] ;
[0013] in, is the original eigenvector, is the feature vector after mapping transformation, is the feature similarity loss value.
[0014] Optionally, the original coordinate loss value and the mapped coordinate loss value are calculated according to the following formula:
[0015] ;
[0016] Among them, when When is the original coordinate loss value, is the number of pixels in the target area manually calibrated in the original color image, is the number of pixels in the target area predicted by the original color image. is the number of pixels in the overlapped part between the manually calibrated target area of the original color image and the predicted target area; When is the mapping coordinate loss value, is the number of pixels in the target calibration box of the mapped color image, is the number of pixels in the target area of the color map prediction inference after mapping transformation, The number of pixels of the overlapping part between the color map target calibration box area after mapping transformation and the predicted inference target area;
[0017] The original angle loss value and the mapped angle loss value are calculated according to the following formula:
[0018] ;
[0019] Among them, when When is the original angle loss value, is the angle of the i-th edge marked by the original color map, is the angle of the i-th edge predicted by the original color image, is the preset hyperparameter; when When is the mapping angle loss value, is the angle of the i-th edge marked by the color map after the mapping transformation, The angle of the i-th edge of the color map prediction inference after mapping transformation, are the preset hyperparameters.
[0020] Optionally, the modified detection head adds angle detection to the original detection head that conventionally detects coordinates and categories.
[0021] Optionally, the angle of each edge is calculated according to the following formula:
[0022] ;
[0023] Among them, k is the slope of the current edge, a is the angle of the current edge, (x1, y1), (x2, y2) are any two points on the current edge.
[0024] On the other hand, the present invention provides a ship detection system for simulating different angle transformations, the system comprising: an acquisition unit, used to acquire an original training set, the original training set comprising multiple ship pictures of the same ship at different angles, heights and distances; a calibration unit, used to select each ship in the original training set through a target frame, and calibrate the coordinates of each vertex and the angle of each edge to obtain a calibrated training set; a mapping transformation unit, used to randomly extract a picture from the calibration training set as an original color picture; perform binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain a mapping transformation. The target calibration frame of the mapped color image is obtained; the angle of each side of the target calibration frame of the mapped color image is calculated; a prediction unit is used to input the original color image and the mapped color image into the backbone network of the original ship detection model to obtain the original feature map and the mapped feature map respectively; the original feature map and the mapped feature map are respectively feature serialized to obtain the original feature vector and the mapped feature vector; the original feature vector and the mapped feature vector are input into the modified detection head of the original ship detection model for prediction to obtain the original predicted coordinates, categories and the angle of each side, and the original predicted coordinates, categories and the angle of each side are obtained. and the predicted coordinates, categories and angles of each edge after mapping transformation; a loss calculation unit, used to calculate the feature similarity loss value according to the original feature vector and the feature vector after mapping transformation; the original coordinate loss value, the original category loss value and the original angle loss value are calculated according to the target calibration coordinates, categories and angles of each edge of the original color image and the original predicted coordinates, categories and angles of each edge; the mapping coordinate loss value, the mapping category loss value and the mapping angle loss value are calculated according to the target calibration coordinates, categories and angles of each edge of the color image after mapping transformation and the predicted coordinates, categories and angles of each edge after mapping transformation. loss value; summing up the feature similarity loss value, all coordinate loss values, all category loss values, and all angle loss values to obtain an iterative total loss value; back-propagating and updating the original ship detection model according to the iterative total loss value; a repeated training unit, used to repeat the mapping transformation unit, the prediction unit, and the loss calculation unit, training the calibration training set and performing multiple rounds of training until the iterative total loss value fluctuates within a preset range, stopping the training, and obtaining a target ship detection model; a detection unit, used to input the ship image to be detected into the target ship detection model for detection, and obtain the ship position and category.
[0025] Optionally, the binarization, pixel assignment and mapping transformation processing are performed on the original color image to obtain a target calibration frame of the mapped color image, including: establishing a binarized image of the same scale as the original color image; assigning a background value of 0 to the binarized image, and assigning values different from 0 to the pixels at the four corners of the ship in the binarized image; multiplying the original color image and the assigned binarized image by the same vertex mapping change matrix to respectively obtain a mapped color image and a mapped binary image; finding four pixel assignments different from 0 in the mapped binary image, and connecting them in sequence to form a target calibration frame; using the target calibration frame of the mapped binary image as the target calibration frame of the mapped color image.
[0026] Optionally, the same vertex mapping change matrix by which the original color image and the assigned binary image are multiplied is randomly selected from the following: multiple vertex mapping transformation matrices corresponding one to one from the original ship image of the same ship to ship images at multiple different angles, heights and distances are calculated respectively.
[0027] Beneficial effects of the present invention:
[0028] The present invention provides a ship detection method and system for simulating different angle transformations, wherein the method uses three factors of angle, height and distance to guide and supervise prior knowledge to obtain a picture transformation that is more in line with the actual scene; uses standard key point information and binarization processing to realize the target coordinates of online calibration vertex mapping transformation; modifies the model structure, adds angle loss branches and manual calibration target serialization, so that when the model is trained, in addition to conventional coordinates and category supervision, four edge angle supervision and similarity supervision after affine transformation of different vertices are added; modifies the coordinate loss function, because the prediction box used by the method of the present invention is not a rectangular box, the conventional coordinate loss function cannot meet the coordinate supervision requirements, therefore, the coordinate loss function is calculated by the pixel value overlapping area. The method of the present invention can accurately detect ships when using drones to shoot ships. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of a ship detection method simulating different angle changes provided by an embodiment of the present invention;
[0030] Figure 2 It is a structural schematic diagram of a ship detection system simulating different angle transformations provided by an embodiment of the present invention;
[0031] Figure 3 It is a structural schematic diagram of the mapping transformation between the original color image and the binary image provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] Figure 1 FIG. 1 is a flow chart of a ship detection method simulating different angle changes provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0034] S1. Obtain an original training set, wherein the original training set includes multiple ship images of the same ship at different angles, heights, and distances;
[0035] Specifically, in addition to the conventional ship image collection, it is also necessary to collect targeted ship images of the same ship at multiple different angles, heights and distances; for example: the original ship image A of the same ship, ship images A1 and A2 at different angles from A; ship images A3 and A4 at different angles and heights from A, and ship image A5 at different angles, heights and distances from A.
[0036] S2, select each ship in the original training set through a target box, and calibrate the coordinates of each vertex and the angle of each edge to obtain a calibrated training set;
[0037] Specifically, the coordinates of the four vertices of each ship are calibrated, and the angles of the four sides connected in sequence by the four vertices are calibrated.
[0038] The angle of each edge is calculated according to the following formula:
[0039] ;
[0040] Among them, k is the slope of the current edge, a is the angle of the current edge, (x1, y1), (x2, y2) are any two points on the current edge.
[0041] S3, randomly extracting a picture from the calibration training set as the original color picture; performing binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain a target calibration frame of the mapped color picture; calculating the angle of each side of the target calibration frame of the mapped color picture;
[0042] Specifically, Figure 3 Schematic diagram of the structure of the original color image and the binary image mapping transformation provided by the embodiment of the present invention; Figure 3As shown, the original color image is subjected to binarization processing, pixel assignment processing and mapping transformation processing to obtain a target calibration frame of the mapped color image, including:
[0043] Creating a binary image with the same scale as the original color image;
[0044] Assigning 0 to the background of the binary image, and assigning values different from 0 to the pixels at the four corners of the ship in the binary image (for example, assigning 1 to the pixels at the four corners);
[0045] like Figure 3 As shown in (a) and (b); (a) is the original color image; (b) is the binary image.
[0046] Multiplying the original color image and the assigned binary image by the same vertex mapping change matrix to obtain a color image after mapping transformation and a binary image after mapping transformation, respectively;
[0047] Specifically, the same vertex mapping change matrix multiplied by the original color image and the assigned binary image is randomly selected from the following:
[0048] Calculate multiple vertex mapping transformation matrices corresponding to each other from the original ship image of the same ship to multiple ship images at different angles, heights and distances.
[0049] For example: (1) The four vertices of the original ship image are (A, B, C, D), and the four vertices of a ship with different angles, different heights, and the same distance are (A1, B1, C1, D1);
[0050] (A1, B1, C1, D1) = T1 (A, B, C, D);
[0051] Among them, T1 is the vertex mapping transformation matrix.
[0052] (2) The four vertices of the original ship image are (A, B, C, D), and the four vertices of a ship with different angles, the same height, and different distances are (A2, B2, C2, D2);
[0053] (A2, B2, C2, D2) = T2 (A, B, C, D);
[0054] Among them, T2 is the vertex mapping transformation matrix.
[0055] Through this method, multiple vertex mapping transformation matrices can be obtained, and one can be randomly selected from the multiple vertex mapping transformation matrices.
[0056] Furthermore, the present invention may also use a perspective transformation matrix or a matrix trained by deep learning. The present invention does not limit the vertex mapping transformation matrix.
[0057] The present invention is described below by a specific embodiment:
[0058] The perspective transformation matrix is calculated using the following formula:
[0059] ;
[0060] in, ; ; u, v are the coordinates of the four vertices of the original ship image; x, y are the coordinates of the four vertices of the original ship image after perspective transformation; is the perspective transformation matrix;
[0061] For example: the coordinates of the four vertices of the original ship image are (248,282), (505,348), (275,311), (477,363);
[0062] The coordinates of the four vertices of the original ship image after perspective transformation are (297,242), (32,224), (254,260), (56,224);
[0063] Then substitute the following formula:
[0064] ;
[0065] get:
[0066] ;
[0067] Through the above four formulas, we can get:
[0068] ;
[0069] That is, T3 is the perspective transformation matrix.
[0070] The original color image and the assigned binary image are multiplied by T3 to obtain the mapped color image and the mapped binary image respectively; Figure 3 As shown in (c) and (d); (c) is the binary image after mapping transformation; (d) is the color image after mapping transformation.
[0071] Find four pixel values different from 0 in the binary image after the mapping transformation, connect them in sequence to form a target calibration frame; and use the target calibration frame of the binary image after the mapping transformation as the target calibration frame of the color image after the mapping transformation.
[0072] Calculate the angle of each side of the target calibration box of the mapped color image;
[0073] The angle of each edge is calculated according to the following formula:
[0074] ;
[0075] Among them, k is the slope of the current edge, a is the angle of the current edge, (x1, y1), (x2, y2) are any two points on the current edge.
[0076] S4, inputting the original color image and the color image after mapping transformation into the backbone network of the original ship detection model, respectively obtaining the original feature map and the feature map after mapping transformation; performing feature serialization on the original feature map and the feature map after mapping transformation, respectively, to obtain the original feature vector and the feature vector after mapping transformation; inputting the original feature vector and the feature vector after mapping transformation into the modified detection head of the original ship detection model for prediction, to obtain the original prediction coordinates, categories and angles of each edge, and the prediction coordinates, categories and angles of each edge after mapping transformation;
[0077] Specifically, the original color image and the color image after the mapping transformation are input into the backbone network of the original ship detection model and subjected to convolution operation, and then converted into a 1*k feature map to obtain the original feature map and the feature map after the mapping transformation, respectively; the original feature map and the feature map after the mapping transformation are subjected to feature serialization such as seq2seq operation to obtain the original feature vector and the feature vector after the mapping transformation.
[0078] Inputting the original feature vector and the feature vector after mapping transformation into the modified detection head of the original ship detection model for prediction, and obtaining the original prediction coordinates, categories and angles of each edge, and the prediction coordinates, categories and angles of each edge after mapping transformation;
[0079] Specifically, the modified detection head adds angle detection to the original detection head that conventionally detects coordinates and categories.
[0080] That is, in addition to the coordinate prediction branch and category prediction branch of conventional target detection, the present invention adds an angle prediction branch to obtain the angle of each edge. The angle prediction branch adopts the same structure as the coordinate prediction branch, and the final output is N*1*4, where N represents the number of targets and 4 represents the angles of the four edges.
[0081] S5. Calculate the feature similarity loss value according to the original feature vector and the feature vector after mapping transformation; calculate the original coordinate loss value, the original category loss value, and the original angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the original color image, and the original predicted coordinates, categories, and the angle of each edge; calculate the mapping coordinate loss value, the mapping category loss value, and the mapping angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the color image after mapping transformation, and the predicted coordinates, categories, and the angle of each edge after mapping transformation; sum the feature similarity loss value, all coordinate loss values, all category loss values, and all angle loss values to obtain the iterative total loss value; perform back propagation update on the original ship detection model according to the iterative total loss value;
[0082] Specifically, the feature similarity loss value is calculated according to the following formula:
[0083] ;
[0084] in, is the original eigenvector, is the feature vector after mapping transformation, is the feature similarity loss value.
[0085] The original coordinate loss value and the mapped coordinate loss value are calculated according to the following formula:
[0086] ;
[0087] Among them, when When is the original coordinate loss value, is the number of pixels in the target area manually calibrated in the original color image, is the number of pixels in the target area predicted by the original color image. is the number of pixels in the overlapped part between the manually calibrated target area of the original color image and the predicted target area; When is the mapping coordinate loss value, is the number of pixels in the target calibration box of the mapped color image, is the number of pixels in the target area of the mapped color image prediction reasoning, The number of pixels of the overlapping part between the color map target calibration box area after mapping transformation and the predicted inference target area;
[0088] The original angle loss value and the mapped angle loss value are calculated according to the following formula:
[0089] ;
[0090] Among them, when When is the original angle loss value, is the angle of the i-th edge marked by the original color map, is the angle of the i-th edge predicted by the original color image, is the preset hyperparameter; when When is the mapping angle loss value, is the angle of the i-th edge marked by the color map after the mapping transformation, The angle of the i-th edge of the color map prediction inference after mapping transformation, are the preset hyperparameters.
[0091] The original category loss value and the mapped category loss value are both calculated based on the existing cross entropy loss.
[0092] The feature similarity loss value, the original coordinate loss value, the mapping coordinate loss value, the original category loss value, the mapping category loss value, the original angle loss value, and the mapping angle loss value are summed to obtain an iterative total loss value; and the original ship detection model is back-propagated and updated according to the iterative total loss value.
[0093] S6, repeat S3 to S5, complete the training of the calibration training set and perform multiple rounds of training until the iterative total loss value fluctuates within a preset range, stop the training, and obtain the target ship detection model;
[0094] Specifically, after the calibration training set is trained and multiple rounds of training are performed, the training is stopped until the total iterative loss value fluctuates within a preset range (±0.1%), and the original ship detection model obtained by the last update is used as the target ship detection model.
[0095] S7. Input the image of the ship to be detected into the target ship detection model for detection to obtain the position and category of the ship.
[0096] Figure 2 FIG. 1 is a schematic diagram of a ship detection system for simulating different angle changes provided by an embodiment of the present invention. Figure 2 As shown, the system includes:
[0097] An acquisition unit 201 is used to acquire an original training set, wherein the original training set includes multiple ship images of the same ship at different angles, heights and distances;
[0098] The calibration sheet, 202, is used to select each ship in the original training set through a target frame, and calibrate the coordinates of each vertex and the angle of each edge to obtain a calibration training set;
[0099] The mapping transformation unit 203 is used to randomly extract a picture from the calibration training set as the original color picture; perform binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain a target calibration frame of the mapped color picture; calculate the angle of each side of the target calibration frame of the mapped color picture;
[0100] The prediction unit 204 is used to input the original color map and the color map after mapping transformation into the backbone network of the original ship detection model to obtain the original feature map and the feature map after mapping transformation respectively; perform feature serialization on the original feature map and the feature map after mapping transformation respectively to obtain the original feature vector and the feature vector after mapping transformation; input the original feature vector and the feature vector after mapping transformation into the modified detection head of the original ship detection model for prediction to obtain the original prediction coordinates, categories and angles of each edge, and the prediction coordinates, categories and angles of each edge after mapping transformation;
[0101] The loss calculation unit 205 is used to calculate the feature similarity loss value according to the original feature vector and the feature vector after mapping transformation; calculate the original coordinate loss value, the original category loss value, and the original angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the original color image, and the original predicted coordinates, categories, and the angle of each edge; calculate the mapping coordinate loss value, the mapping category loss value, and the mapping angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the color image after mapping transformation, and the predicted coordinates, categories, and the angle of each edge after mapping transformation; sum the feature similarity loss value, all the coordinate loss values, all the category loss values, and all the angle loss values to obtain the iterative total loss value; and perform back-propagation update on the original ship detection model according to the iterative total loss value;
[0102] The repeated training unit 206 is used to repeat the mapping transformation unit 203, the prediction unit 204 and the loss calculation unit 205 to complete the training of the calibration training set and perform multiple rounds of training until the iterative total loss value fluctuates within a preset range, then stop the training and obtain the target ship detection model;
[0103] The detection unit 207 is used to input the image of the ship to be detected into the target ship detection model for detection to obtain the position and category of the ship.
[0104] Specifically, the output end of the acquisition unit 201 is connected to the input end of the calibration unit 202, the output end of the calibration unit 202 is connected to the input end of the mapping transformation unit 203, the output end of the mapping transformation unit 203 is connected to the input end of the prediction unit 204, the output end of the prediction unit 204 is connected to the input end of the loss calculation unit 205, the output end of the loss calculation unit 205 is connected to the input end of the repeated training unit 206, and the output end of the repeated training unit 206 is connected to the input end of the detection unit 207.
[0105] It can be understood that the above system corresponds to the method of the present invention, and the details of the system processing method will not be repeated here.
[0106] Beneficial effects of the present invention:
[0107] The present invention provides a ship detection method and system for simulating different angle transformations, wherein the method uses three factors of angle, height and distance to guide and supervise prior knowledge to obtain a picture transformation that is more in line with the actual scene; uses standard key point information and binarization processing to realize the target coordinates of online calibration vertex mapping transformation; modifies the model structure, adds angle loss branches and manual calibration target serialization, so that when the model is trained, in addition to conventional coordinates and category supervision, four edge angle supervision and similarity supervision after affine transformation of different vertices are added; modifies the coordinate loss function, because the prediction box used by the method of the present invention is not a rectangular box, the conventional coordinate loss function cannot meet the coordinate supervision requirements, therefore, the coordinate loss function is calculated by the pixel value overlapping area. The method of the present invention can accurately detect ships when using drones to shoot ships.
[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A ship detection method simulating different angle transformations, characterized in that: include: S1. Obtain an original training set, wherein the original training set includes multiple ship images of the same ship at different angles, heights, and distances; S2, select each ship in the original training set through a target box, and calibrate the coordinates of each vertex and the angle of each edge to obtain a calibrated training set; S3, randomly extracting a picture from the calibration training set as the original color picture; performing binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain a target calibration frame of the mapped color picture; Calculate the angle of each side of the target calibration box of the mapped color image; S4, inputting the original color image and the color image after mapping transformation into the backbone network of the original ship detection model, respectively obtaining the original feature map and the feature map after mapping transformation; performing feature serialization on the original feature map and the feature map after mapping transformation, respectively, to obtain the original feature vector and the feature vector after mapping transformation; inputting the original feature vector and the feature vector after mapping transformation into the modified detection head of the original ship detection model for prediction, to obtain the original prediction coordinates, categories and angles of each edge, and the prediction coordinates, categories and angles of each edge after mapping transformation; S5. Calculate the feature similarity loss value according to the original feature vector and the feature vector after mapping transformation; calculate the original coordinate loss value, the original category loss value, and the original angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the original color image, and the original predicted coordinates, categories, and the angle of each edge; calculate the mapping coordinate loss value, the mapping category loss value, and the mapping angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the color image after mapping transformation, and the predicted coordinates, categories, and the angle of each edge after mapping transformation; sum the feature similarity loss value, all coordinate loss values, all category loss values, and all angle loss values to obtain the iterative total loss value; perform back propagation update on the original ship detection model according to the iterative total loss value; S6, repeat S3 to S5, complete the training of the calibration training set and perform multiple rounds of training until the iterative total loss value fluctuates within a preset range, stop the training, and obtain the target ship detection model; S7, inputting the image of the ship to be detected into the target ship detection model for detection, and obtaining the position and category of the ship; The binarization, pixel assignment and mapping transformation processing are performed on the original color image to obtain a target calibration frame of the mapped color image, which includes: Creating a binary image with the same scale as the original color image; Assigning 0 to the background of the binary image, and assigning values different from 0 to the pixels at the four corners of the ship in the binary image; Multiplying the original color image and the assigned binary image by the same vertex mapping change matrix to obtain a color image after mapping transformation and a binary image after mapping transformation, respectively; Find four pixel values different from 0 in the binary image after the mapping transformation, and connect them in sequence to form a target calibration frame; use the target calibration frame of the binary image after the mapping transformation as the target calibration frame of the color image after the mapping transformation; The same vertex mapping change matrix multiplied by the original color image and the assigned binary image is randomly selected from the following: Calculate multiple vertex mapping transformation matrices corresponding to each other from the original ship image of the same ship to multiple ship images at different angles, heights and distances.
2. The method according to claim 1, characterized in that The feature similarity loss value is calculated according to the following formula: in, is the original eigenvector, is the feature vector after mapping transformation, is the feature similarity loss value.
3. The method according to claim 1, characterized in that The original coordinate loss value and the mapped coordinate loss value are calculated according to the following formula: Among them, when When is the original coordinate loss value, is the number of pixels in the target area manually calibrated in the original color image, is the number of pixels in the target area predicted by the original color image. is the number of pixels in the overlapped part between the manually calibrated target area of the original color image and the predicted target area; When is the mapping coordinate loss value, is the number of pixels in the target calibration box of the mapped color image, is the number of pixels in the target area of the color map prediction inference after mapping transformation, The number of pixels of the overlapping part between the color map target calibration box area after mapping transformation and the predicted inference target area; The original angle loss value and the mapped angle loss value are calculated according to the following formula: Among them, when When is the original angle loss value, is the angle of the i-th edge marked by the original color map, is the angle of the i-th edge predicted by the original color image, is the preset hyperparameter; when When is the mapping angle loss value, is the angle of the i-th edge marked by the color map after the mapping transformation, The angle of the i-th edge of the color map prediction inference after mapping transformation, are the preset hyperparameters.
4. The method according to claim 1, characterized in that: The modified detection head adds angle detection to the original detection head that conventionally detects coordinates and categories.
5. The method according to claim 1, characterized in that The angle of each side is calculated according to the following formula: Among them, k is the slope of the current edge, a is the angle of the current edge, (x1, y1), (x2, y2) are any two points on the current edge.
6. A ship detection system simulating different angle changes, characterized in that: include: An acquisition unit, used to acquire an original training set, wherein the original training set includes multiple ship images of the same ship at different angles, heights and distances; A calibration unit, used for selecting each ship in the original training set through a target frame, and calibrating the coordinates of each vertex and the angle of each edge to obtain a calibrated training set; A mapping transformation unit is used to randomly extract a picture from the calibration training set as an original color picture; perform binarization processing, pixel assignment processing and mapping transformation processing on the original color picture to obtain a target calibration frame of the mapped color picture; Calculate the angle of each side of the target calibration box of the mapped color image; A prediction unit is used to input the original color map and the color map after mapping transformation into the backbone network of the original ship detection model to obtain the original feature map and the feature map after mapping transformation respectively; perform feature serialization on the original feature map and the feature map after mapping transformation respectively to obtain the original feature vector and the feature vector after mapping transformation; input the original feature vector and the feature vector after mapping transformation into the modified detection head of the original ship detection model for prediction to obtain the original prediction coordinates, categories and angles of each edge, and the prediction coordinates, categories and angles of each edge after mapping transformation; The loss calculation unit is used to calculate the feature similarity loss value according to the original feature vector and the feature vector after mapping transformation; calculate the original coordinate loss value, the original category loss value, and the original angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the original color image, and the original predicted coordinates, categories, and the angle of each edge; calculate the mapping coordinate loss value, the mapping category loss value, and the mapping angle loss value according to the target calibration coordinates, categories, and the angle of each edge of the color image after mapping transformation, and the predicted coordinates, categories, and the angle of each edge after mapping transformation; sum the feature similarity loss value, all coordinate loss values, all category loss values, and all angle loss values to obtain the iterative total loss value; and perform back-propagation update on the original ship detection model according to the iterative total loss value; A repeated training unit is used to repeatedly map the transformation unit, predict the unit and calculate the loss unit, complete the training of the calibration training set and perform multiple rounds of training until the total loss value of the iteration fluctuates within a preset range, then stop the training and obtain a target ship detection model; A detection unit, used to input the image of the ship to be detected into the target ship detection model for detection, and obtain the position and category of the ship; The binarization, pixel assignment and mapping transformation processing are performed on the original color image to obtain a target calibration frame of the mapped color image, which includes: Creating a binary image with the same scale as the original color image; Assigning 0 to the background of the binary image, and assigning values different from 0 to the pixels at the four corners of the ship in the binary image; Multiplying the original color image and the assigned binary image by the same vertex mapping change matrix to obtain a color image after mapping transformation and a binary image after mapping transformation, respectively; Find four pixel values different from 0 in the binary image after the mapping transformation, and connect them in sequence to form a target calibration frame; use the target calibration frame of the binary image after the mapping transformation as the target calibration frame of the color image after the mapping transformation; The same vertex mapping change matrix multiplied by the original color image and the assigned binary image is randomly selected from the following: Calculate multiple vertex mapping transformation matrices corresponding to each other from the original ship image of the same ship to multiple ship images at different angles, heights and distances.
