An individual-oriented group pig behavior monitoring method
By improving the YOLO11 behavior detection model and StrongSORT algorithm, and combining it with overhead monitoring video, the problems of low accuracy in pig behavior recognition and easily broken trajectories in group pig farms have been solved, enabling long-term, continuous behavior monitoring at the individual level and supporting health assessment and refined management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAZHONG AGRI UNIV
- Filing Date
- 2026-05-19
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technologies struggle to address the issues of low accuracy in identifying various behaviors of individual pigs in group-farmed pig farms, easily broken trajectories, and frequent identity switching. This makes it impossible to achieve long-term, continuous behavioral monitoring at the individual level, affecting health status assessment and refined management.
An improved YOLO11 behavior detection model and an optimized StrongSORT behavior tracking algorithm were adopted, combined with overhead monitoring video, to construct a dataset and perform feature extraction and identity matching, thereby achieving accurate identification and continuous tracking of pig behavior.
It enables long-term, stable, efficient, and accurate monitoring of various behaviors at the individual pig level in a group-raising environment, providing reliable data support for health status assessment and refined management, thereby improving breeding efficiency.
Smart Images

Figure CN122391963A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to, but is not limited to, the field of computer target detection and multi-target tracking algorithm technology, and particularly relates to a method for monitoring the behavior of pigs raised in groups, oriented towards individuals. Background Technology
[0002] Pig behavior is an important physiological indicator reflecting its health status and animal welfare level. In modern large-scale pig production, accurate, objective, and continuous behavioral monitoring at the individual level is crucial for early disease warning, health status assessment, and refined management. Existing pig behavior monitoring research mostly focuses on statistical analysis at the group level, failing to achieve continuous behavioral identification and stable tracking at the individual level. This makes it difficult to obtain continuous and stable data on various individual pig behaviors, thus affecting the timely assessment of each pig's health status and hindering the formulation of refined feeding and management strategies.
[0003] Existing technologies struggle to achieve long-term, continuous behavioral monitoring of individual pigs. In group-housed settings, pigs often obscure each other, have highly similar appearances, and exhibit frequent activity, leading to a significant decrease in behavioral recognition accuracy. This also increases the risk of broken target trajectories and misidentification, making accurate, long-term, and continuous monitoring of pig behavior difficult. These issues directly result in the inability to obtain stable and complete pig behavioral information, thus hindering the effective implementation of pig health status assessment, abnormal behavior early warning, and refined breeding management.
[0004] This invention proposes a method for monitoring the behavior of pigs in group-housed settings based on top-down video surveillance, aiming to achieve long-term, continuous, and accurate monitoring of various pig behaviors at the individual level in group-housed environments. This method integrates a target detection model and a multi-target tracking algorithm, achieving accurate identification of various pig behaviors while simultaneously enabling individual identification and continuous behavior tracking. This results in long-term, stable, efficient, and accurate monitoring of various pig behaviors at the individual level in group-housed settings, promoting the transformation and upgrading of pig behavior monitoring from the traditional group level to a more refined individual level.
[0005] Based on the above analysis, the urgent technical problems that need to be solved in the existing technology are:
[0006] The problems include low accuracy and serious false negatives in behavior detection caused by dense occupancy of pigs in group housing environments; and frequent identity switching and easy fragmentation of tracks caused by the high similarity in appearance of pigs and frequent crossover. Summary of the Invention
[0007] To address the problems existing in the prior art, this invention provides a method for monitoring the behavior of group-raised pigs at the individual level, which is suitable for long-term automatic monitoring of multiple behaviors of individual pigs in group-raised pigs.
[0008] This invention is implemented as follows: a method for monitoring the behavior of group-raised pigs oriented towards individuals, the method comprising:
[0009] S1: Dataset construction, collecting overhead monitoring videos of pig farms, and constructing pig behavior detection datasets and pig multi-target tracking datasets;
[0010] S2: Build an improved YOLO11 behavior detection model that includes an improved C3K2 module, an improved Concat module, and an improved Neck network;
[0011] S3: Construct and optimize the StrongSORT behavior tracking algorithm;
[0012] S4: Integrates the improved YOLO11 detection model and the optimized StrongSORT tracking algorithm to output end-to-end behavior monitoring results with IDs.
[0013] Further, step S1 includes:
[0014] S11: Video capture, using a top-down camera installed 3m above the pigsty to capture 2560×1440 monitoring video, covering the entire pen, and capturing top-down monitoring video of the pig farm;
[0015] S12: Construction of the behavior detection dataset, obtaining 7220 images by extracting frames from video; labeling bounding boxes for five behavior categories: standing, prone, side-lying, straddling, and eating; dividing the dataset into training / validation / test sets in an 8:1:1 ratio; format: YOLO format, used for model training;
[0016] S13: Construction of a multi-object tracking dataset, using 4 segments × 30 minutes of continuous video; frame-by-frame annotation: pig bounding boxes + unique identification IDs; covering occlusion, intersection, and stacking scenes, used for tracking algorithm training and evaluation;
[0017] S14: Convert the labeled data into the format required for model training.
[0018] Furthermore, in S2, the improved YOLO11 behavior detection model includes:
[0019] (1) C3K2 module introduces grouped convolution: replaces the Bottleneck structure inside C3K2 with grouped convolution;
[0020] (2) Optimize the Concat feature fusion module: add Gaussian noise perturbation; use depthwise separable convolution for lightweight feature extraction; add adaptive dynamic weights to weightedly fuse features at different levels.
[0021] (3) Reconstruct the Neck Network: Add an improved C3K2 module on the basis of the original PAN-FPN; insert an optimized Concat layer.
[0022] Furthermore, in step S2, the model is constructed with an input size of 640×640, batch=16, and epoch=100; the DFL loss function is used to optimize bounding box regression and behavior classification; the input is a video frame, and the model outputs the bounding box and behavior category for each pig.
[0023] Furthermore, step S3 includes:
[0024] S31: Set a fixed group ID initialization strategy to determine the maximum number of individuals in the pigsty. Initialize all pig IDs at once in the first detection frame; record the maximum ID as the constant number of pigs in the pen; do not add new IDs in subsequent frames, only fill in the missing target IDs.
[0025] S32: Add a Euclidean distance rematching module. After the original appearance and motion matching are completed, the unmatched trajectory boxes and detection boxes are matched again. Based on the Euclidean distance of the center point, the matching and ID supplementation are completed according to the relationship between the number of trajectories and the number of detections. The algorithm takes the detection boxes as input and outputs stable IDs, continuous trajectories and behavior categories.
[0026] S33: Integrates appearance features, motion information, and spatial distance to achieve trajectory correlation;
[0027] S34: Output a behavior tracking algorithm suitable for group pig farming scenarios.
[0028] Furthermore, in step S4, the overhead monitoring video is used as input. The improved YOLO11 model outputs the target bounding box and behavior category of the pig frame by frame. The optimized StrongSORT algorithm receives the above detection results and completes the individual ID association and trajectory maintenance. Finally, the unique ID of a single pig, the real-time behavior category, the continuous movement trajectory and the duration of the behavior are output. This can support long-term behavior statistics, behavior comparison at different time periods and behavior change analysis before and after manure cleaning.
[0029] Another object of the present invention is to provide a method for monitoring the behavior of group-housed pigs oriented towards individuals, the method comprising:
[0030] The dataset building module is used to collect overhead monitoring videos of pig farms and build pig behavior detection datasets and pig multi-target tracking datasets.
[0031] The behavior detection module is used to improve the YOLO11 behavior detection model and outputs the bounding box and behavior category for each pig.
[0032] The behavior tracking module is used to optimize the StrongSORT algorithm to receive the above detection results and complete the association of individual IDs and trajectory maintenance, and finally output the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration.
[0033] Another object of the present invention is to provide an individual-oriented group-housed pig behavior monitoring system, comprising:
[0034] The dataset building module is used to collect overhead monitoring videos of pig farms and build pig behavior detection datasets and pig multi-target tracking datasets;
[0035] The behavior detection module is used to build an improved YOLO11 behavior detection model based on the pig behavior detection dataset. The improved YOLO11 behavior detection model includes an improved C3K2 module, an improved Concat module, and an improved Neck network, and outputs the bounding box and behavior category of each pig according to the input video frame.
[0036] The behavior tracking module is used to build an optimized StrongSORT behavior tracking algorithm, which associates the bounding box with the behavior category and maintains the trajectory. The optimized StrongSORT behavior tracking algorithm includes a fixed group ID initialization strategy and a Euclidean distance rematching module.
[0037] The monitoring result output module is used to integrate the improved YOLO11 behavior detection model and the optimized StrongSORT behavior tracking algorithm to output the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration.
[0038] Furthermore, the dataset construction module includes:
[0039] The video acquisition unit uses a top-down camera installed 3 meters above the pigsty to capture monitoring video with a resolution of 2560 x 1440, covering the entire pigsty.
[0040] The behavior detection dataset construction unit is used to extract 7220 images from the surveillance video, label the bounding boxes of five types of behaviors: standing, prone, side-lying, straddling, and eating, and divide the training set, validation set, and test set in an 8:1:1 ratio to form behavior detection data in YOLO format.
[0041] The multi-target tracking dataset construction unit is used to annotate the bounding boxes and unique IDs of pigs frame by frame using four consecutive 30-minute video segments to form multi-target tracking data of pigs covering occlusion, intersection, and stacking scenarios;
[0042] The format conversion unit is used to convert labeled data into the format required for model training.
[0043] Furthermore, in the behavior detection module:
[0044] The improved C3K2 module employs grouped convolutions within the Bottleneck structure inside C3K2;
[0045] The improved Concat module is used to apply Gaussian noise perturbation during feature fusion, uses depthwise separable convolution for lightweight feature extraction, and uses adaptive dynamic weights to perform weighted fusion of features at different levels.
[0046] The improved Neck network is based on the PAN-FPN structure and includes an improved C3K2 module and an improved Concat module.
[0047] The behavior detection module uses a 640x640 input size, a batch size of 16, and 100 training rounds. It also employs the DFL loss function for bounding box regression and behavior classification optimization.
[0048] Furthermore, in the behavior tracking module:
[0049] The fixed group ID initialization strategy is used to determine the maximum number of individuals in the pig house. All pig IDs are initialized at once in the first detection frame, and the maximum ID is recorded as the constant number of pigs in the pen. No new IDs are added in subsequent frames, and IDs are filled in for missed targets.
[0050] The Euclidean distance rematching module is used to perform a second match on the unmatched trajectory boxes and detection boxes after the appearance matching and motion matching are completed. The Euclidean distance of the center point is used as the matching basis, and the matching and ID supplementation allocation are completed according to the relationship between the number of trajectories and the number of detections.
[0051] The behavior tracking module integrates appearance features, motion information, and spatial distance to correlate trajectories.
[0052] Furthermore, the monitoring result output module:
[0053] Using overhead monitoring video as input, the pig target bounding boxes and behavior categories output frame by frame by the improved YOLO11 behavior detection model are sent to the optimized StrongSORT behavior tracking algorithm;
[0054] Based on the individual identity association and trajectory maintenance results, a unique ID, real-time behavior category, continuous movement trajectory, and behavior duration are generated for each pig.
[0055] Generate behavioral monitoring results for long-term behavioral statistics, comparison of behavior at different time periods, and analysis of behavioral changes before and after manure removal.
[0056] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0057] This invention provides a complete, engineerable technical solution combining top-down video and a dual-network model. It integrates a target detection model and a multi-target tracking algorithm to accurately identify various pig behaviors while simultaneously achieving individual identification and continuous behavior tracking. This enables long-term, stable, efficient, and accurate monitoring of multiple individual pig behaviors in group-housed settings, driving the transformation and upgrading of pig behavior monitoring from the traditional group level to a refined individual level. It allows for long-term, continuous, reliable, and accurate monitoring of multiple individual pig behaviors in group-housed environments, replacing manual and group-level statistics. This provides reliable data support for individual behavior rhythm analysis, abnormal behavior identification, and health status assessment, thus providing crucial technical support for precision pig farming.
[0058] Existing technologies face core technical challenges in monitoring individual behavior in group-raised pigs, which are difficult to solve: existing research is mostly limited to group statistics and cannot achieve continuous behavior recognition and stable tracking at the individual level. The core issue is that the dense occlusion of pigs in the group-raising environment leads to low detection accuracy, frequent missed detections and false detections. Furthermore, the similar appearance of pigs and their frequent activities cause identity switching and trajectory breaks, ultimately making it impossible to obtain continuous individual behavior data, which restricts the implementation of refined farming. Conventional model or algorithm optimization cannot simultaneously solve the above-mentioned related pain points.
[0059] To address the aforementioned issues, this study combines the YOLO11-StrongSORT dual-network framework with R&D data, employing targeted technological innovations to precisely solve the problems. Specifically: First, two types of finely labeled datasets (7220 behavior detection images and 4.5 hours of tracking video) were constructed to fill the data gap at the individual level, providing reliable support for model training. Second, the YOLO11 model was optimized (C3K2 module grouped convolution, improved Concat and Neck structures), achieving an mAP50-90 of 87.7% (a 2.1% improvement), while reducing computational cost and parameter count by 0.6 GFLOPS and 0.46 M, respectively, resolving the problem of insufficient detection accuracy in occluded scenes. Third, the StrongSORT algorithm was optimized (introducing Euclidean distance matching and optimizing ID allocation), achieving an IDF1 of 95.7% (a 7.8% improvement) and reducing IDSW to 10, solving the problems of identity switching and trajectory breakage. Fourth, the dual networks were integrated to form a unified framework, achieving an mAP50 of 99.1% and a MOTA of 98.7%, enabling long-term accurate monitoring of multiple individual behaviors.
[0060] This solution addresses the problem and delivers significant innovative technological benefits: First, it breaks through the limitations of group monitoring, enabling precise and continuous monitoring of individual behavior, achieving a leapfrog improvement from group to individual; second, it enables non-contact, low-stress monitoring, reducing human intervention and errors, providing reliable data for health early warning and refined management, and improving breeding efficiency; third, it promotes technological progress in the field through open datasets, and its engineering framework can be adapted to large-scale breeding, helping the pig industry transform towards refinement and intelligence.
[0061] (1) The technical solution of this invention fills a technical gap in the industry both domestically and internationally:
[0062] Currently, the field of swine behavior monitoring lacks a complete set of technologies for individual monitoring in group-house farming scenarios. The industry also lacks dedicated labeled data resources adapted to the dense occlusion of pigs, and a mature integrated detection and tracking framework. Existing monitoring methods are insufficient to meet the practical needs of long-term, accurate, and continuous monitoring of multiple behaviors in a single pig. This invention independently constructs a dedicated dataset, collaboratively improves and deeply integrates detection models and tracking algorithms, creating an individual behavior monitoring solution adapted to group-house farming scenarios. This fills the technological gap in this area, improves the individual behavior perception technology system in the field of smart farming, and provides new technical support for the refined management of swine.
[0063] (2) The technical solution of the present invention solves a technical problem that people have long wanted to solve but have never been able to solve successfully:
[0064] For a long time, continuous behavioral monitoring of individual pigs in group-housed environments has been a core requirement for refined pig farming, early disease warning, and animal welfare assessment. However, due to the interplay of factors such as dense occlusion, homogeneous appearance, and frequent activity among pigs in group-housed environments, problems such as low detection accuracy, fragmented tracking, and misidentification have arisen, making it difficult to achieve long-term accurate monitoring of various behaviors at the individual level. This invention addresses these challenges by specifically optimizing the YOLO11 model and improving the StrongSORT algorithm, and deeply integrating the two to construct a dual-network framework. Experimental data validates this (mAP50 reaches 99.1%, MOTA reaches 98.7%), successfully overcoming this long-standing technical bottleneck. This enables stable, continuous, and accurate monitoring of various behaviors in individual pigs in group-housed environments, meeting the core needs of the industry.
[0065] (3) The technical solution of the present invention overcomes technical bias:
[0066] In group-house farming, technology struggles to achieve long-term, continuous, and accurate monitoring of diverse individual pig behaviors. Most methods rely on group statistical analysis to circumvent these technical challenges, neglecting the development of integrated detection and tracking optimization. This invention breaks through these limitations by specifically improving and deeply integrating the YOLO11 model and the StrongSORT algorithm, supported by a dedicated, refined dataset. It effectively adapts to complex scenarios involving group housing with occlusion and similar individual appearances, stably achieving accurate and continuous monitoring of individual pig behaviors. This fully validates the feasibility and practical value of intelligent individual monitoring in high-density farming environments. Attached Figure Description
[0067] Figure 1This is a flowchart of the group pig behavior monitoring method for individuals provided in the embodiments of the present invention;
[0068] Figure 2 This is a schematic diagram of the dataset construction process provided in an embodiment of the present invention;
[0069] Figure 3 This is a schematic diagram of the improved YOLO11 network structure provided in an embodiment of the present invention;
[0070] Figure 4 This is a schematic diagram comparing the improved YOLO11 and other detection models for group pig behavior detection provided in this embodiment of the invention;
[0071] Figure 5 This is a schematic diagram of the improved StrongSORT algorithm provided in an embodiment of the present invention;
[0072] Figure 6 This is a schematic diagram comparing the effects of group pig behavior tracking before and after the improvement provided in this embodiment of the invention;
[0073] Figure 7 This is a schematic diagram of the execution flow of the dual network framework provided in an embodiment of the present invention;
[0074] Figure 8 This is a block diagram of the group pig behavior monitoring method for individuals provided in the embodiments of the present invention;
[0075] Figure 9 This is a schematic diagram illustrating the effect of continuous behavior monitoring of individual pigs in group farming provided by an embodiment of the present invention;
[0076] Figure 10 Statistics on the duration of five behaviors in group-housed pigs during the morning, noon, and afternoon periods;
[0077] Figure 11 Comparison of the duration of behavior in group-housed pigs before and after manure cleaning. Detailed Implementation
[0078] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0079] The system provided in this invention uses overhead monitoring videos of pig farms as input and focuses on the needs of individual pig behavior recognition and continuous tracking in group-housed environments. First, the dataset construction module collects overhead monitoring videos covering the entire pig pen and establishes a pig behavior detection dataset and a pig multi-object tracking dataset. The behavior detection dataset obtains image samples by extracting frames from the video and annotates bounding boxes for five behaviors: standing, lying prone, lying on one's side, mounting, and eating, to improve the training of the YOLO11 behavior detection model. The multi-object tracking dataset annotates pig bounding boxes and unique IDs frame-by-frame based on continuous video, covering occlusion, intersection, and stacking scenarios, to optimize the training and evaluation of the StrongSORT behavior tracking algorithm. After annotation, the system converts the data into the format required for model training.
[0080] In the behavior detection phase, the system inputs video frames into the improved YOLO11 behavior detection model. This model improves upon the original structure by modifying the C3K2 module, the Concat feature fusion module, and the Neck network. Specifically, the C3K2 module's internal Bottleneck structure employs grouped convolutions; the Concat module applies Gaussian noise perturbation during feature fusion, uses depthwise separable convolutions for feature extraction, and utilizes adaptive dynamic weights to achieve weighted fusion of features from different levels; the Neck network is based on the PAN-FPN structure with the improved C3K2 module and the improved Concat module. The model takes video frames as input, and after feature extraction and multi-layer fusion, outputs the target bounding box and its corresponding behavior category for each pig frame by frame.
[0081] In the behavior tracking phase, the StrongSORT behavior tracking algorithm is optimized to receive the pig bounding boxes and behavior results output by the detection model, and to perform individual identity association and trajectory maintenance. The system first adopts a fixed group ID initialization strategy to determine the maximum number of individuals in the pen, and initializes all pig IDs at once in the first detection frame, recording the maximum ID as the constant head count in the pen. In subsequent video frame processing, no new IDs are added; only missed detection targets are filled with their IDs. Subsequently, after the original appearance matching and motion matching are completed, the algorithm uses a Euclidean distance re-matching module to perform a secondary association between the still unmatched trajectory boxes and detection boxes, using the Euclidean distance between the center point as the matching criterion, and completing the matching and ID supplementation allocation based on the relationship between the number of trajectories and the number of detections. Through the joint association of appearance features, motion information, and spatial distance, the continuity of pig identification and trajectory is maintained.
[0082] The monitoring results output module integrates the improved YOLO11 behavior detection results with the optimized StrongSORT tracking results to form a behavior monitoring output for individual pigs, including a unique ID, real-time behavior category, continuous movement trajectory, and behavior duration. Based on this, the system can achieve individual-level behavior monitoring in group-housed pig environments and provides a basis for long-term behavior statistics, behavior comparisons across different time periods, and analysis of behavior changes before and after manure removal.
[0083] like Figure 1 As shown in the embodiment of the present invention, a method for monitoring the behavior of group-raised pigs oriented towards individuals is provided. The method includes:
[0084] S1: Dataset construction;
[0085] S2: Construct an improved YOLO11 behavior detection model;
[0086] S3: Construct and optimize the StrongSORT behavior tracking algorithm;
[0087] S4: Dual network fusion and behavior monitoring.
[0088] like Figure 2 As shown, step S1 includes:
[0089] S11: Video capture, using a top-down camera installed 3m above the pigsty to capture 2560×1440 monitoring video, covering the entire pen, and capturing top-down monitoring video of the pig farm;
[0090] S12: Construction of the behavior detection dataset, 7220 images were obtained by extracting frames from the video; annotation: bounding boxes for five types of behaviors: standing, prone, side-lying, straddling, and eating; divided into training / validation / test sets in an 8:1:1 ratio; format: YOLO format, used for model training.
[0091] S13: Construction of a multi-object tracking dataset, using 4 segments × 30 minutes of continuous video; frame-by-frame annotation: pig bounding box + unique ID; covering occlusion, intersection, and stacking scenes, used for tracking algorithm training and evaluation.
[0092] S14: Convert the labeled data into the format required for model training.
[0093] The S2 step includes:
[0094] S21: Build a detection model that includes an improved C3K2 module, an improved Concat module, and an improved Neck network:
[0095] (1) Improvement 1: The C3K2 module introduces grouped convolution.
[0096] The Bottleneck structure within C3K2 is replaced with grouped convolutions; this reduces the number of parameters and computational cost, improves feature extraction efficiency under dense occlusion, reduces redundant computation, and enhances the feature representation of small and occluded targets.
[0097] (2) Improvement 2: Optimize the Concat feature fusion module
[0098] Gaussian noise perturbation is added to enhance robustness; lightweight feature extraction is achieved using depthwise separable convolution; adaptive dynamic weights are added to weighted fuse features at different levels; and the stability of behavior classification under complex lighting and occlusion conditions is improved.
[0099] (3) Improvement 3: Reconstruct the Neck Network
[0100] An improved C3K2 module was added to the original PAN-FPN; an optimized Concat layer was inserted to enhance multi-scale feature transfer and fusion; and the detection recall rate of pigs in different poses and at different scales was improved.
[0101] A schematic diagram of the improved YOLO11 network structure is shown below. Figure 3 As shown.
[0102] A comparative diagram of the improved YOLO11 and other detection models for group pig behavior detection is shown below. Figure 4 As shown.
[0103] S22: Use 640×640 as the input size, set batch=16 and epoch=100 to build the model;
[0104] S23: Use the DFL loss function to optimize bounding box regression and behavior classification;
[0105] S24: Output a behavior detection model suitable for group pig farming scenarios. Input video frames, and the model outputs the bounding box and behavior category for each pig.
[0106] The S3 step includes:
[0107] S31: Set a fixed group ID initialization strategy to determine the maximum number of individuals in the pigsty. The first detection frame initializes all pig IDs at once; the maximum ID is recorded as the constant number of pigs in the pen; subsequent frames do not add new IDs, but only complete the missing target IDs; this avoids invalid IDs and identity switching errors from the source.
[0108] S32: Add a Euclidean distance rematching module to improve the data association mechanism. After the original appearance and motion matching are completed, a second matching is performed on the unmatched trajectory boxes and detection boxes, based on the Euclidean distance of the center point; matching and ID supplementation allocation are completed according to the relationship between the number of trajectories and the number of detections, restoring trajectory breaks caused by short-term occlusion and missed detections; the algorithm takes the detection boxes as input and outputs stable IDs, continuous trajectories and behavior categories.
[0109] S33: Integrates appearance features, motion information, and spatial distance to achieve trajectory correlation;
[0110] S34: Output a behavior tracking algorithm suitable for group pig farming scenarios.
[0111] The flowchart of the improved StrongSORT algorithm is shown below. Figure 5 As shown.
[0112] A diagram showing the comparison of the effects of group pig behavior tracking before and after the improvement is shown below. Figure 6 As shown.
[0113] like Figure 7 As shown, step S4 takes overhead monitoring video as input, outputs the pig's target bounding box and behavior category frame by frame through an improved YOLO11 model, optimizes the StrongSORT algorithm to receive the above detection results and completes individual ID association and trajectory maintenance, and finally outputs the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration, which can support long-term behavior statistics, behavior comparison at different time periods, and behavior change analysis before and after manure removal. The steps include:
[0114] S41: Read the overhead surveillance video stream;
[0115] S42: Input the improved YOLO11 model frame by frame for inference;
[0116] S43: Input the detected bounding boxes and behavior categories into the StrongSORT model to optimize it;
[0117] S44: Output continuous monitoring results containing a unique ID, behavior category, and motion trajectory;
[0118] S45: Complete the statistics of behavior duration, time period patterns, and environmental impact analysis.
[0119] like Figure 8 As shown in the figure, this invention provides a method for monitoring the behavior of group-raised pigs oriented towards individuals. The method includes:
[0120] The dataset building module is used to collect overhead monitoring videos of pig farms and build pig behavior detection datasets and pig multi-target tracking datasets.
[0121] The behavior detection module is used to improve the YOLO11 behavior detection model and outputs the bounding box and behavior category for each pig.
[0122] The behavior tracking module is used to optimize the StrongSORT algorithm to receive the above detection results and complete the association of individual IDs and trajectory maintenance, and finally output the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration.
[0123] Evidence related to the technical effects obtained by the embodiments of the present invention.
[0124] This invention improves detection accuracy, and the improved YOLO11 significantly reduces false negatives / false positives in densely occluded scenarios, with an mAP50 of 99.1%.
[0125] This invention proposes three key optimization strategies based on the YOLO11 model and conducts ablation experiments using a pig behavior detection dataset to verify the effectiveness of the three improvements. The relevant experimental results are shown in Table 1. First, this invention introduces grouped convolution technology into the C3K2 module to construct an improved C3K2-I module. Experimental data shows that after adopting the C3K2-I module, the model's mAP50 increases from 96.6% to 97.8%, and mAP50-90 increases from 85.6% to 86.2%; GFLOPs decrease from 21.3 to 18.2, and the number of parameters decreases from 9.41M to 7.92M. This improvement scheme can effectively reduce the model's computational load while enhancing the model's ability to extract and represent pig behavioral features in densely occluded scenarios. Second, this invention optimizes the feature splicing structure, proposing the Concat-I improved module. Experimental results show that after adding the Concat-I module, the model's mAP50 further improves to 98.4%, mAP50-90 to 87.1%, and the GFLOPs and parameter count are 20.6 and 8.92M, respectively. Compared to using the C3K2-I module alone, this structure, although slightly increasing computational overhead, significantly enhances the model's multi-scale feature fusion capability and effectively improves target recognition performance in complex occlusion environments. Finally, this invention combines the improved C3K2-I module and the optimized Concat-I module to upgrade the overall structure of the Neck network, building the optimized Neck-I module. Experiments demonstrate that after integrating the Neck-I module, the model's overall performance reaches the optimal level, with mAP50 increasing to 99.1%, mAP50-90 to 87.7%, GFLOPs at 20.7, and parameter count at 8.95M. Compared to the original YOLO11 model, the optimized detection model of this invention maintains high-efficiency operation while significantly improving accuracy, achieving a reasonable balance between detection and recognition accuracy and computational resource consumption.
[0126] Table 1 YOLO11 Ablation Test
[0127] Model mAP50-90 mAP50 GFLOPs Params YOLO11 85.6 96.6 21.3 9.41M YOLO11 + C3K2-I 86.2 97.8 18.2 7.92M YOLO11 + C3K2-I + Concat-l 87.1 98.4 20.6 8.92M YOLO11 + C3K2-I + Concat-l + Neck-l 87.7 99.1 20.7 8.95M
[0128] This invention improves tracking stability and optimizes StrongSORT to reduce the number of identity switching times from 37 to 10, achieving a MOTA rate of 98.7%.
[0129] To verify the effectiveness of the improved method proposed in this invention, an ablation experiment was conducted based on a pig multi-target tracking dataset. The performance indicators of the optimized StrongSORT algorithm and the original StrongSORT algorithm were compared, and the experimental results are shown in Table 2. The experimental data shows that the improved StrongSORT algorithm of this invention achieves significant improvements in multiple core evaluation indicators for target tracking. The multi-target tracking accuracy (MOTA) increased from 86.70% to 98.70%, significantly improving overall tracking accuracy; the identity switching count (IDSW) decreased from 37 times to 10 times, significantly enhancing the stability of individual identity association in complex group-house scenarios; and the identity recognition F1 score (IDF1) increased by 7.8 percentage points to 95.70%, effectively improving the accuracy of individual identity matching. In summary, the ablation experiment results confirm that the algorithm optimization strategy adopted in this invention can comprehensively improve the overall performance of multi-target tracking, effectively solving the problems of trajectory breakage and identity confusion caused by dense occlusion and similar appearance of pigs, fully demonstrating the effectiveness and rationality of this improved scheme in suppressing identity switching and strengthening identity matching capabilities.
[0130] Table 2 StrongSORT Ablation Experiment
[0131] Model MOTA (%) IDSW IDF1(%) FPS Improved StrongSORT 98.70 10 95.70 27 StrongSORT 86.70 37 87.90 32
[0132] T
[0133] It enables truly individual-level continuous, accurate, and ongoing monitoring, ensuring that each pig's ID remains unchanged and that behavioral data is complete and traceable.
[0134] A schematic diagram illustrating the effect of continuous behavior monitoring of individual pigs in group farming is shown below. Figure 9 As shown.
[0135] To investigate the impact of temperature on pig behavior patterns, this invention utilizes the YOLO11-StrongSORT dual-network framework to conduct long-term behavioral monitoring of group-housed pigs. Three representative time periods (7:30–8:30 AM, 12:30–1:30 PM, and 4:30–5:30 PM) in September (when daily temperature variations were significant) of a large-scale pig farm in Wuhan were selected for analysis. Figure 10 shows the statistical results of pig behavior at each time period. This invention retains the original classifications of mounting and eating, while incorporating both into the statistics of standing behavior. The results show that during the midday high temperatures, the proportion of side-lying behavior in pigs significantly increased to dissipate heat and alleviate heat stress; when the morning and evening temperatures were suitable, standing, eating, and mounting behaviors significantly increased, reflecting a higher willingness to move. In summary, pig behavioral rhythms are regulated by temperature, and pigs maintain physiological homeostasis by adjusting their behavior.
[0136] Figure 11 shows the duration of five behaviors (lying on its side, lying prone, standing, mounting, and eating) for each pig within one hour before and after manure removal. The blue line represents before manure removal, and the yellow line represents after manure removal. Since standing is the basic posture for mounting and eating, this invention, while retaining the independent classification of each behavior, also includes it in the standing behavior statistics. The statistical results show that in the dirty and messy environment before manure removal, the overall activity level of the pig herd was low, the duration of resting behaviors (lying on its side and lying prone) increased, and the duration of eating and mounting behaviors decreased. After manure removal, the sanitary conditions improved, the activity level of the pigs increased, and the duration of standing, mounting, and eating behaviors increased significantly.
[0137] In the description of this invention, unless otherwise stated, "multiple" means two or more; the terms "upper," "lower," "left," "right," "inner," "outer," "front end," "rear end," "head," and "tail," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0138] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0139] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for monitoring the behavior of group-raised pigs oriented towards individuals, characterized in that, The method specifically includes: S1: Dataset construction, collecting overhead monitoring videos of pig farms, and constructing pig behavior detection datasets and pig multi-target tracking datasets; S2: Build an improved YOLO11 behavior detection model that includes an improved C3K2 module, an improved Concat module, and an improved Neck network; S3: Construct and optimize the StrongSORT behavior tracking algorithm; S4: Integrates the improved YOLO11 detection model and the optimized StrongSORT tracking algorithm to output end-to-end behavior monitoring results with IDs.
2. The method for monitoring group-housed pig behavior oriented towards individuals as described in claim 1, characterized in that, The step S1 includes: S11: Video capture, using a top-down camera installed 3m above the pigsty to capture 2560×1440 monitoring video, covering the entire pen, and capturing top-down monitoring video of the pig farm; S12: Construction of the behavior detection dataset, obtaining 7220 images by extracting frames from video; labeling bounding boxes for five behavior categories: standing, prone, side-lying, straddling, and eating; dividing the dataset into training / validation / test sets in an 8:1:1 ratio; format: YOLO format, used for model training; S13: Construction of a multi-object tracking dataset, using 4 segments × 30 minutes of continuous video; frame-by-frame annotation: pig bounding boxes + unique identification IDs; covering occlusion, intersection, and stacking scenes, used for tracking algorithm training and evaluation; S14: Convert the labeled data into the format required for model training.
3. The method for monitoring group-housed pig behavior oriented towards individuals as described in claim 1, characterized in that, The improved YOLO11 behavior detection model, as described in S1 and S2, includes: (1) C3K2 module introduces grouped convolution: replaces the Bottleneck structure inside C3K2 with grouped convolution; (2) Optimize the Concat feature fusion module: add Gaussian noise perturbation; use depthwise separable convolution for lightweight feature extraction; add adaptive dynamic weights to weightedly fuse features at different levels; (3) Reconstruct the Neck Network: Add an improved C3K2 module on the basis of the original PAN-FPN; insert an optimized Concat layer.
4. The method for monitoring group-housed pig behavior oriented towards individuals as described in claim 1, characterized in that, In steps S1 and S2, the model is constructed with an input size of 640×640, a batch size of 16, and an epoch of 100. The DFL loss function is used to optimize bounding box regression and behavior classification. The model outputs the bounding box and behavior category for each pig from the input video frames.
5. The method for monitoring group-housed pig behavior oriented towards individuals as described in claim 1, characterized in that, The steps S1 and S3 include: S31: Set a fixed group ID initialization strategy to determine the maximum number of individuals in the pigsty. Initialize all pig IDs at once in the first detection frame; record the maximum ID as the constant number of pigs in the pen; do not add new IDs in subsequent frames, only fill in the missing target IDs. S32: Add a Euclidean distance rematching module. After the original appearance and motion matching are completed, the unmatched trajectory boxes and detection boxes are matched again. Based on the Euclidean distance of the center point, the matching and ID supplementation are completed according to the relationship between the number of trajectories and the number of detections. The algorithm takes the detection boxes as input and outputs stable IDs, continuous trajectories and behavior categories. S33: Integrates appearance features, motion information, and spatial distance to achieve trajectory correlation; S34: Output a behavior tracking algorithm suitable for group pig farming scenarios.
6. The method for monitoring group-housed pig behavior oriented towards individuals as described in claim 1, characterized in that, S1 and S4 take overhead monitoring video as input, and output the target bounding box and behavior category of pigs frame by frame through the improved YOLO11 model. The optimized StrongSORT algorithm receives the above detection results and completes the individual ID association and trajectory maintenance. Finally, it outputs the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration. It can support long-term behavior statistics, behavior comparison at different time periods and behavior change analysis before and after manure cleaning.
7. A group-housed pig behavior monitoring system oriented towards individuals, characterized in that, include: The dataset building module is used to collect overhead monitoring videos of pig farms and build pig behavior detection datasets and pig multi-target tracking datasets; The behavior detection module is used to build an improved YOLO11 behavior detection model based on the pig behavior detection dataset. The improved YOLO11 behavior detection model includes an improved C3K2 module, an improved Concat module, and an improved Neck network, and outputs the bounding box and behavior category of each pig according to the input video frame. The behavior tracking module is used to build an optimized StrongSORT behavior tracking algorithm, which associates the bounding box with the behavior category and maintains the trajectory. The optimized StrongSORT behavior tracking algorithm includes a fixed group ID initialization strategy and a Euclidean distance rematching module. The monitoring result output module is used to integrate the improved YOLO11 behavior detection model and the optimized StrongSORT behavior tracking algorithm to output the unique ID of a single pig, real-time behavior category, continuous movement trajectory and behavior duration.
8. The individual-oriented group-housed pig behavior monitoring system as described in claim 7, characterized in that, The dataset construction module includes: The video acquisition unit uses a top-down camera installed 3 meters above the pigsty to capture monitoring video with a resolution of 2560 x 1440, covering the entire pigsty. The behavior detection dataset construction unit is used to extract 7220 images from the surveillance video, label the bounding boxes of five types of behaviors: standing, prone, side-lying, straddling, and eating, and divide the training set, validation set, and test set in an 8:1:1 ratio to form behavior detection data in YOLO format. The multi-target tracking dataset construction unit is used to annotate the bounding boxes and unique IDs of pigs frame by frame using four consecutive 30-minute video segments to form multi-target tracking data of pigs covering occlusion, intersection, and stacking scenarios; The format conversion unit is used to convert labeled data into the format required for model training.
9. The individual-oriented group-housed pig behavior monitoring system as described in claim 7, characterized in that, In the behavior detection module: The improved C3K2 module employs grouped convolutions within the Bottleneck structure inside C3K2; The improved Concat module is used to apply Gaussian noise perturbation during feature fusion, use depthwise separable convolution for lightweight feature extraction, and use adaptive dynamic weights to perform weighted fusion of features at different levels. The improved Neck network is based on the PAN-FPN structure and includes an improved C3K2 module and an improved Concat module. The behavior detection module uses a 640x640 input size, a batch size of 16, and 100 training rounds. It also employs the DFL loss function for bounding box regression and behavior classification optimization.
10. The individual-oriented group pig behavior monitoring system as described in claim 7, characterized in that, In the behavior tracking module: The fixed group ID initialization strategy is used to determine the maximum number of individuals in the pig house. All pig IDs are initialized at once in the first detection frame, and the maximum ID is recorded as the constant number of pigs in the pen. No new IDs are added in subsequent frames, and IDs are filled in for missed targets. The Euclidean distance rematching module is used to perform a second match on the unmatched trajectory boxes and detection boxes after appearance matching and motion matching are completed. The Euclidean distance of the center point is used as the matching basis, and the matching and ID supplementation allocation are completed according to the relationship between the number of trajectories and the number of detections. The behavior tracking module integrates appearance features, motion information, and spatial distance to correlate trajectories.