Sow delivery prediction method based on cloud-side cooperation
Through the cloud-edge collaborative framework, sow birth prediction algorithm is deployed on welfare-made delivery beds, and sow behavior analysis is performed using lightweight models and dynamic linear models, which solves the problem of large demand for computing resources in welfare-made delivery beds and easy sensor damage, and achieves efficient deployment and accuracy of sow birth prediction.
Patent Information
- Application Number
- CN202510634600.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-26
AI Technical Summary
It is difficult to effectively deploy sow birth prediction algorithms in welfare-based delivery beds, especially because of the high demand for computing and storage resources, and the wearable sensors are easily damaged by pigs, which affects sow welfare.
The cloud-edge collaboration framework is adopted, sow attitude detection and keyframe transmission are carried out at the edge through a lightweight target detection model, combined with the optical flow detection in the cloud to calculate the arch-ground behavior duration, and a dynamic linear model is used to predict sow delivery, realizing contactless monitoring and early warning.
It has achieved efficient deployment of sow birth prediction, reduced restrictions on sows, improved the accuracy and timeliness of birth prediction, and supported the intelligent development of welfare breeding.
Smart Images

Figure CN120544235A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of pig breeding technology, and specifically is a sow delivery prediction method using computer vision and cloud-edge collaborative technology. Background Art
[0002] Large-scale pig farms restrict sows' movement within farrowing crates to prevent them from crushing piglets, but this compromises sow welfare. To maximize sow welfare before and after farrowing, smart farrowing crates with short-term restrictions have emerged. These crates use cameras to detect the sow's nesting behavior within the crate, generating an early warning signal for farrowing and enabling timely closure.
[0003] Currently, wearable sensors are used to predict farrowing time in sows. Attaching wearable sensors to pigs is challenging because they tend to eat or tear them apart. With the development of computer vision technology, non-contact behavioral monitoring based on computer vision has gained attention. Changes in nesting behavior can be used to predict farrowing time, such as increased rooting duration, increased activity, changes in the proportion of standing postures, and the duration and frequency of posture transitions. However, analyzing nesting behavior using advanced technologies such as video analysis and optical flow calculations requires significant computing and storage resources, making it difficult to deploy this algorithm directly on the farrowing bed. Therefore, a cloud-edge collaborative sow farrowing prediction framework is proposed to enable practical deployment of pre-partum nesting behavior analysis and farrowing prediction in welfare farrowing beds. Summary of the Invention
[0004] (1) Technical issues to be solved
[0005] This patent aims to overcome the aforementioned issues by providing a sow farrowing prediction framework based on cloud-edge collaboration to enable practical deployment of pre-partum nesting behavior analysis and farrowing prediction in welfare farrowing beds. The technical issues to be addressed include: farrowing bed data collection and transmission; edge-side posture analysis and keyframe transmission; cloud-based ground-rooting behavior duration statistics; and edge-side integrated nesting behavior characteristics and farrowing prediction.
[0006] (2) Technical solution of the present invention
[0007] To solve the above problems, the present invention proposes a sow farrowing prediction method based on cloud-edge collaboration, the main process of which is as follows (S1 to S4):
[0008] S1. Install a camera about 4 meters above the ground and diagonally above the farrowing bed. Capture video footage from a side-viewing angle to ensure that the farrowing bed and the sows are fully captured.
[0009] S2. Sow posture detection and key frame transmission.
[0010] S2-1. Use a lightweight target detection model to detect key locations such as the sow's posture and head.
[0011] S2-2: When the distance of the sow's head movement is greater than the threshold and the sow is in a standing position, the frame and the subsequent 24 frames are transmitted to the cloud.
[0012] S3. Calculation of sow activity, standing posture ratio and rooting time under the cloud-edge collaborative framework.
[0013] S3-1. The edge calculates the sow's activity level using the Euclidean distance between key points in the sow's head detection frame. Using a sliding window method with a duration of 45 minutes and a step size of 15 minutes, the average of all displacement data within the sliding window is calculated to obtain the mean sow activity level.
[0014] S3-2: The edge side analyzes the posture detection results of each frame. A sliding window method with a duration of 45 minutes and a step size of 15 minutes is used to calculate the percentage of sows standing in that 45-minute period.
[0015] S3-3. Use the target detection algorithm and optical flow detection method deployed on the cloud server to identify ground arching behavior in the key frame sequence. The time period corresponding to the continuous key frame sequence with ground arching behavior is set to 1. Conversely, the time period without ground arching behavior is set to 0. The study uses a sliding window method with a duration of 45 minutes and a step size of 15 minutes to calculate the total duration of ground arching behavior within 45 minutes. This duration is the ground arching duration. After the end of the first 45-minute window, the calculation results are returned to the edge computing platform every 15 minutes for delivery warning.
[0016] S4. Use a dynamic linear model to predict sow farrowing time. The farrowing warning algorithm receives activity volume and standing posture percentage data calculated by the edge computing platform and ground-rooting duration data calculated by the cloud server. It combines this time series data with a dynamic linear model to perform a detailed analysis to provide sow farrowing warnings. The dynamic linear model integrates and analyzes behavioral data every 15 minutes, including data trends and periodicity. The model uses trend components to calculate the trend of the predicted value. When the trend of the predicted value obtained from the model exceeds a pre-set threshold, it indicates that the sow may be about to farrow. These thresholds are determined based on analysis of historical behavioral data of individual sows, and are intended to provide timely farrowing warnings to sows.
[0017] Preferably, the observation equation and system equation of the dynamic linear model are expressed as follows:
[0018] y t =F t θ t +v t ,v t ~N(0,Vt )
[0019] θ t =G t θ t-1 +w t ,w t ~N(0,W t )
[0020] In the prediction of sow farrowing time before farrowing, y t represents the activity amount, standing posture ratio and arching behavior duration at time t, θ t represents the potential hidden state at time t, and represents the trend and structure of the evolution of activity volume, stance ratio, and duration of arching behavior over time (such as behavioral periodicity, long-term trend, etc.); v t and w t They are independent Gaussian noises with variances v t and w t ; F is the observation matrix; G t is the state transition matrix, which describes the time evolution of the state.
[0021] Beneficial effects of the present invention
[0022] This invention provides a sow farrowing prediction method based on cloud-edge collaboration. Through the cloud-edge collaboration framework, a sow farrowing warning algorithm is deployed on a welfare farrowing bed. Non-contact monitoring of the sow's status allows the bed to be closed for short-term position limiting. This provides technical support for the implementation of welfare-oriented sow farming and has broad application prospects in the field of intelligent livestock farming technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is the overall flow chart of the sow farrowing prediction method based on cloud-edge collaboration of the present invention.
[0024] Figure 2 is the posture detection result.
[0025] Figure 3 is the time series of sow activity.
[0026] Figure 4 is the time series of the proportion of sows standing.
[0027] Figure 5 It is a long time series of sows digging the ground.
[0028] Figure 6 This is a chart showing the sow farrowing prediction results. DETAILED DESCRIPTION
[0029] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the technical solutions therein are clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. In an embodiment of the present invention, a sow delivery prediction method based on cloud-edge collaboration is provided. The method deploys the sow delivery warning algorithm on the welfare delivery bed through the cloud-edge collaboration framework, and closes the delivery bed through non-contact monitoring of the sow status to achieve short-term limit. The overall flow chart is as follows Figure 1 As shown, it mainly includes the following steps (S1 to S4):
[0030] S1. Install a camera about 4 meters above the ground and diagonally above the farrowing bed. Capture video footage from a side-viewing angle to ensure that the farrowing bed and the sows are fully captured.
[0031] S2. Sow posture detection and key frame transmission.
[0032] S2-1, Use the lightweight target detection model YOLOv5n to detect key positions such as the sow's posture and head. The detection results are as follows Figure 2 shown.
[0033] S2-2: When the distance of the sow's head movement is greater than the threshold and the sow is in a standing position, the frame and the subsequent 24 frames are transmitted to the cloud.
[0034] S3. Calculation of sow activity, standing posture ratio and rooting time under the cloud-edge collaborative framework.
[0035] S3-1. At the edge, calculate the sow's activity level using the Euclidean distance of key points in the sow's head detection frame. Using a sliding window with a 45-minute window length and a 15-minute step length, calculate the average of all displacement data within the sliding window to obtain the mean sow activity level.
[0036] The activity level is calculated by calculating the distance the center of the sow's head moves in the first frame of each second for two consecutive seconds. The calculation formula for the distance the center of the head moves is as follows:
[0037]
[0038] Where d(p,q) represents the Euclidean distance between point p and point q, the Cartesian coordinates of point p are (p1,p2), and the Cartesian coordinates of point q are (q1,q2). Point p and point q are the center points of the sow head detection frame in the first frame of each second for two consecutive seconds. This study uses a sliding window method with a length of 45 minutes and a step length of 15 minutes to slide on the data sequence of the moving distance of the sow's head center point. The mean activity value of the sow is obtained by calculating the average value of all displacement data in the sliding window. The activity time series is as follows Figure 3 shown.
[0039] S3-2, the edge end is realized by analyzing the posture detection results of each frame. In the sow standing posture sequence, 1 represents the sow in a standing posture, and 0 represents the sow in other postures (side lying, prone lying and sitting). The sliding window method with a length of 45 minutes and a step length of 15 minutes is also used to calculate the proportion of sows maintaining a standing posture in all postures within 45 minutes, and then the standing posture ratio is obtained. The standing posture ratio time series is as follows Figure 4 shown.
[0040] S3-3. Use the target detection algorithm and optical flow detection method deployed on the cloud server to identify the ground arching behavior in the key frame sequence. The time period corresponding to the continuous key frame sequence with ground arching behavior is set to 1. Conversely, the time period without ground arching behavior is set to 0. In the study, a sliding window method with a length of 45 minutes and a step size of 15 minutes was used to count the total time of ground arching behavior within 45 minutes, which is the ground arching duration. After the end of the first 45-minute window, the settlement results will be returned to the edge computing platform every 15 minutes for delivery warning. The long time series of ground arching time is as follows Figure 5 shown.
[0041] S4. Predicting sow farrowing time using a dynamic linear model.
[0042] Dynamic linear models are a state-space-based time series analysis method that allows for sequential state updates, making them well-suited for online learning or real-time forecasting. This framework consists of observation equations and system equations. The system equations describe the temporal evolution of the underlying states, while the observation equations specify how observations are generated from these latent states.
[0043] The observation equation and system equation are expressed as follows:
[0044] y t =F t θ t +v t ,v t ~N(0,V t )
[0045] θ t =Gt θ t-1 +w t ,w t ~N(0,W t )
[0046] Among them, y t represents the observed value at time t; F t is the observation matrix; θ t represents the potential state vector; v t and w t They are independent Gaussian noises with variances v t and w t ; G t is the state transition matrix, which describes the time evolution of the state. In the prediction of sow farrowing time before delivery, y t represents the activity amount, standing posture ratio and arching behavior duration at time t, θ t Represents the potential hidden state at time t, which includes trend and periodic components in addition to activity volume, standing posture ratio and arching behavior duration. When calculating, first, based on the hidden state θ at time t-1, t-1 Combined state transfer matrix G t and error correction term w t Predict the hidden state θ at the next moment t ,θ t Combined with the observation matrix and the error correction term v t Predict the observed values at time t, namely the activity level, percentage of standing postures, and duration of rooting behavior at that time. The sum of these three features yields a time series of farrowing characteristics. When the trend of the predicted value exceeds a set threshold, it indicates that the sow is about to farrow.
[0047] The farrowing warning algorithm receives the activity volume and standing posture ratio data calculated by the edge computing platform, as well as the ground arching time data calculated by the cloud server, and combines it with the dynamic linear model to conduct a detailed analysis of these time series data to achieve sow farrowing warning. The dynamic linear model conducts an integrated analysis of the behavioral data every 15 minutes, including the changing trend and periodicity of the data. The model uses the trend component to calculate the changing trend of the predicted value. When the changing trend of the predicted value obtained from the model exceeds the pre-set threshold, it indicates that the sow may be about to give birth. These thresholds are determined based on the analysis of the historical behavioral data of individual sows, and are intended to issue timely farrowing warnings to sows. The diagram of the farrowing warning is as follows Figure 6 shown.
[0048] The specific embodiments described herein are merely illustrative of the spirit of the present invention. Persons skilled in the art may make various modifications, additions, or substitutions to the described specific embodiments without departing from the spirit of the present invention or exceeding the scope of the appended claims.
Claims
1. A sow farrowing prediction method based on cloud-edge collaboration, characterized by The following steps are involved: S1. Install a camera on the farrowing bed and capture video from a side-view perspective to ensure that the farrowing bed and the sow are fully captured. S2, sow posture detection and key frame transmission; S3. Calculation of sow activity, standing posture ratio, and rooting time under the cloud-edge collaborative framework; S4. Use a dynamic linear model to predict the sow's farrowing time. The farrowing warning algorithm receives the activity volume and standing posture ratio data calculated by the edge computing platform and the ground arching time data calculated by the cloud server, and combines these time series data with the dynamic linear model to perform detailed analysis to achieve sow farrowing warning.
2. The method according to claim 1, characterized in that In step S1, relevant cloud-edge collaborative algorithms are deployed in the delivery bed.
3. The method according to claim 1, characterized in that In step S2, the target detection method is used to select key frames and transmit them to the cloud, which specifically includes: S2-1. Use a lightweight target detection model to detect the sow’s posture and key head positions; S2-2: When the distance of the sow's head movement is greater than the threshold and the sow is in a standing position, the frame and the subsequent 24 frames are transmitted to the cloud.
4. The method according to claim 1, characterized in that Step S3 specifically includes: S3-1. The edge end calculates the sow's activity level through the Euclidean distance of the key points of the sow's head detection frame, and calculates the mean activity level of the sow; S3-2: The edge end calculates the percentage of sows standing in the 45-minute period by analyzing the posture detection results of each frame; S3-3. Use the target detection algorithm and optical flow detection method deployed on the cloud server to identify the arching behavior and arching duration in the key frame sequence.
5. The method according to claim 4, characterized in that In S3-1, a sliding window method with a duration of 45 minutes and a step size of 15 minutes was used to calculate the average value of all displacement data in the sliding window to obtain the mean activity value of the sow.
6. The method according to claim 4, characterized in that In S3-2, a sliding window method with a duration of 45 minutes and a step size of 15 minutes is used to calculate the proportion of sows standing within 45 minutes.
7. The method according to claim 4, characterized in that In S3-3, the time period corresponding to the continuous key frame sequence with arching behavior is set to 1; the time period without arching behavior is set to 0; a sliding window method with a duration of 45 minutes and a step size of 15 minutes is used to calculate the total duration of arching behavior within 45 minutes as the arching duration.
8. The method according to claim 7, characterized in that After the first 45-minute window ends, the calculation results are returned to the edge computing platform every 15 minutes for delivery warning.
9. The method according to claim 1, characterized in that The dynamic linear model performs an integrated analysis of behavioral data every 15 minutes, including the changing trends and periodicity of the data. The model uses trend components to calculate the changing trends of the predicted values. When the changing trends of the predicted values obtained from the model exceed the pre-set threshold, it indicates that the sow may be about to give birth.
10. The method according to claim 1, characterized in that The observation equation and system equation of the dynamic linear model are expressed as follows: y t =F t θ t +v t ,v t ~N(0,V t ) i t =G t i t-1 +w t ,w t ~N(0,W t ) In the prediction of sow farrowing time before farrowing, y t represents the activity amount, standing posture ratio and arching behavior duration at time t, θ t represents the potential hidden state at time t, and represents the trend and structure of the activity volume, stance ratio, and arching behavior duration over time; v t and w t They are independent Gaussian noises with variances v t and w t ; F t is the observation matrix; G t is the state transition matrix, which describes the time evolution of the state.
Citation Information
Cited By
Sow delivery prediction method using vulva physiological time sequence characterization and prototype correction
CN121661056A
