A sow estrus intelligent prediction method and system based on time sequence behavior analysis

CN122804709APending Publication Date: 2026-09-25CHENGDU BINGKE AGRICULTURAL TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611268570.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

[0008]本申请提供一种基于时序行为分析的母猪发情智能预测方法及系统,旨在解决现有技术姿态解算无法兼顾动态响应与静态稳定性、缺乏对发情相关微动作与长时生理节律的双重建模能力,以及多模态融合策略固定导致个体适应性差、预测准确率低、预警提前量不足的问题

Benefits of technology

[0040]本申请设计基于虚拟角速度反馈的闭环修正机制(PI控制器),将陀螺仪漂移速率降低,同时滤除磁场畸变尖峰,能够清晰分辨发情前期的耳根颤动等高频微小姿态变化,为早期预测提供高灵敏度特征。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122804709A_ABST
    Figure CN122804709A_ABST
Patent Text Reader

Abstract

The application discloses a sow estrus intelligent prediction method and system based on time sequence behavior analysis, and the method comprises the following steps: S1, multi-source time sequence data synchronous acquisition; S2, inertial data fusion and accurate attitude solution; S3, behavior time sequence data preprocessing and event segmentation; S4, construction of double-flow time sequence behavior feature network; S5, multi-head attention mechanism fusion and estrus prediction. The application realizes early, accurate and personalized prediction of sow estrus, especially early estrus, by organically integrating data acquisition, attitude solution, behavior segmentation, double-flow feature extraction, adaptive fusion, early warning decision and system architecture into a complete technical solution. The system can output the best mating time window in advance, reduce the non-production days of sows, improve the annual production of piglets and breeding efficiency, and has outstanding substantial progress and industrial application value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of intelligent farming technology, specifically relating to an intelligent prediction method and system for sow estrus based on time-series behavior analysis. Background Technology

[0002] In recent years, large-scale pig farming has increasingly demanded accurate identification of sows' estrus and timely mating. Traditional manual estrus detection relies on experience-based observation (such as standing reflex and vulvar redness and swelling), which is labor-intensive, subjective, and prone to missing the optimal mating opportunity.

[0003] Existing sensor-based automation methods have significant shortcomings:

[0004] The posture calculation accuracy is low. Sows exhibit dynamic behaviors such as rapid head shaking and rubbing in their daily lives, as well as static behaviors such as lying down for a long time. Traditional complementary filtering or Kalman filtering either produces gyroscope integral drift or causes instantaneous jumps due to magnetic field distortion, making it difficult to extract the micro-movement features with small amplitude and high frequency in the proestrus stage.

[0005] The lack of multi-timescale modeling means that pre-estrus micro-movements require high-resolution analysis with short time windows, while body temperature and activity rhythms require observation with long time windows, which a single model cannot take into account.

[0006] With a fixed multimodal fusion strategy, the dominant modalities of different sows during estrus vary (postural micro-movements or body temperature changes), and fixed weighted fusion cannot adapt to individual differences and cyclical changes.

[0007] Therefore, how to achieve robust pose calculation, dual-stream feature network construction, and adaptive multimodal fusion in both static and dynamic scenarios is a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0008] This application provides a method and system for intelligent prediction of sow estrus based on time-series behavior analysis, aiming to solve the problems of existing technology's posture calculation being unable to take into account both dynamic response and static stability, lacking dual modeling ability for estrus-related micro-movements and long-term physiological rhythms, and the fixed multimodal fusion strategy leading to poor individual adaptability, low prediction accuracy, and insufficient early warning lead time.

[0009] Firstly, a method for intelligent prediction of sow estrus based on temporal behavior analysis, the method comprising:

[0010] S1: Multi-source time-series data synchronous acquisition: Multi-source time-series data is continuously and synchronously acquired through an intelligent detection terminal worn on the sow's ear. The multi-source time-series data includes nine-axis inertial sensing data, body temperature data, and audio data.

[0011] S2: Inertial data fusion and precise attitude calculation: The nine-axis inertial sensing data is fused and calculated to obtain an attitude angle sequence that can characterize the sow's head and neck swing and direction changes, specifically including:

[0012] S2.1 Obtaining the first attitude quaternion based on calibration data from the accelerometer and magnetometer ;

[0013] S2.2 Update the second attitude quaternion based on the angular velocity data output by the gyroscope. ;

[0014] S2.3 Calculate the second attitude quaternion With the first attitude quaternion The error quaternion between And construct a virtual angular velocity vector based on the axis-angle form of the error quaternion. ,in For the error angle, The unit vector of the rotation axis. This is the proportionality coefficient;

[0015] S2.4, the virtual angular velocity vector Superimposed on the measured angular velocity of the gyroscope A corrected angular velocity is generated, and a closed-loop correction is performed based on the corrected angular velocity to obtain the final attitude angle sequence. ;

[0016] S3: Behavioral timing data preprocessing and event segmentation, for the attitude angle sequence The body temperature data and audio data collected simultaneously are preprocessed, and active behavioral segments are segmented from them;

[0017] S4: Construct a dual-stream temporal behavior feature network to process the active behavior segments, and extract short-term micro-motion feature vectors through the parallel first and second branches respectively. With long-term behavioral rhythm feature vector The first branch is used to process high-frequency inertial data in a short time window, and the second branch is used to process low-frequency physiological data in a long time window.

[0018] S5: Multi-head attention mechanism fusion and estrus prediction, which integrates the short-term micro-motion feature vectors With the long-term behavioral rhythm feature vector The two modal tokens are input into a multi-head attention layer for adaptive fusion, resulting in a fused feature vector. And based on the fused feature vector Output the estrus probability and the optimal mating time window.

[0019] Optionally, in S1, the synchronous acquisition of multi-source time-series data includes: triggering the reading operations of all sensors in the same hardware timer interrupt, and attaching a global timestamp based on a real-time clock to each acquisition record to form a continuous multi-source time-series data stream with strict time alignment.

[0020] Optionally, S3 specifically includes:

[0021] S3.1. Use a sliding median filter to remove single-point jump outliers from the body temperature data, use a median filter to smooth the integral overshoot caused by severe ear shaking from the posture angle sequence, and pre-emphasize and extract Mel frequency cepstral coefficients (MFCC) features from the audio data.

[0022] S3.2, Based on attitude angle variation index Using the short-time audio energy E(t), a dual-threshold finite state automaton is employed to segment active segments from the continuous data stream and remove low-information intervals that are lying still.

[0023] Optionally, the first branch in S4 is a short-term micro-motion feature extraction network, whose input is a continuous 30-second window of data truncated with the active behavior segment as the center and extended 15 seconds before and after it. The window data includes the attitude angle sequence and the raw values ​​of the three-axis acceleration.

[0024] The first branch is composed of multiple stacked one-dimensional convolutional layers and outputs the short-term micro-action feature vector. .

[0025] Optionally, the second branch in S4 is a long-term behavioral rhythm feature extraction network with an input time span of 6 hours and input features including a corrected temperature sequence, cumulative activity level, and vocalization frequency.

[0026] The second branch is constructed using a multi-layer bidirectional gated recurrent unit and outputs the long-term behavioral rhythm feature vector. .

[0027] Optionally, S5 specifically includes:

[0028] S5.1, the feature vector and Constructed as a sequence input The attention weights between the two modalities are calculated using a multi-head attention mechanism, and the attention-enhanced representations are added element-wise to obtain the final fused features. ;

[0029] S5.2, The fusion feature The data is fed into a fully connected network, and the Softmax function outputs the probability distributions corresponding to the proestrus, peak estrus, and non-estrus phases. ;

[0030] S5.3. The early warning is triggered by a dual mechanism based on single-point threshold early warning and time-series pattern early warning, and the optimal mating time window is output by using the kernel density estimation method.

[0031] Optionally, the time-series pattern early warning further includes: calculating the probability of the estrus peak in the past 6 hours. Probability of proestrus The magnitude of the increase in the ratio as a transfer indicator When the transfer index The probability of being in the preestrus stage is greater than the predetermined threshold. Below the first predetermined threshold, probability of peak estrus When the temperature exceeds the second predetermined threshold, it is determined that the sow is transitioning from proestrus to peak estrus, and an early warning is issued.

[0032] Secondly, a sow estrus prediction intelligent system based on temporal behavior analysis is provided for performing the method, including:

[0033] The intelligent detection terminal module is worn on the sow's ear and is used to continuously and synchronously collect multi-source time-series data and send it in the form of data packets through a short-range communication protocol.

[0034] An edge computing gateway module, deployed in the pigsty, communicates with the intelligent detection terminal module to receive and decrypt the data packet, execute step S2 of the method to perform inertial data fusion and accurate attitude calculation, output attitude angle sequence, and compress and upload the processed data.

[0035] The cloud server-time series analysis and prediction module is communicatively connected to the edge computing gateway module. It is used to receive uploaded data and execute steps S3 to S5 of the method to perform behavioral time series data preprocessing and event segmentation, dual-stream time series behavioral feature extraction, multi-head attention mechanism fusion and estrus prediction, and finally generate early warning information.

[0036] The user terminal application module communicates with the cloud server module to receive and display the early warning information and the optimal mating time window in real time.

[0037] Thirdly, a computer device includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method.

[0038] Fourthly, a computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the method.

[0039] Compared with the prior art, this application has at least the following beneficial effects:

[0040] This application designs a closed-loop correction mechanism (PI controller) based on virtual angular velocity feedback, which reduces the gyroscope drift rate and filters out magnetic field distortion spikes. It can clearly distinguish high-frequency minute attitude changes such as ear root tremors in the pre-estrus stage, providing high-sensitivity features for early prediction.

[0041] This application utilizes attitude angle variation and audio short-time energy to construct a dual-threshold finite state automaton, which adaptively eliminates low-information intervals such as lying down and stillness. At the same time, the segmentation results themselves can assist in the monitoring of health abnormalities (such as the absence of active segments for a long time indicating limpness or high fever).

[0042] Short-term convolutional networks capture local waveforms of high-frequency micro-movements, while long-term bidirectional GRU models the long-term dependence of body temperature and activity levels on rhythms. The two feature streams are then fused in the later stages, thus balancing the ability to model both transient micro-movements and slow physiological rhythms.

[0043] This application integrates data acquisition, posture calculation, behavior segmentation, dual-stream feature extraction, adaptive fusion, early warning decision-making, and system architecture into a complete technical solution. It achieves early, accurate, and personalized prediction of estrus in sows, especially the pre-estrus stage. The system can output the optimal mating time window in advance, reduce the number of non-productive days for sows, increase the annual parity of pigs and breeding efficiency, and has outstanding substantial progress and industrial application value. Attached Figure Description

[0044] Figure 1 A flowchart illustrating an intelligent prediction method for sow estrus based on time-series behavior analysis, provided as an embodiment of this application;

[0045] Figure 2 A flowchart of step S2 in a sow estrus intelligent prediction method based on time-series behavior analysis provided in one embodiment of this application;

[0046] Figure 3 This is a schematic diagram of the module connections of an intelligent estrus prediction system for sows based on time-series behavior analysis, provided as an embodiment of this application. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments.

[0048] This application provides an intelligent prediction method for sow estrus based on time-series behavioral analysis, as shown in the attached document. Figure 1 As shown, it includes the following steps:

[0049] S1: Multi-source time-series data synchronous acquisition. A smart detection terminal worn on the sow's ear continuously and synchronously acquires multi-source time-series data reflecting the sow's physiological and behavioral status. The smart detection terminal's shell features an IP67 waterproof and dustproof design, and it embeds a main control chip, a nine-axis inertial measurement unit (IMU), a contact thermistor (model NTC 10KΩ), and a miniature MEMS microphone. The terminal weighs no more than 35 grams and is secured to the back of the sow's ear with a medical-grade silicone ear tag, ensuring the temperature sensor is in close contact with the skin at the base of the ear. The microphone's pickup hole faces the mouth and nose to reduce wind noise.

[0050] The data acquisition process employs a non-interrupted cyclic buffering mechanism, with a 72-hour sliding history window. The main control chip is configured with an IMU at a 100Hz sampling rate to read the raw ADC values ​​of triaxial acceleration (range ±16g), triaxial angular velocity (range ±2000° / s), and triaxial geomagnetic intensity (range ±4900μT), which are then encapsulated into an 18-byte inertial navigation data packet. Simultaneously, the temperature sensor's low-power measurement mode is activated every 5 seconds, and the readings are taken twice, averaged, and converted into a body temperature value (unit °C) with an accuracy of 0.01℃.

[0051] Audio data is sampled at 16kHz, quantized to 16-bit, and streamed using real-time pulse density modulation (PDM) with 1024 samples per frame to reduce data redundancy. To prevent clock skew between multiple sensors, each data acquisition is performed within the same hardware timer interrupt of the main control chip: after the interrupt is triggered, all axis data from the IMU are read first, followed by the conversion results from the temperature sensor (if the interrupt period is exactly a multiple of 5 seconds), and finally, the latest audio packet is retrieved from the FIFO buffer. Each record is stamped with a global timestamp based on the RTC (Real-Time Clock, synchronized with the base station NTP).

[0052] The terminal temporarily stores the raw data in a circular buffer and transmits it to the relay gateway via Bluetooth 5.2 or LoRa protocol at a packetization frequency of once per second. Each packet contains: a fixed frame header, a device ID, 100 inertial navigation data points within the current second (arranged in chronological order), the temperature measurement value of the most recent 3 seconds (if no new measurement is taken, the previous valid value is repeated), and a compression identifier for the audio data (the actual audio is transmitted continuously due to bandwidth limitations). Through this mechanism, the cloud can ultimately obtain a strictly time-aligned continuous multi-dimensional time-series data stream, serving as the basis for subsequent attitude calculation and behavior analysis.

[0053] S2: Inertial Data Fusion and Precise Attitude Calculation. The nine-axis inertial sensor data is fused and calculated to suppress measurement errors from a single sensor in dynamic scenarios, obtaining an attitude angle sequence that can finely characterize the sow's head and neck swaying and directional changes. It should be noted that sows often exhibit micro-movements such as ear root tremors and slight head swaying during proestrus, but traditional activity statistics based on acceleration thresholds cannot distinguish these subtle movements from posture changes during normal walking or feeding. Therefore, S2 performs complementary correction between the absolute attitude calculated by the accelerometer / magnetometer and the relative attitude integrated by the gyroscope, as shown in the attached diagram. Figure 2 As shown, the specific steps are as follows:

[0054] S2.1, First attitude quaternion The acquisition of.

[0055] First, the raw data from the accelerometer and magnetometer are calibrated. The calibration process consists of hard iron calibration and soft iron calibration: the terminal is rotated at a fixed rate in three-dimensional space for at least one revolution, and the maximum output values ​​of the accelerometer and magnetometer in each axis are recorded. , , With minimum output value , , Then the offset , scaling factor The calibrated measurement value is ,in These represent the X, Y, and Z axes, respectively. After hard iron correction, an ellipsoidal fitting method is used to eliminate soft iron and scale errors, yielding the calibrated magnetic field strength vector. With the gravitational acceleration vector .

[0056] right A low-pass filter is applied with a cutoff frequency set to 0.5Hz to filter out noise caused by high-frequency vibrations; Similarly, components higher than 1Hz are filtered out. After filtering... and In the local reference coordinate system, these points are directed towards the zenith and the magnetic north pole, respectively. Aligning the Z-axis of the local reference coordinate system with the direction of gravity and the X-axis with the horizontal component of the geomagnetic field, we can construct the direction cosine matrix (DCM):

[0057]

[0058] in The horizontal unit vector is the geomagnetic field. The DCM is a 3×3 orthogonal matrix describing the rotation from the sensor's local coordinate system to the local reference coordinate system. The DCM is further converted into a first attitude quaternion. The transformation relationship uses the standard Sheppard algorithm: The remaining components are passed through Divide the cross terms by The calculation yielded, where This is the element in the i-th row and j-th column of the DCM. Because... Relying on the Earth's gravitational field and geomagnetic field, it has good low-frequency characteristics and high accuracy under static or quasi-static conditions. However, it may exhibit instantaneous jumps when the sow's head swings rapidly or when it encounters an iron fence that causes magnetic field distortion.

[0059] S2.2, Second attitude quaternion Update the gyroscope output of the raw angular velocity value. First, zero-bias compensation is performed. Zero bias is calculated by averaging the gyroscope output after the terminal has been stationary for 2-3 seconds, and this calibration is repeated after each power-on. The compensated angular velocity... A high-pass filter (cutoff frequency 0.05Hz) is applied to eliminate slow drift caused by temperature changes. Then, a fourth-order Runge-Kutta method is used to numerically integrate and update the quaternion, with the update period matching the sensor sampling period (Δt = 0.01s). Let the quaternion at the current moment be Q(t), and the quaternion differential corresponding to the angular velocity vector be... ,in This represents quaternion multiplication. According to the Runge-Kutta recurrence relation:

[0060]

[0061]

[0062]

[0063]

[0064]

[0065] After accumulating points, you need to... Normalization is performed to ensure the unit quaternion constraint. The resulting... It has a high accuracy in tracking relative changes in a short period of time, but it will produce cumulative errors (drift) after long-term integration. This drift manifests as a continuous and slow shift in posture angle when the sow is standing or lying down for a long time. If it is not corrected, it will seriously affect the judgment of small posture changes in a static state.

[0066] S2.3 Attitude Error Calculation and Virtual Angular Velocity Feedback: To overcome the inherent defects of the above two methods, the following feedback compensation mechanism is designed. First, the gyro integral quaternion is calculated. Quaternion conversion with accelerometer / magnetometer The quaternion of the error between:

[0067]

[0068] in for The conjugate quaternion. When When accurately tracking the true pose, It should be close to a unit quaternion (1, 0, 0, 0); if drift or jumps exist, The vector part is non-zero. Let be... The scalar component is The vector components are Then the error angle in axis-angle form The axis of rotation is a unit vector. After proportionally compressing the angular error, a virtual angular velocity vector is constructed:

[0069]

[0070] proportionality coefficient The value should be between 0.5 and 1.0. Too high a value will introduce noise, while too low a value will result in slow convergence.

[0071] Furthermore, to achieve zero steady-state error tracking, an integral term is introduced. This ultimately forms the PI controller structure. Virtual angular velocity. The dimension of the angular velocity is consistent with the actual angular velocity (° / s). Its physical meaning is: when the gyroscope integration attitude deviates from the absolute attitude indicated by the accelerometer / magnetometer, a virtual rotational angular velocity is applied to drive the gyroscope integration result to approach the absolute attitude.

[0072] S2.4, Closed-loop correction and final attitude angle output, which outputs the virtual angular velocity. Superimposed on the measured angular velocity of the gyroscope Above, a corrected angular velocity is formed. Then with Replace S2.2 Perform the Runge-Kutta quaternion update again to obtain the attitude quaternion after closed-loop correction. After each closed-loop update is completed, utilize Recalculate the error next time. This creates continuous feedback. The feedback loop executes with a period of 10ms x 10ms, which can suppress long-term drift of the gyroscope in real time (the drift rate is reduced from the original 1~2° per minute to no more than 0.1° per hour), while filtering out instantaneous spikes caused by magnetic field distortion (jumps with a time width of less than 0.5s are effectively smoothed).

[0073] Finally, the quaternion after closed-loop correction is... Convert to Euler angles to obtain the attitude angle sequence. The conversion formula is as follows:

[0074]

[0075]

[0076]

[0077] in , ,correspond The four components;

[0078] The three posture angles represent the vertical movement of the head and neck (pitch angle), the lateral tilt (roll angle), and the horizontal turning around the vertical axis (yaw angle). Experiments show that when sows are eating (continuous up-and-down head movements), mounting (sudden forward tilting), and standing and looking around (periodic horizontal scanning), the posture angle sequence output in this step can clearly distinguish different behavioral patterns. In particular, the "ear root tremor" that occurs in proestrus will show high-frequency small fluctuations in pitch angle with an amplitude of 2~5° and a frequency of 3~6Hz, providing high-quality input features for subsequent behavior recognition.

[0079] S3: Behavior temporal data preprocessing and event segmentation, using the attitude angle sequence obtained from S2. The temperature sequence T(t) and raw audio signals collected simultaneously cannot be directly used for behavioral feature extraction. This is because sows spend about 60% to 70% of their time in the pen lying down or ruminating, during which time the sensor data changes gradually and contributes very little to estrus prediction. At the same time, the sensors may generate instantaneous abnormal values ​​during the wearing process due to sows rubbing against the fence, drinking water, or excreting. The specific steps include:

[0080] S3.1 Median Filtering and Outlier Removal: For the temperature sequence T(t), the sampling interval is 5 seconds. Occasionally, single-point jumps occur in the raw data due to poor contact between the ear tag and skin (e.g., a sudden drop of 0.5–1.0℃ followed by immediate recovery). For these outliers, a sliding median filter of length 7 is used, meaning the filtered output at each time step is the median of the seven temperature values ​​(three points before and three points after that time step). Data segments with consecutive missing values ​​exceeding 30 minutes are directly marked as invalid and discarded. After filtering, the noise amplitude of the temperature sequence is suppressed to within ±0.05℃.

[0081] For attitude angle sequence The original sampling rate was 100Hz. Although S2 had fused and corrected the inertial data, sows may experience brief integral overshoot when violently shaking their ears or heads, manifesting as spikes in pitch or yaw angles exceeding 30° in a single sample. A median filter with a window length of 11 (corresponding to 0.11 seconds) was used for smoothing. It should be noted that the median filter preserves edges and only eliminates isolated outliers, thus not erasing true rapid motion characteristics. For data gaps exceeding 2 seconds (such as wireless packet loss), cubic spline interpolation was used for completion. Before interpolation, the rate of change of data at both ends of the interpolation interval was checked to ensure it was reasonable (the rate of change did not exceed 200° / s). Otherwise, the interpolation was rejected and the segment was marked as invalid.

[0082] In terms of audio signal processing, the raw PDM stream is converted to PCM format after decimation filtering, with a sampling rate of 16kHz. First, pre-emphasis (coefficient 0.97) is applied to compensate for high-frequency attenuation. Then, a Hamming window is added with a frame length of 25ms and a frame shift of 10ms. 40-dimensional Mel-frequency cepstral coefficients (MFCCs) are calculated for each frame, along with short-time energy. Zero-crossing rate. Outliers are defined as frames whose energy exceeds 5 times or falls below 0.2 times the average energy of the previous 20 frames, accompanied by a sudden change in the zero-crossing rate. This typically corresponds to clipping distortion, such as a microphone being briefly blocked or a pig screaming. Such frames are directly invalidated and do not participate in the energy statistics of subsequent segments.

[0083] S3.2. Active segment segmentation based on short-time energy and attitude angle variation: This method segments time segments containing behaviors such as feeding, standing transition, mounting, and active sniffing from continuous long-term data streams, while removing low-information intervals such as lying stillness and deep sleep. A dual-threshold mechanism is used to make decisions based on both audio energy and attitude angle change rate.

[0084] First, define the attitude angle variation index. Calculate the absolute values ​​of the first-order differences for pitch, roll, and yaw angles, and then take the combined three-axis magnitude:

[0085]

[0086] Where Δ is the difference between adjacent sampling points (time interval 0.01 seconds). To eliminate sampling noise, for Then perform a smoothed average with a window length of 50 (0.5 seconds), denoted as . Simultaneously, short-time energy E(t) (in dB, with reference to the effective value of a full-scale sine wave corresponding to 0 dB) is extracted from the audio MFCC features.

[0087] Set two thresholds: low threshold and high threshold and a minimum duration seconds and a longest idle interval Seconds. The partitioning is achieved using the following finite state automaton:

[0088] Initial state: In the "inactive" zone;

[0089] Conditions for entering an active state: When or (in If the background noise energy (estimated from the lowest 10th percentile of the energy from the first 5 minutes of data) remains continuously for more than 0.2 seconds, then an active starting point is marked. The status has changed to "active";

[0090] Conditions for exiting the active state: While in the active state, if consecutive... Within a time and If so, the action is considered to have ended, and the record is made. .like If so, discard the segment (which may be transient noise or a brief head shake).

[0091] Overlapping merging: If the interval between two active segments is less than 0.5 seconds, they are merged into a single continuous segment;

[0092] The aforementioned thresholds need to be adaptively adjusted according to the type of pigsty. This patent recommends performing an initial data collection period of approximately 30 minutes for each newly installed terminal, during which statistics are collected. The distribution histogram, taking the valley value of the bimodal distribution as... Take the 80th percentile of the peak value as ( Used to determine aggressive behaviors such as climbing. (Background noise energy) It is dynamically updated once a day, taking the average of the lowest 10th percentile of audio energy between 23:00 and 5:00 the next day, in order to eliminate the difference between day and night ambient sound.

[0093] After this step, the original continuous data stream is segmented into several behaviorally active segments ranging in length from 1.5 seconds to several minutes. Each segment includes metadata such as a start timestamp, duration, average variation within the segment, and average energy. These segments will serve as input samples for the two-stream network in S4, while large segments of static data will not participate in subsequent calculations, thus reducing the computational load for model training and inference by approximately 65%. Furthermore, the segmentation results themselves can serve as an auxiliary indicator: if a sow does not exhibit any active segments for several consecutive hours during her estrus cycle, it may indicate a health abnormality (such as lameness or high fever).

[0094] S4: Construct a dual-stream temporal behavioral feature network. The behavioral activity segments obtained from S3 have a large time scale: some segments last only a few seconds (such as ear tremors, a single attempt to climb), while others can last from several minutes to several hours (such as feeding, standing and observing). A single model cannot simultaneously capture high-frequency micro-movements and low-frequency rhythmic changes;

[0095] S4 constructs two parallel feature extraction branches to process high-frequency inertial data in a short time window and low-frequency physiological data in a long time window, respectively. The feature vectors output from the two branches are then fused in a later stage, as follows:

[0096] The first branch is a short-term micro-motion feature extraction network. The input to this branch is a 30-second window of data, centered on a behaviorally active segment and extended 15 seconds before and after it. The data within the window includes: pose angle sequences. (Sampling rate 100Hz, downsampled to 50Hz to reduce computational load) and raw triaxial acceleration values (Also resampled to 50Hz). This forms an input matrix of shape 1500×6 (1500 time steps, 6 channels per step: pitch, roll, yaw, and triaxial acceleration). Notably, this window covers the segment itself and the 15-second "quiet periods" before and after it to provide background information before and after the action, facilitating the network's learning of the start and end transition patterns of the action;

[0097] The network consists of four stacked one-dimensional convolutional layers, each followed by batch normalization and ReLU activation. The first layer has a kernel size of 7, a stride of 2, 32 output channels, and a receptive field covering approximately 140ms (7 sampling points), used to capture the local waveform of a single tremor. The second layer has a kernel size of 5, a stride of 1, 64 output channels, and an expanded receptive field of approximately 300ms. The third layer has a kernel size of 5, a stride of 2, and 128 output channels. The fourth layer has a kernel size of 3, a stride of 1, and 256 output channels. After these four convolutional layers, the temporal dimension is compressed from 1500 to approximately 94, resulting in a feature dimension of 256 at each time step. Global average pooling is then used to flatten the temporal dimension, yielding a 256-dimensional feature vector. ;

[0098] To enhance sensitivity to minute variations, bias terms are disabled in all convolutional layers, and weight normalization is used instead of batch normalization (batch normalization is statistically unstable in small batches). During network training, random dropout (with a dropout rate of 0.3) is introduced at the output of the last convolutional layer during forward propagation. The loss function is cross-entropy, but the class labels are not direct action categories; instead, they are binary labels indicating whether estrus-related micro-movements are present. These labels are extracted by experts from samples simultaneously annotated in the video.

[0099] In addition, the network can simultaneously output an auxiliary regression task—estimating the intensity score of micro-movements (a continuous value between 0 and 1). This auxiliary task uses mean squared error loss and is jointly optimized with the main task to enhance the transferability of features.

[0100] The second branch is a long-term behavioral rhythm feature extraction network. The input time span for this branch is 6 hours, backtracking from the current time point. The input features consist of three sets: the first set is the temperature sequence T(t), with an original sampling interval of 5 seconds, resampled to one point every 5 minutes (72 points in total), and filtered by S3.1. The second set is the cumulative activity, defined as the attitude angle variation within every 5 minutes. The integral value (unit: degrees) also yields 72 points. The third group is the vocal frequency, defined as the number of valid vocalizations detected within 5 minutes (audio energy exceeding the background threshold). Each instance is counted if its duration exceeds 0.2 seconds, and there are 72 points in total. This forms an input matrix of shape 72×3.

[0101] Considering the impact of ambient temperature on the sow's basal body temperature, the temperature sequence needs to be calibrated before being input into the network. Specifically, the hourly average ambient temperature is obtained from environmental sensors in the pigsty. For each temperature point T(t), the average ambient temperature offset for the corresponding time period is subtracted (this offset is obtained by offline analysis of the correlation between body temperature and ambient temperature in healthy non-estrus sows, and is generally 0.02~0.03℃ / ℃). The corrected temperature better reflects the core body temperature changes caused by estrus rather than environmental disturbances;

[0102] The network primarily employs a two-layer bidirectional gated recurrent unit (Bi-GRU) architecture. The first Bi-GRU layer has 64 hidden units, and the second layer has 128. Each Bi-GRU layer processes the sequence in both the forward and backward directions, outputting a concatenation of its respective hidden states. After two Bi-GRU layers, the output of the last time step (i.e., the current time step) is used as a compressed representation of the sequence, resulting in a 256-dimensional feature vector. To prevent overfitting, a random deactivation with a dropout rate of 0.4 is added between the two Bi-GRU layers, and a random masking step (mask rate of 5%) is added to the input sequence as data augmentation.

[0103] The training of this branch employs a multi-task learning framework: the primary task is binary classification (whether it is in proestrus / peak estrus), and the auxiliary tasks are predicting the peak cumulative activity level (regression) and temperature change trend (slope sign classification) within one hour prior to the current moment. The role of the auxiliary tasks is to guide the network to focus on estrus-related rhythmic patterns rather than individual absolute values.

[0104] The two branches were first pre-trained on their respective datasets. The dataset for the short-term branch came from 30-second segments segmented by S3, manually labeled for pre-estrus micro-movements such as "ear root tremors" and "tail root elevation." The dataset for the long-term branch came from a continuous 6-hour window, with annotations derived from video and artificial estrus recordings (using the standing reflex as the gold standard). After pre-training, the output feature vectors of the two branches were... and The concatenation results in a 512-dimensional network, followed by a fully connected layer (256 dimensions, ReLU), and then connected to the multi-head attention fusion layer in S5. The entire two-stream network undergoes end-to-end joint fine-tuning on labeled data from the estrus prediction task. At this stage, the low-level convolutional / GRU parameters of the pre-trained branches are frozen, and only the high-level fully connected and attention layers are fine-tuned to avoid destroying learned general features. The learning rate during fine-tuning is set to one-tenth of the initial pre-training learning rate (typically...). The optimizer uses AdamW, and the weight decay is set to... ;

[0105] S5: Multi-head attention mechanism fusion and estrus prediction, using two feature vectors obtained from S4. and These represent information about short-term micromotor modes and long-term rhythmic modes, respectively. Different sows exhibit different dominant expression modes during estrus: some sows show extremely pronounced micromotor movements but gradual changes in body temperature during proestrus, while others show the opposite.

[0106] Furthermore, the dominant patterns of the same sow in different estrous cycles may vary due to body condition and season. Fixed weighted fusion (such as simple splicing or weighted averaging) cannot adapt to such individual differences and dynamic changes. Therefore, a multi-head attention mechanism is introduced to achieve adaptive fusion, and the estrus probability and optimal mating time window are output based on the fused features. The specific steps are as follows:

[0107] S5.1, Multi-head attention adaptive fusion, will and Treating them as two "modal tokens", construct a sequence input. The parameters for the multi-head attention layer are set as follows: number of attention heads h=4, and the query / key / value dimension for each head. First, through three learnable linear transformation matrices... Map X to a query matrix Q, a key matrix K, and a value matrix V, all of which have the following shapes. Calculate the attention score for each head individually:

[0108]

[0109] in This represents the corresponding component (shape 2×64) of the i-th head. Softmax is applied along the sequence dimension (i.e., between two modalities) such that the sum of the attention weights of each modality to the other modality is 1. The outputs of the four heads are concatenated along the last dimension and then passed through a linear projection layer. The fused feature vector is obtained. .Pick The first row (corresponding to the attention-enhanced representation of the short-term modality) and the second row (corresponding to the attention-enhanced representation of the long-term modality) are added element-wise to obtain the final fused feature. This addition operation is equivalent to a weighted sum of the two modes, where the weights are dynamically determined by the attention scores. For example, if a sow's body temperature changes are highly discriminative, the long-term mode will receive a higher attention weight; conversely, if its postural tremors are more pronounced, the short-term mode will dominate.

[0110] Furthermore, to stabilize training and provide a differentiated representation space for each head, a layer is applied before the attention layer. and Perform layer normalization separately, and apply residual connections: The training parameters for the entire attention module are approximately 4×(256×64)×2 (approximately 131k), which is a moderate computational cost and can be used for inference on embedded devices.

[0111] S5.2, Probability output of estrus phase, The input is fed into a two-layer fully connected network: the first layer outputs 128 dimensions with ReLU activation and random deactivation at a dropout rate of 0.2; the second layer outputs 3 dimensions with no activation function. The three output values ​​are then transformed into a probability distribution using the Softmax function.

[0112]

[0113] in Logical values ​​corresponding to the three categories of "proestrus", "peak estrus", and "non-estrus" are used respectively. Cross-entropy loss is employed during training, and labels are derived from artificial estrus records and video verification.

[0114] It is important to emphasize that "proestrus" is defined as the 12-24 hour window before the standing reflex appears, during which sows will exhibit early signs such as ear twitching, decreased appetite, and a slow increase in activity. "Peak estrus" is defined as the duration of the standing reflex, typically 8-20 hours. "Non-estrus" includes the estrus period, gestation period, and abnormal anestrus. These three categories are not purely mutually exclusive—there is a temporal order between proestrus and peak estrus, but the probability output by the model reflects the likelihood of the current moment belonging to each stage.

[0115] In actual deployment, the model performs inference on the latest data window every 15 minutes, outputting a 3D probability vector. The system records the trajectory of this probability vector over time in real time.

[0116] S5.3, Early Warning Trigger and Optimal Mating Time Window Output: A dual early warning mechanism is designed to balance sensitivity and specificity, as detailed below:

[0117] The first level is a single-point threshold warning, based on the "probability of peak estrus". Exceeding the threshold Upon reaching this point, an "Peak period reached" warning is immediately triggered, indicating "Mating can proceed at this time." This threshold is determined by maximizing the F1 score on the validation set through grid search.

[0118] The second layer is a time-series pattern warning; relying solely on instantaneous probability is prone to false alarms due to noise. Therefore, a sliding window is introduced to detect the transition pattern from "proestrus to peak estrus". Let the current time be... Examining the past 6 hours (Progesterial estrus probability) and Sequence. Define the transition index:

[0119]

[0120] Intuitively, this metric measures the increase in the percentage of peak hours over the most recent 6 hours relative to the previous 6 hours. When And currently and When the system determines that the sow is transitioning from proestrus to peak estrus, it issues an early warning that the sow is expected to reach mating status within 2-4 hours.

[0121] Optimal mating window estimation. The optimal time for mating is within 6 hours after the standing reflex appears (cervix open, mucus facilitates sperm motility). However, for sows where the standing reflex has not yet been observed, it is necessary to predict when the peak period will occur. This patent uses the kernel density estimation (KDE) method, based on the sow's historical estrus cycle data or population statistical prior, to construct the time difference distribution from "progesterone stage probability exceeding the threshold" to "peak period probability exceeding the threshold". Let... Given the historical duration (in hours) from proestrus trigger to peak estrus trigger, its probability density function is:

[0122]

[0123] Where K is the Gaussian kernel function, and the bandwidth h is determined by the Silverman rule. When the system detects a proestrus probability exceeding 0.6 three times consecutively at the current time, the conditional expectation is calculated as follows:

[0124]

[0125] The optimal mating time window is: from now on. Hours to Hours. If historical cycle data for the sow is lacking, a global prior based on statistics from all sows in the training set is used;

[0126] The final warning information is sent to the user terminal in structured text format, including: the current estrus stage tag, the probability value of each stage, the recommended mating time window (e.g., "Standing reflex is expected in 6-10 hours, mating is recommended tomorrow from 8:00 to 12:00"), and the confidence score (calculated based on the variance of the kernel density estimation). Simultaneously, the system updates the warning status and records the historical trajectory every time it receives a new 15-minute inference result, allowing veterinarians or breeders to review and analyze the situation.

[0127] In one embodiment, a sow estrus prediction intelligent system based on time-series behavior analysis is provided. This system serves as the physical carrier for implementing the above method and comprises four sequentially connected modules, as shown in the attached figure. Figure 3 As shown, it includes: an intelligent detection terminal module, an edge computing gateway module, a cloud server-time series analysis and prediction module, and a user terminal application module;

[0128] The intelligent detection terminal module, worn behind the left ear or along the lower edge of the neck of the sow, features an integrated encapsulation structure with an IP67-rated polycarbonate shell and a medical-grade silicone contact pad on the back. Internally, the module integrates a nine-axis inertial measurement unit (MPU9250 or ICM-20948), a contact temperature sensor (encapsulated within a metal probe, protruding 2mm from the shell for close contact with the skin), a MEMS microphone, a low-power Bluetooth microcontroller, and a rechargeable battery. The entire terminal weighs no more than 32g and is secured to the ear with a disposable anti-theft ear tag to prevent it from falling off when the sow shakes her ear.

[0129] The microcontroller reads data from each axis of the IMU at a fixed frequency of 100Hz (driven by the internal real-time clock RTC timer interrupt): accelerometer range ±16g, gyroscope range ±2000° / s, magnetometer range ±4900μT. The data is then directly stored in a circular buffer as a 16-bit signed integer. The temperature sensor wakes up every 5 seconds, reads two consecutive values, averages them, and converts the average to a floating-point value (unit: °C).

[0130] The audio data was acquired using PDM at a sampling rate of 16kHz and a precision of 16bit. After hardware extraction and filtering, it was converted into PCM format, and each 1024 samples were packaged into an audio frame.

[0131] To prevent time misalignment of data from various sensors, all read operations are completed within the same interrupt service routine: after an interrupt is triggered, the IMU's accelerometer / angular velocity / magnetometer data is read sequentially, the temperature is read (single-bus protocol, requiring approximately 10ms), and the latest audio frame is retrieved from the microphone's FIFO. Each record is appended with a millisecond-level timestamp generated by the RTC, and the RTC performs NTP time synchronization with the gateway once a day.

[0132] The terminal firmware employs a dual-buffer ping-pong mechanism: one buffer is used for writing the latest data in real time, and the other buffer is used for packet transmission. The packetization cycle is 1 second, meaning one data packet is generated per second. The data packet format is as follows: fixed frame header, device ID, RTC timestamp starting at the beginning of this second, and 100 sets of IMU data within this second (arranged in chronological order, corresponding to...). , , , , , , , , All data are stored in the original ADC value; the last temperature value within this second (accuracy 0.01℃); and the audio frame identifier (if an audio frame completed within this second is not fully transmitted, only its MD5 digest is transmitted to save bandwidth; the complete audio frame is transmitted in batches with low priority through a separate channel).

[0133] The entire data packet is encrypted using AES-128 and then transmitted via Bluetooth 5.2 to the relay gateway deployed in the pigsty. The transmission power is set to 0dBm. When the battery level is below 10%, the terminal automatically reduces the IMU sampling rate to 50Hz and disables audio acquisition, prioritizing the continuity of inertial navigation and temperature data.

[0134] An edge computing gateway module is deployed on the wall of each pigsty, and each gateway can connect to multiple terminals simultaneously. The gateway runs a real-time operating system and internally executes a C++ implementation of the inertial sensor fusion control algorithm described in S2.

[0135] After receiving encrypted data packets from various terminals, the gateway first verifies the CRC and decrypts them, and then performs the following operations:

[0136] Time alignment: If the timestamp of a terminal data packet deviates from the local time of the gateway by more than 200ms, an NTP correction command is immediately issued and the packet is re-marked based on the gateway time.

[0137] Attitude calculation: S2.1 to S2.4 are performed on the nine-axis data from each terminal. The calculation program uses fixed-point arithmetic optimization, and the time for a single fusion calculation is approximately 0.8ms (measured on the CM4 kernel). Output attitude angle sequence. It includes three angles: pitch, roll, and yaw (quantization accuracy 0.01°).

[0138] Feature extraction: 1-12 dimension coefficients and short-time energy of MFCC are calculated in real time for audio frames without storing the original audio waveform;

[0139] Compression and Upload: The processing results are organized into a structured data stream. Each record includes: terminal ID, absolute time, attitude angle, temperature, MFCC characteristics, and short-time energy. After compression using the LZ4 compression algorithm, the data is uploaded to the cloud server via the MQTT protocol (QoS=1) at 5-second intervals (i.e., a batch of summary data from the past 5 seconds is sent every 5 seconds). To prevent data loss due to network interruptions, the gateway internally caches the data from the last 72 hours in the eMMC, resuming transmission once the network is restored.

[0140] In addition, the gateway also undertakes local log recording and device management functions: it generates an activity report for each terminal daily (cumulative sampling points, packet loss rate, battery voltage), and displays the online status of each terminal through LED indicators (green for normal, yellow for low battery, red for offline).

[0141] The cloud server-time series analysis and prediction module is containerized and runs multiple microservice components in the background. It receives data streams from multiple pig farm gateways and executes algorithms from S3 to S5. The cloud server-time series analysis and prediction module is internally divided into four units, specifically including:

[0142] The data preprocessing unit receives structured data streams uploaded from the gateway via a message queue (Kafka) buffer. First, it performs data cleaning, removing records with out-of-order timestamps (an ordered queue is maintained for each device ID; if the timestamp of newly arrived data is less than the timestamps of the three most recent records, it is discarded), temperatures exceeding the reasonable range of 25~45℃ (discarded), and attitude angles exceeding the ±180° range (if still exceeding the range after correction, it is discarded).

[0143] Next, S3.1 median filtering and outlier removal are performed, with filtering parameters (window length, threshold) stored separately by device ID. Then, S3.2 active segmentation is performed, generating "active segment" events for each device and storing them in the time-series database (InfluxDB). This unit performs global data realignment once a day at midnight, performing cubic spline interpolation (for time periods missing due to network packet loss, if the missing time is no more than 30 minutes consecutively) or directly marking them as invalid (if the missing time exceeds 30 minutes).

[0144] The dual-stream network model library stores and manages the weight parameters and network structures of the two pre-trained network models described in S4, and provides a GPU inference engine. The input size for the short-term micro-action network is 1500×6, and the input size for the long-term rhythm network is 72×3. The model library supports A / B version hot-swapping; once the new model has been trained and evaluated on the validation set, it can replace the old model online without restarting the service. Simultaneously, this unit records the inference results cache for each terminal for the most recent 24 hours, used for subsequent attention fusion.

[0145] The attention fusion and classification unit performs multi-head attention fusion in S5.1 and probabilistic output in S5.2. For each device, it extracts high-frequency data segments (input short-term branches) from the most recent 30 seconds and low-frequency data windows (input long-term branches) from the most recent 6 hours every 15 minutes, calls the model library for inference, and obtains... and Attention calculation and softmax classification are then performed within this unit, outputting a 3D probability vector. All inference results and intermediate feature vectors are stored in a MySQL database (with indexes and partitioned by device ID) for subsequent statistical analysis and model iteration optimization.

[0146] The prediction output interface is responsible for generating the final estrus warning and mating suggestion. The input is the probability sequence generated by attention fusion and classification units, and the output is a structured JSON message. The specific logic follows S5.3: first, a single-point threshold is detected. This directly triggers the "peak period reached" warning; secondly, it calculates the transfer quota within 6 hours. ,like And currently and This triggers a warning that "peak is expected within 2-4 hours." For those meeting the proestrus trigger conditions ( For sows with three consecutive estrus cycles exceeding 0.6, the system queries their historical estrus cycle database (stored in MySQL, indexed by sow ID) and calls the kernel density estimation function to output the optimal mating time window; if no historical data is available, a global prior is used. The final output includes: sow ID, warning type (early / peak), probability value, suggested mating time window, and confidence score (kernel density variance mapped to 0-1). This interface also sends data in real-time to the user's terminal application module via WebSocket push and is available for third-party systems to call via a RESTful API.

[0147] The user terminal application module is presented in two forms: a mobile APP and a PC-based web dashboard. The front end establishes a long connection with the prediction output interface via WebSocket to receive early warning messages in real time and periodically (every minute) retrieve the latest estrus probability curve and ranking data.

[0148] Specifically, the mobile app mainly includes the following functions:

[0149] The homepage dashboard displays all currently alerted sows in card format, sorted in descending order of the probability of peak estrus. Each card shows the sow's ear tag number, alert status (red for peak estrus, orange for proestrus), suggested mating time, and confidence level. Clicking on a card will take you to a details page.

[0150] The details page displays a curve showing the change in the probability of estrus over the past 24 hours (three curves): , , It can overlay and display raw parameter curves such as body temperature, activity level, and number of vocalizations; and provides a countdown timer and calendar reminder function for the "optimal mating window";

[0151] Group Analysis: Displays an "Erosion Index Ranking", statistically analyzes the average estrus probability of all sows on the day, and provides an estrus cycle distribution map (heat map) to assist farmers in developing batch breeding plans;

[0152] Abnormal alarm: If a sow has no active behavior for 48 consecutive hours (total duration of active behavior < 5 minutes), the system will determine it as "suspected health abnormality" (such as lameness, high fever, anorexia), push an abnormal alarm notification in the APP, and suggest that a veterinarian conduct a manual examination;

[0153] The PC-based dashboard functions are similar to those of the app, but it adds a data export function and a model version management interface (allowing technicians to view the current version number, validation set metrics, and last update time of the dual-stream network model).

[0154] In one embodiment, a computer device is also provided, the processor of which provides computing and control capabilities, the computer device loading and running a computer program to implement the above-described intelligent prediction method for sow estrus based on time-series behavior analysis.

[0155] In one embodiment, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the steps of the methods described in the embodiments above.

[0156] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

Claims

1. A method for intelligent prediction of estrus in sows based on temporal behavioral analysis, characterized in that, The method includes: S1: Multi-source time-series data synchronous acquisition: Multi-source time-series data is continuously and synchronously acquired through an intelligent detection terminal worn on the sow's ear. The multi-source time-series data includes nine-axis inertial sensing data, body temperature data, and audio data. S2: Inertial data fusion and precise attitude calculation: The nine-axis inertial sensing data is fused and calculated to obtain an attitude angle sequence that can characterize the sow's head and neck swing and direction changes, specifically including: S2.1 Obtaining the first attitude quaternion based on calibration data from the accelerometer and magnetometer ; S2.2 Update the second attitude quaternion based on the angular velocity data output by the gyroscope. ; S2.3 Calculate the second attitude quaternion With the first attitude quaternion The error quaternion between And construct a virtual angular velocity vector based on the axis-angle form of the error quaternion. ,in For the error angle, The unit vector of the rotation axis. This is the proportionality coefficient; S2.4, the virtual angular velocity vector Superimposed on the measured angular velocity of the gyroscope A corrected angular velocity is generated, and a closed-loop correction is performed based on the corrected angular velocity to obtain the final attitude angle sequence. ; S3: Behavioral timing data preprocessing and event segmentation, for the attitude angle sequence The body temperature data and audio data collected simultaneously are preprocessed, and active behavioral segments are segmented from them; S4: Construct a dual-stream temporal behavior feature network to process the active behavior segments, and extract short-term micro-motion feature vectors through the parallel first and second branches respectively. With long-term behavioral rhythm feature vector The first branch is used to process high-frequency inertial data in a short time window, and the second branch is used to process low-frequency physiological data in a long time window. S5: Multi-head attention mechanism fusion and estrus prediction, which integrates the short-term micro-motion feature vectors With the long-term behavioral rhythm feature vector The two modal tokens are input into a multi-head attention layer for adaptive fusion, resulting in a fused feature vector. And based on the fused feature vector Output the estrus probability and the optimal mating time window.

2. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 1, characterized in that, In S1, the synchronous acquisition of multi-source time-series data includes: triggering the reading operations of all sensors in the same hardware timer interrupt, and attaching a global timestamp based on a real-time clock to each acquisition record to form a continuous multi-source time-series data stream with strict time alignment.

3. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 1, characterized in that, S3 specifically includes: S3.

1. Use a sliding median filter to remove single-point jump outliers from the body temperature data, use a median filter to smooth the integral overshoot caused by severe ear shaking from the posture angle sequence, and pre-emphasize and extract Mel frequency cepstral coefficients (MFCC) features from the audio data. S3.2, Based on attitude angle variation index Using the short-time audio energy E(t), a dual-threshold finite state automaton is employed to segment active segments from the continuous data stream and remove low-information intervals that are lying still.

4. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 1, characterized in that, The first branch in S4 is a short-term micro-motion feature extraction network. Its input is a continuous 30-second window of data truncated with the active behavior segment as the center and extended 15 seconds before and after it. The window data includes the attitude angle sequence and the raw values ​​of the three-axis acceleration. The first branch is composed of multiple stacked one-dimensional convolutional layers and outputs the short-term micro-action feature vector. .

5. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 4, characterized in that, The second branch in S4 is a long-term behavioral rhythm feature extraction network with an input time span of 6 hours. The input features include a corrected temperature sequence, cumulative activity level, and vocalization frequency. The second branch is constructed using a multi-layer bidirectional gated recurrent unit and outputs the long-term behavioral rhythm feature vector. .

6. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 1, characterized in that, S5 specifically includes: S5.1, the feature vector and Constructed as a sequence input The attention weights between the two modalities are calculated using a multi-head attention mechanism, and the attention-enhanced representations are added element-wise to obtain the final fused features. ; S5.2, The fusion feature The data is fed into a fully connected network, and the Softmax function outputs the probability distributions corresponding to the proestrus, peak estrus, and non-estrus phases. ; S5.

3. The early warning is triggered by a dual mechanism based on single-point threshold early warning and time-series pattern early warning, and the optimal mating time window is output by using the kernel density estimation method.

7. The intelligent prediction method for sow estrus based on time-series behavioral analysis according to claim 1, characterized in that, The time-series pattern early warning further includes: calculating the probability of the estrus peak period in the past 6 hours. Probability of proestrus The magnitude of the increase in the ratio as a transfer indicator When the transfer index The probability of being in the preestrus stage is greater than the predetermined threshold. Below the first predetermined threshold, probability of peak estrus When the temperature exceeds the second predetermined threshold, it is determined that the sow is transitioning from proestrus to peak estrus, and an early warning is issued.

8. A sow estrus prediction intelligent system based on temporal behavior analysis, used to execute the method of any one of claims 1 to 7, characterized in that, include: The intelligent detection terminal module is worn on the sow's ear and is used to continuously and synchronously collect multi-source time-series data and send it in the form of data packets through a short-range communication protocol. An edge computing gateway module, deployed in the pigsty, communicates with the intelligent detection terminal module to receive and decrypt the data packet, execute step S2 of the method to perform inertial data fusion and accurate attitude calculation, output attitude angle sequence, and compress and upload the processed data. The cloud server-time series analysis and prediction module is communicatively connected to the edge computing gateway module. It is used to receive uploaded data and execute steps S3 to S5 of the method to perform behavioral time series data preprocessing and event segmentation, dual-stream time series behavioral feature extraction, multi-head attention mechanism fusion and estrus prediction, and finally generate early warning information. The user terminal application module communicates with the cloud server module to receive and display the early warning information and the optimal mating time window in real time.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 7.