A method, system, device and medium for monitoring livestock respiratory rate

Through the improved YOLOv8n model and sparse optical flow method, the movement displacement of the abdominal area of ​​domestic animals is monitored in real time, and the problem of time-consuming and labor-consuming traditional domestic animal breathing rate monitoring methods is solved, and accurate and real-time monitoring of domestic animal breathing rate is achieved, which is suitable for resource-constrained deployment scenarios.

CN120323955BActive Publication Date: 2025-08-19ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510819574.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-08-19
Estimated Expiration
2045-06-19

AI Technical Summary

Technical Problem

The existing methods of livestock breathing rate monitoring rely on manual inspection, which is time-consuming and labor-intensive, and cannot achieve real-time tracking, cannot provide immediate feedback, and it is difficult to respond quickly in scenarios such as disease warning.

Method used

The improved YOLOv8n model was used to detect the abdominal area of ​​livestock, and combined with the sparse optical flow method, the motion displacement of the abdominal area of ​​livestock was monitored in real time, and the respiratory signal and respiration rate were calculated.

Benefits of technology

It improves the accuracy and real-time nature of livestock respiration rate monitoring, is suitable for resource-constrained deployment scenarios, and realizes real-time tracking and rapid response to livestock health.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120323955B_ABST
    Figure CN120323955B_ABST
Patent Text Reader

Abstract

This application discloses a livestock respiratory rate monitoring method, system, device, and medium, relating to the field of animal husbandry technology. The method comprises: acquiring target images at two adjacent moments in real time; inputting the target images into a livestock abdominal region detection model, and outputting corresponding target livestock abdominal region detection results; the livestock abdominal region detection model is obtained by training an improved YOLOv8n model using a training set; using a sparse optical flow method, based on the target livestock abdominal region detection results at two adjacent moments, determining the motion displacement of the livestock abdominal region; determining the livestock's respiratory signal based on the motion displacement of the livestock's abdominal region; and determining the livestock's respiratory rate based on the livestock's respiratory signal, thereby achieving real-time monitoring of the livestock's respiratory rate. This application improves the accuracy and real-time performance of livestock respiratory rate monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of animal husbandry technology, and in particular to a method, system, equipment and medium for monitoring the respiratory rate of livestock. Background Art

[0002] Livestock respiratory rate is an important indicator of livestock health. Excessively high or low respiratory rates may indicate illness, stress, or other health issues. Therefore, timely and accurate monitoring of livestock respiratory rate is crucial for improving farming efficiency, ensuring animal welfare, and preventing disease.

[0003] At present, traditional monitoring methods have some limitations. For example, many traditional livestock respiratory rate monitoring methods rely on manual inspection or manual equipment, which usually require regular inspections and are cumbersome processes. These methods are not only time-consuming and labor-intensive, but also have limited monitoring frequency, making it difficult to achieve real-time tracking of livestock health status and may miss early signs of disease.

[0004] In addition, many monitoring systems cannot provide immediate feedback, and the data needs to be processed and analyzed over a period of time, which is not ideal for scenarios that require rapid response (such as disease warning).

[0005] Therefore, it is necessary to provide a method for monitoring the respiratory rate of livestock to solve the above problems. Summary of the Invention

[0006] The purpose of this application is to provide a livestock respiratory rate monitoring method, system, equipment and medium to improve the accuracy and real-time performance of livestock respiratory rate monitoring.

[0007] To achieve the above objectives, this application provides the following solutions:

[0008] In a first aspect, the present application provides a method for monitoring livestock respiratory rate, the method comprising:

[0009] Acquire target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested;

[0010] The target images at two adjacent moments are input into the livestock abdomen region detection model, and the corresponding target livestock abdomen region detection results are output. The target livestock abdomen region detection results are target images with a prediction frame of the livestock abdomen region marked. The livestock abdomen region detection model is obtained by training an improved YOLOv8n model using the training set.

[0011] The sparse optical flow method is used to determine the motion displacement of the target livestock abdomen based on the detection results of the target livestock abdomen at two adjacent moments.

[0012] determining a respiratory signal of the livestock based on the movement displacement of the livestock's abdominal region;

[0013] Based on the respiratory signal of the livestock, the respiratory rate of the livestock is determined, and real-time monitoring of the respiratory rate of the livestock is achieved.

[0014] In one embodiment, the improved YOLOv8n model includes: an improved backbone network, an improved neck network, and a head network;

[0015] The improved backbone network includes a first convolutional layer, a first depth-separable convolutional layer, a second depth-separable convolutional layer, a third depth-separable convolutional layer, a fourth depth-separable convolutional layer, a fifth depth-separable convolutional layer, a sixth depth-separable convolutional layer, a seventh depth-separable convolutional layer, an eighth depth-separable convolutional layer and a ninth depth-separable convolutional layer, which are connected in sequence;

[0016] The improved neck network includes a first upsampling layer, a first splicing layer, a first C2f layer, a second upsampling layer, a second splicing layer, a second C2f layer, a second convolutional layer, a third splicing layer, a third C2f layer, a third convolutional layer, a fourth splicing layer, a fourth C2f layer, and an LSKblock layer, which are connected in sequence; wherein the first upsampling layer is connected to the ninth depthwise separable convolutional layer, the first splicing layer, and the fourth splicing layer, respectively, the first splicing layer is also connected to the seventh depthwise separable convolutional layer, the first C2f layer is connected to the third splicing layer, and the first splicing layer is connected to the fifth depthwise separable convolutional layer;

[0017] The head network includes: a first detection head, a second detection head and a third detection head; wherein the first detection head is connected to the second C2f layer, the second detection head is connected to the third C2f layer, and the third detection head is connected to the LSKblock layer.

[0018] In one embodiment, the training process of the livestock abdomen region detection model specifically includes:

[0019] Constructing a training set; the training set includes: multiple sample images and corresponding real livestock abdomen region detection results; the sample images are images containing sample livestock, and the real livestock abdomen region detection results are sample images with real frames marked with the sample livestock abdomen region;

[0020] Build an improved YOLOv8n model;

[0021] The improved YOLOv8n model is trained using the sample image as input and the sample image with the ground truth box of the abdominal area of the sample livestock as output. The training set is used until the number of training times reaches the maximum or the loss function reaches the minimum. The training is stopped to obtain the livestock abdominal area detection model.

[0022] In one embodiment, a sparse optical flow method is used to determine the motion displacement of the livestock abdomen region based on the detection results of the target livestock abdomen region at two adjacent moments, specifically including:

[0023] The Shi-Tomasi corner detection method is used to determine multiple key feature points in the target image of the prediction frame marked with the abdominal area of the livestock to be tested at two adjacent moments.

[0024] The sparse optical flow method is used to determine the motion displacement of each key feature point based on multiple key feature points in the target image of the prediction frame marked with the abdominal area of the livestock to be tested at two adjacent moments, and the motion displacement of each key feature point is used as the motion displacement of the livestock's abdominal area.

[0025] In one embodiment, determining a respiratory signal of a livestock based on the movement displacement of the livestock's abdominal region specifically includes:

[0026] Based on the motion displacement of each key feature point, calculate the motion direction angle of the corresponding key feature point;

[0027] Convert the motion direction angle of each key feature point into the corresponding motion direction vector;

[0028] Perform weighted average of the motion direction vectors of all key feature points to obtain the corresponding average motion direction vector;

[0029] determining an angle of an average motion direction based on the average motion direction vector;

[0030] The breathing signal of livestock is determined based on the angle of the average movement direction using a sine function.

[0031] In one embodiment, determining the respiratory rate of the livestock based on the livestock's respiratory signal specifically includes:

[0032] Preprocessing the livestock's respiratory signal to obtain a preprocessed livestock's respiratory signal; the preprocessed livestock's respiratory signal includes a plurality of respiratory cycles, each respiratory cycle including a respiratory signal trough and a respiratory signal peak;

[0033] Calculating the respiratory duration of the corresponding respiratory cycle based on time points corresponding to two adjacent respiratory signal troughs in the preprocessed livestock respiratory signal;

[0034] Based on the breathing duration of each breathing cycle, the average breathing duration of the corresponding breathing cycle is calculated;

[0035] Based on the average breathing duration in any respiratory cycle, the respiratory rate in the corresponding respiratory cycle is calculated to obtain the respiratory rate of the livestock.

[0036] In one embodiment, preprocessing the livestock's respiratory signal to obtain the preprocessed livestock's respiratory signal specifically includes:

[0037] Performing a fourth-order bandpass Butterworth filter on the livestock's respiratory signal to obtain a filtered livestock's respiratory signal;

[0038] The filtered livestock respiratory signal is smoothed by Kalman filtering to obtain a preprocessed livestock respiratory signal.

[0039] In a second aspect, the present application provides a livestock respiratory rate monitoring system, which is used to implement the livestock respiratory rate monitoring method, and the livestock respiratory rate monitoring system includes:

[0040] An image acquisition unit is used to acquire target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested;

[0041] a livestock abdomen region detection result determination unit, configured to input a target image into a livestock abdomen region detection model and output a corresponding target livestock abdomen region detection result; the target livestock abdomen region detection result is a target image annotated with a prediction frame of the abdomen region of the livestock to be tested; the livestock abdomen region detection model is obtained by training an improved YOLOv8n model using a training set;

[0042] a motion displacement determining unit, configured to determine the motion displacement of the livestock abdomen region based on detection results of the target livestock abdomen region at two adjacent moments using a sparse optical flow method;

[0043] a breathing signal determining unit, configured to determine a breathing signal of the livestock based on a movement displacement of an abdominal region of the livestock;

[0044] The respiratory rate determination unit is used to determine the respiratory rate of the livestock based on the respiratory signal of the livestock, thereby realizing real-time monitoring of the respiratory rate of the livestock.

[0045] In a third aspect, the present application provides a computer device 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 livestock respiratory rate monitoring methods described above.

[0046] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the livestock respiratory rate monitoring methods described above.

[0047] According to the specific embodiments provided in this application, this application has the following technical effects:

[0048] The present application discloses a livestock respiratory rate monitoring method, system, device and medium. By constructing a livestock abdominal region detection model based on an improved YOLOv8n model as a benchmark model, the livestock abdominal region is identified in a target image through the livestock abdominal region detection model, thereby improving the accuracy of livestock respiratory rate monitoring. At the same time, the livestock respiratory rate can be obtained by inputting the target image into the livestock abdominal region detection model, thereby improving the efficiency and real-time performance of livestock respiratory rate monitoring. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0050] Figure 1 A schematic flow chart of a method for monitoring livestock respiratory rate according to an embodiment of the present application;

[0051] Figure 2 A schematic diagram of a target image provided in an embodiment of the present application;

[0052] Figure 3 A schematic diagram of statistical results of video clip samples provided in one embodiment of the present application;

[0053] Figure 4 A schematic diagram of the improved YOLOv8n model structure provided in one embodiment of the present application;

[0054] Figure 5 A schematic diagram of the structure of a convolutional layer provided in one embodiment of the present application;

[0055] Figure 6 A schematic structural diagram of a C2f layer provided in one embodiment of the present application;

[0056] Figure 7 A schematic diagram of the structure of a Bottleneck layer provided in one embodiment of the present application;

[0057] Figure 8 A schematic structural diagram of a detection head provided in one embodiment of the present application;

[0058] Figure 9 Schematic diagrams of four different test images provided in an embodiment of the present application;

[0059] Figure 10 Schematic diagram of thermal activation of the LSKblock layer inserted after the P3 scale processing layer for different test images provided in one embodiment of the present application;

[0060] Figure 11 Schematic diagram of thermal activation of the LSKblock layer inserted after the P4 scale processing layer for different test images provided in one embodiment of the present application;

[0061] Figure 12 Schematic diagram of thermal activation of the LSKblock layer inserted after the P5 scale processing layer for different test images provided in one embodiment of the present application;

[0062] Figure 13 A schematic diagram of a time domain signal of an original respiratory signal provided in an embodiment of the present application;

[0063] Figure 14 A schematic diagram of the amplitude spectrum of the original respiratory signal provided in one embodiment of the present application;

[0064] Figure 15 A schematic diagram of a time domain signal of a cow's respiratory signal after preprocessing provided in one embodiment of the present application;

[0065] Figure 16 A schematic diagram of the amplitude spectrum of a cow's respiratory signal after preprocessing provided in one embodiment of the present application;

[0066] Figure 17 A schematic diagram of a regression analysis between the predicted and actual values of livestock respiratory rates provided in one embodiment of the present application;

[0067] Figure 18 A Brann-Altmann diagram provided for an embodiment of the present application;

[0068] Figure 19 A schematic diagram showing the effect of a cow's posture change on the time domain signal of an original respiratory signal according to an embodiment of the present application;

[0069] Figure 20 A schematic diagram showing the effect of a cow's posture change on the amplitude spectrum of an original respiratory signal according to an embodiment of the present application;

[0070] Figure 21 A schematic diagram illustrating the effect of a cow's posture change on a pre-processed time domain signal of the cow's respiratory signal provided in one embodiment of the present application;

[0071] Figure 22 A schematic diagram showing the effect of a cow's posture change on the amplitude spectrum of a pre-processed cow's respiratory signal provided in one embodiment of the present application;

[0072] Figure 23 A schematic diagram of an application program execution interface provided in one embodiment of the present application;

[0073] Figure 24 A schematic diagram of the structure of a computer device provided in one embodiment of the present application.

[0074] Reference numerals:

[0075] Improved backbone network-1, improved neck network-2, head network-3. DETAILED DESCRIPTION

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

[0077] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0078] In an exemplary embodiment, Figure 1 As shown, a method for monitoring livestock respiratory rate is provided. The method is executed by a computer device. Specifically, the method can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is described by taking the application of the method to a server as an example. The method includes the following steps.

[0079] Step S1, acquiring target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested.

[0080] Specifically, when the livestock to be tested are dairy cows, this embodiment will be described using dairy cows as an example. The research subjects are 20 lactating dairy cows. Videos are recorded using a mobile phone with a camera resolution of 1920×1080 @ 30 fps. The phone is placed to the side and rear of the cows, with a distance of about 1 to 1.5 meters between the phone and the cows. The duration of each video clip is about 20 seconds. The specific shooting angle and duration can be adjusted according to the posture of the cows. A total of 300 video clips are recorded, such as Figure 2 As shown, each video clip includes multiple target images, and the statistical results of the video clip samples are as follows Figure 3 As shown. The fluctuation of the cow's abdomen was defined as a complete respiratory cycle. The number of consecutive breaths in each video was counted and converted into respiratory rate per minute based on the duration of the breath, as shown in formula (1). According to this standard, three observers manually counted the respiratory rate in 300 videos. The reliability between observers was evaluated using Pearson correlation, and the results were 0.93-0.99 (indicating that the manually counted data were reliable).

[0081] (1)

[0082] Step S2: Input the target images into the livestock abdominal region detection model and output the corresponding target livestock abdominal region detection results; the target livestock abdominal region detection results are target images marked with a prediction frame of the abdominal region of the livestock to be tested. The livestock abdominal region detection model is obtained by training the improved YOLOv8n model using the training set.

[0083] In one embodiment, in step S2, as Figure 4 As shown, the improved YOLOv8n model includes: an improved backbone network 1, an improved neck network 2 and a head network 3.

[0084] The improved backbone network (i.e., Backbone) is PP-LCNet, which includes the first convolutional layer, the first depth-wise separable convolutional layer, the second depth-wise separable convolutional layer, the third depth-wise separable convolutional layer, the fourth depth-wise separable convolutional layer, the fifth depth-wise separable convolutional layer, the sixth depth-wise separable convolutional layer, the seventh depth-wise separable convolutional layer, the eighth depth-wise separable convolutional layer, and the ninth depth-wise separable convolutional layer, which are connected in sequence.

[0085] The improved neck network (Neck) includes a first upsampling layer, a first splicing layer, a first C2f layer, a second upsampling layer, a second splicing layer, a second C2f layer, a second convolutional layer, a third splicing layer, a third C2f layer, a third convolutional layer, a fourth splicing layer, a fourth C2f layer, and an LSKblock layer (i.e., a large selective kernel layer) connected in sequence; wherein, the first upsampling layer is connected to the ninth depthwise separable convolutional layer, the first splicing layer, and the fourth splicing layer respectively, the first splicing layer is also connected to the seventh depthwise separable convolutional layer, the first C2f layer is connected to the third splicing layer, and the first splicing layer is connected to the fifth depthwise separable convolutional layer.

[0086] The head network (Head) includes: the first detection head, the second detection head and the third detection head (in Figure 4 The first detection head is connected to the second C2f layer, the second detection head is connected to the third C2f layer, and the third detection head is connected to the LSKblock layer.

[0087] The structures of the first convolutional layer, the second convolutional layer and the third convolutional layer are the same and are all represented by convolutional layers, such as Figure 5 As shown in the figure, the first convolution layer, the second convolution layer and the third convolution layer all include: a two-dimensional convolution layer, a batch normalization layer and a SiLU layer (i.e., a SiLU activation function layer).

[0088] The structures of the first C2f layer, the second C2f layer, the third C2f layer and the fourth C2f layer are the same and are all represented by C2f. Figure 6As shown, the first C2f layer, the second C2f layer, the third C2f layer and the fourth C2f layer all include: a convolutional layer, a separation layer, n bottleneck layers, a splicing layer, and a convolutional layer. The structure of the bottleneck layer is as follows Figure 7 shown.

[0089] The first detection head, the second detection head and the third detection head have the same structure and are all represented by detection heads. Figure 8 As shown, the first detection head, the second detection head and the third detection head each include two parallel branches, the first branch includes two convolutional layers, a two-dimensional convolutional layer and a category classification loss layer, and the second branch includes: two convolutional layers, a two-dimensional convolutional layer and a box regression loss layer.

[0090] The backbone of YOLOv8 is used to extract basic image features. The backbone of YOLOv8 consists of multiple layers: Layer 0: The first convolutional layer, which takes as input the target image and convolves the input image with a 3×3 kernel size, a stride of 2, and a padding of 1. This operation halves the size of the feature map and reduces the number of output channels to 16. Layer 1: The first depthwise separable convolutional layer, which takes as input the 16-channel feature map from Layer 0, convolves each channel, and then uses pointwise convolution to fuse the channels. The convolution kernel is 3×3, the stride is 1, and the output channels are 32. Layer 2: The second depthwise separable convolutional layer, which takes as input the 32-channel feature map from Layer 1, the convolution kernel is 3×3, the stride is 2, and the output channels are 64. Layer 3: The third depth-wise separable convolution layer, inputs the 64-channel feature map from the second layer, the convolution kernel is 3×3, the stride is 1, and the number of output channels is still 64; Layer 4: The fourth depth-wise separable convolution layer, inputs the 64-channel feature map from the third layer, the convolution kernel is 3×3, the stride is 2, and the number of output channels is 128; Layer 5: The fifth depth-wise separable convolution layer, inputs the 128-channel feature map from the fourth layer, the convolution kernel is 3×3, the stride is 1, and the number of output channels is 128; Layer 6: The sixth depth-wise separable convolution layer, inputs the 128-channel feature map from the fifth layer Feature map, the convolution kernel is 3×3, the stride is 2, and the number of output channels is 256; Layer 7: The seventh depth-wise separable convolution layer, the input is the 256-channel feature map from the 6th layer, the convolution kernel is 5×5, the stride is 1, and the number of output channels is 256; Layer 8: The eighth depth-wise separable convolution layer, the input is the 256-channel feature map from the 7th layer, the convolution kernel is 5×5, the stride is 2, and the number of output channels is 512; Layer 9: The ninth depth-wise separable convolution layer, the input is the 512-channel feature map from the 8th layer, the convolution kernel is 5×5, the stride is 1, and the number of output channels is 512.

[0091] The main task of the Neck layer is to process feature maps from Backbone and fuse features from different layers to better detect objects (such as the abdominal region of livestock). Layer 10: The first upsampling layer. Input: The 512-channel feature map from layer 9. The feature map is upsampled to double its size and uses the nearest neighbor interpolation method, resulting in an output with 512 channels. Layer 11: The first concatenation layer. Input: The 512-channel feature map from layer 10 and the 256-channel feature map from layer 7. These two feature maps are concatenated along the channel dimension, resulting in an output with 768 channels. Layer 12: The first C2f layer. Input: The 768-channel feature map from layer 11. The C2f layer performs deep feature fusion and uses the CSP structure to enhance feature representation. The output has 512 channels. Layer 13: The second upsampling layer. Input: The 512-channel feature map from layer 12. The output has 512 channels. Layer 14: The second concatenation layer, which takes as input the 512-channel feature map from the 13th layer and the 128-channel feature map from the 5th layer, and outputs 640 channels. Layer 15: The second C2f layer, which takes as input the 640-channel feature map from the 14th layer, and outputs 256 channels. Layer 16: The second convolution layer, with a kernel size of 3×3, a stride of 2, and an output of 256 channels. Layer 17: The third concatenation layer, which takes as input the 256-channel feature map from the 16th layer and the 512-channel feature map from the 12th layer, and outputs 768 channels. Layer 18: The third C2f layer, which takes as input the 768-channel feature map from the 17th layer, and outputs 512 channels. Layer 19: The third convolution layer, which takes as input the 512-channel feature map from the 18th layer, a kernel size of 3×3, a stride of 2, and an output of 512 channels. Layer 20: The fourth concatenation layer, which takes as input the 512-channel feature map from layer 19 and the 512-channel feature map from layer 9, and outputs a total of 1024 channels. Layer 21: The fourth C2f layer, which takes as input the 1024-channel feature map from layer 20, and outputs a total of 1024 channels. Layer 22: The LSKblock layer, which takes as input the 1024-channel feature map from layer 21, applies large kernel convolution and spatial selection mechanisms to enhance feature representation and further strengthen the feature information of the region of interest. The output has a total of 1024 channels.

[0092] The head part is mainly used to detect the abdominal area of livestock using the multi-scale feature maps obtained from the neck part. The input is: feature maps from layers 15, 18, and 22. The detection head performs target detection and generates an image with a bounding box of the livestock abdominal area, the category, and the confidence. Finally, the bounding box, category information, and confidence of the livestock abdominal area are output. During model training, the bounding box is the real box, and during prediction, the bounding box is the predicted box.

[0093] Specifically, to select the optimal lightweight object detection model (i.e., the livestock abdominal region detection model), this application evaluated the performance of six mainstream lightweight object detection models in terms of detection accuracy (mAP), computational efficiency (FPS), number of parameters, FLOPs, and model size. As shown in Table 1, YOLOv8n outperformed all other models, achieving a maximum mAP of 83.10% and an inference speed of 100.49 FPS. In contrast, RT-DETR-1 performed lower, with an mAP of 76.70% and a much slower inference speed of only 34.1 FPS, primarily due to its large number of parameters (31.99M) and high computational cost (103.40 GFLOPs).

[0094] YOLOv5n and YOLOv9t have advantages in model compactness, with sizes of 4.43MB and 3.97MB respectively, but compared with YOLOv8n, they have lower accuracy (82.00% and 81.90% mAP) and slower inference speed (71.68FPS and 48.57FPS). Similarly, the detection accuracy and inference speed of YOLOv10n and YOLO11n are also lower than those of YOLOv8n.

[0095] Overall, YOLOv8n achieves the best balance between detection accuracy and inference speed, achieving state-of-the-art performance in both mAP and FPS. Therefore, this application selects YOLOv8n as the baseline model and works to optimize its architecture to reduce model size while maintaining high detection accuracy, making it suitable for resource-constrained deployment scenarios.

[0096] Table 1 Performance comparison of different basic models in livestock abdominal area detection tasks

[0097]

[0098] Furthermore, to further optimize the YOLOv8n baseline model, comparative experiments were conducted, replacing its original backbone network with seven lightweight architectures. As shown in Table 2, among the lightweight variants, MobileViT achieved the highest mAP (82.70%), but incurred a significant computational cost (5.20 GFLOPs) and slow inference speed (54.30 FPS), making it unsuitable for edge deployment. FasterNet, while having the fastest inference speed (100.15 FPS) and the smallest model size (2.93 MB), suffered from a significant drop in accuracy (76.40% mAP), limiting its applicability. Other lightweight backbone networks, including ShuffleNetv2 (75.60% mAP, 89.10 FPS), EfficientNet (81.30% mAP, 75.94 FPS), MobileNetV3 (81.00% mAP, 72.45 FPS) and LeYOLO (81.30% mAP, 61.79 FPS), either have unsatisfactory accuracy or insufficient computational efficiency.

[0099] PP-LCNet achieves the best balance: compared to the original YOLOv8n, it reduces the model size by 45.9% (from 5.36MB to 2.90MB) and the number of parameters by 47.5% (from 2.68M to 1.41M), while retaining a mAP of 81.40% and achieving 98.14 FPS, only 2.35 FPS slower than the original model. By integrating PP-LCNet into YOLOv8n, a lightweight detector is implemented, significantly reducing storage and computational overhead while maintaining strong detection performance. Although accuracy is slightly reduced, the optimized model's efficiency meets the requirements of edge deployment. Therefore, this application selects PP-LCNet as the backbone network for YOLOv8n.

[0100] Table 2 Performance comparison of lightweight methods

[0101]

[0102] Furthermore, to improve the accuracy of livestock abdominal region detection, we evaluated the impact of integrating LSKblock layers with different scale processing layers (P3, P4, and P5) in the YOLOv8n neck architecture. These LSKblock layers were placed after different feature scales to enhance multi-scale feature representation by optimizing the attention mechanism. The comparative analysis in Table 3 shows that the P5 scale achieves higher detection accuracy, with mAP improvements of 4.7% and 2.2% over the P3 and P4 scales, respectively. This performance difference is likely due to the varying characteristics of network depth. The P5 feature scale inherently has a larger receptive field, which best matches the gradually expanding receptive field generated by the LSKblock layer. By implementing multi-level depthwise convolutions with increasing kernel size and dilation rate, the LSKblock layer effectively aggregates global contextual information, particularly facilitating the detection of large-scale objects. In contrast, shallow features at the P3 scale suffer from spatial scale mismatch when processed using the same kernel configuration, which affects detection accuracy.

[0103] Table 3 Evaluation index table of different insertion positions of LSKblock layer

[0104] .

[0105] In Table 3, A is after inserting the P3 ratio treatment layer; B is after inserting the P4 ratio treatment layer; C is after inserting the P5 ratio treatment layer.

[0106] To further investigate the decision-making principles for different insertion locations, this application used gradient-weighted class activation maps to generate heat activation maps, highlighting the areas that the model focused on when detecting the cow's abdomen. Figures 9-12 As shown, Figure 9 are four different test images. Figure 10 Insert the thermal activation map of the LSKblock layer after the P3 scale processing layer for different test images, Figure 11 Insert the thermal activation map of the LSKblock layer after the P4 scale processing layer for different test images, Figure 12The thermal activation maps of the LSKblock layer inserted after the P5 scale processing layer for different test images show that the activation map of the LSKblock layer inserted after the P5 scale processing layer clearly shows that the cow's abdomen area detection model accurately focuses on the cow's abdomen; in contrast, the activation map of the LSKblock layer inserted after the P3 scale processing layer shows obvious errors in feature extraction. The cow's abdomen area detection model focuses on irrelevant areas, resulting in misinterpretation of the cow's abdomen. Although the thermal map of the LSKblock layer inserted after the P4 scale processing layer is better than the activation map of the LSKblock layer inserted after the P3 scale processing layer, it still shows a somewhat fuzzy boundary range in the thermal map, and the activation area far exceeds the cow's abdomen, which indicates that the model's positioning of the abdomen is not accurate enough. This large inaccurate area reflects the model's difficulty in effectively dividing the object boundary, resulting in lower feature extraction accuracy than when the LSKblock layer is inserted after the P5 scale processing layer. Therefore, this application chooses to insert the LSKblock layer after the P5 scale processing layer as an improvement strategy.

[0107] Furthermore, this application used YOLOv8n as the baseline model and, in combination with the aforementioned improvement strategy, evaluated the effectiveness of the PP-LCNet backbone network and LSKblock layer in cow abdominal region detection, conducting ablation experiments. As shown in Table 4, replacing the original backbone network with PP-LCNet significantly optimized the model structure. The number of parameters was reduced to 1.41 million, a 47.5% reduction compared to the baseline. Computational efficiency was also significantly improved, with FLOPs reduced to 3.8G, a 44.1% reduction, and the model size compressed to 2.90MB. However, this resulted in a 1.7% decrease in mAP to 81.40%. Adding the LSKblock layer increased mAP to 85.30%, reflecting a 2.2% improvement over the baseline by enhancing contextual feature modeling. This improvement resulted in a slight increase in parameters, bringing the total to 2.8 million, a 4.3% increase over the baseline. The integration of PP-LCNet and LSKblock layers achieved an optimal balance between accuracy and computational efficiency. The combined model achieved an average accuracy of 83.90%, an improvement of 0.8% over the baseline model, while reducing the model size to 3.14MB, a 41.4% reduction over the baseline model. Furthermore, its inference speed reached 98.03 frames per second. The resulting improved YOLOv8n model structure is shown in the figure below. Figure 4 This approach combines lightweight design with context awareness, providing an effective solution for balancing computational complexity and detection accuracy, and is therefore suitable for deployment on mobile devices.

[0108] Table 4 Ablation test results of different improved modules

[0109]

[0110] In one embodiment, in step S2, the training process of the livestock abdomen region detection model specifically includes:

[0111] Step S21, constructing a training set; the training set includes: multiple sample images and corresponding real livestock abdominal area detection results; the sample image is an image containing a sample livestock, and the real livestock abdominal area detection result is a sample image with a real frame marked with the abdominal area of the sample livestock.

[0112] Step S22: construct an improved YOLOv8n model.

[0113] Step S23, taking the sample image as input and the sample image with the real frame of the abdominal area of the sample livestock as output, the improved YOLOv8n model is trained using the training set until the number of training times reaches the maximum or the loss function reaches the minimum, and the training is stopped to obtain the livestock abdominal area detection model.

[0114] Step S3: using a sparse optical flow method, based on the detection results of the target livestock abdomen region at two adjacent moments, determine the motion displacement of the livestock abdomen region.

[0115] In one embodiment, step S3 specifically includes:

[0116] In step S31, the Shi-Tomasi corner detection method is used to determine multiple key feature points in the target image of the prediction frame labeled with the abdominal region of the livestock to be tested at two adjacent moments. The key feature points in the target image of the prediction frame labeled with the abdominal region of the livestock to be tested at two adjacent moments remain unchanged. The relationship between the key feature points in the target image of the prediction frame labeled with the abdominal region of the livestock to be tested at two adjacent moments is shown in Equation (2):

[0117] (2)

[0118] in, is the coordinate in the image frame at time t t is the current time frame number (i.e. the frame number at the current moment); For pixels in The amount of displacement in the direction; For pixels in The amount of displacement in the direction; is the time point corresponding to the next frame image.

[0119] Step S32, using a sparse optical flow method, based on multiple key feature points in the target image of the prediction frame marked with the abdominal area of the livestock to be measured at two adjacent moments, determines the motion displacement of each key feature point, and uses the motion displacement of each key feature point as the motion displacement of the livestock's abdominal area.

[0120] Step S4: determining the livestock's breathing signal based on the movement displacement of the livestock's abdominal area.

[0121] In one embodiment, determining a respiratory signal of a livestock based on the movement displacement of the livestock's abdominal region specifically includes:

[0122] Step S41 : Calculate the motion direction angle of each key feature point based on the motion displacement of each key feature point.

[0123] Specifically, determine the motion direction of each key feature point: the output of the sparse optical flow algorithm is the motion displacement of each key feature point between two frames of images ( ) = ( ), the motion direction can be described by calculating the motion direction angle θ, and the formula is as follows:

[0124] (3)

[0125] Step S42: Convert the motion direction angle of each key feature point into a corresponding motion direction vector.

[0126] Specifically, the i The movement direction angle of the key feature points Convert to vector form (i.e. unit vector) for aggregation:

[0127] v i = (cos )(4)

[0128] in, v i For the i The motion direction vector of the key feature point; cos Indicates the i The component of the motion direction of the key feature point on the x-axis; Indicates the i The component of the motion direction of the key feature point on the y-axis.

[0129] Step S43 : performing weighted averaging on the motion direction vectors of all key feature points to obtain a corresponding average motion direction vector.

[0130] Specifically, aggregate the motion direction vector: perform weighted average of the motion direction vectors of all key feature points to obtain the average motion direction vector :

[0131] (5)

[0132] in, n is the total number of key feature points; is the average motion direction vector, is the average motion direction vector in x Components on the axis; is the average motion direction vector y Components on the axis.

[0133] Step S44: Determine the angle of the average motion direction based on the average motion direction vector. The calculation formula of the angle of the average motion direction is as follows:

[0134] (6)

[0135] In step S45 , a sine function is used to determine the livestock's breathing signal based on the angle of the average movement direction.

[0136] Specifically, a sine function is used to form a time series signal based on the average movement direction angle (the change of θ over time) to obtain the livestock's breathing signal.

[0137] The optical flow direction of each frame image is determined by the average optical flow direction (i.e., the average motion direction) of all pixels in the region of interest. The livestock breathing signal is obtained by applying the sin function to the average optical flow direction, with a value range of -1 to 1.

[0138] Step S5: determining the respiratory rate of the livestock based on the respiratory signal of the livestock, thereby achieving real-time monitoring of the respiratory rate of the livestock.

[0139] In one embodiment, in step S5, determining the respiratory rate of the livestock based on the respiratory signal of the livestock specifically includes:

[0140] Step S51 , preprocessing the livestock's respiratory signal to obtain a preprocessed livestock's respiratory signal; the preprocessed livestock's respiratory signal includes a plurality of respiratory cycles, each of which includes a respiratory signal trough and a respiratory signal peak. One respiratory cycle is one breath.

[0141] Taking a cow as an example, the time domain signal of the original respiratory signal (i.e. the cow's respiratory signal) is as follows: Figure 13 As shown, the amplitude spectrum of the original respiratory signal is as follows Figure 14 As shown, the time domain signal and amplitude spectrum of the preprocessed cow's respiratory signal are as follows: Figure 15 and Figure 16As shown in the figure, the peak value (i.e., the peak of the respiratory signal) and the valley value (i.e., the valley of the respiratory signal) in the cow's respiratory signal are key indicators for determining a complete respiratory cycle. The peak point is defined as the local maximum value, and the valley point is defined as the local minimum value. The appearance of the peak and valley value is related to the change of the slope sign.

[0142] Step S52, based on the time points corresponding to the two adjacent respiratory signal troughs in the pre-processed livestock respiratory signal, calculate the respiratory duration of the corresponding respiratory cycle. The calculation formula for the respiratory duration of any respiratory cycle is as follows:

[0143] (7)

[0144] in, For the j The duration of the respiratory cycle; For the j The time point corresponding to the trough of the respiratory signal; For the j+ The time point corresponding to a respiratory signal trough.

[0145] Step S53: Calculate the average breathing duration of each breathing cycle based on the breathing duration of each breathing cycle.

[0146] The average breathing duration in the jth breathing cycle for:

[0147] (8)

[0148] Where N represents the total number of respiratory signal peaks.

[0149] Step S54: Based on the average breathing duration in any breathing cycle, the respiratory rate in the corresponding breathing cycle is calculated to obtain the respiratory rate of the livestock. The calculation formula of the respiratory rate of the livestock is as follows:

[0150] (9)

[0151] in, RR is the respiratory rate.

[0152] Specifically, Figure 17-18 Table 5 compares the consistency between the measured values and the true values obtained by the livestock respiratory rate monitoring method proposed in this application. Figure 17 The regression curve in and the correlation coefficient of 0.97 in Table 5 confirm that there is a strong positive correlation and high consistency between the two methods. In addition, the mean absolute error (2.22) and root mean square error (2.70) are low, indicating that the predicted values are very close to the true values. Figure 18In the Bran-Altman plot shown, there are a few points that fall outside the 95% confidence interval, but their presence does not significantly affect the consistency of the overall measurement. These results indicate that this method can provide consistent and accurate respiratory rate measurements in most situations.

[0153] Table 5 Livestock respiratory rate estimation results of this application

[0154]

[0155] In one embodiment, step S51 specifically includes:

[0156] Step S511 , performing a fourth-order bandpass Butterworth filter on the livestock's respiratory signal to obtain a filtered livestock's respiratory signal.

[0157] Step S512: Perform Kalman filtering and smoothing on the filtered livestock breathing signal to obtain a pre-processed livestock breathing signal.

[0158] Specifically, a multi-stage filter combination is employed to effectively process the raw respiratory signal (i.e., the livestock's respiratory signal) and remove noise. First, the raw respiratory signal is filtered using a fourth-order bandpass Butterworth filter with a cutoff frequency range of 0.33Hz to 2Hz. This filter's cutoff frequency ensures the intended detection range is between 20bpm and 120bpm, effectively removing low-frequency noise and interference, such as artifacts caused by chronic movement or low-frequency drift. At the same time, it also preserves the primary frequency components of the cow's respiratory signal, thereby improving its accuracy and reliability. The filtered livestock respiratory signal is then smoothed using a Kalman filter to reduce random noise caused by sensor errors and environmental interference.

[0159] This application uses a bandpass fourth-order Butterworth filter with a frequency range of 0.33 Hz-2 Hz, combined with a Kalman filter to process the respiratory signals of stationary livestock. Figure 13-14 and Figure 15-16 The effectiveness of the multi-stage filter combination method is demonstrated by comparing the original respiratory signal and the preprocessed respiratory signal of a cow. Figure 13 and Figure 14 The original respiratory signal in contains irregular oscillations and noise, which masks the periodicity of breathing and makes it very difficult to accurately identify a single breath or calculate the respiratory cycle. After applying the bandpass Butterworth filter and Kalman filter, Figure 15 and Figure 16The preprocessed cow's breathing signal exhibits a smoother, more regular waveform in the time domain. The filtering process effectively suppresses high-frequency noise and low-frequency drift while preserving the core frequency components of the breathing signal. This is confirmed by the amplitude spectrum, which shows a dominant peak at 1.67Hz. This smoothing process is crucial for accurately identifying the duration of each breath because it improves the clarity of the peaks and valleys in the breathing signal.

[0160] On the other hand, livestock posture changes are a common factor that introduces noise and artifacts into respiratory signal acquisition, posing a challenge to accurate signal analysis. Taking dairy cows as an example, Figure 19-20 and Figure 21-22 The effects of cow posture changes on the cow's respiratory signal and the effects of applying filtering technology are shown. Figure 19 and Figure 21 The red shaded area highlights a section of erroneous optical flow data caused by pose changes. Figure 19 In the figure, the original breathing signal shows obvious noise in the red shaded area, which is mainly caused by the changes in the cow's posture. These movements introduce erroneous optical flow data, resulting in irregular oscillations and destroying the periodic breathing pattern. Figure 21 The preprocessed cow's respiratory signal shows significant improvement in both the time and frequency domains. After applying the bandpass Butterworth and Kalman filters, the noise in the red-shaded area is effectively suppressed, restoring the signal's smooth and periodic structure. The amplitude spectrum shows a significant reduction in high-frequency noise components, with a dominant peak at 1.39 Hz. This dominant frequency reflects the primary respiratory pattern, facilitating signal identification while minimizing the impact of motion artifacts.

[0161] 1) This application constructs a livestock abdominal region detection model based on the improved YOLOv8n model as the baseline model to identify the livestock abdominal region in the target image, thereby improving the accuracy of livestock respiratory rate monitoring.

[0162] 2) This application can obtain the livestock respiratory rate by inputting the target image into the livestock abdominal area detection model, thereby improving the efficiency and real-time performance of livestock respiratory rate monitoring.

[0163] 3) The system corresponding to this application can be deployed on a small, low-power mobile device (such as a mobile phone). The small mobile device is small in size, easy to carry, and can operate with low power consumption.

[0164] Based on the same inventive concept, embodiments of the present application also provide a livestock respiratory rate monitoring system for implementing the livestock respiratory rate monitoring method described above. The solution provided by this system is similar to the solution described in the method described above. Therefore, the specific limitations of one or more livestock respiratory rate monitoring system embodiments provided below can be found in the above-described limitations of the livestock respiratory rate monitoring method and will not be further elaborated here.

[0165] In an exemplary embodiment, a livestock respiratory rate monitoring system is provided, comprising:

[0166] The image acquisition unit is used to acquire target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested.

[0167] The livestock abdominal region detection result determination unit is used to input each target image into the livestock abdominal region detection model and output the corresponding livestock abdominal region detection result; the livestock abdominal region detection result is a target image marked with a prediction frame of the abdominal region of the livestock to be tested. The livestock abdominal region detection model is obtained by training the improved YOLOv8n model using the training set.

[0168] The motion displacement determining unit is used to determine the motion displacement of the livestock abdomen region based on the livestock abdomen region detection results of the target images at two adjacent moments by using a sparse optical flow method.

[0169] The breathing signal determination unit is used to determine the breathing signal of the livestock based on the movement displacement of the abdominal area of the livestock.

[0170] The respiratory rate determination unit is used to determine the respiratory rate of the livestock based on the respiratory signal of the livestock, thereby realizing real-time monitoring of the respiratory rate of the livestock.

[0171] Specifically, to deploy the improved YOLOv8n model on Android devices, the model must be converted from its original format PyTorch.pt to a format supported by the ncnn inference engine. This process includes several steps to ensure compatibility with mobile devices. First, export the improved YOLOv8n model from PyTorch to the Open Neural Network Exchange (ONNX) format. ONNX is a platform-independent model format that facilitates the transfer of models between different deep learning frameworks. Second, use the onnx2ncnn tool to convert the ONNX model to the native format of ncnn. The tool generates two files: one is a .param file containing the network structure, and the other is a .bin file that stores the model weights. These files are then integrated into the Android application and used for efficient inference using the ncnn engine.

[0172] This application was developed using Android Studio, which provides a comprehensive environment for building, testing, and deploying Android applications. The program includes the following steps: (1) Start the camera and load the model, determine and select the region of interest based on the real-time image (including the target image) transmitted by the camera, and then preprocess each target image (including grayscale processing to reduce the amount of calculation; noise reduction to enhance motion details; image enhancement to improve contrast and clarity, and image scaling and normalization to meet the input requirements of the improved YOLOv8n model); (2) Use the livestock abdominal region detection model to detect the livestock abdominal region and accurately identify the abdominal region. (3) Use the sparse optical flow algorithm to calculate the motion displacement between consecutive frames, extract periodic motion information, and derive the average optical flow angle based on the angular change of the displacement to extract the livestock's respiratory signal. (4) For the obtained livestock respiratory signal, apply Kalman filtering and Butterworth combined filter filtering to improve the stability and accuracy of the signal. (5) Calculate the livestock's respiratory rate based on the peak and trough of the respiratory signal to obtain the number of breaths per minute.

[0173] Furthermore, this application has developed an Android application for real-time detection of cow respiratory rate. The application size is 53.36MB, and the average frame rate when running on an Android device is about 20fps, which meets the requirements of real-time monitoring. Figure 23 As shown, the application interface displays a blue rectangle representing the predicted livestock abdomen area. Green dots represent key feature points. In the figure, "Respiratory rate" represents the respiratory rate, "Bpm" represents breaths per minute, "Standing_abdomina" represents the abdomen when standing, and "FPS" represents frames per second. The calculation results are displayed at the top of the interface.

[0174] In an exemplary embodiment, 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 a method for monitoring livestock respiration rate.

[0175] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, a method for monitoring the respiratory rate of livestock is implemented.

[0176] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 24As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and 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 computer program in the non-volatile storage medium. 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 monitoring the respiratory rate of livestock is implemented.

[0177] Those skilled in the art will understand that Figure 24 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0178] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0179] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. 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 above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application 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), magnetic 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. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0180] The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may include, but are not limited to, general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic units, data processing logic units based on quantum computing, and the like.

[0181] The technical features of the above embodiments can 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.

[0182] This document uses specific examples to illustrate the principles and implementation methods of this application. The description of the above examples is only intended to help understand the method, system, and core concept of this application. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of this application. In summary, the contents of this specification should not be construed as limiting this application.

Claims

1. A method for monitoring livestock respiratory rate, characterized in that: The livestock respiratory rate monitoring method comprises: Acquire target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested; The target images are respectively input into the livestock abdomen region detection model, and the corresponding target livestock abdomen region detection results are output; the target livestock abdomen region detection results are target images marked with a prediction box of the abdomen region of the livestock to be tested. The livestock abdomen region detection model is obtained by training the improved YOLOv8n model using the training set; The sparse optical flow method is used to determine the motion displacement of the target livestock abdomen based on the detection results of the target livestock abdomen at two adjacent moments. determining a respiratory signal of the livestock based on the movement displacement of the livestock's abdominal region; Based on the respiratory signals of livestock, the respiratory rate of livestock is determined, and the real-time monitoring of the respiratory rate of livestock is achieved; The improved YOLOv8n model includes: an improved backbone network, an improved neck network, and a head network; The improved backbone network includes a first convolutional layer, a first depth-separable convolutional layer, a second depth-separable convolutional layer, a third depth-separable convolutional layer, a fourth depth-separable convolutional layer, a fifth depth-separable convolutional layer, a sixth depth-separable convolutional layer, a seventh depth-separable convolutional layer, an eighth depth-separable convolutional layer and a ninth depth-separable convolutional layer, which are connected in sequence; The improved neck network includes a first upsampling layer, a first splicing layer, a first C2f layer, a second upsampling layer, a second splicing layer, a second C2f layer, a second convolutional layer, a third splicing layer, a third C2f layer, a third convolutional layer, a fourth splicing layer, a fourth C2f layer, and an LSKblock layer, which are connected in sequence; wherein the first upsampling layer is connected to the ninth depthwise separable convolutional layer, the first splicing layer, and the fourth splicing layer, respectively, the first splicing layer is also connected to the seventh depthwise separable convolutional layer, the first C2f layer is connected to the third splicing layer, and the first splicing layer is connected to the fifth depthwise separable convolutional layer; The head network includes: a first detection head, a second detection head, and a third detection head; wherein the first detection head is connected to the second C2f layer, the second detection head is connected to the third C2f layer, and the third detection head is connected to the LSKblock layer; Based on the movement displacement of the livestock's abdominal area, the livestock's respiratory signal is determined, specifically including: Based on the motion displacement of each key feature point, calculate the motion direction angle of the corresponding key feature point; Convert the motion direction angle of each key feature point into the corresponding motion direction vector; Perform weighted average of the motion direction vectors of all key feature points to obtain the corresponding average motion direction vector; determining an angle of an average motion direction based on the average motion direction vector; The breathing signal of livestock is determined based on the angle of the average movement direction using a sine function.

2. The livestock respiratory rate monitoring method according to claim 1, characterized in that: The training process of the livestock abdomen area detection model includes: Constructing a training set; the training set includes: multiple sample images and corresponding real livestock abdomen region detection results; the sample images are images containing sample livestock, and the real livestock abdomen region detection results are sample images with real frames marked with the sample livestock abdomen region; Build an improved YOLOv8n model; The improved YOLOv8n model is trained using the sample image as input and the sample image with the ground truth box of the abdominal area of the sample livestock as output. The training set is used until the number of training times reaches the maximum or the loss function reaches the minimum. The training is stopped to obtain the livestock abdominal area detection model.

3. The livestock respiratory rate monitoring method according to claim 1, wherein: The sparse optical flow method is used to determine the motion displacement of the livestock abdomen based on the detection results of the target livestock abdomen at two adjacent moments. Specifically, the following steps are performed: The Shi-Tomasi corner detection method is used to determine multiple key feature points in the target image of the prediction frame marked with the abdominal area of the livestock to be tested at two adjacent moments. The sparse optical flow method is used to determine the motion displacement of each key feature point based on multiple key feature points in the target image of the prediction frame marked with the abdominal area of the livestock to be tested at two adjacent moments, and the motion displacement of each key feature point is used as the motion displacement of the livestock's abdominal area.

4. The livestock respiratory rate monitoring method according to claim 1, wherein: Determine the respiratory rate of the livestock based on the livestock's respiratory signal, including: Preprocessing the livestock's respiratory signal to obtain a preprocessed livestock's respiratory signal; the preprocessed livestock's respiratory signal includes a plurality of respiratory cycles, each respiratory cycle including a respiratory signal trough and a respiratory signal peak; Calculating the respiratory duration of the corresponding respiratory cycle based on time points corresponding to two adjacent respiratory signal troughs in the preprocessed livestock respiratory signal; Based on the breathing duration of each breathing cycle, the average breathing duration of the corresponding breathing cycle is calculated; Based on the average breathing duration in any respiratory cycle, the respiratory rate in the corresponding respiratory cycle is calculated to obtain the respiratory rate of the livestock.

5. The livestock respiratory rate monitoring method according to claim 4, characterized in that: Preprocessing the livestock's respiratory signal to obtain a preprocessed livestock's respiratory signal specifically includes: Performing a fourth-order bandpass Butterworth filter on the livestock's respiratory signal to obtain a filtered livestock's respiratory signal; The filtered livestock respiratory signal is smoothed by Kalman filtering to obtain a preprocessed livestock respiratory signal.

6. A livestock respiratory rate monitoring system, characterized in that: The livestock respiratory rate monitoring system is used to implement the livestock respiratory rate monitoring method according to any one of claims 1 to 5, and the livestock respiratory rate monitoring system comprises: An image acquisition unit is used to acquire target images at two adjacent moments in real time; the target image is an image containing the livestock to be tested; a livestock abdomen region detection result determination unit, configured to input a target image into a livestock abdomen region detection model and output a corresponding target livestock abdomen region detection result; the target livestock abdomen region detection result is a target image annotated with a prediction frame of the abdomen region of the livestock to be tested; the livestock abdomen region detection model is obtained by training an improved YOLOv8n model using a training set; a motion displacement determining unit, configured to determine the motion displacement of the livestock abdomen region based on detection results of the target livestock abdomen region at two adjacent moments using a sparse optical flow method; a breathing signal determining unit, configured to determine a breathing signal of the livestock based on a movement displacement of an abdominal region of the livestock; The respiratory rate determination unit is used to determine the respiratory rate of the livestock based on the respiratory signal of the livestock, thereby realizing real-time monitoring of the respiratory rate of the livestock.

7. A computer device 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 the livestock respiratory rate monitoring method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the livestock respiratory rate monitoring method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Lightweight target detection method and system based on YOLOv8 improvement

    CN116740538A

  • Breathing mode detection method and device of deep learning neural network and controller

    CN118822947A