Fish body length estimation method and system based on feature fusion and point cloud transformation

By employing cross-modal feature fusion and point cloud normalization segmentation transformation, the error problem caused by occlusion and bending in fish length estimation is solved, achieving highly accurate fish length measurement applicable to various fish species.

CN118967574AActive Publication Date: 2024-11-15SHANDONG UNIV

Patent Information

Application Number
CN202410952789.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-15
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

Existing fish length estimation algorithms have errors when dealing with occlusion and fish curvature, especially deep learning-based methods, which fail to effectively handle incomplete fish features and length estimation errors caused by curvature.

Method used

We employ Mask R-CNN (CMFF Mask R-CNN) with cross-modal feature fusion and point cloud normalization segmentation transformation. We extract the complete fish mask through stereo correction and disparity map fusion, and transform the fish contour point cloud into a unified space for clustering and segmentation through planar and elliptical fitting transformations to calculate the fish length.

Benefits of technology

It improves the accuracy of fish length estimation, especially under obstructed and bent conditions, with an average relative error of less than 5%, and is applicable to a variety of fish, including salmon and other freshwater fish.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967574A_ABST
    Figure CN118967574A_ABST
Patent Text Reader

Abstract

The invention discloses a fish body length estimation method and system based on feature fusion and point cloud transformation, and the method comprises the steps: inputting a disparity map and a three-dimensionally corrected left eye image into a trained cross-modal feature fusion Mask RCNN model, and obtaining a mask image of a to-be-detected fish body; processing the mask image of the to-be-detected fish body to determine a fish body contour point cloud; performing plane fitting transformation on the fish body contour point cloud; performing ellipse fitting transformation on the projection of the fish body contour point cloud on the plane; clustering the fish body contour point clouds into a plurality of clusters by adopting a clustering algorithm; performing plane fitting processing on the fish body contour point clouds of each cluster, converting the fish body contour point clouds of each cluster to three planes, converting data of the three planes to a space coordinate system, calculating the fish body length of the fish body contour point clouds corresponding to each cluster in the space coordinate system, summing the fish body lengths of all clusters, and obtaining the fish body contour point clouds of all clusters. The total length of the to-be-measured fish body is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image segmentation, and in particular to a fish body length estimation method and system based on feature fusion and point cloud transformation. Background Art

[0002] Fish length is closely related to fish weight and age, and is an important indicator for measuring the quality of aquatic products. In aquaculture, fish length information plays a key role in both feeding management and fishing strategies. However, traditional contact-based fish length measurement methods can trigger a variety of physiological stress responses in the measured fish, such as nervous excitement, growth retardation caused by loss of appetite, and even death. In addition, manual measurement of fish length is time-consuming and laborious. Therefore, it is urgently necessary to develop a non-invasive fish length measurement method.

[0003] In modern aquaculture, stereo vision systems have been used for fish length estimation due to their non-contact and high accuracy. In early studies, non-contact fish length estimation required manual intervention to locate key points of the fish body. For example, Harvey et al. and Torisawa et al. uploaded binocular images of fish to a stereo vision system and manually marked the key points of the snout and tail fork of tuna. The fish length was calculated based on the 3D coordinates of the key points. However, the key step of locating the key points of the fish body is time-consuming and laborious.

[0004] Traditional image processing algorithms have been applied to automatic fish length estimation based on stereo vision. -Benavent et al. used local thresholding and morphological operations to obtain the abdominal contour of tuna. A deformable model was then designed to fit the extracted abdominal contour and the tuna length was estimated based on the centerline of the model with a length error of less than 5%. Zhao et al. proposed a method for estimating the fish body length based on the centerline of the fish based on the overlapping part of the fish back contour, which was extracted by the Otsu threshold algorithm. Al-jubouri et al. used background subtraction and morphological operations to obtain the fish body mask and constructed a mathematical model to estimate the fish body length. Shi et al. proposed a processing algorithm based on contour and convex hull calculation to extract the key points of the fish mouth tip and tail, and then calculated the Euclidean distance between these two points to obtain the fish body length. However, the above algorithms rely on manually designed fish body feature extraction and show poor robustness. Fish body length estimation becomes difficult when the breeding density is high and the occlusion is severe.

[0005] Recently, deep learning has been widely used in fish length estimation based on stereo vision due to its advantages of not requiring manual feature selection and strong robustness. Fish length estimation algorithms usually use deep learning networks to extract fish features containing length information, and then estimate the length based on these features. Deng et al. used the Keypoints R-CNN network to detect the key points of the fish head and tail, and calculated the Euclidean distance between the two points as the fish length, with a relative length error of less than 10%. Deng et al. (2023) also proposed a key point detection network composed of RetineNet and CenterNet to detect the key points of the fish head and tail to estimate the fish length, with a relative length error of less than 5%. Huang et al. (2020) used Mask R-CNN to extract fish masks to reconstruct the 3D point cloud of the fish and converted the point cloud into a 2D plane for length estimation, with an error of less than 5%. Garcia et al. (2019) used an image refinement method to extract the centerline from the fish mask obtained by Mask R-CNN for fish length estimation.

[0006] Although fish length estimation methods based on deep learning and stereo vision have shown satisfactory performance, some problems still exist. In terms of feature extraction, existing fish length estimation algorithms ignore the possibility that the fish has complete features in the left image, while the features in the right image may be incomplete due to parallax and occlusion. Therefore, the reconstructed fish point cloud is incomplete and lacks length information, cannot be used for length estimation, and needs to be excluded. However, current algorithms do not take this into account and estimate the length of all fish detected with complete features in the left image. They incorrectly estimate the length of incomplete fish in the stereo image, increasing the error of fish length estimation.

[0007] In terms of fish length estimation, some existing fish length estimation algorithms do not take into account that the curvature of the fish body may lead to significant errors in length estimation. Huang et al. assumed that the fish body contour is coplanar, which is incorrect for curved fish bodies. Shi et al., Deng et al., and Deng et al. estimated the fish body length by calculating the Euclidean distance between the key points of the fish mouth and tail. However, using only the distance between the two points of the fish mouth and tail is not enough to accurately describe the length of a curved fish body. Summary of the invention

[0008] In order to address the shortcomings of the prior art, the present invention provides a fish body length estimation method and system based on feature fusion and point cloud transformation; proposes a cross-modal feature fusion Mask R-CNN (CMFF Mask R-CNN) for extracting the mask of the complete fish body in the binocular image, and a fish body length estimation algorithm based on point cloud normalization segmentation transformation.

[0009] On the one hand, a fish body length estimation method based on feature fusion and point cloud transformation is provided, including:

[0010] Acquire a binocular image of the fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map;

[0011] The disparity map and the stereo-rectified left eye image are input into the trained cross-modal feature fusion MaskRCNN model to obtain the mask image of the fish to be tested;

[0012] Performing a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determining the fish body contour point cloud based on the coordinate value of each pixel on the fish body contour and the corresponding disparity value;

[0013] The fish body contour point cloud is transformed into a plane fitting transformation to maximize the area of ​​the fish body contour point cloud projected onto the plane; the projection of the fish body contour point cloud onto the plane is transformed into an ellipse fitting transformation to fit an ellipse, and based on the ellipse, it is ensured that the connecting line between the fish mouth and the fish tail is parallel to the baseline;

[0014] The fish body contour point cloud is clustered into several clusters using a clustering algorithm; the fish body contour point cloud of each cluster is plane fitting processed, and the fish body contour point cloud of each cluster is converted to three planes. The data of the three planes are converted to a spatial coordinate system, and the fish body length of each cluster corresponding to the fish body contour point cloud in the spatial coordinate system is calculated, and the fish body lengths of all clusters are summed up to obtain the total length of the fish body to be measured.

[0015] On the other hand, a fish length estimation system based on feature fusion and point cloud transformation is provided, including:

[0016] An acquisition module is configured to: acquire a binocular image of the fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map;

[0017] A mask image generation module is configured to: input the disparity map and the stereo-rectified left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish to be tested;

[0018] The fish body contour point cloud generation module is configured to: perform a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determine the fish body contour point cloud based on the coordinate value and corresponding disparity value of each pixel on the fish body contour;

[0019] The fitting module is configured to: perform a plane fitting transformation on the fish body contour point cloud to maximize the area of ​​the fish body contour point cloud projected onto the plane; perform an ellipse fitting transformation on the projection of the fish body contour point cloud on the plane to fit an ellipse, and based on the ellipse, ensure that the connecting line between the fish mouth and the fish tail is parallel to the baseline;

[0020] The length estimation module is configured as follows: clustering the fish body contour point cloud into several clusters using a clustering algorithm; performing plane fitting processing on the fish body contour point cloud of each cluster, converting the fish body contour point cloud of each cluster to three planes, converting the data of the three planes to a spatial coordinate system, calculating the fish body length of each cluster corresponding to the fish body contour point cloud in the spatial coordinate system, and summing up the fish body lengths of all clusters to obtain the total length of the fish to be measured.

[0021] On the other hand, there is also provided an electronic device, comprising:

[0022] a memory for non-transitory storage of computer-readable instructions; and

[0023] a processor for executing the computer readable instructions,

[0024] When the computer-readable instructions are executed by the processor, the method described in the first aspect is executed.

[0025] On the other hand, a storage medium is provided, which non-temporarily stores computer-readable instructions, wherein when the non-temporary computer-readable instructions are executed by a computer, the instructions of the method described in the first aspect are executed.

[0026] On the other hand, a computer program product is provided, comprising a computer program, wherein the computer program is used to implement the method described in the first aspect when running on one or more processors.

[0027] The above technical solution has the following advantages or beneficial effects:

[0028] (1) The present invention designs and embeds a cross-modal feature fusion module into Mask R-CNN to effectively aggregate the fish body boundary features from RGB and disparity into a unified feature map. These feature maps help to eliminate incomplete fish bodies and improve the accuracy of the complete fish body mask boundary. A cross-modal feature fusion Mask R-CNN is proposed to extract the complete fish body mask in the binocular image and remove the incomplete fish body in the binocular image.

[0029] (2) A fish length estimation algorithm based on point cloud normalization segmentation transformation is designed to reduce the length estimation error of curved fish bodies. The fish body contour point cloud at any position is transformed by plane and ellipse fitting, and then transformed to a unified space for K-means clustering segmentation. The sum of the distances of each segment is used to estimate the length of the fish body. The fish body length estimation algorithm based on point cloud normalization segmentation transformation proposed in the present invention can reduce the length estimation error of curved fish bodies.

[0030] (3) The method of the present invention was tested on five fishes of different body shapes. The experimental results show that the length estimation method is accurate and reliable and is applicable to various fishes. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0032] Figure 1 is a flow chart of the method of embodiment 1;

[0033] FIG. 2( a ) and FIG. 2( b ) are the experimental data collection environment and equipment of Example 1;

[0034] FIG3(a) and FIG3(b) are photos of four fish of different sizes in Example 1;

[0035] Figure 4 The binocular camera geometric model of the first embodiment;

[0036] FIG5(a) and FIG5(b) are disparity maps obtained by SGBM calculation in Example 1;

[0037] Figure 6 The incomplete fish body disparity map of the first embodiment;

[0038] Figure 7 The overall network structure of CMFF Mask R-CNNN in Example 1;

[0039] Figure 8 Details of the RGB-parallax cross fusion module of Example 1;

[0040] Fig. 9 The ellipse fitted to the salmon outline of Example 1;

[0041] Figure 10(a) to Figure 10(c) The process of generating the fish body contour point cloud of embodiment 1;

[0042] Figure 11(a) to Figure 11(f) The conversion process of the fish body contour point cloud of the first embodiment;

[0043] FIG. 12( a) and FIG. 12( b) are final results of the fish body contour point cloud transformation of Example 1;

[0044] Figure 13(a) to Figure 13(d) Different strategies for fusing RGB and disparity images in embodiment 1;

[0045] Fig.14 This is the instance segmentation visualization result of the first embodiment;

[0046] Fig.15 is the relative error of the salmon length estimation in the experimental pond of Example 1;

[0047] Figure 16(a) to Figure 16(b) The non-bent fish and the bent fish in the experimental pool of Example 1;

[0048] Figure 17(a) to Figure 17(b) In the first embodiment, the center line of the fish is drawn on the image and points are uniformly selected along the center line and mapped to the 3D space;

[0049] Fig.18 The salmon length prediction result in the aquaculture environment of Example 1;

[0050] Figure 19(a) to Figure 19(d) This is the point cloud transformation process of the four fish in Example 1;

[0051] Fig. 20 This is the error in estimating the lengths of the four fish in Example 1. DETAILED DESCRIPTION

[0052] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0053] Automatic fish length estimation is crucial for modern aquaculture. In dense aquaculture environments, occlusion and body bending make accurate fish length estimation challenging. To address these issues, this paper proposes a fish length estimation method based on cross-modal feature fusion Mask R-CNN (CMFF Mask R-CNN) and point cloud normalization segmentation transformation. In order to eliminate the incomplete fish body in the binocular image due to occlusion and extract the complete fish body mask in the binocular image, a cross-modal feature fusion module is designed and embedded into Mask R-CNN to aggregate the fish body boundary features from RGB and disparity into a unified feature map. These feature maps help to remove incomplete fish bodies and improve the accuracy of complete fish body mask boundary prediction. A fish body length estimation algorithm based on point cloud normalization segmentation transformation is designed to reduce the length estimation error of fish body bending. The fish body contour point cloud at any position is transformed by plane and ellipse fitting, and then converted to a unified space for K-means clustering segmentation, and the sum of the distances of each segment is calculated to obtain the fish body length. The experimental results show that the average relative error of salmon length estimation is less than 5%. In addition, generalization experiments show that the average relative error of the proposed method for length estimation of four freshwater fish is less than 5%. This shows that the proposed fish length estimation method can be applied to aquaculture.

[0054] Embodiment 1

[0055] This embodiment provides a fish body length estimation method based on feature fusion and point cloud transformation;

[0056] like Figure 1 As shown, the fish body length estimation method based on feature fusion and point cloud transformation includes:

[0057] S101: Acquire a binocular image of a fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map;

[0058] S102: input the disparity map and the stereo-corrected left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish to be tested;

[0059] S103: performing a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determining the fish body contour point cloud based on the coordinate value of each pixel on the fish body contour and the corresponding disparity value;

[0060] S104: performing a plane fitting transformation on the fish body contour point cloud to maximize the area of ​​the fish body contour point cloud projected onto the plane; performing an ellipse fitting transformation on the projection of the fish body contour point cloud onto the plane to fit an ellipse, and based on the ellipse, ensuring that the connecting line between the fish mouth and the fish tail is parallel to the baseline;

[0061] S105: clustering the fish body contour point cloud into several clusters using a clustering algorithm; performing plane fitting processing on the fish body contour point cloud of each cluster, converting the fish body contour point cloud of each cluster to three planes, converting the data of the three planes to a unified spatial coordinate system, calculating the horizontal length of each cluster in the spatial coordinate system, summing the lengths of all clusters, and obtaining the total length of the fish body to be measured.

[0062] Furthermore, the step S101: acquiring a binocular image of the fish to be tested is performed by using a binocular camera to collect the image.

[0063] Exemplarily, the experimental data acquisition environment is shown in Figure 2(a), and the data acquisition platform is shown in Figure 2(b). The aquaculture pond is 1.25 meters deep and 5.5 meters in diameter, while the experimental pond is 0.8 meters deep and 2.5 meters in diameter. Both pools are supplied with circulating seawater and equipped with oxygen supply equipment. The images captured by the waterproof binocular camera are transmitted via USB. The distance between the two optical centers of the binocular camera is 60 mm. The resolution of a single camera is 1080×1080 pixels, and the frame rate is 15 frames per second.

[0064] Exemplarily, the binocular images obtained from the experimental pool are used to verify the accuracy of the fish length estimation algorithm based on the point cloud normalized segmentation transformation. A salmon was taken out of the breeding pond and placed in an anesthesia pool containing seawater mixed with anesthetics. The total length of the anesthetized salmon was measured using a tape measure with an accuracy of 0.1 cm. Subsequently, the salmon was placed in the experimental pool and photographed using a binocular camera. The number of salmon used for the length estimation algorithm test was 8.

[0065] For example, in addition, an indoor pool was built to capture binocular images of four fish with different body sizes to verify the generalization of the fish length estimation algorithm, as shown in Figure 3(a). The size of the pool is 1.5*1*0.5 meters and is equipped with an oxygen pump. The four fish are: black carp, bream, perch, and crucian carp. The four fish are placed in the tank and filmed using a binocular camera. After filming, their total length is manually measured using a tape measure with an accuracy of 0.1 cm, as shown in Figure 3(b).

[0066] It should be understood that in order to obtain three-dimensional information of the fish body from the binocular, the image needs to be stereo corrected. The calibration plate used in the calibration experiment consists of a 12×9 black and white square, and the size of each square is 30×30 mm. The calibration parameters of the binocular camera are calculated by the calibration algorithm proposed by Zhang. Then, the stereo correction is completed using the Bouguet stereo correction algorithm. After stereo correction, the binocular cameras are completely parallel. The geometric model of the binocular camera after correction is as follows Figure 4 shown.

[0067] Furthermore, the step S101: performing stereo correction on the binocular image includes:

[0068] The baseline length T of the binocular camera is equal to the norm of the translation vector obtained by calibration, point P target (X t ,Y t ,Z t ) in C left and C right There are two corresponding image points (u l ,v l ) and (u r ,v r ), according to the triangle similarity principle, the three-dimensional coordinates of the point can be obtained by the following formula:

[0069]

[0070] Among them, dx and dy represent the physical length of a single pixel in the horizontal and vertical directions respectively, and f represents the focal length of the camera.

[0071] Furthermore, the step S101: processing the stereo-corrected binocular image to obtain a disparity map includes: using a semi-global block matching algorithm (SGBM, Semi-Global Block Matching) to process the corrected binocular image to obtain a disparity map.

[0072] In a binocular image, the difference between the horizontal coordinates of the same pixel (u l -u r ) is obtained through stereo matching algorithm.

[0073] SGBM uses the grayscale similarity between pixels in the reference image and the target image, and introduces a smoothing term to obtain the optimal disparity for each pixel in the reference image.

[0074] The visualization of the stereo matching results is shown in Figure 5(a) and Figure 5(b). Figure 5(a) shows a fish with complete disparity, and Figure 5(b) shows a fish with incomplete disparity. The larger the disparity value, the larger the grayscale value, and the brighter it appears in the disparity map, indicating that the actual object is closer to the stereo camera. Due to occlusion, noise, and insufficient texture, some pixels cannot find matching points within the search range during the stereo matching process, so these pixels are represented as black pixels.

[0075] Although the fish mask in the left image is complete, the fish mask in the right image may be incomplete due to occlusion and stereo disparity. Therefore, the disparity map after stereo matching is also incomplete within the mask range, such as Figure 6As shown in Figure 1, the fish point cloud reconstructed in 3D space according to formula (1) is incomplete and lacks information about the length of the fish. It cannot be used for length estimation and needs to be eliminated. The current algorithm does not take this into account and estimates the length of all fish with complete features detected by the deep learning network in the left figure. They incorrectly estimate the length of the incomplete fish in the binocular image, increasing the error of the fish length estimation.

[0076] The disparity map can help the deep learning network identify the fish body with a complete mask in the binocular image for length estimation. The incompleteness of the fish body in the binocular image can be reflected in the disparity map. Based on the fish body mask and the disparity map in the left image, the present invention can know the disparity state in the fish body mask area, thereby determining that the fish body mask for length estimation should be extracted. According to formula (1), it is known that the depth and disparity are inversely proportional. The disparity boundary is almost the same as the depth boundary. The boundary of the depth map is consistent with the instance boundary. Therefore, the disparity map can also provide supplementary information to extract an accurate fish body mask in the left image.

[0077] Furthermore, the S102: inputting the disparity map and the stereo-corrected left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish body to be tested, wherein the trained cross-modal feature fusion Mask RCNN model includes:

[0078] A first backbone network ResNet50, wherein the input end of the first backbone network ResNet50 is used to input the left-eye image after stereo correction, and the first backbone network ResNet50 comprises: a first convolution module conv1, a second convolution module conv2_x, a third convolution module conv3_x, a fourth convolution module conv4_x, a fifth convolution module conv5_x, a first average pooling layer, a first fully connected layer and a first activation function layer connected in sequence;

[0079] A second backbone network ResNet50, wherein the input end of the second backbone network ResNet50 is used to input a disparity map, and the second backbone network ResNet50 comprises: a sixth convolution module conv1, a seventh convolution module conv2_x, an eighth convolution module conv3_x, a ninth convolution module conv4_x, a tenth convolution module conv5_x, a second average pooling layer, a second fully connected layer, and a second activation function layer connected in sequence;

[0080] The output end of the second convolution module conv2_x and the output end of the seventh convolution module conv2_x are both connected to the input end of the first RGB-parallax cross fusion module, and the first RGB-parallax cross fusion module outputs a first fusion feature;

[0081] The output end of the third convolution module conv3_x and the output end of the eighth convolution module conv3_x are both connected to the input end of the second RGB-parallax cross fusion module, and the second RGB-parallax cross fusion module outputs a second fusion feature;

[0082] The output end of the fourth convolution module conv4_x and the output end of the ninth convolution module conv4_x are both connected to the input end of the third RGB-parallax cross fusion module, and the third RGB-parallax cross fusion module outputs a third fusion feature;

[0083] The output end of the fifth convolution module conv5_x and the output end of the tenth convolution module conv5_x are both connected to the input end of the fourth RGB-parallax cross fusion module, and the fourth RGB-parallax cross fusion module outputs a fourth fusion feature;

[0084] The output end of the first RGB-parallax cross fusion module, the output end of the second RGB-parallax cross fusion module, the output end of the third RGB-parallax cross fusion module, and the output end of the fourth RGB-parallax cross fusion module are all connected to the input end of the feature pyramid network FPN, and the feature pyramid network outputs a plurality of feature maps;

[0085] The output end of the feature pyramid network FPN is connected to the input end of the region proposal network RPN, and the output end of the region proposal network RPN outputs the fish candidate region detection frame; the target detection layer ROI Align layer interpolates the fish candidate region detection frame, and inputs the interpolated detection frame and the feature map output by the feature pyramid network into the ROI head layer, which classifies the candidate region and regresses the bounding box. The ROI head layer inputs the output result into the fully convolutional network FCN to obtain the mask image of the fish to be tested.

[0086] It should be understood that the first convolution module conv1 and the sixth convolution module conv1 each include a convolution layer; the second convolution module conv2_x and the seventh convolution module conv2_x each include: three convolution units connected in sequence, each convolution unit includes three convolution layers connected in sequence; the third convolution module conv3_x and the eighth convolution module conv3_x each include: four convolution units connected in sequence, each convolution unit includes three convolution layers connected in sequence; the fourth convolution module conv4_x and the ninth convolution module conv4_x each include: six convolution units connected in sequence, each convolution unit includes three convolution layers connected in sequence; the fifth convolution module conv5_x and the tenth convolution module conv5_x each include: three convolution units connected in sequence, each convolution unit includes three convolution layers connected in sequence.

[0087] It should be understood that the feature pyramid network FPN is used to generate multi-scale feature maps. Feature maps of different resolutions are combined through top-down paths and lateral connections. The multi-scale feature extraction capability of the detection network is enhanced, so that the model can better detect objects of different sizes.

[0088] It should be understood that the region proposal network RPN is used to generate candidate regions (Region Proposals). It contains a series of sliding windows, through which anchor boxes are generated, and foreground / background classification and boundary regression are performed on each anchor box. It quickly generates regions that may contain targets for subsequent refinement and detection.

[0089] It should be understood that the target detection layer ROI Align layer is used to map the candidate region to the feature map and extract fixed-size features. Bilinear interpolation is used to avoid quantization errors and ensure accurate region alignment. High-quality features are generated for each candidate region for subsequent classification and regression.

[0090] It should be understood that the ROI head layer includes subnetworks for object classification and bounding box regression. The final object recognition and bounding box fine adjustment are performed from the features extracted by the ROIAlign layer, providing the final object category prediction and bounding box position.

[0091] It should be understood that the fully convolutional network FCN is used for semantic segmentation tasks. It contains a fully convolutional layer, which can generate a segmentation map of the same size as the input image. Each pixel is classified to generate a high-quality segmentation mask.

[0092] The present invention proposes a cross-modal feature fusion Mask R-CNN (CMFF Mask R-CNN), which can integrate the fish instance boundary information from the RGB image and the fish disparity boundary information from the disparity map to extract the complete fish mask in the binocular image and eliminate the incomplete fish mask.

[0093] CMFF Mask R-CNN is built on Mask R-CNN. In Mask R-CNN, a disparity feature extraction network branch ResNet50 and four RGB-disparity cross fusion modules are introduced to fuse the feature information of the two modalities to accurately predict the fish body mask.

[0094] like Figure 7 As shown, the process of the CMFF Mask R-CNN algorithm is as follows:

[0095] The RGB left image and disparity map are respectively input into the feature extraction backbone network ResNet50;

[0096] Two ResNet50 networks extract feature maps of four different scales for each modality;

[0097] Then, the four proposed RGB-disparity cross fusion modules perform cross feature fusion on the feature maps of different scales from RGB and disparity, respectively, to obtain feature maps of four different scales. This step helps the network to effectively fuse the complementary features in the two modalities.

[0098] Next, the feature maps of four different scales are simultaneously input into the Feature Pyramid Network (FPN) to fuse feature information of different scales and improve detection performance. In addition, the feature maps are processed by the Region Proposal Network (RPN) to generate region proposal boxes for object classification and bounding box regression. Finally, the feature maps obtained by processing the region proposal and feature pyramid through ROI Align are input into the ROI Head and the Fully Convolutional Network (FCN) to generate instance segmentation masks.

[0099] The proposed RGB-disparity cross-fusion module (RDCFM) aims to effectively utilize the complementarity and difference of RGB and disparity modalities in spatial position. Figure 8 As shown in the figure, channel attention mechanism and channel multiplication are used to adjust the feature weights between the two modalities. The adjusted RGB and disparity features are cross-fused with the original input to provide rich complementary and differential information. Then, the spatial attention mechanism is introduced to adjust the weights of the spatial features after cross-fusion. RDCFM will enhance the expression of common important features in the two modalities and suppress the expression of differential features.

[0100] Furthermore, the internal structures of the first RGB-parallax cross-fusion module, the second RGB-parallax cross-fusion module, the third RGB-parallax cross-fusion module and the fourth RGB-parallax cross-fusion module are consistent, and the first RGB-parallax cross-fusion module includes: a channel feature cross-fusion module and a spatial feature cross-fusion module connected in sequence.

[0101] Furthermore, the channel feature cross fusion module includes:

[0102] Since the subsequent processing of the RGB stream and the disparity map DM is the same, only the RGB stream is described; first, the two modes are connected along the channel direction, and then average pooling and maximum pooling are performed:

[0103]

[0104] Among them, ‖ represents the concatenation operation of the two modal channel features, Max represents the global maximum pooling operation, Avg represents the global average pooling operation, and G represents the sum of the average pooling and maximum pooling operations.

[0105] By using a multi-layer perceptron, we learn the cross-modal channel attention vector of RGB and establish the correlation between the channel features of the two modalities:

[0106]

[0107] Among them, Conv1 represents a 1×1 convolution, Sig represents the Sigmoid function, and relu represents the rectified linear unit;

[0108]

[0109] Next, the expression of common channel features with high importance is enhanced through formula (4-1) and formula (4-2), and the expression of significant differences between the features of the two modalities is suppressed:

[0110]

[0111] Among them, ⊙ represents the channel-by-channel multiplication operation.

[0112] Then, between the enhanced attention vector and the original input RGB features Channel-wise multiplication is performed between them as follows:

[0113]

[0114] Furthermore, the spatial feature cross-fusion module includes:

[0115] The enhanced disparity map features are fused with the original RGB features to provide the RGB feature map with complementary and difference feature information from the disparity map:

[0116]

[0117] In order to make full use of the complementarity and difference of the two modal features in spatial position, a spatial attention mechanism is introduced to convert RGB fused Mapped into space.

[0118] In addition, in order to preserve the original RGB information, maximum pooling and average pooling are used to convert RGB fused Mapped into space.

[0119]

[0120] Where Conv3 represents a 3×3 convolution operation.

[0121] Then, connect S rgb and S r ' gb , and use 3×3 convolution and sigmoid operation to obtain spatial attention weights:

[0122]

[0123]

[0124] Finally, RGB is merged by using spatial attention weights cfe and DM cfe Get the fusion feature F RD :

[0125]

[0126] in, Represents the point-wise product in space.

[0127] Furthermore, the S102: inputting the disparity map and the stereo-corrected left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish body to be tested, wherein the trained cross-modal feature fusion Mask RCNN model includes:

[0128] Constructing a training set, wherein the training set is a disparity map of a known fish body mask image and a left eye image after stereo correction;

[0129] The training set is input into the Mask RCNN model with cross-modal feature fusion, and the model is trained to obtain the trained Mask RCNN model with cross-modal feature fusion.

[0130] Furthermore, the step S103: performing a morphological corrosion operation on the mask image of the fish body to be detected to obtain the fish body contour, wherein the specific morphological corrosion operation includes:

[0131] The Mask RCNN with cross-modal feature fusion has extracted the fish body mask, which is a binary image. In the binary image, the fish body is white (value is 1) and the background is black (value is 0).

[0132] Select a 3×3 or 5×5 matrix as the structure element (kernel). Apply the morphological erosion operation to the fish mask image through the structure element to remove the pixels at the edge of the image and obtain the eroded image.

[0133] The original fish mask image and the eroded image are subjected to pixel-by-pixel exclusive OR (XOR) operation. The exclusive OR operation generates white pixels (value 1) where the two images are different, and black pixels (value 0) where the two images are the same. In the result image of the exclusive OR operation, the white part represents the difference area between the original image and the eroded image, that is, the outline of the fish body.

[0134] Furthermore, the step S103: determining the fish body contour point cloud based on the coordinate value of each pixel on the fish body contour and the corresponding disparity value, comprises:

[0135] Each pixel point on the fish body contour with coordinates (x, y) corresponds to a disparity value, and the disparity value is u l -u r ;

[0136] Substitute x, y and the corresponding disparity value into formula (1) to obtain the coordinates of the pixel point (x, y) in three-dimensional space;

[0137] Substitute all pixel coordinates and corresponding disparity values ​​on the fish body contour into formula (1) to calculate all three-dimensional coordinate points. Combine all three-dimensional coordinate points together to obtain the fish body contour point cloud.

[0138] It should be understood that in the conventional method, the length of the fish body is measured by arranging the fish in a straight line. The distance between the tip of the mouth and the tail end is used as the total length of the fish. The present invention uses an ellipse to fit the fish body contour. Fig. 9 Shows the salmon outline fitted into an ellipse. C f It is the outline of salmon; E f is the ellipse fitted from the contour; R f is the circumscribed rectangle of the outline.

[0139] For example, the fish body mask extracted by CMFF Mask R-CNN is subjected to morphological corrosion operation to obtain the fish body contour. The coordinates of each pixel on the contour and its corresponding disparity value are input into formula (1) to obtain the fish body contour point cloud, as shown in Figure 10(a) to Figure 10(c) As shown in Figure 10(a) shows the original image with the fish body contour; Figure 10(b) shows the disparity map with the fish body contour; Figure 10(c) shows the point cloud of the fish body contour.

[0140] The direction of the binocular camera optical axis is defined as the Z axis, the direction of the baseline is defined as the X axis, and the vertical direction of the XZ plane is defined as the Y axis. The original coordinates of the point cloud are represented as P(x, y, z). The transformation process is as follows: Figure 11(a) to Figure 11(f)As shown in Figure 11(a) shows the point cloud after plane fitting transformation; Figure 11(b) shows the point cloud after ellipse fitting transformation; Figures 11(c) and 11(d) show the XOY and XOZ views after point cloud clustering; Figures 11(e) and 11(f) show the XOY and XOZ views after segmentation plane fitting transformation.

[0141] The fish body contour point cloud reconstructed based on the fish body mask and disparity map is arbitrary in space, which is not conducive to the estimation of fish body length. Therefore, the present invention proposes a fish body length estimation algorithm based on point cloud normalization segmentation transformation to solve this problem. The point cloud is converted to a unified space through plane and ellipse fitting transformation. Then, the fish body length is calculated based on the point cloud segmented measurement addition strategy to reduce the length estimation error caused by the bending of the fish body.

[0142] The fish body contour point cloud is normalized to transform the point cloud at any position in space to a uniform position, ensuring that the line connecting the fish mouth and tail is horizontal and parallel to the baseline. This helps with subsequent point cloud clustering and segmentation operations.

[0143] Furthermore, the step S104: performing a plane fitting transformation on the fish body contour point cloud to maximize the area of ​​the fish body contour point cloud projected onto the plane specifically includes:

[0144] First, the fish outline point cloud is approximated as a plane, assuming that the equation of the plane is k1x+k2y+k3z+1=0, where k1, k2, and k3 are fitting coefficients;

[0145] Use the least squares method to obtain the three fitting coefficients k1, k2 and k3;

[0146] Then the unit normal vector n is obtained through the three fitting coefficients k1, k2 and k3:

[0147]

[0148] All three-dimensional coordinates in the original coordinate system are transformed to the X′O′Y′ plane of the coordinate system, as shown in Figure 11(a);

[0149] Transformed coordinates (x′, y′, z′) T With the original coordinates (x, y, z) T The relationship between them is as follows:

[0150]

[0151] Wherein, O′ is any point on the plane X′O′Y′ after fitting, m is a unit vector on the plane, and the unit vector p is obtained by the cross product of m and n.

[0152] Further, the S104: performing an ellipse fitting transformation on the projection of the fish body contour point cloud on the plane to fit an ellipse, and based on the ellipse, ensuring that the connecting line between the fish mouth and the fish tail is parallel to the baseline, specifically includes:

[0153] The projection of the fish body contour point cloud on the X′O′Y′ plane is approximated as an ellipse;

[0154] Assume that the equation of the ellipse is Ax′ 2 +Bx′y′+Cy′ 2 +Dx′+Ey′+F=0;

[0155] According to the ellipse fitting, the ellipse fitting coefficients A to F are obtained;

[0156] Using formula (13), we can obtain the coordinates of the center point of the ellipse (X0, Y0) and the inclination angle θ of the major axis:

[0157]

[0158] The center point is represented by O″(X0,Y0,0) T , the direction vectors of the major and minor axes are expressed as u = (sinθ, -cosθ, 0) T and v = (cosθ, sinθ, 0) T ;

[0159] The point cloud coordinates (x′, y′, z′) T Convert to the ellipse center point O″ as the origin, the ellipse major axis direction as the X″ axis, the minor axis direction as the Y″ axis, and the plane normal vector k = (0,0,1) T A new coordinate system with direction Z″;

[0160] The transformation relationship is shown in equation (14), and the fish contour point cloud after ellipse fitting transformation is shown in Figure 11(b);

[0161]

[0162] It should be understood that the plane fitting transformation operation maximizes the area of ​​the fish body contour point cloud projected onto the plane, solving the problem of imaging the fish at different angles between the image and the optical axis. The ellipse fitting transformation transforms the fish body contour point cloud to a uniform spatial position, making the line connecting the fish mouth and the fish tail parallel to the baseline.

[0163] When the fish body is bent, directly measuring the spatial distance between its head and tail may lead to significant length estimation errors. Therefore, the fish body is divided into multiple parts to approximate the bent posture of the fish body, the length of each part is calculated, and then they are added together to estimate the total length of the fish body, thereby reducing the length estimation error.

[0164] Furthermore, the step S105: clustering the fish body contour point cloud into a plurality of clusters using a clustering algorithm, including:

[0165] Extract the point cloud data on the X″ and Z″ axes, and use the K-means clustering algorithm to cluster the point cloud into three clusters, as shown in Figure 11(c). Then, obtain the boundary values ​​S1 and S2 on the X″ axis. Based on S1 and S2, (x′, y′, z′) is divided into three parts, P″ s1 (x″1, y″1, z″1) (x1″<S1), P s ″2(x″2,y″2,z″2)(S1≤x″2≤S2) and P s ″3(x3″,y3″,z3″)(S2<x3″).

[0166] Furthermore, the step S105: performing plane fitting processing on the fish body contour point cloud of each cluster, and converting the fish body contour point cloud of each cluster into three planes, includes:

[0167] Perform plane fitting on the segmented fish body contour point cloud, and assume that the equations of the three planes are i=1,2,3, where and is the fitting coefficient;

[0168] The nine fitting coefficients of the three equations are solved by the least square method, and the unit normal vectors of the three planes are obtained according to formula (11);

[0169] Then, P s1 ″,P s2 ″ and P s3 ″Transformed into three planes.

[0170] Further, the step S105: converting the data of the three planes into a unified spatial coordinate system, calculating the horizontal length of each cluster in the spatial coordinate system, and summing the lengths of all clusters to obtain the total length of the fish to be tested, includes:

[0171] The three planes along the X″ axis are converted into the OX″′Y″′Z″′ spatial coordinate system. All coordinate points of the fish body contour are in the Z i The coordinate of the ″′ axis is 0, as shown in Figure 12(a), l1, l2 and l3 represent the lengths of the three planes on the X″′ axis respectively, and the total length of the fish is the sum of l1, l2 and l3. Figure 12(b) shows the result of measuring the length of the fish body after converting the fish point cloud to the same plane;

[0172] Perform plane fitting on the segmented fish body contour point cloud. Assume that the equations of the three planes are i=1,2,3, where and is the fitting coefficient.

[0173] The nine fitting coefficients of the three equations are solved by the least squares method, and the unit normal vectors of the three planes are obtained according to formula (11), denoted as n i .

[0174] Then, P s1 ″,P s2 ″ and P s3 ″Transform to three planes and obtain new coordinate points in

[0175]

[0176] Then transform the three planes to the horizontal plane, and use formula (12) to get the coordinates Convert to (x i ″′,y i ″′,z i ″′) T .

[0177] Among them, O i "'yes m i They are the unit vectors on three planes, a / ||a||, b / ||b|| and c / ||c||. We take Unit vector p i is the vector m i and n i The cross product of .

[0178] The experiments of the present invention were run on an Intel(R) Core(TM) i9-10980XE CPU 3.00GHz and an NVIDIAGeForceRTX 3090GPU. During the training process, the optimizer used SGD, the initial learning rate was set to 0.001, and the learning rate was dynamically adjusted, decreasing at a decay rate of 0.1 after the 10th, 20th, and 30th epochs, respectively. The total epochs were 40, and the batch size was set to 4.

[0179] In the present invention, the performance of the network is evaluated by mAP (mean average precision). The performance of the fish recognition experiment of the positive sample is evaluated by precision, recall and F1 score. The performance of the fish mask segmentation experiment is evaluated by mean intersection over union (mIoU).

[0180]

[0181] Among them, AP irepresents the integral of the precision-recall curve of the target of category i over the domain, K is the total number of categories. TP, FP and FN represent the number of true positives, false positives and false negatives respectively. M represents the number of predicted images.

[0182] The fish length estimation results were evaluated by the mean absolute error (MAE), mean relative error (MRE), root mean square error (RMSE) and correlation coefficient (R), which were calculated by equations (20)-(23).

[0183]

[0184]

[0185] Among them, l i is the true value, is the predicted value, is the mean of the true values, is the mean of the predicted values ​​and N is the number of predicted values.

[0186] In this experiment, the network is used to extract fish body masks from the breeding pond. Fish bodies with complete masks and disparity are considered positive samples, while fish bodies with incomplete masks or disparity are considered negative samples. The training dataset consists of 2000 left images and disparity maps, and the test dataset contains 551 left images and disparity maps. In the training dataset, there are 234 images with fish bodies with complete masks in the left image but incomplete disparity in the disparity map. In the test dataset, there are 87 images with complete masks in the RGB left image but incomplete disparity in the disparity map.

[0187] The RGB-disparity cross fusion module helps the instance segmentation network to eliminate incomplete fish bodies in the binocular image, making the boundary of the complete fish body mask in the binocular image more accurate. In order to verify the superiority of the proposed RGB-disparity cross fusion module, the present invention tests different fusion methods and compares their performance. Figure 13(a) to Figure 13(d) Three RGB and disparity map fusion methods for instance segmentation are shown. The red and blue trapezoids represent the RGB and disparity map feature extraction modules, respectively, the green trapezoid represents the prediction module, the purple rectangle represents the attention module CBAM, and the yellow rectangle represents the RGB-disparity cross fusion module. Figure 13(b)-Figure 13(d) The model in is improved based on Mask R-CNN with ResNet50; FIG13(a) shows a processing diagram of the Mask R-CNN model; FIG13(b) shows a processing diagram of the RDC Mask R-CNN model;

[0188] Figure 13(c) shows a processing diagram of the RDFAMask R-CNN model; Figure 13(d) shows a processing diagram of the RDFAMask R-CNNwith CBAM model.

[0189] The experimental results are shown in Table 1. As can be seen from Table 1, when the model contains disparity information, the recall rates of all three models exceed 96%. Specifically, the proposed CMFF Mask R-CNN achieves a recall rate of 97.2%. In terms of accuracy, CMFF Mask R-CNN achieves a precision of 90.35%. Compared with the other three models, the F1 scores of CMFF Mask R-CNN are improved by 3.57%, 1.91%, and 2.13%, respectively.

[0190] Table 1. Recognition results of fish with complete mask and parallax

[0191]

[0192] In the test dataset, there are 87 negative fish that have complete masks in the RGB left image but incomplete disparity in the disparity map. The false detection rates of the four networks for these 87 fish are shown in Table 2. CMFF Mask R-CNN has the lowest false detection rate of only 20.67%, which is significantly lower than the other three models. The above results show that with the help of the RGB-disparity cross feature fusion module, CMFF Mask R-CNN can accurately exclude these negative fish. Although Mask R-CNN takes RGB images as input, it has learned the distribution of some fish with complete masks but incomplete disparity in the image from the training dataset, resulting in a false detection rate of 62.07%.

[0193] Table 2. Fish body misdetection rate with complete mask but incomplete parallax

[0194]

[0195] For instance segmentation networks, we should not only focus on the ability to identify positive samples, but also on its segmentation ability. According to Table 3, compared with the other two models, CMFF Mask R-CNN's mAP is improved by 0.4% and 1.0%, respectively. mIOU is also improved by 1.90% and 2.39%, respectively. Fig.14 As shown in Figure 2, the above experimental results and instance segmentation results show that the proposed CMFFMask R-CNN has better segmentation performance.

[0196] Table 3 Test set segmentation results

[0197]

[0198] Fish bodies with complete masks but incomplete disparity are regarded as negative samples. This is unfair to Mask R-CNN, which is trained only with RGB data, because Mask R-CNN regards these data as real samples. Therefore, the present invention creates another dataset containing 2000 images and divides them into training and validation sets at a ratio of 8:2, in which there are no fish bodies with complete masks but incomplete disparity. The experimental results of the four models are shown in Table 4. Compared with Mask R-CNN, the three networks containing disparity information have higher mAP and mIOU, among which CMFF Mask R-CNN performs best. The experimental results show that disparity information is helpful in improving network prediction accuracy and segmentation performance, and prove that CMFF Mask R-CNN can utilize disparity information more effectively.

[0199] Table 4 Experimental results on the dataset with complete fish mask but incomplete disparity

[0200]

[0201] In the experimental pool, 8 salmon were estimated 16 times using the fish length estimation method based on point cloud normalization segmentation transformation. The relative error of the length estimation is as follows: Fig.15 As shown in the box plots in . Each rectangular box reflects the 25th to 75th percentile of the measurement results. The red line in each box plot represents the median error. The purple dot represents the average relative error of the length estimation of each salmon. The maximum average relative error among the eight salmon is 3.13%, and the median relative error of the eight salmon is less than 4%. The above experimental results show that the fish body length estimation algorithm based on point cloud normalized segmentation transformation can effectively estimate the length of salmon.

[0202] In order to verify the effectiveness of segmented measurement in estimating the length of fish, the present invention selected 28 non-bent fish pictures and 33 bent fish pictures for testing, as shown in Figure 16 (a) for non-bent fish, and Figure 16 (b) for bent fish. The present invention performed non-segmented measurement, two-segmented measurement, and three-segmented measurement, and the results are shown in Table 5. As can be seen from Table 5, the segmented and non-segmented measurement errors of non-bent fish bodies are almost the same. However, for bent fish bodies, three-segmented measurement reduced the error by 4.7% compared to non-segmented measurement, and reduced the error by 1.23% compared to two-segmented measurement. This shows that segmented measurement has a positive effect on reducing the error in estimating fish length.

[0203] Table 5 Segment and non-segment length estimation measurement results

[0204]

[0205] Fish length estimation algorithms ultimately need to be applied in actual aquaculture environments. However, due to the large number of fish in aquaculture environments and their similar characteristics, it is difficult to obtain the true length of fish, which makes it challenging to verify fish length estimation algorithms in actual aquaculture environments.

[0206] To solve this problem, based on the principle of stereoscopic vision measurement, Yu et al. proposed using the length of the fish body when it is not bent and parallel to the stereoscopic vision camera as the true length of the fish body. Harvey et al. and Shafait et al. measured the length of the fish body by manually marking the key points on the fish body, with an error of less than 1%. Based on the above analysis, it is feasible to select the fish with the best posture from multiple frames of images and obtain the true length of the fish body by marking the key points.

[0207] As shown in Figure 17(a), the present invention manually marked the key points of the salmon's mouth tip and tail, and drew a red line based on these points as the total length. Then, several points were evenly selected along this line and mapped to 3D space, as shown in Figure 17(b). By calculating the distances between these points and adding them up, the total length of the fish can be obtained.

[0208] In order to verify the performance of the proposed algorithm in an actual aquaculture environment, 26 fish were selected from images captured in aquaculture ponds. The length of each fish was estimated 7 times using CMFF Mask R-CNN and point cloud normalization segmentation transformation. Some of the length estimation results are shown in Figure 2. Fig.18 The experimental results are listed in Table 6. According to Table 6, the correlation coefficients R are all higher than 0.9, indicating that there is a strong correlation between the manually measured length and the estimated length results. From the perspective of MAE, RMSE, and MRE, the prediction results of this method fluctuate less, indicating that the fish length estimation has a certain stability.

[0209] Table 6 Analysis of the error in the estimation of salmon length in the culture pond

[0210]

[0211] In order to verify the generalization ability of the point cloud normalization segmentation transformation algorithm, the present invention applies it to estimate the length of fish of different body sizes. Figures 19(a), 19(b), 19(c) and 19(d) show the masked images of four fish, their original contour point cloud images and the images after point cloud transformation. For each fish, the present invention performs 16 length estimations in the segmented (-a) and non-segmented (-b) cases respectively. The length estimation results are shown in Figure 19(a), 19(b), 19(c) and 19(d). Fig. 20 shown.

[0212] exist Fig. 20In the figure, the green dots represent the average fish length estimation errors without segmentation, which are: 3.54% for black carp, 3.38% for bream, 3.23% for sea bass, and 4.28% for crucian carp. The yellow dots represent the average fish length estimation errors after segmentation, which are: 2.97% for black carp, 2.59% for bream, 3.09% for sea bass, and 4.00% for crucian carp. The experimental results show that the fish length estimation method based on point cloud normalized segmentation transformation is applicable to fish of different sizes, and segmented estimation can reduce the length estimation error.

[0213] Occlusion and fish body curvature make it challenging to accurately estimate fish length in dense aquaculture environments. In order to remove the incomplete fish body in the binocular image and extract the mask of the complete fish body in the binocular image, the present invention proposes CMFF Mask R-CNN. Fish body curvature has a negative impact on fish length estimation. The present invention introduces a fish body length estimation method based on point cloud normalization segmentation transformation to solve this problem. The fish body contour point cloud is transformed into a unified spatial coordinate system after plane and ellipse fitting transformations for K-means clustering segmentation, and the fish body length is obtained by accumulating the distance of each segment. The average length estimation error of salmon and four freshwater fish is less than 5%, indicating that the proposed length estimation algorithm is suitable for estimating the length of fish of different body sizes.

[0214] Embodiment 2

[0215] This embodiment provides a fish length estimation system based on feature fusion and point cloud transformation, including:

[0216] An acquisition module is configured to: acquire a binocular image of the fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map;

[0217] A mask image generation module is configured to: input the disparity map and the stereo-rectified left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish to be tested;

[0218] The fish body contour point cloud generation module is configured to: perform a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determine the fish body contour point cloud based on the coordinate value and corresponding disparity value of each pixel on the fish body contour;

[0219] The fitting module is configured to: perform a plane fitting transformation on the fish body contour point cloud to maximize the area of ​​the fish body contour point cloud projected onto the plane; perform an ellipse fitting transformation on the projection of the fish body contour point cloud on the plane to fit an ellipse, and based on the ellipse, ensure that the connecting line between the fish mouth and the fish tail is parallel to the baseline;

[0220] The length estimation module is configured as follows: clustering the fish body contour point cloud into several clusters using a clustering algorithm; performing plane fitting processing on the fish body contour point cloud of each cluster, converting the fish body contour point cloud of each cluster to three planes, converting the data of the three planes to a spatial coordinate system, calculating the fish body length of each cluster corresponding to the fish body contour point cloud in the spatial coordinate system, and summing up the fish body lengths of all clusters to obtain the total length of the fish to be measured.

[0221] It should be noted that the acquisition module, mask image generation module, fish body contour point cloud generation module, fitting module and length estimation module correspond to steps S101 to S105 in Embodiment 1, and the examples and application scenarios implemented by the modules and the corresponding steps are the same, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the modules as part of the system can be executed in a computer system such as a set of computer executable instructions.

[0222] Embodiment 3

[0223] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory so that the electronic device executes the method described in the above embodiment one.

[0224] Embodiment 4

[0225] This embodiment further provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the method described in the first embodiment is completed.

[0226] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A fish body length estimation method based on feature fusion and point cloud transformation, characterized in that: include: Acquire a binocular image of the fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map; The disparity map and the stereo-rectified left eye image are input into the trained cross-modal feature fusion Mask RCNN model to obtain the mask image of the fish to be tested; Performing a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determining the fish body contour point cloud based on the coordinate value of each pixel on the fish body contour and the corresponding disparity value; The fish body contour point cloud is transformed into a plane fitting transformation to maximize the area of ​​the fish body contour point cloud projected onto the plane; the projection of the fish body contour point cloud onto the plane is transformed into an ellipse fitting transformation to fit an ellipse, and based on the ellipse, it is ensured that the connecting line between the fish mouth and the fish tail is parallel to the baseline; The fish body contour point cloud is clustered into several clusters using a clustering algorithm; the fish body contour point cloud of each cluster is plane fitting processed, and the fish body contour point cloud of each cluster is converted to three planes. The data of the three planes are converted to a spatial coordinate system, and the fish body length of each cluster corresponding to the fish body contour point cloud in the spatial coordinate system is calculated, and the fish body lengths of all clusters are summed up to obtain the total length of the fish body to be measured.

2. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 1, characterized in that: The disparity map and the stereo-corrected left eye image are input into the trained cross-modal feature fusion Mask RCNN model to obtain the mask image of the fish to be tested. The trained cross-modal feature fusion Mask RCNN model includes: A first backbone network ResNet50, wherein the input end of the first backbone network ResNet50 is used to input the left-eye image after stereo correction, and the first backbone network ResNet50 comprises: a first convolution module conv1, a second convolution module conv2_x, a third convolution module conv3_x, a fourth convolution module conv4_x, a fifth convolution module conv5_x, a first average pooling layer, a first fully connected layer and a first activation function layer connected in sequence; A second backbone network ResNet50, wherein the input end of the second backbone network ResNet50 is used to input a disparity map, and the second backbone network ResNet50 comprises: a sixth convolution module conv1, a seventh convolution module conv2_x, an eighth convolution module conv3_x, a ninth convolution module conv4_x, a tenth convolution module conv5_x, a second average pooling layer, a second fully connected layer, and a second activation function layer connected in sequence; The output end of the second convolution module conv2_x and the output end of the seventh convolution module conv2_x are both connected to the input end of the first RGB-parallax cross fusion module, and the first RGB-parallax cross fusion module outputs a first fusion feature; The output end of the third convolution module conv3_x and the output end of the eighth convolution module conv3_x are both connected to the input end of the second RGB-parallax cross fusion module, and the second RGB-parallax cross fusion module outputs a second fusion feature; The output end of the fourth convolution module conv4_x and the output end of the ninth convolution module conv4_x are both connected to the input end of the third RGB-parallax cross fusion module, and the third RGB-parallax cross fusion module outputs a third fusion feature; The output end of the fifth convolution module conv5_x and the output end of the tenth convolution module conv5_x are both connected to the input end of the fourth RGB-parallax cross fusion module, and the fourth RGB-parallax cross fusion module outputs a fourth fusion feature; The output end of the first RGB-parallax cross fusion module, the output end of the second RGB-parallax cross fusion module, the output end of the third RGB-parallax cross fusion module, and the output end of the fourth RGB-parallax cross fusion module are all connected to the input end of the feature pyramid network FPN, and the feature pyramid network outputs a plurality of feature maps; The output end of the feature pyramid network FPN is connected to the input end of the region proposal network RPN, and the output end of the region proposal network RPN outputs the candidate region detection frame of the fish body; the target detection layer ROI Align layer interpolates the candidate region detection frame of the fish body, and inputs the interpolated detection frame and the feature map output by the feature pyramid network into the ROI head layer. The ROIhead layer classifies the candidate region and regresses the bounding box. The ROI head layer inputs the output result into the fully convolutional network FCN to obtain the mask image of the fish to be tested.

3. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 2, characterized in that: The internal structures of the first RGB-parallax cross fusion module, the second RGB-parallax cross fusion module, the third RGB-parallax cross fusion module and the fourth RGB-parallax cross fusion module are consistent, and the first RGB-parallax cross fusion module includes: a channel feature cross fusion module and a spatial feature cross fusion module connected in sequence; The channel feature cross-fusion module includes: Since the subsequent processing of the RGB stream and the disparity map DM is the same, only the RGB stream is described; first, the two modes are connected along the channel direction, and then average pooling and maximum pooling are performed: Among them, || represents the concatenation operation of the two modal channel features, Max represents the global maximum pooling operation, Avg represents the global average pooling operation, and G represents the sum of the average pooling and maximum pooling operations; By using a multi-layer perceptron, we learn the cross-modal channel attention vector of RGB and establish the correlation between the channel features of the two modalities: Among them, Conv1 represents a 1×1 convolution, Sig represents the Sigmoid function, and relu represents the rectified linear unit; Next, the expression of common channel features with high importance is enhanced through formula (4-1) and formula (4-2), and the expression of significant differences between the features of the two modalities is suppressed: Among them, ⊙ represents the channel-by-channel multiplication operation; Then, between the enhanced attention vector and the original input RGB features Channel-wise multiplication is performed between them as follows:

4. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 3, characterized in that: The spatial feature cross-fusion module includes: The enhanced disparity map features are fused with the original RGB features to provide the RGB feature map with complementary and difference feature information from the disparity map: In order to make full use of the complementarity and difference of the two modal features in spatial position, a spatial attention mechanism is introduced to convert RGB fused Mapped into space; In addition, in order to preserve the original RGB information, maximum pooling and average pooling are used to convert RGB fused Mapped into space; Where Conv3 represents a 3×3 convolution operation; Then, connect S rgb and S r ' gb , and use 3×3 convolution and sigmoid operation to obtain spatial attention weights: Finally, RGB is merged by using spatial attention weights cfe and DM cfe Get the fusion feature F RD : in, Represents the point-wise product in space.

5. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 1, characterized in that: The fish body contour point cloud is transformed into a plane fitting to maximize the area of ​​the fish body contour point cloud projected onto the plane, including: First, the fish outline point cloud is approximated as a plane, assuming that the equation of the plane is k1x+k2y+k3z+1=0, where k1, k2 and k3 are fitting coefficients; the least squares method is used to obtain the three fitting coefficients k1, k2 and k3; Then the unit normal vector n is obtained through the three fitting coefficients k1, k2 and k3: All three-dimensional coordinates in the original coordinate system are transformed to the X′O′Y′ plane of the coordinate system; Transformed coordinates (x′, y′, z′) T With the original coordinates (x, y, z) T The relationship between them is as follows: Wherein, O′ is any point on the plane X′O′Y′ after fitting, m is a unit vector on the plane, and the unit vector p is obtained by the cross product of m and n.

6. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 1, characterized in that: The projection of the fish body contour point cloud on the plane is transformed into an ellipse fitting transformation to fit an ellipse. Based on the ellipse, the connection line between the fish mouth and the fish tail is ensured to be parallel to the baseline, specifically including: The projection of the fish body contour point cloud on the X′O′Y′ plane is approximated as an ellipse; assuming that the equation of the ellipse is Ax′ 2 +Bx′y′+Cy′ 2 +Dx′+Ey′+F=0; according to the ellipse fitting, the ellipse fitting coefficients A~F are obtained; Using formula (13), we can obtain the coordinates of the center point of the ellipse (X0, Y0) and the inclination angle θ of the major axis: The center point is represented by O″(X0,Y0,0) T , the direction vectors of the major and minor axes are expressed as u = (sinθ, -cosθ, 0) T and v = (cosθ, sinθ, 0) T ; The point cloud coordinates (x′, y′, z′) T Convert to the ellipse center point O″ as the origin, the ellipse major axis direction as the X″ axis, the minor axis direction as the Y″ axis, and the plane normal vector k = (0,0,1) T A new coordinate system with direction Z″; The transformation relationship is shown in equation (14), where the ellipse fits the transformed fish contour point cloud; 7. The method for estimating fish body length based on feature fusion and point cloud transformation as claimed in claim 1, characterized in that: The fish body contour point cloud is clustered into several clusters using a clustering algorithm, including: Extract the point cloud data on the X″ and Z″ axes, and use the K-means clustering algorithm to cluster the point cloud into three clusters. Then, obtain the boundary values ​​S1 and S2 on the X″ axis. Based on S1 and S2, divide (x″, y″, z″) into three parts, P″ s1 (x″1, y″1, z″1), P″ s2 (x″2,y″2,z″2) and P″ s3 (x″3,y″3,z″3);x″1<S1, S1≤x″2≤S2, S2<x″3; The fish body contour point cloud of each cluster is processed by plane fitting, and the fish body contour point cloud of each cluster is converted to three planes, including: Perform plane fitting on the segmented fish body contour point cloud, and assume that the equations of the three planes are in and is the fitting coefficient; The nine fitting coefficients of the three equations are solved by the least squares method, and the unit normal vectors of the three planes are obtained; then, P s1 ″,P s2 ″ and P s3 ″Transformed to three planes; The data of the three planes are converted to a unified spatial coordinate system, the horizontal length of each cluster in the spatial coordinate system is calculated, and the lengths of all clusters are summed to obtain the total length of the fish to be tested, including: The three planes along the X″ axis are converted into the OX″′Y″′Z″′ spatial coordinate system. All coordinate points of the fish body contour are in the Z i The coordinate of the '" axis is 0, l1, l2 and l3 represent the lengths of the three planes on the X'" axis respectively, and the total length of the fish is the sum of l1, l2 and l3. The fish point cloud is converted to the same plane and the length of the fish body is measured. The segmented fish body contour point cloud is plane fitted. The equations of the three planes are in and is the fitting coefficient; The nine fitting coefficients of the three equations are solved by the least squares method, and the unit normal vectors of the three planes are obtained, denoted as n i ; Then, P s1 ″,P s2 ″ and P s3 ″Transform to three planes and obtain new coordinate points in Then transform the three planes to the horizontal plane and change the coordinates Convert to (x″′ i ,y″′ i ,z″′ i ) T ; where O″′ i yes m i They are the unit vectors on three planes, a / ||a||, b / ‖b‖ and c / ||c‖; Unit vector p i is the vector m i and n i The cross product of .

8. A fish length estimation system based on feature fusion and point cloud transformation, characterized by: include: An acquisition module is configured to: acquire a binocular image of the fish body to be tested, perform stereoscopic correction on the binocular image, and process the stereoscopically corrected binocular image to obtain a disparity map; A mask image generation module is configured to: input the disparity map and the stereo-rectified left eye image into the trained cross-modal feature fusion Mask RCNN model to obtain a mask image of the fish to be tested; The fish body contour point cloud generation module is configured to: perform a morphological corrosion operation on the mask image of the fish body to be tested to obtain the fish body contour; determine the fish body contour point cloud based on the coordinate value and corresponding disparity value of each pixel on the fish body contour; The fitting module is configured to: perform a plane fitting transformation on the fish body contour point cloud to maximize the area of ​​the fish body contour point cloud projected onto the plane; perform an ellipse fitting transformation on the projection of the fish body contour point cloud on the plane to fit an ellipse, and based on the ellipse, ensure that the connecting line between the fish mouth and the fish tail is parallel to the baseline; The length estimation module is configured as follows: clustering the fish body contour point cloud into several clusters using a clustering algorithm; performing plane fitting processing on the fish body contour point cloud of each cluster, converting the fish body contour point cloud of each cluster to three planes, converting the data of the three planes to a spatial coordinate system, calculating the fish body length of each cluster corresponding to the fish body contour point cloud in the spatial coordinate system, and summing up the fish body lengths of all clusters to obtain the total length of the fish to be measured.

9. An electronic device, comprising: a memory for non-transitory storage of computer readable instructions; as well as a processor for executing the computer readable instructions, Wherein, when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 6 is executed.

10. A storage medium characterized by being non-temporary The computer-readable instructions are stored, wherein when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • Fish body size measurement and weight prediction method and device based on double-view fusion

    CN114241031A

  • Underwater fish biomass detection method and system

    CN117274786A

  • Computer vision-based full-cycle identification method for cultured fishes

    CN117912056A

  • Juvenile fish limb identification method based on multi-scale cascaded perceptual convolutional neural network

    US20230343128A1

Cited By

  • Flounder fish growth discrimination system and method

    CN119648773A

  • Image processing-based binocular camera fish body length identification method and system

    CN120564226A

  • A binocular camera fish body length recognition method and system based on image processing

    CN120564226B

  • Quantization method and system for fish arching degree

    CN121329999A

  • Fish body length measuring method and system

    CN121999355A