An automatic measurement method for inland river vessel freeboard pixel height based on monocular image
Through instance segmentation and line detection technology based on monocular images, combined with clustering and consistency algorithms, high-precision automatic measurement of ship freeboard pixel height is achieved, which solves the problems of high equipment cost and insufficient detection accuracy in existing methods and provides accurate detection capabilities under blurred or missing signs.
Patent Information
- Application Number
- CN202311201918.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2043-09-18
AI Technical Summary
The existing methods for detecting ship freeboard in inland waterway navigation have the problems of high equipment cost, high maintenance cost, reliance on ship load marks and insufficient detection accuracy. In particular, accurate detection is difficult to achieve when the load marks are blurred or missing.
A monocular image-based method is used to extract the ship freeboard area, fit the deck line and waterline, and calculate the freeboard pixel height through the instance segmentation model, line segment detector (LSD), distance-based clustering algorithm K-means, and random sampling consensus algorithm RANSAC.
It achieves high-precision and robust pixel height detection of ship freeboard, overcoming the time-consuming and labor-intensive problems of traditional manual methods, and can still accurately detect even when the load marks are blurred or missing.
Smart Images

Figure CN117291967B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of digital image processing and monocular vision, relates to a ship safety navigation monitoring technology, and realizes the automatic measurement of the freeboard pixel height of an inland ship based on a monocular image. Background Art
[0002] The focus of inland waterway regulation is monitoring the standard loading depth for waterway maintenance (known as ship draft). Currently, the main methods for measuring ship draft in my country are divided into manual and automatic detection. Manual detection primarily relies on observation, whereby personnel board the vessel to read the ship's waterline scale. The actual draft is calculated using a formula based on the readings of six waterline scales: bow, midship, and stern. Manual detection has significant drawbacks, primarily due to large draft reading errors caused by fluctuating water surfaces, and some ships experience issues such as blurred or corroded waterlines. Automatic detection primarily utilizes information technology to automatically measure ship draft. There are four main methods: underwater measurement methods based on sonar technology, underwater automatic ship draft detection systems based on ultrasonic arrays, ship draft gauge detection systems based on digital signal processing (DSP), and ship draft measurement systems based on lidar. Several current automatic detection methods suffer from the following issues.
[0003] 1. The cost of sensor equipment is high, and installation and deployment are subject to environmental restrictions;
[0004] 2. The deployed sensor equipment requires regular maintenance by specialists, which is time-consuming and costly.
[0005] A ship's freeboard is the vertical distance from the fully loaded waterline to the top edge of the deck mid-ship. If a ship is overloaded and the freeboard is reduced to below the specified limit, the ship cannot safely float on the water. Therefore, the minimum freeboard is also called the safe freeboard. In theory, freeboard measurement is less difficult than waterline measurement, and the ship's load can be estimated based on the freeboard. However, the use of freeboard in inland waterway inspections is rare, with waterline measurement still the primary method.
[0006] To address these issues, this paper first constructs a deep learning-based instance segmentation model based on images of inland waterway vessels and a deep learning model. Furthermore, it employs a line segment detector (LSD), a distance-based clustering algorithm (K-means), and a random sampling consensus algorithm (RANSAC) to develop an automatic method for measuring the pixel height of inland waterway vessel freeboards from monocular images. Compared to existing methods, the proposed method achieves higher detection accuracy and greater robustness. Summary of the Invention
[0007] To address the shortcomings of existing freeboard measurement methods, this paper proposes an automatic method for measuring the pixel height of inland vessel freeboard based on monocular images. Based on monocular images and instance segmentation, this method performs multi-channel binarization on the image, uses a line segment detector (LSD) to detect line segments on the binary image, and performs linear model fitting on the detected line segment endpoints to obtain the ship's deck line and waterline, thereby measuring the pixel height of the ship's freeboard.
[0008] The technical solution of the present invention mainly includes the following steps:
[0009] Step 1: Collect monocular inland river ship images and preprocess them;
[0010] Step 2: For the image processed in step 1, use the instance segmentation model to generate instance segmentation results and result graphs based on the pre-trained network weights;
[0011] Step 3: Extract the instance regression box coordinates from the result and result image after processing in step 2, and use the coordinates to crop the result image to obtain a cropped image;
[0012] Step 4: Perform multi-channel binarization processing on the cropped image obtained in step 3 to obtain a binary image; use the line segment detector LSD to perform line segment detection on the binary image to obtain a line segment result;
[0013] Step 5: Use the distance-based clustering algorithm (K-means) and random sampling consensus algorithm (RANSAC) to fit the linear model of the binary image and line segment results obtained in step 4, and then determine the position of the deck line and waterline, and calculate the pixel height of the ship's freeboard.
[0014] Furthermore, the specific implementation of step 1 is as follows:
[0015] A monocular camera was used to capture images of inland ships. The freeboard areas of the ships in the images were annotated using Lableme software. The annotated images were divided into a training set and a test set.
[0016] Furthermore, the specific implementation of step 2 is as follows:
[0017] Step 2-1: Based on the training set obtained in step 1, the instance segmentation model is trained using the pre-trained instance segmentation weights to accelerate model convergence. After the training, the optimal weights are retained.
[0018] Step 2-2 uses the optimal weight and instance segmentation model to segment the test set images and obtain the instance segmentation results and result graph.
[0019] Furthermore, the specific implementation of step 3 is as follows:
[0020] Step 3-1 First, based on the instance segmentation results obtained in step 2, extract the regression frame of the instance, and extract the coordinates P of the rectangular regression frame in the corresponding result image according to the order of the test set image numbers. ins ;
[0021] Step 3-2 determines whether the instance segmentation result corresponding to the result image has multiple rectangular regression boxes; if so, calculate the areas of all rectangular regression boxes and take the coordinates that make the area the largest as the regression box coordinates of the result image;
[0022] Step 3-3 uses the regression frame coordinates to crop the result image and the original image respectively to obtain I r and I o , after subtraction, we get the cropped image I. The image subtraction formula is as follows:
[0023] I=αI r -βI o
[0024] Among them, α and β are image cropping weight coefficients.
[0025] Furthermore, the specific implementation of step 4 is as follows:
[0026] Step 4-1: Binarize the cropped image I in the R, G, and B channels to obtain the binary image B. r 、B g 、B b ;
[0027] Step 4-2 for binary image B r 、B g 、B b Perform image subtraction to obtain a binary image B. The image subtraction formula is as follows:
[0028] B=B r -B g -B b
[0029] Step 4-3: Use line segment detector LSD to detect the binary image B obtained in step 4-2, and obtain a line segment set S. The specific representation of each line segment l in S is (p x0 , p y0 , p x1 , p y1 ,ρ), where p x0 、p y0 Represents the coordinates of the first endpoint p0 of line segment l, p x1 、p y1 represents the coordinates of the second endpoint p1 of the line segment l, and ρ represents the width of the line segment;
[0030] Step 4-4 Calculate the differential d of each line segment l in Sx d y , length L, the calculation formula is as follows:
[0031] d x =|p x0 -p x1 |
[0032] d y =|p y0 -p y1 |
[0033]
[0034] Steps 4-5 use L, d x d y Filter the line segments in the line segment set S to obtain a new line segment set S1. The filtering formula is as follows:
[0035] S1={l|d x >30,d y <20, l∈S}
[0036] Furthermore, the specific implementation of step 5 is as follows:
[0037] Step 5-1: Divide the image width of the binary image B obtained in step 4 into n equal parts to obtain n corresponding line segment subsets S. 1i , where i∈(1,n);
[0038] Step 5-2: for the n line segment subset S obtained in step 5-1 1i , using the distance-based clustering algorithm (K-means), cluster the vertical coordinates of the line segment endpoints in each subset, the number of clusters is 2, and n line segment subsets S with large vertical coordinates of cluster centers are obtained 1id and the subset S of line segments with small ordinates of n cluster centers 1iw ;
[0039] Step 5-3: The n line segment subset S obtained in step 5-2 1id and n line segment subsets S 1iw , merge them respectively to get the line segment subset S 1d and S 1w ;
[0040] Step 5-4: The two line segment subsets S obtained in step 5-3 1d and S 1w , respectively, using the least squares method to fit the endpoints of the line segment into two straight lines L kd and L kw ;
[0041] Step 5-5: The two straight lines L obtained in step 5-4kd and L kw , calculate the corresponding long line segment l in the clipping image I kd and l kw ;
[0042] Step 5-6: Divide the cropped image I into m equal parts according to the x-axis coordinates and calculate m long line segments l kd and lk w Calculate the vertical distance between two points in m equally divided point pairs and take the average value, which is the pixel height H of the ship freeboard according to the clustering method. k ;
[0043] Step 5-7 uses the random sampling consensus algorithm (RANSAC) to perform a linear model fitting on the line segment set S1 obtained in step 4-5 to obtain the linear model L r1 The slope k1 and intercept b1 of the linear model and the set of interior points P in and the set of points P that do not belong to the linear model out , the linear model is expressed as follows:
[0044] L r1 (x)=k1x+b1
[0045] Step 5-8 is to calculate the external point set P obtained in step 5-7. out , and then use the random sampling consensus algorithm (RANSAC) to fit the linear model and get the linear model L r2 The slope k2 and intercept b2 of the linear model are as follows:
[0046] L r2 (x) = k2x + b2
[0047] Step 5-9 uses the two linear models obtained in steps 5-7 and 5-8 to replace the straight line L kd and L kw Repeat steps 5-5 and 5-6 to obtain the sampling method ship freeboard pixel height H r .
[0048] Step 5-10 performs a weighted average of the two freeboard pixel heights obtained in steps 5-6 and 5-9 to obtain the final ship freeboard pixel height H of the image. o , the calculation formula is as follows:
[0049] H o =aH r +bH k
[0050] Among them, a and b are pixel height fusion coefficients.
[0051] The beneficial effects of the present invention are as follows
[0052] The present invention addresses the shortcomings of existing ship freeboard measurement methods. It uses instance segmentation technology to extract the ship freeboard area in the image, and combines the line segment detector (LSD), the distance-based clustering algorithm (K-means), and the random sampling consensus algorithm (RANSAC) to achieve accurate detection of the pixel height of the ship freeboard. It can overcome the problems of traditional manual methods that are time-consuming and labor-intensive and have large errors, and solve the problem that existing image-based methods rely on ship load marks and draft gauge marks. Even if the load marks or draft gauge marks are blurred or missing, the ship freeboard can still be automatically and accurately detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 Flow chart of the method of the present invention;
[0054] Figure 2 The binary image B generated by the present invention;
[0055] Figure 3 The line segment detection result diagram of the present invention;
[0056] Figure 4 The deck line and waterline diagram fitted by the present invention. DETAILED DESCRIPTION
[0057] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0058] like Figure 1 As shown, the method for automatically measuring the pixel height of the freeboard of an inland river vessel based on a monocular image has been described in detail in the invention content, that is, the technical solution of the present invention mainly includes the following steps:
[0059] Step 1: Collect a monocular inland river ship image and preprocess it. The specific steps are as follows:
[0060] A monocular camera was used to capture images of inland ships. The freeboard areas of the ships in the images were annotated using Lableme software. The annotated images were divided into a training set and a test set.
[0061] Step 2: For the image processed in step 1, use the instance segmentation model to generate instance segmentation results and result maps based on the pre-trained network weights. The specific steps are as follows:
[0062] Step 2-1 is based on the training set obtained in step 1 and trained on the weight training set of the Mask R-CNN instance segmentation model pre-trained on the COCO dataset to accelerate model convergence. The optimal weights are retained after 24 rounds of training.
[0063] The Mask R-CNN used in this paper consists of a backbone network ResNet-50, a feature pyramid network FPN, a classification network RPN, a region of interest alignment layer ROIAlign, and fully connected layers FC layers.
[0064] The loss function l of Mask R-CNN is composed of the classification loss l cls , regression box loss l bbox and mask loss l mask It consists of three parts, of which l bbox is L1 loss, l cls and l mask is Cross Entropy Loss, and the specific formula is as follows:
[0065] l=l cls +l bbox +l mask
[0066]
[0067]
[0068] Among them, y i represents the true value, f(x i ) represents the model prediction value; p(x i ) represents the true distribution of sample X, q(x i ) represents the distribution predicted by the model.
[0069] During Mask R-CNN training, data augmentation methods such as multi-scale training and image flipping are used to enhance instance segmentation. Multi-scale training involves rescaling images from the original size of 4752×3168 to 1333×800, 1333×768, 1333×736, 1333×704, 1333×672, and 1333×640 before inputting them into the model. The image flipping factor of 0.5 means that half of the images are randomly flipped before being input into the model.
[0070] In step 2-2, use the optimal weights and the Mask R-CNN instance segmentation model to segment the test set images, obtaining the instance segmentation results and the resulting graph. The optimal weights are the weights obtained from the 24th round of training. The instance segmentation results consist of encoded dictionary-type elements, corresponding to the generated result graph.
[0071] Step 3: Extract the instance regression box coordinates from the result and result image after processing in step 2, and use the coordinates to crop the result image to obtain a cropped image. The specific steps are as follows:
[0072] Step 3-1 First, use the instance segmentation result to extract the instance regression box, and extract the coordinates P of the rectangular regression box in the corresponding result image according to the order of the test set image number. ins , the specific representation is as follows:
[0073] P t =(x t0 x t1 y t0 y t1 ), t∈[1,q]
[0074]
[0075] Among them, q represents the number of instances detected in the image.
[0076] Step 3-2 determines whether the instance segmentation result corresponding to the result image has multiple rectangular regression boxes, that is, whether n is greater than 1; if q>1, calculate the area of all rectangular regression boxes and take the coordinates that make the area the largest as the regression box coordinates P of the result image bbox , the specific formula is as follows:
[0077] S t =(y t1 -y t0 ) 2 +(x t1 -x t0 ) 2
[0078]
[0079] P m ={P t |S t =S m}
[0080]
[0081] Step 3-3 Use the regression box coordinates P bbox , perform image cropping on the result image and the original image respectively, and obtain I r and I o , after subtraction, we get the cropped image I. The image subtraction formula is as follows:
[0082] I=αI r -βI o
[0083] Among them α=0.75, β=0.225:
[0084] Step 4: Perform multi-channel binarization on the cropped image obtained in step 3 to obtain a binary image; use the line segment detector LSD to perform line segment detection on the binary image to obtain a line segment result; the specific steps are as follows:
[0085] Step 4-1: Separate the cropped image I into the R, G, and B channels to obtain three groups of (0, 255) pixel values of r, g, and b. Binarize these three groups of pixels to obtain the binary image B. r 、B g 、B b , the binarization processing formula is as follows;
[0086]
[0087]
[0088]
[0089] Step 4-2 for binary image B r 、B g 、B b Perform image subtraction to obtain a binary image B. The image subtraction formula is as follows:
[0090] B=B r -B g -B b
[0091] Step 4-3: Use line segment detector LSD to detect the binary image B obtained in step 4-2, and obtain a line segment set S. The specific representation of each line segment l in S is (p x0 , p v0 , p x1 , p y1 ,ρ), where p x0 、p y0 Represents the coordinates of the first endpoint p0 of line segment l, p x1 、p y1 represents the coordinates of the second endpoint p1 of the line segment l, and ρ represents the width of the line segment;
[0092] Step 4-4 Calculate the differential d of each line segment l in S x d v , length L, the calculation formula is as follows:
[0093] d x =|p x0 -p x1 |
[0094] d y =|p y0 -p y1 |
[0095]
[0096] Steps 4-5 use L, d x d y The line segments in the line segment set S are screened to obtain a new line segment set S1. The screening formula is as follows;
[0097] S1={l|d x >30,d y <20, l∈S}
[0098] Step 5: Use the distance-based clustering algorithm (K-means) and the random sampling consensus algorithm (RANSAC) to fit the deck line and waterline of the binary image and line segment results obtained in step 4, and calculate the pixel height of the ship's freeboard; the specific implementation is as follows:
[0099] Step 5-1: Divide the image width of the binary image B obtained in step 4 into n equal parts to obtain n corresponding line segment subsets S. 1i , where i∈(1,n);
[0100] Step 5-2: for the n line segment subset S obtained in step 5-1 1i , using the distance-based clustering algorithm (K-means), cluster the vertical coordinates of the line segment endpoints in each subset, the number of clusters is 2, and n line segment subsets S with large vertical coordinates of cluster centers are obtained 1id and the subset S of line segments with small ordinates of n cluster centers 1iw ;
[0101] K-means is a clustering algorithm that partitions a dataset into k clusters, such that each data point belongs to the closest cluster, and the cluster center is the average of all data points. This algorithm is based on iterative optimization, where each iteration updates the cluster center until convergence is achieved.
[0102] The steps of the K-means clustering algorithm of the present invention are as follows:
[0103] 1) First, the dataset S 1i Initialization: Divide the dataset into 2 clusters, and then randomly select 2 data points as the initial cluster centers.
[0104] 2) Secondly, S 1i Each data point in is assigned to the cluster center closest to it, and each data point can only belong to one cluster.
[0105] 3) Then update the cluster center point according to the assigned data points. The new cluster center point is the average value of the data points in each cluster.
[0106] 4) Repeat steps 2 and 3 until the cluster center no longer changes or a predetermined number of iterations is reached. The termination condition of the present invention consists of two parts: the first part is the maximum number of iterations, which is set to 1000 times, and the second part is the accuracy threshold. When the accuracy is less than 0.1, the iteration is stopped.
[0107] 5) Finally, we get 2 clusters and the center point of each cluster.
[0108] 6) Repeat steps 1 to 5 for n line segment subsets S 1i Perform clustering to obtain n line segment subsets S with large ordinates of cluster centers 1id and the subset S of line segments with small ordinates of n cluster centers 1iw In the present invention, n=2.
[0109] Step 5-3: The n line segment subset S obtained in step 5-2 1id and n line segment subsets S 1iw , merge them respectively to get the line segment subset S 1d and S 1w ;
[0110] Step 5-.4: The two line segment subsets S obtained in step 5-3 1d and S 1w , respectively, using the least squares method to fit the endpoints of the line segment into two straight lines L kd and L kw , this set of straight lines is the ship deck line and waterline, and the least squares formula is as follows:
[0111]
[0112] Where k is the slope of the straight line, x and y are the coordinates of the points to be fitted, and is the mean of the x- and y-coordinates of np points, n p is the number of points to be fitted. When the slope k of the straight line is known, the intercept b can be calculated by the method of undetermined coefficients, and finally the fitting straight line is obtained.
[0113] Step 5-5: The two straight lines L obtained by fitting kd and L kw , calculate the corresponding long line segment l in the clipping image I kd and l kw ;
[0114] Step 5-6: Divide the cropped image I into m equal parts according to the x-axis coordinates and calculate m long line segments l kd and l kw Calculate the vertical distance between two points in m equally divided point pairs and take the average value, which is the pixel height H of the ship freeboard according to the clustering method.k , in the present invention, m=72, and the specific formula is as follows:
[0115]
[0116] Where W is the width of the cropped image I, and x is the length of the line segment l kd The value of the horizontal coordinate of the left endpoint;
[0117] Steps 5-7: The Random Sampling Consensus Algorithm (RANSAC) is an iterative parameter estimation algorithm commonly used for model fitting, outlier removal, or selecting an appropriate data subset. It can find the optimal model parameters through iterative optimization in the presence of noise and outliers.
[0118] The following are the basic steps of the RANSAC algorithm used in this invention to process data:
[0119] 1) Select random samples: Randomly select a small number of samples from the original data set as the inlier set to build the initial model; the present invention sets the minimum number of randomly selected samples to 4.
[0120] 2) Fit Model: Fit a linear model using the selected set of interior points.
[0121] 3) Determine outliers: Using the obtained linear model, search for data points in the original data set that match the model, and define data points that exceed a threshold C as outliers. In the present invention, the distance from the point to the fitted model is compared with the threshold, and the threshold C is set as follows:
[0122]
[0123] Where H is the height of the cropped image I.
[0124] 4) Evaluate the model: Calculate the number of inliers as an evaluation metric for the model. A higher number of inliers indicates a better quality linear model.
[0125] 5) Iterative update: Repeat steps 1 to 4 until a predetermined stopping condition is met. In the present invention, the stopping condition is the maximum number of iterations N=100.
[0126] 6) Optimal model: Select the model with the largest number of inliers in the iterative update, perform least squares processing on the inliers of the model, and obtain the optimal linear model.
[0127] For the line segment set S1 obtained in step 4-5, a linear model is fitted once using the random sampling consensus algorithm (RANSAC) to obtain the linear model L r1 The slope k1 and intercept b1 of the linear model and the set of interior points P inand the set of points P that do not belong to the linear model out , the linear model is expressed as follows:
[0128] L r1 (x)=k1x+b1
[0129] Step 5-8 is to calculate the external point set P obtained in step 5-7. out , and then use the random sampling consensus algorithm (RANSAC) to fit the linear model and get the linear model L r2 The slope k2 and intercept b2 of the linear model are as follows:
[0130] L r2 (x) = k2x + b2
[0131] Step 5-9 uses the two linear models obtained in steps 5-7 and 5-8 to replace the straight line L kd and L kw Repeat steps 5-5 and 5-6 to obtain the sampling method ship freeboard pixel height H r .
[0132]
[0133] Where W is the width of the cropped image I, and x is the length of the line segment l r1 The value of the horizontal coordinate of the left endpoint;
[0134] Step 5-10 performs a weighted average of the two freeboard pixel heights obtained in steps 5-6 and 5-9 to obtain the final ship freeboard pixel height H of the image. o , the calculation formula is as follows:
[0135] H o =aH r +bH k
[0136] Where a=0.5, b=0.5.
[0137] 100 ship images with clear load marks were manually selected from the ship image test set. The true value of the freeboard pixel height was manually measured at the midship. The ship freeboard pixel height H obtained in steps 5-10 was used as the o Compare it with the true value T to verify the reliability of the algorithm.
[0138] In order to truly test the accuracy of the present invention in detecting the freeboard pixel height of inland ships, a comparative test was conducted on 100 manually selected ship images with clear load marks. The evaluation indicators were absolute error and relative error. The absolute error formula is as follows:
[0139] Δ=|H o -T|
[0140] Among them H o is the pixel height of the ship freeboard measured by the method proposed in this invention, and T is the true value of the pixel height of the freeboard measured manually. The relative error formula is as follows:
[0141]
[0142] Where Δ is the absolute error and T is the true value of the freeboard pixel height measured manually.
[0143] After testing, the method proposed in this paper achieved an average absolute error of 4.14 pixels and an average relative error of 1.82%. The currently mainstream Canny edge detection and Hough linear transform measurement methods achieved an average absolute error of 5.54 pixels and an average relative error of 2.48% on this dataset. In terms of error distribution, the experimental results of the method proposed in this paper showed an absolute error greater than 5 pixels in 26% of cases, and an absolute error greater than 10 pixels in 7% of cases. The experimental results of the Canny edge detection and Hough linear transform measurement methods showed an absolute error greater than 5 pixels in 47% of cases, and an absolute error greater than 10 pixels in 12% of cases. This fully demonstrates that the present invention has higher accuracy than the current inland vessel freeboard pixel height detection methods.
[0144] The above description is a further detailed description of the present invention in conjunction with specific / preferred embodiments, and the specific implementation of the present invention should not be considered to be limited to these descriptions. Those skilled in the art of the present invention may make various substitutions or modifications to the described embodiments without departing from the scope of the present invention, and such substitutions or modifications should be considered to fall within the scope of protection of the present invention.
[0145] Parts of the present invention that are not described in detail belong to the common knowledge of those skilled in the art.
Claims
1. A method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image, characterized in that: The steps include: Step 1: Collect monocular inland river ship images and preprocess them; Step 2: For the image processed in step 1, use the instance segmentation model to generate instance segmentation results and result graphs based on the pre-trained network weights; Step 3: Extract the instance regression box coordinates from the result and result image after processing in step 2, and use the coordinates to crop the result image to obtain a cropped image; Step 4: Perform multi-channel binarization processing on the cropped image obtained in step 3 to obtain a binary image; use the line segment detector LSD to perform line segment detection on the binary image to obtain a line segment result; Step 5: Use the distance-based clustering algorithm and random sampling consistency algorithm to fit the linear model of the binary image and line segment results obtained in step 4, and then determine the position of the deck line and waterline, and calculate the pixel height of the ship's freeboard.
2. The method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image according to claim 1, characterized in that: The specific implementation of step 1 is as follows: A monocular camera was used to capture images of inland ships. The freeboard areas of the ships in the images were annotated using Lableme software. The annotated images were divided into a training set and a test set.
3. The method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image according to claim 2, characterized in that: The specific implementation of step 2 is as follows: Step 2-1: Based on the training set obtained in step 1, the instance segmentation model is trained using the pre-trained instance segmentation weights to accelerate model convergence. After the training, the optimal weights are retained. Step 2-2 uses the optimal weight and instance segmentation model to segment the test set images and obtain the instance segmentation results and result graph.
4. The method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image according to claim 1 or 3, characterized in that: The specific implementation of step 3 is as follows: Step 3-1 First, based on the instance segmentation results obtained in step 2, extract the regression frame of the instance, and extract the coordinates P of the rectangular regression frame in the corresponding result image according to the order of the test set image numbers. ins ; Step 3-2 determines whether the instance segmentation result corresponding to the result image has multiple rectangular regression boxes; If so, calculate the areas of all rectangular regression boxes and take the coordinates that maximize the area as the regression box coordinates of the result graph; Step 3-3 uses the regression frame coordinates to crop the result image and the original image respectively to obtain I r and I o , after subtraction, we get the cropped image I. The image subtraction formula is as follows: I=αI r -βI o Among them, α and β are image cropping weight coefficients.
5. The method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image according to claim 4, characterized in that: The specific implementation of step 4 is as follows: Step 4-1: Binarize the cropped image I in the R, G, and B channels to obtain the binary image B. r 、B g 、B b ; Step 4-2 for binary image B r 、B g 、B b Perform image subtraction to obtain a binary image B. The image subtraction formula is as follows: B=B r -B g -B b Step 4-3: Use line segment detector LSD to detect the binary image B obtained in step 4-2, and obtain a line segment set S. The specific representation of each line segment l in S is (p x0 , p y0 , p x1 , p y1 ,ρ), where p x0 、p y0 Represents the coordinates of the first endpoint p0 of line segment l, p x1 、p y1 represents the coordinates of the second endpoint p1 of the line segment l, and ρ represents the width of the line segment; Step 4-4 Calculate the differential d of each line segment l in S x d y , length L, the calculation formula is as follows: d x =|p x0 -p x1 | d y =|p y0 -p y1 | Steps 4-5 use L, d x d y Filter the line segments in the line segment set S to obtain a new line segment set S1. The filtering formula is as follows: S1={l|d x >30,d y <20,l∈S}。 6. The method for automatically measuring the freeboard pixel height of an inland river vessel based on a monocular image according to claim 5, characterized in that: The specific implementation of step 5 is as follows: Step 5-1: Divide the image width of the binary image B obtained in step 4 into n equal parts to obtain n corresponding line segment subsets S. 1i , where i∈(1,n); Step 5-2: for the n line segment subset S obtained in step 5-1 1i , using the distance-based clustering algorithm, cluster the vertical coordinates of the endpoints of the line segments in each subset, the number of clusters is 2, and n line segment subsets S with large vertical coordinates of cluster centers are obtained. 1id and the subset S of line segments with small ordinates of n cluster centers 1iw ; Step 5-3: The n line segment subset S obtained in step 5-2 1id and n line segment subsets S 1iw , merge them respectively to get the line segment subset S 1d and S 1w ; Step 5-4: The two line segment subsets S obtained in step 5-3 1d and S 1w , respectively, using the least squares method to fit the endpoints of the line segment into two straight lines L kd and L kw ; Step 5-5: The two straight lines L obtained in step 5-4 kd and L kw , calculate the corresponding long line segment l in the clipping image I kd and l kw ; Step 5-6: Divide the cropped image I into m equal parts according to the x-axis coordinates and calculate m long line segments l kd and lk w Calculate the vertical distance between two points in m equally divided point pairs and take the average value, which is the pixel height H of the ship freeboard according to the clustering method. k ; Step 5-7 uses the random sampling consensus algorithm to perform a linear model fit on the line segment set S1 obtained in step 4-5 to obtain the linear model L r1 The slope k1 and intercept b1 of the linear model and the set of interior points P in and the set of points P that do not belong to the linear model out , the linear model is expressed as follows: L r1 (x)=k1x+b1 Step 5-8 is to calculate the external point set P obtained in step 5-7. out , and then use the random sampling consensus algorithm to fit the linear model to get the linear model L r2 The slope k2 and intercept b2 of the linear model are as follows: L r2 (x)=k2x+b2 Step 5-9 uses the two linear models obtained in steps 5-7 and 5-8 to replace the straight line L kd and L kw Repeat steps 5-5 and 5-6 to obtain the sampling method ship freeboard pixel height H r ; Step 5-10 performs a weighted average of the two freeboard pixel heights obtained in steps 5-6 and 5-9 to obtain the final ship freeboard pixel height H of the image. o , the calculation formula is as follows: H o =aH r +bH k Among them, a and b are pixel height fusion coefficients.
Citation Information
Patent Citations
Inland ship freeboard automatic measurement method based on monocular vision
CN115861441A
Storage medium, trace detection device, and device and method for training trace detection model
US20220262090A1