Shrimp length measurement method and system based on machine vision

Through the machine vision-based shrimp length measurement method, the PA-YOLOv7 network and SimAM attention mechanism are used to solve the problems of shrimp length measurement error and slow speed in the existing technology, and the rapid, accurate and automated shrimp length measurement is achieved. It provides high-precision data support for large-scale shrimp image processing.

CN117934583BActive Publication Date: 2024-12-27青岛励图高科信息技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410114042.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-27
Publication Date
2024-12-27
Estimated Expiration
2044-01-27

AI Technical Summary

Technical Problem

The existing shrimp length measurement technology has problems such as measurement error, slow speed, limited accuracy, high equipment cost, complex operation and unsuitable for large-scale measurements.

Method used

Using machine vision-based shrimp length measurement method, the shrimp instance segmentation model is constructed, and the PA-YOLOv7 network and SimAM attention mechanism are used, combined with the EIoU loss function, the segmentation mask of shrimp is automatically identified and the pixels on the length of its minimum rectangular frame are calculated. , and obtain the actual body length of the shrimp with reference.

Benefits of technology

It realizes fast, accurate and automated shrimp length measurement, improves measurement accuracy, is suitable for large-scale shrimp image processing, saves time and human resources, and provides important data support for shrimp farming.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117934583B_ABST
    Figure CN117934583B_ABST
Patent Text Reader

Abstract

The present invention relates to a shrimp length measurement method and system based on machine vision, belonging to the field of image processing technology, comprising the following steps: (1) obtaining an image to be identified; (2) inputting the image to be identified into a shrimp instance segmentation model, obtaining a segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on a sample image with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the shrimp length pixel data is obtained; (3) based on the image to be identified, the actual body length of each shrimp in the image to be identified is determined using the shrimp length pixel data. The advantages of the present invention are: it has the advantages of automation, rapidity, accuracy, etc., can save time and human resources, provide higher measurement accuracy, and provide important data support for shrimp farming and resource management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a shrimp length measurement method based on machine vision, and belongs to the technical field of image processing. Background Art

[0002] Shrimp resources are one of the most important economic resources in the world. As a rich source of food, shrimps are widely used in the fishery and aquaculture industries to meet the growing global demand for seafood. Shrimp farming is an important part of the global aquaculture industry, covering multiple shrimp species, such as prawns, prawns, and shrimps. Shrimp farming is highly favored for its high output value, high economic benefits and short breeding cycle. Through the cultivation of shrimp resources, the growth environment of shrimps can be controlled and optimized, thereby improving production and quality to meet the growing market demand for aquatic products.

[0003] In recent years, scholars have continuously studied and achieved certain results in shrimp length measurement. "A shrimp length rapid measurement device CN207622655U" controls the spacing between the holding plates by setting a coil spring, so as to facilitate the measurement of shrimps of different sizes. The coil spring in the device may have a certain elastic deformation, which may lead to measurement errors. Since the shrimps need to be placed on the holding plates one by one, the speed is subject to certain restrictions, especially when measuring in large quantities, the speed may be slow. "Shrimp length measurement device CN206235273U" places the shrimps to be measured in the space between the left measuring slot and the right measuring slot, and the shrimps will naturally be located between the two slides. By moving the flexible front slide bar and the flexible rear slide bar, the shrimps are clamped between the slides, and the position of the slide bar is controlled by a clamp to fix the length range of the shrimps. Then, the length of the shrimp can be measured by reading the data on the scale line. Although the device is relatively simple and has good adjustability, it has certain measurement accuracy and size limitations and is not suitable for large-scale measurement.

[0004] For example, the publication number is CN114998565A, and the name of the invention is: A size detection device and method for semi-finished shrimps, which discloses placing semi-finished Argentine red shrimps on a conveyor, and performing image acquisition when the conveyor belt is moving, processing the original image of the semi-finished shrimps according to the training model, obtaining the boundary box information of the semi-finished shrimps and the segmented image of the semi-finished shrimps, performing image processing on the segmented image, obtaining the contour image, contour feature information, skeleton line image and skeleton line feature information of the semi-finished shrimps, and establishing a length detection model based on the contour feature information and the main skeleton line feature information to determine the length of the semi-finished shrimps. Although this method uses a machine vision method, it measures semi-finished shrimps, and can only measure single shrimps. It is necessary to manually place the shrimps one by one on the conveyor belt, and the measurement efficiency is low.

[0005] For example, the publication number is CN108917616A, and the name of the invention is: Equipment and method for detecting the growth phenotype of live shrimps, which discloses that the shrimps to be tested are placed in a transparent pipe, and the industrial camera connected to the transparent pipe will collect images of the shrimps. The image recognition module in the computer will process and analyze the image, identify the characteristics of the shrimps, and measure the growth phenotype of the shrimps. Since this method uses more complex equipment, including a dark box, a transparent pipe, multiple industrial cameras and an industrial computer, the cost of the equipment itself is relatively high. Secondly, although the contact with the shrimps is reduced, the shrimps still need to be placed in a transparent pipe, and this process still has a certain interference with the shrimps. In addition, the maintenance and operation of the equipment may also be relatively complicated, requiring professional personnel to maintain and manage.

[0006] For example, the invention with the publication number CN115690546A and the name of the invention is: Shrimp length measurement method, device, electronic device and storage medium. The advantage of the invention is that it uses the target detection model to automatically, quickly and accurately detect the position and body length of each shrimp on the shrimp image. However, this method uses the Pythagorean theorem to deduce the length of the diagonal of the target detection frame to obtain the shrimp length. However, for shrimps in a horizontal or vertical state, calculating the shrimp length by the diagonal will cause the calculated length to be too large, resulting in errors. Summary of the invention

[0007] In order to overcome the defects of the prior art, the present invention provides a shrimp length measurement method based on machine vision. The technical solution of the present invention is:

[0008] A shrimp length measurement method based on machine vision comprises the following steps: (1) obtaining an image to be identified;

[0009] (2) inputting the image to be identified into a shrimp instance segmentation model, and obtaining a segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on sample images with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the pixel data of the shrimp length is obtained;

[0010] (3) Based on the image to be identified, the actual body length of each shrimp in the image to be identified is determined using the shrimp length pixel data.

[0011] The step (1) is specifically as follows:

[0012] The image to be identified includes image information of the shrimp to be identified and image information of the reference object. The shrimp to be identified is placed in a shallow tray or a shallow water tank filled with water, and the reference object is also placed therein to avoid mutual occlusion between the shrimps and between the shrimps and the reference object.

[0013] The step (2) is specifically:

[0014] S2.1 Construct shrimp instance segmentation image dataset:

[0015] 2.1.1 The method for constructing a shrimp instance segmentation image dataset includes: collecting shrimp images, and annotating shrimp contours to obtain annotated image data;

[0016] 2.1.2 The annotated image data is divided into training set, validation set and test set according to the preset ratio to obtain the shrimp instance segmentation image dataset: the shrimp instance segmentation model is constructed through the PA-YOLOv7 network, the collected shrimp images are obtained by edge devices, and the shrimp instance segmentation manual data is annotated through the labelme software. The generated json annotation file contains the category and location information of each point. The annotation information of each image is matched from the original json annotation file of the dataset according to the name and converted into a YOLO annotation format file. Finally, all image data are divided into training set, validation set and test set according to the ratio of 80%, 10%, and 10%, and finally the shrimp instance segmentation image dataset is formed;

[0017] S2.2 Shrimp instance segmentation model training:

[0018] S2.3 obtains the segmentation mask of each shrimp in the image to be identified according to the shrimp instance segmentation model, and obtains the minimum rectangular frame of each shrimp according to the segmentation mask, and the long side of the minimum rectangular frame is the number of pixels of the shrimp length.

[0019] The step S2.2 of shrimp instance segmentation model training is specifically as follows:

[0020] First, prepare a dataset of shrimp images. Then, according to the network structure of the PA-YOLOv7 algorithm, use the dataset to initialize the parameters in the network.

[0021] Next, the network is trained using the back-propagation algorithm and loss function. The training image data is input into the network, the difference between the predicted bounding box and length and the true annotation is calculated, and the network parameters are adjusted according to the difference, so that the prediction result gradually approaches the true annotation.

[0022] Finally, the trained network is tested using performance evaluation and validation datasets to evaluate the performance and accuracy of the network on the shrimp instance segmentation task. The shrimp instance segmentation model training is now complete.

[0023] The PA-YOLOV7 network consists of three parts: input, backbone and head. The input image is preprocessed and aligned into a 640*640 RGB image, which is input into the backbone network. This part consists of a series of convolutional layers, pooling layers and activation functions. In the convolutional layer, except for the first layer of the backbone, the 3*3 convolutional layer with a step size of 1 is replaced by PConv to extract image features.

[0024] The image features enter the Head part, where they are processed by the SPPCSPC module to enhance the feature expression capability. In the Head part, different convolutional layers and upsampling operations are used to fuse and combine multi-layer features to obtain feature representation.

[0025] Finally, the ISegment module is used to predict the bounding box and category probability of the target. The ISegment module generates a predicted bounding box based on the predefined anchor box and the features of the network output, and calculates the coordinate offset of the bounding box and the probability of the target category; the entire process is implemented through forward propagation. During the training process, the network parameters are optimized through the back-propagation algorithm and loss function, so that the network can detect the target in the image and predict its boundaries and categories;

[0026] The EIoU loss function is defined as follows:

[0027]

[0028] Among them, c w and c h is the width and height of the minimum bounding rectangle of the predicted bounding box and the true bounding box. ρ is the Euclidean distance between two points.

[0029] The step S2.3 is specifically as follows: obtaining the segmentation mask of each shrimp in the image to be identified according to the shrimp instance segmentation model, then finding the contour of each shrimp by using the findContours() function, and finding the minimum enclosing rectangle surrounding the contour by using the cv2.minAreaRect() function; using the cv2.boxPoints() function to convert the obtained rotated rectangle into its vertex coordinates, which are used to draw the rectangular bounding box;

[0030] Use the cv2.boundingRect() function to find the bounding box of the contour. The function returns the coordinates of the upper left corner (x, y) and the width (w) and height (h) of the bounding box. The maximum value of the width and height is the number of pixels of the shrimp length.

[0031] The step S3 is specifically as follows:

[0032] By calculating the ratio between the pixel size of the reference object in the image to be identified and the actual size, the proportional relationship of the objects in the image is obtained, and the actual body length of each shrimp in the image to be identified is deduced by combining this proportional relationship with the shrimp length pixel data;

[0033] Select the bottle cap as the reference. The bottle cap is red and has a diameter of 3 cm. By performing image processing, the RGB image is converted into an image in the HSV space. The threshold of the red image is used for extraction. The red HSV threshold range is H: 0-10, 170-180, S: 100-255, V: 100-255. Use the inRange function of opencv to extract the color. Then, an iterative algorithm is used to construct the minimum enclosing circle of the red area to obtain the number of pixels of the circle diameter.

[0034] The actual body length of the shrimp can be calculated using the following formula:

[0035]

[0036]

[0037] A shrimp length measurement system based on machine vision, comprising:

[0038] An image acquisition module, used for acquiring an image to be identified;

[0039] A shrimp length pixel data acquisition module is used to input the image to be identified into a shrimp instance segmentation model, and obtain the segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on sample images with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the shrimp length pixel data is obtained;

[0040] The actual body length determination module is used to determine the actual body length of each shrimp in the image to be identified based on the image to be identified and using the shrimp length pixel data.

[0041] The advantages of the present invention are: using instance segmentation technology to detect the length of shrimp, it has the advantages of automation, speed and accuracy, etc., can save time and human resources, provide higher measurement accuracy, and can process large-scale shrimp images, providing important data support for shrimp farming and resource management. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a schematic diagram of the process of the present invention.

[0043] Figure 2 It is the PA-YOLOV7 network structure diagram of the present invention.

[0044] Figure 3 yes Figure 2 Local convolution graph in .

[0045] Figure 4 It is the SimAM attention mechanism diagram of the present invention.

[0046] Figure 5 Schematic diagram of the rectangular side length of the shrimp length of the present invention.

[0047] Figure 6 It is the recognition effect diagram of the present invention.

[0048] Figure 7 The present invention is a structural block diagram of a shrimp length measurement system based on machine vision. DETAILED DESCRIPTION

[0049] The present invention will be further described below in conjunction with specific embodiments, and the advantages and features of the present invention will become clearer as the description proceeds. However, these embodiments are exemplary only and do not constitute any limitation to the scope of the present invention. It should be understood by those skilled in the art that the details and forms of the technical solution of the present invention may be modified or replaced without departing from the spirit and scope of the present invention, but these modifications and replacements all fall within the scope of protection of the present invention.

[0050] See also Figures 1 to 7 The present invention relates to a shrimp length measurement method based on machine vision, comprising the following steps: (1) obtaining an image to be identified; (2) inputting the image to be identified into a shrimp instance segmentation model, and obtaining a segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on a sample image with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the shrimp length pixel data is obtained; (3) based on the image to be identified, the actual body length of each shrimp in the image to be identified is determined using the shrimp length pixel data.

[0051] The step (1) is specifically as follows:

[0052] The image to be identified includes image information of the shrimp to be identified and image information of the reference object. The shrimp to be identified is placed in a shallow tray or a shallow water tank filled with water, and the reference object is also placed therein to avoid mutual occlusion between the shrimps and between the shrimps and the reference object.

[0053] The step (2) is specifically:

[0054] S2.1 Construct shrimp instance segmentation image dataset:

[0055] 2.1.1 The method for constructing a shrimp instance segmentation image dataset includes: collecting shrimp images, and annotating shrimp contours to obtain annotated image data;

[0056] 2.1.2 The annotated image data is divided into training set, validation set and test set according to the preset ratio to obtain the shrimp instance segmentation image dataset: the shrimp instance segmentation model is constructed through the PA-YOLOv7 network, the collected shrimp images are obtained by edge devices, and the shrimp instance segmentation manual data is annotated through the labelme software. The generated json annotation file contains the category and location information of each point. The annotation information of each image is matched from the original json annotation file of the dataset according to the name and converted into a YOLO annotation format file. Finally, all image data are divided into training set, validation set and test set according to the ratio of 80%, 10%, and 10%, and finally the shrimp instance segmentation image dataset is formed;

[0057] S2.2 Shrimp instance segmentation model training:

[0058] By improving the YOLOv7 algorithm to perform shrimp instance segmentation, we first made some improvements to the YOLOv7 algorithm, including improvements to the convolutional layer, adding an attention mechanism module to achieve better recognition results, and improving the loss function. Then we trained and verified the shrimp instance segmentation model, and improved the YOLOv7 algorithm to form a new algorithm PA-YOLOV7 (PConvAttention YOLOV7). The algorithm structure diagram is shown below: Figure 3 shown.

[0059] 1) Optimize the shrimp image recognition model using partial convolution: reduce occlusion, improve lightweight and reduce interference: In order to alleviate the occlusion problem of shrimp in the image, make the model lighter and reduce interference, partial convolution (PConv) will be introduced to extract spatial features more effectively by reducing redundant calculations and memory accesses at the same time. The specific method is to replace the 3*3 convolution with a step size of 1 with PConv except for the first layer of backbone, and conduct comparative experiments. The PConv structure diagram is as follows Figure 4 shown.

[0060] 2) Introducing SimAM attention mechanism to improve the accuracy and robustness of the model:

[0061] The SimAM attention mechanism can help the model better focus on important target areas, thereby improving the accuracy and robustness of the model in instance segmentation tasks. In the YOLOv7 network, the SimAM attention mechanism is added to the head structure of the model. By adding it in this way, the SimAM attention mechanism can realize weighted operations on feature maps of different resolutions. At the same time, this can also make full use of the feature information that has been extracted in the YOLOv7 network and further improve the performance of target detection. The SimAM attention mechanism is as follows Figure 5 shown.

[0062] 3) Use EIoU loss function to improve model performance: The core loss function of YOLOv7 is GIoULoss loss function, which calculates the minimum bounding rectangle for each predicted box and the true box. The calculation and convergence speed are limited. It is replaced by EIoU loss function. EIoU loss function takes into account the overlapping area, center point distance, length, width and side length, and solves the fuzzy definition of aspect ratio based on CIOU. EIoU includes three parts: IoU loss, distance loss, height and width loss (overlapping area, center point example, height and width ratio). Height and width loss directly minimizes the difference in height and width between the predicted target bounding box and the true bounding box, so that it has faster convergence speed and better positioning results.

[0063] S2.3 obtains the segmentation mask of each shrimp in the image to be identified according to the shrimp instance segmentation model, and obtains the minimum rectangular frame of each shrimp according to the segmentation mask, and the long side of the minimum rectangular frame is the number of pixels of the shrimp length.

[0064] The step S2.2 of shrimp instance segmentation model training is specifically as follows:

[0065] First, prepare a dataset of shrimp images. Then, according to the network structure of the PA-YOLOv7 algorithm, use the dataset to initialize the parameters in the network.

[0066] Next, the network is trained using the back-propagation algorithm and loss function. The training image data is input into the network, the difference between the predicted bounding box and length and the true annotation is calculated, and the network parameters are adjusted according to the difference, so that the prediction result gradually approaches the true annotation. During the training process, 300 epochs are trained, that is, the entire data set is traversed 300 times to ensure that the network converges to the optimal solution.

[0067] Finally, the trained network was tested through performance evaluation and verification data sets to evaluate the performance and accuracy of the network on the shrimp instance segmentation task. At this point, the shrimp instance segmentation model training was completed; in order to verify the good effect of the PA-YOLOV7 algorithm proposed in this invention on shrimp recognition, an algorithm ablation experiment was carried out.

[0068] Among them, the PA-YOLOV7 network consists of three parts: input, backbone and head. The input image is first preprocessed and aligned into a 640*640 RGB image, which is input into the backbone network. This part consists of a series of convolutional layers, pooling layers and activation functions. In the convolutional layer, except for the first layer of the backbone, the 3*3 convolutional layer with a step size of 1 is replaced by PConv, which is used to extract image features. These features contain semantic information of different scales at different levels, and gradually increase from low-level to high-level features; the image features enter the Head part, where the features are processed by the SPPCSPC module to enhance the feature expression ability; in the Head part, different convolutional layers and upsampling operations are used to fuse and combine multi-layer features to obtain richer feature representation. This multi-scale feature fusion helps to better detect targets of different sizes; finally, the bounding box prediction and category probability prediction of the target are performed through the ISegment module. The ISegment module generates a predicted bounding box based on the predefined anchor box and the features of the network output, and calculates the coordinate offset of the bounding box and the probability of the target category. The entire process is implemented through forward propagation. During the training process, the network parameters are optimized through the back-propagation algorithm and loss function, so that the network can detect the target in the image and predict its boundary and category.

[0069] The EIoU loss function is defined as follows:

[0070]

[0071] Among them, c w and c h is the width and height of the minimum bounding rectangle of the predicted bounding box and the true bounding box. ρ is the Euclidean distance between two points.

[0072] The step S2.3 is specifically as follows: according to the shrimp instance segmentation model, the segmentation mask of each shrimp in the image to be identified is obtained, and then the outline of each shrimp is found through the findContours() function, and the minimum circumscribed rectangle surrounding the outline is found using the cv2.minAreaRect() function; the obtained rotated rectangle is converted into its vertex coordinates using the cv2.boxPoints() function, and these coordinates are used to draw the rectangular bounding box; the bounding box of the outline is found using the cv2.boundingRect() function, which returns the upper left corner coordinates (x, y) and width (w) and height (h) of the bounding box; the maximum value of the width and height is the number of pixels of the shrimp length.

[0073] The step S3 is specifically as follows: by calculating the ratio between the pixel size of the reference object in the image to be identified and the actual size, the proportional relationship of the objects in the image is obtained, and the actual body length of each shrimp in the image to be identified is derived by combining the proportional relationship and the shrimp length pixel data;

[0074] Select the bottle cap as the reference. The bottle cap is red and has a diameter of 3 cm. By performing image processing, the RGB image is converted into an image in the HSV space. The threshold of the red image is used for extraction. The red HSV threshold range is H: 0-10, 170-180, S: 100-255, V: 100-255. Use the inRange function of opencv to extract the color. Then, an iterative algorithm is used to construct the minimum enclosing circle of the red area to obtain the number of pixels of the circle diameter.

[0075] The actual body length of the shrimp can be calculated using the following formula:

[0076] The present invention also relates to a shrimp length measurement system based on machine vision, comprising an image acquisition module 1, used to acquire an image to be identified; a shrimp length pixel data acquisition module 2, used to input the image to be identified into a shrimp instance segmentation model, and acquire a segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on sample images with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn to obtain the number of pixels of the long side of the minimum rectangular frame, and then the shrimp length pixel data is obtained; an actual body length determination module 3, used to determine the actual body length of each shrimp in the image to be identified based on the image to be identified and using the shrimp length pixel data.

[0077] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A shrimp length measurement method based on machine vision, characterized in that: The following steps are involved: Step (1) obtaining an image to be identified; Step (2) inputs the image to be identified into a shrimp instance segmentation model, and obtains a segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on a sample image with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the shrimp length pixel data is obtained; Step (3) based on the image to be identified, using the shrimp length pixel data to determine the actual body length of each shrimp in the image to be identified; The step (2) is specifically as follows: step S2.1 constructs a shrimp instance segmentation image dataset: 2.1.1 The method for constructing a shrimp instance segmentation image dataset comprises: collecting shrimp images, and annotating shrimp contours to obtain annotated image data; 2.1.2 The annotated image data is divided into training set, validation set and test set according to the preset ratio to obtain the shrimp instance segmentation image dataset: the shrimp instance segmentation model is constructed through the PA-YOLOv7 network, the collected shrimp images are obtained by edge devices, and the shrimp instance segmentation manual data is annotated through the labelme software. The generated json annotation file contains the category and location information of each point. The annotation information of each image is matched from the original json annotation file of the dataset according to the name and converted into a YOLO annotation format file. Finally, all image data are divided into training set, validation set and test set according to the ratio of 80%, 10%, and 10%, and finally the shrimp instance segmentation image dataset is formed; Step S2.2 Shrimp instance segmentation model training: Step S2.3 obtains the segmentation mask of each shrimp in the image to be identified according to the shrimp instance segmentation model, and obtains the minimum rectangular frame of each shrimp according to the segmentation mask, where the long side of the minimum rectangular frame is the number of pixels of the shrimp length; The step S2.2 of shrimp instance segmentation model training is specifically as follows: First, prepare a dataset of shrimp images. Then, according to the network structure of the PA-YOLOv7 algorithm, use the dataset to initialize the parameters in the network. Next, the network is trained using the back-propagation algorithm and loss function. The training image data is input into the network, the difference between the predicted bounding box and length and the true annotation is calculated, and the network parameters are adjusted according to the difference, so that the prediction result gradually approaches the true annotation. Finally, the trained network is tested using performance evaluation and validation datasets to evaluate the performance and accuracy of the network on the shrimp instance segmentation task. The shrimp instance segmentation model training is now complete. The PA-YOLOV7 network consists of three parts: input, backbone and head. The input image is preprocessed and aligned into a 640*640 RGB image, which is input into the backbone network. This part consists of a series of convolutional layers, pooling layers and activation functions. In the convolutional layer, except for the first layer of the backbone, the 3*3 convolutional layer with a step size of 1 is replaced by PConv to extract image features. The image features enter the Head part, where they are processed by the SPPCSPC module to enhance the feature expression capability. In the Head part, different convolutional layers and upsampling operations are used to fuse and combine multi-layer features to obtain feature representation. Finally, the ISegment module is used to predict the bounding box and category probability of the target. The ISegment module generates a predicted bounding box based on the predefined anchor box and the features of the network output, and calculates the coordinate offset of the bounding box and the probability of the target category. The entire process is implemented through forward propagation. During the training process, the network parameters are optimized through the back-propagation algorithm and the loss function, so that the network can detect the target in the image and predict its boundaries and categories. The EIoU loss function is defined as follows: Among them, c w and c h is the width and height of the minimum bounding rectangle of the predicted bounding box and the true bounding box, and ρ is the Euclidean distance between the two points.

2. The method for measuring shrimp length based on machine vision according to claim 1, characterized in that: The step (1) is specifically as follows: The image to be identified includes image information of the shrimp to be identified and image information of the reference object. The shrimp to be identified is placed in a shallow tray or a shallow water tank filled with water, and the reference object is also placed therein to avoid mutual occlusion between the shrimps and between the shrimps and the reference object.

3. The method for measuring shrimp length based on machine vision according to claim 1, characterized in that: The step S2.3 is specifically as follows: obtaining the segmentation mask of each shrimp in the image to be identified according to the shrimp instance segmentation model, then finding the contour of each shrimp by using the findContours() function, and finding the minimum enclosing rectangle surrounding the contour by using the cv2.minAreaRect() function; using the cv2.boxPoints() function to convert the obtained rotated rectangle into its vertex coordinates, which are used to draw the rectangular bounding box; Use the cv2.boundingRect() function to find the bounding box of the contour. The function returns the coordinates of the upper left corner (x, y) and the width (w) and height (h) of the bounding box. The maximum value of the width and height is the number of pixels of the shrimp length.

4. The method for measuring shrimp length based on machine vision according to claim 1, characterized in that: The step (3) is specifically as follows: By calculating the ratio between the pixel size of the reference object in the image to be identified and the actual size, the proportional relationship of the objects in the image is obtained, and the actual body length of each shrimp in the image to be identified is derived by combining this proportional relationship with the shrimp length pixel data; Select the bottle cap as the reference. The bottle cap is red and has a diameter of 3 cm. By performing image processing, the RGB image is converted into an image in the HSV space. The threshold of the red image is used for extraction. The red HSV threshold range is H: 0-10, 170-180, S: 100-255, V: 100-255. Use the inRange function of opencv to extract the color. Then, an iterative algorithm is used to construct the minimum enclosing circle of the red area to obtain the number of pixels of the circle diameter. The actual body length of the shrimp can be calculated using the following formula:

5. A shrimp length measurement system based on machine vision, characterized in that: include An image acquisition module is used to acquire an image to be identified, wherein the image to be identified includes image information of the shrimp to be identified and image information of a reference object. The shrimp to be identified is placed in a shallow tray or a shallow water tank filled with water, and the reference object is also placed therein to avoid mutual occlusion between the shrimps and between the shrimps and the reference object; A shrimp length pixel data acquisition module is used to input the image to be identified into a shrimp instance segmentation model, and obtain the segmentation mask of each shrimp in the image to be identified output by the shrimp instance segmentation model; the shrimp instance segmentation model is obtained after training based on sample images with shrimp contour position labels; based on the segmentation mask of each shrimp in the image to be identified, a minimum rectangular frame of the shrimp is drawn, the number of pixels of the long side of the minimum rectangular frame is obtained, and then the shrimp length pixel data is obtained; Construct a shrimp instance segmentation image dataset: The method for constructing a shrimp instance segmentation image dataset includes: collecting shrimp images, and annotating shrimp contours to obtain annotated image data; The annotated image data is divided into training set, validation set and test set according to the preset ratio to obtain the shrimp instance segmentation image dataset: the shrimp instance segmentation model is built through the PA-YOLOv7 network, the collected shrimp images are obtained by edge devices, and the shrimp instance segmentation manual data is annotated through the labelme software. The generated json annotation file contains the category and the location information of each point. The annotation information of each image is matched from the original json annotation file of the dataset according to the name and converted into a YOLO annotation format file. Finally, all image data are divided into training set, validation set and test set according to the ratio of 80%, 10%, and 10%, finally forming the shrimp instance segmentation image dataset; Shrimp instance segmentation model training: According to the shrimp instance segmentation model, the segmentation mask of each shrimp in the image to be identified is obtained, and the minimum rectangular frame of each shrimp is obtained according to the segmentation mask. The long side of the minimum rectangular frame is the number of pixels of the shrimp length. The shrimp instance segmentation model training is specifically as follows: First, prepare a dataset of shrimp images. Then, according to the network structure of the PA-YOLOv7 algorithm, use the dataset to initialize the parameters in the network. Next, the network is trained using the back-propagation algorithm and loss function. The training image data is input into the network, the difference between the predicted bounding box and length and the true annotation is calculated, and the network parameters are adjusted according to the difference, so that the prediction result gradually approaches the true annotation. Finally, the trained network is tested using performance evaluation and validation datasets to evaluate the performance and accuracy of the network on the shrimp instance segmentation task. The shrimp instance segmentation model training is now complete. The PA-YOLOV7 network consists of three parts: input, backbone and head. The input image is preprocessed and aligned into a 640*640 RGB image, which is input into the backbone network. This part consists of a series of convolutional layers, pooling layers and activation functions. In the convolutional layer, except for the first layer of the backbone, the 3*3 convolutional layer with a step size of 1 is replaced by PConv to extract image features. The image features enter the Head part, where they are processed by the SPPCSPC module to enhance the feature expression capability. In the Head part, different convolutional layers and upsampling operations are used to fuse and combine multi-layer features to obtain feature representation. Finally, the ISegment module is used to predict the bounding box and category probability of the target. The ISegment module generates a predicted bounding box based on the predefined anchor box and the features of the network output, and calculates the coordinate offset of the bounding box and the probability of the target category. The entire process is implemented through forward propagation. During the training process, the network parameters are optimized through the back-propagation algorithm and the loss function, so that the network can detect the target in the image and predict its boundaries and categories. The EIoU loss function is defined as follows: Among them, c w and c h is the width and height of the minimum bounding rectangle of the predicted bounding box and the true bounding box, and ρ is the Euclidean distance between the two points; The actual body length determination module is used to determine the actual body length of each shrimp in the image to be identified based on the image to be identified and using the shrimp length pixel data.