Ship water gauge reading method in complex environment
By combining UAV image processing and deep learning, this method identifies and corrects waterline characters, segments ship images, and calculates the average waterline height. This solves the problems of error and generalization in ship waterline readings under complex environments, and achieves high-precision waterline extraction and draft calculation.
Patent Information
- Application Number
- CN202211564549.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2042-12-07
AI Technical Summary
Existing ship draft identification methods suffer from large calculation errors and poor generalization in complex environments, making it difficult to adapt to factors such as water surface waves and obstacles, resulting in inaccurate or failed waterline extraction.
Image data was acquired using a drone equipped with a high-definition camera. The YOLOv5n neural network was used to identify water gauge characters and the tilt was corrected by linear regression. The ship images were segmented by a U2-NetP neural network with a CA attention mechanism. The average waterline height was calculated using the Newton-Leibniz formula, and perspective transformation was introduced to correct the water gauge characters.
It improves the accuracy and robustness of waterline extraction, overcomes the segmentation problem in complex environments, and the waterline extraction calculation method can maintain high accuracy even when obstacles are present. It is adaptable to a variety of complex environments and reduces calculation errors.
Smart Images

Figure CN116434230B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a ship water gauge reading method in a complex environment and belongs to the technical field of ship water gauge reading methods. BACKGROUND
[0002] Ship water gauge reading is an important link in the water gauge weight measurement method, and the water gauge weight measurement is widely used in ship cargo load measurement and import and export commodity weight identification. The depth of the ship draft is measured twice before and after ship loading and unloading, so that the weight of the cargo can be calculated. Since the method has the advantages of time saving, labor saving and cost saving, it is adopted by the international trade and transportation departments. At present, the ship draft is mainly determined by manual observation, which usually requires an observer to drive a traffic boat to observe the ship. However, manual observation is easily affected by complex environments such as water waves, water obstacles, ship water lines, tilting and rusted water gauge characters. These environmental factors not only affect the accuracy and reliability of manual observation, but also pose a certain threat to the personal safety of the observer.
[0003] Invention patents with application numbers CN202010222648.9 and CN201810310518.3 disclose a ship water gauge recognition method. The two methods use the color difference between the ship body and the water surface, use the color gamut segmentation method to separate the ship body and the water surface in the original image, and obtain the waterline position. This method is difficult to adapt to segmentation tasks in various complex environments, such as water waves and water obstacles, resulting in inaccurate or failed waterline extraction, which in turn negatively affects the subsequent calculation of the ship draft, and has poor generalization. Invention patent with application number CN202011168530.9 discloses a ship water gauge recognition method based on deep learning technology. The method regards the waterline as a kind of target, uses a target detection network to detect multiple waterline recognition boxes, and takes the average value of the center point longitudinal coordinates of the screened recognition boxes as the average height of the waterline. This method cannot guarantee that the center point of the waterline recognition box is on the waterline, and the average height will have an error with the actual average height. At the same time, in the complex situation of the ship's side with water lines, it is easy to detect waterline recognition boxes at the position of the water lines, which in turn causes a large error in the subsequent calculation of the ship draft.
[0004] Therefore, it is necessary to develop a new ship water gauge reading method to solve the above problems existing in the existing ship water gauge recognition method. SUMMARY
[0005] The purpose of the present application is to provide a ship water gauge reading method in a complex environment to solve the problems of large calculation error and poor generalization existing in the existing ship water gauge reading method.
[0006] The technical scheme of the present application is:
[0007] The ship water gauge reading method in the complex environment, characterized in that: the ship water gauge reading method, comprising the following steps:
[0008] 1、Image preprocessing module;
[0009] First, the ship image data is obtained by the unmanned aerial vehicle carrying the high-definition camera, and then input into the Yolov5n neural network, the water gauge characters of the ship side are located and identified, and the water gauge characters are screened out through the water gauge character features; second, the linear model of the water gauge character is obtained by using the linear regression method; finally, the ship image is perspective transformed to correct the inclined water gauge characters.
[0010] 2、Waterline extraction calculation module;
[0011] U 2 -NetP neural network is used to segment the background area, ship area and water area of the ship image to obtain a ship segmentation image; then a waterline extraction algorithm is used to extract the waterline of the ship segmentation image; finally, the Newton-Leibnitz formula is used to calculate the average height of the waterline.
[0012] 3、Water gauge calculation module
[0013] The average height of the waterline and the accurate position information of the water gauge characters are required for the ship draft calculation. After the above steps, the integer character of the water gauge, the decimal character of the water gauge and the average height of the waterline can be obtained. In addition, the actual height of each pixel represented by the water gauge character , the actual lowest scale of the current visible water gauge and the corresponding maximum pixel height .
[0014] First, according to the height information of the water gauge decimal character , the actual height of the character is 10 cm, in order to ensure the accuracy of , the average scale_norm of all decimal water gauge characters is taken; then the maximum pixel height of the integer character and the decimal character of the water gauge is screened out, the highest pixel height visible in the current image is calculated and converted into the actual water gauge height . Finally, the ship draft scale is calculated according to the ship water gauge reading standard. The ship water gauge reading standard is as follows:
[0015] (1) The accuracy of water gauge reading is accurate to centimeter;
[0016] (2) The lower edge of the waterline reaching a certain number indicates that the actual reading at this point is the value represented by the number;
[0017] (3) the waterline just submerges the number, indicating that the actual reading at the place is the value represented by the number plus the corresponding character height;
[0018] (4) when the waterline is located at the half of the character height, indicating that the actual draft at the place is the value represented by the number plus the half of the corresponding character height;
[0019] (5) when the water surface is fluctuating, the changes of the waterline should be continuously observed, and the average value of all waterline heights is taken as the waterline position, and then the water gauge scale of the ship is calculated.
[0020] The advantages of the present application are:
[0021] The reading method of the ship water gauge in the complex environment fuses the U 2 -NetP network of the CA attention mechanism, ensures the lightweight reasoning, pays more attention to the spatial position information of the category edge, and compared with the original network, the mIou index can be improved by about 5 percentage points, overcomes the segmentation difficulties in various complex environments, improves the accuracy and robustness of the next waterline extraction, and solves the inaccurate and failed waterline extraction when there are obstacles or other interferences on the water surface, which is a problem that other existing segmentation technologies cannot solve, and is particularly suitable for the use demand of ship water gauge reading. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of the present application;
[0023] Figure 2 is a water gauge character specification diagram;
[0024] Figure 3 is a Yolov5n model training loss curve;
[0025] Figure 4 is an mAP curve of the Yolov5n model training;
[0026] Figure 5 is a water gauge character screening range;
[0027] Figure 6 is a perspective transformation operation;
[0028] ATTACHMENT Figure 7 is some U-Net segmentation result sample;
[0029] Figure 8 is a CA-Block module and RSU-CA-L module (L=5);
[0030] Figure 9 is an improved U 2 -NetP network architecture;
[0031] Figure 10 Examples for ship waterline extraction;
[0032] Figure 11 Examples for calculating the average height of the ship waterline;
[0033] Figure 12 Examples for ship draft reading;
[0034] Figure 13 Complete examples for ship draft reading. DETAILED DESCRIPTION
[0035] The ship draft reading method in the complex environment, the ship draft reading method, comprising the following steps (see the attached drawings of the specification Figure 1 ):
[0036] 1. Image preprocessing module
[0037] First, the ship image data is obtained by the unmanned aerial vehicle carrying a high-definition camera, and then input into the Yolov5n (You only look once version 5 nano) neural network, the water gauge characters of the ship side are located and identified, and the water gauge characters are screened out through the water gauge character features; second, the linear model of the water gauge characters is obtained by using the linear regression method; finally, the ship image is perspective transformed to correct the inclined water gauge characters.
[0038] (1) Water gauge character detection;
[0039] The water gauge characters on the ship side are composed of the characters "0-9" and "M", the line width is 2CM, and the water gauge font height and the vertical distance between two characters are 10CM (see the attached drawings of the specification Figure 2 ); For the positioning and identification task of the water gauge characters, it should be ensured that the water gauge characters on the ship side are completely detected without missing any one, and the detection frame should be as close to the water gauge characters as possible, so as to provide prior conditions for the subsequent water gauge reading; under the premise of ensuring the network recognition accuracy, the network should also be lightened and the inference speed should be ensured, which provides support for the subsequent research on the deployment of edge devices; therefore, the present application proposes to use the Yolov5n lightweight neural network to identify and locate the water gauge characters;
[0040] Yolov5n is a lightweight version of the Yolov5 neural network, and Yolov5n makes the following improvements: the depthmultiple parameter is reduced to 0.25, thus reducing the number of parameters by 75%, from 7.5M to 1.9M, using Conv (k=6, s=2, p=2) instead of Focus layer for easy model export; using SPPF (Cascaded Spatial Pyramid Pooling) instead of SPP layer (Spatial Pyramid Pooling); reducing P3 (the third feature map of the backbone) main layer C3 (Cross Stage Partial Bottleneck with 3 convolutions); placing SPPF behind the main stem; reintroducing shortcuts in the last C3 main layer, which improves the parameter amount and inference speed at the cost of a certain mAP, which is very suitable for detecting simple tasks and deploying on devices with weak computing power;
[0041] The water gauge character detection dataset is obtained by using the Labelme labeling tool to label the water gauge characters on the ship image; the water gauge character detection dataset is divided into a training set, a validation set and a test set according to a ratio of 7:2:1, and is input into the Yolov5n network to obtain a training result (see the attached drawings of the specification Figure 3 、 4 ), and the network training parameters are shown in Table 1.
[0042] Table 1 Yolov5n network training parameters
[0043] (2). Water gauge character screening
[0044] For the "0-9" and "M" water gauge characters detected by the Yolov5n neural network, the characters are divided into integer character and decimeter character; in the image coordinate system, the M character and the integer character to the left are at the same height, according to the center point of the M character and the regression box position information, the range of the integer region is determined, the integer character to the left of the M character is screened out, and the remaining is the decimeter character (see the attached drawings of the specification Figure 5 ); the screening range can be represented by formula (1).
[0045]
[0046] where x, y represent the horizontal and vertical coordinates of the center point of the integer character, represents the pixel height of the current M character, represents the horizontal coordinate of the center point of the current M character;
[0047] The water gauge characters can be classified into integer bit characters and decimeter bit characters by formula (1), so as to provide prior knowledge for the next character correction and water gauge scale calculation.
[0048] The description is accompanied by Figure 5 The integer bit and decimeter bit characters are equal in height on the left side, and the integer bit is twice the height of the decimeter bit character on the right side.
[0049] (3). Perspective transformation
[0050] When obtaining the ship image data, the water gauge characters in the ship image may be inclined due to the shooting angle or environmental conditions; the present application proposes to use perspective transformation operation to correct the inclined water gauge characters to a vertical state; the specific process of perspective transformation is as follows:
[0051] 1) For the decimeter bit water gauge characters screened out in step (2), the center point coordinates of each character are taken as the independent variables of linear regression, and a linear function of the water gauge character is fitted; the linear regression model is as follows:
[0052]
[0053] 2) The linear function obtained in step 1) is translated left and right until it intersects with the vertices of the inclined ship image to form a parallelogram, and the four vertices of the parallelogram are taken as the original target points of perspective transformation.
[0054] 3) Perspective transformation is a process of projecting an image to a new viewing plane (Viewing Plane) through a projection matrix, also known as projection mapping. The process includes: converting the image in two-dimensional space to three-dimensional space, and then projecting the image from three-dimensional space to a new two-dimensional plane.
[0055] The general transformation equation is shown in formula (3):
[0056]
[0057] Wherein is the coordinate point in the original image, written in the form of an augmented vector is the coordinate point in the three-dimensional space after transformation, is the transformation matrix, wherein represents a linear transformation, mainly responsible for the rotation operation of the image, is responsible for the translation operation of the image, represents the perspective transformation, the parameter is 1;
[0058] Divide the target point by , and the point converted to the two-dimensional image is The final coordinate point formula of its projection on the new plane is as follows:
[0059]
[0060] There are 8 parameters in total, and 4 pairs and The coordinate points before and after the transformation can be solved to obtain the equation parameters. The present application gives a perspective transformation example (see the attached Figure 6 ).
[0061] Description Figure 6 (a) is the original graph; (b) is the fitting water level character center point; (c) is the intersection point of the linear function and the image vertex; (d) is the perspective transformation result.
[0062] 2. Waterline extraction calculation module
[0063] First, the U 2 -NetP neural network is used to segment the background area, ship area and water area of the ship image to obtain a ship segmentation image; then a waterline extraction algorithm is used to extract the waterline of the ship segmentation image; finally, the Newton-Leibnitz formula is used to calculate the average height of the pixels of the waterline.
[0064] (1). Segment the ship image
[0065] First, the EISeg labeling tool is used to mark the ship area and water area, and the remaining area is marked as background to obtain a ship image segmentation dataset; then, according to the ratio of 7:2:1, the training set, the verification set and the test set are divided, and input into the semantic segmentation neural network for training to obtain a ship segmentation image, which provides prior knowledge for the next step of extracting the waterline. The more accurate the ship image segmentation is, especially the area near the waterline, the greater the help for the next step of waterline extraction.
[0066] In the case of calm water surface, the segmentation effect of the classic U-structure network neural network has certain reference significance, but in the complex environment of large waves on the water surface, containing obstacles and ship residual water marks, the segmentation effect is not ideal, and the contour segmentation between the ship and the water area is not accurate (see the attached Figure 7 Therefore, in order to make the network pay more attention to the contour edge information of the target, and ensure the lightweight of the network, the present application uses a U 2 -NetP lightweight semantic segmentation network, and a CA attention mechanism is designed in the U 2 -NetP.
[0067] CA attention mechanism, short for Coordinate Attention, is a new mobile network attention mechanism that embeds the position information of an image into the channel attention mechanism. The CA attention mechanism decomposes the channel attention into two 1-dimensional feature encoding processes, which respectively aggregate the features along two spatial directions. In this way, long-range dependencies can be captured along one spatial direction, while precise position information can be preserved along the other spatial direction. Then the generated feature maps are respectively encoded into a pair of direction-aware and position-sensitive Attention Maps, which can be complementarily applied to the input feature maps to enhance the representation of the objects of attention. A CA block can be regarded as a computational unit designed to enhance the representational capacity of the features in the network. It can take any intermediate feature tensor as input and output an Attention Map with the same size as the tensor while having enhanced representation (see the accompanying drawings Figure 8 ).
[0068] Improved U 2 The specific steps of the NetP network are as follows: in the U 2 -NetP neural network main architecture and after the up-sampling in the RSU-CA-L module (Residual-CA-U-blocks-Layer), a CA-Block is added, and then a Concate operation is performed (see the accompanying drawings Figure 8 、 Figure 9 ). Similarly, the CA attention mechanism is also designed to be integrated into the U-Net neural network. The results of the U-Net, U-Net+CA, U 2 -NetP, and U 2 -NetP+CA semantic segmentation neural networks are compared under the same experimental parameter conditions.
[0069] Finally, the experimental results are subjected to stratified 10-fold cross-validation. The training set and the validation set of the ship image segmentation dataset are divided into 10 folds. Each fold is used as the validation set in turn, and the other folds are used as the training set. A total of 10 training times are performed to obtain the average mIoU index on the test set. The effect of the network is evaluated from four aspects of Parameters, Flops (Floating point operations), Model size, and mIoU. Parameters is the parameter quantity, which reflects the spatial complexity of the model. Flops is the floating point operation number, which reflects the computational amount of the model and is used to measure the inference speed of the model. Model size reflects the storage space occupied by the entire model and whether it is easy to deploy. mIoU is the average value of the intersection over union (the ratio of the intersection to the union) of the predicted region and the actual region of each class, as shown in formula (5). It reflects the coincidence degree between the predicted results and the true results of all classes and is used to measure the performance effect of the model inference.
[0070]
[0071] Where TP represents the number of positive classes predicted as positive; TN represents the number of negative classes predicted as negative; FP represents the number of negative classes predicted as positive; and FN represents the number of positive classes predicted as negative. The training parameters and comparison results of the semantic segmentation network are shown in Tables 2 and 3.
[0072] Table 2 Training parameters of semantic segmentation network
[0073]
[0074] Table 3 U-Net, U 2 -NetP, U-Net+CA, U 2 -NetP+CA segmentation comparison
[0075]
[0076] As can be seen from Table 3, compared to the original U-Net and U... 2 -NetP network, U-Net and U after incorporating CA attention mechanism 2 -NetP networks show improvements in mIoU, among which U 2 The NetP network showed the greatest improvement, nearly 5 percentage points higher than the initial network. Furthermore, after 10-fold cross-validation, it is clear that the improved U... 2 The NetP network exhibits better robustness, demonstrating the effectiveness of the improvement. Furthermore, U... 2 -NetP has a stronger advantage over U-Net in terms of parameters, model size, and FLOPS metrics;
[0077] (2). Waterline extraction algorithm
[0078] The specific steps of the waterline extraction algorithm are as follows:
[0079] 1) For the ship segmentation image obtained in step (1), if there are no obstacles, the complete waterline information can be obtained by using Canny edge detection once;
[0080] 2) For complex situations with obstacles (see the attached instruction manual) Figure 7 Canny edge detection is performed on the ship segmentation image obtained in step (1) and its corresponding grayscale image to obtain an image (d) containing waterline and obstacle contours, and an image (e) containing only obstacle contours; (see the appendix of the instruction manual) Figure 10 (d) and (e)
[0081] Instruction manual attachedFigure 7 (a), (b) are normal segmentation effects; (c), (d) are segmentation effects in the presence of water traces and with obstacles;
[0082] 3) Subtracting the two waterline images (d) and (e) obtained in step 2) can obtain the actual waterline without obstacles (see the attached Figure 10 ); Therefore, the effect of extracting the waterline depends on the segmentation effect of the ship and the water area; the better the effect of the segmentation network, the more refined the extracted waterline;
[0083] the attached Figure 10 (a) is the original ship water gauge; (b) is the semantic segmentation result image; (c) is the gray image of (b); (d) is the waterline image containing the waterline and obstacle contour; (e) is the waterline image of the obstacle contour; (f) is the actual waterline result after subtracting (d) and (e).
[0084] (3) Calculate the average height of the waterline
[0085] In the process of extracting the waterline, there are inevitably complex situations caused by environmental factors that cause the waterline to fluctuate greatly, resulting in the actual waterline being curved; Therefore, the contact position of the water gauge character and the water surface cannot be simply used as a reference; Therefore, after obtaining the waterline of the image, the present application comprehensively considers the overall change of the waterline in the spatial dimension and uses the Newton-Leibnitz formula to calculate the average height of the waterline. See formula (6):
[0086]
[0087] The principle is to divide the curve into small intervals, when the number of intervals tends to infinity, The average height of all points on the continuous curve can be obtained;
[0088] The present application applies this formula to the image field, and the smallest unit of the image is a pixel, so formula (6) is converted into the form of formula (7):
[0089]
[0090] Where n is the number of columns of waterline pixels after scanning the image column by column, is the height of each pixel point of the waterline in the image coordinate system. Usually, multiple adjacent pixel points on a column represent the bending trend of the waterline, and the average height of the multiple adjacent pixel points is taken as the height of the current column, and then the average height of the waterline is calculated (see the attached Figure 11 ).
[0091] Description Figure 11The left is the original image, and the right is the marking of the average height of waterline on the segmented image.
[0092] 3. Water gauge calculation module
[0093] The average height of waterline and the accurate position information of water gauge characters are needed for calculating the draft of a ship. After the above steps, we can get the integer character, the decimeter character and the average height of waterline of the water gauge. In addition, the actual height of each pixel of the water gauge character needs to be calculated dynamically , the actual lowest scale of the current visible water gauge and the corresponding maximum pixel height (see the attached drawings in the description Figure 12 ).
[0094] Firstly, the actual height of the decimeter character of the water gauge is calculated according to the height information of the decimeter character of the water gauge , and the actual height of the character is 10 cm. In order to ensure the accuracy of , the average scale_norm of all decimeter characters of the water gauge is taken; then the maximum pixel height of the integer character and the decimeter character of the water gauge is selected to calculate the highest pixel height of the current image that can be seen, and the actual water gauge height is converted. Finally, the draft of the ship is calculated according to the standard of reading the water gauge of the ship. The standard of reading the water gauge of the ship is as follows:
[0095] (1) The accuracy of the reading of the water gauge is accurate to centimeter;
[0096] (2) When the waterline reaches the lower edge of a certain number, it indicates that the actual reading at this place is the value represented by the number;
[0097] (3) When the waterline just submerges the number, it indicates that the actual reading at this place is the value represented by the number plus the corresponding character height;
[0098] (4) When the waterline is located at half of the character height, it indicates that the actual draft at this place is the value represented by the number plus half of the corresponding character height;
[0099] (5) When the water surface has fluctuations, the average value of all waterline heights should be taken as the position of the waterline to calculate the scale of the water gauge of the ship;
[0100] According to the standard of reading the water gauge, the average height of waterline is taken as the reference line for calculating the water gauge; the values of and are compared to obtain the actual scale of the water gauge , and the calculation formula is shown in formula (8).
[0101]
[0102] wherein The unit is meter. The present application gives a complete ship water gauge reading schematic diagram (see the attached Figure 13 ).
[0103] The attached Figure 13 (a) is the original drawing; (b) is the semantic segmentation image; (c) is the character detection result; (d) is the waterline extraction result; (e) is the average height marking of the waterline; (f) is the reading result display.
[0104] The present application compares the results of artificial reading under different complex situations, wherein the artificial results are the average values obtained by observing the key video frames for 30 seconds by multiple professionals, and the longer the video frame duration, the more accurate the result; and the reading results of the present application are also the average values of all frame reading results, and the error (artificial reading The present application reading) statistics table of part of the test video is shown in Table 4.
[0105] Table 4 Reading error under different complex situations
[0106]
[0107] It has been verified that under various complex environments, the method of the present application can be accurate to within an average error, especially in complex environments such as large waves on the water surface and obstacles, and still achieve good performance, with strong robustness and generalization. The present application technology makes up for the deficiencies of the prior art technology, such as poor segmentation effect, inaccurate or failed waterline extraction, and poor generalization performance, and provides very important reference value for artificial observation, saves manpower and material resources, and is gradually applied in the field.
[0108] The present application proposes a water gauge reading method combining image processing and deep learning, involving a new lightweight semantic segmentation network architecture and a waterline extraction calculation method, and the network architecture is a U-Net network architecture fused with CA (Coordinate Attention) attention mechanism. 2-NetP (small two-level nested U-structure network) network, while ensuring its reasoning lightweight, it pays more attention to the spatial position information of the class edge, compared with the original network, its mIou index can be improved by about 5 percentage points, overcoming the segmentation problem in various complex environments, and improving the accuracy and robustness of the next waterline extraction; The waterline extraction calculation method solves the problem of inaccurate and failed waterline extraction when there are obstacles or other interference on the water surface based on the segmented image, which is a problem that other existing segmentation techniques cannot solve. At the same time, the average height of the waterline is calculated by introducing the Newton-Leibniz formula, which has more and more accurate point quantity than the method of application No. CN202011168530.9, and the result is closer to the actual average height. In addition, the perspective transformation method is used to correct the inclined water gauge characters, which adapts to the draft calculation under the condition of inclined water gauge characters and enhances the robustness of the whole method.
Claims
1. A method for ship draft reading in complex environment, characterized in that: The ship water gauge reading method comprises the following steps: 1、Image preprocessing module First, the ship image data is obtained by the unmanned aerial vehicle carrying a high-definition camera, and then input into the Yolov5n neural network to locate and identify the water gauge characters on the ship side, and the water gauge characters are screened out through the water gauge character features; secondly, a linear model of the water gauge characters is obtained by using a linear regression method; finally, perspective transformation is performed on the ship image to correct the inclined water gauge characters; 2、Waterline extraction calculation module; U 2 The background region, the ship region and the water region of the ship image are segmented by using the NetP neural network to obtain a ship segmentation image; then a waterline extraction algorithm is used to extract the waterline of the ship segmentation image; finally, the Newton-Leibnitz formula is used to calculate the average height of the pixels of the waterline. 3、Water gauge calculation module; The ship draft calculation needs the average height of the waterline and the accurate position information of the water gauge character; after the step 1 image preprocessing module and the step 2 waterline extraction calculation module, the integer bit character, the decimal bit character and the waterline height information of the water gauge are obtained; in addition, the actual height represented by each pixel of the water gauge character needs to be dynamically calculated , the actual lowest scale of the current visible water gauge and the corresponding maximum pixel height ; First, calculate the height information of the decimeter markings on the water gauge. The actual height of the characters is 10cm. To ensure... To ensure accuracy, the average scale_norm of all decimeter-level water gauge characters is taken; then, the maximum pixel height between the integer-level water gauge characters and the decimeter-level characters is selected, and the highest visible pixel height in the current image is calculated. And convert it into actual water gauge height Finally, following the ship draft reading standards, calculate the ship's draft. The ship draft reading standards are as follows: (1) The accuracy of water gauge reading is accurate to centimeter; (2) When the waterline reaches the lower edge of a certain number, it indicates that the actual reading at this position is the value represented by the number; (3) When the waterline just submerges the number, it indicates that the actual reading at this position is the value represented by the number plus the corresponding character height; (4) When the waterline is located at half of the character height, it indicates that the actual draft at this position is the value represented by the number plus half of the corresponding character height; (5) When the water surface has fluctuations, the average value of all waterline heights should be taken as the waterline position to calculate the water gauge scale of the ship; According to the water gauge reading standard, the average height of water line As the reference line for calculating the water gauge; comparison With The actual water gauge scale is obtained by comparing the size of the values The formula is shown in equation (8): ; wherein in meters.
2. The method for ship water gauge reading in complex environment according to claim 1, characterized in that: The image preprocessing module in step 1 comprises the following steps: (1) Water gauge character detection; The water gauge characters on the ship side are composed of numbers "0-9" and "M" characters, with a line width of 2 CM, a water gauge character height, and a vertical distance between two characters of 10 CM; for the positioning and identification task of the water gauge characters, it should be ensured that the water gauge characters on the ship side are completely detected without missing any one, and the detection frame should be as close to the water gauge characters as possible to provide prior conditions for the subsequent water gauge reading; the Yolov5n lightweight neural network is used for water gauge character identification and positioning; Yolov5n is a lightweight version of Yolov5 neural network, and Yolov5n has made the following improvements: the depthmultiple parameter is reduced to 0.25, thus reducing 75% of the parameters from 7.5M to 1.9M, using Conv(k=6, s=2, p=2) instead of Focus layer for easy model export; using SPPF instead of SPP layer; reducing P3 main layer C3; placing SPPF behind the main body; reintroducing shortcuts in the last C3 main layer at the cost of losing some mAP to improve parameter quantity and inference speed; The Conv parameter is the convolution function in the main layer C3; the k parameter is the bottleneck, representing the size of the convolution neck; the s parameter is the stage, representing the size of the stride; and the p parameter is the partial, representing the value of local padding; The water gauge character detection dataset is obtained by using the Labelme labeling tool to label the water gauge characters on the ship image; the water gauge character detection dataset is divided into training set, validation set and test set according to the ratio of 7:2:1, and input into the Yolov5n network for training to obtain the training result; The training parameters are as follows: the image input size is 640*640, the Epoch is 2000, the Batch Size is 16, the learning rate is 0.001, the loss function is BECLogits+BCEcls+GIOU loss, and the Optimizer is Momentum; (2) Water gauge character screening; For the "0-9" and "M" water gauge characters detected by the Yolov5n neural network, the characters are divided into integer character and decimeter character; In the image coordinate system, the M character and the integer character on the left are at the same height, according to the center point of the M character and the regression box position information, the integer region range is determined, the integer character on the left of the M character is screened out, and the remaining is the decimeter character; The screening range can be represented by formula (1): ; wherein x, y represent the horizontal and vertical coordinates of the center point of the integer bit character, represents the pixel height of the current M character, represents the horizontal coordinate of the center point of the current M character; Through formula (1), the water gauge characters can be classified into integer characters and decimeter characters, which provides prior knowledge for the next character correction and water gauge scale calculation; (3) Perspective transformation; When obtaining ship image data, due to the shooting angle or environmental conditions, the water gauge characters in the ship image will be inclined; It is proposed to use perspective transformation operation to correct the inclined water gauge characters to vertical state; The specific process of perspective transformation is as follows: 1) For the decimeter water gauge characters screened out in step (2), the center point coordinates of each character are taken as the independent variables of linear regression, and the linear function of the water gauge characters is fitted; The linear regression model is as follows: ; 2) The linear function obtained in step 1) is translated left and right until it intersects with the top point of the inclined ship image to form a parallelogram, and the four vertices of the parallelogram are taken as the original target points of the perspective transformation; 3) Perspective transformation is the process of projecting an image to a new view plane through a projection matrix, also known as projection mapping; The process includes: converting the image in two-dimensional space to three-dimensional space, and then projecting the image from three-dimensional space to a new two-dimensional plane; The general transformation equation is shown in formula (3): ; wherein is the coordinate point in the original graph, written in the form of an augmented vector is the coordinate point in the three-dimensional space after transformation, is the transformation matrix, wherein represents a linear transformation, mainly responsible for the rotation operation of the image, is responsible for the translation operation of the image, represents a perspective transformation, the parameter is 1; Divide the target point by to obtain the point converted to the two-dimensional image as The final coordinate point formula of the projection to the new plane is as follows: ; There are 8 parameters in the equation, and 4 pairs of With The coordinate points before and after the transformation, and the equation parameters can be solved.
3. The method of reading a ship's water gauge in a complex environment according to claim 1, wherein: The waterline extraction calculation module in step 2 includes the following steps: (1) Segmenting ship image; First, use the EISeg labeling tool to mark the ship area and water area, and mark the rest as background to get the ship image segmentation dataset; Then, according to the ratio of 7:2:1, divide it into training set, validation set and test set, and then input it into the semantic segmentation neural network for training to get the ship segmentation image; In order to make the network pay more attention to the contour edge information of the target, and ensure the lightweight of the network, U 2 -NetP lightweight semantic segmentation network, and in U 2 -NetP design integrates the CA attention mechanism; The CA attention mechanism, which stands for Coordinate Attention, is a new mobile network attention mechanism that embeds the position information of the image into the channel attention mechanism; The CA attention mechanism decomposes the channel attention into two 1-dimensional feature encoding processes, which aggregate features along two spatial directions respectively; Remote dependency is captured along one spatial direction while preserving precise location information along another spatial direction; then the generated feature maps are encoded into a pair of direction-aware and location-sensitive Attention Maps, which are applied to the input feature maps complementarily to enhance the representation of the attended objects; a CA block is regarded as a computational unit aiming to enhance the expressive power of features in the network; it takes any intermediate feature tensor as input and outputs an Attention Map with the same size as the tensor while having enhanced representation through transformation; Improvement U 2 The specific steps of the NetP network are as follows: in the U 2 CA-Block is added after up-sampling in the main architecture of the NetP neural network and the RSU-CA-L module, and then the Concate operation is performed; similarly, the CA attention mechanism is also designed in the U-Net neural network; and compared the results of U-Net, U-Net+CA, U-NetP, U-NetP+CA four semantic segmentation neural networks under the same experimental parameter conditions; the experimental parameter conditions are as follows: the image input size is 320x320, the iteration number is 5000 times, the Batch Size is 16, the learning rate is 0.001, the Scheduler is Cosine Annealing Decay, the loss function is Cross Entropy Loss, and the Optimizer is Momentum. 2 2 and compared the results of U-Net, U-Net+CA, U-NetP, U-NetP+CA four semantic segmentation neural networks under the same experimental parameter conditions; the experimental parameter conditions are as follows: the image input size is 320x320, the iteration number is 5000 times, the Batch Size is 16, the learning rate is 0.001, the Scheduler is Cosine Annealing Decay, the loss function is Cross Entropy Loss, and the Optimizer is Momentum. Finally, the experimental results were stratified 10-fold cross-validation, the training set and validation set of the ship image segmentation dataset were divided into 10 folds, each fold was used as the validation set in turn, and the other folds were used as the training set, a total of 10 training times were performed to obtain the average mIoU index on the test set; the effect of the network was evaluated from four aspects of Parameters, Flops, Model size and mIoU; Parameters is the parameter quantity, which reflects the spatial complexity of the model; Flops is the floating point operation number, which reflects the calculation amount of the model and is used to measure the inference speed of the model; Model size reflects the storage space occupied by the entire model and whether it is convenient for deployment; mIoU is the average value of the intersection over union of each class prediction region and actual region, see formula (5), which reflects the coincidence degree between the prediction results and the true results of all classes, and is used to measure the performance effect of the model inference; ; Where TP: the number of positive class predicted as positive class; TN: the number of negative class predicted as negative class; FP: the number of negative class predicted as positive class; FN: the number of positive class predicted as negative class; (2) Waterline extraction algorithm; The specific steps of the waterline extraction algorithm are as follows: 1) For the ship segmentation image obtained in step (1), if there is no obstacle, a Canny edge detection can be used to obtain complete waterline information; 2) For the complex case where there are obstacles, Canny edge detection is performed on the ship segmentation image obtained in step (1) and its corresponding gray image to obtain an image (d) containing the waterline and obstacle contour, and an image (e) containing only the obstacle contour; 3) Subtracting the two waterline images (d) and (e) obtained in step 2) can obtain the actual waterline without obstacles; therefore, the effect of extracting the waterline depends on the segmentation effect of the ship and the water area; the better the effect of the segmentation network, the more refined the extracted waterline; (3) Calculate the average height of the waterline; After obtaining the waterline of the image, the overall change of the waterline in the spatial dimension is integrated, and the average height of the waterline is calculated using the Newton-Leibniz formula; see formula (6): 、 The principle is to divide the curve into small intervals, when the number of intervals tends to infinity, That is, the height of the current interval curve, so that the average height of all points on the continuous curve is obtained; When this formula is applied in the image field, the smallest unit of the image is a pixel, so formula (6) is converted into the form of formula (7): ; where n is the number of columns of waterline pixels after scanning the image column by column, is the height of each pixel of the waterline in the image coordinate system; if multiple adjacent pixel points appear on a column, which represent the bending trend of the waterline, the average height of the multiple adjacent pixel points is taken as the height of the current column, and then the average height of the waterline is calculated.
Citation Information
Patent Citations
An Automatic Reading Method for Ship Draft Images Based on Deep Learning Algorithms
CN108549894B
Unmanned aerial vehicle intelligent ship water gauge identification method and device
CN111476120A
A method, device and storage medium for identifying ship draft marks.
CN112183470B
Ship water gauge image automatic number reading method based on deep learning algorithm
CN108549894A
Ship water gauge reading identification method based on deep learning
CN111652213A