Method and device for measuring size of fish body underwater and estimating biomass, electronic equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA AGRI UNIV
- Filing Date
- 2026-04-03
- Publication Date
- 2026-06-09
Smart Images

Figure CN122176035A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, system, electronic device and storage medium for measuring the size and estimating the biomass of underwater fish. Background Technology
[0002] In aquaculture production, fish size and biomass are important indicators reflecting fish growth status and farming scale. Accurately obtaining information on fish length, width, and biomass is crucial for developing scientific feeding strategies, evaluating farming effectiveness, and making aquaculture management decisions. Traditional methods of measuring fish size and biomass typically rely on manual sampling or weighing. These methods are not only inefficient but also require catching fish, which can easily cause stress and negatively impact their normal growth.
[0003] With the development of computer vision technology, non-contact fish measurement methods based on image processing have gradually attracted attention. By acquiring underwater fish images and performing target detection and morphological analysis on the fish bodies, fish size information can be obtained without contact with the fish. However, in actual aquaculture environments, fish are often in a free-swimming state, with significant changes in fish posture, and there are also situations such as mutual occlusion between fish, changes in lighting, and water disturbance, which pose considerable challenges to fish target detection and size measurement.
[0004] Furthermore, existing visual measurement methods typically estimate fish size based on monocular images, which is easily affected by shooting distance and changes in fish posture, making it difficult to obtain stable and accurate true size information. At the same time, the relationship between fish biomass and morphological parameters often exhibits complex nonlinearity, and single regression models may suffer from insufficient predictive stability in practical applications.
[0005] Therefore, how to achieve stable detection and segmentation of fish targets in complex underwater environments, and how to combine depth information to accurately measure the true size of the fish, while further realizing the automatic estimation of fish biomass, remains a technical problem that needs to be solved in this field. Summary of the Invention
[0006] The technical problem to be solved by this invention is how to provide an underwater fish size measurement and biomass estimation method, system, equipment and storage medium that can automatically acquire fish size and biomass information in complex aquaculture environments, thereby improving the automation level and measurement accuracy of aquaculture monitoring.
[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a method for measuring the body size and estimating the biomass of underwater fish, comprising the following steps: Acquire binocular images of underwater fish schools and preprocess the binocular images to obtain images of the fish schools to be analyzed; The fish school image is input into the fish body instance segmentation model to detect and segment the fish body targets in the fish school image, and obtain the segmentation mask of each fish body target and the corresponding fish body contour information. The fish body contour is extracted based on the fish body segmentation mask, and the fish body central skeleton curve is calculated by curve fitting method. The fish body length direction is determined according to the central skeleton curve, and the fish body width curve is calculated along the direction perpendicular to the body length direction to obtain the two-dimensional morphological parameters of the fish body. The depth information corresponding to the fish image is obtained, and the mapping relationship between pixel coordinates and real space coordinates is established according to the binocular stereo vision imaging model. The two-dimensional morphological parameters of the fish are converted into real scale parameters to obtain the actual size of the fish body length and width. Based on the fish's body length and width, fish morphological features are constructed and input into the biomass prediction model to obtain the predicted individual body mass of the corresponding fish, and then the overall biomass of the fish population is calculated.
[0008] This invention also discloses an underwater fish size measurement and biomass estimation device, comprising: The image acquisition module is used to acquire binocular images of underwater fish schools; The fish body segmentation module is used to detect and segment fish bodies in fish school images to obtain fish body segmentation masks and fish body contour information. The morphological parameter calculation module is used to calculate the central skeleton curve of the fish body based on the fish body outline and to obtain the two-dimensional morphological parameters of the fish body length and width. The size conversion module is used to convert two-dimensional morphological parameters into the actual size of the fish by combining binocular vision depth information; The biomass estimation module is used to predict the individual body mass of fish and calculate the overall biomass of the fish population based on fish size parameters.
[0009] The present invention also discloses an electronic device, comprising: a processor and a memory, wherein the memory stores a computer program, and the computer program, when executed on the processor, causes the processor to perform the method described thereon.
[0010] The present invention also discloses a computer-readable storage medium storing a computer program that executes the method when run on a processor.
[0011] The beneficial effects of adopting the above technical solution are as follows: The method of the present invention achieves automatic detection and contour extraction of fish targets by segmenting underwater fish school images, and obtains fish morphological parameters through fish central skeleton curve analysis, thereby adapting to size measurement under fish posture changes; at the same time, by combining binocular stereo vision depth information, the two-dimensional image information is converted into real spatial scale, realizing non-contact measurement of fish length and width; on this basis, by constructing a biomass prediction model, the automatic estimation of fish biomass is realized, thereby enabling automatic acquisition of fish size and biomass information in complex aquaculture environments, improving the automation level and measurement accuracy of aquaculture monitoring. Attached Figure Description
[0012] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0013] Figure 1 This is a flowchart of the underwater fish body size measurement and biomass estimation method described in Embodiment 1 of the present invention; Figure 2 This is a flowchart illustrating the underwater fish size measurement and biomass estimation method described in Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the outline of the fish provided in Embodiment 3 of the present invention; Figure 4 This is a flowchart illustrating the underwater fish size measurement and biomass estimation method described in Embodiment 3 of the present invention; Figure 5 This is a flowchart illustrating the underwater fish size measurement and biomass estimation method described in Embodiment 4 of the present invention; Figure 6 This is a schematic diagram of the segmentation model in Embodiment 4 of the present invention; Figure 7 This is a flowchart illustrating the underwater fish size measurement and biomass estimation method described in Embodiment 5 of the present invention; Figure 8 This is a schematic block diagram of the estimation device described in Embodiment Six of the present invention; Figure 9 This is a schematic diagram of the device described in Embodiment 7 of the present invention; Figure 10 This is a schematic block diagram of the electronic device described in Embodiment 8 of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0015] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0016] Example 1 like Figure 1 As shown in the figure, this invention discloses a method for measuring the body size and estimating the biomass of underwater fish, including the following steps: Acquire binocular images of underwater fish schools and preprocess the binocular images to obtain images of the fish schools to be analyzed; The fish school image is input into the fish body instance segmentation model to detect and segment the fish body targets in the fish school image, and obtain the segmentation mask of each fish body target and the corresponding fish body contour information. The fish body contour is extracted based on the fish body segmentation mask, and the fish body central skeleton curve is calculated by curve fitting method. The fish body length direction is determined according to the central skeleton curve, and the fish body width curve is calculated along the direction perpendicular to the body length direction to obtain the two-dimensional morphological parameters of the fish body. The depth information corresponding to the fish image is obtained, and the mapping relationship between pixel coordinates and real space coordinates is established according to the binocular stereo vision imaging model. The two-dimensional morphological parameters of the fish are converted into real scale parameters to obtain the actual size of the fish body length and width. Based on the fish's body length and width, fish morphological features are constructed and input into the biomass prediction model to obtain the predicted individual body mass of the corresponding fish, and then the overall biomass of the fish population is calculated.
[0017] Furthermore, the preprocessing includes one or more of the following: image denoising, brightness enhancement, color correction, or geometric correction, on the binocular images to improve the accuracy of fish target detection and segmentation. The fish instance segmentation model is a deep learning segmentation model trained on sample fish group images with fish segmentation labels, used to achieve automatic detection and pixel-level segmentation of fish targets in fish group images. The fish body length is the curve length calculated along the central skeleton curve of the fish, and the fish body width is the maximum width calculated along the vertical direction of the central skeleton curve. The depth information is obtained through binocular image matching calculation, and a mapping relationship between pixel disparity and spatial distance is established through camera calibration parameters. The biomass prediction model is a stacked ensemble model based on a multi-regression model, used to predict the individual fish mass based on the fish body length and width.
[0018] Example 2 like Figure 2 As shown in the figure, the present invention discloses a method for measuring the body size and estimating the biomass of underwater fish, including but not limited to the following steps: First, in step S1, the target fish group image is input into the contour extraction model to obtain the contour data of each fish in the target fish group image output by the contour extraction model.
[0019] The underwater fish video can be taken by an image acquisition device of the fish school under test. The image acquisition device can be a three-dimensional sensor such as a binocular camera, a structured light camera, or a three-dimensional (3D) depth camera. In the following embodiments, the underwater fish video taken by a binocular camera will be used as an example for illustration, which is not considered as a limitation on the scope of protection of the present invention.
[0020] The underwater fish school video is corrected to obtain a corrected fish school video. The corrected fish school video is then cropped to obtain a target fish school image. The target fish school image includes at least one complete, unobstructed image of the fish to be tested. The target fish school image can be a left-eye image or a right-eye image. In the following embodiments, the processing of the left-eye image is used as an example for illustration, which is not considered as a limitation on the scope of protection of the present invention.
[0021] The preprocessed fish school image is input into the fish instance segmentation model to automatically detect and segment fish targets in the image. The fish instance segmentation model is trained using sample fish school images with fish annotation information to achieve pixel-level segmentation of fish targets. The model outputs a segmentation mask and target boundary information for each fish target, thus enabling independent identification of individual fish within a fish school environment.
[0022] Further, in step S2, based on the contour data of any fish, contour extraction is performed on each fish target. Edge detection is performed on the segmentation mask to obtain the fish contour point set, and a skeleton extraction algorithm is used to perform morphological analysis on the fish contour to obtain the central skeleton curve of the fish. The central skeleton curve reflects the spatial posture of the fish, and the two-dimensional body length information of the fish can be obtained by calculating the curve length. Simultaneously, the lateral width of the fish is calculated along the vertical direction at each position of the skeleton curve, and the maximum width is selected as the fish width parameter, thus obtaining the two-dimensional morphological parameters of the fish.
[0023] Since the size information in a two-dimensional image is affected by the shooting distance, scale restoration requires combining binocular visual depth information to obtain the true size information of the fish. In this embodiment, a disparity map is obtained through binocular image matching calculation, and a mapping relationship between pixel disparity and actual spatial distance is established based on camera calibration parameters. Based on the depth information of the pixels corresponding to the fish outline, the two-dimensional morphological parameters of the fish are converted into the true spatial scale, thereby obtaining the actual length and width of the fish.
[0024] Further, in step S3, based on the obtained fish size parameters, fish morphological features are constructed, and these features are input into a biomass prediction model to estimate the fish's body mass. The biomass prediction model is trained using sample fish data; the model inputs are fish length, width, and their combinations, and the output is a predicted individual fish body mass. By statistically summing the individual body masses of each fish in the group, the overall biomass information of the fish group can be obtained.
[0025] Figure 3 This is a schematic diagram of the outline and key points of a fish provided by the present invention. The key points of any fish include point A on the head, point B0 on the right pectoral fin, point B1 on the left pectoral fin, point C0 on the right pelvic fin, point C1 on the left pelvic fin, and point D at the midpoint of the tail.
[0026] By fitting the coordinates of key points in the world coordinate system to spatial curves, we can obtain the body length curve L1 and the body width curve L2.
[0027] Among them, the body length curve L1 passes through the head A, the midpoint B of the pectoral fin, the midpoint C of the anal fin, and the midpoint D of the tail; the body width curve L2 passes through the right pectoral fin B0 point, the left pectoral fin B1 and the midpoint B of the pectoral fin, and the pelvic fin B1.
[0028] In step S3, the body shape data of any fish is determined based on the body length curve and the body width curve; the contour extraction model is obtained after training on sample fish images with key point data labels and contour data labels.
[0029] For the body length curve L1 and the body width curve L2, we construct and solve the spatial plane equations respectively, and we can obtain that the length of the body length curve L1 is the body length S1 of the fish, and the length of the body width curve L2 is the body width S2 of the fish.
[0030] Example 3 like Figure 4 As shown in the figure, the present invention discloses a method for measuring the body size and estimating the biomass of underwater fish, including but not limited to the following steps: First, extract sample fish images from the corrected fish school video; Secondly, the fish in the sample fish group images are classified and labeled to create training samples; Subsequently, the training samples are input into the instance segmentation model for training to obtain the contour extraction model.
[0031] Optionally, before inputting the target fish image into the contour extraction model, the method further includes: Acquire calibration data sets from multiple azimuths; The target camera is calibrated using each calibration data set to obtain the intrinsic parameter matrix, the extrinsic parameter matrix, and the distortion coefficients; The underwater fish school video is corrected using the extrinsic parameter matrix and the distortion coefficients to obtain a corrected fish school video, thereby determining the target fish school image. The underwater fish school video is acquired based on the target camera.
[0032] Example 4 like Figure 5 As shown in the figure, the present invention discloses a method for measuring the body size and estimating the biomass of underwater fish, including but not limited to the following steps: First, underwater calibration videos were collected at different distances, angles, and orientations to form a calibration data set. Calibration videos were captured at distances of 0.5m, 1.5m, and 2.0m from the binocular camera. The relative positions of the calibration board and the binocular camera lens when parallel were categorized as directly facing each other, 20cm upward, and 20cm downward. The relative positions of the calibration board and the binocular camera lens when tilted were categorized as tilted forward 20°, tilted backward 20°, tilted left 20°, and tilted right 20°.
[0033] Secondly, the stereo camera is calibrated using calibration video. The captured calibration video is divided into left and right stereo images, and Zhang's calibration method is used to process the left and right stereo images containing the complete calibration plate to detect the corner points of the calibration plate in the images.
[0034] Next, the calibration parameters of the stereo camera are output, including the intrinsic parameter matrix, extrinsic parameter matrix, and distortion coefficients. Based on the actual size of the calibration board and the coordinates of the corner points in the image, the intrinsic parameter matrix, extrinsic parameter matrix, and distortion coefficients of the stereo camera are calculated. as follows: ; in, , These are the effective focal lengths along the u-axis and v-axis, respectively; , It is an optical center; It is the non-perpendicularity factor between the u-axis and v-axis. In general, let s=0.
[0035] The extrinsic parameters of a stereo camera include: rotation matrix R and translation vector T, as follows: ; ; in, It is a vector that rotates about the X-axis; It is a vector that rotates about the Y-axis; It is a vector that rotates about the Z-axis; It is the translation distance along the X-axis; It is the translation distance along the Y-axis; It is the translation distance along the Z-axis.
[0036] The distortion coefficients of a stereo camera include: radial distortion parameters. , .
[0037] Subsequently, the underwater fish school video was corrected using calibration parameters. The binocular camera, fixed to a camera mount, allows adjustment of its vertical height, horizontal position, and tilt angle. Connected to a computer via a USB extension cable, it records and saves underwater fish school videos in real time. The camera's extrinsic parameter matrix is then used to perform binocular parallelism correction and distortion correction on the captured underwater fish school videos, as detailed below: The camera rotation matrix R is divided into a composite matrix for the left and right cameras. , ,in, , This achieves coplanarity of the image plane.
[0038] Create a rotation matrix in the direction of the translation vector T. , ; in, Let ||T| be the pole in the same direction as the translation vector T, and ||T| denotes taking the modulus of vector T. , , and These are the translation vectors in the x, y, and z directions, respectively; It is a vector pointing in the direction of the image plane; To be perpendicular to and The vector of the plane in which it is located.
[0039] Based on the composite matrix of the left camera The composite matrix of the right camera Rotation matrix in the direction of translation vector T The alignment transformation matrix of the left camera can be obtained. Alignment transformation matrix with the right camera The details are as follows: ; Using the alignment transformation matrix of the left camera The underwater fish video captured by the left camera is rotated and aligned; similarly, the alignment transformation matrix of the right camera can be used. Rotate and align the underwater fish video captured by the right camera.
[0040] Multiplying the left and right cameras by these two matrices respectively completes the transformation, yielding the corrected pixel coordinates of the image after row rotation alignment. , ), and the image coordinates after row rotation alignment ( , ).
[0041] The image pixel coordinate system is a rectangular coordinate system with the top left corner of the video frame as the origin, while the image coordinate system is a rectangular coordinate system with the intersection of the diagonals of the video frame as the origin.
[0042] For any frame of the underwater fish video after rotation correction, the image correction pixel coordinates are ( , Distortion correction is performed using the distortion coefficient, as follows: ; in,( , ) represents the image correction pixel coordinates, ( , ) represents the pixel coordinates of an image without distortion. , () indicates the image coordinates after row rotation alignment.
[0043] Using the distortion parameters of the left and right cameras , Distortion correction is performed on each frame of the underwater fish school video after rotation correction to obtain the corrected fish school video. The left eye image is then extracted from the corrected fish school video of the left camera as the target fish school image.
[0044] The underwater fish body mass measurement method provided by the present invention can obtain more accurate images of the target fish school by performing coordinate correction on the captured underwater fish school video, thus providing a basis for calculating the body size data of the fish.
[0045] The instance segmentation model includes a YOLO12-seg backbone network, an upsampling enhancement module, a bidirectional adaptive weighted feature fusion structure, and an instance segmentation module, specifically including: Backbone network: used for preliminary feature extraction of fish images to obtain target feature images; Upsampling enhancement module: used to enhance high-resolution features, improve the ability to express fish body boundaries and details, and optimize the upsampling path; Bidirectional adaptive weighted feature fusion structure: used for the unified fusion of multi-scale feature information, realizing dynamic weighting between features of different scales, and improving the segmentation stability of the model in complex backgrounds and situations with large differences in fish body scale; Instance segmentation module: used to predict fish body contours and detect key points based on fused feature maps, generating candidate fish body contours and key point data.
[0046] The backbone network uses a YOLOv12 feature extraction module to perform preliminary feature extraction on the target fish image and obtain an initial feature image. Figure 6 The diagram shows the structure of the instance segmentation model. The method is based on the YOLOv12 model and includes a backbone network, an upsampling enhancement module, a bidirectional adaptive weighted feature fusion structure, and an instance segmentation module.
[0047] The backbone network is used to perform preliminary feature extraction on the input fish school image and output a multi-scale target feature image. The backbone network consists of two parts: a YOLO12 feature extraction module and a Feature Pyramid Network (FPN) module.
[0048] The YOLO12 feature extraction module extracts the texture, boundary, and local structural features of the fish body through multiple convolutional layers, batch normalization layers, and activation functions, and outputs preliminary feature maps at different scales.
[0049] The pyramid feature fusion module upsamples and fuses the multi-scale features output by the YOLO12 feature extraction module to generate a target feature image containing high-resolution spatial and semantic information, providing basic features for subsequent segmentation and keypoint detection.
[0050] The target feature image, after being processed by the backbone network, enters the upsampling enhancement module for high-resolution feature enhancement. The upsampling enhancement module includes an efficient upsampling unit and a channel rearrangement unit. The efficient upsampling unit recovers high-resolution features while reducing information loss through transposed convolution or bilinear interpolation upsampling operations.
[0051] The channel rearrangement unit rearranges feature channels to achieve interaction and fusion between feature channels, thereby enhancing the ability to express boundaries and details.
[0052] The output feature map of the upsampling enhancement module can effectively identify small-scale and dense fish while preserving the edge and detail information of the fish body.
[0053] Subsequently, the feature maps are input into a bidirectional adaptive weighted feature fusion structure for multi-scale feature fusion. This structure includes an adaptive weighting computation unit and a bidirectional feature fusion unit: The adaptive weighted calculation unit assigns weights based on the importance of the fish body region and the background region in the feature map, and dynamically adjusts the features at different scales.
[0054] The bidirectional feature fusion unit achieves bidirectional integration of features through bottom-up and top-down fusion paths, thereby balancing high-resolution spatial information with semantic information.
[0055] By employing a bidirectional adaptive weighted feature fusion structure, the model can improve the stability and accuracy of instance segmentation in scenarios with large differences in fish size, complex poses, and complex backgrounds.
[0056] The fused feature maps are then fed into the instance segmentation module for fish contour prediction and keypoint detection. The instance segmentation module includes a candidate region generation unit, a mask prediction unit, and a keypoint detection unit. The candidate region generation unit obtains the candidate outline of the fish body through anchor box generation and bounding box regression; The Mask prediction unit generates a pixel-level fish body outline Mask based on the candidate region; The key point detection unit outputs key point information for each fish body, which is used for subsequent 3D size reconstruction.
[0057] Optionally, obtaining the body length curve and body width curve of any fish based on its contour data includes: Based on the intrinsic and extrinsic parameter matrices of the target camera, binocular matching is performed on the contour data to obtain the transformation relationship between the target fish group image and the world coordinate system; Based on the transformation relationship, coordinate transformation is performed on each key point data to obtain the world coordinates of each key point; the target fish school image is acquired based on the target camera; Based on all world coordinates of any given fish, fit the body length curve and body width curve of any given fish.
[0058] Based on the contour data output by the contour extraction model, a binocular matching algorithm (Semi-Global Block Matching, SGBM) is used to perform binocular matching within the fish body contour. This avoids the complex and computationally intensive nature of global matching and yields a local binocular depth map, which provides the true three-dimensional coordinates of key points.
[0059] The formula for converting from coordinates to world coordinates is as follows: ; Where S is the scale factor, used for ease of calculation; , () are the image pixel coordinates in a pixel coordinate system without distortion. These are coordinates in the world coordinate system; pixel coordinates (u, v) are obtained through the intrinsic parameter matrix. extrinsic matrix , The calculation yields the coordinates in the world coordinate system. .
[0060] According to the underwater fish body mass measurement method provided by the present invention, the size measurement is performed by fitting a true spatial curve through the three-dimensional spatial coordinates of key points. The entire measurement process can be automatically realized without human intervention.
[0061] Optionally, based on the body length curve and the body width curve, the body size data of any fish is determined, including: The body length curve is constructed and solved to obtain the body length data of any fish, and the body width curve is constructed and solved to obtain the body width data of any fish. The body shape data is determined based on the body length and body width data.
[0062] Spatial curve fitting is performed on the three-dimensional spatial coordinates of key points, including head A. Midpoint D of the tail dorsal fin front end B0 pelvic fin B1 Two spatial curves, L1 and L2, are fitted from the tail end of the dorsal fin (C0) and the anal fin (C1). L1 passes through the head (A), the anterior end of the dorsal fin, and the midpoint of the pelvic fin (B) of the fish's body. C, the caudal tip of the dorsal fin and the midpoint of the anal fin The midpoint D of the tail, L2 passes through the front end B0 of the dorsal fin, the front end of the dorsal fin, the midpoint B of the pelvic fin, and the pelvic fin B1. The length of L1 represents the body length of the fish, and the length of L2 represents the body width of the fish.
[0063] For curve L1, construct the equation of the space plane. Transformed into , written as ,make: ; ; ; Based on the solution of the normal equations The parameters A1, B1, and C1 are obtained.
[0064] Project points A, B, C, and D onto the plane. Get points The coordinates are used to define curve L1: Utilizing points The parameters are obtained by coordinate fitting. .
[0065] The length of curve L1 is S1, which serves as an estimate of the fish's body length, i.e., body length data. Specifically: ; Similarly, by constructing and solving curve L2, the length S2 of curve L2 is obtained as the estimated value of fish body width, i.e., body width data.
[0066] According to the method provided by the present invention, by constructing and solving the body length curve and body width curve of the fish, the spatial posture of the fish can be effectively fitted, and relatively accurate body shape data of the fish can be obtained.
[0067] Example 5 like Figure 7 As shown in the figure, the present invention discloses a method for measuring the body size and estimating the biomass of underwater fish, including but not limited to the following steps: First, collect video data of fish swimming underwater; Secondly, a binocular camera was used for calibration. The Zhang Zhengyou calibration method was used to obtain the camera's intrinsic parameter matrix, extrinsic parameter matrix, and distortion coefficients. Distortion correction was performed on the underwater fish video to obtain the corrected video data. Multiple sample fish images were then extracted from the corrected video. Then, each sample fish image is labeled, including the fish outline and key point location, to build training and testing datasets; Next, the target fish image is input into the contour extraction model provided by the present invention for processing. The contour extraction model includes a backbone network, an upsampling enhancement module, a bidirectional adaptive weighted feature fusion structure and an instance segmentation module, which predicts and extracts the contour and key points of each fish. Subsequently, the target fish group image was matched based on binocular stereo vision to obtain the pixel coordinates and corresponding depth information of key points, forming the three-dimensional spatial coordinates of the fish body; Then, coordinate transformation is performed on the three-dimensional spatial coordinates to map the pixel coordinates to the actual world coordinate system, so as to obtain the precise position of the fish in three-dimensional space. Then, the key points of the fish body are processed into a skeleton to realize the curve integral calculation of the fish body length. At the same time, the normal direction is detected by the center robust point method to realize the measurement of the fish body width. Finally, the fitted body length curve and body width information are processed to obtain the body shape parameters and estimated biomass information of the fish.
[0068] Example 6 like Figure 8 As shown in the figure, this invention also discloses an underwater fish size measurement and biomass estimation device, comprising: The image acquisition module is used to acquire binocular images of underwater fish schools; The fish body segmentation module is used to detect and segment fish bodies in fish school images to obtain fish body segmentation masks and fish body contour information. The morphological parameter calculation module is used to calculate the central skeleton curve of the fish body based on the fish body outline and to obtain the two-dimensional morphological parameters of the fish body length and width. The size conversion module is used to convert two-dimensional morphological parameters into the actual size of the fish by combining binocular vision depth information; The biomass estimation module is used to predict the individual body mass of fish and calculate the overall biomass of the fish population based on fish size parameters.
[0069] Example 7 like Figure 9 As shown in the figure, this invention also discloses an underwater fish size measurement and biomass estimation device, comprising: The first acquisition module 801 is used to input the target fish group image into the contour extraction model and acquire the contour data of each fish in the target fish group image output by the contour extraction model. The second acquisition module 802 is used to acquire the body length curve and body width curve of any fish based on the outline data of any fish. The determination module 803 is used to determine the body shape data of any fish based on the body length curve and the body width curve; the contour extraction model is obtained after training on sample fish images with key point data labels and contour data labels.
[0070] First, the first acquisition module 801 inputs the target fish group image into the contour extraction model to obtain the contour data of each fish in the target fish group image output by the contour extraction model.
[0071] The underwater fish video can be taken by an image acquisition device of the fish school under test. The image acquisition device can be a three-dimensional sensor such as a binocular camera, a structured light camera, or a three-dimensional (3D) depth camera. In the following embodiments, the underwater fish video taken by a binocular camera will be used as an example for illustration, which is not considered as a limitation on the scope of protection of the present invention.
[0072] The underwater fish school video is corrected to obtain a corrected fish school video. The corrected fish school video is then cropped to obtain a target fish school image. The target fish school image includes at least one complete, unobstructed image of the fish to be tested. The target fish school image can be a left-eye image or a right-eye image. In the following embodiments, the processing of the left-eye image is used as an example for illustration, which is not considered as a limitation on the scope of protection of the present invention.
[0073] The target fish school image is input into the contour extraction model. The model performs contour segmentation and keypoint labeling on each complete, unoccluded fish in the target fish school image, and outputs the complete contour data of each unoccluded fish. Keypoints are used to label the body shape of the fish, and all keypoints are located on the contour of the fish.
[0074] Furthermore, the second acquisition module 802 acquires the body length curve and body width curve of any fish based on the outline data of any fish.
[0075] The pixel coordinates corresponding to the contour data on the image are transformed to the world coordinate system to obtain the outline and key points of the fish in the world coordinate system.
[0076] Furthermore, the determination module 803 determines the weight and biomass data of any fish based on the body length curve and the body width curve; the contour extraction model is obtained after training on sample fish group images with key point data labels and contour data labels.
[0077] Example 8 The present invention also discloses an electronic device, such as Figure 10As shown, the electronic device may include a processor 910, a communication interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute an underwater fish body mass measurement method, which includes: inputting a target fish group image into a contour extraction model to obtain the contour data of each fish in the target fish group image output by the contour extraction model; obtaining the body length curve and body width curve of any fish based on the contour data of any fish; and determining the biomass data of any fish based on the body length curve and body width curve. The contour extraction model is obtained after training on sample fish group images with key point data labels and contour data labels.
[0078] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0079] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the underwater fish body mass measurement method provided by the above methods. The method includes: inputting a target fish group image into a contour extraction model to obtain contour data of each fish in the target fish group image output by the contour extraction model; obtaining the body length curve and body width curve of any fish based on the contour data of any fish; and determining the body shape data of any fish based on the body length curve and body width curve. The contour extraction model is obtained after training on sample fish group images with key point data labels and contour data labels.
[0080] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the underwater fish body mass measurement method provided by the above methods. The method includes: inputting a target fish group image into a contour extraction model to obtain contour data of each fish in the target fish group image output by the contour extraction model; obtaining the body length curve and body width curve of any fish based on the contour data of any fish; and determining the body shape data of any fish based on the body length curve and body width curve. The contour extraction model is obtained after training on sample fish group images with key point data labels and contour data labels.
[0081] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0082] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for measuring the body size and estimating the biomass of underwater fish, characterized in that... Includes the following steps: Acquire binocular images of underwater fish schools and preprocess the binocular images to obtain images of the fish schools to be analyzed; The fish school image is input into the fish body instance segmentation model to detect and segment the fish body targets in the fish school image, and obtain the segmentation mask of each fish body target and the corresponding fish body contour information. The fish body contour is extracted based on the fish body segmentation mask, and the fish body central skeleton curve is calculated by curve fitting method. The fish body length direction is determined according to the central skeleton curve, and the fish body width curve is calculated along the direction perpendicular to the body length direction to obtain the two-dimensional morphological parameters of the fish body. The depth information corresponding to the fish image is obtained, and the mapping relationship between pixel coordinates and real space coordinates is established according to the binocular stereo vision imaging model. The two-dimensional morphological parameters of the fish are converted into real scale parameters to obtain the actual size of the fish body length and width. Based on the fish's body length and width, fish morphological features are constructed and input into the biomass prediction model to obtain the predicted individual body mass of the corresponding fish, and then the overall biomass of the fish population is calculated.
2. The method for measuring underwater fish body size and estimating biomass as described in claim 1, characterized in that: The preprocessing includes one or more of the following: image denoising, brightness enhancement, color correction, or geometric correction of the binocular image.
3. The method for measuring underwater fish body size and estimating biomass as described in claim 1, characterized in that, The instance segmentation model includes a YOLO12-seg backbone network, an upsampling enhancement module, a bidirectional adaptive weighted feature fusion structure, and an instance segmentation module: Backbone network: used for preliminary feature extraction of fish images to obtain target feature images; Upsampling enhancement module: used to enhance high-resolution features, improve the ability to express fish body boundaries and details, and optimize the upsampling path; Bidirectional adaptive weighted feature fusion structure: used for the unified fusion of multi-scale feature information, realizing dynamic weighting between features of different scales; Instance segmentation module: used to predict fish body contours and detect key points based on fused feature maps, generating candidate fish body contours and key point data.
4. The method for measuring underwater fish body size and estimating biomass as described in claim 3, characterized in that, The backbone network includes a YOLO12 feature extraction module and a pyramid feature fusion module: The YOLO12 feature extraction module extracts the texture, boundary, and local structural features of the fish body through multiple convolutional layers, batch normalization layers, and activation functions, and outputs preliminary feature maps at different scales. The pyramid feature fusion module upsamples and fuses the multi-scale features output by the YOLO12 feature extraction module to generate a target feature image containing high-resolution spatial and semantic information. The upsampling enhancement module includes a high-efficiency upsampling unit and a channel rearrangement unit: The efficient upsampling unit recovers high-resolution features while reducing information loss through transposed convolution or bilinear interpolation upsampling operations; The channel rearrangement unit rearranges feature channels to achieve interaction and fusion between feature channels, thereby enhancing the ability to express boundaries and details. The output feature map of the upsampling enhancement module can effectively identify small-scale and dense fish while preserving the edge and detail information of the fish body; The bidirectional adaptive weighted feature fusion structure includes an adaptive weighted computation unit and a bidirectional feature fusion unit: The adaptive weighted calculation unit assigns weights based on the importance of the fish body region and the background region in the feature map, and dynamically adjusts the features at different scales. The bidirectional feature fusion unit achieves bidirectional integration of features through bottom-up and top-down fusion paths, thereby balancing high-resolution spatial information and semantic information. The segmentation module includes a candidate region generation unit, a mask prediction unit, and a key point detection unit: The candidate region generation unit obtains the candidate outline of the fish body through anchor box generation and bounding box regression; The Mask prediction unit generates a pixel-level fish body outline Mask based on the candidate region; The key point detection unit outputs key point information for each fish body, which is used for subsequent 3D size reconstruction.
5. The method for measuring underwater fish body size and estimating biomass as described in claim 1, characterized in that, The fish body length is the curve length calculated along the central skeleton curve of the fish body, and the fish body width is the maximum width calculated along the vertical direction of the central skeleton curve.
6. The method for measuring underwater fish body size and estimating biomass as described in claim 3, characterized in that, The method for obtaining two-dimensional morphological data of fish includes the following steps: Spatial curve fitting is performed on the three-dimensional spatial coordinates of key points, including head A. Midpoint D of the tail dorsal fin front end B0 pelvic fin B1 Two spatial curves, L1 and L2, are fitted from the tail end of the dorsal fin (C0) and the anal fin (C1). Spatial curve L1 passes through the head (A), the anterior end of the dorsal fin, and the midpoint of the pelvic fin (B) of the fish's body. C, the caudal tip of the dorsal fin and the midpoint of the anal fin The midpoint of the tail is D. L2 passes through the front end of the dorsal fin B0, the front end of the dorsal fin, the midpoint of the pelvic fin B, and the pelvic fin B1. The length of the spatial curve L1 represents the body length data of the fish, and the length of the spatial curve L2 represents the body width data of the fish. For the space curve L1, construct the equation of the space plane. Transformed into , written as ,make: ; ; ; Based on the solution of the normal equations The parameters A1, B1, and C1 are obtained. Project points A, B, C, and D onto the plane. Get points The coordinates are used to define curve L1: Utilizing points The parameters are obtained by coordinate fitting. ; The length of the space curve L1 is S1, which serves as an estimate of the fish's body length, i.e., body length data. Specifically: ; Similarly, by constructing and solving curve L2, the length S2 of curve L2 is obtained as the estimated value of the fish's body width, i.e., the body width data.
7. The method for measuring underwater fish size and estimating biomass as described in claim 3, characterized in that: The biomass prediction model is a stacked ensemble model based on a multi-regression model, used to predict the individual body mass of fish based on their body length and width.
8. A device for measuring the body size and estimating the biomass of underwater fish, characterized in that, include: The image acquisition module is used to acquire binocular images of underwater fish schools; The fish body segmentation module is used to detect and segment fish bodies in fish school images to obtain fish body segmentation masks and fish body contour information. The morphological parameter calculation module is used to calculate the central skeleton curve of the fish body based on the fish body outline and to obtain the two-dimensional morphological parameters of the fish body length and width. The size conversion module is used to convert two-dimensional morphological parameters into the actual size of the fish by combining binocular vision depth information; The biomass estimation module is used to predict the individual body mass of fish and calculate the overall biomass of the fish population based on fish size parameters.
9. An electronic device, characterized in that, include: A processor and a memory, wherein the memory stores a computer program that, when executed on the processor, causes the processor to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program that, when run on a processor, executes the method as described in any one of claims 1 to 7.