An automatic extraction method for the optical flow map of the tails of group - raised ewes
By positioning the tail in the flock and intercepting the optical flow map, the problem of difficult to identify the early estrus behavior of ewes in the group-raising environment is solved, timely detection of ewe estrus information is achieved, and the ewe conception rate and childbirth efficiency are improved.
Patent Information
- Application Number
- CN202411023675.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2044-07-29
AI Technical Summary
In a group breeding environment, it is difficult for the existing technology to timely identify the shaking behavior of ewes in the early stage of estrus, resulting in the inability to adjust the sheep in advance to wait for mating, which affects the ewe's conception rate and childbirth efficiency.
Through a computer vision-based method, deep learning algorithm is used to locate the tail position of the flock, and the tail optical flow map is intercepted on the optical flow map to obtain the tail motion information of the ewes, so as to detect the early estrus behavior of ewes.
Accurately identifying the shaking behavior of ewes in the early stage of estrus in complex breeding environments has improved the ewe's conception rate and production efficiency, and saved manual operation costs.
Smart Images

Figure CN119006533B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent breeding of group sheep, and specifically relates to a method for positioning the tails of group sheep using computer vision and deep learning technologies and intercepting the optical flow maps of the tails of group sheep using tolerance extension technology. Background Art
[0002] When ewes enter the pre-estrus period, they start to show mental excitement, often walk around in the pen, wag their tails frequently, but do not accept the mounting of rams. When ewes enter the estrus period, they start to chase rams and often lean on rams with their necks or bodies. When the estrus is strong, they are willing to accept the mounting of rams. When ewes enter the post-estrus period, their spirits start to calm down and their appetites start to recover. Using computer vision technology to timely and accurately grasp the estrus information of ewes in a complex activity environment, enabling ewes to mate at the best conception time, can save labor operation costs, improve the conception rate of ewes, shorten the calving interval, and maximize the production efficiency of the sheep farm.
[0003] Currently, the detection methods for the estrus behavior of animals mainly detect the mounting behavior based on video frames. However, the appearance of the mounting behavior indicates that the ewe has entered the estrus period, and such methods cannot timely detect ewes in the pre-estrus period and adjust the sheep for mating. Therefore, it is very necessary to identify the tail-wagging behavior of ewes in the pre-estrus period in a complex activity environment. In a group breeding environment, group sheep often move around and have a large activity range. The tails of ewes are short and small, and the extraction of the characteristics of the tail-wagging behavior is also affected by the overall movement of the ewes. Therefore, it is very important to propose a method for using computer vision technology to locate the tail regions of all sheep in the group and simultaneously intercept the optical flow maps of the tails of all sheep on the optical flow map according to the positioning results, which is the basis for obtaining the tail movement information of ewes and detecting the tail-wagging behavior of ewes. Summary of the Invention
[0004] The present invention aims to solve the problem of how to locate the tail positions of group sheep based on the skeleton key point information and intercept the optical flow maps of the tails, so as to locate the tail positions of group sheep in a complex breeding environment and obtain the tail movement information of group sheep.
[0005] Technical Solution:
[0006] An automatic extraction method for the optical flow maps of the tails of group ewes, which includes the following steps:
[0007] S1. Collect the activity video data of multiple ewes in the sheep farm during the concentrated estrus months of ewes and preprocess the data to obtain the group sheep image dataset D;
[0008] S2. Build a group sheep body skeleton key point detection model based on the group sheep image dataset D;
[0009] S3. Collect video data, use the group sheep body skeleton key point detection model to obtain the sheep body target box coordinate information and sheep body skeleton key point coordinate information of each sheep, and perform tolerance expansion based on this information to calculate the tail coordinate information of each sheep;
[0010] S4. Convert the video RGB data into optical flow data, and intercept the tail optical flow map on the optical flow data according to the tail position coordinate information calculated in S3.
[0011] Preferably, S1 specifically includes:
[0012] S1-1. Use a camera to collect the group sheep activity video in the sheep pen from a side-down view;
[0013] S1-2. Perform frame splitting, screening, filtering and noise reduction, rotation and flipping operations on the collected group sheep video to construct the group sheep image dataset D.
[0014] Preferably, the group sheep body skeleton key point detection model in S2 is constructed using the YOLOv8-pose, DeepPose, Deeplabcut, RTMPose or HRNet algorithm.
[0015] As an implementation method, the construction steps of the group sheep body skeleton key point detection model in S2 specifically include:
[0016] S2-1. To obtain the tail map of the sheep, determine the sheep body skeleton key points to be extracted, including a total of 4 key points: H, B, T1, and T2. Among them: H is located at the skull position of the sheep body, B is located at the connection position of the thoracic vertebra and lumbar vertebra of the sheep body, T1 is located at the sacral bone position of the sheep body, and T2 is located at the end position of the caudal vertebra of the sheep body;
[0017] S2-2. Divide the group sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test according to a ratio of 8:2;
[0018] S2-3. Perform sheep body target box annotation on the training set D_train, draw a rectangular bounding box for each sheep in the group sheep image, the category is sheep, and mark the position of the sheep;
[0019] S2-4. Perform sheep body skeleton key point annotation inside each sheep body bounding box in the training set D_train, and mark the skull position H of the sheep body, the connection position B of the thoracic vertebra and lumbar vertebra of the sheep body, the sacral bone position T1 of the sheep body, and the end position T2 of the caudal vertebra of the sheep body;
[0020] S2-5. Generate a json file for each image file in the training set D_train, which contains the image file name, the target box coordinate position of each sheep, the name and coordinates of each key point inside the target box of each sheep;
[0021] S2-6. Select YOLOv8-pose to train the labeled training set D_train to obtain a group sheep body skeleton key point detection model;
[0022] S2-7. Input the D_test divided in S2-2 into the trained group sheep body skeleton key point detection model to evaluate the performance indicators of this model.
[0023] Preferably, S3 specifically includes:
[0024] S3-1. Collect video data, and use the group sheep body skeleton key point detection model to obtain the target box coordinate positions of each sheep in each frame, the names and coordinates of each key point within the target box of each sheep;
[0025] S3-2. Calculate the offsets of the target box of each sheep in the x and y directions for each frame;
[0026] S3-3. If the position T2 of the end of the tail vertebra of a sheep within the target box of a certain sheep is not detected during model detection, record the coordinate information of the position T2 of the end of the tail vertebra of this sheep in the previous frame;
[0027] S3-4. Perform tolerance expansion on the coordinate points of the end position of the tail vertebra of each sheep in each frame, and calculate its tail coordinate information:
[0028] (1) If the end of the tail vertebra of the sheep body is close to one or both of the left, right, upper, and lower boundary boxes of the sheep body target box, perform tolerance expansion in the other three or two directions of the end of the tail vertebra of the sheep body, and add the offsets in the x and y directions to the T2 coordinate point;
[0029] (2) If the end of the tail vertebra of the sheep body is in the middle of the sheep body target box, perform tolerance expansion in the four directions of the end of the tail vertebra of the sheep body, and add the offsets in the x and y directions to the T2 coordinate point.
[0030] Specifically, in S3-2, calculate the offset offset_x n,i and offset_y n,i of the target box of the i-th sheep in the n-th frame, and the calculation formula is as follows:
[0031] offset_x n,i = 1 / 5(x n,i,2 - x n,i,1 )
[0032] offset_y n,i = 1 / 5(y n,i,2 - y n,i,1 )
[0033] where, (x n,i,1 , y n,i,1(x n,i,2 , y n,i,2 ) is the upper left corner coordinate point of the target box of the i-th sheep in the n-th frame, and (x n,i,3 , y n,i,3 ) is the lower right corner coordinate point of the target box of the i-th sheep in the n-th frame. n,i,2 , y n,i,2 ) is the lower right corner coordinate point of the target box of the i-th sheep in the n-th frame.
[0034] Specifically, in S3-4, the coordinate point of the end position T2 of the tail vertebra of the sheep body within the target box of the i-th sheep is denoted as (x n,i,3 , y n,i,3 ). Calculating the tail coordinate information of the i-th sheep in the n-th frame includes: n,i,3 , y n,i,3 ).
[0035] (1) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,1 ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ); n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,1 ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ); n,i,1 , y n,i,1 ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i );
[0036] (2) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,2 ); n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,2 ); n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinate (x n,i,3 + offset_x n,i , y n,i,2 );
[0037] (3) If |x n,i,3 - x n,i,1 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,3 + offset_y n,i,3 - x n,i,1 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinate (x n,i,1 , y n,i,3 + offset_y n,i,1 , y n,i,3 + offset_yn,i )), the area enclosed by the rectangle with the lower - right corner coordinates of (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ));
[0038] (4) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i - th sheep in the n - th frame is the area enclosed by the rectangle with the upper - left corner coordinates of (x n,i,2 - offset_x n,i , y n,i,1 ) and the lower - right corner coordinates of (x n,i,2 , y n,i,3 - offset_y n,i );
[0039] (5) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i - th sheep in the n - th frame is the area enclosed by the rectangle with the upper - left corner coordinates of (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower - right corner coordinates of (x n,i,2 , y n,i,2 );
[0040] (6) If |x n,i,3 - x n,i,2 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i - th sheep in the n - th frame is the area enclosed by the rectangle with the upper - left corner coordinates of (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower - right corner coordinates of (x n,i,2 , y n,i,3 - offset_yn,i ) The area enclosed by the rectangle;
[0041] (7) If |x n,i,3 - x n,i,1 | > offset_x n,i , |x n,i,3 - x n,i,2 | > offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i And |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ).
[0042] Advantages of the present invention
[0043] The present invention applies the key point detection algorithm to the tail position positioning of a flock of sheep, realizes the determination of the position information of the tails of the flock of sheep in a complex breeding environment, and automatically locates and intercepts the tail block diagram of the flock of sheep in the optical flow map. The technology disclosed by the present invention facilitates the subsequent extraction of tail movement information in the tail optical flow map, provides technical support for the recognition of the tail wagging behavior of ewes in a group breeding environment based on computer vision, and can help the breeding industry quickly and accurately master the estrus information of ewes, and has a wide application prospect in the field of intelligent technology for livestock breeding. Description of the drawings
[0044] Figure 1 is the overall flowchart of the method for positioning and intercepting the optical flow map of the tails of a flock of sheep according to the present invention.
[0045] Figure 2 is the distribution diagram of the key points of the sheep body skeleton features according to the present invention.
[0046] Figure 3 is the schematic diagram for determining the tail position by tolerance expansion according to the T2 coordinate point. Detailed implementation manners
[0047] The present invention will be further described below in conjunction with embodiments, but the protection scope of the present invention is not limited thereto:
[0048] The present invention will be further described below in conjunction with the accompanying drawings and embodiments. In the embodiments of the present invention, a method is provided for obtaining tail position information by tolerance expansion based on the detection results of key points of the group sheep skeleton, and intercepting the tail optical flow map of each sheep in the optical flow map. This method collects video data on-site and preprocesses it, uses a deep learning algorithm to extract the key points of the sheep body skeleton, obtains the coordinate points of the end position of the sheep's caudal vertebra through model inference, and finally performs tolerance expansion on the coordinate points of the end position of the sheep's caudal vertebra to achieve positioning and intercept the optical flow map of the group sheep's tail. The overall flowchart of this method is as shown in Figure 1 shown, and mainly includes the following steps (S1 to S4):
[0049] S1. Collect video data of multiple ewes during the concentrated estrus month in the sheep farm and preprocess the data;
[0050] S1-1. Use a camera to collect video of the group sheep in the sheep pen from a side-downward perspective;
[0051] S1-2. Perform operations such as frame splitting, screening, filtering and noise reduction, rotation and flipping on the collected group sheep video to construct a group sheep image dataset D;
[0052] S2. Construct a group sheep body skeleton key point detection model based on the group sheep image dataset D;
[0053] S2-1. To obtain the tail map of the sheep, determine the key points of the sheep body skeleton to be extracted, as shown in Figure 2 shown, including a total of 4 key points H, B, T1, and T2, where: H is located at the skull position of the sheep body, B is located at the connection position between the thoracic vertebra and the lumbar vertebra of the sheep body, T1 is located at the sacral position of the sheep body, and T2 is located at the end position of the sheep's caudal vertebra;
[0054] S2-2. Divide the group sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test according to a ratio of 8:2;
[0055] S2-3. Perform sheep body target box annotation on the training set D_train, draw a rectangular bounding box for each sheep in the group sheep image, the category is sheep, and mark the position of the sheep;
[0056] S2-4. Perform sheep body skeleton key point annotation within each sheep body bounding box in the training set D_train, and mark the skull position H of the sheep body, the connection position B between the thoracic vertebra and the lumbar vertebra of the sheep body, the sacral position T1 of the sheep body, and the end position T2 of the sheep's caudal vertebra;
[0057] S2-5. Generate a json file for each image file in the training set D_train, which includes the image file name, the upper left coordinate point (x i,1 , y i,1 ) and the lower right coordinate point (xi,2 , y i,2 ), the name coordinates (x of each key point within the target bounding box of the i-th sheep i,j , y i,j ), j = 3, 4, 5, 6;
[0058] S2 - 6. Select YOLOv8 - pose to train the labeled training set D_train to obtain a group sheep body skeleton key point detection model;
[0059] S2 - 7. Input the D_test partitioned in S2 - 2 into the trained group sheep body skeleton key point detection model to evaluate the performance metrics of this model;
[0060] S3. Collect video data, infer the collected video data according to the trained model, obtain the sheep body target bounding box coordinate information and the sheep body tail vertebra end key point coordinate information of each sheep, and perform tolerance expansion based on this information to calculate the tail coordinate information of each sheep. The schematic diagram of tolerance expansion is as Figure 3 shown. The black bounding box is the sheep body target bounding box, and the red bounding box is the tail position intercepted after tolerance expansion;
[0061] S3 - 1. Infer that the upper - left - corner coordinate point of the target bounding box of the i-th sheep in the n-th frame of the video is (x n,i,1 , y n,i,1 ) and the lower - right - corner coordinate point is (x n,i,2 , y n,i,2 ), and the coordinate point of the position T2 of the end of the sheep body tail vertebra within the target bounding box of the i-th sheep is (x n,i,3 , y n,i,3 );
[0062] S3 - 2. Calculate the offset offset_x n,i and offset_y n,i of the target bounding box of the i-th sheep in the n-th frame. The calculation formula is as follows
[0063] offset_x n,i = 1 / 5(x n,i,2 - x n,i,1 )
[0064] offset_y n,i = 1 / 5(y n,i,2 - y n,i,1 )
[0065] S3 - 3. If the position T2 of the end of the sheep body tail vertebra within the target bounding box of the i-th sheep in the n-th frame is not detected during model inference, then
[0066] x n, i ,3 = x n-1, i ,3
[0067] y n, i ,3 = y n-1, i ,3
[0068] S3-4. Calculate the tail coordinate information of the i-th sheep in the n-th frame.
[0069] (1) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,1 , y n,i,1 ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ).
[0070] (2) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,2 ).
[0071] (3) If |x n,i,3 - x n,i,1 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,3 + offset_x n,i,y n,i,3 - offset_y n,i ) The area enclosed by the rectangle;
[0072] (4) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by a rectangle with the upper left corner coordinates (x n,i,2 - offset_x n,i , y n,i,1 ) and the lower right corner coordinates (x n,i,2 , y n,i,3 - offset_y n,i ) The area enclosed by the rectangle;
[0073] (5) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by a rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,2 , y n,i,2 ) The area enclosed by the rectangle;
[0074] (6) If |x n,i,3 - x n,i,2 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by a rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,2 , y n,i,3 - offset_y n,i ) The area enclosed by the rectangle;
[0075] (7) If |x n,i,3 -x n,i,1 | > offset_x n,i , |x n,i,3 -x n,i,2 | > offset_x n,i , |y n,i,3 -y n,i,1 | > offset_y n,i and |y n,i,3 -y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left coordinate (x n,i,3 -offset_x n,i , y n,i,3 +offset_y n,i ) and the lower right coordinate (x n,i,3 +offset_x n,i , y n,i,3 -offset_y n,i );
[0076] S4. Convert the video RGB data into optical flow data, and intercept the tail optical flow map on the optical flow data according to the tail position coordinate information calculated in S3.
[0077] Preferably, in this embodiment, YOLOv8-pose is used as the key point detection algorithm, and it can also be replaced by other key point detection algorithms, including but not limited to DeepPose, Deeplabcut, RTMPose, HRNet, etc. In this embodiment, the optimal solution is selected by comparing with the existing data.
[0078] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.
[0079] The specific embodiments described herein are merely illustrative of the spirit of the present invention. Those skilled in the art of the present invention can make various modifications or supplements to the described specific embodiments or use similar methods to replace them, but will not deviate from the spirit of the present invention or exceed the scope defined by the appended claims.
Claims
1. An automatic extraction method for the optical flow diagram of the tails of group - raised ewes, characterized in that It includes the following steps: S1. Collect the activity video data of multiple ewes in the sheep farm during the concentrated estrus month of the ewes and preprocess the data to obtain the group sheep image dataset D; S2. Build a group sheep body skeleton key point detection model based on the group sheep image dataset D; S3. Collect video data, use the group sheep body skeleton key point detection model to obtain the coordinate information of the sheep body target box and the coordinate information of the sheep body skeleton key points of each sheep, and perform tolerance expansion according to this information to calculate the tail coordinate information of each sheep. S3 specifically includes: S3-1. Collect video data, and use the group sheep body skeleton key point detection model to obtain the coordinate position of the target box of each sheep in each frame, the name and coordinates of each key point in the target box of each sheep; S3-2. Calculate the offsets offset_x n,i and offset_y n,i of the target bounding box of the i-th sheep in the n-th frame. The calculation formula is as follows: offset_x n,i =1 / 5(x n,i,2 - x n,i,1 ) offset_y n,i =1 / 5(y n,i,1 - y n,i,2 ) Among them, (x n,i,1 , y n,i,1 ) is the upper left coordinate point of the target box of the i-th sheep in the n-th frame, and (x n,i,2 , y n,i,2 ) is the lower right coordinate point of the target box of the i-th sheep in the n-th frame; S3-3. If the position T2 of the end of the sheep's tail vertebra in the target box of a certain sheep in a certain frame is not detected during model detection, record it as the coordinate information of the position T2 of the end of the tail vertebra of this sheep in the previous frame; S3-4. Perform tolerance expansion on the coordinate points of the end position of the sheep's tail vertebra of each sheep in each frame, and calculate its tail coordinate information: (1) If the end of the sheep's tail vertebra is close to one or two of the left, right, upper, and lower boundary boxes of the sheep body target box, perform tolerance expansion in the other three or two directions of the end of the sheep's tail vertebra, and add offsets in the x and y directions to the T2 coordinate point; (2) If the end of the sheep's tail vertebra is in the middle of the sheep body target box, perform tolerance expansion in the four directions of the end of the sheep's tail vertebra, and add offsets in the x and y directions to the T2 coordinate point; In S3-4, the coordinate point of the position T2 at the end of the caudal vertebra of the sheep body within the target bounding box of the $i$-th sheep is denoted as $(x n,i,3 , y n,i,3 ). Calculating the tail coordinate information of the $i$-th sheep in the $n$-th frame includes: (1) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,1 , y n,i,1 ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,3 -offset_y n,i ); (2) If |x n,i,3 - x n,i,1 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,2 ); (3) If |x n,i,3 - x n,i,1 | < offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left coordinate (x n,i,1 , y n,i,3 + offset_y n,i ) and the lower right coordinate (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ); (4) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,1 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,1 ) and the lower right corner coordinates (x n,i,2 , y n,i,3 - offset_y n,i ); (5) If |x n,i,3 - x n,i,2 | < offset_x n,i , and |y n,i,3 - y n,i,2 | < offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,2 , y n,i,2 ); (6) If |x n,i,3 - x n,i,2 | < offset_x n,i , |y n,i,3 -y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,3 -offset_x n,i , y n,i,3 +offset_y n,i ) and the lower right corner coordinates (x n,i,2 , y n,i,3 - offset_y n,i ). (7) If |x n,i,3 - x n,i,1 | > offset_x n,i , |x n,i,3 - x n,i,2 | > offset_x n,i , |y n,i,3 - y n,i,1 | > offset_y n,i and |y n,i,3 - y n,i,2 | > offset_y n,i , then the tail of the i-th sheep in the n-th frame is the area enclosed by the rectangle with the upper left corner coordinates (x n,i,3 - offset_x n,i , y n,i,3 + offset_y n,i ) and the lower right corner coordinates (x n,i,3 + offset_x n,i , y n,i,3 - offset_y n,i ). S4. Convert the video RGB data into optical flow data, and intercept the tail optical flow map on the optical flow data according to the tail position coordinate information calculated in S3.
2. The method according to claim 1, wherein S1 specifically includes: S1-1. Use a camera to collect the activity video of the group sheep in the sheep pen from a side-down view; S1-2. Perform frame division, screening, filtering and noise reduction, rotation and flipping operations on the collected group sheep video to construct the group sheep image dataset D.
3. The method according to claim 1, wherein The group sheep body skeleton key point detection model described in S2 is constructed using the YOLOv8-pose, DeepPose, Deeplabcut, RTMPose or HRNet algorithm.
4. The method according to claim 3, wherein The construction steps of the group sheep body skeleton key point detection model described in S2 specifically include: S2-1. To obtain the tail map of the sheep, determine the key points of the sheep body skeleton to be extracted, including a total of 4 key points: H, B, T1, and T2. Among them: H is located at the position of the sheep's skull, B is located at the connection position of the thoracic vertebra and lumbar vertebra of the sheep, T1 is located at the position of the sheep's sacrum, and T2 is located at the end position of the sheep's tail vertebra; S2-2. Divide the group sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test according to a ratio of 8:2; S2-3. Perform sheep body target box annotation on the training set D_train, draw a rectangular boundary box for each sheep in the group sheep image, the category is sheep, and mark the position of the sheep; S2-4. Perform annotation of the key points of the sheep body skeleton within each sheep body bounding box in the training set D_train, marking the position H of the sheep's skull, the position B where the thoracic vertebra and lumbar vertebra of the sheep are connected, the position T1 of the sheep's sacrum, and the position T2 of the end of the sheep's caudal vertebra; S2-5. Generate a json file for each image file in the training set D_train, including the image file name, the coordinate positions of the target boxes for each sheep, and the names and coordinates of the key points within each target box of each sheep; S2-6. Select YOLOv8-pose to train the well-annotated training set D_train to obtain a group sheep body skeleton key point detection model; S2-7. Input the D_test divided in S2-2 into the trained group sheep body skeleton key point detection model to evaluate the performance indicators of this model.
Citation Information
Patent Citations
Pig behavior recognition method and device, electronic equipment and storage medium
CN112215107A
Calculation method for single-time sow lactation duration based on computer vision
CN114677614A
Ewe oestrus detection device and method
CN117136873A
Method for automatically detecting ideal standing posture of sheep based on computer vision
CN117576733A