A method for detecting fish target length based on binocular vision
By combining the binocular camera and wavelet transform diffusion model with YOLOV8 and TransPose models, contactless and accurate fish length measurement is achieved, solving the error and adaptability problems of traditional measurement methods, and improving detection performance and robustness in underwater environments. Great sex.
Patent Information
- Application Number
- CN202410677436.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-05-29
AI Technical Summary
Existing fish length detection technology suffers from manual measurement, which leads to fish damage, resource waste and large measurement errors. Machine vision methods are difficult to accurately capture three-dimensional information. Deep learning methods require a large amount of annotated data and have limited generalization capabilities. The resolution of imaging sonar Inadequate rate and range.
A binocular camera is used for non-contact measurement, the diffusion model of wavelet transform is used for image enhancement, the YOLOV8 model is improved for target recognition, the TransPose model is used to detect fish key points, and the binocular camera parameters are combined for three-dimensional reprojection and curve fitting calculations Fish length.
It achieves contactless and accurate fish length measurement, reduces measurement errors, improves adaptability to the underwater environment, enhances target detection performance and robustness, provides an accurate description of fish posture and morphology, and supports fish Growth monitoring and breeding management.
Smart Images

Figure CN118397074B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing in computer vision, and in particular relates to a fish target length detection method based on binocular vision. Background Art
[0002] With the increasing global attention to fish resources, an important challenge facing the fish farming industry is how to efficiently and accurately manage and breed large numbers of fish. The growth rate and size of fish directly affect their breeding benefits and output value, so accurately measuring the length of fish has become a key indicator for evaluating and monitoring fish health. Binocular stereo vision-assisted individualized intelligent breeding of fish has been a research hotspot in the field of aquaculture in recent years. Its core method is to measure fish length contactlessly through a binocular camera to achieve more efficient and sustainable breeding production. It provides a new idea and method for the aquaculture industry, which helps to improve breeding efficiency, reduce resource consumption, and promote the sustainable development of the aquaculture industry. The fish target length measurement method based on binocular vision can detect the growth of fish schools through an underwater intelligent vision system, thereby obtaining more accurate fish length information to help manage fish farms.
[0003] Although there have been many attempts in the existing fish length detection technology, there are still some problems and challenges. The following is an analysis of the existing technology and the technical problems that our solution may solve.
[0004] Traditional measurement methods often require manual fishing for measurement, which not only increases the workload of fishermen, but also causes damage to fish, and cannot meet the different needs of different fish individuals, resulting in resource waste and uneven growth. It may also lead to large errors in overall estimates.
[0005] Methods based on machine vision: Using machine vision to measure the length of fish mainly relies on image acquisition equipment, fish contour extraction algorithm and length measurement method. For example, the minimum enclosing rectangle, Hough transform and other methods are used to extract the fish contour. However, these methods can usually only process two-dimensional images and may not accurately capture the three-dimensional information of the fish. In addition, image quality is affected by many factors, such as lighting conditions, water quality and fish posture, which may affect the measurement accuracy.
[0006] Deep learning-based methods: By establishing a Fish-Keypoints dataset and using deep learning technology to detect fish and their key points, more accurate size measurements can be achieved. However, although deep learning can improve detection accuracy, its training process requires a large amount of labeled data, and the model's generalization ability and ability to adapt to different environmental conditions remain a challenge.
[0007] Imaging sonar-based methods: Fish length measurements using imaging sonar show a good linear relationship with fork length and a small error. However, although imaging sonar can provide a non-contact measurement method, its resolution and measurement range are limited and may not be suitable for all types and sizes of fish. Summary of the invention
[0008] In view of the above problems, the present invention provides a method for detecting the length of fish targets based on binocular vision, which includes the following processes:
[0009] Step 1: Use a binocular camera to collect image information of the underwater target fish body, and perform binocular positioning to obtain the camera's internal and external parameters;
[0010] Step 2, based on the diffusion model of wavelet transform, the image acquired in step 1 is enhanced;
[0011] Step 3, input the enhanced image data into the improved YOLOV8 model to identify fish targets;
[0012] Step 4: Based on the fish target identified in step 3, the TransPose model is used to detect key points of the fish body;
[0013] Step 5, based on the key points detected in step 4, three-dimensional reprojection is performed in combination with the internal and external parameters of the binocular camera, the coordinates of the key points are transformed, and the posture curve of the fish is fitted using the corresponding curve fitting algorithm according to the coordinates of the key points after reprojection; the fitted posture curve is integrated and the length of the curve is calculated, which is the length of the fish.
[0014] Preferably, the binocular calibration in step 1 is performed by using Zhang Zhengyou calibration method and GP290 checkerboard calibration plate.
[0015] Preferably, step 1 also includes a stereo correction process, the purpose of which is to align the images of the left and right cameras; a stereo correction method based on a disparity map is adopted to calculate the disparity between the left and right camera images, adjust the camera's intrinsic and extrinsic parameters, and achieve image alignment.
[0016] Preferably, the specific process of step 2 is:
[0017] S21, firstly, the fish image obtained in step 1 is processed using a one-dimensional discrete Haar Wavelet Transform 1D-DWT Decompose and calculate as follows:
[0018]
[0019] in Represents the low-frequency information of the image, Represents high-frequency information of the image; Represents the original image;
[0020] S22, enhances low-frequency images through a diffusion model. The diffusion model is divided into two parts: forward diffusion and reverse denoising. The forward diffusion process first uses a fixed variance plan , through T steps, the input Converted to corrupted noisy data , the process is as follows:
[0021]
[0022]
[0023] in, and are the corrupted noise data and the predefined variance at time step T, respectively; N represents the Gaussian distribution; X0 is the original data; the transition probability from t-1 to t is ;
[0024] The process of reverse denoising is as follows:
[0025]
[0026]
[0027] in, For the condition After the occurrence Probability of occurrence;
[0028] S23, the cross attention mechanism is used to enhance the high-frequency information. The process is as follows:
[0029] ,
[0030]
[0031] Among them, LH is low high, LH represents the horizontal high-frequency component, which contains the edge and detail information in the horizontal direction of the image; HL is high low, HL represents the vertical high-frequency component, which contains the edge and detail information in the vertical direction of the image; HH is high high, HH represents the high-frequency component, among which Conv is convolution, is the result after LH convolution, is the result after HL convolution, It is the result of HH convolution; it contains the details of the image that change rapidly in the horizontal and vertical directions.
[0032] Preferably, the improved YOLOV8 model in step 3 is specifically as follows: introducing the DCNV3 module into the neck network of the YOLOV8 model, replacing the C2f module in the PAN module, and at the same time, in the backbone network, using the C2f_ScConv module to replace the original C2f module;
[0033] The DCN V3 module allows flexible learning of sampling offsets, and autonomously learns sampling offsets suitable for long-range or short-range dependencies based on given data; at the same time, the DCN V3 module can adaptively adjust the convolution operation according to the input data, and it conventionally adopts a 3×3 convolution window;
[0034] Among them, the SCConv submodule in the C2f_ScConv module consists of two units, namely the spatial reconstruction unit SRU and the channel reconstruction unit CRU; the SRU adopts a separation and reconstruction method to suppress spatial redundancy, while the CRU adopts a split transformation and fusion strategy to reduce channel redundancy; the channel reconstruction unit CRU replaces the standard convolution and is implemented by three operators, namely splitting, transformation and fusion; the spatial reconstruction unit SRU adopts an independent reconstruction operation to suppress spatial redundancy through a separation-reconstruction method.
[0035] Preferably, in step 4, a TransPose model is used to perform key point detection, and the construction process of the TransPose model is:
[0036] S41, obtain a large amount of underwater fish image data set through a binocular camera and divide it into a training set and a test set;
[0037] S42, use labelme to annotate the key points of the fish in the image, including the head, eyes, the root of the front end of the dorsal fin, the root of the end of the dorsal fin, the root of the pectoral fin, the root of the anal fin, and the root of the caudal fin;
[0038] S43, construct the TransPose model, including three parts: CNN backbone network, encoder group and heat map output head group; feature extraction and downsampling are performed through the CNN backbone network. The size of the feature map is adjusted to a shape suitable for the encoder through the cropping layer. The adjusted feature map is regarded as a sequence and then input into N cascaded encoders. The encoder uses a self-attention mechanism to establish dependencies between features, and gradually extracts higher-level feature representations by encoding the sequence multiple times. The output of each encoder is an encoded feature sequence. In the heat map output head group, the output of the last encoder is used as the input for generating key point heat maps to generate key point heat maps;
[0039] S44, use the labeled training set and test set to perform end-to-end supervised learning on the constructed transPose model. The loss function is constructed using the mean square error MSE to calculate the heat map loss. The model adjusts the prediction results of the key points by optimizing the loss function to make them close to the actual position. Finally, the TransPose model can determine the final coordinates of each key point through the maximum activation function.
[0040] Preferably, in step 5, three-dimensional reprojection is performed by combining the internal and external parameters of the binocular camera to transform the coordinates of the key points, specifically:
[0041] Take the optical center of the left camera as the origin of the world coordinate system, assume that the X-axis and Y-axis are the same as the imaging plane of the left camera, and the Z-axis represents the direction the camera is facing. According to the similar triangle theorem, calculate the spatial coordinates of the key points ; First, the pixel coordinates of the key points in the left camera and the right camera are expressed as and ; Focal length underwater The value of is 1.33 times that of air; the calculation process is as follows:
[0042]
[0043] Among them, B is the baseline length, that is, the distance between the left and right cameras; is the length on the imaging plane.
[0044] Preferably, in step 5, a corresponding curve fitting algorithm is used to fit the posture curve of the fish, the fitted posture curve is integrated, and the length of the curve is calculated. The specific process is:
[0045] S1, in world coordinates, the key point of the head is , the center point of the line connecting the key points at the root of the front end of the dorsal fin and the key points at the root of the pectoral fin is , the center point of the line connecting the key points at the end of the dorsal fin and the root of the anal fin is , the key point of the tail fin root is ;
[0046] S2, after setting the key points ( ), these four key points are fitted to form a curve ;
[0047] In order to limit the twisting of the fish posture curve to a certain two-dimensional plane in the three-dimensional coordinate system In the equation, an expression is used to define the equation of the plane Φ, which is shown below:
[0048]
[0049] in, Represents the coordinate on the X-axis, Represents the coordinate on the Y axis, Represents the coordinate on the Z axis; is the coefficient, through Obtained using linear regression;
[0050] The process is as follows:
[0051]
[0052] S3, using the equation ( ) in the plane The coordinate point in the middle ( ); the process is as follows:
[0053]
[0054] S4, using Φ as a subspace to construct a new coordinate system is the origin The X-axis direction is calculated according to the following formula to obtain its coordinates in the new coordinate system on the Φ plane. :
[0055]
[0056] S5, note The expression in the Φ plane is , where a, b, and c are calculated by the following formula:
[0057]
[0058] Among them, a, b, and c are equation parameters. for Expression in the Φ plane;
[0059] S6, the last pair Perform curve integral summation and obtain the length That is the length of the fish, and the process is as follows:
[0060]
[0061] Where L is the last measured length of the fish, X base is the expression of the unknown number on the Φ plane. Compared with the prior art, the present invention has the following beneficial effects:
[0062] 1. By using a binocular camera to measure fish length in a non-contact manner, damage to the fish in traditional manual measurement is avoided. By using the Zhang Zhengyou calibration method to obtain the accurate parameters of the binocular camera, the error in subsequent measurements is greatly reduced. The binocular camera can provide more accurate depth information when measuring the size of fish underwater, better handle the problem of light refraction in the underwater environment, and can perform more complex visual tasks. The application of binocular cameras is not limited to size measurement, but also includes tracking the three-dimensional trajectory of fish swimming and refined analysis of underwater targets.
[0063] 2. The fish images are processed by the proposed diffusion model based on wavelet transform. By combining the diffusion model and wavelet transform, the computing power is reduced without losing information. The wavelet transform can halve the spatial dimension without sacrificing information, while other transform techniques, such as fast Fourier transform (FFT) and discrete cosine transform (DCT), will cause information loss. The wavelet transform can decompose underwater images into frequency bands of different scales, so that detailed information at different scales can be captured. Due to light attenuation and scattering in underwater environments, image details may exist at different scales. Therefore, information at different scales can be extracted through wavelet transform, which helps to restore the details of the image. The diffusion model can model the complex features of the image by learning the nonlinear relationship of a large amount of data. Compared with traditional enhancement algorithms based on rules or statistical methods, the diffusion model can better capture the high-level semantic and structural information in the image, so as to perform image enhancement more accurately.
[0064] The proposed wavelet transform-based diffusion model is used for enhancement, which reduces the scattering effect and restores the image clarity and details, so that the image will achieve better results in later tasks. At the same time, the noise reduction and enhancement of underwater pictures are achieved. After image enhancement by this method, the target detection of underwater fish is improved while the false detection is reduced.
[0065] 3. In order to adapt to the particularity of the underwater environment, this method improves the YOLOv8 algorithm. This method replaces the C2f module in the PAN module by introducing the DCN V3 network into Yolov8. By utilizing the long-distance modeling capability of DCN V3, Yolov8 can better capture the correlation between targets and improve the detection performance of distant targets. By utilizing the adaptive spatial aggregation capability of DCN V3, its detection capability for targets of different scales is enhanced, while reducing the inductive bias of regular convolution and improving the generalization ability of the model. Although the Yolov8 network has significant performance, this is at the expense of a large amount of computing resources, partly because the convolutional layer extracts redundant features. Therefore, this method uses the C2f module in the C2f_ScConv module backbone network to reduce the amount of computation.
[0066] In view of the changes in underwater light conditions and the blurring of underwater images, this method optimizes the network architecture and training strategy, and improves the algorithm's perception and robustness of underwater fish targets. It improves the accuracy of the algorithm in locating fish targets in underwater environments and the accuracy of underwater fish length measurement. It optimizes the performance of the algorithm in underwater environments. This will provide high-speed and high-precision target area of interest positioning for underwater fish length measurement tasks, and provide a reliable basis for subsequent size measurement.
[0067] 4. By detecting the key points of fish, the position and shape of the fish targets detected in the image can be captured more accurately. These positions are important indicators of the posture and morphology of the fish. By detecting and locating these key points, the posture and shape of the fish targets, that is, the body posture and orientation of the fish, can be accurately described. This is crucial for understanding the biological characteristics of fish and considering the changes in the posture of fish during measurement. It can accurately determine the body length of the fish, provide accurate size information for breeding management and research, help analyze the physiological state, behavioral characteristics and possible abnormalities of fish, and can be used to monitor the growth changes of fish. By comparing the key point information at different time points, the growth trend and rate of fish during breeding can be understood, providing a scientific basis for adjusting feeding strategies.
[0068] By fitting the pose curve of the fish, that is, when all the key points of the fish are successfully matched in pairs, the three-dimensional coordinates of these key points can be used to fit a pose curve. This pose curve can not only reflect the position of the fish in real space, but also accurately depict its pose. By analyzing the pose curve, the coordinate information of the fish can be obtained, and important characteristics such as the length of the fish can be calculated. This process provides an in-depth understanding of the behavior and ecological characteristics of fish. Through three-dimensional reconstruction technology, it is possible to accurately locate and track fish in the natural environment. In addition, by obtaining information such as the length of the fish, it is also possible to conduct a detailed analysis of the population structure and ecosystem dynamics. It provides a new, non-invasive method for fish research and provides strong support for research and practice in the fields of ecology and environmental monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the technical solutions of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, what is described below is only one embodiment of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0070] Figure 1 It is a logic block diagram of the underwater fish size measurement method of the present invention.
[0071] Figure 2 Improved YOLOV8 model diagram for this invention
[0072] Figure 3 This is a comparison diagram of underwater image enhancement in Example 1.
[0073] Figure 4 This is the fish target detection image of Example 1.
[0074] Figure 5 This is the fish key point identification diagram in Example 1.
[0075] Figure 6 This is a diagram of fish size measurement in Example 1. DETAILED DESCRIPTION
[0076] The invention will be further described below in conjunction with specific embodiments.
[0077] In order to improve the performance of underwater fish target detection accuracy, the present invention proposes an underwater fish target length detection method for underwater image enhancement, target detection and feature point detection. The method first calibrates the binocular camera underwater, and then introduces the diffusion model into the underwater image enhancement to make the enhancement result more accurate and natural, and further improves the ability of underwater image enhancement by introducing wavelet transform. A diffusion model based on wavelet transform is proposed. Then, improvements are proposed for YOLOV8, and the SCConv network and DCNv3 network are integrated to improve the recognition and detection capabilities of fish targets. Then, by detecting and locating the key points of the fish body, the posture and shape of the fish target, that is, the body posture and orientation of the fish, are accurately described. Finally, the positions of these paired key points in the left and right images are three-dimensionally reprojected, and their three-dimensional coordinates in the world coordinate system can be obtained. The three-dimensional coordinates of these key points are used to fit a pose curve. This pose curve can not only reflect the position of the fish in the real space, but also accurately depict its posture. By analyzing the pose curve, the coordinate information of the fish can be obtained, and important features such as the length of the fish can be calculated.
[0078] The overall idea of the present invention is as follows Figure 1 As shown, the overall method includes binocular matching, image enhancement, object detection, key point detection and measuring fish size.
[0079] This embodiment takes a group of underwater images as an example to further illustrate the method of the present invention.
[0080] 1. Binocular positioning and image acquisition;
[0081] First, build a binocular system to capture binocular videos or images of fish. The waterproof binocular camera and light source are combined with a pool to build a measurement device.
[0082] The binocular camera uses Zhang Zhengyou calibration method and GP290 checkerboard calibration plate for accurate calibration above and below water, optimizing the depth perception function.
[0083] The configuration of the binocular camera and light source is specially designed to adapt to the complex underwater lighting conditions and environmental changes. This configuration includes but is not limited to the waterproof depth adjustment of the camera, the wavelength selection of the light source, and the light intensity control. It aims to optimize the interaction between the light source and the camera to ensure that high-quality images can be captured under different water quality conditions (including but not limited to clear, turbid, and water of different colors), as well as under different water depths and lighting conditions. In addition, the specific placement angle and distance of the binocular camera are carefully designed to ensure that the system can obtain the best viewing angle and depth information for fish of different sizes and shapes, thereby improving the accuracy and reliability of the measurement.
[0084] The binocular matching module uses a zed 2 binocular camera with a video output resolution of 3840×1080 (1080P) @30fps, USB3.0 interface transmission, and a motion and object detection posture update rate of up to 100Hz. It is waterproofed when working underwater, and the increase of errors is avoided after waterproofing. The calibration plate used is a GP290 chessboard calibration plate. The substrate is a glass float substrate and an alumina panel. It has the advantages of being non-reflective, opaque, high precision and waterproof. The number of corner points is 11*8, and the side length of the chessboard is 20mm. The software development environment used for binocular positioning is MATLAB R2019b, and the built-in binocular positioning toolbox is used for calibration. The binocular camera of the present invention collects 16 groups of calibration plate images from different angles on land and underwater.
[0085] In an underwater environment, the shape and characteristics of the calibration plate may change due to the influence of refraction and scattering. In the experiment, an alumina calibration plate GP290 with high contrast and clear calibration points was first selected. A large amount of image data was collected by shooting the calibration plate at different depths and distances. Then, the underwater binocular camera was calibrated using this data. The experimental results show that by properly processing and correcting the calibration plate image, similar accuracy and precision as traditional camera calibration can be obtained. After completing the camera calibration, the next step is stereo correction. The purpose of stereo correction is to align the images of the left and right cameras to ensure accurate results in subsequent depth estimation and size measurement. This study adopted a stereo correction method based on disparity map. By calculating the parallax between the left and right camera images and adjusting the camera's intrinsic and extrinsic parameters, the image alignment was achieved. Through experimental verification, the underwater binocular camera calibration and stereo correction method of this study not only improved the accuracy of fish size measurement, but also provided a reliable basis for subsequent image processing and analysis.
[0086] 2. Perform image processing on the acquired binocular images
[0087] The collected underwater binocular images are processed, and a diffusion model processing method based on wavelet transform is proposed. The low-frequency information is enhanced by using the diffusion model, and the high-frequency information is enhanced and denoised by using the cross-attention mechanism.
[0088] The diffusion model based on wavelet transform is divided into two parts: denoising diffusion model and wavelet transform. The denoising diffusion probability model (DDPM) is an image denoising method based on probability modeling. It utilizes two Markov chains: one is the forward chain that interferes with data to noise, and the other is the reverse chain that converts noise back to data. Forward diffusion process (ForwardDiffusion): In DDPM, the input image is first subjected to a forward diffusion process. This process perturbs the distribution of the image by gradually adding noise. The noise can be random, such as Gaussian noise. Through multiple iterations, the intensity of the noise will gradually increase, making the distribution of the image gradually blurred. Reverse diffusion process (Reverse Diffusion): After completing the forward diffusion process, the DDPM model performs a reverse diffusion process. The goal of the reverse diffusion process is to restore the original image from the perturbed image. By gradually reducing the intensity of the noise, the distribution of the image gradually becomes clear.
[0089] Wavelet transform is a one-dimensional discrete Haar wavelet transform (1D-DWT), and the specific operation is: decompose the acquired fish image into a low-frequency part (approximate component) and a high-frequency part (detail component). The low-frequency part represents the overall trend and smooth information of the image, and the high-frequency part represents the details and texture information of the image. The decomposition process can be performed recursively, and each level of decomposition further decomposes the low-frequency part. In each level of decomposition, the frequency range of the wavelet function is adjusted by changing the scale parameter of the wavelet function to achieve the analysis of different frequency components. Smaller scales provide higher frequency resolution, and larger scales provide lower frequency resolution. The wavelet reconstruction of the image is to synthesize and reconstruct the coefficients obtained by decomposition into the original image. Through inverse scaling and inverse convolution operations, the coefficients obtained at each level of decomposition are inversely operated and inversely downsampled to obtain the low-frequency part and high-frequency part of the previous level. Finally, the low-frequency part of the highest level is inversely scaled and inversely convolved to obtain a complete reconstructed image.
[0090] First, the underwater image is decomposed using one-dimensional discrete Haar wavelet transform (1D-DWT), and the process is shown in the following formula:
[0091]
[0092] Among them, LL0 represents the low-frequency information of the image, ( ) represents the high-frequency information of the image. IMG0 represents the original image. Then the low-frequency image is enhanced through the diffusion model. The diffusion model is generally divided into two parts: forward diffusion and reverse denoising. The forward diffusion process first uses a fixed variance plan , gradually transform the input X0 into corrupted noise data through T steps , the process is shown in the following formula:
[0093]
[0094]
[0095] in, and are the corrupted noise data and the predefined variance at time step T, respectively. N represents Gaussian distribution, and X0 is the original data. The transition probability from t-1 to t is Finally, the process of using the cross attention mechanism to enhance the reverse denoising of high-frequency information is shown in the following formula:
[0096]
[0097]
[0098] in, For the condition After the occurrence Probability of occurrence;
[0099] Among them, LH is low high, LH represents the horizontal high-frequency component, which contains the edge and detail information in the horizontal direction of the image; HL is high low, HL represents the vertical high-frequency component, which contains the edge and detail information in the vertical direction of the image; HH is high high, HH represents the high-frequency component, among which Conv is convolution, is the result after LH convolution, is the result after HL convolution, It is the result of HH convolution; it contains the details of the image that change rapidly in the horizontal and vertical directions.
[0100] The wavelet transform-based diffusion model is designed to address the unique challenges of underwater imaging, including but not limited to light attenuation, scattering of particles, and dynamic image blur caused by water flow. The diffusion model uses the multi-scale decomposition capability of the wavelet transform to effectively separate the signal and noise in the image, achieving noise reduction and signal recovery at different frequency levels. In addition, the model combines the characteristics of underwater imaging and adjusts the threshold processing method of the wavelet coefficients, making it more suitable for image recovery under complex underwater lighting and turbidity conditions. In this way, the system can effectively improve the clarity and contrast of underwater images, providing a clearer and more accurate image basis for fish target detection and length measurement. Furthermore, the implementation of the model reduces the dependence on computing resources, making the visual system more suitable for deployment in resource-constrained field environments, and improving the practicality and universality of the system.
[0101] Underwater images are affected by water scattering and absorption, resulting in blurred images. Through enhancement processing, the scattering effect can be reduced, the clarity and details of the image can be restored, and the image can be easier to observe and analyze. Traditional underwater image enhancement methods mainly rely on hand-crafted enhancement techniques with limited generalization capabilities. Using the powerful feature extraction capabilities of convolutional neural networks and Transformer, a series of deep learning methods have been proposed and have achieved remarkable success in the field of underwater image enhancement. Although the above methods have made significant progress in underwater image enhancement, the noise-covered details they recover can be further enhanced. Previous methods often lead to blurred details and color distortion. Diffusion models show talent in image generation, which can generate more realistic details through a series of improvements. Diffusion models can model the complex features of images by learning nonlinear relationships of large amounts of data. Compared with traditional enhancement algorithms based on rules or statistical methods, diffusion models can better capture high-level semantic and structural information in images, thereby performing image enhancement more accurately. Therefore, diffusion models are introduced into underwater image enhancement to make the enhancement results more accurate and natural.
[0102] Although diffusion models have many advantages in image enhancement, they also face some challenges, such as time-consuming restoration, excessive consumption of computing resources, and unstable restoration. Wavelet transform can decompose underwater images into frequency bands of different scales, so that detailed information at different scales can be captured. Due to light attenuation and scattering in underwater environments, image details may exist at different scales. Therefore, information at different scales can be extracted through wavelet transform, which helps to restore the details of the image. In addition, wavelet transform has the characteristic of energy concentration, that is, the energy of the image in the wavelet domain is usually more concentrated in a few coefficients. In underwater images, valuable information is often concentrated in lower-frequency wavelet coefficients, while noise and interference are usually concentrated in high-frequency parts. Only targeted processing of low-frequency and high-frequency information is required to improve the effect of image enhancement while reducing the use of computing resources. Therefore, the present invention further improves the ability of underwater image enhancement by introducing wavelet transform.
[0103] This method takes advantage of the generative power of the diffusion model and the advantages of wavelet transform to achieve satisfactory denoising and image restoration effects for underwater images and reduce the demand for computing power. Wavelet transform can halve the spatial dimension without sacrificing information, while other transform techniques, such as fast Fourier transform (FFT) and discrete cosine transform (DCT), will cause information loss. In the wavelet transformed image, the low-frequency information contains the low-frequency components of the image, which represent the slowly changing parts of the image, such as the background, flat areas, and general structures. The low-frequency information also contains the global features of the image, such as overall brightness, contrast, and color distribution. These features are very important for the overall perception and analysis of the image. The low-frequency information also contains some larger-scale details, but these details change more slowly than the high-frequency components. Through the low-frequency information, larger textures and shapes in the image can be observed. In the wavelet transformed image, the high-frequency information contains the details and faster-changing parts of the image. Specifically, the high-frequency components usually contain detailed information such as edges, contours, and textures in the image. High-frequency information also contains smaller-scale subtle structures in the image, such as fine textures, fine lines, and small object features. Since high-frequency components are very sensitive to subtle changes in the image, they also contain noise in the image. Therefore, this paper uses a diffusion model to enhance low-frequency information and a cross-attention mechanism to enhance and reduce noise in high-frequency information.
[0104] The image enhancement experiment uses the underwater UIEB dataset, which includes 950 real-world underwater images, divided into two subsets: 890 pairs of original underwater images and corresponding high-quality reference images and 60 challenging images with no reference. The experiment in this paper divides the dataset into training set, validation set and test set in a ratio of 8:1:1. In order to quantitatively compare the restored images with the paired reference images provided on the dataset, the PSNR and SSIM indicators were used for evaluation. The higher the values of PSNR and SSIM, the more similar the structures between the images. The compared methods include WaterNet, UWCNN-typeI, Ucolo and U-Trans. The comparison results are shown in Tables 1 and Figure 3 According to Table 1 and Figure 3 It can be concluded that the diffusion model based on wavelet transform proposed by this method achieves good results, can improve the quality of underwater pictures, and provide better results for subsequent tasks.
[0105] Table 1 Underwater image enhancement comparison results
[0106]
[0107] 3. Fish identification on enhanced images
[0108] The present invention is based on the improved YOLOv8 algorithm to perform fish recognition on the acquired image, identify the fish, and obtain the position. Figure 2 As shown, the DCNV3 module is introduced into the neck network of the YOLOV8 model to replace the C2f module in the PAN module. At the same time, in the backbone network, the C2f_ScConv module is used to replace the original C2f module. The long-distance modeling capability of DCNV3 is utilized to enable Yolov8 to better capture the correlation between targets and improve the detection performance of distant targets. The adaptive spatial aggregation capability of DCNV3 is utilized to enhance its detection capability for targets of different scales, while reducing the inductive bias of regular convolution and improving the generalization ability of the model. In order to solve the problems of underwater lighting conditions and underwater image blur, this method optimizes the network structure and training strategy to enhance the algorithm's perception and robustness of fish targets in underwater environments. By training and adjusting the fish images taken underwater, it is ensured that the algorithm can accurately detect and locate fish targets in underwater environments, thereby improving the accuracy of underwater fish length measurement. The present invention establishes a data set specifically for underwater fish target detection, which contains underwater fish images of various species, sizes and backgrounds, covering a variety of typical underwater environmental conditions. By using this data set to train and test the algorithm, the present invention can evaluate the target detection performance of the algorithm in an underwater environment and further improve and optimize the performance of the algorithm.
[0109] SRU uses separation and reconstruction to suppress spatial redundancy, while CRU uses split transformation and fusion strategies to reduce channel redundancy. The scaling factor in the group normalization (GN) layer is used to evaluate the information content of different feature maps. The process is shown in the formula:
[0110]
[0111] in µ and σ are the mean and standard deviation in X, ε is a small positive constant added for division stability, γ and β is a trainable affine transformation. Using the trainable parameters in the GN layer γ as a way to measure the spatial pixel variance of each batch and channel. Richer spatial information reflects more spatial pixel variations, resulting in greater γ . Normalized correlation weights Wγ From the formula, this shows the importance of different feature maps. Then, Wγ The weights of the re-weighted feature map are mapped to the range (0, 1) by a sigmoid function and gated by a threshold. The weights above the threshold are set to 1 to obtain informative weights W1, while they are set to 0 to obtain non-informative weights W2.
[0112] Finally, the input feature X is multiplied by W1 and W2 respectively to obtain two weighted features: the informative feature X1w and the less informative feature X2w. Therefore, the present invention successfully separates the input feature into two parts: X1w has informative and expressive spatial content, while X2w has little or no information, which is considered redundant.
[0113] The Channel Reconstruction Unit (CRU) replaces the standard convolution with CRU, which is implemented through three operators - split, transform and fuse.
[0114] Segmentation: First, the features The channel is divided into two parts, using αC channel and (1−α)C channel respectively, where 0≤α≤1 is the segmentation ratio. After segmentation and compression operations, the spatially refined features Divided into upper part and lower part .
[0115] Conversion: For Efficient convolution operations (i.e., GWC and PWC) are used to extract high-level representative information and reduce computational costs. Due to sparse convolutional connections, GWC reduces the number of parameters and computations, but cuts off the information flow between channel groups. PWC can compensate for information loss and help information flow across feature channels. Finally, a merged representative feature map is formed. The process can be expressed as follows:
[0116]
[0117] is a merged representative feature map, and X is the feature.
[0118] for The PWC operation is used to generate a feature map with shallow hidden details as a complement to the rich feature extractor. Finally, a merged representative feature map is formed. The process can be expressed as follows:
[0119]
[0120] is a merged representative feature map, and X is the feature.
[0121] Fusion: After completing the conversion, the simplified SKNet method adaptively merges the output features from the upper and lower conversion stages and First, a global average pooling (pooling) is applied to collect global spatial information. Next, the upper and lower global channel-level descriptors , They are stacked together and a channel-level soft attention operation is used to generate a feature importance vector and Finally, in the feature importance vector and Under the guidance of and The channel refinement feature Y is obtained by merging, and the process can be expressed by the equation:
[0122]
[0123]
[0124]
[0125] in: and is the output feature of the up-down conversion stage. , It is the upper and lower global channel level descriptor. and Generates feature importance vector for channel-level soft attention operation. Y is the channel-refined feature.
[0126] The self-attention mechanism is a method that can dynamically adjust weights based on different inputs. In ViT, the multi-head self-attention mechanism makes the calculation of weights dependent on the input query vector, which enables different tokens to dynamically adjust weights based on the input query. This mechanism enables ViT to aggregate information between different tokens in an adaptive manner, thereby achieving global interaction and modeling. In contrast, when traditional CNN aggregates information, the parameters of the convolution kernel are static and cannot be dynamically adjusted based on different inputs. This makes traditional CNNs relatively limited in their adaptive spatial aggregation capabilities.
[0127] Therefore, by introducing the self-attention mechanism, ViT successfully overcomes the limitations of traditional CNN in global modeling and adaptive spatial aggregation. This enables ViT to perform better when processing various types of data, especially in tasks that require global information interaction. With the continuous development of the field of deep learning, models based on attention mechanisms such as ViT are expected to become important tools for processing large-scale data and complex tasks.
[0128] The core operation of the new convolutional backbone network DCN V3 is dynamic sparse convolution, which uses a common 3×3 window size. Its main features are as follows:
[0129] (1) Sampling offset: DCN V3 allows flexible learning of sampling offsets to dynamically determine the appropriate receptive field. The model can autonomously learn sampling offsets suitable for long-range or short-range dependencies based on the given data. This flexibility allows DCN V3 to better adapt to different types of tasks.
[0130] (2) Adaptive adjustment: DCN V3 adaptively adjusts the convolution operation according to the input data. This can achieve an adaptive spatial aggregation effect similar to ViTs (Vision Transformers). Compared with regular convolution operations, adaptive adjustment can reduce over-induction bias, thereby improving the performance and generalization ability of the model.
[0131] (3) 3×3 convolution window: DCN V3 uses a common 3×3 convolution window. This choice of window size avoids optimization problems that may occur when using large dense kernels and reduces computational costs. Therefore, DCN V3 has certain advantages in achieving efficient convolution operations.
[0132] The DCN V3 network is introduced into YOLOv8 to replace the C2f module in the PAN module. The long-distance modeling capability of DCN V3 is used to enable Yolov8 to better capture the correlation between targets and improve the detection performance of distant targets. The adaptive spatial aggregation capability of DCN V3 is used to enhance its detection capability for targets of different scales, while reducing the inductive bias of regular convolution and improving the generalization ability of the model. The improved model is as follows: Figure 2 shown.
[0133] By combining the SCConv network and the DCNv3 network, the improved YOLOv8 algorithm not only improves the recognition of underwater dynamic environments and fish's diverse postures, but also significantly enhances the algorithm's robustness to common interferences in underwater environments, such as suspended particles and swaying water plants. This algorithm optimization not only improves the accuracy and efficiency of target detection, but also reduces the false detection rate and missed detection rate while maintaining real-time processing capabilities, providing more powerful and reliable technical support for the precise measurement and breeding management of underwater fish.
[0134] The fish dataset of this embodiment is obtained by collection. In addition, some pictures are obtained by crawling and the UIEB dataset is used for screening. Labelme is used for annotation, and a total of 654 pictures are annotated. The dataset is expanded by cropping, zooming in, zooming out, and rotating the pictures. The recognition results are shown in the figure. Figure 4 Table 2 is a model comparison table. It can be seen that the P, R, and mAP indicators of the improved network are significantly better than those of other original models. Its P, R, and mAP have all been improved to varying degrees, proving that the improvement method proposed in this paper is effective and can pave the way for subsequent tasks.
[0135] Table 2 Model comparison
[0136]
[0137] 4. Use the TransPose model to detect the key points of the fish body.
[0138] After detecting individual fish, the key points of the fish are detected, including the head, eyes, dorsal fin, pectoral fin, anal fin and caudal fin. This method uses the TransPose key point detector and the transPose neural network trained by deep learning technology to accurately detect fish in a single frame of binocular image. Then, the image coordinates of the detected key points are converted into world coordinates through 3D reprojection technology and binocular imaging principle.
[0139] First, prepare the data set and collect image data sets containing fish posture annotations. Each image needs to be annotated with the location information of key points such as the fish head and tail. Annotation can be done manually or automatically. Then design the network architecture and design a posture estimation model based on the transposed neural network (TransPose Net) to detect key points such as the fish head and tail. The network architecture usually includes structures such as convolutional layers, transposed convolutional layers, and residual connections to effectively extract image features and achieve key point regression. Then preprocess the image, including resizing, normalization, and demeaning. Preprocessing helps improve the training effect and generalization ability of the network. Then start training the model and use the prepared data set to train the designed posture estimation model. During the training process, supervised learning is used to optimize the model parameters using the annotated key point location information and image data. Then perform model evaluation and tuning, use the validation set to evaluate the trained model, and tune the model based on the evaluation results. Evaluation indicators can include the accuracy and recall rate of key point positioning. Finally, the model is tested and applied. The evaluated and tuned model is tested using the test set to evaluate its performance on unseen data. If the model performance is satisfactory, it can be applied to actual scenes to detect key points such as fish heads and tails. Post-processing operations are performed as needed, such as smoothing of key points and calculation of posture angles, to improve the stability and accuracy of the detection results.
[0140] The overall processing of the TransPose model is as follows: the input image is passed through the CNN backbone network for feature extraction and downsampling. The size of the feature map is adjusted to a shape suitable for the encoder through the cropping layer. The adjusted feature map is regarded as a sequence and then input into N cascaded encoders. The encoder uses a self-attention mechanism to establish dependencies between features, and gradually extracts higher-level feature representations by encoding the sequence multiple times. The output of each encoder is an encoded feature sequence. In the heat map output head group, the output of the last encoder is used as the input for generating the key point heat map. The heat map is trained to accurately locate the key points of fish.
[0141] TransPose generates a heat map that matches the number of key points through a heat map output head. A heat map is a two-dimensional image in which each pixel value represents the probability that the position may be the corresponding key point. By constructing a loss function to calculate the heat map loss using the mean square error (MSE), the model can adjust the prediction results of the key points by optimizing the loss function to make them close to the true position. Finally, through the maximum activation function, TransPose can determine the final coordinates of each key point. By finding the pixel with the highest probability value in the heat map, the specific location of the key point in the image can be determined.
[0142] In summary, the steps of using a transposed neural network-based model to detect key points such as fish head and tail include data set preparation, network architecture design, data preprocessing, model training, model evaluation and tuning, model testing and application, and post-processing. Through these steps, accurate detection of key points of underwater fish can be achieved. By identifying the position of the detected fish target in the key point capture image, the posture and shape of the fish target, that is, the body posture and orientation of the fish, can be accurately described.
[0143] The design and training process of the transPose neural network trained by deep learning technology includes the following key steps: First, by using a large number of annotated underwater fish image datasets, the transPose neural network is end-to-end supervised learning to learn and improve the network's key point detection ability for underwater fish. Secondly, in view of the particularity of the underwater environment, the network structure is optimized and adjusted, including but not limited to the depth and width of the convolution layer, the selection of pooling operations, and the application of regularization and batch normalization to improve the network's robustness in underwater lighting changes, water flow effects, and image blur. Subsequently, the training data is amplified and enhanced using data augmentation technology to increase the generalization and anti-interference capabilities of the network and ensure the stability and reliability of the model in different underwater environments and lighting conditions. Finally, through repeated iterative training and verification on a large-scale underwater scene dataset, the transPose neural network is tuned and optimized to show higher accuracy and stability in the key point detection task of underwater fish images.
[0144] Through the above training process, the transPose neural network trained by deep learning technology can accurately detect the key points of fish in a single-frame binocular image, and convert the image coordinates into world coordinates through 3D reprojection technology and binocular imaging principle. The network combines the cognition and understanding of the underwater environment, has a strong adaptability to changes in lighting, water flow interference and changes in fish posture, and can robustly cope with the challenges of complex underwater environments, providing a reliable length measurement solution for individualized fish farming.
[0145] The fish dataset in this article was collected by myself. In addition, some pictures were obtained through crawlers and filtered. Labelme was used for annotation, and a total of 578 pictures were annotated. The TranPose model weights were randomly initialized, and the model basically converged after 120 iterations. The AP and AR were 81.6 and 83.1 respectively. The recognition results are shown in Figure 5 shown.
[0146] 5. Perform coordinate transformation based on the detected key points, fit the fish's posture curve, integrate the fitted posture curve, and calculate the length of the curve, which is the length of the fish.
[0147] The size of the fish is measured. Based on the coordinates of the key points after reprojection, the curve fitting algorithm is used to successfully fit a curve reflecting the fish's posture, and the length of the curve is accurately calculated through integral operation, thereby obtaining the actual length information of the fish. In the binocular image, the key points of the two matching left and right bounding boxes can be detected to achieve three-dimensional reconstruction of the fish's posture and position. Specifically, if the key points of a certain fish exist in both the left and right images, then the left and right key points can be matched. By performing three-dimensional reprojection of the positions of these paired key points in the left and right images, their three-dimensional coordinates in the world coordinate system can be obtained. When all the key points of the fish are successfully matched in pairs, the three-dimensional coordinates of these key points can be used to fit a posture curve. This posture curve can not only reflect the position of the fish in the real space, but also accurately depict its posture. By analyzing the posture curve, the coordinate information of the fish can be obtained, and important features such as the length of the fish can be calculated.
[0148] In the binocular detection task, the optical center of the left camera is used as the origin of the world coordinate system. Assume that the X-axis and Y-axis are the same as the imaging plane of the left camera, and the Z-axis represents the direction the camera is facing. According to the similar triangle theorem, the spatial coordinates of the key points are calculated. First, the pixel coordinates of the key points in the left camera and the right camera are expressed as and The focal length f underwater is 1.33 times that in air. The baseline length is B (i.e. the distance between the left and right cameras). is the length on the imaging plane. The process is shown in the following formula.
[0149]
[0150] in: Represents the coordinate on the X-axis, Represents the coordinate on the Y axis, represents the coordinate on the Z axis; f is the underwater focal length; is the length on the imaging plane; B is the baseline length, and Represents the pixel coordinates of the key points in the left and right cameras.
[0151] The head key point and the tail key point serve as the starting point and end point of the pose curve, representing the initial position and orientation of the fish. Then, the three-dimensional coordinates of the head key point and the tail key point are used to fit a curve to reflect the movement trajectory of the fish in real space. Except for the head and tail key points, other key points cannot be directly used to fit the pose curve. This is because they represent other parts of the fish's body, and their position information is not sufficient to determine the overall movement trajectory of the fish. Instead, the position information of these key points needs to be combined to comprehensively consider the shape and posture of the fish. By combining the position information of other key points, a more comprehensive description of the fish's pose can be obtained. In world coordinates, the head key point is recorded as , the center point of the line connecting the key points at the root of the front end of the dorsal fin and the key points at the root of the pectoral fin is The center point of the line connecting the key points at the end of the dorsal fin and the root of the anal fin is The key point of the tail fin root is After setting the key points ( ), these four key points are fitted to form a curve .
[0152] In order to limit the twisting of the fish posture curve to a certain two-dimensional plane in the three-dimensional coordinate system In , we can use an expression to define the equation of this plane Φ. The equation is shown in the formula:
[0153]
[0154] in: Represents the coordinate on the X-axis, Represents the coordinate on the Y axis, Represents the coordinate on the Z axis; is the coefficient, which can be obtained by It is obtained by linear regression, and the process is shown in the formula:
[0155]
[0156] in: The key points for definition; Represents the coordinate on the X-axis, Represents the coordinate on the Y axis, Represents the coordinate on the Z axis.
[0157] Then we can use the equation to get ( ) in the plane The coordinate point in the middle ( ). The process is shown in the formula:
[0158]
[0159] in: ( ) represents the key point In plane The coordinate point in the middle
[0160] Use Φ as a subspace to construct a new coordinate system. is the origin is the X-axis direction. The coordinates of the new coordinate system on the Φ plane are calculated as follows .
[0161]
[0162] in: Representing key points Coordinates in the new coordinate system on the Φ plane.
[0163] remember The expression in the Φ plane is , where a, b, c parameters can be calculated by the formula.
[0164]
[0165] Among them, a, b, c are equation parameters, for Expression in the Φ plane.
[0166] Last pair Perform curve integral summation and obtain the length That is the length of the fish, and the process is shown in the formula.
[0167]
[0168] Where L is the last measured length of the fish. Xbase is the expression of the unknown number on the Φ plane, which can be used to calculate XΦ, etc.
[0169] 6. Experimental Verification
[0170] In order to verify the accuracy of this algorithm, an experimental platform was built and a video of fish swimming in a pool was shot. Then the video was framed and the length of the fish in the image was calculated. The experimental results are as follows: Figure 6 Five samples were selected and the length measured by the algorithm was compared with the actual length. The comparison results are shown in Table 3. As can be seen from the table, the error between the length measured by the algorithm and the actual length is limited to less than 10%, which proves the feasibility of this algorithm.
[0171] Table 3 Measured length and actual length
[0172]
[0173] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0174] Although the above describes the specific implementation methods of the present invention, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A method for detecting the length of fish targets based on binocular vision, characterized in that: The process includes: Step 1: Use a binocular camera to collect image information of the underwater target fish body, and perform binocular positioning to obtain the camera's internal and external parameters; Step 2: Based on the diffusion model of wavelet transform, the image obtained in step 1 is enhanced; wherein, the high-frequency information is enhanced by using the cross-attention mechanism, and the process is as follows: , Among them, LH is low high, LH represents the horizontal high-frequency component, which contains the edge and detail information in the horizontal direction of the image; HL is high low, HL represents the vertical high-frequency component, which contains the edge and detail information in the vertical direction of the image; HH is high high, HH represents the high-frequency component, among which Conv is convolution, is the result after LH convolution, is the result after HL convolution, It is the result of HH convolution; it contains the details of the image that change rapidly in the horizontal and vertical directions; Step 3, input the enhanced image data into the improved YOLOV8 model to identify fish targets; the YOLOV8 model is specifically as follows: the DCNV3 module is introduced into the neck network of the YOLOV8 model, and the C2f module in the PAN module is replaced. At the same time, in the backbone network, the C2f_ScConv module is used to replace the original C2f module; The DCN V3 module allows flexible learning of sampling offsets, and autonomously learns sampling offsets suitable for long-range or short-range dependencies based on given data; at the same time, the DCN V3 module can adaptively adjust the convolution operation according to the input data, and it conventionally adopts a 3×3 convolution window; The SCConv submodule in the C2f_ScConv module consists of two units: a spatial reconstruction unit SRU and a channel reconstruction unit CRU; the SRU adopts a separation and reconstruction method to suppress spatial redundancy, while the CRU adopts a split transformation and fusion strategy to reduce channel redundancy; the channel reconstruction unit CRU replaces the standard convolution and is implemented by three operators, namely splitting, transformation and fusion; the spatial reconstruction unit SRU adopts an independent reconstruction operation to suppress spatial redundancy through a separation-reconstruction method; Step 4: Based on the fish target identified in step 3, the TransPose model is used to detect key points of the fish body; Step 5, based on the key points detected in step 4, three-dimensional reprojection is performed in combination with the internal and external parameters of the binocular camera, the coordinates of the key points are transformed, and the posture curve of the fish is fitted using the corresponding curve fitting algorithm according to the coordinates of the key points after reprojection; the fitted posture curve is integrated and the length of the curve is calculated, which is the length of the fish.
2. A method for detecting the length of a fish target based on binocular vision as claimed in claim 1, characterized in that: The binocular calibration in step 1 is performed by using Zhang Zhengyou calibration method and GP290 chessboard calibration plate.
3. A method for detecting the length of a fish target based on binocular vision as claimed in claim 1, characterized in that: The step 1 also includes a stereo correction process, the purpose of which is to align the images of the left and right cameras; a stereo correction method based on a disparity map is used to calculate the disparity between the left and right camera images, adjust the camera's intrinsic and extrinsic parameters, and achieve image alignment.
4. A method for detecting the length of a fish target based on binocular vision as claimed in claim 1, characterized in that: The specific process of step 2 is: S21, firstly, the fish image obtained in step 1 is processed using a one-dimensional discrete Haar Wavelet Transform 1D-DWT Decompose and calculate as follows: in Represents the low-frequency information of the image, Represents high-frequency information of the image; Represents the original image; S22, enhances low-frequency images through a diffusion model. The diffusion model is divided into two parts: forward diffusion and reverse denoising. The forward diffusion process first uses a fixed variance plan , through T steps, the input Converted to corrupted noisy data , the process is as follows: in, and are the corrupted noise data and the predefined variance at time step T, respectively; N represents the Gaussian distribution; X0 is the original data; the transition probability from t-1 to t is ; The process of reverse denoising is as follows: in, For the condition After the occurrence Probability of occurrence.
5. A method for detecting fish target length based on binocular vision as claimed in claim 1, characterized in that: In step 4, the TransPose model is used to detect key points. The construction process of the TransPose model is as follows: S41, obtain a large amount of underwater fish image data set through a binocular camera and divide it into a training set and a test set; S42, use labelme to annotate the key points of the fish in the image, including the head, eyes, the root of the front end of the dorsal fin, the root of the end of the dorsal fin, the root of the pectoral fin, the root of the anal fin, and the root of the caudal fin; S43, construct the TransPose model, including the CNN backbone network, the encoder group and the heat map output head group; perform feature extraction and downsampling through the CNN backbone network; adjust the size of the feature map to a shape suitable for the encoder through the cropping layer; the adjusted feature map is regarded as a sequence and then input into N cascaded encoders; the encoder uses the self-attention mechanism to establish dependencies between features, and gradually extracts higher-level feature representations by encoding the sequence multiple times; the output of each encoder is the encoded feature sequence; In the heat map output head group, the output of the last encoder is used as the input for generating the key point heat map; S44, use the labeled training set and test set to perform end-to-end supervised learning on the constructed transPose model. The loss function is constructed using the mean square error MSE to calculate the heat map loss. The model adjusts the prediction results of the key points by optimizing the loss function to make them close to the actual position. Finally, the TransPose model can determine the final coordinates of each key point through the maximum activation function.
6. A method for detecting the length of a fish target based on binocular vision as claimed in claim 1, characterized in that: In step 5, three-dimensional reprojection is performed by combining the internal and external parameters of the binocular camera, and the key points are transformed in coordinates, specifically: Take the optical center of the left camera as the origin of the world coordinate system, assume that the X-axis and Y-axis are the same as the imaging plane of the left camera, and the Z-axis represents the direction the camera is facing. According to the similar triangle theorem, calculate the spatial coordinates of the key points ; First, the pixel coordinates of the key points in the left camera and the right camera are expressed as and ; Focal length underwater The value of is 1.33 times that of air; the calculation process is as follows: Among them, B is the baseline length, that is, the distance between the left and right cameras; is the length on the imaging plane.
7. A method for detecting the length of a fish target based on binocular vision as claimed in claim 1, characterized in that: In step 5, the corresponding curve fitting algorithm is used to fit the posture curve of the fish, the fitted posture curve is integrated, and the length of the curve is calculated. The specific process is: S1, in world coordinates, the key point of the head is , the center point of the line connecting the key points at the root of the front end of the dorsal fin and the key points at the root of the pectoral fin is , the center point of the line connecting the key points at the end of the dorsal fin and the root of the anal fin is , the key point of the tail fin root is ; S2, after setting the key points ( ), these four key points are fitted to form a curve ; In order to limit the twisting of the fish posture curve to a certain two-dimensional plane in the three-dimensional coordinate system In the equation, an expression is used to define the equation of the plane Φ, which is shown below: in, Represents the coordinate on the X-axis, Represents the coordinate on the Y axis, Represents the coordinates on the Z axis; A, B, C are coefficients, obtained by linear regression through P1, P2, P3, P4; The process is as follows: S3, obtained using Eq. (P1,P2,P3,P4) In plane The coordinate point in the middle ( ) ; The process is as follows: S4, Φ As a subspace, a new coordinate system is constructed with is the origin is the X-axis direction, and the following formula is used to calculate its Φ Coordinates in the new coordinate system on the plane : S5, note exist Φ The expression of the plane is ,in a, b, c Calculated by the following formula: in, a, b, c is the equation parameter, for exist Φ Plane expressions; S6, the last pair Perform curve integral summation and obtain the length That is the length of the fish, and the process is as follows: Where L is the last measured length of the fish, Xbase For unknown Φ Expression on a plane.
