Fry counting system and counting method based on fry counting system
By combining a fish fry counting system with a YOLOv3 neural network, the system achieves automation and accuracy in fish fry counting, solving the problems of high labor intensity and large errors associated with manual counting. It is applicable to counting various types of fish fry.
Patent Information
- Application Number
- CN202211628597.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-17
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-12-17
AI Technical Summary
In existing technologies, fish fry counting relies on manual counting, which is labor-intensive and prone to errors. In particular, when counting large-scale fish fry, the labor intensity is high and the mortality rate of fish fry is high.
The system employs a fish fry counting system that combines an ultrasonic distance sensor, a camera, and a YOLOv3 neural network. Through the coordination of a water pump, a screw, and a fish baffle, the system automatically counts the fish fry. A photoelectric switch triggers the camera to take pictures, and image processing algorithms are used for accurate counting.
It achieves automation and accuracy in fish fry counting, reduces manual labor intensity, lowers errors, and is applicable to counting different types of fish fry, ensuring safety and reliability.
Smart Images

Figure CN117178935B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fishery breeding, in particular to a fry counting system and a counting method based on the fry counting system. Background Art
[0002] Accurately counting fry is essential for standardized aquaculture management, including scientific feeding, stocking density control, fry survival assessment, and fry purchase and sales. It is also a fundamental guarantee for implementing automated aquaculture. Currently, fry counting relies on manual counting, which is labor-intensive and subject to significant errors. Most counting methods estimate the number of fry based on a small cup. This method is inaccurate, subject to significant human error, and can result in significant errors. Furthermore, counting larger fry increases the labor intensity, and the mortality rate during fry counting is high. Summary of the Invention
[0003] In view of this, the object of the present invention is to provide a fish fry counting system and a counting method based on the fish fry counting system, which replaces manual counting and can be applied to the counting of different types of fish fry, and is simple to use and safe and reliable.
[0004] To achieve the above-mentioned purpose, the present invention adopts the following technical scheme: a fry counting system, comprising a water pump (1), a nozzle (2), an ultrasonic distance detection sensor (3), a rubber (4), a belt with a baffle (5), a camera (6), a photoelectric sensor (7), a fry collection bin (8) after counting, a screw and a fish baffle (9), a motor (10), and a fry collection bin (11) before counting; the detection sensor (3) is connected to the control motor (10); the water pump (1) is connected to the nozzle (2), and the water pump (1) and the nozzle (2) are arranged The device is placed above the fry collection bin (11) before counting, and the screw and the fish baffle (9) are arranged in front of the fry collection bin (11) before counting; the screw and the fish baffle (9) are connected to a motor (10), and the motor (10) drives the screw and the fish baffle (9) to move up and down linearly; an ultrasonic distance detection sensor (3) is arranged above the fry collection bin (11) before counting, and the ends of the screw and the fish baffle (9) are connected to one end of a rubber (4), and the other end of the rubber (4) abuts against the belt (5) with the baffle;
[0005] The belt (5) with baffles is provided with baffle grooves at fixed intervals, and the baffle grooves evenly separate the fry; the camera 96 is provided in front of the belt (5) with baffles for obtaining images of the fry; a photoelectric switch (7) is provided in front of the camera (6) for triggering a photo taking control; and the viewing angle range of the camera (6) is the same as the width of each baffle groove at fixed intervals of the belt (5) with baffles.
[0006] The present invention also provides a counting method based on a fry counting system, which adopts a fry counting system and comprises the following steps:
[0007] Step S1: The configured water pump (1) sprays water through the nozzle (2) into the pre-counting fry collection chamber (11), wherein the pre-counting fry collection chamber (11) contains fry to be counted; the screw and the fish baffle (9) move up and down to form a water level difference in the pre-counting fry collection chamber (11), so that the fry in the pre-counting fry collection chamber (11) enter the belt (5) with the baffle through the rubber (4);
[0008] If the ultrasonic distance detection sensor (3) does not detect the discharge of the fry, the motor (10) controls the screw and the baffle of the fish baffle (9) to move linearly downward, opening the fry discharge port until fry are discharged. At this time, the ultrasonic distance detection sensor (3) controls the motor (10) to stop moving downward, and the cycle is repeated to ensure that all the live fry are discharged to the conveyor belt (5) with the baffle.
[0009] Step S2: All discharged fry fall into the belt with baffles (5), and the fry finally fall into the fry collection bin (8) after being counted via the belt with baffles (5);
[0010] When the baffle of the baffle groove reaches the photoelectric switch (7), the photoelectric switch 7 is triggered and the camera (6) is controlled to trigger and take a photo; when the field of view of each baffle groove enters the camera, a photo is triggered and taken, and after the photo is taken, the camera enters the background to perform image processing for fry counting;
[0011] Step S3: Counting the fry using a fry counting image processing method.
[0012] In a preferred embodiment, step S3 specifically includes the following steps:
[0013] Step S31: Input of fry images, obtained based on steps S1 to S2, the obtained images are first used for training, and part of the images are used for testing; train and test the available YOLOV3 network in advance and save it. One YOLOV3 network can only be used for counting one type of fry;
[0014] Step S32: The acquired fry images are divided into a training set and a test set. Both sets of images are first converted to grayscale values and the maximum inter-class variance method is used to separate the background. On this basis, a combination of morphological corrosion and expansion operations is performed, and feature extraction and classification are prepared.
[0015] Step S33: The YOLOV3 network converts the target detection into a target classification problem, divides the image area into confidence boxes of different sizes, classifies the confidence boxes, and then adjusts the confidence boxes; a modified version of YOLOV3 is used;
[0016] First, use the following function to express the input-output relationship of the classification neural network used by YOLOV3:
[0017] N=f(W(σ(X)+b)) (1)
[0018] Where f is the function expression of the YOLOV3 classification neural network, W and b are the learned weights and biases, σ is the activation function, and X is the input of the neural network, which is the information after the fry image is preprocessed and the confidence box is circled;
[0019] Then, perform first-order Taylor expansion on formula (1) to obtain:
[0020]
[0021] Where ΔW and Δb are the step increase values of W and b respectively. is the expanded residual;
[0022] Define the reference value, set it to 1, and further define Subtracting N(t+1) from both sides of formula (2) yields:
[0023] ∈(t+1)=∈(t)+φ(t)U(t)+ω(t) (3)
[0024] in, represents the partial derivative, It is the partial derivative of function f with respect to weight value W, It is the partial derivative of function f with respect to the bias b;
[0025] Since ∈(t) is known, let the learning rate U(t) be as follows:
[0026] U(t)=G∈(t) (4)
[0027] Among them, G is the controller parameter to be determined;
[0028] Substituting the learning rate U(t) in formula (4) into the neural network system in formula (3), we get:
[0029] ∈(t+1)=(I+φ(t)G)∈(t)+ω(t) (5)
[0030] Where I is the identity matrix; the Lyapunov function is established as follows:
[0031] V(t)=∈ T (t)P∈(t) (6)
[0032] Where P is a positive definite symmetric matrix;
[0033] Calculating the difference function ΔV(t) of the Lyapunov function, we get:
[0034]
[0035] Define the matrix H, then from formula (5), we get:
[0036] 0=2∈ T (t+1)H[-∈(t+1)+(I+φ(t)G)∈(t)+ω(t)] (8)
[0037] The following performance index function J(t) is given:
[0038]
[0039] Among them, γ is the performance index;
[0040] Now combining equations (7)-(9), we get the following nonlinear matrix inequality:
[0041]
[0042] When formula (10) holds, ΔV(t) < 0, which means that the system is stable, that is, the learning algorithm (4) makes the neural network output N(t) close to the reference value. And the performance index γ with deviation;
[0043] definition
[0044] G=φ T (t)[φ(t)φ T (t)] -1 g (11)
[0045] Where G is the parameter of the learning algorithm, g is a linear matrix parameter with appropriate dimensions; then, define Substituting formula (11) into (10), we obtain:
[0046]
[0047] Solve inequality (12) using MATLAB's LMI toolbox, and the learning rate parameter g is obtained as follows:
[0048]
[0049] Now, after substituting formula (13) into formula (11) and formula (4), the neural network learning algorithm for solution is as follows:
[0050] U(t)=φ T (t)[φ(t)φT (t)] -1 g∈(t) (14)
[0051] In order to consider [φ(t)φ T (t)] -1 It is very likely that a singularity will occur and the inverse solution of the matrix cannot be obtained. Here we modify the neural network learning algorithm for the solution as follows
[0052] U(t)=φ T (t)[φ(t)φ T (t)+δI] -1 g∈(t) (15)where δ is a very small scalar;
[0053] Finally, further Substituting into formula (15), the final solution of the neural network learning algorithm is as follows:
[0054]
[0055] and
[0056]
[0057] in It represents solving the square of the 2-norm of information*.
[0058] Compared with the prior art, the present invention has the following beneficial effects: it can replace manual counting, can be applied to the counting of different types of fry, and is simple to use and safe and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 A block diagram of a fry counting system according to a preferred embodiment of the present invention is shown;
[0060] Figure 2 A schematic flow chart of a method for using a fry counting system according to a preferred embodiment of the present invention;
[0061] Figure 3 1 is a flow chart of step S3 of the method for using the fry counting system according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0062] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0063] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.
[0064] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form, and it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.
[0065] Fry counting system, as attached Figure 1 As shown, it includes a water pump 1, a nozzle 2, an ultrasonic distance detection sensor 3, a rubber 4, a belt with a baffle 5, a camera 6, a photoelectric sensor 7, a fry collection bin 8 after counting, a screw and a fish baffle 9, a motor 10, and a fry collection bin 11 before counting;
[0066] Counting method based on fry counting system, reference Figure 2 , including the following steps:
[0067] Step S1: A configured water pump 1 sprays water through a nozzle 2 into a pre-counting fry collection bin 11, wherein the pre-counting fry collection bin 11 contains fry to be counted; a screw and a fish baffle 9 are provided in front of the pre-counting fry collection bin 11, and the screw and the fish baffle 9 are moved up and down linearly by a motor 10; an ultrasonic distance detection sensor 3 is provided above the pre-counting fry collection bin 11, and the screw and the fish baffle 9 are moved up and down linearly by the motor 10; when the screw and the fish baffle 9 move up and down linearly, a rubber 4 is provided that moves therewith, thereby ensuring that the living fry are evenly distributed and discharged onto a belt 5 with a baffle.
[0068] The configured water pump 1 sprays water through the nozzle 2 into the fry collection bin 11 before counting, so that the fry in the fry collection bin before counting have enough water to survive. The front of the fry collection bin 11 before counting is equipped with a screw and a fish baffle 9. The screw and the fish baffle 9 use an electric motor 10 to make linear movements up and down, so that the amount of fry discharged can be controlled by controlling the height of the screw and the fish baffle 9. The ultrasonic distance detection sensor 3 and the motor 10 are linked together. If the ultrasonic distance detection sensor 3 cannot detect the discharge of fry for a long time, the motor 10 controls the screw and the baffle of the fish baffle 9 to move linearly downward, opening the fry discharge port until fry are discharged. At this time, the ultrasonic distance detection sensor 3 controls the motor 10 to pause downward movement, and the cycle is repeated to ensure that the living fry can be evenly discharged to the belt 5 with the baffle.
[0069] Step S2: The evenly distributed fry fall onto a baffled belt 5, which has regularly spaced baffle grooves that evenly separate the fry. A camera 6 is located in front of the belt to capture images of the fry. A photoelectric switch 7 is also located in front to trigger a camera to take photos. Finally, the fry fall into a counted fry collection bin 8.
[0070] The baffled belt 5 has baffle grooves at fixed intervals in order to ensure that the whole fish can fall into the camera's shooting area when taking pictures, because the half-cut fry image is difficult to process or has counting errors. The viewing angle range design of the camera 6 is the same as the width of each baffle groove at fixed intervals of the belt, in order to easily divide the target area of the fry and make subsequent image processing easier and more accurate. A photoelectric switch 7 is provided in front of the camera 6. When the baffled belt 5 of each baffle groove reaches the photoelectric switch 7, the photoelectric switch 7 is triggered and the camera 6 is controlled to trigger the picture taking. The result of this arrangement is that when the field of view of each baffle groove enters the camera, it will trigger a picture taking, and after taking the picture, it will enter the background to carry out the fry counting image processing.
[0071] Step S3: Design of image processing method for fry counting.
[0072] First, create a flow chart, which includes 4 steps, as shown in the attached figure. Figure 3 As shown:
[0073] 3.1 Image Input
[0074] The input fish fry images are obtained based on steps S1-2. These images are used for training, and a portion for testing. A modified version of YOLOv3 is used. Due to the variety of fish fry species, the device we developed can be used for counting multiple fry. However, this requires pre-training and testing a working YOLOv3 network, which must be saved. A single YOLOv3 network can only be used for counting one type of fry.
[0075] 3.2 Image Preprocessing
[0076] The acquired fish fry images are divided into training set and test set. Both sets of images are first converted into grayscale values, and the maximum inter-class variance method is used to separate the background. On this basis, a combination of morphological corrosion and dilation operations are performed, and feature extraction and classification are prepared.
[0077] 3.3 Image Feature Extraction and Classification
[0078] This is the most critical step in using the YOLOv3 network. The network transforms object detection into an object classification problem, segmenting image regions into confidence boxes of varying sizes, classifying these confidence boxes, and then adjusting them. Therefore, the core technology lies in classification, which uses gradient descent, which can easily lead to local minima and large classification errors. This case uses a modified version of YOLOv3, the core of which lies in the different classification algorithms.
[0079] First, use the following function to express the input-output relationship of the classification neural network used by YOLOV3:
[0080] N=f(W(σ(X)+b)), (1)
[0081] Among them, f is the functional expression of the YOLOV3 classification neural network, W and b are the learned weight values and biases, σ is the activation function, and X is the input of the neural network. The input here is the information after the fry image is preprocessed and the confidence box is circled.
[0082] Then, perform first-order Taylor expansion on formula (1) to obtain:
[0083]
[0084] Where ΔW and Δb are the step increase values of W and b respectively. is the expanded residual, It is the partial derivative of function f with respect to weight value W, It is the partial derivative of the function f with respect to the bias b.
[0085] Define the reference value, set it to 1, and further define Subtract N(t+1) from both sides of formula (2) to obtain:
[0086] ∈(t+1)=∈(t)+φ(t)U(t)+ω(t), (3)
[0087] in, represents the partial derivative.
[0088] Since ∈(t) is known, we can design the learning rate U(t) as follows:
[0089] U(t)=G∈(t), (4)
[0090] Among them, G is the controller parameter to be determined.
[0091] Further substituting the learning rate U(t) in (4) into the neural network system in (3), we get:
[0092] ∈(t+1)=(I+φ(t)G)∈(t)+ω(t). (5)
[0093] Where I is the identity matrix. In order to solve the controller gain G, the Lyapunov function is established as follows:
[0094] V(t)=∈ T (t)P∈(t), (6)
[0095] Where P is a positive definite symmetric matrix.
[0096] Calculating the difference function ΔV(t) of the Lyapunov function, we get:
[0097]
[0098] Define the matrix H, then from formula (5), we get:
[0099] 0=2∈ T (t+1)H[-∈(t+1)+(I+φ(t)G)∈(t)+ω(t)]. (8)
[0100] The following performance index function J(t) is given:
[0101]
[0102] Among them, γ is the performance indicator.
[0103] Now combining equations (7)-(9), we get the following nonlinear matrix inequality:
[0104]
[0105] When formula (10) holds, ΔV(t) < 0, which means that the system is stable, that is, the learning algorithm (4) enables the neural network output N(t) used to approach the reference value And has a performance indicator γ with deviation.
[0106] This has been done. However, the parameter G of the learning algorithm cannot be obtained by solving the above nonlinear matrix inequality (10), so we define
[0107] G=φ T (t)[φ(t)φ T (t)] -1 g, (11)
[0108] Where g is a linear matrix parameter with appropriate dimensions. Next, define Substituting formula (11) into (10), we obtain:
[0109]
[0110] By solving inequality (12) using the LMI toolbox in MATLAB, the learning rate parameter g can be obtained as follows:
[0111]
[0112] Now, after substituting formula (13) into formula (11) and formula (4), the neural network learning algorithm for solution is as follows:
[0113] U(t)=φ T (t)[φ(t)φT (t)] -1 g∈(t). (14)
[0114] In order to consider [φ(t)φ T (t)] -1 It is very likely that a singularity will occur and the inverse solution of the matrix cannot be obtained. Here we modify the neural network learning algorithm for the solution as follows
[0115] U(t)=φ T (t)[φ(t)φ T (t)+δI] -1 g∈(t). (15)
[0116] Here, δ is a very small scalar.
[0117] Finally, further Substituting into formula (15), the final solution of the neural network learning algorithm is as follows:
[0118]
[0119] and
[0120]
[0121] in It represents solving the square of the 2-norm of information*.
Claims
1. A counting method based on a fry counting system, characterized in that A fry counting system is used, the fry counting system comprising a water pump (1), a nozzle (2), an ultrasonic distance detection sensor (3), a rubber (4), a belt with a baffle (5), a camera (6), a photoelectric sensor (7), a fry collecting bin (8) after counting, a screw and a fish baffle (9), a motor (10), and a fry collecting bin (11) before counting; the ultrasonic distance detection sensor (3) is connected to the control motor (10); the water pump (1) is connected to the nozzle (2), and the water pump (1) and the nozzle (2) are arranged Above the fry collection bin (11) before counting, the screw and the fish baffle (9) are arranged in front of the fry collection bin (11) before counting; the screw and the fish baffle (9) are connected to a motor (10), and the motor (10) drives the screw and the fish baffle (9) to move linearly up and down; an ultrasonic distance detection sensor (3) is arranged above the fry collection bin (11) before counting, and the ends of the screw and the fish baffle (9) are connected to one end of a rubber (4), and the other end of the rubber (4) abuts against the belt (5) with the baffle; The belt (5) with baffles is provided with baffle grooves at fixed intervals, and the baffle grooves evenly separate the fry; the camera (6) is provided in front of the belt (5) with baffles for obtaining images of the fry; a photoelectric sensor (7) is provided in front of the camera (6) for triggering a photo taking control; the viewing angle of the camera (6) is the same as the width of each of the baffle grooves at fixed intervals on the belt (5) with baffles; The counting method includes the following steps: Step S1: The configured water pump (1) sprays water through the nozzle (2) into the pre-counting fry collection chamber (11), wherein the pre-counting fry collection chamber (11) contains fry to be counted; the screw and the fish baffle (9) move up and down to form a water level difference in the pre-counting fry collection chamber (11), so that the fry in the pre-counting fry collection chamber (11) enter the belt (5) with the baffle through the rubber (4); If the ultrasonic distance detection sensor (3) does not detect the discharge of the fry, the motor (10) controls the screw and the fish baffle (9) to move linearly downward, opening the fry discharge port until fry are discharged. At this time, the ultrasonic distance detection sensor (3) controls the motor (10) to stop moving downward, and the cycle is repeated to ensure that all the live fry are discharged to the belt with the baffle (5); Step S2: All discharged fry fall into the belt with baffles (5), and the fry finally fall into the fry collection bin (8) after being counted via the belt with baffles (5); When the baffle of the baffle slot reaches the photoelectric sensor (7), the photoelectric sensor (7) is triggered and the camera (6) is controlled to trigger a photo. When the field of view of each baffle slot enters the camera, a photo is triggered and taken. After the photo is taken, the camera enters the background to process the image of the fry counting. Step S3: Counting the fry using a fry counting image processing method; The step S3 specifically includes the following steps: Step S31: Input of fry images, obtained based on steps S1 to S2, the fry images obtained are first used for training, and part of the images are used for testing; train and test the available YOLOV3 network in advance and save it. One YOLOV3 network can only be used for counting one type of fry; Step S32: The acquired fry images are divided into a training set and a test set. Both sets of images are first converted to grayscale values and the maximum inter-class variance method is used to separate the background. On this basis, a combination of morphological corrosion and expansion operations is performed, and feature extraction and classification are prepared. Step S33: The YOLOV3 network converts the target detection into a target classification problem, divides the image area into confidence boxes of different sizes, classifies the confidence boxes, and then adjusts the confidence boxes; a modified version of YOLOV3 is used; First, use the following function to express the input-output relationship of the classification neural network used by YOLOV3: 1) in, It is the functional expression of YOLOV3 classification neural network. and are the learned weights and biases, is the activation function, is the input of the neural network, where the input is the information after the fry image is preprocessed and the confidence box is drawn; Next, perform a first-order Taylor expansion on formula 1) to obtain: 2) in They are The step increase value is is the expanded residual, is a function Weight value Find the partial derivative, is a function Offset Find partial derivatives; Define the reference value, set it to 1, and further define , Formula 2) Subtract both sides get: 3) in, , represents partial derivative; because Is known, set the learning rate as follows: 4) in, is the controller parameter to be requested; The learning rate Substituting Equation 4) into the neural network system in Equation 3) yields: 5) in, is the identity matrix; the Lyapunov function is established as follows: 6) in is a positive definite symmetric matrix; Computes the difference function of a Lyapunov function ,get: 7) Define the matrix , then from formula 5), we get: 8) Given the following performance indicator function : 9) in, is a performance indicator; Now combining equations 7)-9), we get the following nonlinear matrix inequality: 10) When formula 10) holds true, we get , which means that the system is stable, that is, the learning algorithm makes the neural network output used Approximation reference value , and performance indicators with deviations ; definition 11) in, are the parameters of the learning algorithm, is a linear matrix parameter with appropriate dimensions; then, define , after substituting formula 11) into 10) we get: 12) Solve inequality 12) using MATLAB's LMI toolbox, then the linear matrix parameters with appropriate dimensions are , and obtain the following: 13) Now, after substituting Equation 13) into Equation 11) and Equation 4), the neural network learning algorithm to be solved is as follows: 14) For consideration It is very likely that a singularity will occur and the inverse solution of the matrix cannot be obtained. Here we modify the neural network learning algorithm for the solution as follows 15) in, is a very small scalar; Finally, further Substituting into formula 15), the final solution of the neural network learning algorithm is as follows: 16) and 17) in Representatives of information Solve for the square of the power 2 norm.
Citation Information
Patent Citations
Large-batch rapid fry counting device and counting method
CN112085142A
Fry counting method based on deep learning
CN112767382A
Intelligent grading system and intelligent grading method for fusiform fish vaccine injection
CN114982692A
Novel absorption tower water seal overflow device
CN207221667U