Sturgeon rollover detection method and system based on deep learning and ellipse fitting

Through deep learning and elliptical fitting methods, combined with preprocessing and semantic segmentation technology, the problem of rollover detection in complex environments in sturgeon farms is solved, and high-precision and robust automated monitoring is achieved, which reduces manual inspection costs and improves breeding efficiency and caviar quality.

CN120472501APending Publication Date: 2025-08-12GUANGDONG OCEAN UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510656401.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

The existing automated monitoring methods of sturgeon farms are difficult to achieve high-precision and robust sturgeon rollover detection in complex environments (such as high light reflection at noon and turbid water quality), resulting in low detection accuracy and poor robustness, which is difficult to meet the actual application needs.

Method used

Using deep learning and ellipse fitting methods, after pre-treatment (dynamic interference removal, noise removal, light correction and water quality turbidity correction), deep learning model is used for semantic segmentation, binary masks are generated and morphological processing is performed, and the flip angle is calculated in combination with ellipse fitting to determine whether the flip and flip degree of sturgeon has been flipped.

Benefits of technology

It realizes high-precision and robust sturgeon overturn detection, reduces manual inspection costs, improves breeding efficiency, ensures the health of sturgeon and the production quality of caviar, and has a certain degree of versatility that can be applied to sturgeon detection of other fish.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120472501A_ABST
    Figure CN120472501A_ABST
Patent Text Reader

Abstract

The invention provides a sturgeon rollover detection method and system based on deep learning and ellipse fitting. The method comprises the following steps: acquiring a sturgeon image and preprocessing the sturgeon image; performing semantic segmentation on the preprocessed sturgeon image by using a pre-trained deep learning model; according to the semantic segmentation result, binary masks of the back area and the belly area of each sturgeon are generated, and noise areas in the masks are removed through morphological processing and connected domain analysis; respectively performing ellipse fitting on the denoised back and belly region pixel sets of each sturgeon, extracting long axis direction angles of the back and belly ellipses of each sturgeon, further calculating a rollover angle, and judging whether the sturgeon has rollover or not and the rollover degree according to the rollover angle; according to the method, high-robustness and high-precision automatic monitoring can be realized in complex environments such as strong light reflection and turbid water quality, so that the manual inspection cost is remarkably reduced, the culture efficiency is improved, and sturgeon health and caviar production quality are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automated monitoring of aquaculture, and more specifically, to a sturgeon rollover detection method and system based on deep learning and ellipse fitting. Background Art

[0002] In sturgeon aquaculture, particularly for high-value sturgeon farms used for caviar production, fish health is directly linked to profitability and caviar yield. Sturgeon capsizing is often an early sign of health problems, such as hypoxia, disease, or water quality issues. If not detected and addressed promptly, it can lead to widespread mortality and severe economic losses.

[0003] Traditional sturgeon farms rely mainly on manual inspections to monitor fish status. However, manual inspections have the following significant drawbacks: 1) Inefficiency: Breeding ponds are usually large, with large numbers of sturgeons. Manual inspections are time-consuming and labor-intensive, making it impossible to achieve all-weather, real-time monitoring. 2) Susceptible to subjective factors: The experience and subjective judgment of inspectors may lead to missed inspections or misjudgments. Especially in complex environments such as strong reflections at noon and turbid water, it is difficult to accurately identify the sideways state of sturgeons. 3) High labor costs: Manual inspections require a lot of manpower, significantly increasing breeding costs.

[0004] To solve the above problems, some automated monitoring methods have been proposed, but existing technologies still have obvious limitations: 1) Threshold-based methods: These methods use simple grayscale or color thresholds to distinguish between the back and belly of sturgeons. However, due to their susceptibility to interference from factors such as light fluctuations (such as strong glare at noon) and turbid water (due to direct use of unfiltered mountain and river water for aquaculture), these methods have poor robustness and a high failure rate, making them difficult to apply in actual aquaculture environments. 2) Shape-based methods: For example, methods based on principal component analysis (PCA) can extract the shape features of the fish body. However, these methods are very sensitive to changes in the sturgeon's body shape (such as body bending or changes in posture in the water), resulting in unstable detection results. 3) Deep Learning-Based Object Detection Methods: Existing deep learning methods (such as the YOLO-based object detection method in patent publication "CN117197553A") can be used to locate fish and provide a bounding box for the fish body, but they do not yet segment the sturgeon's back and abdomen, making it difficult to achieve accurate rollover detection. 4) U-Net-based semantic segmentation method: The U-Net-based semantic segmentation method can segment the fish body, but it is not optimized for complex scenarios such as the special features of the sturgeon's dorsal bony plates and strong light reflections to accurately detect sturgeon rollover.

[0005] Therefore, the current automated monitoring methods have problems such as low segmentation accuracy, sensitivity to illumination changes, and insufficient robustness, making them difficult to meet the needs of practical applications. Summary of the Invention

[0006] To overcome the shortcomings of the above-mentioned existing technologies in detecting sturgeon rollovers, such as low accuracy and poor robustness in complex environments (such as strong sunlight reflections at noon and turbid water), the present invention provides a sturgeon rollover detection method and system based on deep learning and ellipse fitting. This method can achieve highly robust and high-precision automated monitoring, thereby significantly reducing manual inspection costs, improving breeding efficiency, and ensuring the health of sturgeons and the production quality of caviar.

[0007] In order to solve the above technical problems, the technical solutions of the present invention are as follows: A sturgeon rollover detection method based on deep learning and ellipse fitting includes the following steps: S1: Collecting sturgeon images and performing preprocessing; the preprocessing includes at least: dynamic interference removal, denoising, illumination correction, and water turbidity correction; S2: performing semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; S3: Based on the semantic segmentation results, a binary mask of the back and abdomen of each sturgeon is generated. The noise area in the mask is removed through morphological processing and connected domain analysis to obtain the denoised pixel set of the back and abdomen of each sturgeon. S4: Ellipse fitting is performed on the pixel sets of the back and abdomen areas of each sturgeon after denoising, and the major axis direction angle of the ellipse of the back and abdomen of each sturgeon is extracted. The rollover angle is further calculated, and the rollover angle is used to determine whether the sturgeon has rolled over and the degree of the rollover.

[0008] Preferably, in step S1, an inter-frame difference algorithm is used to remove dynamic interference, a median filter and a Gaussian filter are used for denoising, a contrast-limited adaptive histogram equalization algorithm is used for illumination correction, and a gray-world algorithm is used for water turbidity correction to complete the preprocessing.

[0009] Preferably, in step S2, the deep learning model is specifically a DeepLabV3+ neural network model.

[0010] Preferably, in step S2, the adaptive weighted cross entropy loss function is specifically:

[0011] Where L is the adaptive weighted cross entropy loss function value; N is the total number of pixels in the image; i is the pixel index; 、 and are the weights of background pixels, back pixels, and abdomen pixels, respectively; 、 and are the true labels of background pixels, back pixels, and abdomen pixels respectively; 、 and are the predicted probabilities of background pixels, back pixels, and belly pixels, respectively; The weight of the back pixel Calculated according to the following formula:

[0012] in, is the number of pixels in the sturgeon dorsal bone plate area in the current image; is the total number of pixels in the entire back area of the sturgeon in the current image; is the preset bone plate weight coefficient.

[0013] Preferably, in step S3, the morphological processing includes an erosion operation and a dilation operation; The connected domain analysis includes: using the 8-connectivity labeling algorithm to find all connected regions on the binary mask after morphological processing, calculating the area of each connected region, setting an area threshold, and removing all connected regions with an area smaller than the area threshold to complete the connected domain analysis.

[0014] Preferably, in step S4, the RANSAC algorithm is used to perform ellipse fitting on the denoised pixel sets of the back and abdomen regions of each sturgeon to obtain the back ellipse and abdomen ellipse of each sturgeon.

[0015] Preferably, in step S4, the fitting equation of the ellipse is expressed as:

[0016] in, is the coordinate of the point on the ellipse; A 、 B 、 C 、 D 、 E and F are the first to sixth fitting parameters of the ellipse respectively; The major axis direction angle of the ellipse is further extracted according to the following formula :

[0017] Calculate the rollover angle using the following formula :

[0018] in, and represent the major axis direction angles of the dorsal ellipse and the abdominal ellipse respectively; Indicates the absolute value symbol.

[0019] Preferably, the step S4 further includes: The pixel sets of the back and abdomen regions of each sturgeon after denoising were converted from RGB color space to HSV color space, and the average hue values of the back and abdomen regions were calculated respectively. The hue value difference between the back and abdomen regions of each sturgeon was further calculated. Whether the sturgeon has flipped and the degree of flipping are comprehensively determined based on the flipping angle and hue value difference.

[0020] Preferably, whether the sturgeon has rolled over and the degree of the rollover are comprehensively determined according to the following rules: like and , it is judged to be normal; if or , it is determined to be a rollover; like and , it is determined to be a moderate rollover; if or , it is determined to be a serious rollover; in, Indicates the rollover angle; Indicates the difference in tonal value between the dorsal and ventral regions of the sturgeon; and They represent the rollover angle threshold and hue value difference threshold respectively; k is a proportional coefficient greater than 1.

[0021] The present invention also provides a sturgeon rollover detection system based on deep learning and ellipse fitting, which applies the above-mentioned sturgeon rollover detection method, including: Preprocessing module: used to collect sturgeon images and perform preprocessing; the preprocessing includes at least: dynamic interference removal, denoising, illumination correction and water turbidity correction; Semantic segmentation module: used to perform semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; Mask generation module: This module generates binary masks for the back and abdomen of each sturgeon based on the semantic segmentation results. It then removes the noise from the masks through morphological processing and connected domain analysis to obtain the denoised pixel sets for the back and abdomen of each sturgeon. Rollover detection module: It is used to perform ellipse fitting on the pixel sets of the dorsal and abdominal regions of each sturgeon after denoising, extract the major axis direction angle of each sturgeon's dorsal and abdominal ellipse, and further calculate the rollover angle. Based on the rollover angle, it is determined whether the sturgeon has rolled over and the degree of rollover.

[0022] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: The present invention provides a sturgeon rollover detection method and system based on deep learning and ellipse fitting. First, sturgeon images are collected and preprocessed. The preprocessing includes at least: dynamic interference removal, denoising, illumination correction, and water turbidity correction. Then, semantic segmentation is performed on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon. The pre-trained deep learning model is trained based on an adaptive weighted cross-entropy loss function. Then, based on the semantic segmentation results, a binary mask of the back and abdomen regions of each sturgeon is generated. Noise regions in the mask are removed through morphological processing and connected domain analysis to obtain a denoised pixel set of the back and abdomen regions of each sturgeon. Finally, ellipse fitting is performed on the denoised pixel sets of the back and abdomen regions of each sturgeon to extract the major axis direction angle of the ellipse of the back and abdomen of each sturgeon, and the rollover angle is further calculated. Whether the sturgeon has rolled over and the degree of the rollover are determined based on the rollover angle. The present invention has the following advantages: 1) High-precision detection: The semantic segmentation method proposed in this paper, based on a deep learning model and an adaptive weighted loss function, combined with the characteristics of the sturgeon's dorsal bony plates, can achieve high-precision segmentation of the sturgeon's back, thereby accurately detecting the sturgeon's rollover state, thus overcoming the accuracy shortcomings of existing methods. 2) Robustness: This invention utilizes pre-processing techniques such as illumination correction and grayscale color balancing to address the low detection accuracy often caused by strong light reflections and turbid water in aquaculture environments. In addition to rollover angle, the invention also incorporates the color differences between the sturgeon's back and abdomen to aid in determining rollover status. The combined application of these techniques improves detection robustness and accuracy in complex environments. 3) Cost reduction: The present invention can realize automatic monitoring of sturgeon rollover, reduce reliance on manual inspections, and significantly reduce the frequency of manual inspections, thereby saving labor costs; 4) Real-time monitoring and early warning: This invention can achieve closed-loop management from sturgeon capsizing detection to early warning. Through real-time monitoring and rapid early warning, it can effectively shorten emergency response time and buy valuable time for timely intervention measures; 5) Improved economic benefits: The present invention can detect and intervene in the rollover in a timely manner, thereby reducing the mortality of sturgeons caused by rollover and reducing economic losses for farmers; 6) Good promotion prospects: The method proposed in this invention has certain versatility and can be promoted and applied to the rollover detection of other fish with similar characteristics (such as carp, grass carp, etc.), and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a flow chart of a sturgeon rollover detection method based on deep learning and ellipse fitting provided in Example 1.

[0024] Figure 2 This is a flow chart of a sturgeon rollover detection method based on deep learning and ellipse fitting provided in Example 2.

[0025] Figure 3 This is the back ellipse fitting flow chart provided in Example 2. DETAILED DESCRIPTION

[0026] The accompanying drawings are for illustrative purposes only and are not to be construed as limiting the present application; In order to better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size; It is understandable to those skilled in the art that some well-known structures and descriptions thereof may be omitted in the drawings.

[0027] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.

[0028] Example 1 like Figure 1 As shown, this embodiment provides a sturgeon rollover detection method based on deep learning and ellipse fitting, comprising the following steps: S1: Collecting sturgeon images and performing preprocessing; the preprocessing includes at least: dynamic interference removal, denoising, illumination correction, and water turbidity correction; S2: performing semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; S3: Based on the semantic segmentation results, a binary mask of the back and abdomen of each sturgeon is generated. The noise area in the mask is removed through morphological processing and connected domain analysis to obtain the denoised pixel set of the back and abdomen of each sturgeon. S4: Ellipse fitting is performed on the pixel sets of the back and abdomen areas of each sturgeon after denoising, and the major axis direction angle of the ellipse of the back and abdomen of each sturgeon is extracted. The rollover angle is further calculated, and the rollover angle is used to determine whether the sturgeon has rolled over and the degree of the rollover.

[0029] In the specific implementation process, firstly, the sturgeon image is collected and preprocessed; in this embodiment, the preprocessing includes at least: dynamic interference removal, denoising, illumination correction and water turbidity correction; The pre-processed sturgeon images were then semantically segmented using a pre-trained deep learning model to obtain segmentation results for the dorsal and ventral regions of each sturgeon. The pre-trained deep learning model was trained using an adaptive weighted cross-entropy loss function to improve the segmentation accuracy of the dorsal region. Then, based on the semantic segmentation results, a binary mask of the back and abdomen of each sturgeon was generated. The noise areas in the mask were removed through morphological processing and connected domain analysis to obtain the denoised pixel sets of the back and abdomen regions of each sturgeon. Finally, ellipse fitting was performed on the pixel sets of the back and abdomen regions of each sturgeon after denoising. The major axis direction angle of each sturgeon's back and abdomen ellipse was extracted, and the rollover angle was further calculated. Based on the rollover angle, it was determined whether the sturgeon had rolled over and the degree of rollover. The sturgeon rollover detection method proposed in this embodiment can effectively solve the problems of low efficiency, susceptibility to subjective factors, and high cost of traditional manual inspections, as well as the problems of low accuracy and poor robustness of existing automated monitoring methods in strong light reflection and turbid water environments.

[0030] Example 2 like Figure 2 As shown, this embodiment provides a sturgeon rollover detection method based on deep learning and ellipse fitting, comprising the following steps: S1: Collecting sturgeon images and performing preprocessing; the preprocessing includes at least: dynamic interference removal, denoising, illumination correction, and water turbidity correction; S2: performing semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; S3: Based on the semantic segmentation results, a binary mask of the back and abdomen of each sturgeon is generated. The noise area in the mask is removed through morphological processing and connected domain analysis to obtain the denoised pixel set of the back and abdomen of each sturgeon. S4: Ellipse fitting is performed on the pixel sets of the back and abdomen regions of each sturgeon after denoising, and the major axis direction angle of the ellipse of the back and abdomen of each sturgeon is extracted, and the rollover angle is further calculated; The pixel sets of the back and abdomen regions of each sturgeon after denoising were converted from RGB color space to HSV color space, and the average hue values of the back and abdomen regions were calculated respectively. The hue value difference between the back and abdomen regions of each sturgeon was further calculated. Whether the sturgeon has flipped and the degree of flipping are comprehensively determined based on the flipping angle and hue value difference.

[0031] In the specific implementation process, the computing device of this embodiment uses a computer equipped with an Intel Core i7-9700K processor, 16GB of memory and an NVIDIA GeForce RTX 3060 graphics card as an image processing server; this configuration can meet the needs of real-time processing, the operating system is Ubuntu 20.04 LTS, the programming language is Python 3.8, the deep learning framework is PyTorch 1.9.0, the image processing library is OpenCV 4.5.1, CUDA is 11.1 (for GPU acceleration), and cuDNN is 8.0.5 (for GPU acceleration); First, sturgeon images are captured. In this embodiment, an industrial-grade above-water or underwater camera is used to capture images or video frames. For example, a Hikvision DS-2CD3T47WDV3-L camera is used for acquisition. This camera has a high resolution of 1920×1080, a frame rate of 30fps, and a lens focal length of 4mm, which can clearly capture details of the sturgeons in the breeding pond. The camera is installed above the breeding pond, approximately 1.5 meters above the water surface, at an angle of 15-30 degrees to the horizontal plane to obtain an optimal shooting angle, minimize the impact of surface reflections, and ensure that the activities of most sturgeons can be monitored. The camera field of view must cover the main area of the breeding pond. The acquisition frequency is set to one frame per minute. The frequency is selected to ensure that the sturgeons can be detected in time when they turn over, while avoiding the generation of excessive redundant data and increasing the computational burden. The method in this embodiment is adaptable to various environmental conditions, including water depths of 0.5-2 meters, water turbidity of 0-50 NTU (nephelometric turbidity units), and different lighting conditions such as daytime, evening, and nighttime. In actual sturgeon farming environments, the quality of underwater images is affected by multiple factors, the most important of which are strong midday sunlight reflections and varying degrees of turbidity in the river water. Strong sunlight reflections can cause local overexposure in the image, obscuring the texture details of the sturgeon. Turbid water can lead to overall color cast and reduced contrast in the image, making it difficult to distinguish between the sturgeon's back and abdomen. These problems seriously affect the accuracy and robustness of subsequent semantic segmentation. Traditional image enhancement methods, such as global histogram equalization, are often unable to effectively handle these local and non-uniform illumination / color variations and may even exacerbate noise. To address these two major challenges of strong midday sunlight reflections and turbid water, this method designs a series of sophisticated preprocessing steps to significantly improve image quality and provide a guarantee for subsequent segmentation. In this embodiment, the following preprocessing is performed after the image is collected: dynamic interference removal, denoising, illumination correction, and water turbidity correction, as follows: 1) Dynamic interference removal: In aquaculture environments, in addition to the target sturgeons, there may be other moving objects, such as water waves, floating objects, and fast-swimming non-target fish. These dynamic interferences will affect subsequent segmentation and rollover detection. Therefore, it is necessary to remove these dynamic areas from the image and only analyze the stationary or slow-swimming sturgeons. This embodiment uses an inter-frame difference algorithm to remove dynamic interference caused by the rapid swimming of non-target fish, water waves, and floating objects. The inter-frame difference algorithm detects motion by comparing the difference in pixel values between two adjacent frames. If the pixel value changes significantly, exceeding a set threshold, the pixel is considered to belong to a moving object (moving area). The inter-frame difference method is simple and efficient, with simple calculations and high speed, which can meet the needs of real-time processing. At the same time, the algorithm is adaptable to the breeding environment and has a certain degree of robustness to changes in lighting. Although water waves and lighting changes can also cause pixel value changes, these changes are usually slow and uniform, while the pixel value changes caused by fast-moving fish are more dramatic and easier to detect. The algorithm flow is as follows: 1.1) Read two consecutive frames of image: I t (Current Frame) and I t-1 (previous frame); 1.2) Grayscale (optional): If the original image is in color, it can be converted to a grayscale image to reduce the amount of computation; 1.3) Calculate the difference image: D(x,y)=|I t (x,y)-I t-1 (x,y)|; Among them, I t (x,y) and I t-1(x, y) represents the RGB value (or grayscale value) of the current frame and the previous frame at the pixel point (x, y), and D(x, y) represents the pixel value of the difference image at the corresponding position; 1.4) Binarization: B(x,y)={1,if D(x,y)>T d ;0,otherwise}; Among them, T d is the preset differential threshold, B(x, y) is the binarized image; a pixel value of 1 indicates that the pixel belongs to the dynamic area, and a pixel value of 0 indicates that the pixel belongs to the static area; In this embodiment, the threshold value T d The choice of T needs to be adjusted according to the actual situation. d Too small will lead to water waves, lighting changes, etc. being misjudged as motion areas, resulting in excessive removal; d If the value is too large, it will fail to detect slow-moving fish, resulting in missed detections. By conducting experiments on the actual farm images collected, the detection effects under different thresholds are observed, and a threshold that can effectively remove the interference of fast movement while retaining slow-moving or stationary sturgeons is selected; for example, one can start with a small value (such as 10), gradually increase the threshold, observe the detection results, and find an optimal value; according to experience, T d The value of is usually set between 20 and 40 (for 8-bit grayscale images); in this embodiment, after experiments, T d =30 proved to be a more appropriate value; 1.5) Mask application: The binary image B(x,y) is applied to the original image as a mask to remove all detected dynamic areas. 2) Denoising: 2.1) Use median filtering to remove salt and pepper noise (for example, noise caused by suspended particles in water) from images. Median filtering is a nonlinear statistical sorting filtering method that replaces the grayscale value of each pixel with the median of all pixels within its neighborhood window. Median filtering effectively suppresses salt and pepper noise while preserving image edges and avoiding excessive blurring. In this embodiment, the formula for median filtering is as follows: I_out(x,y)=median{I_in(x+i,y+j)|(i,j) belongs to W} Where: I_in(x,y) represents the pixel value of the input image at the coordinate (x,y); I_out(x,y) represents the pixel value of the output image at the coordinate (x,y); W represents a 3×3 neighborhood window, more specifically, W={(i,j)|-1<=i<=1,-1<=j<=1}; For example, suppose the grayscale values of a pixel (assuming the original value is 255) and its 3×3 neighborhood are [120, 255, 130, 125, 255, 128, 132, 127, 129]. After median filtering, these grayscale values are first sorted as [120, 125, 127, 128, 129, 130, 132, 255, 255]. Then, the middle value 128 is taken as the new grayscale value of the pixel. This example shows that median filtering effectively removes salt and pepper noise (the extreme value of 255). 2.2) Use Gaussian filtering to smooth the image and remove Gaussian noise (for example, noise caused by uneven lighting and sensor noise). Gaussian filtering is a linear smoothing filtering method that uses a Gaussian function (normal distribution function) as a convolution kernel to perform a weighted average of the image. The new value of each pixel is the weighted average of its neighboring pixels, with the weight determined by the Gaussian kernel. Pixels closer to the center pixel have a larger weight. Each pixel value (x, y) of the output image I_out is calculated using the following formula: I_out(x,y)=Σ[I_in(x+i,y+j)G(i,j)] for all (i,j) belonging to W Where: I_in(x,y) represents the pixel value of the input image at coordinate (x,y); I_out(x,y) represents the pixel value of the output image (after filtering) at coordinate (x,y); W is the convolution kernel window (usually a square, such as 5×5), W={(i,j)|-k<=i<=k,-k<=j<=k}, where 2k+1 is the side length of the convolution kernel; G(i,j) is the value of the Gaussian kernel at position (i,j); The Gaussian kernel function is defined as: G(i,j)=(1 / (2πσ²))exp(-(i²+j²) / (2σ²)) Where σ represents the standard deviation of the Gaussian distribution. σ controls the "width" of the Gaussian function, thus determining the smoothness of the filter. The larger the σ value, the stronger the filtering effect (the blurrier the image). The value of σ usually needs to be adjusted according to the degree of image noise and the desired smoothness. The size of the Gaussian kernel is usually an odd number (such as 3×3, 5×5, 7×7, etc.); a larger kernel will produce a stronger smoothing effect, but may also cause loss of image details; the choice of σ is related to the kernel size. A rule of thumb is that the kernel size is about 6σ (rounded up to the nearest odd number); for example, if σ = 1.5, the kernel size can be chosen to be 61.5 = 9, rounded up to the nearest odd number of 9, and a 9×9 convolution kernel is used; Gaussian filtering can effectively smooth images and remove Gaussian noise. At the same time, by controlling the σ parameter, it can balance the denoising effect and image detail preservation, which is very effective in suppressing uneven illumination and sensor noise. Gaussian kernel calculation and normalization example (σ=1.5, 5×5 kernel): a) Calculate the original Gaussian value: Take the center point of the kernel as the origin (0,0) and calculate the G(i,j) value at each position (i,j) according to the Gaussian function formula; for example: Center point: G(0,0)=(1 / (2π1.5²))exp(-(0²+0²) / (21.5²))≈0.070735; Neighborhood point: G(1,1)=(1 / (2π1.5²))exp(-(1²+1²) / (21.5²))≈0.045345; b) Normalization: Add up all calculated G(i,j) values to get a sum S; then, divide each G(i,j) value by S to get the normalized Gaussian kernel G'(i,j); the purpose of normalization is to ensure that the overall brightness of the filtered image does not change too much; the normalization formula is: G'(i,j)=G(i,j) / S; c) Example of a normalized 5×5 Gaussian kernel (σ=1.5): [[0.018316,0.028379,0.032489,0.028379,0.018316], [0.028379,0.043938,0.050296,0.043938,0.028379], [0.032489,0.050296,0.057576,0.050296,0.032489], [0.028379,0.043938,0.050296,0.043938,0.028379], [0.018316,0.028379,0.032489,0.028379,0.018316]]; 3) Lighting correction: In this embodiment, the contrast-limited adaptive histogram equalization (CLAHE) algorithm is used to enhance local image contrast, reduce the impact of strong light reflections, and avoid excessive noise enhancement. CLAHE is a local adaptive contrast enhancement method that divides the image into multiple small, non-overlapping regions (called "tiles") and performs histogram equalization on each tile. Unlike traditional global histogram equalization, CLAHE prevents excessive noise enhancement by limiting the degree of contrast amplification. The specific steps are as follows: 3.1) Tiling: Divide the input image into M×N tiles of equal size. For example, a 1920x1080 image can be divided into 8×8 tiles, where each tile is 240x135 pixels in size. 3.2) Calculation of histogram and contrast limit (Histogram Calculation and Clipping): Calculate the grayscale histogram for each tile; Set a "clip limit", usually expressed as a percentage of the maximum bin height in the original histogram (for example, 0.01 or 1%); Traverse each bin of the histogram, and if the height of the bin exceeds the clipping threshold, the excess part will be clipped; Sum up the number of pixels that were clipped and redistribute this total evenly across all histogram bins; this prevents excessive peaks in the histogram, thus limiting excessive contrast enhancement. 3.3) Histogram Equalization: For each tile, use its clipped and redistributed histogram to equalize it; Calculate the cumulative distribution function (CDF): CDF(r)=Σ[p(i)] for all i<=r Where: r represents the original grayscale value (0 to L-1, where L is the number of grayscale levels, usually 256); p(i) represents the probability of grayscale value i appearing in the tile (histogram after clipping and redistribution); CDF(r): the cumulative probability of grayscale value less than or equal to r; Calculate the mapping function: T(r)=(L-1)CDF(r) Where T(r) represents the new grayscale value mapped to the original grayscale value r; Apply mapping: replace the original grayscale value r of each pixel in the tile with T(r); 3.4) Interpolation: Since each tile is processed independently, directly stitching them together may produce obvious boundaries between tiles (blocking effect). To eliminate these boundaries, bilinear interpolation is usually used to smooth the transition between adjacent tiles. Parameter Selection: The key parameters of CLAHE are tile size and clipping threshold. Smaller tiles enhance local contrast, but also tend to amplify noise. Higher clipping thresholds enhance contrast, but also tend to produce artifacts. These parameters need to be adjusted based on the specific image characteristics. Unlike global histogram equalization, CLAHE effectively suppresses strong light reflections by limiting the amplitude of local contrast enhancement, while avoiding excessive noise enhancement and preserving the texture details of the sturgeon. After CLAHE processing, the grayscale value distribution of the image is more uniform, the brightness of the reflective area is effectively suppressed without being excessively darkened, and the outline and texture details of the sturgeon become clearer; 4) Water turbidity correction: In this example, a grayscale world algorithm (auto white balance) is used to correct color deviations caused by turbid water and enhance the color differences between the sturgeon's back and abdomen. The grayscale world assumption states that for a natural image with sufficient color variation, the average values of its three RGB color channels should tend to the same "gray" value (i.e., the average color of the image should be gray). Turbid water often causes image color casts (for example, greenish or yellowish), and the grayscale world assumption can be used to correct such casts. First calculate the mean of each color channel: μ_R=(1 / N)ΣR_i for all pixels i μ_G=(1 / N)ΣG_i for all pixels i μ_B=(1 / N)ΣB_i for all pixels i Where N is the total number of pixels in the image; R_i, G_i, B_i are the R, G, and B values of the i-th pixel respectively; μ_R, μ_G, and μ_B are the average values of the R, G, and B channels respectively; Calculate the overall average grayscale value: μ_gray=(μ_R+μ_G+μ_B) / 3 Wherein, μ_gray is the average gray value of the image; other gray value calculation methods can also be used, for example, μ_gray=0.299μ_R+0.587μ_G+0.114μ_B; Calculate the adjusted gain for each channel: k_R=μ_gray / μ_R k_G=μ_gray / μ_G k_B=μ_gray / μ_B Among them, k_R, k_G, k_B are the adjustment gains of R, G, and B channels respectively; Multiply the R, G, and B values of each pixel in the image by the corresponding gain to adjust the color value of each pixel: R'_i=k_R·R_i G'_i=k_G·G_i B'_i=k_B·B_i Among them, R'_i, G'_i, B'_i are the adjusted R, G, and B values of the i-th pixel respectively; After this adjustment, the image's color deviation was reduced, the greenish tint was corrected, and the color difference between the sturgeon's back (usually darker) and belly (usually brighter) became more distinct, making it easier to distinguish. The grayscale world hypothesis effectively corrected the overall color deviation caused by turbid water. By adjusting the gain of the three RGB channels, the image's natural color was restored, and the color difference between the sturgeon's back and belly was enhanced, facilitating subsequent segmentation. This method addresses two core challenges in actual sturgeon farming environments: strong midday glare and varying degrees of water turbidity. A novel and effective image preprocessing pipeline is proposed. This pipeline innovatively combines contrast-limited adaptive histogram equalization (CLAHE) with a color balancing method based on the grayscale world hypothesis. First, the CLAHE algorithm effectively suppresses local overexposure caused by strong glare through local contrast enhancement, while avoiding the noise amplification problem that is prone to traditional histogram equalization methods, significantly improving the clarity of sturgeon texture details. Then, the color balancing method based on the grayscale world hypothesis effectively corrects the overall color cast in the image caused by water turbidity, enhancing the color difference between the sturgeon's back and abdomen. The combination of CLAHE and the grayscale world algorithm produces a synergistic effect: CLAHE improves local contrast, enabling the color balance algorithm to perform more accurate color correction on clearer images. This preprocessing process significantly improves the quality of underwater images, reduces the effects of noise, uneven lighting, and color deviation in the images, and provides more reliable input data for subsequent semantic segmentation tasks, thereby improving the accuracy and robustness of sturgeon dorsal and ventral segmentation. Compared with traditional image enhancement methods, the preprocessing process of this method is more targeted and effective, and can better adapt to the complex environment of aquaculture. After preprocessing, the pre-trained deep learning model was used to perform semantic segmentation on the preprocessed sturgeon images to obtain the segmentation results of the back and abdomen regions of each sturgeon; The purpose of this step is to accurately segment the sturgeon's back and abdomen in the image, providing pixel-level classification information for subsequent rollover detection. This embodiment uses the DeepLabV3+ model as the semantic segmentation model and designs an adaptive weighted cross-entropy loss function based on the special morphological characteristics of the sturgeon's dorsal bony plates. This effectively improves the model's segmentation accuracy for the sturgeon's back, especially the dorsal bony plate area. The input of the DeepLabV3+ model is a preprocessed RGB image resized to 512×512 pixels; the output is the segmentation result S, with a size of 512×512. The value of each pixel represents its category: 0 represents background, 1 represents the back of the sturgeon, and 2 represents the belly of the sturgeon. S∈{0, 1, 2} (512×512) ; The DeepLabV3+ model has high accuracy and efficiency in semantic segmentation tasks. Its core components (atrous convolution and ASPP module) can effectively expand the receptive field and extract multi-scale features, thereby improving segmentation accuracy. Compared with the U-Net model, DeepLabV3+ has significant advantages in processing complex backgrounds and detailed information. DeepLabV3+ uses ResNet-50 as the backbone network for extracting image features. ResNet-50 solves the gradient vanishing problem in deep neural network training through residual connections, allowing the network to be trained deeper and thus extract richer features. DeepLabV3+ uses atrous convolution to increase the receptive field without increasing the number of parameters or computational complexity. Atrous convolution expands the receptive field of the convolution kernel by inserting "holes" into the convolution kernel. DeepLabV3+ uses the Spatial Pyramid Pooling (ASPP) module, which contains multiple dilated convolutions with different dilation rates and a global average pooling layer to capture multi-scale contextual information. The ASPP module usually contains a 1×1 convolution (rate=1), three 3×3 convolutions (rate=6, 12, 18) and a global average pooling layer. Convolution kernels with different dilation rates can capture features of different scales, and the global average pooling layer can capture global contextual information. By fusing these features of different scales, the model can improve its ability to segment objects of different sizes. The DeepLabV3+ decoder gradually upsamples the feature maps output by the ASPP module (through methods such as bilinear interpolation), fuses them with the corresponding low-level features in the backbone network, and then performs 1×1 convolution to finally output pixel-level classification results; For DeepLabV3+ model training, this example uses a custom adaptive weighted cross-entropy loss function and optimizes it for the unique features of the sturgeon's dorsal bony plates. The cross-entropy loss function is a commonly used loss function in semantic segmentation tasks. It measures the difference between the predicted result and the true label. The adaptive weighted cross-entropy loss function dynamically adjusts the weights in the loss function based on the characteristics of different categories. The adaptive weight cross entropy loss function is specifically:

[0032] Where L is the adaptive weighted cross entropy loss function value; N is the total number of pixels in the image; i is the pixel index; 、 and are the weights of background pixels, back pixels and abdomen pixels respectively. In this embodiment, =1, =1.2 (given a slightly higher weight considering that there are fewer pixels on the abdomen); 、 and are the true labels (one-hot encoding) for background pixels, back pixels, and belly pixels, respectively. For example, if pixel i belongs to the back, then =1, = =0; 、 and are the predicted probabilities of background pixels, back pixels, and abdomen pixels respectively; by adjusting the weights of different categories, the learning difficulty between different categories can be balanced and the segmentation accuracy of the model for important categories can be improved; Weight of back pixels Calculated according to the following formula:

[0033] in, is the number of pixels in the sturgeon dorsal bone plate area in the current image; is the total number of pixels in the entire back area of the sturgeon in the current image; is the preset bone plate weight coefficient. After experiments, = 0.6 when the model performs best; The value range is 1.0-1.6; The dorsal bony plate of sturgeons is an important morphological feature and the key to distinguishing the back and abdomen. By increasing the weight of the bony plate area, this method can encourage the model to pay more attention to the segmentation of the bony plate area, thereby improving segmentation accuracy. In this embodiment, the training process of the deep learning model is as follows: a) Dataset: 10,000 images were collected from a sturgeon farm and other cooperative farms. The dataset included images of different water qualities (turbidity 0-50 NTU), different lighting conditions (daytime, dusk, nighttime, and strong midday light reflections), different water depths (0.5-2 meters), and images of sturgeons in different postures (normal, slightly capsized, and severely capsized) to ensure the generalization and robustness of the model. The dataset was divided into a training set (8,000 images) and a validation set (2,000 images). The back, abdomen, and background areas of the sturgeons were manually annotated using the LabelMe 4.5.6 tool. During the annotation process, the polygon tool was used to accurately outline the contours of the sturgeon's back and abdomen. For occluded areas, reasonable inferences were made based on the sturgeon's anatomical structure and movement patterns. At the same time, multi-person cross-validation was used for annotation. Each image was independently annotated by at least two annotators. If the annotation results were inconsistent, a third expert would arbitrate to ensure the accuracy and consistency of the annotations. The data distribution is shown in Table 1: Table 1 Data distribution

[0034] Note: Table 1 shows the approximate distribution of the number of images in different categories. Since an image may belong to multiple categories at the same time (for example, an image may be "turbidity 30-50 NTU", "daytime" and "water depth 1-1.5 meters"), the sum of the number of images in each category is greater than the total number of images; b) Data augmentation: Various data augmentation techniques are used to expand the dataset and improve the robustness of the model. Specific operations include random rotation (-30° to 30°), horizontal flipping, random scaling (0.8 to 1.2 times), and brightness adjustment (-0.2 to 0.2). c) Training parameters: Initial learning rate: 0.0001; Learning rate strategy: Use the StepLR strategy for learning rate decay; after every 10 epochs, the learning rate is multiplied by 0.1. StepLR is a simple and effective learning rate decay strategy. In the early stages of training, using a larger learning rate can speed up the model's convergence; in the later stages of training, using a smaller learning rate can enable the model to adjust parameters more finely, avoid oscillation, and improve accuracy. Optimizer: Adam; Adam is an adaptive learning rate optimization algorithm that automatically adjusts the learning rate of each parameter based on the first and second moments of the gradient; the Adam algorithm has shown good performance in many deep learning tasks and is relatively insensitive to the choice of hyperparameters; BatchSize: 16; The selection of BatchSize needs to consider computing resources (GPU memory) and training effect. A too small BatchSize will lead to unstable training and slow convergence. A too large BatchSize will occupy too much GPU memory and may cause memory overflow. At the same time, a too large BatchSize may cause the model to fall into a local optimal solution. 16 is a value that strikes a balance between computing resources and training effect. Epochs: 50; Early stopping mechanism: When the average IoU on the validation set does not improve within 10 consecutive epochs, training is stopped to prevent overfitting; Monitoring: Use TensorBoard to monitor the training process, including loss curves, average IoU, IoU of each category, and periodically save comparison images of the predicted segmentation mask and the actual mask; Hyperparameter optimization: Using grid search method, key hyperparameters such as learning rate and batch size were adjusted to obtain the best model performance; After training, the model has an average IoU of 0.88 on the validation set, an IoU of 0.90 on the back, and an IoU of 0.85 on the abdomen; This method combines the unique characteristics of the sturgeon's dorsal bony plate and innovatively designs an adaptive weighted cross-entropy loss function. This function is specifically optimized for the morphological characteristics of the sturgeon. By dynamically adjusting the weight of the dorsal bony plate region in the loss function, the model's segmentation accuracy for the back, especially the bony plate region, is enhanced. After performing semantic segmentation using the trained DeepLabV3+ model, a binary mask of the back and abdomen of each sturgeon was generated based on the semantic segmentation results. The noise areas in the mask were removed through morphological processing and connected domain analysis to obtain the denoised pixel sets of the back and abdomen regions of each sturgeon. Specifically, the formula of the back mask (M_back) is expressed as: M_back(x, y) = 1 if and only if S(x, y) = 1; otherwise M_back(x, y) = 0; Where M_back(x, y): the pixel value of the back mask at the coordinate (x, y); S(x, y) represents the pixel value of the semantic segmentation result at the coordinate (x, y); (x, y) is the coordinate of the pixel in the image; Mark all back pixels (value 1) in S as 1 in M_back; mark the remaining pixels as 0; that is, use a "template" containing only back information to mark the image; The formula of the abdomen mask (M_belly) is expressed as: M_belly(x, y) = 1 if and only if S(x, y) = 2; otherwise M_belly(x, y) = 0; Where M_belly(x, y) is the pixel value of the belly mask at the coordinate (x, y); S(x, y) is the pixel value of the semantic segmentation result at the coordinate (x, y); (x, y) is the coordinate of the pixel in the image; Mark all belly pixels (value 2) in S as 1 in M_belly; mark the remaining pixels as 0; similar to the back mask, use the belly "template" to mark; Morphological processing includes erosion and dilation operations; both operations are based on a small template called a "structural element" (a 5×5 circular template in this example); the structural element B (circular template) is expressed as: [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0]]; Among them, 1 represents the pixel participating in the operation; 0 represents the pixel not participating in the operation; In this embodiment, M_back and M_belly are first corroded and then expanded respectively; The corrosion formula is: M_out(x, y)=min{M_in(x+i, y+j)|(i, j)∈B} Where M_out(x, y) is the pixel value at coordinate (x, y) in the image after corrosion; M_in(x, y) is the pixel value at coordinate (x, y) in the image before corrosion; (x, y) are the coordinates of the pixel in the image; (i, j) are the pixel coordinates within the structuring element B, relative to the center point; B is the structuring element; min{...} is the minimum value in the set; The center of the structural element B is placed at each pixel position of the image in turn; if B is completely covered in the sturgeon area (i.e., all pixel values covered by B are 1), the center pixel remains 1; otherwise, the center pixel is set to 0 (background); the erosion operation can remove noise (small spots) smaller than the structural element; The expansion formula is: M_out(x, y)=max{M_in(x+i, y+j)|(i, j)∈B} Where M_out(x, y) is the pixel value at coordinate (x, y) of the image after expansion; M_in(x, y) is the pixel value at coordinate (x, y) of the image before expansion; (x, y) are the coordinates of the pixel in the image; (i, j) are the pixel coordinates within the structuring element B, relative to the center point; B is the structuring element; max{...} is the maximum value in the set; Place the center of the structural element B at each pixel position of the image in turn; if any pixel in the area covered by B belongs to the sturgeon area (value 1), the center pixel is set to 1; otherwise, it remains 0; the dilation operation can fill holes smaller than the structural element and smooth the edges; Example: Assume there is a small noise block (10 pixels) in the back mask (M_back). First, erode the small noise block. Since it is smaller than the structural element, it will be completely eliminated. Then, dilate the back edge slightly after erosion. The dilation operation restores the edge while maintaining smoothness, resulting in a clean and smooth sturgeon back region. After morphological processing, there may still be some small noise areas in the binary mask (for example, caused by water surface reflections, suspended matter, etc.). The purpose of connected domain analysis is to remove these small noise areas and retain only the larger connected areas corresponding to the sturgeon body. In this embodiment, 8-connectivity is used to perform connected domain analysis. The definition of 8-connectivity is: for a pixel in a binary image, its 8 adjacent pixels (upper, lower, left, right, upper left, upper right, lower left, and lower right) are considered connected. If there is a path of connected pixels between two pixels, the two pixels are considered to belong to the same connected region. 8-connectivity can better connect adjacent pixels to form a more complete connected region, avoiding segmenting the fish body into multiple parts. Compared with 4-connectivity (which only considers the four directions of up, down, left, and right), 8-connectivity is more sensitive to diagonal connections and is more suitable for detecting slender and curvy sturgeon bodies. The specific process of connected domain analysis is as follows: for the binary mask after morphological processing (for example, M_back or M_belly), use the 8-connectivity labeling algorithm (for example, the Two-Pass algorithm) to find all connected regions and assign a unique label to each connected region; calculate the area (i.e., the number of pixels) of each connected region, set an area threshold A_threshold (for example, A_threshold = 500 pixels), and remove the connected regions with an area smaller than A_threshold (set their pixel values to 0); The threshold A_threshold needs to be adjusted according to the actual situation. If A_threshold is too small, the noise area cannot be removed. If A_threshold is too large, small sturgeons or parts of the sturgeon body may be misclassified as noise, resulting in missed detection. By analyzing a large number of actual farm images and statistically analyzing the area distribution of noise areas and valid sturgeon body areas, a threshold that can effectively distinguish between noise and valid targets is selected. Finally, ellipse fitting was performed on the pixel sets of the back and abdomen regions of each sturgeon after denoising. The major axis direction angle of each sturgeon's back and abdomen ellipse was extracted, and the rollover angle was further calculated. Based on the rollover angle, it was determined whether the sturgeon had rolled over and the degree of rollover. To address the sturgeon's slender body, ellipse fitting is performed on the dorsal and ventral pixel sets to accurately and robustly determine its posture. The sturgeon's body typically exhibits a curved, nearly elliptical shape when swimming normally and when flipping sideways. Ellipse fitting is a good way to describe this feature and is robust to noise and small changes in the image. Compared to other shape fitting methods (such as rectangular fitting and polygonal fitting), rectangular fitting cannot accurately reflect the sturgeon's bending form, especially when it rolls over. Although polygonal fitting can describe the shape more precisely, it has too many parameters, is computationally complex, and is easily affected by noise, resulting in unstable fitting results. Elliptical fitting has fewer parameters (only five), is relatively simple to calculate, and can well summarize the sturgeon's overall posture, making it the best choice for this application scenario. This embodiment uses the RANSAC (Random Sample Consensus) algorithm for ellipse fitting. RANSAC is an iterative algorithm that can robustly estimate model parameters from a data set containing "outliers" (noise points). like Figure 3 As shown, for ellipse fitting, the specific steps are as follows (taking back ellipse fitting as an example, the abdominal ellipse fitting steps are the same): In the post-processed back pixel set (the set of pixels with a value of 1 in the binary mask M_back), 5 different pixels are randomly sampled (the ellipse equation has 5 free parameters: A, B, C, D, E, so determining an ellipse requires 5 independent constraints). The general form of the ellipse equation is expressed as:

[0035] in, is the coordinate of the point on the ellipse; A 、 B 、 C 、 D 、 E and F are the first to sixth fitting parameters of the ellipse respectively; Substituting the coordinates of the five sampling points into the ellipse equation, a linear system of five equations is obtained; solving this system of equations (for example, using Gaussian elimination) yields a set of ellipse parameters; Inlier calculation: Calculate the algebraic distance d from all pixels in the back pixel set to the current fitted ellipse i, a distance threshold T is set (for example, T = 5 pixels). If d i < T, then this pixel is considered an inlier, that is, this point conforms to the current fitted ellipse model; otherwise, it is considered an outlier, that is, a noise point or a point that does not conform to the current model; subsequently, the number of inliers is counted; Repeat the above fitting steps a certain number of times (for example, 1000 times). Each iteration obtains an ellipse model and the corresponding number of inliers. Among all the ellipse models obtained in the iterations, select the ellipse with the largest number of inliers as the final fitting result, that is, take the optimal ellipse as the back-fitted ellipse; The fitting process of the abdominal ellipse is similar to that of the back ellipse and will not be elaborated here; After ellipse fitting, the ellipse center coordinates, major axis length, minor axis length, major axis inclination angle, etc. can be calculated according to the fitted ellipse parameters; in this embodiment, the major axis direction of the ellipse reflects the main orientation of the sturgeon's body in this area; normally, the sturgeon's back is upward and the abdomen is downward. From a top view, the major axes of the ellipses in the back and abdomen areas should be roughly parallel (or have a slight angle because the sturgeon's body may be slightly curved); when the sturgeon rolls over, its body will rotate around the longitudinal axis. Due to the different shapes and positions of the back and abdomen, their projections during the rotation will also change differently, resulting in a relative change in the major axis directions of the back ellipse and the abdominal ellipse, and the angle between them will increase significantly; One can imagine a rectangular object (representing the sturgeon's body). When it rotates around its major axis, from a top view, the directions of its long side and short side will both change. The back and abdomen are like two different parts of this rectangle, and their projection changes during the rotation are different, resulting in different changes in the corresponding major axis directions of the ellipses; therefore, by calculating the angle between the major axes of these two ellipses, the roll-over angle of the sturgeon can be estimated; In this embodiment, the major axis direction angle of the ellipse is further extracted according to the following formula :

[0036] Since the value range of the arctan function is [-90°, 90°], it is necessary to adjust according to the relative sizes of A and C to ensure that θ represents the direction of the major axis; Calculate the major axis inclination angle of the back ellipse and the major axis inclination angle of the abdominal ellipse ; further calculate the roll-over angle according to the following formula :

[0037] where, and represent the major axis direction angles of the dorsal ellipse and the abdominal ellipse respectively; represents the absolute value sign; since this embodiment only focuses on the acute angle between the two major axes, when , it needs to be corrected to ; Getting the rollover angle After that, you can set the threshold by Compare with the threshold to determine whether the sturgeon has flipped and the degree of flipping, and finally realize the flipping detection of the sturgeon; Although the angle of the major axis of the ellipse It is the main basis for judging rollover, but this method can also introduce color features to assist in judgment. By using the significant feature of the color difference between the back and abdomen of the sturgeon, it can assist in judging the rollover state, which can improve the accuracy and robustness of detection. Specifically, the denoised pixel sets of the back and abdomen regions of each sturgeon were converted from RGB color space to HSV color space. The average hue values of the back and abdomen regions were calculated, and the hue value difference between the back and abdomen regions of each sturgeon was further calculated. The rollover angle and hue value difference were used to comprehensively determine whether the sturgeon had rolled over and the degree of rollover. The HSV (Hue, Saturation, Value) color space decomposes color information into hue, saturation, and value. Hue represents the type of color (such as red, green, blue, etc.) and is relatively insensitive to changes in light intensity and direction. This allows hue-based feature extraction methods to be somewhat resistant to interference from factors such as strong reflections at noon. At the same time, the HSV color space is closer to how humans perceive color, and the three components of hue, saturation, and brightness are easier to understand and interpret. Compared to some other color spaces (such as Lab and Luv), the HSV color space is relatively simple to calculate and has a faster conversion speed. Compared with the RGB color space, which directly uses red, green, and blue components to represent color, it is easily affected by changes in lighting. Under strong light, the values of the three RGB components will increase, resulting in an overall brighter color and difficulty distinguishing between the back and abdomen. The HSV color space, on the other hand, separates the brightness component, making the hue information less affected by lighting and more suitable for this application scenario. The conversion process from RGB to HSV is as follows: Let R, G, B be the normalized red, green, and blue components (value range is [0, 1]); max = max(R, G, B), min = min(R, G, B); The formula for calculating hue is: H={60((GB) / (max-min)), ifmax=R; 60(2+(BR) / (max-min)), ifmax=G; 60(4+(RG) / (max-min)), ifmax=B}; If H<0, it is corrected to H=H+360, and the value range of H is [0, 360], indicating different colors; The saturation calculation formula is: S={0, ifmax=0; (max-min) / max, ifmax!=0}; The value range of S is [0, 1], which indicates the purity of the color; The formula for calculating brightness (Value) is: V=max; The value range of V is [0, 1], which indicates the brightness of the color; The average hue values for the dorsal and ventral regions were calculated separately according to the following formula: μ_back=(1 / N_back)ΣH(x, y), (x, y)∈back region μ_belly=(1 / N_belly)ΣH(x,y), (x,y)∈belly region Where N_back and N_belly are the number of pixels on the back and belly respectively, and H(x, y) is the hue value of the pixel point (x, y); Further calculate the difference between the average hue values of the back and belly, Δμ: Δμ=μ_back-μ_belly; Since the back of a sturgeon is usually darker (smaller hue value) and the belly is lighter (larger hue value), a negative Δμ value usually means that the sturgeon is in a sideways position with its back facing down and its belly facing up; Specifically, whether the sturgeon has capsized and the degree of capsizing can be comprehensively determined based on the following rules: like and , it is judged to be normal; if or , it is determined to be a rollover; like and , it is determined to be a moderate rollover; if or , it is determined to be a serious rollover; in, Indicates the rollover angle; Indicates the difference in tonal value between the dorsal and ventral regions of the sturgeon; and They represent the rollover angle threshold and the hue value difference threshold respectively. In this embodiment, =25 ° , =20; k is a proportional coefficient greater than 1. In this embodiment, k =2; That is: if and , it is judged as normal; like and , it is determined to be a moderate rollover; like or , it is determined to be a serious rollover; Normal means the sturgeon may be making a brief posture adjustment or being slightly disturbed by external factors. This situation usually does not require immediate action, but requires close observation. Moderate rollover indicates that the sturgeon may have health problems, such as hypoxia, early symptoms of disease, etc. This situation requires attention and appropriate measures should be taken, such as checking water quality, adjusting feed, isolating and observing, etc. Severe capsizing indicates that the sturgeon's health condition may be very serious, such as severe hypoxia or advanced disease. In this case, emergency measures must be taken immediately, such as oxygenation, isolation treatment, or even culling. After rollover detection is complete, the results are promptly notified to the farm management personnel so that appropriate measures can be taken. The rollover detection results (including rollover severity, occurrence time, and farm pond number) are transmitted to the farm management system via an IoT module (e.g., ESP32). If a moderate or severe rollover is detected, an alert is automatically generated and notified to staff via SMS or app push notification. All rollover events are recorded for subsequent analysis and management. Here is an example of the alert message format: "{farming pond number}, {time}, {rollover severity}, {recommended measures}"; Experiments show that this method has an accuracy of 96%, a recall rate of 94%, and an F1 value of 0.95 for rollover detection, with extremely high detection accuracy. The few missed samples mainly occur in situations with extremely poor lighting or when the fish color is very close to the background color. This embodiment proposes a sturgeon rollover detection method that can effectively solve the problems of low efficiency, susceptibility to subjective factors, and high cost of traditional manual inspections, as well as the low accuracy and poor robustness of existing automated monitoring methods in strong light reflection and turbid water environments. Experimental results show that this method has the advantages of high precision, high robustness, good real-time performance, and controllable costs. It can meet the needs of actual aquaculture scenarios and has good application prospects.

[0038] Example 3 This embodiment provides a sturgeon rollover detection method based on deep learning and ellipse fitting, which is suitable for scenarios with limited computing resources.

[0039] In the specific implementation process, this embodiment provides a low-cost detection method. The overall process is consistent with the method process in Example 2, except that: The computing device of this embodiment uses NVIDIA Jetson Nano 4GB Developer Kit as the edge computing device. This device has low power consumption (about 10W) and low cost (about 1,000 yuan), making it suitable for deployment on farms. The operating system uses JetPack 4.6 (based on Ubuntu 18.04). The programming language, deep learning framework, and image processing library are the same as those in Example 2. The semantic segmentation model still uses the DeepLabV3+ model, but the backbone network is replaced with MobileNetV2 to reduce the number of model parameters and the amount of calculation; the training parameters are the same as in Example 2; Experiments showed that on a Jetson Nano, the processing time for a single frame image was approximately 0.5 seconds, and the accuracy of rollover detection was 93%. The accuracy rates were 95%, 93%, and 91%, respectively, under different water qualities (turbidity 0-50 NTU), lighting conditions (daytime, evening, and nighttime), and water depths (0.5-2 meters). This method can achieve high-precision sturgeon rollover detection even with limited computing resources, with false positives primarily occurring when the fish are severely bent.

[0040] The same or similar reference numerals correspond to the same or similar components; The terms used in the drawings to describe positional relationships are for illustrative purposes only and are not to be construed as limiting the present application. Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.

Claims

1. A sturgeon rollover detection method based on deep learning and ellipse fitting, characterized in that: The following steps are involved: S1: Collecting sturgeon images and performing preprocessing; the preprocessing includes at least: dynamic interference removal, denoising, illumination correction, and water turbidity correction; S2: performing semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; S3: Based on the semantic segmentation results, a binary mask of the back and abdomen of each sturgeon is generated. The noise area in the mask is removed through morphological processing and connected domain analysis to obtain the denoised pixel set of the back and abdomen of each sturgeon. S4: Ellipse fitting is performed on the pixel sets of the back and abdomen areas of each sturgeon after denoising, and the major axis direction angle of the ellipse of the back and abdomen of each sturgeon is extracted. The rollover angle is further calculated, and the rollover angle is used to determine whether the sturgeon has rolled over and the degree of the rollover.

2. A sturgeon rollover detection method based on deep learning and ellipse fitting according to claim 1, characterized in that: In step S1, the inter-frame difference algorithm is used to remove dynamic interference, the median filter and Gaussian filter are used to perform denoising, the contrast-limited adaptive histogram equalization algorithm is used to perform illumination correction, and the gray world algorithm is used to perform water turbidity correction to complete the preprocessing.

3. The sturgeon rollover detection method based on deep learning and ellipse fitting according to claim 1 is characterized in that: In step S2, the deep learning model is specifically a DeepLabV3+ neural network model.

4. The method for detecting sturgeon rollover based on deep learning and ellipse fitting according to claim 1, wherein: In step S2, the adaptive weight cross entropy loss function is specifically: Where L is the adaptive weighted cross entropy loss function value; N is the total number of pixels in the image; i is the pixel index; 、 and are the weights of background pixels, back pixels, and abdomen pixels, respectively; 、 and are the true labels of background pixels, back pixels, and abdomen pixels respectively; 、 and are the predicted probabilities of background pixels, back pixels, and belly pixels, respectively; The weight of the back pixel Calculated according to the following formula: in, is the number of pixels in the sturgeon dorsal bone plate area in the current image; is the total number of pixels in the entire back area of the sturgeon in the current image; is the preset bone plate weight coefficient.

5. The method for detecting sturgeon rollover based on deep learning and ellipse fitting according to claim 1, characterized in that: In step S3, the morphological processing includes an erosion operation and a dilation operation; The connected domain analysis includes: using the 8-connectivity labeling algorithm to find all connected regions on the binary mask after morphological processing, calculating the area of each connected region, setting an area threshold, and removing all connected regions with an area smaller than the area threshold to complete the connected domain analysis.

6. The method for detecting sturgeon rollover based on deep learning and ellipse fitting according to claim 1, characterized in that: In step S4, the RANSAC algorithm is used to perform ellipse fitting on the pixel sets of the back and abdomen regions of each sturgeon after denoising, so as to obtain the back ellipse and the abdomen ellipse of each sturgeon.

7. The method for detecting sturgeon rollover based on deep learning and ellipse fitting according to claim 1, characterized in that: In step S4, the fitting equation of the ellipse is expressed as: in, is the coordinate of the point on the ellipse; A 、 B 、 C 、 D 、 E and F are the first to sixth fitting parameters of the ellipse respectively; The major axis direction angle of the ellipse is further extracted according to the following formula : Calculate the rollover angle using the following formula : in, and represent the major axis direction angles of the dorsal ellipse and the abdominal ellipse respectively; Indicates the absolute value symbol.

8. A sturgeon rollover detection method based on deep learning and ellipse fitting according to any one of claims 1 to 7, characterized in that: The step S4 further includes: The pixel sets of the back and abdomen regions of each sturgeon after denoising were converted from RGB color space to HSV color space, and the average hue values of the back and abdomen regions were calculated respectively. The hue value difference between the back and abdomen regions of each sturgeon was further calculated. Whether the sturgeon has flipped and the degree of flipping are comprehensively determined based on the flipping angle and hue value difference.

9. A sturgeon rollover detection method based on deep learning and ellipse fitting according to any one of claim 8, characterized in that: The following rules are used to comprehensively determine whether the sturgeon has flipped and the degree of flipping: like and , it is judged to be normal; if or , it is determined to be a rollover; like and , it is determined to be a moderate rollover; if or , it is determined to be a serious rollover; in, Indicates the rollover angle; Indicates the difference in tonal value between the dorsal and ventral regions of the sturgeon; and They represent the rollover angle threshold and hue value difference threshold respectively; k is a proportional coefficient greater than 1.

10. A sturgeon rollover detection system based on deep learning and ellipse fitting, applying the sturgeon rollover detection method according to any one of claims 1 to 9, characterized in that: include: Preprocessing module: used to collect and preprocess sturgeon images; The pre-processing includes at least: dynamic interference removal, noise removal, illumination correction and water turbidity correction; Semantic segmentation module: used to perform semantic segmentation on the preprocessed sturgeon images using a pre-trained deep learning model to obtain segmentation results of the back and abdomen regions of each sturgeon; the pre-trained deep learning model is trained based on an adaptive weighted cross entropy loss function; Mask generation module: This module generates binary masks for the back and abdomen of each sturgeon based on the semantic segmentation results. It then removes the noise from the masks through morphological processing and connected domain analysis to obtain the denoised pixel sets for the back and abdomen of each sturgeon. Rollover detection module: It is used to perform ellipse fitting on the pixel sets of the dorsal and abdominal regions of each sturgeon after denoising, extract the major axis direction angle of each sturgeon's dorsal and abdominal ellipse, and further calculate the rollover angle. Based on the rollover angle, it is determined whether the sturgeon has rolled over and the degree of rollover.

Citation Information

Patent Citations

  • Fish abnormal state detection method and system based on improved Yolov5s

    CN117197553A