Fish information monitoring method, device, medium and product

Through the improved YOLO model and multi-target tracking algorithm, combined with the target detection and motion correlation of fish video streams, the problems of low accuracy and low efficiency of existing fish monitoring methods are solved, and automated, real-time fish information is achieved. Monitor and identify.

CN118628844BActive Publication Date: 2024-10-22INST OF AQUATIC LIFE ACAD SINICA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411102777.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2024-10-22
Estimated Expiration
2044-08-13

AI Technical Summary

Technical Problem

Existing fish monitoring methods have strong data subjectivity, insufficient representativeness, and poor accuracy. Video monitoring requires manual analysis and is costly. Intrusive monitoring can cause damage to fish bodies. The accuracy of hydroacoustic detection decreases in complex environments and cannot be used. Identify fish species in real time.

Method used

Use the improved YOLO model combined with the Anchor Free mechanism to perform target detection on fish video streams. Use the target detection model and multi-target tracking algorithm to adjust the confidence and maximum category probability, and use motion correlation and migratory behavior to identify fish species and quantities. , calculate body length and weight.

Benefits of technology

It improves the efficiency and accuracy of fish information monitoring, reduces false positives, realizes automation and real-time data analysis of fish monitoring, and reduces manual intervention and costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628844B_ABST
    Figure CN118628844B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, medium and product for monitoring fish information, and relates to the field of fish monitoring. The method comprises performing target detection on a single-frame image through a target detection model, obtaining prediction frames, confidences and maximum category probabilities of multiple target fish, adjusting the confidences and maximum category probabilities using the correlation coefficient between the confidences and maximum category probabilities of the target fish and the motion correlation of the target fish, obtaining a second confidence and a first maximum category probability, and determining the position of the target fish on this basis, and tracking the target fish based on the position of the target fish using a multi-target tracking algorithm, obtaining the type and swimming track of the target fish; and obtaining the number and characterization characteristics of the target fish according to the swimming track of the target fish and the migratory behavior of the target fish. The present invention can quickly complete the monitoring and information statistics of fish schools, and improve the efficiency and accuracy of monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of fish monitoring, and in particular to a method, device, medium and product for monitoring fish information. Background Art

[0002] The existing traditional methods for monitoring fish include visual inspection, interception, trap, and mark-recapture methods, all of which are sampling surveys and have the problems of time-consuming and labor-intensive manual net fishing, strong subjectivity, lack of representativeness, and poor accuracy of the data. The video monitoring method based on the vertical slot fishway observation room still requires manual analysis in the later stage of work, and is greatly affected by the turbidity of the water body. The video data is huge, resulting in high analysis costs, and the data cannot be analyzed and displayed in real time. PIT radio frequency chip tracking monitoring is an invasive monitoring method that is harmful to fish bodies and is also a sampling survey. The hydroacoustic detection method is limited by acoustic characteristics, and its accuracy is greatly reduced under complex environmental conditions such as fast water flow, many bubbles and impurities in the water, and dense fish schools. At the same time, it is still impossible to identify fish species at this stage.

[0003] Therefore, the existing technology for monitoring fish schools has the problems of low efficiency and poor accuracy in statistical fish information. Summary of the invention

[0004] The purpose of the present invention is to provide a method, device, medium and product for monitoring fish information, which can improve the efficiency and accuracy of statistical fish information.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] In a first aspect, the present invention provides a method for monitoring fish information, the method comprising:

[0007] Acquire continuous video frame images in a pre-recorded video stream of a school of fish; the continuous video frame images include a plurality of single frame images;

[0008] Performing target detection on the single frame image through a target detection model to obtain prediction boxes, confidences and maximum category probabilities of multiple target fish; the target detection model is trained by an improved YOLO model; wherein the improved YOLO model is obtained by introducing an Anchor Free mechanism into a traditional YOLO model;

[0009] The confidence degree and the maximum category probability of the target fish are adjusted according to the correlation coefficient between the confidence degree and the maximum category probability of the target fish to obtain a first confidence degree and a first maximum category probability of the target fish;

[0010] According to the continuous video frame images, the motion correlation of the target fish is obtained, and the first confidence is adjusted by using the motion correlation to obtain a second confidence of the target fish; wherein the motion correlation of the target fish includes the sudden appearance or disappearance of the target fish and the motion trajectory of the target fish;

[0011] Determine the position of the target fish according to the prediction box, the second confidence and the first maximum category probability;

[0012] Based on the position of the target fish, the target fish is tracked using a multi-target tracking algorithm to obtain the type and swimming track of the target fish;

[0013] The number and characterization characteristics of the target fish are obtained according to the swimming track of the target fish and the migratory behavior of the target fish. The characterization characteristics include the body length and weight of the target fish, wherein the migratory behavior includes upward behavior and downward behavior.

[0014] Furthermore, the training process of the target detection model is:

[0015] Constructing a training set; the training set includes sample fish and labels of the sample fish; the labels include species information of the sample fish and location information of the sample fish;

[0016] The training set is input into the improved YOLO model to obtain the candidate box, confidence and maximum category probability of each sample fish, the loss function is calculated according to the candidate box, confidence and maximum category probability of each sample fish, and the improved YOLO model is trained according to the loss function to obtain a trained target detection model; wherein a dynamic weight factor is set in the loss function.

[0017] Furthermore, constructing a training set includes:

[0018] The original sample fish data is subjected to image flipping, brightness transformation, color transformation, noise addition, perspective transformation, data noise reduction and normalization processing in sequence to obtain processed sample fish data;

[0019] A training set is constructed using the processed sample fish data.

[0020] Further, the confidence and maximum category probability of the target fish are adjusted according to the correlation coefficient between the confidence and maximum category probability of the target fish to obtain a first confidence and a first maximum category probability of the target fish, including:

[0021] Calculating the correlation coefficient between the confidence level and the maximum category probability of the target fish;

[0022] Determining a confidence test threshold and a maximum category probability test threshold according to the correlation coefficient;

[0023] The confidence and maximum category probability of the target fish are adjusted according to the confidence test threshold and the maximum category probability test threshold to obtain a first confidence and a first maximum category probability of the target fish.

[0024] Further, obtaining the motion correlation of the target fish according to the continuous video frame images, and adjusting the first confidence by using the motion correlation to obtain the second confidence of the target fish, comprises:

[0025] Acquire the Qth frame and the Q+1th frame image from the continuous video frame images; wherein Q is an integer positive number;

[0026] The Qth frame and the Q+1th frame image are analyzed by using an inter-frame difference algorithm and an optical flow method to obtain multiple motion trajectories of the target fish, and the number of times the target fish appears in continuous video frame images is determined by using the motion trajectories;

[0027] Extracting the features of the target fish in the Qth frame image to obtain a first feature; extracting the features of the target fish in the Q+1th frame image to obtain a second feature; wherein the features of the target fish are the shape, size and position of the target fish;

[0028] Determine a feature change between the Qth frame and the Q+1th frame image according to the first feature and the second feature;

[0029] When it is determined according to the characteristic change that the target fish suddenly appears or disappears in the Q+1th frame image, the target fish is judged to be a suspicious target;

[0030] When the target fish is a suspicious target and the target fish appears multiple times, the first confidence level of the target fish is increased to obtain the second confidence level of the target fish.

[0031] Further, using the motion trajectory to determine the number of times the target fish appears in continuous video frame images includes:

[0032] Obtain the motion trajectory of the target fish at time t and at time t+1;

[0033] When the motion trajectory at time t and the motion trajectory at time t+1 overlap, it is determined that the number of times the target fish appears in the continuous video frame images is multiple;

[0034] When the motion trajectory at time t and the motion trajectory at time t+1 do not overlap, it is determined that the number of times the target fish appears in the continuous video frame images is once.

[0035] Furthermore, obtaining the characterization features of the target fish according to the swimming track of the target fish includes:

[0036] Acquire all prediction frames of the target fish from the swimming track, and determine a first prediction frame according to the pixel points in the horizontal direction of each prediction frame;

[0037] Extracting pixel points in the horizontal direction of the first prediction box to obtain a first length;

[0038] Converting the first length into real and virtual length to obtain the body length of the target fish;

[0039] The body length of the target fish is converted to obtain the weight of the target fish.

[0040] In a second aspect, a computer device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the above-mentioned methods for monitoring fish information.

[0041] In a third aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the method for monitoring fish information described in any one of the above items is implemented.

[0042] In a fourth aspect, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements any of the above-mentioned methods for monitoring fish information.

[0043] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0044] The present invention utilizes the correlation coefficient between the confidence degree and the maximum category probability of each target fish to verify and adjust the confidence degree and the maximum category probability, thereby reducing the occurrence of false positives and ensuring the authenticity and accuracy of monitoring data. The adjusted confidence degree is adjusted again by utilizing the movement correlation of the target fish, thereby improving the probability of target detection and further improving the accuracy and reliability of the detection result. Furthermore, the target fish can be statistically analyzed through the swimming trajectory and migratory behavior of the target fish to obtain the number and characterization characteristics of the target fish, thereby quickly completing the monitoring and information statistics of the fish school, thereby improving the efficiency and accuracy of monitoring. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0046] Figure 1 A flow chart of a method for monitoring fish information provided in Example 1 of the present invention;

[0047] Figure 2 It is a schematic diagram of intersection and union ratio;

[0048] Figure 3 A flow chart of a method for adjusting a first confidence level of a target fish to obtain a second confidence level;

[0049] Figure 4 Positional relationship diagram for fish counting logic;

[0050] Figure 5 A flow chart of the method for calculating the length and weight of target fish;

[0051] Figure 6 A diagram of the internal structure of a computer device. DETAILED DESCRIPTION

[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0053] The purpose of the present invention is to provide a method, device, medium and product for monitoring fish information, which can quickly complete the monitoring and information statistics of fish schools and improve the efficiency and accuracy of monitoring.

[0054] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] Example 1

[0056] like Figure 1 As shown, this embodiment provides a method for monitoring fish information, the method comprising the following steps:

[0057] S101, obtaining continuous video frame images in a pre-recorded fish school video stream; the continuous video frame images include multiple single frame images.

[0058] The pre-recorded fish school video stream may be a fish school video stream recorded of migratory fish in a fishway, or may be a fish school video stream recorded in a fish image acquisition scene built indoors.

[0059] A fishway is a continuous stepped trough-like structure designed to help migratory fish survive in artificial water environments or natural barriers such as dams, locks, waterfalls, etc. Fishways mainly include different types such as pool weir type, vertical slit type and pipeline type.

[0060] S102, performing target detection on the single-frame image through a target detection model to obtain prediction boxes, confidence levels, and maximum category probabilities of multiple target fish; the target detection model is trained by an improved YOLO model.

[0061] The training process of the target detection model is:

[0062] Step A, constructing a training set; the training set includes sample fish and labels of the sample fish; the labels include species information of the sample fish and location information of the sample fish.

[0063] A1. Balance and increment the collected original sample fish data. The balance and increment processing methods include image flipping, brightness transformation, color transformation, noise addition and perspective transformation.

[0064] 1) Image flipping is a transformation based on pixel position, and its formula is:

[0065] Flip vertically: (1)

[0066] Flip Horizontal: (2)

[0067] Flip diagonally: (3)

[0068] in, is the pixel position of the original image, is the new pixel position of the flipped image, and are the width and height of the image respectively.

[0069] 2) Brightness transformation: Increase or decrease a constant value for each pixel value in the image. For a color image, the formula for brightness transformation of each channel is:

[0070] (4)

[0071] in, is the original image at position The pixel value of It is a constant for brightness adjustment, which can be positive or negative. A positive number brightens the image, while a negative number darkens it. The image is at position after brightness adjustment The pixel value of .

[0072] 3) Color conversion: mainly the conversion from BGR to grayscale and from BGR to HSV.

[0073] BGR stands for red, green and blue, red, green and blue; HSV stands for Hue, Saturation and Value.

[0074] From BGR to grayscale, the weighted average method is used, using the following calculation formula:

[0075] (5)

[0076] in, are the pixel values ​​of the red, green, and blue channels respectively, and is the grayscale value after conversion.

[0077] The conversion formula from BGR to HSV color space is:

[0078] 1. Calculate the maximum value and minimum value .

[0079] 2. Calculate saturation ,if ,but .

[0080] 3. Calculate hue , which is calculated depending on which color channel has the maximum value:

[0081] if ,but ; (6)

[0082] if ,but ; (7)

[0083] if ,but ; (8)

[0084] if ,but ; (9) Maximum value V: In the BGR color model, for a given pixel, the highest value among the three channels of red (R), green (G), and blue (B); the maximum value V is calculated to determine the brightness level of the current pixel. In the HSV color space, the V value represents the basis for calculating hue and saturation.

[0085] Minimum value m: In the BGR color model, for a given pixel, the lowest value among the three channels of red (R), green (G), and blue (B); calculating the minimum value m is used to calculate saturation. Saturation indicates the intensity or purity of the color, which is determined by the ratio of the difference between the maximum and minimum values ​​to the maximum value itself.

[0086] 4) Adding noise: Specifically, add Gaussian noise, whose probability density function follows the normal distribution (also called Gaussian distribution); the basic formula for adding Gaussian noise to an image can be expressed as:

[0087] (10)

[0088] in: is the pixel value of the image after adding noise, is the pixel value of the original image, is Gaussian noise, is the variance, is the mean, Indicates that the noise is centered on the original pixel value. Usually set to 0, is the standard deviation, which controls the strength of the noise.

[0089] 5) Perspective transformation: Use a 3x3 transformation matrix to transform the points in the image Map to new coordinates The transformation matrix determines the properties of the transformation, such as rotation, scaling, tilting, and translation. The formula for perspective transformation can be expressed as:

[0090] (11)

[0091] in, are the coordinates of the point in the original image, are the transformed point coordinates, It is a homogeneous coordinate. Homogeneous coordinates can realize the projection transformation from three-dimensional to two-dimensional. are the elements in the transformation matrix.

[0092] Transformed coordinates Through and After normalization, the expression is:

[0093] (12)

[0094] (13)

[0095] in, are the coordinates of the point in the original image, are the coordinates of the point in the transformed image, are homogeneous coordinates, are the elements in the 3x3 transformation matrix.

[0096] A2. Perform noise reduction on the data to obtain enhanced image data. Specifically, use histogram equalization technology or Retinex algorithm to reduce the noise of the image data. The noise reduction process restores the original color image in real conditions, which can obtain better target detection effect.

[0097] A3. Normalize the enhanced image data, that is, perform a linear transformation on each pixel value and scale it to the range of [0, 1] to adapt the image data to the input requirements of the YOLO model, thereby speeding up the training speed and improving the model performance. Specifically:

[0098] (14)

[0099] (1) Among them, is the normalized image, is the resized image, are the minimum and maximum pixel values ​​of the image respectively.

[0100] The processed sample fish data is obtained through the processing of the above steps A1 to A3. The sample fish in the processed sample fish data is labeled to obtain a label of the sample fish. The label includes the following information:

[0101] 1) Dimensions of the sample fish, e.g., width, height, number of channels.

[0102] 2) The type of sample fish, for example, carp, crucian carp, bream, etc.

[0103] 3) The bounding box of the sample fish, usually represented by the coordinates of the upper left and lower right corners of the object's bounding box.

[0104] 4) View or posture information, for example, the direction or angle of the sample fish body in the image, such as the front, side, back, etc.

[0105] 5) Truncation. For example, only a part of the fish body of the sample fish is shown in the image, while the other part is not fully displayed due to reasons such as the image boundary.

[0106] 6) Occlusion information, for example, whether the sample fish body is partially or completely obscured by other fish bodies or environmental factors.

[0107] Step B, inputting the training set into the improved YOLO model, obtaining the prediction box, confidence and maximum category probability of each sample fish, calculating the loss function according to the prediction box, confidence and maximum category probability of each sample fish, training the improved YOLO model according to the loss function, and obtaining the trained target detection model.

[0108] Specifically, the processed sample fish data are divided into training set, validation set and test set in proportion. For example, 80% of the data constitute the training set, 10% of the data constitute the validation set, and 10% of the data constitute the test set. Among them, the main function of the training set is to train the parameters. The validation set is basically to adjust the hyperparameters after each training is completed to prevent the model from overfitting on the training set. The main function of the test set is to test the accuracy of the trained target detection model.

[0109] The improved YOLO model is obtained by introducing the Anchor Free mechanism into the traditional YOLO model. Specifically, the output layer of the YOLO model is adjusted, and the Anchor Free mechanism is used to enable the YOLO model to directly predict the center point, width and height of the target fish and the maximum category probability of the target fish at each network point.

[0110] Predict whether each grid point is the center of a target fish, generate a prediction box for the target fish, use the sigmoid function to predict the offset, and get the center point coordinates.

[0111] (15)

[0112] (16)

[0113] in, and They are the center point coordinates of the prediction box; is the sigmoid function; and is the predicted offset; and are the coordinates of the grid points.

[0114] During the training process, the Anchor Free mechanism generates a dynamic candidate box, namely the Anchor, by calculating the average width and average height of the sample fish using the actual sizes of all the sample fish in the training set. The dynamic candidate box is used to change the output result of the YOLO model to obtain the predicted box of the target fish.

[0115] (17)

[0116] (18)

[0117] in, and They are the width and height of the dynamic Anchor respectively; is the number of target fish; and It is The width and height of the target fish.

[0118] In the improved YOLO model, the network points are represented by coordinates, and the prediction box of the target fish is obtained by prediction in each network point. The loss function is:

[0119] (19)

[0120] in, is the total loss; is the coordinate loss weight, There are confidence loss weights for the sample fish prediction box, The confidence loss weight of the sample-free fish prediction box, Classification loss weight, is the coordinate loss, is the confidence loss of the sample fish prediction box, Confidence loss of the prediction box of the fish without sample, is the classification loss.

[0121] A dynamic weight factor is set in the loss function of the improved YOLO model. During the training process, the dynamic weight factor is dynamically adjusted. If the recall rate is low, the confidence loss weight of the sample fish prediction box is increased; if the accuracy rate is low, the classification loss weight is increased.

[0122] (20)

[0123] in, and is the change in recall and precision.

[0124] Evaluation indicators of target detection models:

[0125] (1) Intersection and Union

[0126] Intersection over Union (IoU) is mainly used to measure the overlap between the predicted box and the real box. Figure 2 As shown in the figure, there are two bounding boxes, box A and box B. Box A is the ground-truth bouding box, and box B is the predicted bouding box. The ground-truth bouding box is the correct result of manual annotation, and the predicted bouding box is the result predicted by the algorithm. The relationship between the two boxes can be determined by judging the degree of overlap between the two boxes. The higher the overlap, the higher the value.

[0127] It can be seen that IoU is a ratio. The numerator of the ratio represents the area of ​​the overlapping area between the predicted box and the actual box, and the denominator of the ratio represents the total area occupied by the predicted box and the actual box.

[0128] (2) Accuracy

[0129] Precision refers to the proportion of correct predictions among all target fish predicted by the model, that is, the proportion of samples that the classifier considers to be positive samples and are indeed positive samples to all samples that the classifier determines to be positive samples. The calculation formula is as follows:

[0130] (twenty one)

[0131] True Positive (TP), True Negative (TN), False Positive (FP), False Negative (FN), Positive and Negative represent the predicted results. If the IoU value is greater than the set threshold (usually set to 0.5), the prediction is Positive, if the IoU value is less than the set threshold, the prediction is Negative; True and False indicate whether the predicted result is the same as the actual result, if the same is True, and if different is False, as shown in Table 1, the division of positive and negative samples.

[0132] Table 1

[0133]

[0134] (3) Recall rate

[0135] Recall refers to the proportion of targets predicted correctly by the model among all real targets, that is, the proportion of positive samples that the classifier considers to be positive samples and are indeed positive samples to all positive samples in the test set. The calculation formula is as follows:

[0136] (twenty two)

[0137] (4) Average accuracy

[0138] Mean average precision (mAP) is an indicator that measures whether the model predicts the box category and position accurately. AP uses Recall as the horizontal axis and Precision as the vertical axis. The area under the PR curve is used as the scale of the model. The calculation formula is as follows:

[0139] (twenty three)

[0140] (twenty four)

[0141] Among them, r is the recall rate and n is the number of samples.

[0142] (5) Detection frame rate

[0143] Detection frame rate (Frames Per Second, FPS) is an important indicator to measure the performance of the target detection model. It is mainly used to measure the processing speed or real-time performance of the model. FPS refers to the number of frames per second that the model can process, that is, how many pictures can be detected per second. A high FPS value means a faster processing speed. In the real-time monitoring scenario of fish in vertical slot fishways, this indicator is particularly emphasized. The calculation formula is as follows:

[0144] (25)

[0145] The total number of frames processed refers to the number of image frames processed by the model within a given time; the total processing time is the time required to complete the processing of these frames, usually in seconds.

[0146] S103, adjusting the confidence and maximum category probability of the target fish according to the correlation coefficient between the confidence and maximum category probability of the target fish to obtain a first confidence and a first maximum category probability of the target fish.

[0147] Using the confidence and maximum class probability of the target fish obtained in step S102, the Pearson correlation coefficient is used to quantify the correlation between the confidence and the maximum class probability. The calculation formula of the Pearson correlation coefficient is:

[0148] (26)

[0149] in, is the Pearson correlation coefficient, and They are The confidence and maximum category probability of the target fish, and are the average of the confidence and maximum class probability, respectively.

[0150] The confidence test threshold and the maximum category probability test threshold are determined according to the calculated correlation coefficient; and the confidence test threshold and the maximum category probability test threshold are used to adjust the confidence and the maximum category probability of the target fish to obtain the first confidence and the first maximum category probability of the target fish.

[0151] If the confidence is high but the maximum category probability is low, it is considered to be a false positive. The confidence and maximum category probability of the target fish are adjusted to obtain the first confidence and first maximum category probability of the target fish. Specifically, the confidence and maximum category probability of the target fish are adjusted using formulas (27)-(28).

[0152] (27)

[0153] (28)

[0154] in, The adjusted confidence level, The adjusted maximum class probability, and is the adjustment factor.

[0155] S104. Obtaining the motion correlation of the target fish according to the continuous video frame images, and adjusting the first confidence by using the motion correlation to obtain a second confidence of the target fish; wherein the motion correlation of the target fish includes the sudden appearance or disappearance of the target fish and the motion trajectory of the target fish.

[0156] like Figure 3 As shown, step S104 specifically includes:

[0157] S1041. Obtain the Qth frame and the Q+1th frame image from the continuous video frame images; wherein Q is an integer positive number.

[0158] For example, the first and second frames, the second and third frames, the third and fourth frames, etc. are obtained from continuous video frame images.

[0159] S1042. Analyze the Qth frame and the Q+1th frame image by using an inter-frame difference algorithm and an optical flow method to obtain multiple motion trajectories of the target fish, and use the motion trajectories to determine the number of times the target fish appears in continuous video frame images.

[0160] Specifically, the feature changes between the Qth frame and the Q+1th frame image are calculated using inter-frame differences, and the motion area of ​​the target fish is obtained through the feature changes.

[0161] (29)

[0162] in, yes Moment and The moment between The characteristic changes of target fish and They are Moment and Time The feature vector of each target fish.

[0163] The optical flow method is used to analyze the movement of the target fish in continuous frame images, the motion vector field of the image pixels is calculated, and the movement direction and speed of the target fish are obtained using the motion vector field.

[0164] (30)

[0165] in, is the motion vector of pixel (x, y) at time t, and , respectively Moment and images, It is the optical flow calculation function.

[0166] The movement trajectory of the target fish is obtained based on the movement area of ​​the target fish obtained above as well as the movement direction and speed of the target fish.

[0167] The motion trajectory of the target fish at time t and the motion trajectory at time t+1 are obtained. When the motion trajectory at time t and the motion trajectory at time t+1 overlap, it is determined that the target fish appears multiple times in the continuous video frame images; when the motion trajectory at time t and the motion trajectory at time t+1 do not overlap, it is determined that the target fish appears once in the continuous video frame images.

[0168] If formula (31) is satisfied, it means that the motion trajectory at time t coincides with the motion trajectory at time t+1, specifically:

[0169] (31)

[0170] in, It is The movement trajectory of the target fish at time t is: It is Target fish in movement trajectory.

[0171] S1043. Extract the features of the target fish in the Qth frame image to obtain a first feature; extract the features of the target fish in the Q+1th frame image to obtain a second feature; wherein the features of the target fish are the shape, size and position of the target fish.

[0172] The first feature and the second feature are quantized by formula (32) to obtain the corresponding feature vectors.

[0173] (32)

[0174] in, yes Time The feature vector of the target fish, is the first images of target fish, is the feature extraction function.

[0175] S1044. Determine feature changes between the Qth frame and the Q+1th frame image according to the first feature and the second feature.

[0176] According to the feature vectors respectively corresponding to the first feature and the second feature obtained in step S1043, the feature change between the Qth frame and the Q+1th frame image is determined.

[0177] S1045. When it is determined based on feature changes that the target fish suddenly appears or disappears in the Q+1th frame image, the target fish is judged to be a suspicious target.

[0178] The target fish that suddenly appears or disappears is defined as a suspicious target. If the feature change between the Qth frame and the Q+1th frame image exceeds a preset feature change threshold, it is marked as a suspicious target.

[0179] When formula (33) is satisfied, the suspicious target is marked:

[0180] (33)

[0181] in, is a characteristic change, is the feature change threshold.

[0182] S1046. When the target fish is a suspicious target and the target fish appears multiple times, the first confidence level of the target fish is increased to obtain a second confidence level of the target fish.

[0183] Confidence is the degree of confidence of the network model on whether a certain prediction box contains the target fish. It indicates the probability that the network model believes that this prediction box contains a certain object. The confidence value is usually between 0 and 1. The closer it is to 1, the more confident the model is in this prediction. Dynamically adjusting the confidence of suspicious targets can increase the probability of suspicious targets being detected.

[0184] The target detection model is set with a confidence detection threshold. Only when the confidence of the prediction box of the target fish is higher than the detection threshold, the prediction box will be considered valid and the target fish will be output as the detection result of the target detection model. Therefore, after determining that a target fish is a suspicious target, adjust the detection threshold of the target detection model to ensure that the target fish can be detected. By adjusting the detection threshold of the target detection model, the precision and recall rate of the detection results of the target detection model can be controlled.

[0185] S105. Determine the position of the target fish according to the prediction box, the second confidence level and the first maximum category probability.

[0186] Specifically, the location of the target fish includes the coordinates of the center point of the prediction box, the width and height of the prediction box, the category probability of the target in the prediction box, and the confidence of the prediction box.

[0187] S106. Based on the position of the target fish, the target fish is tracked using a multi-target tracking algorithm to obtain the type and swimming track of the target fish.

[0188] According to step S105, the center point coordinates of the prediction frame of the target fish are obtained, and the initial trajectory of the target fish is formed by connecting the center points of the target fish in each frame image in the continuous video frame image. Then, the trajectory of the target fish is predicted using the Kalman filter algorithm, and the initial trajectory is updated to obtain the updated trajectory of the target fish. The updated trajectory is matched with the features of the target fish in the initial trajectory using the Hungarian algorithm to obtain the optimal matching solution, and the swimming trajectory of the target fish is determined according to the optimal matching solution. Specifically, the following steps are included:

[0189] (1) The image in the prediction box obtained by target detection is processed to obtain a processed image. The image processing methods used are image resizing and normalization, so that the processed image meets the input requirements of the ResNet50 network model.

[0190] (2) The processed image is input into the ResNet50 network model to extract the features of the target fish, including the color, size, shape, etc., and obtain a feature vector. The ResNet50 network model is selected as the feature extractor, and the obtained feature vector is associated with the corresponding prediction box of the target fish and stored for subsequent matching and tracking.

[0191] (3) Obtain the feature vectors of the target fish in the qth frame image and the q-1th frame image in the continuous video frame images respectively, where q is a positive integer greater than 1.

[0192] The qth frame image is the current frame, the 1st frame image and the q-1th frame image generate the updated trajectory of the target fish, the feature similarity between the feature vector of the target fish in the qth frame image and the feature vector of the target fish in the q-1th frame image is calculated, and the feature similarity cost is obtained according to the feature similarity.

[0193] In this embodiment, the cosine similarity is used to calculate the feature similarity, and the calculation formula of the feature similarity is:

[0194] (34)

[0195] in, is the feature vector of the target fish in the qth frame image, is the feature vector of the target fish in the q-1th frame image, and They are and Model.

[0196] The calculation formula of feature similarity cost is:

[0197] (35)

[0198] in, is the target fish detected in the qth frame image , is the trajectory of the target fish from the 1st frame image to the q-1th frame image.

[0199] The Euclidean distance method can also be used to calculate the feature similarity between the target fish in the qth frame image and the q-1th frame image.

[0200] (4) Use the Kalman filter algorithm to obtain the target fish in the qth frame image Detection status And the target fish from the 1st frame image to the qth frame image The trajectory , the Kalman filter prediction error is obtained according to the detection state and trajectory, and the calculation formula of the Kalman filter prediction error cost is obtained according to the Kalman filter prediction error:

[0201] (36)

[0202] in, For the trajectory The predicted state of Target fish Detection status.

[0203] (5) The matching cost is constructed based on the feature similarity cost and the Kalman filter prediction error cost. The matching cost is calculated as follows:

[0204] (37)

[0205] in, and is the adjustment coefficient, which is used to balance the weight of the feature similarity cost and the Kalman filter prediction error cost.

[0206] (6) Use the Hungarian algorithm to solve the optimal solution of the matching cost and obtain the optimal matching solution.

[0207] The Hungarian algorithm is used to solve the assignment problem and can find the matching solution with the minimum total matching cost among all possible matching pairs. , the matching scheme The target fish With trajectory The best matching solution , the minimum matching solution The expression

[0208] (38)

[0209] Among them, m is the target fish detected in the current frame image. The number of

[0210] (7) According to the optimal matching solution Update the state and feature vector of the target fish in the qth frame image.

[0211] 1. Kalman filter state update

[0212] a) For the matched trajectory and target fish , according to the state update formula of Kalman filter:

[0213] (39)

[0214] in, Is the updated target fish The state estimate of The target fish before the update The state estimate of The target fish The detection status, is the Kalman gain, is the observation matrix.

[0215] b) Optimal matching solution If the match is not successful, it means that the target fish and the track are not matched successfully. There are the following situations:

[0216] b1. For the target fish that are not matched, it indicates that the target fish The first time it appears in the qth frame image, a new trajectory is initialized As target fish The trajectory:

[0217] (40)

[0218] in, The target fish The detection status, The target fish The characteristic vector of is the initial error covariance matrix.

[0219] b2. For unmatched tracks, if no new target fish is matched for multiple consecutive frames, the track is considered to have disappeared and the track deletion operation is performed.

[0220] 2. Error covariance update of Kalman filter

[0221] (41)

[0222] in, is the updated error covariance matrix, is the error covariance matrix before updating, is the identity matrix, is the Kalman gain, is the observation matrix.

[0223] 3. Update the feature vector of the target fish in the qth frame image:

[0224] (42)

[0225] in, It's a track The characteristic vector of The target fish The feature vector of .

[0226] A matching cost is constructed based on feature similarity and Kalman filter error, and the Hungarian algorithm is used to solve the optimal matching solution for the matching cost, so as to find the best matching solution among all possible matching pairs and determine the swimming trajectory of the target fish. In this embodiment, the trajectory of the target fish is tracked when the species of the target fish is known. Therefore, the species of the target fish is determined while the swimming trajectory of the target fish is determined.

[0227] S107, obtaining the number and characterization characteristics of the target fish according to the swimming track and the migratory behavior of the target fish.

[0228] The fish counting logic is:

[0229] The migratory behaviors of migratory fishes passing through the vertical slot fishway are mainly divided into upward behavior and downward behavior. The two migratory behaviors are defined as follows: Figure 4 As shown, a is the upper edge of the underwater camera's field of view; b is the lower edge of the underwater camera's field of view.

[0230] If the target fish appears from b (the lower edge of the underwater camera's field of view) and disappears at a (the upper edge of the underwater camera's field of view), the target fish's migration behavior is an upward behavior, and it is recorded as one upward movement; if the target fish appears from a (the upper edge of the underwater camera's field of view) and disappears at b (the lower edge of the underwater camera's field of view), the target fish's migration behavior is a downward behavior, and it is recorded as one downward movement.

[0231] According to the swimming track of the target fish and the above-mentioned fish counting logic, the target fish are counted to obtain the number of the target fish.

[0232] The characterization features of the target fish include the body length and weight of the target fish. The body length and weight of the target fish are obtained by using all the prediction boxes in the swimming trajectory of the target fish, such as Figure 5 As shown, calculating the body length and weight of the target fish includes the following steps:

[0233] S1071. Obtain all prediction frames of the target fish from the swimming trajectory, and determine a first prediction frame according to pixel points in the horizontal direction of each prediction frame.

[0234] The continuous video frame images obtained by tracking each target fish individual are analyzed, and all prediction boxes in the swimming track of each target fish individual in this series of frame images are collected.

[0235] Screen all prediction frames: For each target fish individual, compare the number of pixels in the horizontal direction of all prediction frames, and select the prediction frame with the largest number of pixels in the horizontal direction as the first prediction frame representing the target fish individual in the horizontal direction.

[0236] S1072: Extract pixel points in the horizontal direction of the first prediction box to obtain a first length.

[0237] The pixels in the horizontal direction of the first prediction box are taken as the first length, and the relative length of the fish body is recorded as , that is, the relative length of the fish body is the first length.

[0238] S1073, converting the first length into real and virtual to obtain the body length of the target fish.

[0239] Scene calibration: Under the same imaging conditions, the actual horizontal length of the entire image is determined by field measurement or by using a calibration object of known size. The actual horizontal length is recorded as , the actual horizontal length unit is millimeter.

[0240] Count the number of pixels in the horizontal length of the entire image, recorded as , which is the actual horizontal length.

[0241] The body length of the target fish is calculated based on the length ratio using the data obtained in steps S1072 and S1073, which is also the actual body length of the target fish. The calculation formula for the body length of the target fish is:

[0242] Target fish length (43)

[0243] S1074. Convert the body length of the target fish to obtain the weight of the target fish.

[0244] Based on the biological characteristics of fish, the known length-weight relationship formula is used to estimate the weight of fish. Different species of fish have different length-weight formulas, but they all have the following form:

[0245] (44)

[0246] in, is the weight of the fish, is the length of the fish. and is a type-specific constant.

[0247] Substitute the body length of the target fish into formula (44) to obtain the weight of the target fish.

[0248] The present invention significantly improves the accuracy and automation level of fish size measurement by developing an advanced fish length and weight measurement module. Based on the results of the target detection model and multi-target tracking, the module selects the best first prediction frame when the fish individual is in the horizontal direction to represent the relative length of the fish. In addition, by comparing with field measurements or calibration objects of known size, the actual body length of the target fish is accurately determined, which not only improves the automation level of data collection, but also greatly enhances the accuracy and reliability of subsequent data analysis, providing high-quality basic data for fish population research.

[0249] Example 2

[0250] A computer device, which may be a database, may have an internal structure as shown in Figure 6As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store pending transactions. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for detecting fish information in Example 1 is implemented. .

[0251] Example 3

[0252] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a method for detecting fish information in Example 1.

[0253] Example 4

[0254] A computer program product includes a computer program, which implements a method for detecting fish information in Example 1 when executed by a processor.

[0255] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the object or fully authorized by all parties.

[0256] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present invention may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present invention may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0257] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0258] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for monitoring fish information, It is characterized in that The method comprises: Acquire continuous video frame images in a pre-recorded video stream of a school of fish; the continuous video frame images include a plurality of single frame images; Performing target detection on the single frame image through a target detection model to obtain prediction boxes, confidences and maximum category probabilities of multiple target fish; the target detection model is trained by an improved YOLO model; wherein the improved YOLO model is obtained by introducing an Anchor Free mechanism into a traditional YOLO model; The training process of the target detection model is: Constructing a training set; the training set includes sample fish and labels of the sample fish; the labels include species information of the sample fish and location information of the sample fish; The training set is input into the improved YOLO model to obtain the candidate box, confidence and maximum category probability of each sample fish, and the loss function is calculated according to the candidate box, confidence and maximum category probability of each sample fish. The improved YOLO model is trained according to the loss function to obtain a trained target detection model; wherein a dynamic weight factor is set in the loss function; The loss function is: ; ; in, is the total loss; is the coordinate loss weight, There are confidence loss weights for the sample fish prediction box, The confidence loss weight of the sample-free fish prediction box, Classification loss weight, is the coordinate loss, is the confidence loss of the sample fish prediction box, Confidence loss of the prediction box of the fish without sample, is the classification loss, and is the change in recall and precision; During the training process, the Anchor Free mechanism generates a dynamic candidate box, namely the Anchor, by calculating the average width and average height of the sample fish using the actual size of all sample fish in the training set. The dynamic candidate box is used to change the output result of the YOLO model to obtain the predicted box of the target fish. ; ; in, and They are the width and height of the dynamic Anchor respectively; is the number of target fish; and It is The width and height of the target fish; A detection threshold of confidence is set in the target detection model. After a target fish is determined to be a suspicious target, the detection threshold of the target detection model is adjusted to ensure that the target fish can be detected; The confidence degree and the maximum category probability of the target fish are adjusted according to the correlation coefficient between the confidence degree and the maximum category probability of the target fish to obtain a first confidence degree and a first maximum category probability of the target fish; According to the continuous video frame images, the motion correlation of the target fish is obtained, and the first confidence is adjusted by using the motion correlation to obtain a second confidence of the target fish; wherein the motion correlation of the target fish includes the sudden appearance or disappearance of the target fish and the motion trajectory of the target fish; Determine the position of the target fish according to the prediction box, the second confidence and the first maximum category probability; Based on the position of the target fish, the target fish is tracked using a multi-target tracking algorithm to obtain the type and swimming track of the target fish; The number and characterization characteristics of the target fish are obtained according to the swimming track of the target fish and the migratory behavior of the target fish. The characterization characteristics include the body length and weight of the target fish, wherein the migratory behavior includes upward behavior and downward behavior.

2. The method according to claim 1, It is characterized in that The constructing of the training set comprises: The original sample fish data is subjected to image flipping, brightness transformation, color transformation, noise addition, perspective transformation, data noise reduction and normalization processing in sequence to obtain processed sample fish data; A training set is constructed using the processed sample fish data.

3. The method according to claim 1, It is characterized in that The step of adjusting the confidence and the maximum category probability of the target fish according to the correlation coefficient between the confidence and the maximum category probability of the target fish to obtain a first confidence and a first maximum category probability of the target fish comprises: Calculating the correlation coefficient between the confidence level and the maximum category probability of the target fish; Determining a confidence test threshold and a maximum category probability test threshold according to the correlation coefficient; The confidence and maximum category probability of the target fish are adjusted according to the confidence test threshold and the maximum category probability test threshold to obtain a first confidence and a first maximum category probability of the target fish.

4. The method according to claim 1, It is characterized in that The step of obtaining the motion correlation of the target fish according to the continuous video frame images, and adjusting the first confidence by using the motion correlation to obtain the second confidence of the target fish comprises: Acquire the Qth frame and the Q+1th frame image from the continuous video frame images; wherein Q is an integer positive number; The Qth frame and the Q+1th frame image are analyzed by using an inter-frame difference algorithm and an optical flow method to obtain multiple motion trajectories of the target fish, and the number of times the target fish appears in continuous video frame images is determined by using the motion trajectories; Extracting the features of the target fish in the Qth frame image to obtain a first feature; extracting the features of the target fish in the Q+1th frame image to obtain a second feature; wherein the features of the target fish are the shape, size and position of the target fish; Determine a feature change between the Qth frame and the Q+1th frame image according to the first feature and the second feature; When it is determined according to the characteristic change that the target fish suddenly appears or disappears in the Q+1th frame image, the target fish is judged to be a suspicious target; When the target fish is a suspicious target and the target fish appears multiple times, the first confidence level of the target fish is increased to obtain the second confidence level of the target fish.

5. The method according to claim 4, It is characterized in that Determining the number of times the target fish appears in continuous video frame images using the motion trajectory includes: Obtain the motion trajectory of the target fish at time t and at time t+1; When the motion trajectory at time t and the motion trajectory at time t+1 overlap, it is determined that the number of times the target fish appears in the continuous video frame images is multiple; When the motion trajectory at time t and the motion trajectory at time t+1 do not overlap, it is determined that the number of times the target fish appears in the continuous video frame images is once.

6. The method according to claim 1, It is characterized in that The step of obtaining the characteristic features of the target fish according to the swimming track of the target fish includes: Acquire all prediction frames of the target fish from the swimming track, and determine a first prediction frame according to the pixel points in the horizontal direction of each prediction frame; Extracting pixel points in the horizontal direction of the first prediction box to obtain a first length; Converting the first length into real and virtual length to obtain the body length of the target fish; The body length of the target fish is converted to obtain the weight of the target fish.

7. A computer device, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for monitoring fish information as described in any one of claims 1-6.

8. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method for monitoring fish information described in any one of claims 1 to 6 is implemented.

9. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method for monitoring fish information described in any one of claims 1 to 6 is implemented.