Method for automatically extracting optical flow diagrams of tail parts of group-rearing female sheep

Through computer vision technology, positioning the tail in the flock and intercepting the optical flow map, the problem of obtaining the position and movement information of ewes in complex environments is solved, and the accurate detection of ewe estrus information is achieved, and the production efficiency of the sheep farm is improved. .

CN119006533AActive Publication Date: 2024-11-22NANJING AGRICULTURAL UNIVERSITY
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411023675.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-11-22
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

In a complex group breeding environment, it is difficult to accurately identify the tail wagging behavior of ewes in the early estrus. The existing technology cannot detect ewes in the early estrus in a timely manner, resulting in the inability to adjust the sheep in time to wait for mating, which affects the ewe's conception rate and childbirth rate of ewes benefit.

Method used

Through computer vision technology, the tail position of the flock is located based on the information of the skeleton key point, 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 achieve accurate detection of the ewe estrus information.

Benefits of technology

In a complex breeding environment, the accurate positioning of the tail position of the sheep and the acquisition of movement information is achieved, supporting the identification of ewe's tail wagging behavior, helping the breeding industry to quickly and accurately grasp the ewe's estrus information, and improving the conception rate and childbirth efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006533A_ABST
    Figure CN119006533A_ABST
Patent Text Reader

Abstract

The invention provides a method for automatically extracting a tail optical flow diagram of group-rearing female sheep, and belongs to the technical field of group-rearing intelligent sheep rearing. The method mainly comprises the steps of collecting group breeding activity video data; identifying sheep and skeleton key points thereof in the sheep group by using a key point detection algorithm based on deep learning; performing tolerance expansion according to the identified position of the tail end of the tail vertebra of the sheep body in the target frame of the sheep body, and determining the tail position of each sheep; and calculating an optical flow diagram of the group raising activity data, and intercepting a tail optical flow diagram of the group sheep according to the tail position of each sheep. According to the method, the tail movement information of each ewe in the group raising environment can be acquired, the method is a basis for detecting the tail shaking behavior of the ewes, whether suspected estrus ewes exist in the group of ewes or not is detected, estrus information of the ewes in the complex activity environment can be conveniently, timely and accurately mastered by farmers, and the manual operation cost is saved.
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 sheep breeding, and specifically is a method for locating the tails of sheep by using computer vision and deep learning technology and intercepting the optical flow map of the tails of sheep by using tolerance expansion technology. Background Art

[0002] When the ewe enters the early estrus period, she begins to become excited, often walking around the pen and wagging her tail, but she does not accept the ram to mount her. When the ewe enters the estrus period, she begins to chase the ram, often leaning against the ram with her neck or body, and is willing to accept the ram to mount her when she is in strong estrus. When the ewe enters the late estrus period, her spirit begins to calm down and her appetite begins to recover. Using computer vision technology to timely and accurately grasp the estrus information of ewes in complex activity environments, so that ewes can mate at the best time for conception, can save labor operation costs, increase the conception rate of ewes, shorten the calving interval, and maximize the production efficiency of the sheep farm.

[0003] At present, the estrus behavior detection method of animals is mainly based on the detection of mounting behavior in video frames. However, the appearance of mounting behavior indicates that the ewe has entered the estrus period. Such methods cannot timely detect the ewes in the proestrus period and adjust the sheep to wait for mating. Therefore, it is necessary to identify the tail wagging behavior of ewes in the proestrus period in complex activity environments. In a group-raising environment, the flock of sheep often walks and has a large range of activities. The tail of the ewe is short and small. When extracting the characteristics of the tail wagging behavior, it is also affected by the overall movement of the ewe. Therefore, it is very important to propose a method to locate the tail area of ​​all sheep in the flock using computer vision technology, and at the same time, intercept the tail optical flow map of all sheep on the optical flow map according to the positioning results. This is the basis for obtaining the tail movement information of the ewe and detecting the tail wagging behavior of the ewe. Summary of the invention

[0004] The present invention aims to solve the problem of how to locate the tail position of a flock of sheep and intercept the tail optical flow map according to the skeleton key point information, so as to locate the tail position of a flock of sheep in a complex breeding environment and obtain the movement information of the tail of the flock of sheep.

[0005] Technical solution:

[0006] A method for automatically extracting an optical flow map of the tail of a group-raised ewe comprises the following steps:

[0007] S1. Collecting video data of multiple ewes' activities in a sheep farm during the concentrated estrus months and preprocessing the data to obtain a flock of sheep image dataset D;

[0008] S2, constructing a sheep skeleton key point detection model based on the sheep image dataset D;

[0009] S3, collecting video data, using the sheep skeleton key point detection model of the flock of sheep to obtain the sheep body target frame coordinate information and the sheep skeleton key point coordinate information of each sheep, and performing tolerance expansion based on this information to calculate the tail coordinate information of each sheep;

[0010] S4, converting the video RGB data into optical flow data, and intercepting the tail optical flow graph on the optical flow data according to the tail position coordinate information calculated in S3.

[0011] Preferably, S1 specifically includes:

[0012] S1-1, using a camera to collect a video of the sheep activities in the sheepfold from a side-down perspective;

[0013] S1-2, perform frame segmentation, screening, filtering, noise reduction, rotation and flipping operations on the collected sheep videos to construct a sheep image dataset D.

[0014] Preferably, the sheep group skeleton key point detection model in S2 is constructed using YOLOv8-pose, DeepPose, Deeplabcut, RTMPose or HRNet algorithm.

[0015] As an implementation manner, the steps of constructing the sheep skeleton key point detection model in S2 specifically include:

[0016] S2-1. To obtain the sheep's tail image, determine the sheep skeleton key points to be extracted, including four key points: H, B, T1, and T2. H is located at the sheep's skull, B is located at the connection between the thoracic and lumbar vertebrae, T1 is located at the sheep's sacrum, and T2 is located at the end of the sheep's coccyx.

[0017] S2-2, dividing the sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test in a ratio of 8:2;

[0018] S2-3, label the sheep body target box for the training set D_train, draw a rectangular bounding box for each sheep in the sheep group image, with the category of sheep, and mark the location of the sheep;

[0019] S2-4, marking the key points of the sheep skeleton in each sheep body bounding box in the training set D_train, marking the sheep skull position H, the sheep thoracic vertebrae and lumbar vertebrae connection position B, the sheep sacrum position T1, and the sheep coccygeal end position T2;

[0020] S2-5. Generate a json file for each image file in the training set D_train, which contains the image file name, the coordinate position of the target frame of each sheep, and the name and coordinates of each key point in the target frame of each sheep;

[0021] S2-6, select YOLOv8-pose to train the labeled training set D_train to obtain the sheep skeleton key point detection model;

[0022] S2-7. Input D_test divided in S2-2 into the trained sheep 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 sheep skeleton key point detection model to obtain the target frame coordinate position of each sheep in each frame, and the name and coordinates of each key point in the target frame of each sheep;

[0025] S3-2, calculating the offset of the target frame of each sheep in each frame in the x and y directions;

[0026] S3-3, if the tail vertebra end position T2 of a sheep in a certain frame is not detected in the target frame during model detection, the coordinate information of the tail vertebra end position T2 of the sheep in the previous frame is recorded;

[0027] S3-4. Perform tolerance expansion on the tail vertebrae end position coordinate point of each sheep in each frame, and calculate the tail coordinate information:

[0028] (1) If the end of the sheep's tail vertebrae is close to one or two of the left, right, upper and lower boundary boxes of the sheep's target box, then the tolerance is extended in the other three or two directions of the end of the sheep's tail vertebrae, and the offset in the x and y directions is increased at the T2 coordinate point;

[0029] (2) If the end of the sheep's tail vertebrae is located in the middle of the sheep's target frame, the four directions of the end of the sheep's tail vertebrae are extended with tolerance, and the offsets in the x and y directions are increased at the T2 coordinate point.

[0030] Specifically, in S3-2, the offset offset_x of the target frame of the i-th sheep in the n-th frame is calculated. n,i and offset_y n,i , 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] Among them, (x n,i,1 ,y n,i,1) is the coordinate point of the upper left corner of the target box of the ith sheep in the nth frame, (x n,i,2 ,y n,i,2 ) is the coordinate point of the lower right corner of the target box of the i-th sheep in the n-th frame.

[0034] Specifically, in S3-4, the coordinate point T2 of the tail vertebrae end position of the i-th sheep in the target frame is recorded as (x n,i,3 ,y n,i,3 ), calculate the tail coordinate information of the i-th sheep in the n-th frame including:

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,2 ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_yn,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,2 -offset_x n,i ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,2 ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_yn,i ) is 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area contained in the rectangle enclosed by .

[0042] Beneficial Effects of the Invention

[0043] The present invention applies the key point detection algorithm to the tail position positioning of the flock of sheep, realizes the determination of the position information of the tail of the flock of sheep in a complex breeding environment, and automatically locates and intercepts the tail frame diagram of the flock of sheep in the optical flow map. The technology disclosed in 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 shaking behavior of ewes in a group breeding environment based on computer vision, can help the breeding industry quickly and accurately grasp the estrus information of ewes, and has broad application prospects in the field of intelligent animal husbandry technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 The present invention is an overall flow chart of the method for locating and intercepting the optical flow map of the tail of a flock of sheep based on computer vision.

[0045] Figure 2 This is a distribution diagram of key points of sheep skeleton characteristics according to the present invention.

[0046] Figure 3 Schematic diagram of determining the tail position by tolerance extension based on the T2 coordinate point. DETAILED DESCRIPTION

[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 is further described below in conjunction with the accompanying drawings and embodiments. In an embodiment of the present invention, a method is provided for obtaining tail position information by performing tolerance expansion based on the key point detection results of the sheep skeleton, and intercepting the tail optical flow map of each sheep in the optical flow map. The method collects video data on-site and performs preprocessing, uses a deep learning algorithm to extract the key points of the sheep skeleton, obtains the coordinate points of the end position of the sheep's tail vertebrae through model reasoning, and finally performs tolerance expansion on the coordinates of the end position of the sheep's tail vertebrae to achieve positioning and intercept the optical flow map of the sheep's tail. The overall flow chart of the method is as follows: Figure 1 As shown, it mainly includes the following steps (S1 to S4):

[0049] S1. Collect video data of multiple ewes' activities in the sheep farm during the concentrated estrus months and pre-process the data;

[0050] S1-1, using a camera to collect a video of the sheep activities in the sheepfold from a side-down perspective;

[0051] S1-2, performing operations such as frame segmentation, screening, filtering, noise reduction, rotation and flipping on the collected sheep videos to construct a sheep image dataset D;

[0052] S2, constructing a sheep skeleton key point detection model based on the sheep image dataset D;

[0053] S2-1. To obtain the sheep's tail image, determine the key points of the sheep's skeleton that need to be extracted, such as Figure 2 As shown, there are 4 key points, including H, B, T1, and T2, among which: H is located at the skull of the sheep, B is located at the connection between the thoracic vertebrae and the lumbar vertebrae of the sheep, T1 is located at the sacrum of the sheep, and T2 is located at the end of the coccyx of the sheep;

[0054] S2-2, dividing the sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test in a ratio of 8:2;

[0055] S2-3, label the sheep body target box for the training set D_train, draw a rectangular bounding box for each sheep in the sheep group image, with the category of sheep, and mark the location of the sheep;

[0056] S2-4, marking the key points of the sheep skeleton in each sheep body bounding box in the training set D_train, marking the sheep skull position H, the sheep thoracic vertebrae and lumbar vertebrae connection position B, the sheep sacrum position T1, and the sheep coccygeal end position T2;

[0057] S2-5. Generate a json file for each image file in the training set D_train, including the image file name, the coordinate point of the upper left corner of the target box of the i-th sheep (x i,1 ,y i,1 ) and the lower right corner coordinate point (xi,2 ,y i,2 ), the name coordinates of each key point in the target frame of the i-th sheep (x 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 the sheep skeleton key point detection model;

[0059] S2-7, inputting D_test divided in S2-2 into the trained sheep skeleton key point detection model to evaluate the performance index of this model;

[0060] S3. Collect video data, and infer the collected video data based on the trained model to obtain the target frame coordinate information of each sheep and the coordinate information of the key points at the end of the tail vertebra of the sheep. Based on this information, perform tolerance expansion to calculate the coordinate information of the tail of each sheep. The tolerance expansion diagram is shown in Figure 3 As shown, the black frame is the target frame of the sheep body, and the red frame is the tail position obtained after the tolerance is expanded;

[0061] S3-1, the inference is that the coordinate point of the upper left corner of the target frame 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 ), the coordinate point T2 of the tail vertebrae end position in the target frame of the i-th sheep is (x n,i,3 ,y n,i,3 );

[0062] S3-2. Calculate the offset offset_x of the target frame of the i-th sheep in the n-th frame n,i and offset_y n,i , 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 tail vertebrae end position T2 of the sheep in the target frame 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,2 ) is the area enclosed by the rectangle;

[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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i,y n,i,3 -offset_y n,i ) is 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,2 -offset_x n,i ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_y n,i ) is 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,2 ) is 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_y n,i ) is 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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle;

[0076] S4, converting the video RGB data into optical flow data, and intercepting the tail optical flow graph on the optical flow data according to the tail position coordinate information calculated in S3.

[0077] Preferably, this embodiment uses YOLOv8-pose as a key point detection algorithm, which can also be replaced by other key point detection algorithms, including but not limited to DeepPose, Deeplabcut, RTMPose, HRNet, etc. This embodiment compares the existing data and selects the best solution.

[0078] 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.

[0079] The specific embodiments described herein are merely examples of the spirit of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in similar ways, but they will not deviate from the spirit of the present invention or exceed the scope defined by the appended claims.

Claims

1. A method for automatically extracting the optical flow map of the tail of a group-raised ewe, characterized in that It includes the following steps: S1. Collecting video data of multiple ewes' activities in a sheep farm during the concentrated estrus months and preprocessing the data to obtain a flock of sheep image dataset D; S2, constructing a sheep skeleton key point detection model based on the sheep image dataset D; S3, collecting video data, using the sheep skeleton key point detection model of the flock of sheep to obtain the sheep body target frame coordinate information and the sheep skeleton key point coordinate information of each sheep, and performing tolerance expansion based on this information to calculate the tail coordinate information of each sheep; S4, converting the video RGB data into optical flow data, and intercepting the tail optical flow graph on the optical flow data according to the tail position coordinate information calculated in S3.

2. The method according to claim 1, characterized in that S1 specifically includes: S1-1, using a camera to collect a video of the sheep activities in the sheepfold from a side-down perspective; S1-2, perform frame segmentation, screening, filtering, noise reduction, rotation and flipping operations on the collected sheep videos to construct a sheep image dataset D.

3. The method according to claim 1, characterized in that The sheep skeleton key point detection model described in S2 is constructed using YOLOv8-pose, DeepPose, Deeplabcut, RTMPose or HRNet algorithm.

4. The method according to claim 3, characterized in that The steps for constructing the sheep skeleton key point detection model in S2 specifically include: S2-1. To obtain the sheep's tail image, determine the sheep skeleton key points to be extracted, including four key points: H, B, T1, and T2. H is located at the sheep's skull, B is located at the connection between the thoracic and lumbar vertebrae, T1 is located at the sheep's sacrum, and T2 is located at the end of the sheep's coccyx. S2-2, dividing the sheep image dataset D obtained in step S1 into a training set D_train and a test set D_test in a ratio of 8:2; S2-3, annotating the sheep body target frame of the training set D_train, drawing a rectangular bounding box for each sheep in the sheep image, with the category of sheep, marking the position of the sheep; S2-4, marking the key points of the sheep skeleton in each sheep body bounding box in the training set D_train, marking the sheep skull position H, the sheep thoracic vertebrae and lumbar vertebrae connection position B, the sheep sacrum position T1, and the sheep coccygeal end position T2; S2-5. Generate a json file for each image file in the training set D_train, which contains the image file name, the coordinate position of the target frame of each sheep, and the name and coordinates of each key point in the target frame of each sheep; S2-6, select YOLOv8-pose to train the labeled training set D_train to obtain the sheep group skeleton key point detection model; S2-7, input D_test divided in S2-2 into the trained sheep group skeleton key point detection model to evaluate the performance indicators of this model.

5. The method according to claim 1, characterized in that S3 specifically includes: S3-1, collect video data, and use the sheep skeleton key point detection model to obtain the target frame coordinate position of each sheep in each frame, and the name and coordinates of each key point in the target frame of each sheep; S3-2, calculating the offset of the target frame of each sheep in each frame in the x and y directions; S3-3, if the tail vertebra end position T2 of a sheep in a certain frame is not detected in the target frame during model detection, the coordinate information of the tail vertebra end position T2 of the sheep in the previous frame is recorded; S3-4. Perform tolerance expansion on the tail vertebrae end position coordinate point of each sheep in each frame, and calculate the tail coordinate information: (1) If the end of the sheep's tail vertebrae is close to one or two of the left, right, upper and lower boundary boxes of the sheep's target box, then the tolerance is extended in the other three or two directions of the end of the sheep's tail vertebrae, and the offset in the x and y directions is increased at the T2 coordinate point; (2) If the end of the sheep's tail vertebrae is located in the middle of the sheep's target frame, the four directions of the end of the sheep's tail vertebrae are extended with tolerance, and the offsets in the x and y directions are increased at the T2 coordinate point.

6. The method according to claim 1, characterized in that In S3-2, the offset offset_x of the target frame of the i-th sheep in the n-th frame is calculated n,i and offset_y n,i , 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,2 -y n,i,1 ) Among them, (x n,i,1 ,y n,i,1 ) is the coordinate point of the upper left corner of the target box of the ith sheep in the nth frame, (x n,i,2 ,y n,i,2 ) is the coordinate point of the lower right corner of the target box of the i-th sheep in the n-th frame.

7. The method according to claim 1, characterized in that In S3-4, the coordinate point T2 of the tail vertebrae end position of the i-th sheep in the target frame is recorded as (x n,i,3 ,y n,i,3 ), calculate the tail coordinate information of the i-th sheep in the n-th frame including: (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,2 ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,1 ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,2 -offset_x n,i ,y n,i,1 ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,2 ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,2 ,y n,i,3 -offset_y n,i ) is the area enclosed by the rectangle; (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 ith sheep in the nth frame is the tail of the upper left corner with coordinate (x n,i,3 -offset_x n,i ,y n,i,3 +offset_y n,i ), the coordinates of the lower right corner are (x n,i,3 +offset_x n,i ,y n,i,3 -offset_y n,i ) is the area contained in the rectangle enclosed by .

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

  • Detection frame external expansion method and device

    CN117078919A

  • Ewe oestrus detection device and method

    CN117136873A

  • Method for automatically detecting ideal standing posture of sheep based on computer vision

    CN117576733A