Piglet group behavior pattern automatic monitoring method under sow posture conversion based on motion state driving
By establishing a spatiotemporal hierarchical matching strategy and multi-target tracking model driven by motion state, the problem of piglet behavior recognition in complex scenarios such as occlusion and crowding was solved, the accurate positioning and identification of piglet group behavior was achieved, and the safety of piglet healthy growth was improved.
Patent Information
- Application Number
- CN202510789297.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-26
AI Technical Summary
Existing behavior recognition methods have difficulty accurately locating targets in complex scenarios such as occlusion, crowding, target deformation, and mutual interference between individual targets in a group. They are also unable to effectively identify the gathering and dispersion behaviors of piglet groups, affecting the safe and healthy growth of piglets.
By establishing a spatiotemporal hierarchical matching strategy driven by motion state, a multi-target tracking model is used to obtain the center point position, motion displacement and appearance characteristics of the pigs. The hierarchical spatiotemporal matching algorithm is combined for identity association to obtain the pig trajectory information, and the group behavior discrimination features are constructed through the trajectory to identify the aggregation and dispersion behavior of piglets.
It can accurately locate targets in complex scenarios such as occlusion, crowding, and deformation, improve tracking accuracy, identify the gathering and dispersion behaviors of piglet groups, provide data support for the safe and healthy growth of piglets, and improve the accuracy of pig group behavior identification.
Smart Images

Figure CN120708277A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of smart animal husbandry, multi-target tracking and group behavior recognition, and in particular to a method for automatically monitoring the behavior patterns of piglets under sow posture conversion driven by motion state. Background Art
[0002] The gathering and dispersal behaviors of piglets in groups are a stress response to their external environment. For example, when a sow actively calls her piglets to nurse, they exhibit grouping behaviors. However, when nursing is interrupted and she leaves, the piglets disperse to avoid being crushed. These group gathering and dispersal behaviors are important indicators for maintaining stability and harmony within the pig herd and ensuring the safe and healthy growth of piglets. However, obtaining this information primarily relies on manual observation, which is time-consuming, labor-intensive, and prone to errors. Therefore, automated monitoring of piglet group stress behaviors is necessary and critical for promoting selective breeding programs in the pig industry.
[0003] Computer vision-based monitoring has been widely used for pig behavior monitoring due to its non-contact, cost-effective, convenient, and animal welfare-friendly advantages. However, because group stress behavior in piglets requires consistent judgment of individual behavior and is subject to interference from individuals and their behaviors, behavioral recognition using computer vision presents significant challenges. Consequently, research on the identification of piglet group gathering and dispersal behaviors is rare.
[0004] Multi-object tracking (MOT) technology can capture the target category, location, motion direction, and trajectory in video scenes, which is crucial for accurate behavior recognition. Recently, MOT has achieved excellent performance in pig behavior recognition. For example, Tu et al. used YOLOv5 to detect individual pig behaviors such as eating, standing, and walking, and then used the Byte method to track individual pig movements. Li et al. enhanced the detection network by integrating an efficient attention mechanism into the detection network, and then used the Byte algorithm to track the movement trajectory of individual pigs. Although these methods have demonstrated their advantages in target tracking and behavior recognition, they still have limitations in trajectory correlation and have difficulty locating targets in complex scenes such as occlusion, crowding, target deformation, and mutual interference between individual targets in a group.
[0005] In summary, the current behavior recognition methods are difficult to realize the gathering and dispersion behaviors of pig groups. There is an urgent need for a pig group behavior recognition method that can accurately locate targets in complex scenarios such as occlusion, crowding, target deformation, and mutual interference between individual targets in the group, obtain target individual motion information, and thereby identify group gathering and dispersion behaviors, providing data support for the safe and healthy growth of piglets. Summary of the Invention
[0006] The purpose of the present invention is to provide a method for automatically monitoring the behavior patterns of piglet groups under sow posture transitions driven by motion state, obtain piglet trajectories by establishing a spatiotemporal hierarchical matching strategy through the pig motion state, and obtain the piglet group aggregation and dispersion behavior categories by constructing group behavior discrimination features through the trajectory, providing decision support for the safe and healthy growth of piglets.
[0007] To achieve the above object, the present invention provides the following solutions:
[0008] A method for automatically monitoring the behavior patterns of piglets under sow posture transitions driven by motion state, comprising:
[0009] Videos of daily behavior of lactating sows and piglets are obtained and input into a preset multi-target tracking model to output the center point position, motion displacement, and appearance features of the pigs. The multi-target tracking model is trained based on a training set that includes videos of labeled pigs. The multi-target tracking model is constructed by adding an identity re-identification branch to a multi-target tracking framework based on point-based joint detection and embedding.
[0010] Based on the center point position, motion displacement and appearance characteristics of the pig, identity association is performed using a hierarchical spatiotemporal matching algorithm driven by motion state to obtain pig trajectory information;
[0011] Based on the pig trajectory information, the pig behavior category and the pig group behavior category are judged, and the correlation between sow posture conversion and pig group behavior category is analyzed to complete the pig group behavior pattern monitoring under sow posture conversion.
[0012] Optionally, the identity re-identification branch includes a 3×3 convolutional layer, a ReLU layer, and a 1×1 convolutional layer. The loss function used in the training of the identity re-identification branch is:
[0013]
[0014] Among them, Loss reid represents the loss of the identity re-identification branch, Represents the predicted behavior category, i represents the target piglet, N represents the total number of piglets, m represents the pig category, M represents the total number of pig categories, Indicates the real behavior category.
[0015] Optionally, the motion state-driven hierarchical spatiotemporal matching algorithm includes:
[0016] The first level of matching is used to calculate the distance between the center point of the pig in the current frame and the center points of all tracked pigs in the previous frame, and use a greedy algorithm to match the optimal ID. If the distance is greater than the diagonal of the pig bounding box in the current frame, it is marked as invalid.
[0017] The second level of matching is used when the number of matched pigs is not greater than the total number of pigs after the first level of matching. The unmatched detection boxes are matched with the remaining unmatched tracking tracks by calculating the spatiotemporal appearance similarity and using the Hungarian algorithm.
[0018] The third level of matching is used to match the unmatched detection frames with the remaining unmatched tracking tracks based on the detection frame scores when the number of matched pigs is not greater than the total number of pigs after the second level of matching.
[0019] Optionally, calculating the spatiotemporal appearance similarity includes:
[0020] AS = α × β × fea_id;
[0021] Among them, AS is the spatiotemporal appearance similarity, α=(tn i ) / n is the time series weight, which indicates the weight of the pig's disappearance time, t is the current frame number, n i is the frame number where the target pig is detected but not matched, n is the total number of video frames, β is the detection score, and fea_id is the appearance feature.
[0022] Optionally, matching the unmatched detection boxes with the remaining unmatched tracking tracks by using the detection box scores in the third-level matching includes:
[0023] The unmatched target pigs are divided according to the score threshold of the detection frame. If the detection frame score exceeds the score threshold, a new trajectory is assigned to the target pig; if it does not exceed the score threshold, the target pig's information is temporarily retained for a frame and matched according to the first-level matching method. If no match is found after a frame, the target pig is deleted.
[0024] Optionally, determining the pig behavior category and the pig group behavior category based on the pig trajectory information includes:
[0025] Calculating the distance and the difference between the distances based on the center points of the sow and the piglet, and making a first behavior judgment of the piglet based on the difference;
[0026] Calculating the movement direction of the piglet and the movement direction of the piglet relative to the sow based on the displacement of the piglet, and making a second behavior judgment of the piglet based on the movement direction of the piglet and the movement direction of the piglet relative to the sow;
[0027] Based on the results of the first and second behavioral judgments, the individual behavior of the piglets is obtained, and the group behavior of the piglets is statistically analyzed based on the individual behavior of the piglets.
[0028] Optionally, based on the first piglet behavior judgment result and the second piglet behavior judgment result, obtaining the individual piglet behavior includes:
[0029]
[0030] Among them, p_behavior i is the individual behavior of the i-th piglet, dist_label i is the first behavioral judgment result of the i-th piglet, ori_label i is the second behavior judgment result of the i-th piglet, where 0, 1, and 2 represent gathering behavior, dispersing behavior, and other behaviors, respectively.
[0031] Optionally, the distance and movement direction are calculated within a preset non-safe area, where the non-safe area is a circular range with the sow center point position as the center and the long side of the sow enclosing frame as the radius.
[0032] Optionally, analyzing the correlation between sow posture transitions and pig group behavior categories includes:
[0033] Counting the number of gathering and dispersion events of the piglet group when the sow transitions to an upward posture, wherein the upward posture transition refers to the transition of the sow's body position from low to high;
[0034] Counting the number of gathering and dispersion events of the piglet group when the sow transitions to a downward posture, wherein the downward posture transition refers to the transition of the sow's body position from high to low;
[0035] Based on the statistical results, the proportion of piglet aggregation and dispersion behaviors under different sow posture transitions was calculated, that is, the correlation coefficient of piglet group behavior to different sow posture transitions.
[0036] The beneficial effects of the present invention are:
[0037] The present invention establishes a spatiotemporal hierarchical matching strategy based on the pig's motion state to obtain piglet trajectories. It then constructs group behavior discrimination features based on the trajectories to identify the clustering and dispersing behavior of the piglets. This method can accurately locate targets in complex scenarios such as occlusion, crowding, target deformation, and mutual interference between individual targets in the group, obtain individual target motion information, and thereby identify clustering and dispersing behaviors. The present invention improves the tracking accuracy of deformable targets in dense and occluded environments. Furthermore, the clustering / dispersing stress behavior of piglets under different posture transitions with their sows is an important indicator for determining the harmonious, healthy, and stable growth of a pig group. This behavior recognition not only provides new ideas for group behavior recognition based on visual technology, but also provides data support for the healthy growth of pig groups. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 This is a flow chart of a method for automatically monitoring the behavior patterns of piglets in a group under sow posture transitions driven by motion state according to an embodiment of the present invention;
[0040] Figure 2 This is a flow chart of a motion state-driven hierarchical spatiotemporal matching algorithm according to an embodiment of the present invention;
[0041] Figure 3 This is a flowchart for distinguishing the gathering and dispersion stress behaviors of piglets under posture changes relative to the sow according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0043] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0044] This embodiment provides a method for automatically monitoring the behavior patterns of piglets in a group under sow posture transitions driven by motion state, comprising:
[0045] Videos of daily behavior of lactating sows and piglets are obtained and input into a preset multi-target tracking model to output the center point position, motion displacement, and appearance features of the pigs. The multi-target tracking model is trained based on a training set that includes videos of labeled pigs. The multi-target tracking model is constructed by adding an identity re-identification branch to a multi-target tracking framework based on point-based joint detection and embedding.
[0046] Based on the center point position, motion displacement and appearance characteristics of the pig, identity association is performed using a hierarchical spatiotemporal matching algorithm driven by motion state to obtain pig trajectory information;
[0047] Based on the pig trajectory information, the pig behavior category and the pig group behavior category are judged, and the correlation between the sow posture conversion and the pig group behavior category is analyzed to complete the pig group behavior pattern monitoring under the sow posture conversion.
[0048] Specifically, this embodiment establishes a spatiotemporal hierarchical matching strategy through the pig movement state to obtain the piglet trajectory, and then constructs the group behavior discrimination feature through the trajectory to obtain the piglet group gathering and dispersion behavior category. It can accurately locate the target in complex scenarios such as occlusion, crowding, target deformation, and mutual interference between individual targets in the group, obtain the target individual motion information, and thereby identify the group gathering and dispersion behavior.
[0049] Furthermore, the identity re-identification branch includes a 3×3 convolutional layer, a ReLU layer, and a 1×1 convolutional layer. The loss function used in the training of the identity re-identification branch is:
[0050]
[0051] Among them, Loss reid represents the loss of the identity re-identification branch, Represents the predicted behavior category, i represents the target piglet, N represents the total number of piglets, m represents the pig category, M represents the total number of pig categories, Indicates the real behavior category.
[0052] Furthermore, the motion state-driven hierarchical spatiotemporal matching algorithm includes:
[0053] The first level of matching is used to calculate the distance between the center point of the pig in the current frame and the center points of all tracked pigs in the previous frame, and use a greedy algorithm to match the optimal ID. If the distance is greater than the diagonal of the pig bounding box in the current frame, it is marked as invalid.
[0054] The second level of matching is used when the number of matched pigs is not greater than the total number of pigs after the first level of matching. The unmatched detection boxes are matched with the remaining unmatched tracking tracks by calculating the spatiotemporal appearance similarity and using the Hungarian algorithm.
[0055] The third level of matching is used to match the unmatched detection frames with the remaining unmatched tracking tracks based on the detection frame scores when the number of matched pigs is not greater than the total number of pigs after the second level of matching.
[0056] Furthermore, calculating the spatiotemporal appearance similarity includes:
[0057] AS = α × β × fea_id;
[0058] Among them, AS is the spatiotemporal appearance similarity, α=(tn i) / n is the time series weight, which indicates the weight of the pig's disappearance time, t is the current frame number, n i is the frame number where the target pig is detected but not matched, n is the total number of video frames, β is the detection score, and fea_id is the appearance feature.
[0059] Furthermore, matching the unmatched detection boxes with the remaining unmatched tracking tracks by using the detection box scores in the third-level matching includes:
[0060] The unmatched target pigs are divided according to the score threshold of the detection frame. If the detection frame score exceeds the score threshold, a new trajectory is assigned to the target pig; if it does not exceed the score threshold, the target pig's information is temporarily retained for a frame and matched according to the first-level matching method. If no match is found after a frame, the target pig is deleted.
[0061] Furthermore, judging the pig behavior category and the pig group behavior category based on the pig trajectory information includes:
[0062] Calculating the distance and the difference between the distances based on the center points of the sow and the piglet, and making a first behavior judgment of the piglet based on the difference;
[0063] Calculating the movement direction of the piglet and the movement direction of the piglet relative to the sow based on the displacement of the piglet, and making a second behavior judgment of the piglet based on the movement direction of the piglet and the movement direction of the piglet relative to the sow;
[0064] Based on the results of the first and second behavioral judgments, the individual behavior of the piglets is obtained, and the group behavior of the piglets is statistically analyzed based on the individual behavior of the piglets.
[0065] Furthermore, based on the first piglet behavior judgment result and the second piglet behavior judgment result, obtaining the individual piglet behavior includes:
[0066]
[0067] Among them, p_behavior i is the individual behavior of the i-th piglet, dist_label i is the first behavioral judgment result of the i-th piglet, ori_label i is the second behavior judgment result of the i-th piglet, where 0, 1, and 2 represent gathering behavior, dispersing behavior, and other behaviors, respectively.
[0068] Furthermore, the distance and the direction of movement are calculated within a preset non-safe area, where the non-safe area is a circular range with the sow center point as the center and the long side of the sow enclosing frame as the radius.
[0069] Further analysis of the correlation between sow posture transitions and pig group behavior categories includes:
[0070] Count the number of piglet gathering and dispersion events when the sow transitions to an upward posture, where the sow transitions to an upward posture refer to transitions from a low to a high position, such as from prone to standing, from prone to sitting, and from sitting to standing;
[0071] Count the number of piglet gathering and dispersion events when the sow transitions to a downward posture, where the sow transitions to a downward posture refer to transitions from a high to a low position, such as from standing to lying, from sitting to lying, from standing to sitting, etc.
[0072] Based on the statistical results, the proportion of piglet aggregation and dispersion behaviors under different sow posture transitions was calculated, that is, the correlation coefficient of piglet group behavior to different sow posture transitions.
[0073] Specifically, this embodiment improves the tracking accuracy of deformable targets in dense and occluded environments. At the same time, the gathering / dispersion stress behavior of piglets under different posture transitions of sows is an important indicator for judging the harmonious, healthy and stable growth of pig groups. This behavior recognition not only provides new ideas for group behavior recognition based on visual technology, but also provides data support for the healthy growth of pig groups. Figure 1 The present embodiment provides a method for automatically monitoring the behavior pattern of a group of piglets under sow posture transitions driven by motion state, which includes the following contents:
[0074] 1) Build and train a multi-target tracking model. Input the daily behavior video data of lactating sows and piglets into the preset multi-target tracking model to obtain the pig's center point, motion displacement, and appearance characteristics. The following steps are included:
[0075] 1.1. Constructing a multi-target tracking model is a multi-target tracking framework based on point joint detection and embedding. The network is based on anchor-free CenterNet and uses deep layer aggregation (DLA) as its backbone network. In addition, in addition to constructing the existing target detection branch and tracking branch, an identity re-identification (ReID) branch is also added. The Detection branch contains three small branches: Heatmap, Size, and Offset. Each branch is composed of a 3×3 convolution layer, a Relu layer, and a 1×1 convolution layer. The ReID branch is composed of a 3×3 convolution layer, a Relu layer, and a 1×1 convolution layer, and the number of output channels is set to 128. In order to obtain discriminative appearance features, the loss function of the ReID branch constructed in this embodiment sends the features output by the ReID branch to a softmax classifier for multi-target classification during the model training phase. The number of categories is the number of different pigs M, where M=12 represents the number of pigs in a pen. After the ReID features are input into the softmax classifier, a one-hot label is generated. i represents the target, m represents the category, and the ReID branch loss is constructed:
[0076]
[0077] in, Represents the predicted category, M represents the total number of categories, N represents the total number of piglets, represents the true category.
[0078] 1.2. Input the labeled video training set into the multi-target tracking model for training to obtain the optimal network parameters. When inputting the first frame, in addition to the first frame, the first frame needs to be Gaussian rendered to generate a heat map to be input into the network at the same time. After that, the input of the heat map uses the heat map output of the previous frame. In this embodiment, the training set is 80 overhead videos of lactating pigs, totaling 24,000 images. Each video contains 1 sow and 8-12 piglets, and the training set is collected from 8 pig pens. All video segments are 30 seconds long, with a frame rate of 5 frames per second, and the video image size is 1920×1080 and 960×540. The Adam optimization model is used for training, the number of input samples is 16 each time, the learning rate is 0.0001, the number of iterations is 120 times, and the input image size is set to 960×544.
[0079] 1.3. Input the test set data into the trained multi-target tracking model and output the target response heat map, center point offset, target size, tracking displacement and re-identification appearance features. In this embodiment, the test set consists of 30 videos of lactating pigs viewed from above, totaling 9,000 images. Each video contains 1 sow and 8-12 piglets, and the test set is collected from 3 pig pens. All video segments are 30 seconds long, with a frame rate of 5 frames per second, and the video image sizes are 1920×1080 and 960×540. The test set only outputs targets with target response values greater than 0.3 and their corresponding center offset, size, displacement and recognition appearance features.
[0080] 2) The pig's center point, motion displacement and appearance features are input into the hierarchical spatiotemporal matching algorithm based on motion state drive to perform identity association and obtain pig trajectory information. The matching process is as follows Figure 2 As shown, the following steps are included:
[0081] 2.1. By observing videos of daily lactating pig behavior, we determined the visual state of pig movement. When a pig is unobstructed and continuously appears in the video, it is easily detected and receives a high detection box score. When a pig is obscured by a sow or piglets, the pig's detection score is low or even undetected. When a pig reappears after being completely obscured, its ID is likely to change due to changes in position and appearance. Based on these three scenarios, the matching algorithm is divided into three levels to handle these three conditions: pre-occlusion (i.e., unobstructed), during occlusion (partially obscured), and reappearance (reappearing after being obscured).
[0082] 2.2. First-level matching: When pigs are detected continuously, ID matching can be performed based on the distance between the front and back center points of the pigs. In this embodiment, the Euclidean distance between the center point of the pig in the current frame and the center points of all tracked piglets in the previous frame is calculated. If the distance is greater than the diagonal of the piglet bounding box in the current frame, it is marked as invalid. Finally, the optimal ID is matched using a greedy algorithm.
[0083] 2.3. Second-level matching: When the pig reappears, its spatial position has changed, and it can be matched by appearance features. At that time, the longer the pig disappears, the greater the change in its appearance features. In addition, when the pig's posture changes or part of its body is blocked, the appearance features also change significantly. At this time, the detection frame score can reflect whether the body is blocked, motion blurred, or the posture changes, etc. Therefore, the present invention adopts a spatiotemporal weighted appearance similarity matching method. Before matching, first count whether the number of pigs that have been matched is greater than the total number of pigs. If not, the unmatched detection frames are matched with the remaining unmatched tracking tracks for the second level. The specific steps are as follows:
[0084] First, calculate the spatiotemporal appearance similarity AS:
[0085] AS = α × β × fea_id;
[0086] Where, α=(tn i ) / n is the time series weight, which represents the weight of the piglet disappearance time, t is the current frame number, n i is the frame number where the target is detected but not matched, n is the total number of video frames, in this embodiment n = 300. β represents the detection score, and fea_id represents the appearance feature.
[0087] Then, appearance similarity matching is performed using the Hungarian matching algorithm, and unmatched detection boxes enter the third level of matching.
[0088] 2.4. Third-level matching: After the first two levels of matching, the remaining unmatched pigs are mainly those whose appearance characteristics have changed dramatically when they disappeared and reappeared due to occlusion, motion blur, deformation, etc. This embodiment adopts a temporary retention and iterative processing strategy. The specific steps are as follows:
[0089] First, it is counted whether the number of matched pigs is greater than the total number of pigs. If not, the unmatched detection frames are matched with the remaining unmatched tracking tracks in the third layer.
[0090] Then, the unmatched targets are divided according to the score threshold. If the score is greater than the threshold of 80 points, a new trajectory is assigned to it. Otherwise, the target information is temporarily retained for 3 frames and matched according to the first-level matching method. If no match is found after 3 frames, the target is deleted.
[0091] Through the above steps, pig tracking is complete and the tracking trajectory is output. The tracking trajectory includes the center point coordinates, bounding box coordinates, identity ID, and displacement information of the pig target in each frame. The tracking results on the test set are shown in Table 1.
[0092] Table 1
[0093]
[0094] To identify piglets' stress responses to sow posture changes, in this example, 100 video clips of sow posture transitions were manually extracted, including 52 upward transitions, 32 downward transitions, and 14 tumbling transitions. These 100 video clips were then fed into the algorithm described above to obtain pig trajectory information.
[0095] 3) Construct the discriminant features of pig gathering and dispersing behaviors based on the trajectory information, and obtain the pig group gathering, dispersing and other behavior categories based on the dispersion / gathering ratio of individual pigs in the pig group. The gathering and dispersing stress behaviors of pigs under the posture transformation relative to the sow are closely related to the movement direction of the piglets and the distance between the piglets and the sow. This embodiment first realizes the discrimination of individual piglet behaviors based on these two features, and then discriminates the group gathering and dispersing stress behaviors based on the ratio of individual piglet behaviors in the whole group. The specific process is as follows: Figure 3 As shown, before identification, a circular area with the sow center point as the center and the long side of the sow bounding box as the radius is defined as a non-safe area. The individual and collective gathering and dispersal behaviors of piglets are identified within this area, including the following steps:
[0096] 3.1. Obtain the center point coordinates, bounding box coordinates, and displacement of the i-th piglet at time t from the multi-target tracking network;
[0097] 3.2. According to the coordinates of the sow and piglet center points, calculate the Euclidean distance between the sow center point and the piglet center point at time t, which is recorded as
[0098] 3.3. Calculate the distance between all piglets and the sow in the entire video frame sequence according to steps 3.1 and 3.2;
[0099] 3.4. Calculate the difference between the distance between piglet i and the sow. If more than 60% of the differences are negative, the distance of piglet i in the entire video is marked as dist_label. i =0; if more than 60% of the differences are positive, the distance label dist_label i =1; otherwise, mark dist_label i =2; 0, 1, 2 represent aggregation, dispersion and others respectively.
[0100] 3.5. Calculate the direction of movement of piglet i at time t based on its displacement.
[0101] 3.6. Calculate the direction of movement of the piglet relative to the sow. Specifically, obtain the coordinates of the highest and lowest points of the sow according to the coordinates of the sow's bounding box, and calculate the highest point of the piglet relative to the sow at time t according to the coordinates of the center point of piglet i. and the direction of the lowest point if Mark the direction of the current frame as 0; if The direction is marked as 1, and the opposite direction is marked as 2.
[0102] 3.7. Calculate the direction of movement of all piglets relative to the sow in the entire video frame sequence according to steps 3.5 and 3.6. If more than 60% of the direction labels of piglet i in the entire video are 0, mark its direction label in the entire video as ori_label i =0; if more than 60% of the directions are marked as 1, the direction mark ori_label i =1; otherwise mark ori_label i =2. 0, 1, 2 represent aggregation, dispersion and others respectively.
[0103] 3.8. Obtain the individual behavior of piglet i in the entire video:
[0104]
[0105] 3.9. Count the individual behaviors of all piglets in the entire video. If more than 50% of the individual behaviors of the piglets are marked as 0, the piglet group stress behavior is judged to be gathering; if more than 50% of the individual behaviors of the piglets are marked as 1, the piglet group stress behavior is judged to be dispersing; otherwise, it is other behaviors.
[0106] In this embodiment, in order to prevent the interference of non-active piglet movement caused by crowding, camera shaking, etc., the piglet movement information with a movement speed greater than 8 is used in the behavior discrimination calculation. The results of the piglet gathering and dispersing behavior recognition in 100 videos using the above method are shown in Table 2.
[0107] Table 2
[0108]
[0109]
[0110] 4) Exploring the correlation between piglet aggregation / dispersion behavior and sow posture transitions, including the following steps:
[0111] 4.1. Count the number of piglet gathering and dispersing behaviors during sow upward posture transitions (body-upward transitions, such as from prone to standing, from sitting to standing, etc.) and downward posture transitions (body-downward transitions, such as from standing to prone, from standing to sitting, etc.). In this example, among the 100 manually extracted video clips of sow posture transitions, there were 52 upward posture transitions, 32 downward posture transitions, and 14 rolling posture transitions.
[0112] 4.2. We calculated the proportion of piglet aggregation and dispersal behaviors during different sow posture transitions. This proportion served as the correlation coefficient for piglets' responses to different sow posture transitions. A higher correlation indicates a higher correlation, while a lower correlation indicates a lower correlation. This allowed us to explore the piglets' stress responses to sow posture transitions. Our calculations showed that when the sow performed an upward posture transition, piglets tended to disperse, with a correlation of 0.6. When the sow performed a downward posture transition, piglets tended to aggregate, with a correlation of 0.82. When the sow performed a rolling posture transition, piglets showed no clear preference.
[0113] Experimental results demonstrate that the proposed method can overcome certain issues of target loss and ID swapping caused by occlusion, crowding, and deformation. Furthermore, behavioral recognition results demonstrate the feasibility of the proposed method. This method can provide a method for acquiring pig movement information in actual piggeries, particularly offering new insights and methods for identifying group gathering and dispersal behaviors. This information can provide important data support for the harmonious, healthy, and stable growth of pig herds.
[0114] The embodiments described above are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by persons skilled in the art should fall within the scope of protection defined by the claims of the present invention.
Claims
1. A method for automatically monitoring the behavior pattern of piglets under sow posture transition based on motion state drive, characterized in that: include: Videos of daily behavior of lactating sows and piglets are obtained and input into a preset multi-target tracking model to output the center point position, motion displacement, and appearance features of the pigs. The multi-target tracking model is trained based on a training set that includes videos of labeled pigs. The multi-target tracking model is constructed by adding an identity re-identification branch to a multi-target tracking framework based on point-based joint detection and embedding. Based on the center point position, motion displacement and appearance characteristics of the pig, identity association is performed using a hierarchical spatiotemporal matching algorithm driven by motion state to obtain pig trajectory information; Based on the pig trajectory information, the pig behavior category and the pig group behavior category are judged, and the correlation between the sow posture conversion and the pig group behavior category is analyzed to complete the pig group behavior pattern monitoring under the sow posture conversion.
2. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 1 is characterized in that: The identity re-identification branch includes a 3×3 convolutional layer, a ReLU layer, and a 1×1 convolutional layer. The loss function used in the training of the identity re-identification branch is: Among them, Loss reid represents the loss of the identity re-identification branch, Represents the predicted behavior category, i represents the target piglet, N represents the total number of piglets, m represents the pig category, M represents the total number of pig categories, Indicates the real behavior category.
3. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 1 is characterized in that: The motion state-driven hierarchical spatiotemporal matching algorithm includes: The first level of matching is used to calculate the distance between the center point of the pig in the current frame and the center points of all tracked pigs in the previous frame, and use a greedy algorithm to match the optimal ID. If the distance is greater than the diagonal of the pig's bounding box in the current frame, it is marked as invalid. The second level of matching is used when the number of matched pigs is not greater than the total number of pigs after the first level of matching. The unmatched detection boxes are matched with the remaining unmatched tracking tracks by calculating the spatiotemporal appearance similarity and using the Hungarian algorithm. The third level of matching is used to match the unmatched detection frames with the remaining unmatched tracking tracks based on the detection frame scores when the number of matched pigs is not greater than the total number of pigs after the second level of matching.
4. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 3 is characterized in that: Calculating the spatiotemporal appearance similarity includes: AS = α × β × fea_id; Among them, AS is the spatiotemporal appearance similarity, α=(tn i ) / n is the time series weight, which indicates the weight of the pig's disappearance time, t is the current frame number, n i is the frame number where the target pig is detected but not matched, n is the total number of video frames, β is the detection score, and fea_id is the appearance feature.
5. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 3 is characterized in that: Matching the unmatched detection frames with the remaining unmatched tracking tracks by using the detection frame scores in the third level matching includes: The unmatched target pigs are divided according to the score threshold of the detection frame. If the detection frame score exceeds the score threshold, a new trajectory is assigned to the target pig; if it does not exceed the score threshold, the target pig's information is temporarily retained for a frame and matched according to the first-level matching method. If no match is found after a frame, the target pig is deleted.
6. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 1 is characterized in that: Determining the pig behavior category and the pig group behavior category based on the pig trajectory information includes: Calculating the distance and the difference between the distances based on the center points of the sow and the piglet, and making a first behavior judgment of the piglet based on the difference; Calculating the movement direction of the piglet and the movement direction of the piglet relative to the sow based on the displacement of the piglet, and making a second behavior judgment of the piglet based on the movement direction of the piglet and the movement direction of the piglet relative to the sow; Based on the results of the first and second behavioral judgments, the individual behavior of the piglets is obtained, and the group behavior of the piglets is statistically analyzed based on the individual behavior of the piglets.
7. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 6 is characterized in that: Based on the first and second piglet behavior judgment results, the individual piglet behaviors are obtained, including: Among them, p_behavior i is the individual behavior of the i-th piglet, dist_label i is the first behavioral judgment result of the i-th piglet, ori_label i is the second behavior judgment result of the i-th piglet, where 0, 1, and 2 represent gathering behavior, dispersing behavior, and other behaviors, respectively.
8. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 6 is characterized in that: The distance and movement direction are calculated within a preset non-safe area, where the non-safe area is a circular range with the sow center point as the center and the long side of the sow enclosing frame as the radius.
9. The method for automatically monitoring the behavior pattern of piglets under sow posture conversion based on motion state drive according to claim 1, characterized in that: Analyzing the correlation between sow posture transitions and pig behavior categories includes: Count the number of piglet group gathering and dispersion events when the sow switches to the upward posture, among which, The sow-up posture transition refers to the transition of the sow's body position from low to high; Count the number of piglet group gathering and dispersion events when the sow changes to the downward posture, among which, The sow-down posture transition refers to the transition of the sow's body position from high to low; Based on the statistical results, the proportion of piglet aggregation and dispersion behaviors under different sow posture transitions was calculated, that is, the correlation coefficient of piglet group behavior to different sow posture transitions.