Activity calculation method for piglets in suckling period

Through deep learning and multi-objective tracking technology, accurate tracking and motion analysis of lactation piglets is achieved, and the problems of low monitoring efficiency and high cost in the existing technology are solved, and a rapid and accurate assessment of piglet legs is provided.

CN119785381AActive Publication Date: 2025-04-08NANJING AGRICULTURAL UNIVERSITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411852031.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-08
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

The prior art is inefficient in monitoring the leg robustness of lactation piglets, and has problems of observation deviation and high economic costs.

Method used

Deep learning technology and multi-objective tracking technology are adopted to train the object detection model YOLO_v8 through video data acquisition and preprocessing. Combined with the multi-objective tracking model, the position tracking and motion trajectory analysis of piglets is realized, and their activity volume and motion speed are calculated.

Benefits of technology

It realizes rapid and accurate tracking of piglets in complex bed environments, assesses their leg robustness, improves monitoring efficiency, reduces costs, and provides an accurate assessment of piglet health.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119785381A_ABST
    Figure CN119785381A_ABST
Patent Text Reader

Abstract

The invention discloses a method for calculating the activity amount of piglets in the lactation period, and belongs to the technical field of intelligent pig breeding. The method comprises the following steps: acquiring video data of an obstetric table for pigs in a pig farm from the day of postpartum sow to 28 days of postpartum sow, and preprocessing the data; training a target detection deep learning model YOLOv8 to obtain a piglet target detection frame; designing a multi-target tracking model, and associating the trajectory and detection of the piglets; inputting the piglet video into a target detection model and a multi-target tracking model, and obtaining the position and the movement track of a piglet target; and calculating the activity amount and the movement speed of the piglet according to the movement track. According to the invention, a computer vision technology is utilized to automatically track the piglets in the suckling period in a low-cost and non-contact manner and calculate the activity amount of individuals and groups, so that farmers can timely and accurately master the activity information of the piglets in a complex obstetric table environment, and the method accords with the animal welfare idea and the requirements of the precise livestock breeding industry; and a foundation is laid for the research of measuring the leg robustness of the piglet through the activity amount.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of intelligent pig breeding, and specifically is a method for locating and tracking suckling piglets by using deep learning technology and multi-target tracking technology and calculating the activity amount according to the movement trajectory of the piglets. Background Art

[0002] In large-scale commercial pig farms, in order to reduce the probability of newborn piglets being crushed to death by postpartum sows, they are usually confined in stalls before and after farrowing. However, when piglets have a certain degree of leg strength to avoid being crushed by sows, in order to improve the welfare of sows and ensure their health during lactation, the stalls should be opened to allow sows to move freely.

[0003] At present, the monitoring of the robustness of suckling piglets mainly relies on manual observation and the experience of breeders, which is not only time-consuming and labor-intensive, but also inefficient and may have observation bias. With the development of radio frequency identification technology, some large-scale pig farms use electronic ear tags to identify piglets and track targets to obtain their movement information. However, the installation of electronic ear tags is prone to cause short-term stress reactions in piglets, and external readers are required to identify the target identity, which has a high economic cost. There are still some problems with implantable devices. Therefore, driven by the concept of welfare breeding and the needs of precision animal husbandry industry, it is of great practical significance to use computer vision technology to automatically track piglets and evaluate leg robustness in a low-cost and contactless manner. The daily movement of piglets under natural conditions is an important basis for the analysis of piglet leg robustness. Kinematics shows that piglets with poor leg robustness are likely to have problems such as low walking speed, short walking stride, and long standing time for a long time. Therefore, it is very important to propose a method for locating and tracking suckling piglets using multi-target tracking technology, and calculating the activity and movement speed according to the piglet movement trajectory, which is the basis for measuring the robustness of piglet legs. Summary of the invention

[0004] Calculating the activity and speed of piglets is the basic premise for measuring the robustness of piglet legs. A method is needed to detect and track piglets in a complex farrowing bed environment, so as to obtain the location information and movement trajectory of piglets, and calculate the activity and speed of individual piglets and groups of piglets. The present invention aims to solve the problem of how to locate and track piglets and calculate their activity using multi-target tracking technology.

[0005] Technical solution:

[0006] To solve the above problems, the present invention proposes a method for locating and tracking suckling piglets using multi-target tracking technology, and calculating the activity amount and movement speed according to the piglet movement trajectory, which specifically includes the following steps:

[0007] S1. Collect video data of pig farrowing beds in pig farms from the day after farrowing to 28 days after farrowing and pre-process the data;

[0008] S1-1, using a camera to collect activity videos of piglets in the farrowing bed from a bird's-eye view;

[0009] S1-2, perform frame segmentation, cleaning, screening, noise reduction, image enhancement and other operations on the collected piglet videos to construct a piglet image dataset D1;

[0010] S1-3, intercepting piglet video clips and constructing piglet video dataset D2;

[0011] S2. Train the target detection deep learning model YOLO_v8 to obtain the target detection frame of the suckling piglet;

[0012] S2-1, dividing the piglet image dataset D obtained in step S1 into a training set D1_train, a validation set D1_valid and a test set D1_test in a ratio of 8:1:1;

[0013] S2-2, perform individual target box annotation for the training set D1_train, the validation set D1_valid, and the test set D1_test, draw a rectangular bounding box for each piglet in the piglet image, with the category of piglet, and mark the position of the piglet;

[0014] S2-3. Generate a txt file with the corresponding image name for each annotated image file, including the target category, the coordinates of the upper left corner of the annotation box (x GT ,y GT ), the width of the label box is w GT and the height of the label box h GT , where x GT ,y GT 、w GT 、h GT All are normalized values;

[0015] S2-4. Use the YOLO_v8 model to train the labeled training set D1_train, and use the validation set D1_valid for verification to obtain the piglet target detection model;

[0016] S2-5, input the test set D1_test divided by S2-2 into the trained piglet target detection model to evaluate the performance indicators of this model;

[0017] S2-6. Use the trained piglet target detection model to identify the video frame and obtain the coordinates of the upper left corner of the suckling piglet target detection frame in the video frame (x tl ,y tl), the width w and height h of the detection frame, and calculate the center point coordinates (x center ,y center );

[0018] S3. Design a multi-target tracking model to associate trajectories and detections;

[0019] S3-1, use Kalman filter to estimate the target position and motion state;

[0020] S3-2, use Complete IoU Loss, i.e. CIoU, to calculate the position similarity between the detection box and the trajectory prediction box, and generate the similarity matrix M between the detection and the trajectory;

[0021] S3-3, using the Hungarian algorithm to match detections and trajectories according to the similarity matrix M, assigning ID numbers to the targets to form multiple tracking trajectories;

[0022] S4. Select the piglet video input target detection model and multi-target tracking model from the data set D2 to obtain the position and motion trajectory of the piglet target.

[0023] S4-1, input the piglet video frame by frame into the trained YOLO_v8 target detection model to obtain the target detection results, including the piglet target position and confidence information;

[0024] S4-2, input the detection results into the multi-target tracking model, and assign a unique identity number to each piglet;

[0025] S4-3, repeating steps S4-1 and S4-2 in subsequent frames until the video ends, and outputting the target tracking results to a txt file, including the frame number, the piglet target identity number and the piglet target position information;

[0026] S5. Calculate the piglet's activity volume and movement speed according to the movement trajectory;

[0027] S5-1, read the target tracking result txt file, according to the frame number t, the piglet target identity number i, the piglet target center point coordinates u, v;

[0028] S5-2. Calculate the total activity s of a single piglet in the video i and the total activity of all piglets, S;

[0029] S5-3. Calculate the movement speed p of a single piglet in the video i and the average movement speed P of all piglets in the video.

[0030] Beneficial effects of the present invention

[0031] The present invention applies a multi-target tracking algorithm to the tracking of piglets, realizes the identification and tracking of individual piglets in a complex delivery bed environment, and calculates the activity and movement speed based on the piglet's movement trajectory. The technology disclosed in the present invention provides technical support for the measurement of leg robustness of lactating piglets in a welfare delivery bed environment based on computer vision, which can help pig farmers quickly and accurately grasp the vitality level and health status of piglets, and has broad application prospects in the fields of precision breeding and smart animal husbandry. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 The present invention is an overall flow chart of the method for calculating the activity amount of lactating piglets based on multi-target tracking.

[0033] Figure 2 It is a flow chart of the multi-target tracking algorithm of the present invention.

[0034] Figure 3 This is a schematic diagram of some parameters of Complete IoU Loss of the present invention.

[0035] Figure 4 Schematic diagram of the visualization of the results of the multi-target tracking model of the present invention (the 0th frame, 100th frame, 200th frame, 300th frame, 400th frame and 500th frame of the test video respectively). DETAILED DESCRIPTION

[0036] The present invention is further described below in conjunction with the accompanying drawings and embodiments. In an embodiment of the present invention, a method is provided for locating and tracking lactating piglets using multi-target tracking technology, and calculating the amount of activity and movement speed based on the piglet's movement trajectory. The method collects video data on-site and performs preprocessing, uses a deep learning algorithm to obtain a piglet detection frame, obtains the piglet's movement trajectory through a multi-target tracking model, and calculates the amount of activity and movement speed of the piglet. The overall flow chart of the method is as follows Figure 1 As shown, it mainly includes the following steps (S1 to S4):

[0037] S1. Collect video data of pig farrowing beds in pig farms from the day after farrowing to 28 days after farrowing and pre-process the data;

[0038] S1-1, using a camera to collect activity videos of piglets in the farrowing bed from a bird's-eye view;

[0039] S1-2, perform frame segmentation, cleaning, screening, noise reduction, image enhancement and other operations on the collected piglet videos to construct a piglet image dataset D1;

[0040] S1-3, intercepting piglet video clips and constructing piglet video dataset D2;

[0041] S2. Train the target detection deep learning model YOLO_v8 to obtain the target detection frame of the suckling piglet;

[0042] S2-1, dividing the piglet image dataset D obtained in step S1 into a training set D1_train, a validation set D1_valid and a test set D1_test in a ratio of 8:1:1;

[0043] S2-2, perform individual target box annotation for the training set D1_train, the validation set D1_valid, and the test set D1_test, draw a rectangular bounding box for each piglet in the piglet image, with the category of piglet, and mark the position of the piglet;

[0044] S2-3. Generate a txt file with the corresponding image name for each annotated image file, including the target category, the coordinates of the upper left corner of the annotation box (x GT ,y GT ), the width of the label box is w GT and the height of the label box h GT , where x GT ,y GT 、w GT 、h GT All are normalized values;

[0045] S2-4. Use the YOLO_v8 model to train the labeled training set D1_train, and use the validation set D1_valid for verification to obtain the piglet target detection model;

[0046] S2-5, input the test set D1_test divided by S2-2 into the trained piglet target detection model to evaluate the performance indicators of this model;

[0047] S2-6. Use the trained piglet target detection model to identify the video frame and obtain the coordinates of the upper left corner of the suckling piglet target detection frame in the video frame (x tl ,y tl ), the width w and height h of the detection frame, and calculate the center point coordinates (x center ,y center ), the calculation formula is as follows:

[0048]

[0049] S3. Design a multi-target tracking model, associate trajectories and detections; combine Figure 2 , including:

[0050] S3-1, use Kalman filter to estimate the target position and motion state of the next frame;

[0051] S3-2, use Complete IoU Loss, i.e. CIoU, to calculate the position similarity between the detection box and the trajectory prediction box, and generate the detection and trajectory similarity matrix M. The CIoU calculation formula is as follows:

[0052]

[0053] Among them, Figure 3 As shown, d is the distance between the center points of the prediction box and the detection box, c is the diagonal distance between the minimum circumscribed rectangle of the prediction box and the detection box, and the correction factor Positive trade-off parameter

[0054] S3-3, using the Hungarian algorithm to match detections and trajectories according to the similarity matrix M, assigning ID numbers to the targets to form multiple tracking trajectories;

[0055] S4, select the piglet video input target detection model and multi-target tracking model from the data set D2 to obtain the position and motion trajectory of the piglet target;

[0056] S4-1, input the piglet video frame by frame into the trained YOLO_v8 target detection model to obtain the target detection results, including the piglet target position and confidence information;

[0057] S4-2, input the detection results into the multi-target tracking model, and assign a unique identity number to each piglet;

[0058] S4-3, repeating steps S4-1 and S4-2 in subsequent frames until the video ends, and outputting the target tracking results to a txt file, including the frame number, the piglet target identity number and the piglet target position information;

[0059] The results of the multi-target tracking model of the present invention are visualized as follows: Figure 4 As shown (the 0th frame, 100th frame, 200th frame, 300th frame, 400th frame and 500th frame of the test video respectively).

[0060] S5. Calculate the piglet's activity volume and movement speed according to the movement trajectory;

[0061] S5-1, read the target tracking result txt file, according to the frame number t, the piglet target identity number i, the piglet target center point coordinates u, v;

[0062] S5-2. Calculate the total activity s of a single piglet in the video i , the calculation formula is as follows:

[0063]

[0064] Where T represents the total number of video frames.

[0065] Calculate the total activity S of all piglets using the following formula:

[0066]

[0067] Where n is the total number of piglets in the video;

[0068] S5-3. Calculate the movement speed of a single piglet in the video and the average movement speed of all piglets in the video. The movement speed p of a single piglet in the video is i , the calculation formula is as follows:

[0069]

[0070] The average movement speed P of all piglets in the video is calculated as follows:

[0071]

[0072] Preferably, this embodiment uses YOLO_v8 as the target detection algorithm, which can also be replaced by other target detection algorithms, including but not limited to YOLO_v5, YOLO_v10, YOLOX and RT-DETR, etc. This embodiment compares and selects the best solution based on existing data.

[0073] Preferably, this embodiment uses Kalman filter and Hungarian algorithm to complete the association operation of the multi-target tracking algorithm, which can also be replaced by other modules and algorithms. This embodiment compares and selects the best solution based on existing data.

[0074] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for calculating the activity of lactating piglets, characterized in that It includes the following steps S1 to S5: S1, collecting image data of piglets on a pig delivery bed, and preprocessing the image data to obtain a piglet image dataset D1; S2. Obtain the optimal target detection deep learning model YOLO_v8; specifically including: S2-1, divide the piglet image dataset D1 into a training set D1_train, a validation set D1_valid and a test set D1_test; S2-2, perform individual target box annotation for the training set D1_train, the validation set D1_valid, and the test set D1_test, draw a rectangular bounding box for each piglet in the piglet image, with the category of piglet, and mark the position of the piglet; S2-3. Generate a txt file with the corresponding image name for each annotated image file, including the target category, the coordinates of the upper left corner of the annotation box (x GT ,y GT ), the width of the label box is w GT and the height of the label box h GT , where x GT ,y GT 、w GT 、h GT All are normalized values; S2-4. Use the YOLO_v8 model to train the labeled training set D1_train, and use the validation set D1_valid for verification to obtain the piglet target detection model; S2-5, input the test set D1_test divided by S2-2 into the trained piglet target detection model, evaluate the performance indicators of this model, and obtain the optimal target detection deep learning model YOLO_v8; S2-6, based on the optimal target detection deep learning model YOLO_v8, the input is the image data of the piglet, and the output is the coordinates of the upper left corner of the piglet target detection box (x tl ,y tl ), the width w and height h of the detection frame; calculate the center point coordinates (x center ,y center ); S3. Design a multi-target tracking model to associate trajectories and detections; S4. Obtain the video data of the piglets to be calculated, input the optimal target detection deep learning model YOLO_v8 and the multi-target tracking model frame by frame, and obtain the position and motion trajectory of the piglet target in each frame; S5. Calculate the piglet's activity volume and movement speed based on the movement trajectory.

2. The method according to claim 1, characterized in that In step S1, the image data is obtained by the following steps: S1-1. Use a camera to collect video data of pig farrowing beds from the day after farrowing to 28 days after farrowing in the pig farm; S1-2, dividing the collected piglet video data into frames to obtain piglet image data.

3. The method according to claim 1, characterized in that In the step S1, the preprocessing includes cleaning, screening, noise reduction, and image enhancement operations.

4. The method according to claim 1, characterized in that In step S2-6, the center point coordinates (x center ,y center ) is calculated as follows: Where: x center ,y center are the horizontal and vertical coordinates of the center point, respectively, tl ,y tl They are the horizontal and vertical coordinates of the upper left corner of the target detection box.

5. The method according to claim 1, characterized in that The step S3 specifically includes: S3-1, use Kalman filter to estimate the target position and motion state of the next frame; S3-2, use CIoU to calculate the position similarity between the detection box and the trajectory prediction box, and generate a detection and trajectory similarity matrix M, where the row of M represents the index of the detection box and the column of M represents the index of the trajectory prediction box; S3-3. Use the Hungarian algorithm to match detections and trajectories according to the similarity matrix M, assign ID numbers to the targets, and form multiple tracking trajectories.

6. The method according to claim 5, characterized in that In step S3-2, the CIoU calculation formula is as follows: Where d is the distance between the center points of the prediction box and the detection box, c is the diagonal distance between the minimum circumscribed rectangle of the prediction box and the detection box, and IoU is the intersection over union of the prediction box and the true box. CIoU uses the correction factor v to measure the aspect ratio of the real box and the predicted box aspect ratio The similarity of the correction factor v is calculated as follows: The positive trade-off parameter α is calculated as follows:

7. The method according to claim 1, characterized in that The step S4 specifically includes: S4-1, input the piglet video frame by frame into the optimal target detection deep learning model YOLO_v8, and obtain the target detection result, including the piglet target position and confidence information; S4-2, input the detection results into the multi-target tracking model, and assign a unique identity number to each piglet; S4-3, repeat steps S4-1 and S4-2 in subsequent frames until the video ends, and output the target tracking results to a txt file, including the frame number, piglet target identity number and piglet target position information.

8. The method according to claim 1, characterized in that The step S5 specifically includes: S5-1, read the target tracking result txt file, according to the frame number t, the piglet target identity number i, the piglet target center point coordinates u, v; S5-2. Calculate the total activity s of a single piglet in the video i and the total activity of all piglets, S; S5-3. Calculate the movement speed p of a single piglet in the video i and the average movement speed P of all piglets in the video.

9. The method according to claim 8, characterized in that: Calculate the total activity s of a single piglet in the video i , the calculation formula is as follows: Where T represents the total number of video frames; Calculate the total activity S of all piglets using the following formula: Where n is the total number of piglets in the video.

10. The method according to claim 8, characterized in that: The movement speed p of a single piglet in the video i , the calculation formula is as follows: The average movement speed P of all piglets in the video is calculated as follows:

Citation Information

Patent Citations

  • Lane-dividing vehicle automatic counting method based on YOLO V4 and DeepSORT

    CN112101433A

  • Method and system for accurately detecting animal individual health and storage medium

    CN113628253A

  • Suckling piglet multi-target tracking method based on long and short memory

    CN113947617A

  • Multi-target tracking and behavior statistics method for health-preserving pigs in group

    CN115830490A

  • Method for tracking pigs and detecting health status of pigs

    CN117218379A