Scale-based underwater target monitoring method and electronic device
By using a scale-based underwater target monitoring method and employing an improved YOLOv8-obb model and multimodal segmentation and fusion technology, the automated identification and size measurement of underwater targets were achieved, solving the problem of time-consuming and labor-intensive manual monitoring and improving monitoring efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEBEI SAILHERO ENVIRONMENTAL PROTECTION HIGH TECH
- Filing Date
- 2026-03-09
- Publication Date
- 2026-06-16
AI Technical Summary
Current underwater biological monitoring technologies require manual diving to collect samples, which is time-consuming, labor-intensive, and difficult.
An underwater target monitoring method based on a ruler is adopted. By acquiring target images containing the monitoring target and a rectangular ruler, the pixel size of the monitoring target is identified using an improved YOLOv8-obb model. The actual size of the monitoring target is determined by combining the pixel size of the ruler with the actual size. The ruler outline is detected using a multimodal segmentation and fusion method, thus achieving automated monitoring without human intervention.
It enables automated identification and size measurement of underwater targets, reduces labor costs, improves monitoring efficiency, adapts to complex underwater environments, and provides high-precision monitoring results.
Smart Images

Figure CN122223296A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a scale-based underwater target monitoring method and electronic device. Background Technology
[0002] Underwater biological monitoring is a core component of refined management in aquaculture. Its core function is to monitor the growth, health, and ecological status of aquaculture organisms in real time and with precision, thereby providing data support for feeding, disease prevention and control, and water quality regulation, and ultimately improving aquaculture efficiency and survival rate.
[0003] In existing technologies, underwater biological monitoring usually involves manual diving underwater to collect samples, which is difficult, time-consuming, and labor-intensive. Summary of the Invention
[0004] This invention provides a scale-based underwater target monitoring method and electronic device to solve the problems of time-consuming, labor-intensive, and difficult manual sampling and monitoring.
[0005] In a first aspect, embodiments of the present invention provide a scale-based underwater target monitoring method, comprising: Acquire the target image; the target image contains the monitoring target and a scale, the scale being rectangular; The improved YOLOv8-obb was used to identify the target image and obtain the pixel size of the monitored target; Perform contour detection on the target image to obtain the pixel dimensions of the scale; The actual size of the monitored target is determined based on the pixel size of the monitored target, the pixel size of the scale, and the actual size of the scale.
[0006] In a second aspect, embodiments of the present invention provide an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the scale-based underwater target monitoring method as described in the first aspect or any possible implementation of the first aspect.
[0007] This invention provides a ruler-based underwater target monitoring method and electronic device. The ruler-based underwater target monitoring method includes: acquiring a target image; wherein the target image contains a monitoring target and a ruler, the ruler being rectangular; using an improved YOLOv8-obb algorithm to identify the target image and obtain the pixel size of the monitoring target; performing contour detection on the target image to obtain the pixel size of the ruler; and determining the actual size of the monitoring target based on the pixel size of the monitoring target, the pixel size of the ruler, and the actual size of the ruler. This invention directly extracts the pixel size of the rectangular ruler through contour detection, using the ruler as a unified reference. Based on the pixel sizes of the monitoring target and the ruler, combined with the known actual size of the ruler, a linear conversion of the actual size of the monitoring target is achieved. This eliminates the need for complex calibration, offers flexible application scenarios, has low deployment costs, requires no manual intervention, and saves time and effort. Attached Figure Description
[0008] Figure 1 This is a flowchart illustrating the implementation of a scale-based underwater target monitoring method provided in an embodiment of the present invention. Figure 2 This is a layout diagram of the underwater scale provided in an embodiment of the present invention; Figure 3 This is an improved YOLOv8-obb network architecture diagram provided by an embodiment of the present invention; Figure 4 This is a network architecture diagram of an SAConv spatial adaptive convolutional layer provided in an embodiment of the present invention; Figure 5 This is a network architecture diagram of an MLLA attention module provided in an embodiment of the present invention; Figure 6 This is a fluctuation graph of the accuracy, recall, and MAP of the scale-based underwater target monitoring method provided in the embodiments of the present invention. Figure 7 This is a schematic diagram of the detection results of the scale-based underwater target monitoring method provided in an embodiment of the present invention; Figure 8 This is a device layout diagram corresponding to the underwater target monitoring method based on a ranging sensor provided in the embodiments of the present invention; Figure 9 This is a schematic diagram of the detection results of the underwater target monitoring method based on a ranging sensor provided in an embodiment of the present invention; Figure 10 This is a diagram showing the arrangement of the laser scale provided in an embodiment of the present invention; Figure 11 This is a schematic diagram of the underwater target monitoring device based on a scale provided in an embodiment of the present invention; Figure 12 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0009] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0010] See Figure 1 The diagram illustrates a flowchart of an underwater target monitoring method based on a scale, as provided in an embodiment of the present invention, and is described in detail below: The aforementioned scale-based underwater target monitoring method may include: S101: Acquire the target image; wherein the target image contains the monitoring target and a scale, and the scale is rectangular; The target image is acquired through an underwater video acquisition module, which uses an ultra-low illumination straight-tube camera mounted on a mobile or fixed platform adapted to the underwater environment. The camera's field of view completely covers the scale area. It is also equipped with an adjustable supplementary light to adapt to underwater lighting conditions and dim lighting, ensuring that the acquired target image is clear and complete, and can clearly present the outline features of the monitored target and the detailed structure of the scale.
[0011] In one possible implementation, the scale can be a black and white grid scale.
[0012] The black and white grid structure can improve the accuracy of contour recognition under complex underwater lighting conditions, which facilitates subsequent contour detection and size calibration.
[0013] For example, refer to Figure 2 The underwater ruler can be assisted by two fixed rods, which together with the ruler form a stable triangular structure (for example, the two fixed rods are 40cm steel rulers, and the ruler is also 40cm long). This structure enhances the stability of the ruler in the underwater environment, prevents the ruler from tilting, shifting, or shaking due to water flow impact, and ensures that the ruler always maintains the preset horizontal or vertical posture, thus ensuring the accuracy of the ruler pixel size detection.
[0014] Furthermore, after obtaining the target image, underwater scattering noise can be suppressed by nonlocal mean filtering, and the contrast between the target (scale / sea cucumber) and the background can be enhanced by using a dark channel prior dehazing algorithm, providing high-quality input for subsequent detection algorithms and reducing environmental interference (such as uneven lighting, shadows, and image distortion).
[0015] S102: The improved YOLOv8-obb is used to identify the target image and obtain the pixel size of the monitored target; This application uses an improved YOLOv8-obb to identify target images and outputs the pixel size of the monitored target for subsequent actual size conversion.
[0016] The improved YOLOv8-obb is an adaptive optimization based on the underwater application scenarios of this application, as detailed below: In one possible implementation, refer to Figure 3 The improved YOLOv8-obb includes: MLLA (Mamba-Like Linear Attention) attention module, SAConv (Switchable Atrous Convolution) spatially adaptive convolutional layer, and DySample dynamic upsampling module; The MLLA attention module is located in the last layer of the backbone network; SAConv spatially adaptive convolutional layers are applied to all standard convolutional operations in the improved YOLOv8-obb; The DySample dynamic upsampling module is applied to all upsampling operations in the improved YOLOv8-obb.
[0017] The SAConv spatially adaptive convolutional layer applies all standard convolutional operations (e.g., 3×3 convolution) in the improved YOLOv8-obb, replacing traditional convolutions with a fixed dilation rate. This convolutional layer dynamically fuses convolutional features with different dilation rates through a spatially adaptive switching function, enabling the network to adaptively adjust its receptive field based on the local scale and contextual information of the monitored target. This allows for precise capture of detailed features of nearby targets and contour features of distant targets, achieving accurate focus on target features and effective suppression of background interference.
[0018] For example, refer to Figure 4 Assuming the input feature vector ;in, C Representing dimension, H Indicates altitude, W Indicates the width. The workflow of the SAConv spatially adaptive convolutional layer is described below: First, to improve the network's understanding of the overall scene and provide prior guidance for subsequent local decisions, global context enhancement is applied to the input features, calculated as follows:
[0019] in, GAP (·) represents global average pooling.
[0020] Secondly, based on features that have already integrated global information F The module needs to make independent decisions for each spatial location: whether feature extraction for the current pixel should rely more on local details or the broader context, calculated as follows:
[0021] Where σ is the Sigmoid function, AvgPool It is 5×5 average pooling.
[0022] Secondly, dual-path feature extraction and dynamic fusion. In this core step, the module performs convolutional operations on two different receptive fields in parallel, and uses the switching map generated in the previous step... S Dynamic fusion is performed, and the calculation formula is as follows:
[0023] in, Conv (·,·, r ) indicates the void ratio. r Convolution, where ⊙ represents element-wise multiplication. K It is a shared basic convolutional kernel.
[0024] Finally, to ensure that the dynamically fused features also have consistent global representation capabilities, a context module is introduced again for global integration, and the calculation formula is as follows:
[0025] in, BN (·) indicates batch normalization. This module, through a spatially adaptive dynamic fusion mechanism, enables the network to autonomously select the optimal receptive field based on the local context, effectively coordinating the extraction of local details and global structural information, thereby improving the model's stability in identifying and locating multi-scale targets in complex underwater scenes.
[0026] refer to Figure 3 The MLLA attention module is placed in the last layer of the backbone network. It incorporates some core designs of the Mamba model into the linear attention mechanism, which can efficiently model the long-distance dependency between the monitored target and the complex underwater environment, adaptively enhance the target features and suppress background noise. At the same time, it improves the model inference speed by replacing the forget gate with position encoding, and solves the problems of low contrast between the target and the background and difficulty in feature extraction in underwater images.
[0027] refer to Figure 5 Let the input feature map be Where B is the batch size, C is the number of channels, and H and W are the spatial height and width, respectively.
[0028] First, serialize it to suit the attention mechanism:
[0029] in, N = H × W For sequence length, R (·, shape) represents the reshaping operation. P (·, perm) represents the dimension permutation operation. This operation yields serialized features. , which serves as the input for all subsequent linear transformations.
[0030] Then, the serialized features X s Simultaneously inputting two independent linear transformations generates the fundamental tensor required for subsequent calculations, as shown in the following formula:
[0031] in, For learnable projection weight matrix, For bias terms, The obtained tensor. Q 0 and K 0 will enter the gated path, while V 0 will be used as a value in the attention calculation.
[0032] The core of the gated path is to generate a spatially and channel-adaptive modulation signal. First, a nonlinear activation is applied to the query and key, calculated as follows:
[0033] in, SiLU ( x )=x · σ(x) is the sigmoid function, σ(·) is the sigmoid function, and 1 represents a tensor of all 1s.
[0034] Subsequently, a global, content-relevant gating vector is calculated using the following formula:
[0035] in, express The first in the sequence dimension i A vector.
[0036] The main path is responsible for extracting features with rich contextual information. First, the projected values... V 0. Applying a linear attention mechanism, the calculation formula is as follows:
[0037] Subsequently, attention output A Apply local positional enhancement. After reshaping it back to its spatial format, apply a convolution to inject local structural inductive biases, calculated as follows:
[0038] Finally, reshape F back into sequence format:
[0039] The modulation signal g generated by the gated path is compared with the features extracted from the main path. F s By combining these methods, content-aware feature selection and enhancement can be achieved. The calculation formula is as follows:
[0040] Finally, the output sequence is reshaped into the same four-dimensional format as the input:
[0041] The DySample dynamic upsampling module is applied to all upsampling operations in the improved YOLOv8-obb, replacing the traditional fixed-rate upsampling method. By adopting a point sampling approach, the sampling rate can be flexibly adjusted to achieve more efficient feature fusion, while further reducing computational overhead. This provides higher-quality feature maps for the detection of small-scale monitoring targets (such as juvenile sea cucumbers), optimizing the detection performance of small targets.
[0042] Further, refer to Figure 3 The improved YOLOv8-obb in this application adds a small-scale detection head (e.g., 160×160) to the original three detection heads (e.g., 80×80, 40×40, 20×20). This small-scale detection head is specifically responsible for receiving and processing higher resolution and more detailed feature maps, and directly focuses on small and blurry underwater targets (<30 pixels) in the image, achieving full-size coverage of underwater targets without omission.
[0043] In one possible implementation, the loss function of the improved YOLOv8-obb model is the second formula; The second formula may include:
[0044]
[0045]
[0046] in, The loss function for the improved YOLOv8-obb model; It is the gradient gain factor. For the final weighted mapping; For outlier degree, , For hyperparameters, For distance attention, For bounding box loss based on intersection-union ratio, This represents the average sliding loss. For intersection, union, and comparison; , ( ) represents the x and y coordinates of the center point of the prediction box; , () represents the x and y coordinates of the center point of the true bounding box; , These are the width and height of the minimum bounding rectangles of the predicted bounding box and the ground truth bounding box, respectively; The separation operation in the computation graph.
[0047] Since training data inevitably contains low-quality examples, geometric metrics such as distance and aspect ratio will exacerbate the penalty for low-quality examples, thereby reducing the model's generalization performance. Therefore, this application adopts the second formula as the loss function, which addresses the importance differences between different pixels by assigning different weights to each pixel, further optimizing the model training effect and improving the localization accuracy and generalization ability of underwater target recognition.
[0048] S103: Perform contour detection on the target image to obtain the pixel size of the scale; Due to issues such as uneven lighting, blurring, and noise interference in underwater images, single contour detection methods are insufficient to accurately extract the ruler contour. Therefore, this step employs multimodal segmentation and fusion to perform contour detection on the ruler in the target image, thereby improving stability under different underwater lighting and contrast conditions.
[0049] In one possible implementation, S103 includes: S1031: Adaptive threshold segmentation is used to detect the target image to obtain the first detection result; The adaptive threshold segmentation method can dynamically calculate the segmentation threshold of each region based on the brightness distribution of the local area of the target image. It can effectively distinguish the regions with obvious differences in brightness between the scale (especially the black and white grid scale) and the background, suppress the interference caused by uneven local illumination, and extract the preliminary outline of the scale.
[0050] Let the input image be This process can be represented as:
[0051] in, I gray For a single-channel grayscale image everywhere, ψ BGR2GRAY (·) indicates a color space conversion from RGB to grayscale. I blur For Gaussian blur, G α α is a Gaussian filter kernel with standard deviation α, and * indicates convolution operation.
[0052] S1032: The Canny edge detection algorithm is used to detect the target image to obtain the second detection result; The Canny edge detection algorithm captures edge information with significant intensity gradients in the target image by setting high and low thresholds. It can accurately extract the edge contour of the scale and make up for the shortcomings of adaptive threshold segmentation in edge detail extraction. It is especially suitable for detecting the scale edge in underwater blurred images.
[0053] S1033: The first detection result and the second detection result are fused to obtain a candidate contour set; Subsequently, the preliminary contour obtained by adaptive threshold segmentation is fused with the edge contour obtained by Canny edge detection at the pixel level, integrating the advantages of the two detection methods, eliminating false contours and missed areas generated by a single detection method, and forming a candidate contour set containing more complete ruler shape information.
[0054] S1034: Perform area and rectangle filtering on the candidate contour set to obtain the ruler contour; Since there may be interfering targets in the target image that are similar to the ruler contour (such as underwater rocks and debris), it is necessary to filter the candidate contour set: First, according to the preset area range of the ruler, candidate contours that are too large or too small are eliminated; then the rectangularity of the remaining candidate contours is calculated. Since the ruler is rectangular, the contour with a rectangularity close to 1 is the ruler contour. By filtering the rectangularity, non-rectangular interference contours can be further eliminated, and finally the accurate ruler contour is obtained.
[0055] S1035: Determine the pixel size of the ruler based on the ruler outline.
[0056] Based on the selected ruler outline, extract the ruler's pixel width and pixel height as the ruler's pixel dimensions, which will be used for subsequent conversion between pixel dimensions and actual dimensions.
[0057] S104: Determine the actual size of the monitored target based on the pixel size of the monitored target, the pixel size of the scale, and the actual size of the scale.
[0058] In one possible implementation, the pixel dimensions of the monitored target include: center point coordinates, target width, target length, and rotation angle; the pixel dimensions of the scale include: scale width and scale length; S104 may include: S1041: Determine the physical length corresponding to a single pixel based on the pixel size of the ruler and the actual size of the ruler; Given the actual size of the ruler, the physical length corresponding to a single pixel can be determined based on the pixel size and the actual size of the ruler, that is, the mapping relationship between the pixel size and the actual size.
[0059] For example, the physical length corresponding to a single pixel = the actual length of the ruler / the pixel length of the ruler, or the physical length corresponding to a single pixel = the actual width of the ruler / the pixel width of the ruler (the calculation results are the same).
[0060] S1042: Determine the four corner points of the monitored target based on the pixel size of the monitored target; In one possible implementation, S1042 may include: 1. Based on the pixel size of the monitored target, determine the four corner points of the monitored target using the first formula; The first formula may include:
[0061]
[0062]
[0063]
[0064] in, Let be a rotation matrix. For rotation angle, and It is a semi-axis vector. For target width, For the target length, , , , These are the four corner points; Let be a coordinate vector, ( ( ) represents the coordinates of the center point.
[0065] S1043: Determine the pixel values of the width and length of the monitored target based on the four corner points; By calculating the Euclidean distances between the four corner points, the pixel values of the monitored target's width and length are obtained, accurately representing the pixel morphological parameters of the monitored target. The calculation formula is as follows:
[0066] in, , These are the pixel values for the body length and body width of the monitored target, respectively.
[0067] S1044: Determine the actual length and actual width of the monitored target based on the pixel values of the body width, the pixel values of the body length, and the physical length corresponding to a single pixel.
[0068] The actual length and width of the monitored target are:
[0069] in, , These are the actual length and actual width of the monitored target, respectively. The physical length corresponding to a single pixel The above formula converts the pixel size of the monitored target into its actual physical size, enabling accurate measurement of the target's morphological parameters.
[0070] When the monitoring target is aquaculture species such as sea cucumber, weight is an important parameter for assessing its growth status and aquaculture benefits. This application also uses a piecewise linear regression model based on the actual length and width of the monitoring target to accurately estimate the weight of the monitoring target, achieving non-destructive weight measurement without the need for harvesting.
[0071] In one possible implementation, the monitoring target is a sea cucumber, and the actual dimensions of the monitoring target include: actual length and actual width; the above method may further include: S105: The weight of the monitored target is obtained based on the actual length and width, combined with the third formula; The third formula may include:
[0072] in, For weight, This is the actual length. This is the actual width. This is the width threshold. , , , The coefficients of the first formula are... , , , This is the coefficient of the second formula.
[0073] The relationship between body length, body width, and weight may differ for sea cucumbers within different body width ranges. Therefore, this application sets a width threshold and uses different formulas to calculate weight, thereby achieving an accurate estimation of sea cucumber weight.
[0074] In one possible implementation, prior to S105, the above method may further include: S106: Using width as a variable, a grid search algorithm is used to determine the width threshold; The grid search algorithm traverses the preset width threshold range, calculates the weight estimation error corresponding to each candidate threshold, and selects the candidate threshold with the smallest estimation error as the optimal width threshold, ensuring the rationality of the segmentation points and enabling the two regression models to accurately adapt to the relationship between the weight and body length and body width of sea cucumbers with different body widths.
[0075] Sea cucumber weight Y Compared with actual length L act and actual width Wact The linear relationship between them can be expressed as:
[0076] in, β 0 indicates the intercept (constant term). β 1 represents the regression coefficient for body length. β 2 represents the regression coefficient for body width. δ This is the random error term. δ Satisfies: Zero mean: E( δ =0, homoscedasticity: Var( δ )=σ 2 ,normal distribution: δ ∈ N (0,σ 2 ). (It is set up) n Given training samples, the above relationship can be represented in matrix form:
[0077] in:
[0078] Then, the least squares method is used to estimate the regression coefficients, with the goal of minimizing the sum of squared prediction errors:
[0079] in, Let be the predicted weight of the i-th sample. By taking the partial derivative of the objective function and setting it to zero, we obtain the normal equation system:
[0080] Express the normal equations in matrix form and solve them:
[0081] The analytical solution for the regression coefficients is:
[0082] This application introduces body width as a segmentation variable, and determines the optimal width threshold through grid search. The calculation formula is as follows:
[0083] in, t ˊ represents the optimal width threshold. This indicates the optimal width threshold. t The predicted value at that location.
[0084] S107: Based on the first sample set, the coefficients of the first formula are determined using a multiple linear regression algorithm; wherein, the actual width of each sample in the first sample set is less than the width threshold; S108: Based on the second sample set, the coefficients of the second formula are determined using a multiple linear regression algorithm; wherein, the actual width of each sample in the second sample set is not less than the width threshold. S109: Determine the third formula based on the coefficients of the first and second formulas.
[0085] Using different sample sets, two sets of formula coefficients were obtained using the multiple linear regression algorithm. , , , ,and , , , This leads to a third formula for the accurate estimation of sea cucumber weight.
[0086] Technical effects of this application: 1. High-precision measurement: The image scale is accurately calibrated by using a rectangular ruler (preferably a black and white grid ruler). The ruler contour is extracted by combining a multimodal contour detection method to ensure accurate calculation of the physical length corresponding to a single pixel. At the same time, the YOLOv8-obb model is specifically improved to optimize the accuracy of feature extraction and target positioning. This effectively solves the problem of inaccurate measurement caused by underwater image blurring and large interference, and significantly improves the accuracy of actual size measurement of monitored targets.
[0087] 2. Intelligent Recognition: The improved YOLOv8-obb model is used to achieve automatic recognition of monitoring targets and extraction of pixel size. Multimodal segmentation and fusion are used to achieve automatic detection of scale outline. The entire monitoring process does not require manual intervention and can realize automatic recognition, size measurement and weight estimation of underwater targets, which greatly improves the efficiency of underwater monitoring and reduces labor costs and subjective errors.
[0088] 3. Strong adaptability: The improved YOLOv8-obb model, through the optimization of the MLLA attention module, SAConv spatial adaptive convolutional layer, DySample dynamic upsampling module, and the application of the WIoU loss function, can effectively cope with complex scenarios such as uneven underwater illumination, suspended object interference, target ambiguity, and varying scales. It is suitable for different types of underwater monitoring targets (such as sea cucumbers and abalone) and has a wide range of applications.
[0089] 4. Non-destructive monitoring: Without the need to catch the monitoring target, the underwater image acquisition and intelligent algorithm analysis can accurately measure the morphological parameters and weight of the monitoring target, avoiding damage to the monitoring target caused by the fishing process. It is especially suitable for long-term monitoring in aquaculture ponds, ecological protection areas and other scenarios.
[0090] 5. Data is traceable and quantifiable: All monitoring data can be stored completely, and the monitoring results have clear quantitative standards, which facilitates subsequent data statistics, analysis and long-term tracking, providing reliable data support for aquaculture management and ecological environment assessment.
[0091] The above method will be described in detail below with reference to specific embodiments.
[0092] Data augmentation was used to process the augmented images. The roLabelImg tool was used to rotate and label the bounding boxes of the current dataset, with a target number of no less than 10,000 images. The dataset was divided into training set, validation set, and test set in a ratio of 8:1:1.
[0093] The underwater target detection method based on a scale provided in this invention is used to detect images in the dataset, and the results are evaluated by the fluctuations in precision and recall. From the fluctuations in precision, recall, and mean area (MAP), the fluctuations in precision and recall can reflect the quality of the training; smaller fluctuations indicate better training performance. Figure 6 The results show a steady upward trend, indicating that the training is effective. The test results are as follows: Figure 7 As shown, by Figure 7 It can be seen that accurate identification of sea cucumbers can be achieved.
[0094] Furthermore, this embodiment of the invention also provides an underwater target monitoring method based on a ranging sensor, including: S201: Acquire the target image and the shooting distance of the underwater video acquisition module; refer to Figure 8 The system uses a range sensor to detect the shooting distance. The range sensor and the video acquisition module (underwater camera) are mounted on the same plane, and the distance detected by the range sensor is the shooting distance.
[0095] S202: Determine the pixel-physical size mapping relationship based on the shooting distance; S203: The improved YOLOv8-obb is used to identify the target image and obtain the pixel size of the monitored target; Specifically, the improved YOLOv8-obb is as described above, and will not be repeated here.
[0096] S204: Determine the actual size of the monitored target based on the mapping relationship and the pixel size of the monitored target.
[0097] Using the same steps as in S1042, the four corner points of the monitored target are determined based on the pixel size of the monitored target. The four corner points are arranged clockwise as follows: ( , ), ( , ), ( , ), ( , ); Define the longer side of the detection box as the volume length of the monitored target, and the wider side of the detection box as the volume width of the monitored target, then the volume width pixel value of the monitored target is... and body length pixel value Represented as:
[0098] The center point of the detection frame ( , ) is represented as:
[0099] A geometric calibration method based on field of view and shooting distance is adopted to establish a pixel-to-physical size mapping relationship. Represented as:
[0100] in, and Separate the pixel length and pixel width of the target image. and Let this be the physical width and height of the camera's actual visible area underwater. Based on trigonometric relationships, and The effective underwater field of view ( , ) and shooting distance The calculation yielded:
[0101] in, , These are the effective horizontal and vertical field of view underwater, respectively. Due to light refraction underwater, the effective field of view needs to be multiplied by a correction factor of 0.716.
[0102] Based on the above, the actual size of the monitored target is obtained, and the calculation formula is as follows:
[0103] in, and These are the actual length and actual width of the monitored target, respectively.
[0104] Figure 9 The results of detecting sea cucumbers using an underwater target monitoring method based on a ranging sensor are shown. Figure 9 It can be seen that accurate identification of sea cucumbers can be achieved. Experimental verification shows that the difference between the detection results and the actual sea cucumber size is within the preset error range, which can accurately detect the size of sea cucumbers and verify the effectiveness and accuracy of the above method.
[0105] Furthermore, embodiments of the present invention also provide a laser-based underwater target monitoring method, referencing... Figure 10 A laser pointer is used to create a rectangular laser scale on the underwater surface, with a preset size. The underwater video acquisition module then captures images of the target. Since the target image contains both the target and the laser scale, the improved YOLOv8-obb model described above is used for detection to obtain the pixel dimensions of the detected target and the laser scale. Because the actual size of the laser scale is known, the actual size of the target can be derived; details will not be elaborated here.
[0106] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0107] The following are device embodiments of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.
[0108] Figure 11 A schematic diagram of the underwater target monitoring device based on a scale provided in an embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, and are described in detail below: like Figure 11 As shown, the scale-based underwater target monitoring device includes: Image acquisition module 21 is used to acquire target image; wherein, the target image contains the monitoring target and a scale, and the scale is rectangular; The first pixel size determination module 22 is used to identify the target image using the improved YOLOv8-obb to obtain the pixel size of the monitored target; The second pixel size determination module 23 is used to perform contour detection on the target image to obtain the pixel size of the scale; The target size output module 24 is used to determine the actual size of the monitored target based on the pixel size of the monitored target, the pixel size of the scale, and the actual size of the scale.
[0109] In one possible implementation, the pixel dimensions of the monitored target include: center point coordinates, target width, target length, and rotation angle; the pixel dimensions of the scale include: scale width and scale length; the target size output module 24 may include: The length conversion unit is used to determine the physical length corresponding to a single pixel based on the pixel size of the ruler and the actual size of the ruler. The corner output unit is used to determine the four corners of the monitored target based on the pixel size of the monitored target. The first pixel size resolution unit is used to determine the width pixel value and length pixel value of the monitored target based on the four corner points; The actual size calculation unit is used to determine the actual length and actual width of the monitored target based on the pixel values of the body width, the pixel values of the body length, and the physical length corresponding to a single pixel.
[0110] In one possible implementation, the corner output unit can be specifically used for: 1. Based on the pixel size of the monitored target, determine the four corner points of the monitored target using the first formula; The first formula may include:
[0111]
[0112]
[0113]
[0114] in, Let be a rotation matrix. For rotation angle, and It is a semi-axis vector. For target width, For the target length, , , , These are the four corner points; Let be a coordinate vector, ( ( ) represents the coordinates of the center point.
[0115] In one possible implementation, the second pixel size determination module 23 may include: The first result output unit is used to detect the target image using adaptive threshold segmentation to obtain the first detection result; The second result output unit is used to detect the target image using the Canny edge detection algorithm to obtain the second detection result; The fusion unit is used to fuse the first detection result and the second detection result to obtain a candidate contour set; The filtering unit is used to filter the candidate contour set by area and rectangle to obtain the ruler contour. The second pixel size resolution unit is used to determine the pixel size of the ruler based on the ruler outline.
[0116] In one possible implementation, the scale is a black and white grid scale.
[0117] In one possible implementation, the improved YOLOv8-obb may include: an MLLA attention module, an SAConv spatial adaptive convolutional layer, and a DySample dynamic upsampling module; The MLLA attention module is located in the last layer of the backbone network; SAConv spatially adaptive convolutional layers are applied to all standard convolutional operations in the improved YOLOv8-obb; The DySample dynamic upsampling module is applied to all upsampling operations in the improved YOLOv8-obb.
[0118] In one possible implementation, the loss function of the improved YOLOv8-obb model can be the second formula; The second formula may include:
[0119]
[0120]
[0121] in, The loss function for the improved YOLOv8-obb model; It is the gradient gain factor. For the final weighted mapping; For outlier degree, , For hyperparameters, For distance attention, For bounding box loss based on intersection-union ratio, This represents the average sliding loss. For intersection, union, and comparison; , ( ) represents the x and y coordinates of the center point of the prediction box; , () represents the x and y coordinates of the center point of the true bounding box; , These are the width and height of the minimum bounding rectangles of the predicted bounding box and the ground truth bounding box, respectively; The separation operation in the computation graph.
[0122] In one possible implementation, the monitoring target can be a sea cucumber, and the actual dimensions of the monitoring target include: actual length and actual width; the device may further include: The weight output module is used to obtain the weight of the monitored target based on the actual length and actual width, combined with the third formula; The third formula may include:
[0123] in, For weight, This is the actual length. This is the actual width. This is the width threshold. , , , The coefficients of the first formula are... , , , This is the coefficient of the second formula.
[0124] In one possible implementation, the above-described apparatus may further include: The threshold determination module is used to determine the width threshold using a grid search algorithm with width as the variable. The first coefficient output module is used to determine the coefficients of the first formula based on the first sample set using a multiple linear regression algorithm; wherein the actual width of each sample in the first sample set is less than the width threshold. The second coefficient output module is used to determine the coefficients of the second formula based on the second sample set using a multiple linear regression algorithm; wherein the actual width of each sample in the second sample set is not less than the width threshold. The formula output module is used to determine the third formula based on the coefficients of the first and second formulas.
[0125] Figure 12 This is a schematic diagram of the electronic device 3 provided in an embodiment of the present invention. Figure 12 As shown, the electronic device 3 of this embodiment includes a processor 30 and a memory 31. The memory 31 stores a computer program 32. When the processor 30 executes the computer program 32, it implements the steps in the various method embodiments described above. Alternatively, when the processor 30 executes the computer program 32, it implements the functions of each module / unit in the various device embodiments described above.
[0126] For example, computer program 32 may be divided into one or more modules / units, which are stored in memory 31 and executed by processor 30 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 32 in electronic device 3.
[0127] Electronic device 3 may include, but is not limited to, processor 30 and memory 31. Those skilled in the art will understand that... Figure 12 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 3 may also include input / output devices, network access devices, buses, etc.
[0128] The processor 30 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0129] The memory 31 can be an internal storage unit of the electronic device 3, such as a hard disk or memory of the electronic device 3. The memory 31 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 3. Furthermore, the memory 31 can include both internal and external storage units of the electronic device 3. The memory 31 is used to store the computer program 32 and other programs and data required by the electronic device 3. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0130] For the sake of simplicity and clarity, only the above-described functional modules / units are used as examples. In practical applications, the functions described above can be assigned to different functional modules / units as needed. These modules / units can be implemented in hardware, software, or a combination of both.
[0131] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.
[0132] This invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.
[0133] Computer programs include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0134] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not detailed or described in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Unless otherwise specified or in conflict with logic, the terminology and / or descriptions between different embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.
[0135] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A scale-based underwater target monitoring method, characterized in that, include: Acquire a target image; wherein the target image contains a monitoring target and a ruler, and the ruler is rectangular; The target image is identified using an improved YOLOv8-obb algorithm to obtain the pixel size of the monitored target; Contour detection is performed on the target image to obtain the pixel dimensions of the ruler; The actual size of the monitored target is determined based on the pixel size of the monitored target, the pixel size of the scale, and the actual size of the scale.
2. The underwater target monitoring method based on a scale according to claim 1, characterized in that, The pixel dimensions of the monitored target include: center point coordinates, target width, target length, and rotation angle; the pixel dimensions of the scale include: scale width and scale length; determining the actual size of the monitored target based on the pixel dimensions of the monitored target, the pixel dimensions of the scale, and the actual size of the scale includes: The physical length corresponding to a single pixel is determined based on the pixel size of the scale and the actual size of the scale. Based on the pixel size of the monitored target, determine the four corner points of the monitored target; Based on the four corner points, determine the pixel values of the body width and body length of the monitored target; The actual length and actual width of the monitored target are determined based on the width pixel value, the length pixel value, and the physical length corresponding to a single pixel.
3. The underwater target monitoring method based on a scale according to claim 2, characterized in that, The step of determining the four corner points of the monitored target based on the pixel size of the monitored target includes: Based on the pixel size of the monitored target, the four corner points of the monitored target are determined using the first formula; The first formula includes: in, Let be a rotation matrix. For rotation angle, and It is a semi-axis vector. The target width, For the target length, , , , These are the four corner points; Let be a coordinate vector, ( ( ) represents the coordinates of the center point.
4. The underwater target monitoring method based on a scale according to any one of claims 1 to 3, characterized in that, The step of performing contour detection on the target image to obtain the pixel dimensions of the scale includes: The target image is detected using adaptive threshold segmentation to obtain a first detection result; The target image is detected using the Canny edge detection algorithm to obtain a second detection result; The first detection result and the second detection result are fused to obtain a candidate contour set; The candidate contour set is filtered by area and rectangle to obtain the ruler contour; The pixel size of the ruler is determined based on the ruler outline.
5. The underwater target monitoring method based on a scale according to claim 4, characterized in that, The scale is a black and white grid scale.
6. The underwater target monitoring method based on a scale according to any one of claims 1 to 3, characterized in that, The improved YOLOv8-obb includes: an MLLA attention module, a SAConv spatial adaptive convolutional layer, and a DySample dynamic upsampling module; The MLLA attention module is located in the last layer of the backbone network; The SAConv spatial adaptive convolutional layer is applied to all standard convolutional operations in the improved YOLOv8-obb; The DySample dynamic upsampling module is applied to all upsampling operations in the improved YOLOv8-obb.
7. The underwater target monitoring method based on a scale according to any one of claims 1 to 3, characterized in that, The loss function of the improved YOLOv8-obb model is the second formula; The second formula includes: in, The loss function for the improved YOLOv8-obb model; It is the gradient gain factor. For the final weighted mapping; For outlier degree, , For hyperparameters, For distance attention, For bounding box loss based on intersection-union ratio, This represents the average sliding loss. For intersection, union, and comparison; , ( ) represents the x and y coordinates of the center point of the prediction box; , () represents the x and y coordinates of the center point of the true bounding box; , These are the width and height of the minimum bounding rectangles of the predicted bounding box and the ground truth bounding box, respectively; The separation operation in the computation graph.
8. The underwater target monitoring method based on a scale according to any one of claims 1 to 3, characterized in that, The monitoring target is a sea cucumber, and the actual dimensions of the monitoring target include: actual length and actual width; the method further includes: The weight of the monitored target is obtained based on the actual length and the actual width, combined with the third formula. The third formula includes: in, The weight is mentioned. The actual length, The actual width, This is the width threshold. , , , The coefficients of the first formula are... , , , This is the coefficient of the second formula.
9. The underwater target monitoring method based on a scale according to claim 8, characterized in that, Before obtaining the weight of the monitored target based on the actual length and the actual width using the third formula, the method further includes: Using width as a variable, a grid search algorithm is used to determine the width threshold; Based on the first sample set, the coefficients of the first formula are determined using a multiple linear regression algorithm; wherein, the actual width of each sample in the first sample set is less than the width threshold. Based on the second sample set, the coefficients of the second formula are determined using a multiple linear regression algorithm; wherein, the actual width of each sample in the second sample set is not less than the width threshold. The third formula is determined based on the coefficients of the first formula and the coefficients of the second formula.
10. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the scale-based underwater target monitoring method as described in any one of claims 1 to 9.