A method and device for detecting animal semen quality

By identifying and analyzing sperm movement trajectories in image videos of animal semen, extracting feature vectors, and combining sensor data to evaluate semen quality, the problem of low semen quality analysis efficiency in the existing technology is solved, and rapid and accurate semen quality assessment is achieved.

CN118485663BActive Publication Date: 2024-09-06SICHUAN ANIMAL SCI ACAD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410933784.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-06
Estimated Expiration
2044-07-12

AI Technical Summary

Technical Problem

In the existing technology, the efficiency of animal semen quality analysis is low, the image processing system has difficulty processing complex samples, and the accuracy and stability of sensor technology are affected by factors such as the environment and instrument quality, resulting in reduced semen quality analysis efficiency.

Method used

By acquiring image videos of animal semen, identifying sperm movement trajectories, extracting feature vectors, predicting sperm motility indicators, calculating semen density, combining multiple sperm motility indicators and densities to evaluate semen quality, and using optical flow estimation and attention mechanisms to improve Feature extraction accuracy, generating spatio-temporal trajectory diagram to intuitively display the movement status of sperm.

Benefits of technology

It achieves rapid and accurate detection of semen quality, reduces human errors, improves analysis efficiency, and can effectively evaluate semen quality in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118485663B
    Figure CN118485663B
Patent Text Reader

Abstract

The present invention relates to the field of animal semen quality detection, and specifically to a method and device for detecting animal semen quality, comprising: obtaining an image video containing animal semen, identifying the movement trajectory of sperm in the animal semen in the image video, extracting features of the movement trajectory of the sperm in the animal semen to obtain a feature vector of the sperm, predicting the sperm activity index label value based on the sperm feature vector and a vector machine model, and in order to determine the quality of the animal semen, calculating the density of the animal semen by the volume of the animal semen and the number of sperm. Then, according to the activity index label value and the density of the animal semen, the quality evaluation value of the animal semen is calculated, so as to determine the quality of the animal semen according to the quality evaluation value. The quality evaluation value is obtained through user interface data, so that the user can easily view the evaluation results and reports, and realize the rapid and accurate detection of multiple indicators of semen samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of animal semen quality detection, in particular to a method and a device for detecting animal semen quality. Background Art

[0002] With the continuous advancement of science and technology, people have an increasing demand for automation and intelligence in animal husbandry production. The automatic monitoring and analysis system for animal semen quality can improve the accuracy and efficiency of semen quality analysis, and obtain a large amount of semen quality data in real time while reducing manpower. At present, the existing technology can use an automatic analysis system of image processing and computer vision to analyze the quality of animal semen. The system can capture and analyze semen images in real time, and measure key indicators such as the number, vitality and morphology of sperm. Compared with traditional manual observation methods, the automatic analysis system based on image processing has higher accuracy and stability, can reduce human errors, and can achieve high-throughput sample processing and improve analysis efficiency. However, image processing and computer vision technology have high requirements for image quality and clarity, and the existing algorithms have poor generalization. Some systems have difficulties in processing and analyzing complex semen samples, such as image analysis when particles exist in liquids, thereby reducing the efficiency of semen quality analysis.

[0003] In addition, existing technologies can also integrate various sensors to monitor and record physical and chemical parameters of semen such as temperature, pH value, viscosity, etc. in real time, so as to comprehensively evaluate semen quality. However, the accuracy and stability of sensor technology are affected by environmental factors, instrument quality and calibration, which may lead to deviation or instability in sensor readings, thereby reducing the efficiency of semen quality analysis. Summary of the invention

[0004] In order to solve the above-mentioned problems in the prior art, the present invention provides a method and a device for detecting animal semen quality, which solves the problem in the prior art that the efficiency of semen quality analysis cannot be improved.

[0005] One aspect of the present invention provides a method for detecting animal semen quality, comprising:

[0006] Obtaining images and videos containing animal semen;

[0007] Identifying the movement trajectory of sperm in the animal's semen in the image video;

[0008] Extracting features of the movement trajectory of the sperm in the animal semen to obtain a feature vector of the sperm;

[0009] Predicting the sperm motility index label value according to the sperm feature vector and the vector machine model;

[0010] Calculating the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen;

[0011] A quality evaluation value of the animal semen is obtained according to the density of the animal semen and the motility index label values ​​of multiple sperms in the animal semen.

[0012] In one embodiment, before obtaining the quality evaluation value of the animal semen according to the density of the animal semen and the motility index label values ​​of multiple sperms in the animal semen, the method for detecting the quality of the animal semen further includes:

[0013] Creating a motion recognition model; wherein the motion recognition model includes the motion trajectory of the reference sperm and its corresponding motion state;

[0014] Determining the motion state of the sperm in the image video according to the motion trajectory of the sperm and the motion recognition model;

[0015] A space-time trajectory diagram is generated according to the motion trajectory of each sperm in the image video and its corresponding motion state; wherein the space-time trajectory diagram is used to display the motion trajectory of each sperm in the animal semen and its corresponding motion state.

[0016] In one embodiment, the identifying the movement trajectory of the sperm in the animal semen in the image video includes:

[0017] Extracting adjacent frame images of the captured image in the image video; wherein the image video is composed of a plurality of frames of captured images that are continuous in time;

[0018] Determining a target area containing sperm in the adjacent frame images;

[0019] The motion trajectory of the sperm in the target area between the captured image and the adjacent frame image is estimated to obtain the motion trajectory of multiple sperms of the animal semen in each frame of continuous captured images.

[0020] In one embodiment, estimating the movement trajectory of sperm in the target area between the captured image and the adjacent frame image includes:

[0021] Determining key points corresponding to sperm in the target area;

[0022] Calculating the vertical gradient and the horizontal gradient of the pixel points around the key point;

[0023] Calculate the optical flow vector of the key point according to the gradient of the pixel points around the key point in the vertical direction and the gradient in the horizontal direction; wherein the optical flow vector includes the motion offset of the key point in the horizontal direction and the motion offset in the vertical direction;

[0024] The movement trajectory of the sperm in the target area between the captured image and the adjacent frame image is determined according to the movement offset in the horizontal direction and the movement offset in the vertical direction of the key point.

[0025] In one embodiment, creating a motion recognition model includes:

[0026] Acquiring a plurality of reference image videos containing semen of the animal;

[0027] identifying the movement trajectory of a reference sperm of the animal's semen in each reference image video;

[0028] Extracting features from the motion trajectory of the reference sperm to obtain a feature map;

[0029] Based on the attention mechanism, performing global average pooling processing on the feature map to obtain a feature vector of the reference sperm;

[0030] Inputting the feature vector of the reference sperm into a classifier for classification to obtain the motion state of the reference sperm;

[0031] The motion recognition model is constructed according to the motion trajectories of a plurality of reference sperms and their corresponding motion states.

[0032] In one embodiment, the step of extracting features from the reference sperm's motion trajectory to obtain a feature map includes:

[0033] The spatiotemporal features of the reference sperm's motion trajectory are extracted to obtain a spatiotemporal feature map; wherein the feature map includes the spatiotemporal feature map.

[0034] In one embodiment, the performing global average pooling processing on the feature map based on the attention mechanism to obtain the feature vector of the reference sperm includes:

[0035] Calculating attention weights according to the spatiotemporal features and weight parameters of the spatiotemporal feature graph;

[0036] Calculating a weighted spatiotemporal feature map according to the attention weight and the spatiotemporal feature map;

[0037] Performing global average pooling processing on the weighted spatiotemporal feature map to obtain the spatiotemporal feature vector of the reference sperm;

[0038] The step of inputting the feature vector of the reference sperm into a classifier for classification to obtain the motion state of the reference sperm includes:

[0039] The spatiotemporal feature vector of the reference sperm is input into a recurrent neural network model for classification to obtain the motion state of the reference sperm.

[0040] In one embodiment, generating a spatiotemporal trajectory diagram according to the motion trajectory of each sperm in the image video and its corresponding motion state includes:

[0041] Constructing a time series for each sperm; wherein the time series includes the coordinate position of the sperm in the multiple frames of the image video and the trajectory length of the sperm;

[0042] Creating a blank image on a preset coordinate system; wherein the blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value;

[0043] Marking the coordinate position of each sperm in the multiple frames of the image video in the form of an identifier in the blank image and sequentially connecting the identifiers according to the time sequence of the image video to draw a movement trajectory of each sperm;

[0044] The motion state of each sperm is marked at the corresponding position of the drawn motion trajectory to generate the spatiotemporal trajectory diagram.

[0045] In one embodiment, after generating the spatiotemporal trajectory diagram according to the motion trajectory of each sperm in the image video and its corresponding motion state, the method for detecting animal semen quality further includes:

[0046] Counting the number of occurrences of each same motion state in the space-time trajectory diagram;

[0047] Based on the number of occurrences of each identical motion state, the number of sperms in the animal's semen with an active state is counted.

[0048] Another aspect of the present invention provides a device for detecting animal semen quality, comprising:

[0049] A video acquisition module, used for acquiring image videos containing animal semen;

[0050] An identification module, used for identifying the movement track of sperm in the animal semen in the image video;

[0051] A feature extraction module, used for extracting features of the motion trajectory of the sperm in the animal semen to obtain a feature vector of the sperm;

[0052] A prediction module, used for predicting the sperm vitality index label value according to the sperm feature vector and the vector machine model;

[0053] A calculation module, used for calculating the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen;

[0054] The evaluation module is used to obtain the quality evaluation value of the animal semen according to the density of the animal semen and the activity index label values ​​of multiple sperms in the animal semen.

[0055] The beneficial effect of the present invention is that the present invention is based on the estimation method of optical flow vector, and the motion of each pixel in the captured image is estimated by the Lucas-Kanade optical flow method, thereby tracking the motion trajectory of sperm. Then, under the feature extraction strategy of attention enhancement, the motion trajectory of the tracked sperm is feature extracted, wherein the motion of the sperm is feature extracted using a convolutional neural network to obtain a feature map, and an attention mechanism is introduced on the feature map to improve the model's attention to the sperm area, so that the area where the sperm is located can be accurately located. The motion state of the sperm is classified by learning the spatiotemporal characteristics of the sperm and using a recurrent neural network. The motion state of the identified sperm and the corresponding spatiotemporal key information are visualized, for example, a spatiotemporal trajectory map is generated, and the motion state and morphological characteristics of the sperm can be intuitively displayed through the spatiotemporal trajectory map. In order to determine the quality of animal semen, the activity state of the sperm is predicted by a vector machine model to obtain a vitality index label value, and the density of the animal semen is calculated by the volume of the animal semen and the number of sperm. Then, according to the activity index label value and the density of the animal semen, the quality evaluation value of the animal semen is calculated, so as to determine the quality of the animal semen according to the quality evaluation value. At the same time, quality evaluation values ​​can be obtained through user interface data, allowing users to easily view evaluation results and reports and achieve rapid and accurate testing of multiple indicators of semen samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 The present invention is a schematic flow chart of the method for detecting animal semen quality provided by the present invention.

[0057] Figure 2 A schematic flow chart of a method for detecting animal semen quality provided by another embodiment of the present invention.

[0058] Figure 3 A schematic diagram of the flow of the method for constructing a motion recognition model provided by the present invention.

[0059] Figure 4 The figure is a flow chart of the method for generating a spatiotemporal trajectory graph provided by the present invention.

[0060] Figure 5 This is a schematic diagram of the structure of the device for detecting animal semen quality provided by the present invention.

[0061] Figure 6 This is a schematic structural diagram of a device for detecting animal semen quality provided by another embodiment of the present invention.

[0062] Figure 7 It is a structural diagram of the electronic device provided by the present invention.

[0063] Description of reference numerals:

[0064] 20. Animal semen quality detection device; 201. Video acquisition module; 202. Recognition module; 203. Feature extraction module; 204. Prediction module; 205. Calculation module; 206. Evaluation module; 2021. Extraction unit; 2022. Determination unit; 2023. Estimation unit; 10. Electronic device; 11. Processor; 12. Memory; 13. Input device; 14. Output device. DETAILED DESCRIPTION

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

[0066] Embodiment 1: Figure 1 The figure is a flow chart of the method for detecting the quality of animal semen provided by the present invention. Figure 1 , animal semen quality detection methods include:

[0067] S110: Acquire an image video containing animal semen.

[0068] In the embodiment of the present invention, in order to accurately determine the quality of animal semen, the present invention needs to obtain images and videos containing animal semen in advance, so as to analyze the quality of animal semen based on the images and videos. The present invention can take images and videos of animal semen by using equipment such as a microscope and a high-speed camera.

[0069] S120: Identify the movement trajectory of sperm in animal semen in the image video.

[0070] In an embodiment of the present invention, in order to identify the activity state of each sperm in animal semen, the present invention can first identify the movement trajectory of each sperm in the animal semen in the image video, and determine the activity state of each sperm through the movement trajectory of each sperm.

[0071] Before identifying the movement trajectory of sperm in animal semen in an image video, it is necessary to preprocess multiple frames of captured images in the image video to reduce interference information in the multiple frames of captured images and prevent the interference information from affecting the identification of the movement trajectory of sperm in animal semen in the image video. Specifically, the method for preprocessing multiple frames of captured images in an image video includes: graying each frame of the captured image to obtain a grayed captured image; denoising the grayed captured image to obtain a denoised captured image. Then, the movement trajectory of each sperm in the multiple frames of denoised images is identified.

[0072] S130: Extracting features of the movement trajectory of sperm in animal semen to obtain a feature vector of the sperm.

[0073] In an embodiment of the present invention, in order to efficiently perform spatiotemporal analysis on the motion trajectory of sperm, feature extraction can be performed on the motion trajectory of each sperm in animal semen. Specifically, spatiotemporal feature extraction can be performed on the motion trajectory of each sperm in animal semen to obtain the spatiotemporal feature vector of the motion trajectory of sperm. The important spatiotemporal information in the motion trajectory of sperm can be determined by the spatiotemporal feature vector. During feature extraction, the motion trajectory of sperm in animal semen can be feature extracted by motion features and morphological features, specifically including feature extraction of the motion trajectory of sperm in animal semen by features such as linear motion, curvilinear motion, path speed, size, circumference, angle, linearity, forwardness, and swingability of sperm. Among them, motion features include linear motion, path speed, curvilinear motion, forwardness, and swingability. Morphological features include size, circumference, angle, and linearity. Linear motion and curvilinear motion describe the way sperm moves in space. Linear motion means that sperm moves along a straight path, while curvilinear motion means that sperm moves along a curvilinear path. Path speed means the speed of sperm on its motion trajectory. It describes the distance that the sperm travels along a path per unit of time. Proximity and oscillation describe the change in direction and the amplitude of the oscillation of the sperm during movement. Size indicates the size or size of the sperm. Circumference indicates the length of the sperm's boundaries. Angle indicates the angular relationship between the sperm or sperm located in a specific area. Straightness indicates whether the shape of the sperm tends to be more straight.

[0074] Specifically, a convolutional neural network can be used to extract spatiotemporal features of the sperm trajectory in animal semen, and the data sequence of the sperm trajectory can be set. ,in Represents the coordinate position of the sperm at time t.

[0075] S140: Predict the sperm motility index label value based on the sperm feature vector and the vector machine model.

[0076] In the embodiment of the present invention, in order to evaluate the quality of animal semen, it is necessary to first predict the motility characteristics of sperm. The motility characteristics can be reflected by the motility index label value of sperm, wherein the motility index label value is between 0 and 1, and the value represents the motility level or motility characteristics of sperm.

[0077] Specifically, the present invention can first construct a vector machine model for predicting the vitality characteristics of sperm in a new sample. The method for constructing the vector machine model includes: obtaining the spatiotemporal feature vectors of multiple reference sperms, then obtaining the vitality index label value corresponding to the spatiotemporal feature vector of each reference sperm, and establishing a corresponding relationship between the spatiotemporal feature vectors of the multiple reference sperms and their corresponding vitality index label values ​​to obtain the vector machine model. The constructed vector machine model can predict the vitality characteristics of sperm in a new sample and obtain the vitality index label value of sperm in the new sample.

[0078] Among them, the spatiotemporal feature vector X of the reference sperm and its corresponding vitality index label value The corresponding relationship between them is set as , where X represents the spatiotemporal feature vector of the reference sperm, Indicates the vitality indicator label value.

[0079] S150: Calculate the density of the animal semen according to the number of sperms in the animal semen and the volume of the animal semen.

[0080] In the embodiment of the present invention, since semen density is generally proportional to the number of sperms, the quality of animal semen can be directly judged by semen density. The present invention calculates the density of animal semen by the number of sperms in the animal semen and the volume of the animal semen.

[0081] Among them, the calculation formula of animal semen density is: , where N represents the number of sperm in animal semen and V represents the volume of animal semen.

[0082] S160: Obtaining a quality evaluation value of the animal semen according to the density of the animal semen and the motility index label values ​​of multiple sperms in the animal semen.

[0083] In an embodiment of the present invention, since the density of animal semen and the motility characteristics of sperm in animal semen determine the quality of animal semen, the product of the motility index label value of each sperm in the animal semen and the density of the animal semen can be calculated, and then the multiple products can be weighted to obtain the quality evaluation value of the animal semen, and the quality of the animal semen can be estimated by the quality evaluation value of the animal semen.

[0084] In addition, the present invention can set a preset quality threshold, and use the preset quality threshold to judge the quality of animal semen. That is, if the quality evaluation value is greater than the preset quality threshold, the quality of the animal semen is determined to be high quality. If the quality evaluation value is less than the preset quality threshold, the quality of the animal semen is determined to be poor quality. Alternatively, the present invention can also set quality intervals, each quality interval corresponds to a grade, for example, the first quality interval corresponds to grade A, then when the quality evaluation value matches the first quality interval, the quality grade of the animal semen is determined to be grade A. The specific method is: obtain quality intervals corresponding to different quality grades; determine the quality interval matching the quality evaluation value as the target quality interval; determine the quality grade corresponding to the target quality interval as the quality grade of the animal semen.

[0085] The present invention relates to a method for detecting the quality of animal semen, comprising: obtaining an image video containing animal semen, identifying the motion trajectory of sperm in the animal semen in the image video, extracting features of the motion trajectory of the sperm in the animal semen to obtain a feature vector of the sperm, predicting a sperm vitality index label value according to the sperm vitality vector and a vector machine model, calculating the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen, and obtaining a quality evaluation value of the animal semen according to the density of the animal semen and the vitality index label values ​​of multiple sperm in the animal semen. The activity state of the sperm is predicted by a vector machine model to obtain a vitality index label value, and the quality evaluation value of the animal semen is calculated according to the activity index label value and the density of the animal semen, so as to determine the quality of the animal semen according to the quality evaluation value.

[0086] Figure 2 A schematic flow chart of a method for detecting animal semen quality provided by another embodiment of the present invention. Figure 3 The flowchart of the method for constructing the motion recognition model provided by the present invention is shown in FIG. Figure 2-Figure 3 Before S160, the methods for testing animal semen quality may include:

[0087] S170: Create a motion recognition model, wherein the motion recognition model includes a motion trajectory of a reference sperm and its corresponding motion state.

[0088] In the embodiment of the present invention, by creating a motion recognition model in advance, the motion state of sperm in a new sample can be quickly determined.

[0089] Specifically, step 170 may include the following steps:

[0090] S171: Acquire multiple reference image videos containing animal semen.

[0091] In the embodiment of the present invention, in order to create an accurate motion recognition model, a large number of training samples are required to train the model, thereby improving the accuracy of the model.

[0092] Specifically, a plurality of reference image videos containing animal semen can be taken by using equipment such as a microscope and a high-speed camera.

[0093] S172: Identify the movement trajectory of the reference sperm of the animal semen in each reference image video.

[0094] In the embodiment of the present invention, the movement trajectory of each sperm in the animal semen is identified by using the optical flow vector of the reference sperm in the animal semen.

[0095] Specifically, S172 can be implemented as follows: extracting reference adjacent frame images of a reference shot image in a reference image video, wherein the reference image video is composed of multiple frames of time-continuous reference shot images; determining a reference target area containing reference sperm in the reference adjacent frame images; estimating the motion trajectory of the reference sperm in the reference target area between the reference shot image and the reference adjacent frame image, so as to obtain the motion trajectories of multiple reference sperm of animal semen in each frame of time-continuous reference shot images.

[0096] First, it can be assumed that the image grayscale value between the reference captured image and its corresponding reference adjacent frame captured image is approximately constant in space. That is: ,in, is the horizontal movement offset of the reference key point, is the vertical displacement of the reference key point. represents the grayscale value of the reference captured image, Represents the grayscale value of the image captured by the reference adjacent frame. The Lucas-Kanade optical flow method is then used to estimate the optical flow vector. Specifically, a linear approximation is performed on the pixels around the reference sperm in a small window, where the window is represented as the reference target area mentioned above, and the size of the window is , N represents the number of pixels. The motion trajectory of the reference sperm in the reference target area between the reference captured image and the reference adjacent frame image is estimated, so that the motion trajectory of the reference sperm on the multi-frame continuous captured images can be obtained. The motion trajectories of different reference sperm at different positions can be estimated by placing the window (or reference target area) at different positions in the reference captured image, so that the motion trajectory of each sperm in the animal semen on the multi-frame continuous captured images can be obtained.

[0097] Among them, the Lucas-Kanade optical flow method is a classic optical flow estimation method, which is based on some assumptions to simplify the calculation of the optical flow field. The Lucas-Kanade method assumes that within a small local window, the grayscale value of the image changes linearly over time. This means that within this small window, a local motion model can be used to describe the change in pixel grayscale values, so that the optical flow of the entire image can be estimated by the local optical flow. Assuming that the image grayscale values ​​between adjacent frames are approximately constant in space can simplify the calculation in the Lucas-Kanade method. By spatially averaging the grayscale values ​​in a small local window, the amount of calculation can be reduced, making the optical flow estimation more efficient. Assuming that the grayscale values ​​are approximately constant in space also helps to suppress the impact of noise in the image on optical flow estimation.

[0098] Among them, by limiting the optical flow estimation within a small window, the motion relationship between local pixels can be better handled. This localized processing method can reduce the complexity of the problem, making the optical flow estimation more reliable and efficient. Using a small window estimation can reduce the number of pixels that need to be considered, thereby reducing the amount of calculation. For each window, only a few pixels need to be considered, avoiding global processing of the entire image and improving the efficiency of the algorithm. Small window estimation can improve the stability of the algorithm. In a small local window, the change of grayscale values ​​is easier to establish a linear model, thereby improving the accuracy and stability of optical flow estimation.

[0099] Specifically, estimating the motion trajectory of a reference sperm in a target area between a reference captured image and a reference adjacent frame image comprises the following steps: determining a reference key point corresponding to the reference sperm in the target area; calculating the gradient of pixels around the reference key point in the vertical direction and the gradient of pixels around the reference key point in the horizontal direction; calculating a reference optical flow vector of the reference key point based on the gradient of pixels around the reference key point in the vertical direction and the gradient of pixels around the reference key point in the horizontal direction; wherein the reference optical flow vector comprises a motion offset of the reference key point in the horizontal direction and a motion offset of the reference key point in the vertical direction; determining the motion trajectory of the sperm in the reference target area between the reference captured image and the reference adjacent frame image based on the motion offset of the reference key point in the horizontal direction and the motion offset of the reference key point in the vertical direction.

[0100] First, determine the reference key point corresponding to the reference sperm in the reference target area, that is, the reference key point corresponds to the position of the reference sperm or the pixel point where the reference sperm is located. Then, linear approximation is performed on the pixel points around the reference key point in the reference target area, and the gradient of the pixel points around the reference key point in the vertical direction and the gradient in the horizontal direction are calculated. The calculation formula is:

[0101] , and is the gradient of the pixels around the reference key point in the reference target area in the x and y directions, is the rate of change of the image of the reference target area over time, which can be calculated according to the calculation formula and , is the horizontal movement offset of the reference key point, is the vertical motion offset of the reference key point. The above equation can be solved by the least square method. Then, according to the horizontal motion offset and the vertical motion offset of the reference key point, the position change of the reference key point in the multi-frame continuous time-lapse images is tracked to obtain the motion trajectory of the sperm. That is, after the position of the sperm is detected in the first frame of the captured image, the position of the sperm is predicted in the next frame according to the horizontal motion offset and the vertical motion offset of the reference key point. According to the optical flow vector near the predicted position, the actual position of the sperm can be adjusted to obtain a more accurate tracking result. The tracked sperm position is recorded to form its motion trajectory in time.

[0102] S173: Extract features from the motion trajectory of the reference sperm to obtain a feature map.

[0103] In an embodiment of the present invention, features of the motion trajectory of a reference sperm can be extracted through a pre-trained convolutional neural network, and a feature map is obtained after feature extraction, wherein the feature map contains important feature information in the captured image, such as the morphology, density, and distribution of sperm.

[0104] S174: Based on the attention mechanism, the feature map is globally averaged pooled to obtain the feature vector of the reference sperm.

[0105] In the embodiment of the present invention, an attention mechanism is introduced on the feature map to improve the model's attention to the sperm area. Assuming that the input feature map is F and the attention weight is A, the calculation process of the attention mechanism is as follows:

[0106] ; Where W is the first weight parameter, which can be the first learnable weight parameter, b is the first bias parameter, and the Softmax function is used to normalize the attention weight. The attention weight is then applied to the feature map to obtain a weighted feature map , and its calculation formula is: ;in, Represents an element-by-element multiplication operation. Finally, a global average pooling operation is performed on the weighted feature map to obtain the feature vector (global average value of the i-th channel), which is calculated as:

[0107] , where h and w represent the height and width of the feature map respectively. Represents the weighted feature map The value at position (j, k) and channel i, represents the global average of the i-th channel.

[0108] S175: Input the feature vector of the reference sperm into the classifier for classification to obtain the movement state of the reference sperm.

[0109] In an embodiment of the present invention, classification is performed by inputting a feature vector into a classifier, wherein the feature vector can be input into a fully connected layer for classification, and a probability distribution of each category is output, that is, the matching probability between the motion trajectory and the motion state of the reference sperm, and a category with a matching probability greater than a preset probability threshold is selected as the motion state corresponding to the motion trajectory of the reference sperm, that is, a category with a higher matching probability is selected as the motion state corresponding to the motion trajectory of the reference sperm.

[0110] S176: Construct a motion recognition model based on the motion trajectories of multiple reference sperms and their corresponding motion states.

[0111] In an embodiment of the present invention, the motion recognition model can be constructed using a model structure such as CNN, so that when the input is the motion trajectory of the reference sperm, the output is the motion state of the reference sperm. CNN is the abbreviation of Convolutional Neural Network, which is a deep learning model that is usually used to process and analyze data with a grid structure, such as images and videos.

[0112] S180: Determine the movement state of the sperm in the image video according to the movement trajectory of the sperm and the movement recognition model.

[0113] In the embodiment of the present invention, although the motion trajectory of each sperm in the animal semen can be determined, it is still necessary to identify the motion state corresponding to each motion trajectory. The motion trajectory describes the path of the sperm moving in space. The motion state of the sperm can be determined by the moving path, and the motion state includes linear motion, forward motion, curvilinear motion, swinging motion, etc. And each motion state corresponds to the morphological characteristics of the sperm.

[0114] S190: Generate a space-time trajectory diagram according to the motion trajectory of each sperm in the image video and its corresponding motion state, wherein the space-time trajectory diagram is used to display the motion trajectory of each sperm in the animal semen and its corresponding motion state.

[0115] In the embodiment of the present invention, in order to enable the user to intuitively understand the motion state and morphological characteristics of sperm, a spatiotemporal trajectory diagram is generated according to the motion state corresponding to the motion trajectory of each sperm in the animal semen in the image video. The spatiotemporal trajectory diagram can be used to visualize the motion state and morphological characteristics of sperm.

[0116] In one embodiment, S120 can be specifically implemented as follows: extracting adjacent frame images of a captured image in an image video; wherein the image video is composed of multiple frames of time-continuous captured images; determining a target area containing sperm in adjacent frame images; estimating the movement trajectory of sperm in the target area between the captured image and the adjacent frame images, so as to obtain the movement trajectory of multiple sperm in animal semen in each frame of time-continuous captured images.

[0117] In the embodiment of the present invention, first, it can be assumed that the image grayscale value between the captured image and its corresponding adjacent frame captured image is approximately constant in space. That is: ,in, are the pixel coordinates in the captured image, Represents the grayscale value of the captured image, Represents the grayscale value of the image captured by adjacent frames, and is the horizontal and vertical motion offset of the key point, i.e., the optical flow vector. The Lucas-Kanade optical flow method is then used to estimate the optical flow vector. Specifically, a linear approximation is performed on the pixels around the sperm in a small window, where the window is represented as the target area mentioned above, and the size of the window is , N represents the number of pixels. The motion trajectory of sperm in the target area between the captured image and the adjacent frame image is estimated, so that the motion trajectory of sperm on multiple frames of continuous captured images can be obtained. By placing the window (or target area) at different positions in the captured image, the motion trajectories of different sperm at different positions can be estimated, so that the motion trajectory of each sperm in the animal semen on multiple frames of continuous captured images can be obtained.

[0118] Among them, the Lucas-Kanade optical flow method is a classic optical flow estimation method, which is based on some assumptions to simplify the calculation of the optical flow field. The Lucas-Kanade method assumes that within a small local window, the grayscale value of the image changes linearly over time. This means that within this small window, a local motion model can be used to describe the change in pixel grayscale values, so that the optical flow of the entire image can be estimated by the local optical flow. Assuming that the image grayscale values ​​between adjacent frames are approximately constant in space can simplify the calculation in the Lucas-Kanade method. By spatially averaging the grayscale values ​​in a small local window, the amount of calculation can be reduced, making the optical flow estimation more efficient. Assuming that the grayscale values ​​are approximately constant in space also helps to suppress the impact of noise in the image on optical flow estimation.

[0119] Among them, by limiting the optical flow estimation within a small window, the motion relationship between local pixels can be better handled. This localized processing method can reduce the complexity of the problem, making the optical flow estimation more reliable and efficient. Using a small window estimation can reduce the number of pixels that need to be considered, thereby reducing the amount of calculation. For each window, only a few pixels need to be considered, avoiding global processing of the entire image and improving the efficiency of the algorithm. Small window estimation can improve the stability of the algorithm. In a small local window, the change of grayscale values ​​is easier to establish a linear model, thereby improving the accuracy and stability of optical flow estimation.

[0120] In one embodiment, S120 can be specifically implemented as follows: determining the key points corresponding to the sperm in the target area; calculating the gradients of the pixels around the key points in the vertical direction and the gradients in the horizontal direction; calculating the optical flow vector of the key point based on the gradients of the pixels around the key points in the vertical direction and the gradients in the horizontal direction; wherein the optical flow vector includes the motion offset of the key point in the horizontal direction and the motion offset in the vertical direction; determining the motion trajectory of the sperm in the target area between the captured image and the adjacent frame image based on the motion offset of the key point in the horizontal direction and the motion offset in the vertical direction.

[0121] First, determine the key point corresponding to the sperm in the target area, that is, the key point corresponds to the position of the sperm or the pixel point where the sperm is located. Then, linear approximation is performed on the pixel points around the key point in the target area, and the vertical and horizontal gradients of the pixel points around the key point are calculated. The calculation formula is:

[0122] , and is the gradient of the pixels around the key point of the target area in the x and y directions, is the rate of change of the image of the target area over time, which can be calculated according to the calculation formula and , is the horizontal movement offset of the key point, is the vertical motion offset of the key point. The above equation can be solved by the least square method. Then, according to the horizontal motion offset and the vertical motion offset of the key point, the position change of the key point in the multi-frame continuous time-lapse images is tracked to obtain the motion trajectory of the sperm. That is, after the position of the sperm is detected in the first frame of the captured image, the position of the sperm is predicted in the next frame according to the horizontal motion offset and the vertical motion offset of the key point. According to the optical flow vector near the predicted position, the actual position of the sperm can be adjusted to obtain a more accurate tracking result. The tracked sperm position is recorded to form its motion trajectory in time.

[0123] In one embodiment, S173 may be specifically implemented as follows: performing spatiotemporal feature extraction on the motion trajectory of the reference sperm to obtain a spatiotemporal feature map, wherein the feature map includes the spatiotemporal feature map.

[0124] In an embodiment of the present invention, in order to perform efficient spatiotemporal analysis on sperm trajectory data and thus accurately identify different motion states of sperm, the present invention combines deep learning and spatiotemporal attention mechanisms, thereby extracting the spatiotemporal characteristics of the sperm motion trajectory, and utilizing the attention mechanism to automatically learn and focus on important spatiotemporal information in the sperm motion trajectory.

[0125] In one embodiment, S174 can be specifically implemented as follows: calculating the attention weight based on the spatiotemporal features and weight parameters of the spatiotemporal feature map; calculating the weighted spatiotemporal feature map based on the attention weight and the spatiotemporal feature map; performing global average pooling processing on the weighted spatiotemporal feature map to obtain the spatiotemporal feature vector of the reference sperm; wherein S175 can be specifically implemented as follows: inputting the spatiotemporal feature vector of the reference sperm into a recurrent neural network model for classification to obtain the motion state of the reference sperm.

[0126] In the embodiment of the present invention, a convolutional neural network is used to extract the spatiotemporal features of the sperm's motion trajectory and set the sperm's motion trajectory sequence as follows:

[0127] , Represents the coordinate position of the sperm at the 𝑡th moment, which is converted into a spatiotemporal feature map through CNN ,in, Represents the spatiotemporal features at the tth moment. The spatiotemporal attention mechanism focuses on important spatiotemporal information by learning spatiotemporal attention weights. For each moment t, an attention mechanism is used to calculate the spatiotemporal attention weights , and its calculation formula is:

[0128] ,in represents the second weight parameter, specifically the second learnable weight parameter, is the second bias parameter. Then the attention weight is applied to the spatiotemporal feature map to obtain the weighted spatiotemporal feature map : ;in, Represents an element-by-element multiplication operation. Furthermore, for the weighted spatiotemporal feature map Perform global average pooling operation to obtain the first eigenvector of sperm , h1 and w1 represent the height and width of the spatiotemporal feature map, respectively. Represents weighted spatiotemporal feature map The value at position (j, k) and channel i, Represents the global average of the i-th channel. The first feature vector is input into the recurrent neural network model (RNN) for classification, and the classification result is output. RNN (Recurrent Neural Network) is a neural network model that can process sequence data.

[0129] Figure 4 This is a flow chart of the method for generating a spatiotemporal trajectory diagram provided by the present invention. Figure 4 , S190 can include:

[0130] S191: Construct a time series for each sperm, wherein the time series includes the coordinate position of the sperm in multiple frames of the image video and the trajectory length of the sperm.

[0131] In the embodiment of the present invention, in order to enable the user to intuitively understand the movement state and morphological characteristics of sperm, the first feature vector The sperm trajectory is obtained to obtain the change of the coordinate position of each sperm in the captured image over time. , whose motion trajectory can be expressed as a time series ,in, is the sperm at time t The coordinate position in the captured image, is the trajectory length of sperm i.

[0132] S192: Creating a blank image in a preset coordinate system, wherein the blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value.

[0133] In the embodiment of the present invention, in order to draw the space-time trajectory diagram, a preset coordinate system is first constructed, which includes time as the X-axis (time axis) and spatial position as the Y-axis (space axis), and then a blank image is created on the space axis. The blank image is composed of an image matrix. The size of the blank image is , It is the maximum length of the trajectory of sperm in animal semen, that is, the maximum value of the trajectory lengths of multiple sperm in animal semen. It can be the length or width of the blank image, and M represents the width or length of the blank image.

[0134] The blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value. The image matrix can represent a completely black or completely white image, wherein the grayscale values ​​of all pixels in the image matrix are the first preset grayscale value, the first preset grayscale value is 0, representing black, or the grayscale values ​​of all pixels in the image matrix are the second preset grayscale value, the second preset grayscale value is 255, representing white.

[0135] S193: Mark the coordinate position of each sperm in the multiple frames of the image video in the form of an identifier in the blank image and connect the identifiers in sequence according to the time sequence of the image video to draw the movement trajectory of each sperm.

[0136] In the embodiment of the present invention, for each sperm's motion trajectory , draw the coordinate position in the motion trajectory on the preset coordinate system, that is, the corresponding position t on the time axis and the corresponding position on the space axis , and the coordinate position of each sperm in the multi-frame images of the image video is marked in the blank image in the form of an identifier, and the identifiers are connected in sequence according to the time sequence of the image video to draw the movement trajectory of each sperm. Among them, the shape of the identifier can be circular, triangular, star-shaped, etc., and each sperm in the animal semen can be assigned a different identifier. The shape of the identifier is not limited and can be any shape, which is determined according to the user's choice.

[0137] S194: Mark the motion state of each sperm at the corresponding position of the drawn motion trajectory to generate a spatiotemporal trajectory diagram.

[0138] In the embodiment of the present invention, different motion state marks are added to the motion trajectory of each sperm according to the motion state of each sperm. , according to the movement state of the sperm, a movement state mark is drawn at the corresponding coordinate position on the preset coordinate system. Among them, the shape of the movement state mark can be a mark such as a straight line, a curve, etc. that can represent the movement state of the sperm. The shape of the movement state mark is not limited in any way and can be any shape, which is specifically determined according to the user's choice. Then the movement trajectory of each sperm in the animal semen and its corresponding movement state mark are drawn on the same blank image to form a space-time trajectory diagram.

[0139] In one embodiment, after S190, the method for detecting the quality of animal semen can be specifically implemented as follows: counting the number of occurrences of each identical motion state in the space-time trajectory diagram; and based on the number of occurrences of each identical motion state, counting the number of sperm in an active state in the animal semen.

[0140] In an embodiment of the present invention, a counter is initialized, and a counter is set up for each motion state to record the number of times the motion state occurs. Then, the motion trajectories of all sperm in the animal semen are traversed, and the corresponding counter is updated according to the motion state of the sperm in each time step. Finally, the counting result of each motion state is output, that is, the number of times each state occurs. Then, based on the number of occurrences of each same motion state, the number of sperm in the animal semen with an active state is counted. It should be understood that when the sperm is not in an active state, the sperm is located in the same position and does not move. It can be specifically determined based on morphological characteristics and motion state. For example, the angle in the morphological characteristics has not changed, and the motion state is in the original position, then the corresponding sperm is not moving, that is, there is no active state. The number of sperm in the animal semen with an active state is displayed, so as to help users determine whether the activity state of the sperm in the animal semen is of high quality.

[0141] Figure 5 This is a schematic diagram of the structure of the device for detecting animal semen quality provided by the present invention. Figure 5 The device 20 for detecting the quality of animal semen includes: a video acquisition module 201, which is used to acquire an image video containing animal semen; an identification module 202, which is used to identify the movement trajectory of sperm in the animal semen in the image video; a feature extraction module 203, which is used to extract the feature of the movement trajectory of the sperm in the animal semen to obtain the feature vector of the sperm; a prediction module 204, which is used to predict the sperm vitality index label value according to the sperm feature vector and the vector machine model; a calculation module 205, which is used to calculate the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen; an evaluation module 206, which is used to obtain the quality evaluation value of the animal semen according to the density of the animal semen and the vitality index label values ​​of multiple sperm in the animal semen.

[0142] Figure 6This is a schematic diagram of the structure of a device for detecting animal semen quality provided by another embodiment of the present invention. Figure 6 Before the evaluation module 206, the animal semen quality detection device 20 can be specifically configured as follows: creating a motion recognition model; wherein the motion recognition model includes the motion trajectory of the reference sperm and its corresponding motion state; determining the motion state of the sperm in the image video according to the motion trajectory of the sperm and the motion recognition model; generating a space-time trajectory diagram according to the motion trajectory of each sperm in the image video and its corresponding motion state; wherein the space-time trajectory diagram is used to display the motion trajectory of each sperm in the animal semen and its corresponding motion state.

[0143] In one embodiment, the recognition module 202 may include: an extraction unit 2021, used to extract adjacent frame images of a captured image in an image video; wherein the image video is composed of multiple frames of time-continuous captured images; a determination unit 2022, used to determine a target area containing sperm in adjacent frame images; an estimation unit 2023, used to estimate the movement trajectory of sperm in the target area between the captured image and the adjacent frame images, so as to obtain the movement trajectory of multiple sperms of animal semen in each frame of time-continuous captured images.

[0144] In one embodiment, the estimation unit 2023 can be specifically configured as follows: determining the key points corresponding to the sperm in the target area; calculating the gradients of the pixels around the key points in the vertical direction and the gradients in the horizontal direction; calculating the optical flow vector of the key points based on the gradients of the pixels around the key points in the vertical direction and the gradients in the horizontal direction; wherein the optical flow vector includes the motion offset of the key points in the horizontal direction and the motion offset in the vertical direction; determining the motion trajectory of the sperm in the target area between the captured image and the adjacent frame image based on the motion offset of the key points in the horizontal direction and the motion offset in the vertical direction.

[0145] In one embodiment, the animal semen quality detection device 20 can be specifically configured as follows: obtaining multiple reference image videos containing animal semen; identifying the motion trajectory of the reference sperm of the animal semen in each reference image video; performing feature extraction on the motion trajectory of the reference sperm to obtain a feature map; based on the attention mechanism, performing global average pooling processing on the feature map to obtain a feature vector of the reference sperm; inputting the feature vector of the reference sperm into a classifier for classification to obtain the motion state of the reference sperm; and constructing a motion recognition model based on the motion trajectories of multiple reference sperm and their corresponding motion states.

[0146] In one embodiment, the animal semen quality detection device 20 may be specifically configured as follows: performing spatiotemporal feature extraction on the motion trajectory of reference sperm to obtain a spatiotemporal feature map; wherein the feature map includes a spatiotemporal feature map.

[0147] In one embodiment, the animal semen quality detection device 20 can be specifically configured as follows: calculating the attention weight based on the spatiotemporal characteristics and weight parameters of the spatiotemporal feature map; calculating the weighted spatiotemporal feature map based on the attention weight and the spatiotemporal feature map; performing global average pooling processing on the weighted spatiotemporal feature map to obtain the spatiotemporal feature vector of the reference sperm; inputting the spatiotemporal feature vector of the reference sperm into a recurrent neural network model for classification to obtain the motion state of the reference sperm.

[0148] In one embodiment, the animal semen quality detection device 20 can be specifically configured as follows: constructing a time series for each sperm; wherein the time series includes the coordinate position of the sperm in multiple frames of an image video and the trajectory length of the sperm; creating a blank image on a preset coordinate system; wherein the blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value; marking the coordinate position of each sperm in the multiple frames of an image video in the form of an identifier in the blank image and connecting the identifiers in sequence according to the time sequence of the image video to draw the motion trajectory of each sperm; marking the motion state of each sperm at the corresponding position of the drawn motion trajectory to generate a spatio-temporal trajectory diagram.

[0149] In one embodiment, the animal semen quality detection device 20 can be specifically configured to: count the number of occurrences of each same motion state in the space-time trajectory diagram; and count the number of sperm in the animal semen in an active state based on the number of occurrences of each same motion state.

[0150] Figure 7 A block diagram of an electronic device according to an embodiment of the present application is illustrated.

[0151] like Figure 7 As shown, the electronic device 10 includes one or more processors 11 and a memory 12 .

[0152] The processor 11 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 10 to perform desired functions.

[0153] The memory 12 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 11 may run the program instructions to implement the animal semen quality detection method of each embodiment of the present application described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.

[0154] In one example, the electronic device 10 may further include: an input device 13 and an output device 14 , and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0155] When the electronic device is a stand-alone device, the input device 13 may be a communication network connector, which is used to receive the collected input signals from the first device and the second device.

[0156] In addition, the input device 13 may also include, for example, a keyboard, a mouse, and the like.

[0157] The output device 14 can output various information to the outside, including the determined distance information, direction information, etc. The output device 14 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.

[0158] Of course, to simplify, Figure 7 Only some of the components related to the present application in the electronic device 10 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 10 may also include any other appropriate components.

[0159] The computer program product may be written in any combination of one or more programming languages ​​to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0160] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0161] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for detecting animal semen quality, characterized in that: include: Obtaining images and videos containing animal semen; Extracting adjacent frame images of the captured image in the image video; wherein the image video is composed of a plurality of frames of captured images that are continuous in time; Determining a target area containing sperm in the adjacent frame images; Determining key points corresponding to sperm in the target area; Calculate the vertical gradient and the horizontal gradient of the pixel points around the key point; Calculate the optical flow vector of the key point according to the gradient of the pixel points around the key point in the vertical direction and the gradient in the horizontal direction; wherein the optical flow vector includes the motion offset of the key point in the horizontal direction and the motion offset in the vertical direction; Determine the movement trajectory of the sperm in the target area between the captured image and the adjacent frame image according to the movement offset of the key point in the horizontal direction and the movement offset in the vertical direction; Extracting features of the movement trajectory of the sperm in the animal semen to obtain a feature vector of the sperm; Predicting the sperm motility index label value according to the sperm feature vector and the vector machine model; Calculating the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen; Acquiring a plurality of reference image videos containing semen of the animal; identifying the movement trajectory of a reference sperm of the animal's semen in each reference image video; Extracting spatiotemporal features from the reference sperm's motion trajectory to obtain a spatiotemporal feature map; wherein the feature map includes the spatiotemporal feature map; Calculating attention weights according to the spatiotemporal features and weight parameters of the spatiotemporal feature graph; Calculating a weighted spatiotemporal feature map according to the attention weight and the spatiotemporal feature map; Performing global average pooling processing on the weighted spatiotemporal feature map to obtain the spatiotemporal feature vector of the reference sperm; Inputting the spatiotemporal feature vector of the reference sperm into a recurrent neural network model for classification to obtain the motion state of the reference sperm; Constructing a motion recognition model according to the motion trajectories of a plurality of reference sperms and their corresponding motion states; wherein the motion recognition model includes the motion trajectories of the reference sperms and their corresponding motion states; Determining the motion state of the sperm in the image video according to the motion trajectory of the sperm and the motion recognition model; Constructing a time series for each sperm; wherein the time series includes the coordinate position of the sperm in the multiple frames of the image video and the trajectory length of the sperm; Creating a blank image on a preset coordinate system; wherein the blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value; Marking the coordinate position of each sperm in the multiple frames of the image video in the form of an identifier in the blank image and sequentially connecting the identifiers according to the time sequence of the image video to draw a movement trajectory of each sperm; Marking the motion state of each sperm at a corresponding position of the drawn motion trajectory to generate a time-space trajectory diagram; wherein the time-space trajectory diagram is used to display the motion trajectory of each sperm in the animal semen and its corresponding motion state; Counting the number of occurrences of each same motion state in the space-time trajectory diagram; Based on the number of occurrences of each identical motion state, counting the number of sperms in the animal's semen in an active state; A quality evaluation value of the animal semen is obtained according to the density of the animal semen and the motility index label values ​​of multiple sperms in the animal semen.

2. A device for detecting animal semen quality, characterized in that: include: A video acquisition module, used for acquiring image videos containing animal semen; A recognition module, used to: extract adjacent frame images of the captured image in the image video; wherein the image video is composed of multiple frames of captured images that are continuous in time; Determining a target area containing sperm in the adjacent frame images; Determining key points corresponding to sperm in the target area; Calculate the vertical gradient and the horizontal gradient of the pixel points around the key point; Calculate the optical flow vector of the key point according to the gradient of the pixel points around the key point in the vertical direction and the gradient in the horizontal direction; wherein the optical flow vector includes the motion offset of the key point in the horizontal direction and the motion offset in the vertical direction; Determine the movement trajectory of the sperm in the target area between the captured image and the adjacent frame image according to the movement offset of the key point in the horizontal direction and the movement offset in the vertical direction; A feature extraction module, used for extracting features of the motion trajectory of the sperm in the animal semen to obtain a feature vector of the sperm; A prediction module, used for predicting the sperm vitality index label value according to the sperm feature vector and the vector machine model; A calculation module, used for calculating the density of the animal semen according to the number of sperm in the animal semen and the volume of the animal semen; Evaluation module for: Acquiring a plurality of reference image videos containing semen of the animal; identifying the movement trajectory of a reference sperm of the animal's semen in each reference image video; Extracting spatiotemporal features from the reference sperm's motion trajectory to obtain a spatiotemporal feature map; wherein the feature map includes the spatiotemporal feature map; Calculating attention weights according to the spatiotemporal features and weight parameters of the spatiotemporal feature graph; Calculating a weighted spatiotemporal feature map according to the attention weight and the spatiotemporal feature map; Performing global average pooling processing on the weighted spatiotemporal feature map to obtain the spatiotemporal feature vector of the reference sperm; Inputting the spatiotemporal feature vector of the reference sperm into a recurrent neural network model for classification to obtain the motion state of the reference sperm; Constructing a motion recognition model according to the motion trajectories of a plurality of reference sperms and their corresponding motion states; wherein the motion recognition model includes the motion trajectories of the reference sperms and their corresponding motion states; Determining the motion state of the sperm in the image video according to the motion trajectory of the sperm and the motion recognition model; Constructing a time series for each sperm; wherein the time series includes the coordinate position of the sperm in the multiple frames of the image video and the trajectory length of the sperm; Creating a blank image on a preset coordinate system; wherein the blank image is composed of an image matrix, and the grayscale value of each pixel in the image matrix is ​​a first preset grayscale value or a second preset grayscale value; Marking the coordinate position of each sperm in the multiple frames of the image video in the form of an identifier in the blank image and sequentially connecting the identifiers according to the time sequence of the image video to draw a movement trajectory of each sperm; Marking the motion state of each sperm at a corresponding position of the drawn motion trajectory to generate a time-space trajectory diagram; wherein the time-space trajectory diagram is used to display the motion trajectory of each sperm in the animal semen and its corresponding motion state; Counting the number of occurrences of each same motion state in the space-time trajectory diagram; Based on the number of occurrences of each identical motion state, counting the number of sperms in the animal's semen in an active state; A quality evaluation value of the animal semen is obtained according to the density of the animal semen and the motility index label values ​​of multiple sperms in the animal semen.