Livestock respiratory rate monitoring method, system, equipment and medium

Through the improved YOLOv8n model and sparse optical flow method, real-time monitoring of livestock respiration rates is solved, and the traditional method is time-consuming and labor-consuming and monitoring is not real-time, achieving efficient and accurate respiration rate detection.

CN120323955AActive Publication Date: 2025-07-18ZHEJIANG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing methods of livestock breathing rate monitoring are time-consuming and labor-intensive, with limited monitoring frequency, making it difficult to achieve real-time tracking, and cannot provide immediate feedback, and cannot detect early signs of the disease in a timely manner.

Method used

The improved YOLOv8n model is used to detect the abdominal area of domestic animals in real time, and the motion displacement is determined in combination with the sparse optical flow method. By calculating the respiratory signal and respiration rate, real-time monitoring of domestic animals is achieved.

Benefits of technology

It improves the accuracy and real-time performance of livestock respiration rate monitoring, is suitable for low-power mobile devices, and is suitable for resource-constrained deployment scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120323955A_ABST
    Figure CN120323955A_ABST
Patent Text Reader

Abstract

The invention discloses a livestock respiration rate monitoring method, system and device and a medium, and relates to the technical field of breeding, and the method comprises the steps: obtaining target images of two adjacent moments in real time; respectively 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 by adopting a training set; adopting a sparse optical flow method to determine the motion displacement of the abdomen area of the livestock based on the detection results of the abdomen area of the target livestock at two adjacent moments; determining a respiratory signal of the livestock based on the movement displacement of the abdominal region of the livestock; based on the respiratory signal of the livestock, the respiratory rate of the livestock is determined, and the respiratory rate of the livestock is monitored in real time. The accuracy and the real-time performance of livestock respiration rate monitoring are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of breeding technology, and in particular to a method, system, device and medium for monitoring the respiratory rate of livestock. Background Art

[0002] The respiratory rate of livestock is an important indicator to measure the health status of livestock. An excessively high or low respiratory rate may indicate that the livestock has diseases, stress reactions or other health problems. Therefore, timely and accurate monitoring of the respiratory rate of livestock is of great significance for improving breeding efficiency, ensuring animal welfare and preventing diseases.

[0003] Currently, traditional monitoring methods have some limitations. For example, many traditional livestock respiratory rate monitoring methods rely on manual inspections or manual devices, usually requiring regular inspections, and the process is cumbersome. These methods not only consume time and effort, but also have limited monitoring frequencies, making it difficult to achieve real-time tracking of the health status of livestock and may miss early signs of diseases.

[0004] In addition, many monitoring systems cannot provide instant feedback, and the data needs to be processed and analyzed for a period of time, which is not ideal for scenarios that require quick responses (such as disease early warnings, etc.).

[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 method, system, device and medium for monitoring the respiratory rate of livestock, so as to improve the accuracy and real-time performance of livestock respiratory rate monitoring.

[0007] To achieve the above purpose, this application provides the following solutions: In the first aspect, this application provides a method for monitoring the respiratory rate of livestock, and the method for monitoring the respiratory rate of livestock includes: Real-time acquisition of target images at two adjacent moments; the target image is an image containing the livestock to be measured; Input the target images at two adjacent moments into the livestock abdominal area detection model respectively, and output the corresponding detection results of the target livestock abdominal area; the detection result of the target livestock abdominal area is a target image with a prediction box marked with the abdominal area of the livestock to be measured, and the livestock abdominal area detection model is obtained by training the improved YOLOv8n model with a training set; Using the sparse optical flow method, based on the detection results of the target livestock abdominal area at two adjacent moments, determine the movement displacement of the livestock abdominal area; Based on the movement displacement of the livestock abdominal area, determine the respiratory signal of the livestock; Based on the respiratory signal of the livestock, determine the respiratory rate of the livestock, and realize real-time monitoring of the respiratory rate of the livestock.

[0008] In one embodiment, 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 depthwise separable convolutional layer, a second depthwise separable convolutional layer, a third depthwise separable convolutional layer, a fourth depthwise separable convolutional layer, a fifth depthwise separable convolutional layer, a sixth depthwise separable convolutional layer, a seventh depthwise separable convolutional layer, an eighth depthwise separable convolutional layer, and a ninth depthwise separable convolutional layer connected in sequence; The improved neck network includes a first upsampling layer, a first concatenation layer, a first C2f layer, a second upsampling layer, a second concatenation layer, a second C2f layer, a second convolutional layer, a third concatenation layer, a third C2f layer, a third convolutional layer, a fourth concatenation layer, a fourth C2f layer, and an LSKblock layer; wherein, the first upsampling layer is respectively connected to the ninth depthwise separable convolutional layer, the first concatenation layer, and the fourth concatenation layer, the first concatenation layer is further connected to the seventh depthwise separable convolutional layer, the first C2f layer is connected to the third concatenation layer, and the first concatenation 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.

[0009] In one embodiment, the training process of the livestock abdominal area detection model specifically includes: Construct a training set; the training set includes: multiple sample images and corresponding true livestock abdominal area detection results; the sample images are images containing sample livestock, and the true livestock abdominal area detection results are sample images marked with true boxes of the abdominal areas of the sample livestock; Construct an improved YOLOv8n model; Using the sample images as input and the sample images marked with true boxes of the abdominal areas of the sample livestock as output, train the improved YOLOv8n model using the training set until the number of training times reaches the maximum value or the loss function reaches the minimum value, then stop training to obtain the livestock abdominal area detection model.

[0010] In one embodiment, using the sparse optical flow method, based on the livestock abdominal area detection results at two adjacent times, determine the movement displacement of the livestock abdominal area, specifically including: Adopt the Shi-Tomasi corner detection method to respectively determine multiple key feature points in the target images of the prediction boxes of the abdominal areas of the livestock to be measured marked at two adjacent times; Using the sparse optical flow method, based on multiple key feature points in the target images of the prediction boxes that label the abdominal regions of the livestock to be measured at two adjacent times, determine the motion displacements of each key feature point, and use the motion displacements of each key feature point as the motion displacement of the abdominal region of the livestock.

[0011] In one embodiment, based on the motion displacement of the abdominal region of the livestock, determine the respiration signal of the livestock, specifically including: Based on the motion displacements of each key feature point, calculate the motion direction angles of the corresponding key feature points; Convert the motion direction angles of each key feature point into corresponding motion direction vectors; Perform weighted averaging on the motion direction vectors of all key feature points to obtain the corresponding average motion direction vector; Based on the average motion direction vector, determine the angle of the average motion direction; Use the sine function to determine the respiration signal of the livestock based on the angle of the average motion direction.

[0012] In one embodiment, based on the respiration signal of the livestock, determine the respiration rate of the livestock, specifically including: Preprocess the respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock; the preprocessed respiration signal of the livestock includes multiple respiration cycles, and each respiration cycle includes a respiration signal trough and a respiration signal peak; Based on the time points corresponding to two adjacent respiration signal troughs in the preprocessed respiration signal of the livestock, calculate the respiration duration of the corresponding respiration cycle; Based on the respiration durations of each respiration cycle, calculate the average respiration duration corresponding to the respiration cycle; Based on the average respiration duration in any respiration cycle, calculate the respiration rate corresponding to the respiration cycle, thereby obtaining the respiration rate of the livestock.

[0013] In one embodiment, preprocess the respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock, specifically including: Perform fourth-order band-pass Butterworth filtering on the respiration signal of the livestock to obtain the filtered respiration signal of the livestock; Perform Kalman filter smoothing on the filtered respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock.

[0014] In a second aspect, the present application provides a livestock respiration rate monitoring system, which is used to implement the livestock respiration rate monitoring method described above. The livestock respiration rate monitoring system includes: An image acquisition unit, configured to acquire target images at two adjacent times in real time; the target image is an image containing the livestock to be measured; A livestock abdominal area detection result determination unit, which is used to input a target image into a livestock abdominal area detection model respectively and output a corresponding target livestock abdominal area detection result; the target livestock abdominal area detection result is a target image with a prediction box marking the abdominal area of the livestock to be measured, and the livestock abdominal area detection model is obtained by training an improved YOLOv8n model using a training set; A motion displacement determination unit, which is used to use the sparse optical flow method, based on the target livestock abdominal area detection results at two adjacent times, to determine the motion displacement of the livestock abdominal area; A respiration signal determination unit, which is used to determine the respiration signal of the livestock based on the motion displacement of the livestock abdominal area; A respiration rate determination unit, which is used to determine the respiration rate of the livestock based on the respiration signal of the livestock, so as to realize real-time monitoring of the respiration rate of the livestock.

[0015] In a third aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the livestock respiration rate monitoring method described in any one of the above.

[0016] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the livestock respiration rate monitoring method described in any one of the above.

[0017] According to the specific embodiments provided by the present application, the present application has the following technical effects: The present application discloses a livestock respiration rate monitoring method, system, device and medium. By constructing a livestock abdominal area detection model with an improved YOLOv8n model as the benchmark model, and identifying the livestock abdominal area from the target image through the livestock abdominal area detection model, the accuracy of livestock respiration rate monitoring is improved; at the same time, by inputting the target image into the livestock abdominal area detection model, the livestock respiration rate can be obtained, which improves the efficiency and real-time performance of livestock respiration rate monitoring. Description of the Drawings

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0019] Figure 1 It is a schematic flow chart of the livestock respiration rate monitoring method provided by an embodiment of the present application; Figure 2Schematic diagram of the target image provided by an embodiment of the present application; Figure 3 Schematic diagram of the statistical results of the video clip sample provided by an embodiment of the present application; Figure 4 Schematic diagram of the improved YOLOv8n model structure provided by an embodiment of the present application; Figure 5 Schematic diagram of the structure of the convolutional layer provided by an embodiment of the present application; Figure 6 Schematic diagram of the structure of the C2f layer provided by an embodiment of the present application; Figure 7 Schematic diagram of the structure of the Bottleneck layer provided by an embodiment of the present application; Figure 8 Schematic diagram of the structure of the detection head provided by an embodiment of the present application; Figure 9 Schematic diagram of four different test images provided by an embodiment of the present application; Figure 10 Schematic diagram of the thermal activation of inserting the LSKblock layer after the P3 ratio processing layer for different test images provided by an embodiment of the present application; Figure 11 Schematic diagram of the thermal activation of inserting the LSKblock layer after the P4 ratio processing layer for different test images provided by an embodiment of the present application; Figure 12 Schematic diagram of the thermal activation of inserting the LSKblock layer after the P5 ratio processing layer for different test images provided by an embodiment of the present application; Figure 13 Schematic diagram of the time-domain signal of the original respiratory signal provided by an embodiment of the present application; Figure 14 Schematic diagram of the amplitude spectrum of the original respiratory signal provided by an embodiment of the present application; Figure 15 Schematic diagram of the time-domain signal of the preprocessed respiratory signal of cows provided by an embodiment of the present application; Figure 16 Schematic diagram of the amplitude spectrum of the preprocessed respiratory signal of cows provided by an embodiment of the present application; Figure 17 Schematic diagram of the regression analysis between the predicted value and the true value of the livestock respiratory rate provided by an embodiment of the present application; Figure 18 Schematic diagram of Bland-Altman provided by an embodiment of the present application; Figure 19 Schematic diagram of the influence of the cow posture change on the time-domain signal of the original respiratory signal provided by an embodiment of the present application; Figure 20 Schematic diagram of the influence of the posture change of dairy cows on the amplitude spectrum of the original respiratory signal provided by an embodiment of the present application; Figure 21 Schematic diagram of the influence of the posture change of dairy cows on the time-domain signal of the preprocessed respiratory signal of dairy cows provided by an embodiment of the present application; Figure 22 Schematic diagram of the influence of the posture change of dairy cows on the amplitude spectrum of the preprocessed respiratory signal of dairy cows provided by an embodiment of the present application; Figure 23 Schematic diagram of the application program running interface provided by an embodiment of the present application; Figure 24 Schematic diagram of the structure of a computer device provided by an embodiment of the present application.

[0020] Reference numerals: Improved backbone network - 1, improved neck network - 2, head network - 3. Detailed implementation manners

[0021] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0022] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.

[0023] In an exemplary embodiment, as Figure 1 shown, a livestock respiratory rate monitoring method is provided. This method is executed by a computer device, and specifically, it can be executed alone by a computer device such as a terminal or a server, or jointly executed by a terminal and a server. In the embodiments of the present application, this method is described by taking it as an example applied to a server, and includes the following steps. Wherein: Step S1, obtain target images at two adjacent moments in real time; the target images are images containing livestock to be measured.

[0024] Specifically, when the livestock to be measured is a dairy cow, this embodiment will be described taking the dairy cow as an example. The research object is 20 lactating dairy cows. A mobile phone with a camera resolution of 1920×1080 @ 30 fps is used for video recording. The mobile phone is placed at the rear side of the dairy cow, and the distance between the mobile phone and the dairy cow is about 1 meter to 1.5 meters. 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 dairy cow. A total of 300 video clips are recorded. As Figure 2 shown, each video clip includes multiple target images, and the statistical results of the video clip samples are as Figure 3 shown. The fluctuation of the dairy cow's abdomen is defined as a complete breathing cycle. The number of consecutive breaths in each video is calculated and converted into the breathing rate per minute according to the breathing duration, as shown in formula (1). According to this standard, three observers manually counted the breathing rates of 300 videos, and the reliability among the observers was evaluated using Pearson correlation, and the result was 0.93 - 0.99 (indicating that the data of manual counting is reliable).

[0025] (1) Step S2: Input the target images into the livestock abdominal area detection model respectively, and output the corresponding detection results of the target livestock abdominal area; the detection results of the target livestock abdominal area are target images with prediction boxes marked with the abdominal areas of the livestock to be measured. The livestock abdominal area detection model is obtained by training the improved YOLOv8n model with a training set.

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

[0027] The improved backbone network (i.e., Backbone) is PP-LCNet, which includes a first convolutional layer, a first depthwise separable convolutional layer, a second depthwise separable convolutional layer, a third depthwise separable convolutional layer, a fourth depthwise separable convolutional layer, a fifth depthwise separable convolutional layer, a sixth depthwise separable convolutional layer, a seventh depthwise separable convolutional layer, an eighth depthwise separable convolutional layer, and a ninth depthwise separable convolutional layer connected in sequence.

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

[0029] The Head network includes: a first detection head, a second detection head, and a third detection head (all represented by detection heads in Figure 4 ); among them, 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.

[0030] 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. As Figure 5 shown, the first convolutional layer, the second convolutional layer, and the third convolutional layer all include: a two-dimensional convolutional layer, a batch normalization layer, and a SiLU layer (i.e., a SiLU activation function layer).

[0031] 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. As Figure 6 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 concatenation layer, and a convolutional layer. The structure of the bottleneck layer is as Figure 7 shown.

[0032] The structures of the first detection head, the second detection head, and the third detection head are the same, and are all represented by detection heads. As Figure 8 shown, the first detection head, the second detection head, and the third detection head all include two parallel branches. The first branch includes two convolutional layers, a two-dimensional convolutional layer, and a class classification loss layer. The second branch includes: two convolutional layers, a two-dimensional convolutional layer, and a bounding box regression loss layer.

[0033] Among them, the role of the Backbone is to extract the basic features of the image. The backbone of YOLOv8 consists of multiple layers. Layer 0: The first convolutional layer, which takes the target image as input, performs convolution on the input image with a convolution kernel size of 3×3, a stride of 2, and a padding of 1. Through this operation, the size of the feature map is halved, and the number of output channels is 16. Layer 1: The first depthwise separable convolutional layer, which takes the 16-channel feature map from Layer 0 as input, performs convolution on each channel, and then uses pointwise convolution for fusion between channels. The convolution kernel is 3×3, the stride is 1, and the number of output channels is 32. Layer 2: The second depthwise separable convolutional layer, which takes the 32-channel feature map from Layer 1 as input, with a convolution kernel of 3×3, a stride of 2, and an output channel number of 64. Layer 3: The third depthwise separable convolutional layer, which takes the 64-channel feature map from Layer 2 as input, with a convolution kernel of 3×3, a stride of 1, and the number of output channels remaining 64. Layer 4: The fourth depthwise separable convolutional layer, which takes the 64-channel feature map from Layer 3 as input, with a convolution kernel of 3×3, a stride of 2, and an output channel number of 128. Layer 5: The fifth depthwise separable convolutional layer, which takes the 128-channel feature map from Layer 4 as input, with a convolution kernel of 3×3, a stride of 1, and an output channel number of 128. Layer 6: The sixth depthwise separable convolutional layer, which takes the 128-channel feature map from Layer 5 as input, with a convolution kernel of 3×3, a stride of 2, and an output channel number of 256. Layer 7: The seventh depthwise separable convolutional layer, which takes the 256-channel feature map from Layer 6 as input, with a convolution kernel of 5×5, a stride of 1, and an output channel number of 256. Layer 8: The eighth depthwise separable convolutional layer, which takes the 256-channel feature map from Layer 7 as input, with a convolution kernel of 5×5, a stride of 2, and an output channel number of 512. Layer 9: The ninth depthwise separable convolutional layer, which takes the 512-channel feature map from Layer 8 as input, with a convolution kernel of 5×5, a stride of 1, and an output channel number of 512.

[0034] The main task of the Neck part is to process the feature maps from the Backbone and fuse the features from different layers for better object detection (detection of the livestock abdominal area). Layer 10: The first upsampling layer, input: a 512-channel feature map from Layer 9. The size of the feature map is doubled through the upsampling operation using the nearest neighbor interpolation method, and the output number of channels is 512. Layer 11: The first concatenation layer, input: a 512-channel feature map from Layer 10 and a 256-channel feature map from Layer 7. These two feature maps are concatenated in the channel dimension, and the output number of channels is 768. Layer 12: The first C2f layer, input: a 768-channel feature map from Layer 11. The C2f layer performs deep feature fusion and adopts the CSP structure to enhance feature representation, and the output number of channels is 512. Layer 13: The second upsampling layer, input: a 512-channel feature map from Layer 12, and the output number of channels is 512. Layer 14: The second concatenation layer, input: a 512-channel feature map from Layer 13 and a 128-channel feature map from Layer 5, and the output number of channels is 640. Layer 15: The second C2f layer, input: a 640-channel feature map from Layer 14, and the output number of channels is 256. Layer 16: The second convolutional layer, with a convolutional kernel size of 3×3 and a stride of 2, and the output number of channels is 256. Layer 17: The third concatenation layer, input: a 256-channel feature map from Layer 16 and a 512-channel feature map from Layer 12, and the output number of channels is 768. Layer 18: The third C2f layer, input: a 768-channel feature map from Layer 17, and the output number of channels is 512. Layer 19: The third convolutional layer, input: a 512-channel feature map from Layer 18, with a convolutional kernel size of 3×3 and a stride of 2, and the output number of channels is 512. Layer 20: The fourth concatenation layer, input: a 512-channel feature map from Layer 19 and a 512-channel feature map from Layer 9, and the output number of channels is 1024. Layer 21: The fourth C2f layer, input: a 1024-channel feature map from Layer 20, and the output number of channels is 1024. Layer 22: The LSKblock layer, input: a 1024-channel feature map from Layer 21. The LSKblock layer applies large kernel convolution and spatial selection mechanisms to enhance the ability of feature representation, further strengthening the feature information of the attention area, and the output number of channels is 1024.

[0035] The Head part is mainly used to perform livestock abdominal area detection on the multi-scale feature maps obtained from the Neck part. Input: Feature maps from Layers 15, 18, and 22. Through the detection head, object detection is carried out to generate an image, category, and confidence with the bounding boxes of the livestock abdominal area. Finally, the bounding boxes, category information, and confidence of the livestock abdominal area are output. Among them, during model training, the bounding boxes are ground truth boxes, and during prediction, the bounding boxes are predicted boxes.

[0036] Specifically, to select the optimal lightweight object detection model (i.e., the livestock abdominal area 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, FLOP, and model size. As shown in Table 1, it can be seen that the performance of YOLOv8n is better than that of all other models, with the highest mAP reaching 83.10% and the fastest inference speed reaching 100.49 FPS. In contrast, the performance of RT-DETR-l is lower, with an mAP of 76.70% and a much slower inference speed of only 34.1 FPS, mainly due to its large number of parameters (31.99M) and high computational cost (103.40 GFLOPs).

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

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

[0039] Table 1 Performance comparison of different base models in the livestock abdominal area detection task

[0040] Furthermore, to further optimize the YOLOv8n baseline model, comparative experiments were conducted by 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 huge computational cost (5.20 GFLOPs) and a slow inference speed (54.30 FPS), making it unsuitable for edge deployment; although FasterNet had the fastest inference speed (100.15 FPS) and the smallest model size (2.93 MB), its accuracy dropped significantly (76.40% mAP), limiting its applicability. Other lightweight backbones, 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 had unsatisfactory accuracy or insufficient computational efficiency.

[0041] PP-LCNet achieved the best balance: compared with the original YOLOv8n, it reduced the model size by 45.9% (from 5.36 MB to 2.90 MB) and the parameters by 47.5% (from 2.68 M to 1.41 M), while retaining 81.40% of the mAP and achieving 98.14 FPS, only 2.35 FPS slower than the original model. By integrating PP-LCNet into YOLOv8n, a lightweight detector was achieved, greatly reducing the storage and computational overhead while maintaining strong detection performance. Although the accuracy decreased slightly, the efficiency of the optimized model met the requirements of edge deployment. Therefore, this application selected PP-LCNet as the backbone network of YOLOv8n.

[0042] Table 2 Performance comparison table of lightweight methods

[0043] Furthermore, to improve the accuracy of livestock abdominal region detection, the impact of integrating the LSKblock layer into different scale processing layers (P3, P4, P5) in the neck structure of YOLOv8n was evaluated. 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 detection accuracy of the P5 scale is higher, with the mAP increasing by 4.7% and 2.2% compared to the P3 and P4 scales respectively. This performance difference may be due to the different characteristics of the network depth. The P5 feature scale itself has a large receptive field, which is most matched with the gradually expanding receptive field generated by the LSKblock layer. Through multi-level depth convolution that increases the kernel size and dilation rate, the LSKblock layer can effectively aggregate global context information, which is particularly beneficial for the detection of large-scale objects. In contrast, the shallow features of the P3 scale encounter problems of spatial scale mismatch when processed with the same kernel configuration, thus affecting the detection accuracy.

[0044] Table 3 Evaluation Index Table for Different Insertion Positions of the LSKblock Layer 。

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

[0046] To further study the decision principle of different insertion positions, this application uses gradient-weighted class activation mapping to generate heat activation maps, highlighting the areas that the model focuses on when detecting the abdominal region of cows. As Figures 9 - 12 shown, Figure 9 are four different test images, Figure 10 is the heat activation map of different test images with the LSKblock layer inserted after the P3 ratio processing layer, Figure 11 is the heat activation map of different test images with the LSKblock layer inserted after the P4 ratio processing layer, Figure 12The heat activation maps of inserting the LSKblock layer after the P5 ratio processing layer for different test images are shown. It can be seen that the activation map of inserting the LSKblock layer after the P5 ratio processing layer clearly shows that the cow abdominal area detection model accurately focuses on the abdomen of the cow; in contrast, the activation map of inserting the LSKblock layer after the P3 ratio processing layer shows obvious errors in feature extraction, and the cow abdominal area detection model focuses on irrelevant areas, resulting in misreading of the cow's abdomen. Although the heat map of inserting the LSKblock layer after the P4 ratio processing layer is better than the activation map of inserting the LSKblock layer after the P3 ratio processing layer, there are still some blurred boundary ranges shown in the heat map, and the activation area far exceeds the abdomen of the cow, which indicates that the model's positioning of the abdomen is not precise enough. This relatively large imprecise area reflects the difficulty of the model in effectively dividing the object boundary, resulting in lower accuracy of feature extraction than inserting the LSKblock layer after the P5 ratio processing layer. Therefore, this application selects to insert the LSKblock layer after the P5 ratio processing layer as the improvement strategy.

[0047] Furthermore, this application uses YOLOv8n as the baseline model and combines the above improvement strategy to evaluate the effects of the PP-LCNet backbone network and the LSKblock layer in cow abdominal area detection and conducts ablation experiments. As shown in Table 4, replacing the original backbone network with PP-LCNet greatly optimizes the model structure. The number of parameters is reduced to 1.41 million, a decrease of 47.5% compared with the baseline. The computational efficiency is also significantly improved, with FLOPs dropping to 3.8G, a reduction of 44.1%, and the model size is compressed to 2.90MB. However, this results in a 1.7% reduction in mAP, reaching 81.40%. After adding the LSKblock layer, mAP increases to 85.30%, indicating that through enhanced context feature modeling, mAP is increased by 2.2% compared with the baseline value. This improvement brings a slight increase in parameters, increasing the total number of parameters to 2.8 million, a 4.3% increase compared with the baseline parameters. The integration of PP-LCNet and the LSKblock layer achieves the best balance between accuracy and computational efficiency. The average precision of the combined model reaches 83.90%, an increase of 0.8% compared with the baseline model, while the model size is reduced to 3.14MB, a 41.4% reduction compared with the baseline model. In addition, its inference speed is as high as 98.03 frames per second, and the improved YOLOv8n model structure diagram is as Figure 4 shown. This method 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.

[0048] Table 4 Ablation experiment results of different improvement modules

[0049] In one embodiment, in step S2, the training process of the livestock abdominal area detection model specifically includes: Step S21, constructing a training set; the training set includes: multiple sample images and corresponding true livestock abdominal area detection results; the sample images are images containing sample livestock, and the true livestock abdominal area detection results are sample images with true boxes marked with the abdominal areas of the sample livestock.

[0050] Step S22, constructing an improved YOLOv8n model.

[0051] Step S23, using the sample images as inputs and the sample images with true boxes marked with the abdominal areas of the sample livestock as outputs, training the improved YOLOv8n model with the training set until the number of training times reaches the maximum value or the loss function reaches the minimum value, then stopping the training to obtain the livestock abdominal area detection model.

[0052] Step S3, using the sparse optical flow method, based on the livestock abdominal area detection results at two adjacent times, determining the movement displacement of the livestock abdominal area.

[0053] In one embodiment, step S3 specifically includes: Step S31, using the Shi-Tomasi corner detection method to respectively determine multiple key feature points in the target images of the prediction boxes marked with the abdominal areas of the livestock to be measured at two adjacent times. In the target images of the prediction boxes marked with the abdominal areas of the livestock to be measured at two adjacent times, the key feature points remain unchanged, and the relationship of the key feature points in the target images of the prediction boxes marked with the abdominal areas of the livestock to be measured at two adjacent times is shown in Equation (2): (2) Wherein, is the pixel intensity value at the coordinate in the image frame at time t; t is the current time frame serial number (i.e., the frame serial number of the current time); is the displacement amount of the pixel in the direction; is the displacement amount of the pixel in the direction; is the time point corresponding to the next frame of image.

[0054] Step S32, using the sparse optical flow method, based on the multiple key feature points in the target images of the prediction boxes marked with the abdominal areas of the livestock to be measured at two adjacent times, determining the movement displacements of the key feature points, and taking the movement displacements of the key feature points as the movement displacement of the livestock abdominal area.

[0055] Step S4, based on the movement displacement of the livestock abdominal area, determining the respiration signal of the livestock.

[0056] In one embodiment, based on the movement displacement of the abdominal region of livestock, the respiratory signal of the livestock is determined, which specifically includes: Step S41: Calculate the movement direction angle of the corresponding key feature point based on the movement displacement of each key feature point.

[0057] Specifically, determine the movement direction of each key feature point: The output of the sparse optical flow algorithm is the movement displacement of each key feature point between two frames of images ( ) = ( ). The movement direction can be described by calculating the movement direction angle θ, and its formula is as follows: (3) Step S42: Convert the movement direction angles of each key feature point into corresponding movement direction vectors.

[0058] Specifically, convert the movement direction angle i of the -th key feature point into vector form (i.e., unit vector) for aggregation: v i = (cos ) (4) Wherein, v i is the movement direction vector of the i -th key feature point; cos represents the component of the movement direction of the i -th key feature point on the x-axis; represents the component of the movement direction of the i -th key feature point on the y-axis.

[0059] Step S43: Perform weighted averaging on the movement direction vectors of all key feature points to obtain the corresponding average movement direction vector.

[0060] Specifically, aggregate the movement direction vectors: Perform weighted averaging on the movement direction vectors of all key feature points to obtain the average movement direction vector : (5) Wherein, n is the total number of key feature points; is the average movement direction vector, is the component of the average movement direction vector on the x -axis; is the component of the average movement direction vector on the y -axis.

[0061] Step S44: Determine the angle of the average motion direction based on the average motion direction vector. The calculation formula for the angle of the average motion direction is as follows: (6) Step S45: Use the sine function to determine the respiration signal of the livestock based on the angle of the average motion direction.

[0062] Specifically, use the sine function to form a time series signal according to the change of the average motion direction angle (θ over time) to obtain the respiration signal of the livestock.

[0063] Among them, the optical flow direction of each frame of image is determined by the average optical flow direction (i.e., the average motion direction) of all pixels in the region of interest. The respiration signal of the livestock is obtained by applying the sin function to the average optical flow direction, and the value range is from -1 to 1.

[0064] Step S5: Determine the respiration rate of the livestock based on the respiration signal of the livestock to achieve real-time monitoring of the respiration rate of the livestock.

[0065] In an embodiment, in step S5, to determine the respiration rate of the livestock based on the respiration signal of the livestock, it specifically includes: Step S51: Preprocess the respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock; the preprocessed respiration signal of the livestock includes multiple respiration cycles, and each respiration cycle includes a respiration signal trough and a respiration signal peak. One respiration cycle is one breath.

[0066] Among them, taking dairy cows as an example, the time-domain signal of the original respiration signal (i.e., the respiration signal of dairy cows) is as Figure 13 shown, the amplitude spectrum of the original respiration signal is as Figure 14 shown, the time-domain signal and amplitude spectrum of the preprocessed respiration signal of dairy cows are respectively as Figure 15 and Figure 16 shown. The peak value (i.e., the respiration signal peak) and valley value (i.e., the respiration signal trough) in the respiration signal of dairy cows are the key indicators to determine a complete respiration cycle. The peak point is defined as the local maximum value, and the valley point is defined as the local minimum value. The occurrence of the peak value and valley value is related to the change of the slope sign.

[0067] Step S52: Calculate the respiration duration of the corresponding respiration cycle based on the time points corresponding to two adjacent respiration signal troughs in the preprocessed respiration signal of the livestock. The calculation formula for the respiration duration of any respiration cycle is as follows: (7) Among them, is the respiration duration of the j th respiration cycle; is thej The time point corresponding to the valley of a breathing signal wave is the j+ time point corresponding to the valley of the 1st breathing signal wave

[0068] Step S53: Calculate the average breathing duration for the corresponding breathing cycle based on the breathing duration of each breathing cycle

[0069] The average breathing duration for the jth breathing cycle is: (8) where N represents the total number of peaks of the breathing signal

[0070] Step S54: Calculate the breathing rate for the corresponding breathing cycle based on the average breathing duration for any breathing cycle, so as to obtain the breathing rate of the livestock. The calculation formula for the breathing rate of the livestock is as follows (9) where RR is the breathing rate

[0071] Specifically Figures 17 - 18 Table 5 compares the consistency between the measured values and the true values obtained by the livestock breathing rate monitoring method proposed in this application Figure 17 The regression curve in Figure 18 and the correlation coefficient of 0.97 in Table 5 confirm a strong positive correlation and a high degree of consistency between the two methods. In addition, the mean absolute error (2.22) and the root mean square error (2.70) are low, indicating that the predicted values are very close to the true values. Although in the Bland - Altman plot shown in

[0072] Table 5 Results table of livestock breathing rate estimation in this application

[0073] In one embodiment, step S51 specifically includes Step S511: Perform a fourth - order band - pass Butterworth filter on the breathing signal of the livestock to obtain the filtered breathing signal of the livestock

[0074] Step S512: Perform a Kalman filter smoothing on the filtered breathing signal of the livestock to obtain the pre - processed breathing signal of the livestock

[0075] Specifically, to effectively process the original respiratory signal (i.e., the respiratory signal of livestock) and remove noise, a multi-stage filter combination is adopted. First, the original respiratory signal is filtered using a fourth-order band-pass Butterworth filter with a cut-off frequency range of 0.33 Hz to 2 Hz; the cut-off frequency of this filter ensures that the expected detection range is between 20 bpm and 120 bpm, effectively removing low-frequency noise and interference, such as spurious signals caused by chronic motion or low-frequency drift. At the same time, it also retains the main frequency components of the dairy cow's respiratory signal, thus improving the accuracy and reliability of the dairy cow's respiratory signal. Then, a Kalman filter is used to smooth the filtered respiratory signal of livestock, reducing random noise caused by sensor errors and environmental interference.

[0076] This application uses a band-pass fourth-order Butterworth filter with a frequency range of 0.33 Hz - 2 Hz and combines it with a Kalman filter to process the respiratory signal of stationary livestock. Figures 13 - 14 and Figures 15 - 16 By comparing the original respiratory signal and the preprocessed respiratory signal of dairy cows, the effectiveness of the multi-stage filter combination method is demonstrated. Figure 13 and Figure 14 The original respiratory signal in [relevant figure] contains irregular oscillations and noise, masking the periodicity of breathing and making it very difficult to accurately identify a single breath or calculate the respiratory cycle. After applying the band-pass Butterworth filter and the Kalman filter, Figure 15 and Figure 16 the preprocessed respiratory signal of dairy cows in [relevant figure] presents a smoother and more regular waveform in the time domain. The filtering process effectively suppresses high-frequency noise and low-frequency drift while retaining the core frequency components of the respiratory signal, as confirmed by the amplitude spectrum, which shows a main peak at 1.67 Hz. This smoothing is crucial for accurately identifying the duration of each breath as it improves the clarity of the peak and valley of the respiratory signal.

[0077] On the other hand, livestock posture changes are a common factor introducing noise and artifacts in respiratory signal acquisition, posing challenges to accurate signal analysis. Taking dairy cows as an example, Figures 19 - 20 and Figures 21 - 22 show the impact of dairy cow posture changes on the respiratory signal of dairy cows and the effect of applying filtering techniques, Figure 19 and Figure 21 The red shaded area in [relevant figure] highlights a segment of incorrect optical flow data caused by posture changes. In [relevant figure], the original respiratory signal shows obvious noise in the red shaded area, mainly due to the posture changes of dairy cows. These movements introduce incorrect optical flow data, resulting in irregular oscillations and disrupting the periodic breathing pattern. In contrast, Figure 19 Figure 21 ​The respiratory signal of the dairy cow after preprocessing is significantly improved in both the time domain and the frequency domain. After applying the band-pass Butterworth filter and the Kalman filter, the noise in the red shaded area is effectively suppressed, restoring the smooth and periodic structure of the signal. The amplitude spectrum shows that the high-frequency noise components are significantly reduced, and the main peak is located at 1.39 Hz. This dominant frequency reflects the main respiratory pattern, which helps to identify the respiratory signal and minimize the influence of motion-induced artifacts at the same time.

[0078] 1) In this application, a livestock abdominal area detection model is constructed based on the improved YOLOv8n model as the benchmark model to identify the livestock abdominal area in the target image, improving the accuracy of livestock respiratory rate monitoring.

[0079] 2) In this application, the livestock respiratory rate can be obtained by inputting the target image into the livestock abdominal area detection model, improving the efficiency and real-time performance of livestock respiratory rate monitoring.

[0080] 3) The system corresponding to this application can be deployed on low-power small mobile devices (such as mobile phones). The small mobile devices are small in size, convenient to carry, and can operate with low power consumption.

[0081] Based on the same inventive concept, the embodiment of this application also provides a livestock respiratory rate monitoring system for implementing the livestock respiratory rate monitoring method involved above. The implementation solutions provided by this system to solve problems are similar to the implementation solutions recorded in the above method. Therefore, the specific limitations in one or more embodiments of the livestock respiratory rate monitoring system provided below can refer to the limitations on the livestock respiratory rate monitoring method in the above text and will not be repeated here.

[0082] In an exemplary embodiment, a livestock respiratory rate monitoring system is provided, including: An image acquisition unit for real-time acquisition of target images at two adjacent times; the target image is an image containing the livestock to be measured.

[0083] A livestock abdominal area detection result determination unit for respectively inputting each target image into the livestock abdominal area detection model and outputting the corresponding livestock abdominal area detection result; the livestock abdominal area detection result is a target image with a prediction box marking the abdominal area of the livestock to be measured, and the livestock abdominal area detection model is obtained by training the improved YOLOv8n model with a training set.

[0084] A motion displacement determination unit for using the sparse optical flow method to determine the motion displacement of the livestock abdominal area based on the livestock abdominal area detection results of the target images at two adjacent times.

[0085] A respiratory signal determination unit for determining the respiratory signal of the livestock based on the motion displacement of the livestock abdominal area.

[0086] A respiration rate determination unit, which is used to determine the respiration rate of livestock based on the respiration signal of the livestock, so as to realize the real-time monitoring of the respiration rate of livestock.

[0087] Specifically, to deploy the improved YOLOv8n model on an Android device, the model must be converted from its original format PyTorch.pt to a format supported by the ncnn inference engine. This process involves 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. This tool generates two files: one is a.param file containing the network structure, and the other is a.bin file storing the model weights. Then integrate these files into the Android application and use the ncnn engine for efficient inference.

[0088] This application is 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 according to the real-time images (including target images) 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 scaling and normalizing the image to meet the input requirements of the improved YOLOv8n model); (2) Use the livestock abdominal area detection model to detect the abdominal area of the livestock and accurately identify the abdominal area. (3) Adopt the sparse optical flow algorithm to calculate the motion displacement between consecutive frames, extract the periodic motion information, and obtain the average optical flow angle according to the angular change of the displacement, so as to extract the respiration signal of the livestock. (4) For the obtained respiration signal of the livestock, apply a combined filter of Kalman filter and Butterworth filter for filtering to improve the stability and accuracy of the signal. (5) Calculate the respiration rate of the livestock based on the respiration signal peaks and respiration signal valleys to obtain the number of breaths per minute.

[0089] Furthermore, this application has developed an Android application for real-time detection of the respiration frequency of dairy cows. The size of the application is 53.36MB, and the average frame rate when running on an Android device is about 20fps, meeting the requirements of real-time monitoring. As Figure 23As shown, the application running interface displays a blue rectangle, representing the predicted abdominal area of livestock, and green dots represent key feature points. Respiratory rate in the figure indicates the respiratory rate, Bpm indicates beats per minute, Standing_abdomina indicates the abdomen when standing, and FPS indicates frames per second. The calculation results are displayed at the top of the interface.

[0090] In an exemplary embodiment, a computer device is provided, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement a method for monitoring the respiratory rate of livestock.

[0091] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, it implements a method for monitoring the respiratory rate of livestock.

[0092] In an exemplary embodiment, a computer device is provided. The computer device can be a server or a terminal, and its internal structure diagram can be as Figure 24 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a method for monitoring the respiratory rate of livestock.

[0093] Those skilled in the art can understand that Figure 24 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0094] 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 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 need to comply with relevant regulations.

[0095] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing 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 embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0096] The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0097] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, 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, it should be considered as the scope described in this specification.

[0098] In this article, specific examples are used to elaborate on the principles and implementation manners of the present application. The descriptions of the above embodiments are only used to help understand the method, system and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A method for monitoring the respiratory rate of livestock, characterized in that, The livestock respiration rate monitoring method includes: Obtaining target images at two adjacent moments in real time; the target images are images containing the livestock to be measured; Inputting the target images into the livestock abdominal area detection model respectively, and outputting the corresponding detection results of the target livestock abdominal area; the detection results of the target livestock abdominal area are target images with prediction frames marked with the abdominal areas of the livestock to be measured, and the livestock abdominal area detection model is obtained by training the improved YOLOv8n model with a training set; Using the sparse optical flow method, based on the detection results of the target livestock abdominal area at two adjacent moments, determining the movement displacement of the livestock abdominal area; Based on the movement displacement of the livestock abdominal area, determining the respiration signal of the livestock; Based on the respiration signal of the livestock, determining the respiration rate of the livestock, and realizing the real-time monitoring of the livestock respiration rate.

2. The livestock respiration rate monitoring method according to claim 1, characterized in that 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 depthwise separable convolutional layer, a second depthwise separable convolutional layer, a third depthwise separable convolutional layer, a fourth depthwise separable convolutional layer, a fifth depthwise separable convolutional layer, a sixth depthwise separable convolutional layer, a seventh depthwise separable convolutional layer, an eighth depthwise separable convolutional layer and a ninth depthwise separable convolutional layer 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; among them, 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; among them, 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.

3. The livestock respiration rate monitoring method according to claim 2, characterized in that, The training process of the livestock abdominal area detection model specifically includes: Constructing a training set; the training set includes: multiple sample images and corresponding real detection results of the livestock abdominal area; the sample images are images containing sample livestock, and the real detection results of the livestock abdominal area are sample images with real boxes marked with the abdominal areas of the sample livestock; Constructing an improved YOLOv8n model; Using the training set to train the improved YOLOv8n model with the sample images as the input and the sample images with real boxes marked with the abdominal areas of the sample livestock as the output until the number of training times reaches the maximum value or the loss function reaches the minimum value, then stopping the training to obtain the livestock abdominal area detection model.

4. The livestock respiration rate monitoring method according to claim 1, characterized in that, Using the sparse optical flow method, based on the detection results of the target livestock abdominal area at two adjacent moments, determining the movement displacement of the livestock abdominal area, specifically including: Using the Shi-Tomasi corner detection method, determine multiple key feature points in the target images of the prediction boxes of the abdominal regions of the livestock to be measured marked at two adjacent times respectively; Using the sparse optical flow method, based on multiple key feature points in the target images of the prediction boxes of the abdominal regions of the livestock to be measured marked at two adjacent times, determine the motion displacements of each key feature point, and use the motion displacements of each key feature point as the motion displacement of the abdominal region of the livestock.

5. The livestock respiration rate monitoring method according to claim 1, characterized in that, Based on the motion displacement of the abdominal region of the livestock, determine the respiration signal of the livestock, specifically including: Based on the motion displacements of each key feature point, calculate the motion direction angles of the corresponding key feature points; Convert the motion direction angles of each key feature point into corresponding motion direction vectors; Perform weighted averaging on the motion direction vectors of all key feature points to obtain the corresponding average motion direction vector; Based on the average motion direction vector, determine the angle of the average motion direction; Use the sine function to determine the respiration signal of the livestock based on the angle of the average motion direction.

6. The livestock respiration rate monitoring method according to claim 1, wherein Based on the respiration signal of the livestock, determine the respiration rate of the livestock, specifically including: Preprocess the respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock; the preprocessed respiration signal of the livestock includes multiple respiration cycles, and each respiration cycle includes a respiration signal trough and a respiration signal peak; Based on the time points corresponding to two adjacent respiration signal troughs in the preprocessed respiration signal of the livestock, calculate the respiration duration of the corresponding respiration cycle; Based on the respiration durations of each respiration cycle, calculate the average respiration duration corresponding to the corresponding respiration cycle; Based on the average respiration duration of any respiration cycle, calculate the respiration rate corresponding to the corresponding respiration cycle, thereby obtaining the respiration rate of the livestock.

7. The livestock respiration rate monitoring method according to claim 1, characterized in that, Preprocess the respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock, specifically including: Perform fourth-order band-pass Butterworth filtering on the respiration signal of the livestock to obtain the filtered respiration signal of the livestock; Perform Kalman filter smoothing on the filtered respiration signal of the livestock to obtain the preprocessed respiration signal of the livestock.

8. A livestock respiratory rate monitoring system, characterized in that, The livestock respiration rate monitoring system is used to implement the livestock respiration rate monitoring method according to any one of claims 1-7, and the livestock respiration rate monitoring system includes: An image acquisition unit for real-time acquiring target images at two adjacent times; the target image is an image containing the livestock to be measured; A livestock abdominal region detection result determination unit for respectively inputting the target image into the livestock abdominal region detection model and outputting the corresponding target livestock abdominal region detection result; the target livestock abdominal region detection result is the target image of the prediction box of the abdominal region of the livestock to be measured marked, and the livestock abdominal region detection model is obtained by training the improved YOLOv8n model using a training set; A motion displacement determination unit for using the sparse optical flow method to determine the motion displacement of the abdominal region of the livestock based on the target livestock abdominal region detection results at two adjacent times; A respiration signal determination unit for determining the respiration signal of the livestock based on the motion displacement of the abdominal region of the livestock; A respiration rate determination unit, configured to determine the respiration rate of livestock based on the respiration signal of the livestock, so as to achieve real-time monitoring of the respiration rate of the livestock.

9. A computer device, comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the livestock respiration rate monitoring method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the livestock respiration rate monitoring method according to any one of claims 1-7.

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

  • Ship target intelligent detection method, equipment and medium

    CN119006778A

  • Measurement method, computer program product, measurement system, and recording medium

    CN119992585A

  • Method and device for detection of sleep apnea

    WO2024263131A1