Pig farm anomaly detection system based on multi-sensor data fusion
Through multi-sensor data fusion and particle filtering algorithms, combined with dynamic perception networks and behavioral fingerprint libraries, the problems of limited data dimensions and response delays in traditional breeding modes are solved, and all-round and real-time monitoring and abnormal detection of pig farms are achieved, improving breeding efficiency and safety.
Patent Information
- Application Number
- CN202510609042.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2045-05-13
AI Technical Summary
The traditional breeding model relies on a single sensor, has limited data dimensions, and is difficult to fully reflect complex breeding scenarios, and has a high response delay and false alarm rate.
Multi-sensor data fusion technology is adopted to predict the movement trajectory of pigs through particle filtering algorithms, build a global anomaly detection model, and combine dynamic perception networks and behavioral fingerprint libraries for real-time abnormality detection and early warning.
All-round and real-time monitoring of the pig farm environment, behavior and health status has been achieved, which has significantly improved breeding efficiency, reduced the risk of epidemic transmission, and improved the accuracy and reliability of abnormal detection.
Smart Images

Figure CN120123958A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of anomaly detection based on multi-sensor fusion, and specifically to a pig farm anomaly detection system for multi-sensor data fusion. Background Art
[0002] Animal husbandry is an important part of agricultural production. Among them, pig breeding plays a core role in ensuring meat supply and promoting agricultural economy. However, the traditional breeding mode relies on manual experience management, with problems such as extensive environmental regulation, lagging disease warning, and insufficient recognition of abnormal behaviors, resulting in low production efficiency and high risks. With the development of smart agriculture, the intelligent transformation of livestock breeding has become an inevitable trend. By introducing multi-sensor data fusion technology, real-time monitoring and anomaly detection of the breeding environment, pig behavior, and health status can be achieved, which can significantly improve breeding efficiency, reduce the risk of disease transmission, and promote the development of animal husbandry towards refinement and scientificization. Traditional breeding monitoring mostly relies on a single sensor, with limited data dimensions, making it difficult to comprehensively reflect complex breeding scenarios. Moreover, the single-sensor system has a response delay and a high false alarm rate in complex environments. Summary of the Invention
[0003] The present invention aims at the technical problems existing in the prior art and provides a pig farm anomaly detection system for multi-sensor data fusion.
[0004] The technical solution of the present invention to solve the above technical problems is as follows: A pig farm anomaly detection system for multi-sensor data fusion, including: Multi-source data acquisition and fusion module: Continuously collect data through sensors, bind a unique spatio-temporal anchor point to the RFID tag, and use the particle filter algorithm to predict the movement trajectory of pigs between different sensor fields of view; Anomaly detection model construction module: Locally train the model according to its own data at each node, and then upload the local model parameters to the central node for fusion through the gradient aggregation strategy to generate a global anomaly detection model; Anomaly detection module: Divide a dynamic perception network in the pigsty, and each grid unit collects multi-modal data features in real time. By calculating the entropy value of the grid unit, evaluate the degree of chaos and anomaly possibility of the data; Anomaly warning module: Establish a behavior fingerprint library for each pig, monitor the pig behavior data in real time, and calculate the matching degree with the behavior fingerprint.
[0005] In a preferred embodiment, the multi-source data acquisition and fusion module continuously collects data at a set frequency through various sensors, including pig behavior, movement, physiological data, and environmental data, and obtains pig ID and location information through an RFID reader. The collected data is initially cleaned, a unique spatio-temporal anchor is assigned to each RFID tag, and the initial spatio-temporal coordinates are determined for each tag by combining the camera frame timestamp and the weight sensor sampling period. A unified time reference is established, and the times of the camera, weight sensor, and RFID reader are calibrated with this reference time. The network time protocol is used to synchronize the device times regularly to reduce time errors. The particle filter algorithm is used to predict the movement trajectory of the pigs. Taking the location information obtained by the RFID tag as the observed data and combining the historical movement state of the pigs, a movement trajectory prediction model is established. The specific steps of the movement trajectory prediction model are as follows: S1. According to the known initial position and state information of the pig, a set of particles is randomly generated, and the same weight is assigned to each particle. Let the state space of the pig be , which respectively represent the position of the pig in the two-dimensional space and the speed . At the initial time t = 0, the initial position and speed of the pig are known. N particles are randomly generated, and the initial state
[0006] of each particle is: where i represents the index of the particle, represents the state of the i-th particle at the initial time t = 0, which respectively includes the initial position and the initial speed of the particle. represents that the initial position and speed of the i-th particle respectively follow a normal distribution with the initial position and speed of the pig as the mean, and represents the variance; S2. According to the movement model of the pig, considering the speed and acceleration factors of the pig, the state of each particle is predicted to obtain the position and speed information of the particle at the next moment; S5. Calculate the estimated position and movement trajectory of the pigs based on the resampled particle states and weights, and obtain the final trajectory prediction result through weighted averaging.
[0007] When a pig enters the recognition range of another RFID reader from the recognition range of one RFID reader, predict its movement trajectory between the two readers through the particle filter algorithm, fill the data acquisition gap, ensure the continuity and integrity of the pig's movement trajectory, compare and correct the predicted movement trajectory with the pig's behavior captured by the camera, and map the data collected by different types of sensors to a unified spatio-temporal coordinate system according to the spatio-temporal anchor points and time synchronization information.
[0008] In a preferred embodiment, the abnormal detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including the pig behavior images collected by the camera, the real-time acquisition of the pig position and movement trajectory data by RFID, and the environmental parameters collected by the temperature and humidity sensors. Preprocess the collected data, use the mini-batch gradient descent algorithm to divide the preprocessed data into small batches, and use the cross-entropy loss combined with the mean square error as the loss function to train the local abnormal detection model. The local model training includes dividing the preprocessed data into small batches according to the time window, each batch containing a first preset number of samples, calculating the gradient through the backpropagation algorithm, and updating the model parameters to learn the normal behavior pattern and environmental fluctuation characteristics. When the number of training rounds reaches the second preset threshold, trigger the gradient upload operation. During the training process, calculate the gradient through the backpropagation algorithm, continuously adjust the model parameters, so that the model learns the normal behavior pattern of the pigs, the movement law, and the characteristics of the normal fluctuation range of the environmental parameters. Set the local model training round threshold to 10 rounds. After the edge node completes 10 rounds of training, trigger the gradient upload operation, encapsulate the gradient information recorded during the training process, add the edge node identifier, the number of training rounds, and the data source identifier such as the camera in Area A of the pigsty and the temperature and humidity sensor data in Area B of the pigsty, and upload the data to the central node. After receiving the gradient information uploaded by each edge node, the central node first extracts the node identifier, the data source identifier, and the data volume information, assigns weights according to the proportion of the node data volume and the computing power score. After calculating the weights of each edge node at the central node, use the gradient weighted average formula to perform an aggregation operation on the local gradients uploaded by each node. The specific calculation formula is as follows:
[0009] Among them, represents the local gradient of node k, which is the gradient information calculated by the edge node based on the pig behavior images, RFID position trajectories, and environmental parameter data collected by itself after local model training. represents the weight of node k, which is obtained according to the weighted allocation mechanism of the proportion of node data volume and the computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradients , and uses the Adam optimization algorithm to update the parameters of the global anomaly detection model , and the specific calculation formula is as follows:
[0010] where represents the updated parameter represents the learning rate. The updated parameters are packaged and sent to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters, and prepares for the next round of training based on local data. The specific steps of the new round of training loop are as follows: S1. The edge node uses the updated global model parameters, combines with the newly collected multi-source local data, and continues the next round of local model training, repeating the processes of gradient calculation, gradient upload, central node gradient aggregation and model update. In each round of iteration, the model continuously learns the features in the new data; S2. In each iteration process, the central node monitors the convergence of the global model through the following double-condition judgment mechanism: on the one hand, calculate the change in the loss function for consecutive multiple iterations. When the change in the loss function is less than 0.001, it indicates that the model parameter update tends to be stable and the training is approaching convergence. On the other hand, set the maximum number of training rounds to 100 rounds. When this round is reached, regardless of whether the change in the loss function meets the threshold, stop the training; S3. When any of the above termination conditions is met, output the final global anomaly detection model, which has the ability to accurately detect abnormal situations in the actual pig farm environment.
[0011] Deploy the finally trained global anomaly detection model to the pig farm real-time monitoring system, connect with the data collection of each sensor to ensure that the pig behavior images, RFID location trajectories, and environmental parameter data can be obtained in real time. When new data is input into the model, the model analyzes and judges the data based on the normal behavior characteristics, movement rules of pigs and the normal range of environmental parameters learned during the training process. If the data does not conform to the normal mode and has a large difference from the historical normal behavior mode, the model outputs abnormal results, including the abnormal type, and reminds the pig farm management personnel in the form of an alarm. The management personnel take corresponding measures in a timely manner according to the alarm information.
[0012] In a preferred embodiment, the anomaly detection module divides a dynamic perception network in the pigsty. According to the actual physical space layout of the pigsty, the pigsty is divided into several grid units of uniform size. Each grid unit serves as an independent data collection and analysis unit to ensure coverage of all areas in the pigsty. A unique identification ID is assigned to each grid unit, and a mapping relationship between the grid unit and the sensor data is established to clarify the sensors included in each grid unit. Multimodal data is collected through the sensors, and the multimodal data collected for each grid unit is preprocessed. The entropy value of each grid unit is calculated to evaluate the degree of data chaos and the possibility of anomalies. Suppose there are n different types of sensor data in the grid unit, and the probability distribution of each type of data is , then the calculation formula for the entropy value of this grid unit is as follows:
[0013] where represents the distribution probability density of the i-th type of sensor data in the grid. Set the time window length. When the entropy value increment of the grid unit exceeds the preset threshold within 3 consecutive time windows, it is determined that an abnormal event has occurred in this area.
[0014] In a preferred embodiment, the anomaly warning module establishes a behavior fingerprint library for each pig. The extracted motion patterns, feeding characteristics, and social behavior information are integrated and stored. The behavior fingerprint library of each pig uses the RFID tag ID of the pig as the unique identifier. The preprocessed pig behavior data is obtained in real time, and the real-time monitored pig behavior data is matched with the behavior fingerprint library of this pig. The Euclidean distance is used to calculate the distance between the real-time data and the data in the behavior fingerprint library. A short distance indicates a high degree of matching. Suppose there are two feature vectors and , the specific calculation formula for the Euclidean distance is as follows:
[0015] The feature vector of the real-time monitored pig behavior data is matched and calculated with the feature vector of this pig in the behavior fingerprint library. Set the matching threshold. When the calculated distance is less than the threshold, it is considered that the real-time data matches well with the behavior fingerprint library and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and a warning is triggered.
[0016] The beneficial effects of the present invention are as follows: The present invention widely deploys various types of sensors, including high-definition cameras, weight sensors, RFID devices, and environmental monitoring devices, which can comprehensively collect multi-dimensional information such as pig behavior, movement, physiological data, and environmental parameters, ensuring a full range of perception of the pig farm situation, providing a rich and accurate data basis for subsequent analysis, avoiding the omission of anomaly detection caused by data loss. Through spatio-temporal alignment and data fusion operations, data from different types of sensors are accurately aligned in the time and space dimensions, and their advantages are integrated to form a more comprehensive and accurate data set. This enables anomaly detection to consider multiple factors comprehensively, improving the accuracy and reliability of detection, and being able to detect abnormal situations that are difficult to detect with single data. A behavior fingerprint library is established for each pig, and real-time monitoring and matching with the fingerprint library can trigger individual anomaly warnings in a timely manner. Through the monitoring of the entropy value of group data, group anomaly warnings can be realized, and potential problems can be discovered in a timely manner. Brief Description of the Drawings
[0017] Figure 1 is a flowchart of the present invention; Figure 2 is a system block diagram of the present invention. Detailed Embodiments
[0018] 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 skilled in the art without creative efforts belong to the scope of protection of the present application.
[0019] In the description of the present application, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more, unless otherwise specifically defined.
[0020] In the description of the present application, the term "for example" is used to mean "serving as an example, illustration, or explanation". Any embodiment described as "for example" in the present application is not necessarily construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to implement and use the present invention. In the following description, details are set forth for purposes of explanation. It should be understood that those of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but rather to be in line with the broadest scope consistent with the principles and features disclosed in the present application.
[0021] As Figure 1-2 , this embodiment provides: a pig farm anomaly detection system for multi-sensor data fusion, including: Multi-source data acquisition and fusion module: Continuously collect data through sensors, bind a unique spatio-temporal anchor point to the RFID tag, and use the particle filter algorithm to predict the movement trajectory of pigs between different sensor fields of view; In this embodiment, it should be noted that for the multi-source data acquisition and fusion module, the multi-source data acquisition and fusion module continuously collects data through various sensors at a set frequency, including pig behavior, movement, physiological data, and environmental data, and obtains pig ID and location information through the RFID reader, preliminarily cleans the collected data, assigns a unique spatio-temporal anchor point to each RFID tag, combines the camera frame timestamp and the weight sensor sampling period, determines the initial spatio-temporal coordinates for each tag. For example, when the RFID tag is first recognized by the reader, record the timestamp of the camera and the sampling moment of the weight sensor at this time, and calculate the initial position of the tag in space based on this to form a spatio-temporal anchor point, establish a unified time reference, calibrate the time of the camera, weight sensor, and RFID reader with this reference time to ensure the consistency of all data in the time dimension, use the network time protocol to synchronize the time of each device regularly to reduce time errors, and use the particle filter algorithm to predict the movement trajectory of pigs. Taking the location information obtained by the RFID tag as the observation data, combined with the historical movement state of the pigs, establish a movement trajectory prediction model. The specific steps of the movement trajectory prediction model are as follows: S1. According to the known initial position and state information of the pig, randomly generate a set of particles, and assign the same weight to each particle. Let the state space of the pig be , which respectively represent the position of the pig in the two-dimensional space and the speed . At the initial moment t = 0, the known initial position , randomly generate N particles, and the initial state of each particle is:
[0022] where i represents the index of the particle, represents the state of the i-th particle at the initial time t = 0, and respectively includes the initial position and the initial velocity , represents that the initial position and velocity of the i-th particle respectively follow a normal distribution with the initial position and velocity of the pig as the mean, and the variance; S2. According to the motion model of the pig, the motion model of the pig can be expressed as:
[0023] where t represents the current time, t - 1 represents the previous time, represents the time interval, respectively represent the accelerations of the pig in the x and y directions, represents the weight of the particle's position in the x direction at time t, which reflects the matching degree between the particle's position in the x direction and the observed data. The larger the weight, the higher the possibility that the particle's position in the x direction is closer to the true position of the pig, represents the weight of the particle's position in the y direction at time t, which is used to measure the degree of conformity between the particle's position in the y direction and the actual observation, represents the weight of the particle's velocity in the x direction at time t, which reflects the consistency between the velocity in the x direction represented by the particle and the velocity inferred from the observed data and the motion model. The higher the weight, the more likely the velocity in the x direction corresponding to the particle is the true velocity of the pig, represents the weight of the particle's velocity in the y direction at time t, which is used to evaluate the matching degree between the particle's velocity in the y direction and the actual situation. Considering the velocity and acceleration factors of the pig, predict the state of each particle to obtain the position and velocity information of the particle at the next moment:
[0024] where, represents the position of particle i in the x direction at time t - 1, represents the position of particle i in the y direction at time t - 1, represents the velocity of particle i in the x direction at time t - 1, represents the velocity of particle i in the y direction at time t - 1, represents the predicted position of particle i in the x direction at time t, Denotes the predicted position of particle i in the y - direction at time t, Denotes the predicted velocity of particle i in the x - direction at time t, Denotes the predicted velocity of the particle in the y - direction at time t, Denotes the noise that affects the prediction of the position of particle i in the x - direction at time t, Denotes the noise that affects the prediction of the position of particle i in the y - direction at time t, Denotes the noise that affects the prediction of the velocity of particle i in the x - direction at time t, representing the interference of other random factors on the velocity of the particle in the x - direction in addition to the influence of acceleration and time interval on the velocity, Denotes the noise that affects the prediction of the velocity of particle i in the y - direction at time t, which is other random factors affecting the velocity of the particle in the y - direction; S3. Compare the predicted particle state with the actually observed RFID tag position information, and update the weight of each particle by calculating the observation likelihood function. The weight reflects the matching degree between the particle and the observed data. Let the observation model be , where, Denotes the observed data, Denotes the observed value calculated according to the pig state , Denotes the observation noise, which follows a normal distribution with a mean of 0. The observation likelihood function adopts a Gaussian distribution form:
[0025] where, Denotes the probability of observing the data under the i - th particle state , that is, the observation likelihood function. Update the weight of the particle according to the observation likelihood function:
[0026] where, Denotes the updated weight of the i - th particle at time t, which is calculated from the weight at the previous time and the observation likelihood function , and then normalize the weight:
[0027] where, Denotes the normalized weight of the i - th particle at time t, which is used to make the sum of the weights of all particles equal to 1; S4. Resample according to the weights of the particles, delete the particles with smaller weights, and replicate the particles with larger weights to ensure that the particle set can better approximate the true probability distribution. Adopt the polynomial resampling method, according to the normalized weights Resampling is performed to calculate the cumulative distribution function , and N random numbers uniformly distributed in the interval [0, 1] are generated . For each random number , find j that satisfies . Then the k-th resampled particle is the j-th particle in the outlier subset, that is , and its weight ; S5. According to the states and weights of the resampled particles, calculate the estimated position and motion trajectory of the pig, and obtain the final trajectory prediction result through weighted average:
[0028]
[0029]
[0030]
[0031] Among them, represents the estimated position of the pig in the x-axis direction at time t, represents the estimated position of the pig in the y-axis direction at time t, represents the estimated velocity of the pig in the x-axis direction at time t, represents the estimated velocity of the pig in the y-axis direction at time t, N represents the total number of particles, represents the weight of the i-th particle at time t, represents the position of the i-th particle in the x-axis direction at time t, represents the position of the i-th particle in the y-axis direction at time t, represents the velocity of the i-th particle in the x-axis direction at time t, represents the velocity of the i-th particle in the y-axis direction at time t. The estimated motion trajectory of the pig is the sequence composed of at different times t.
[0032] When the pig enters the recognition range of another RFID reader from the recognition range of one RFID reader, its motion trajectory between the two readers is predicted through the particle filter algorithm to fill the data acquisition gap, ensure the continuity and integrity of the pig's motion trajectory, compare and correct the predicted motion trajectory with the pig's behavior captured by the camera, improve the accuracy of trajectory prediction, and map the data collected by different types of sensors to a unified spatio-temporal coordinate system according to the spatio-temporal anchor points and time synchronization information.
[0033] It should be noted that various sensors need to be installed according to the actual layout of the pig farm and monitoring requirements. High-definition cameras are installed on the top of the pigsty to ensure full coverage without dead angles. Weight sensors are embedded in the ground of the areas where pigs often move. RFID readers are arranged at key positions such as the entrances and exits of the pigsty and passages. Environmental sensors such as temperature, humidity, and ammonia concentration sensors are evenly distributed in the pigsty to ensure the comprehensiveness and representativeness of data collection. Set appropriate sampling frequencies for different types of sensors. For high-definition cameras, video data is collected at a frequency of 30 frames per second to capture the details of pig behavior in real time. The weight sensor collects pressure data 10 times per second to accurately record the pressure changes when pigs are moving and eating. The RFID reader reads RFID tag information 5 times per second to track the positions of pigs in real time. The environmental sensor collects environmental parameters once per minute to continuously monitor the environmental conditions of the pigsty. Start various sensors and start collecting data according to the set frequencies. The camera generates video stream data, the weight sensor outputs a pressure sequence, the RFID reader obtains the pig ID and position information, and the environmental sensor collects data such as temperature, humidity, and ammonia concentration. Conduct preliminary cleaning on the collected raw data. Use filtering algorithms to remove noise and interference in the video stream. Through data range judgment and outlier detection, eliminate invalid data that exceeds the reasonable range in the weight sensor and environmental sensor, such as extremely unreasonable values of temperature and humidity. Conduct deduplication and integrity checks on RFID data to ensure the accuracy and effectiveness of the data.
[0034] Anomaly detection model construction module: At each node, local model training is carried out according to its own data, and then through the gradient aggregation strategy, the local model parameters are uploaded to the central node for fusion to generate a global anomaly detection model; In this embodiment, it is necessary to specifically describe the abnormal detection model construction module. The abnormal detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including collecting pig behavior images by cameras, obtaining pig positions and movement trajectory data in real time by RFID, and collecting environmental parameters in the pig farm by temperature and humidity sensors. The collected data is preprocessed, including denoising and normalizing image data, filling missing values in time series data, removing abnormal discrete points, graying and cropping pig behavior images, and converting temperature, humidity, and ammonia concentration data into a unified numerical type. The mini-batch gradient descent algorithm is used to divide the preprocessed data into small batches. Based on the cross-entropy loss combined with the mean square error as the loss function, the local abnormal detection model is trained. The local model training includes dividing the preprocessed data into small batches according to time windows, with each batch containing a first preset number of samples. The gradient is calculated through the backpropagation algorithm, and the model parameters are updated to learn the normal behavior pattern and environmental fluctuation characteristics. When the number of training rounds reaches the second preset threshold, a gradient upload operation is triggered. During the training process, the gradient is calculated through the backpropagation algorithm, and the model parameters are continuously adjusted to enable the model to learn the normal behavior pattern of pigs, movement rules, and the characteristics of the normal fluctuation range of environmental parameters. The threshold for the number of local model training rounds is set to 10 rounds. When the edge node completes 10 rounds of training, a gradient upload operation is triggered. The gradient information recorded during the training process is encapsulated, and the edge node identifier, training round, and data source identifier such as the camera in Area A of the pigsty and the temperature and humidity sensor data in Area B of the pigsty are added, and the data is uploaded to the central node. After the central node receives the gradient information uploaded by each edge node, it first extracts the node identifier, data source identifier, and data volume information, and assigns weights according to the proportion of node data volume and the computing power score. After the central node completes the weight calculation of each edge node, the gradient weighted average formula is used to aggregate the local gradients uploaded by each node. The specific calculation formula is as follows:
[0035] Among them, represents the local gradient of node k, which is the gradient information calculated after local model training based on the pig behavior images, RFID position trajectories, and environmental parameter data collected by the edge node itself. represents the weight of node k, which is obtained according to the weighted allocation mechanism of the proportion of node data volume and the computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradient , and uses the Adam optimization algorithm to update the global abnormal detection model parameters , and the specific calculation formula is as follows:
[0036] Among them, represents the updated parameter. Denote the learning rate. Pack the updated parameters and send them to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters after information update to prepare for the next round of training based on local data. The specific steps of the new round of training loop are as follows: S1. The edge node uses the updated global model parameters and combines them with the newly collected multi-source local data to continue the next round of local model training, repeating the processes of gradient calculation, gradient uploading, gradient aggregation at the central node, and model update. In each iteration, the model continuously learns the features in the new data; S2. In each iteration process, the central node monitors the convergence of the global model through the following double-condition judgment mechanism: On the one hand, calculate the change in the loss function for consecutive multiple iterations. When the change in the loss function is less than 0.001, it indicates that the update of the model parameters tends to be stable and the training is approaching convergence. On the other hand, set the maximum number of training rounds to 100 rounds. When this round is reached, stop the training regardless of whether the change in the loss function meets the threshold; S3. When any of the above termination conditions is met, output the final global anomaly detection model, which has the ability to accurately detect abnormal situations in the actual pig farm environment.
[0037] It should be noted that the first preset number of samples refers to the number of library samples contained in each batch when the preprocessed data is divided into small batches according to the time window. During the machine learning training process, small-batch data is used for training. For example, the data within the time window is divided into multiple batches, and each batch contains multiple samples. This can utilize the advantages of batch calculation to accelerate the training process of the model and avoid the problem of insufficient memory caused by processing too much data at one time. The second preset threshold refers to the upper limit of the number of iteration rounds when the edge node performs local model training.
[0038] Deploy the finally trained global anomaly detection model into the real-time monitoring system of the pig farm, and connect it with the data collection of each sensor to ensure that data such as pig behavior images, RFID location trajectories, and environmental parameters can be obtained in real time. When new data is input into the model, the model analyzes and judges the data based on the normal behavior characteristics, movement rules, and normal range of environmental parameters learned during the training process. If the data does not conform to the normal pattern, for example, a certain pig remains stationary for a long time during the normal activity period and has a large difference from the historical normal behavior pattern, or the temperature, humidity, and ammonia concentration in a certain area exceed the normal fluctuation range, the model will identify it as an abnormal situation. The model outputs abnormal results, including detailed information such as the type of anomaly (such as pig behavior anomaly, environmental parameter anomaly) and the location where the anomaly occurs (determined by RFID or sensor location), and reminds the pig farm management personnel in the form of an alarm. The management personnel take corresponding measures in a timely manner according to the alarm information, such as conducting a health check on the abnormal pigs and strengthening ventilation and adjusting the temperature and humidity in the area with environmental anomalies.
[0039] Anomaly detection module: Divide a dynamic perception network in the pigsty. Each grid unit collects multi-modal data features in real time, and evaluates the degree of data chaos and the possibility of anomalies by calculating the entropy value of the grid unit. In this embodiment, it should be noted that for the anomaly detection module, the anomaly detection module divides a dynamic perception network in the pigsty. According to the actual physical space layout of the pigsty, the pigsty is divided into several grid units with uniform sizes. Each grid unit serves as an independent data collection and analysis unit to ensure that all areas in the pigsty are covered. A unique identification ID is assigned to each grid unit, and the mapping relationship between the grid unit and the sensor data is established to clarify the sensors included in each grid unit. Multi-modal data is collected through sensors, such as the coverage range of the camera, the sensing area of the RFID reader, and the location of the environmental sensor, so as to accurately collect the multi-modal data in this area. The camera corresponding to each grid unit collects image data at a frequency of 30 frames per second, and extracts visual features such as the posture, quantity, and activity status of the pigs through computer vision algorithms. For example, it identifies whether the pigs are in a lying, eating, walking, etc. state, counts the number of pigs, uses the RFID reader to collect the location information and movement trajectory data of the pigs in the grid unit, records the time when the pigs enter and leave the grid unit and their movement paths within the grid, and the environmental sensor collects environmental parameters such as temperature, humidity, and ammonia concentration in the grid unit in real time. The collection frequency is once per minute to ensure timely acquisition of environmental change information. The multi-modal data collected for each grid unit is preprocessed, and the entropy value of each grid unit is calculated to evaluate the degree of data chaos and the possibility of anomalies. Suppose there are n different types of sensor data in the grid unit, and the probability distribution of each type of data is , then the entropy value calculation formula of this grid unit is as follows:
[0040] Among them, denotes the distribution probability density of the i-th type of sensor data in the grid. Set the time window length. When the entropy value increment of the grid cell exceeds the preset threshold within 3 consecutive time windows, it is determined that an abnormal event occurs in this area.
[0041] Abnormal warning module: Establish a behavior fingerprint library for each pig, monitor the pig behavior data in real time, and calculate the matching degree with the behavior fingerprint; In this embodiment, it should be specifically explained about the abnormal warning module. The abnormal warning module establishes a behavior fingerprint library for each pig, integrates and stores the extracted motion patterns, feeding characteristics, and social behavior information. The behavior fingerprint library of each pig uses the RFID tag ID of the pig as the unique identifier, obtains the preprocessed pig behavior data in real time, matches the real-time monitored pig behavior data with the behavior fingerprint library of this pig, and uses the Euclidean distance to calculate the distance between the real-time data and the data in the behavior fingerprint library. A short distance indicates a high matching degree. There are two feature vectors and . The specific calculation formula of the Euclidean distance is as follows:
[0042] Match and calculate the feature vector of the real-time monitored pig behavior data with the feature vector of this pig in the behavior fingerprint library. Set the matching threshold. When the calculated distance is less than the threshold, it is considered that the real-time data matches well with the behavior fingerprint library and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and triggers an alarm.
[0043] It should be noted that in the above embodiments, the descriptions of each embodiment have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0044] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0045] The present invention will be described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.
[0046] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implement the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.
[0047] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.
[0048] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they know the basic inventive concept. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0049] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
Claims
1. The pig farm anomaly detection system based on multi-sensor data fusion is characterized by: include: Multi-source data collection and fusion module: continuously collects data through sensors, binds unique spatiotemporal anchor points to RFID tags, and uses particle filter algorithms to predict the movement trajectory of pigs between different sensor fields of view; Anomaly detection model building module: Each node performs local model training based on its own data, and then uploads local model parameters to the central node for fusion through the gradient aggregation strategy to generate a global anomaly detection model; Anomaly detection module: A dynamic sensing network is divided in the pig house. Each grid unit collects multimodal data features in real time. By calculating the entropy value of the grid unit, the degree of data chaos and the possibility of anomalies are evaluated; Abnormal warning module: establish a behavioral fingerprint library for each pig, monitor the pig behavior data in real time, and calculate the matching degree with the behavioral fingerprint.
2. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 1 is characterized in that: The multi-source data acquisition and fusion module continuously collects data at a set frequency through various sensors, including pig behavior, movement, physiological data and environmental data, and obtains pig ID and location information through RFID readers. The collected data is preliminarily cleaned, and a unique spatiotemporal anchor point is assigned to each RFID tag. Combined with the camera frame timestamp and the weight sensor sampling period, the initial spatiotemporal coordinates are determined for each tag, and a unified time reference is established. The time of the camera, weight sensor and RFID reader is calibrated with the reference time. The network time protocol is used to regularly synchronize the time of each device to reduce time errors. The particle filter algorithm is used to predict the movement trajectory of the pig. The location information obtained by the RFID tag is used as the observation data, and a movement trajectory prediction model is established in combination with the historical movement status of the pig.
3. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 2 is characterized in that: The specific steps of the motion trajectory prediction model are as follows: Where i represents the index of the particle, represents the state of the i-th particle at the initial time t=0, including the initial position of the particle and initial velocity , It means that the initial position and velocity of the i-th particle are respectively subject to the initial position and velocity of the pig as the mean, represents the normal distribution of variance; S2. According to the pig's motion model, taking into account the pig's speed and acceleration factors, the state of each particle is predicted to obtain the position and speed information of the particle at the next moment; S3, comparing the predicted particle state with the actually observed RFID tag position information, and updating the weight of each particle by calculating the observation likelihood function, where the weight reflects the degree of match between the particle and the observed data; S4, resampling according to the weight of the particles, deleting particles with smaller weights, and copying particles with larger weights; S5. Calculate the estimated position and motion trajectory of the pig according to the resampled particle states and weights, and obtain the final trajectory prediction result by weighted average.
4. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 3 is characterized in that: The particle filtering algorithm is used to predict the movement trajectory of the pig between the two readers, fill the data collection gap, ensure the continuity and integrity of the pig's movement trajectory, compare and correct the predicted movement trajectory with the pig's behavior captured by the camera, and map the data collected by different types of sensors into a unified space-time coordinate system based on the space-time anchor point and time synchronization information.
5. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 1 is characterized in that: The anomaly detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including cameras collecting pig behavior images, RFID obtaining pig location and movement trajectory data in real time, and temperature and humidity sensors collecting environmental parameters in the pig farm. The collected data is preprocessed and divided into small batches. The local anomaly detection model is trained based on cross entropy loss combined with mean square error as the loss function, and the gradient information recorded during the training process is encapsulated and uploaded to the central node. After the central node receives the gradient information uploaded by each edge node, it first extracts the node identification, data source identification, and data volume information, and assigns weights according to the node data volume ratio and computing power score. After the central node completes the weight calculation of each edge node, the gradient weighted average formula is used to aggregate the local gradients uploaded by each node. The specific calculation formula is as follows: in, The local gradient of node k is the gradient information calculated by the edge node based on the pig behavior images, RFID location trajectories, and environmental parameter data collected by the edge node after local model training. represents the weight of node k, which is obtained according to the weighted distribution mechanism of node data volume ratio and computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradient. , use Adam optimization algorithm to update the global anomaly detection model parameters , the specific calculation formula is as follows: in, represents the updated parameters, Represents the learning rate. The updated parameters are packaged and sent to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters to prepare for the next round of training based on local data.
6. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 5 is characterized in that: The specific steps of a new round of training cycle are as follows: S1. The edge node uses the updated global model parameters and combines the newly collected local multi-source data to continue the next round of local model training, repeating the process of gradient calculation, gradient upload, central node gradient aggregation and model update. In each round of iteration, the model continuously learns the features in the new data. S2. During each iteration, the central node monitors the convergence of the global model through the following two-condition judgment mechanism: calculate the change in the loss function for multiple consecutive iterations, set the maximum number of training rounds to 100, and stop training when this round is reached regardless of whether the loss function change meets the threshold; S3. When any of the above termination conditions is met, the training is terminated and the final global anomaly detection model is output. The model has the ability to accurately detect abnormal situations in the actual pig farm environment.
7. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 5 is characterized in that: Local model training includes dividing the preprocessed data into small batches according to time windows, each batch contains a first preset number of samples, calculating the gradient through the back propagation algorithm, updating the model parameters to learn normal behavior patterns and environmental fluctuation characteristics, and triggering the gradient upload operation when the training round reaches the second preset threshold.
8. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 5 is characterized in that: The final trained global anomaly detection model is deployed to the real-time monitoring system of the pig farm, and connected with the data collection of each sensor to ensure that pig behavior images, RFID location trajectories, and environmental parameter data can be obtained in real time. When new data is input into the model, the model analyzes and judges the data based on the normal behavior characteristics, movement patterns, and normal range of environmental parameters of pigs learned during the training process. If the data does not conform to the normal pattern and differs greatly from the historical normal behavior pattern, the model outputs abnormal results, including the type of abnormality, and reminds the pig farm managers in the form of alarms. The managers take corresponding measures in a timely manner based on the alarm information.
9. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 1, characterized in that: The anomaly detection module divides the dynamic perception network in the pig house. According to the actual physical space layout of the pig house, the pig house is divided into several grid units of uniform size. Each grid unit serves as an independent data collection and analysis unit to ensure coverage of all areas in the pig house. A unique identification ID is assigned to each grid unit, and a mapping relationship between the grid unit and the sensor data is established. The sensors contained in each grid unit are clarified, and multimodal data is collected through sensors. The multimodal data collected by each grid unit is preprocessed, and the entropy value of each grid unit is calculated to evaluate the degree of data confusion and the possibility of anomalies. Assume that there are n different types of sensor data in the grid unit, and the probability distribution of each data is , then the entropy value calculation formula of the grid unit is as follows: in, Identify the distribution probability density of the i-th type of sensor data in the grid, set the time window length, and when the entropy value increment of the grid unit exceeds the preset threshold within three consecutive time windows, it is determined that an abnormal event has occurred in the area.
10. The pig farm abnormality detection system based on multi-sensor data fusion according to claim 1, characterized in that: The abnormal warning module establishes a behavior fingerprint library for each pig, integrates and stores the extracted movement patterns, feeding characteristics, and social behavior information. The behavior fingerprint library of each pig uses the pig's RFID tag ID as a unique identifier, obtains pre-processed pig behavior data in real time, matches the real-time monitored pig behavior data with the behavior fingerprint library of the pig, and uses the Euclidean distance to calculate the distance between the real-time data and the data in the behavior fingerprint library. A short distance indicates a high degree of matching. There are two feature vectors: and , the specific calculation formula of Euclidean distance is as follows: The feature vector of the pig behavior data monitored in real time is matched with the feature vector of the pig in the behavior fingerprint library, and a matching threshold is set. When the calculated distance is less than the threshold, it is considered that the real-time data matches the behavior fingerprint library well and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and an early warning is triggered.
Citation Information
Patent Citations
Beef cattle body condition prediction method, device and system based on multi-source breeding data mining
CN115222091A
Livestock breeding environment data abnormity intelligent monitoring method
CN116340801A
Intelligent breeding data platform
CN116957836A
Livestock and poultry breeding environment monitoring method based on image data
CN117152676A
Multi-source data anomaly detection and bad data correction method for pig farm
CN117555886A
Cited By
Laying hen house intelligent drinking water scheduling and water-saving control method integrated with multi-source sensing
CN120295147A
Intelligent archival repository monitoring system based on Internet of Things
CN120299207A
Wireless multi-sensing data monitoring terminal system for smart rice and fish
CN120800473A
Cattle herd density abnormity early warning method based on multi-camera data fusion
CN120997463A