Walking sheep standing stereoscopic ruler estimation method based on walking posture quantification

Through the method based on walking posture quantization, the body ruler of the sheep is predicted by using the depth camera and regression model, the problem of body ruler measurement in the natural walking state of the sheep is solved, and efficient and accurate body ruler conversion is achieved to adapt to the needs of actual breeding scenarios.

CN120510207AActive Publication Date: 2025-08-19ANHUI AGRICULTURAL UNIVERSITY
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511004367.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-08-19
Estimated Expiration
2045-07-21

AI Technical Summary

Technical Problem

The prior art is difficult to accurately measure the body ruler in the natural walking state of sheep. The traditional methods have high labor intensity and low efficiency, and the measurement accuracy is easily affected by human factors. In actual applications, the depth camera method has systematic errors and insufficient model generalization capabilities.

Method used

Using a method based on walking posture quantization, we collect walking videos of sheep only through a depth camera, detect key points of the trunk and legs, and build a walking posture quantization error prediction model. The regression model is used to predict the error of the walking body ruler relative to the standing stereo ruler, and correct the key points with the edge detection algorithm to realize the conversion of the body ruler from the walking state to the standing state.

Benefits of technology

The sheep can complete the measurement of the body ruler without only maintaining a stand still posture, which reduces the difficulty of measurement, improves efficiency and accuracy, adapts to the needs of large-scale breeding and production, reduces the stress response of the sheep, and improves the accuracy and practicality of the measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120510207A_ABST
    Figure CN120510207A_ABST
Patent Text Reader

Abstract

The invention discloses a walking sheep standing three-dimensional ruler estimation method based on walking posture quantification. The method comprises the steps of data acquisition, key point detection, walking body ruler parameter calculation, walking posture quantification-based error prediction model construction and walking body ruler and prediction error-based standing three-dimensional ruler parameter deduction. Firstly, sheep body image data is obtained; with the help of a key point detection model, key points of the body and the legs of the sheep are accurately recognized; various walking body size parameters of the sheep are calculated based on the three-dimensional coordinates of the key points; constructing a standing three-dimensional ruler parameter deduction model based on walking posture quantification and walking body size parameters, and predicting the percentage error of the walking body size relative to the standing three-dimensional ruler when the sheep naturally walks; and finally, deducing an outbound three-dimensional scale by using the predicted percentage error and the calculated walking body scale. Stereoscopic ruler measurement can be completed when the sheep naturally passes through the channel, the influence of the walking posture on the measurement result is effectively reduced, and the method has the advantages of being high in practicability, easy and convenient to operate, efficient, accurate and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of animal husbandry intelligent measurement and machine vision technology, and in particular to a method for estimating the standing body size of walking sheep based on walking posture quantification. Background Art

[0002] In the livestock sector, traditional sheep body measurement methods have numerous shortcomings. Manually measuring sheep requires manually securing them in a standing position, using specialized measuring tools such as measuring rods, tape measures, and rulers. This method is labor-intensive and inefficient, and measurement accuracy is susceptible to subjective factors, which can easily cause stress reactions in the sheep and increase the risk of zoonotic diseases.

[0003] While depth camera measurement methods can obtain more accurate distance information, most studies require animals to remain stationary or in a fixed position for data collection. For example, patent publication number CN 117576733 A discloses a computer vision-based method for automatically detecting the ideal stance of sheep. The method includes: S1. Collecting sheep image data on a sheep farm and preprocessing the data; S2. Extracting key features of the sheep skeleton using a key point detection deep learning model; S3. Defining criteria for determining ideal stance based on the requirements for sheep body measurement; S4. Preliminarily designing 21 sets of image feature vectors for determining ideal stance based on these criteria; and S5. Training a classifier to identify sheep in the ideal stance. Applying deep learning technology to ideal stance detection enables efficient, accurate, and automated detection of ideal stance for sheep. This method can help the livestock industry quickly and accurately identify images of sheep in the ideal stance, providing technical support for non-contact, high-precision, and automated measurement of sheep body dimensions based on computer vision.

[0004] The above-mentioned patent and the prior art methods based on two-dimensional images calculate body size data based on key point detection results. Although this method overcomes the shortcomings of manual methods, since sheep are three-dimensional creatures, they cannot be strictly coplanar with the calibration plate in real scenes. In actual situations, due to the uncontrollable movement and standing posture of sheep, the detected key point positions have varying degrees of deviation, resulting in inevitable systematic errors. Secondly, due to the influence of shooting angle and the dynamic posture of the sheep, it is extremely challenging to make the camera direction perpendicular to the side of the sheep, which is very easy to introduce new errors. In addition, the two-dimensional image method is difficult to implement and inefficient in actual farming scenarios. The processing of multi-view point cloud data requires a large amount of computing power, which is not conducive to field deployment and real-time requirements. At the same time, the number of animals involved in the experiment is small, resulting in insufficient model generalization ability. Furthermore, most methods require the animals to maintain a stationary, standing position perpendicular to the camera's direction of view to achieve high accuracy. This strict posture requirement is extremely difficult to achieve in practice; the perpendicular camera orientation requirement is particularly challenging, even with human assistance. In practice, managers desire a body measurement system that can detect the walking body dimensions of sheep as they naturally walk through a certain area within a passageway, using side cameras to measure their walking body dimensions, and then infer their standing body dimensions based on their walking posture. Current technology lacks a method that can deduce standing body dimensions from walking sheep's body dimensions.

[0005] Therefore, the present invention provides a method for estimating the body size of walking sheep based on gait quantification. When a sheep naturally walks through a certain area, its body size parameters in the walking state can be calculated, and its body size parameters when it is standing still can be estimated. This method overcomes the problems of the existing technology in estimating the static standing body size of walking sheep, and the insufficient accuracy of direct estimation, which is difficult to meet the actual breeding needs. Summary of the Invention

[0006] The purpose of the present invention is to overcome the defects and shortcomings of the existing technology and provide a method for estimating the standing body size of walking sheep based on gait quantification, which solves various problems existing in the existing technology.

[0007] To achieve the above object, the present invention provides the following technical solutions: A method for estimating standing body dimensions of walking sheep based on gait quantification, the method comprising the following steps: S1. Data Collection A walking corridor was constructed in the sheep farm. A depth camera was used to capture videos of sheep walking naturally from the side of the corridor. The video data was pre-processed to obtain two-dimensional plane images and three-dimensional depth images. S2. Key point detection Use the keypoint detection model to detect two types of body keypoints of the sheep's torso and legs in the planar image; S3. Calculation of walking body size parameters By registering the planar image and the depth image, the key points detected in step S2 are transformed into the depth image, and the various body size parameters of the sheep are calculated using the three-dimensional coordinates of the key points; S4. Construction of error prediction model based on walking posture quantification Construct a standing body size parameter deduction model based on walking posture quantification and walking body size parameters. The specific steps are as follows: a. Define the following four walking posture quantification angles: front leg angle, front knee angle, back leg angle, and back knee angle; b. Collect videos of sheep of typical body types walking naturally. For each frame of the image, calculate the four walking angles of the sheep in both 2D and 3D, and calculate their walking body dimensions using the S3-step method. The body dimensions of the sheep, measured manually while standing, are considered the true body dimensions. The error between the true body dimensions and the walking body dimensions, divided by the true body dimensions, is defined as the percentage error. Using this method, generate a sample set of "walking angle-percentage error" for an appropriate number of sheep of typical body types. c. Based on the above typical sample set, a regression model is used to establish a mapping relationship between the quantified walking posture angle and the percentage error of various body dimensions, forming a percentage error prediction model; S5. Derivation of standing body size parameters based on walking body size and walking posture angle The percentage error prediction model in step S4 is used to predict the error of the sheep's walking body size relative to its standing body size when walking naturally, and the standing body size parameter is derived by substituting the following formula: ; The parameters are: : Estimated standing body size; : Calculate the walking body size value based on key points; : The percentage error in the regression model's predictions.

[0008] The key points in step S2 are distributed at the contours of the trunk and legs, including: P1 at the front edge of the shoulder blade, P2 at the middle of the front leg, P3 at the middle of the front knee, P4 at the bottom of the front hoof, P5 at the lowest point of the abdomen, P6 at the middle of the hind leg, P7 at the middle of the hind knee, P8 at the bottom of the hind hoof, P9 at the base of the tail, P10 at the highest point of the hip contour, P11 at the lowest point of the back contour, and P12 at the bulge of the neck. Specifically, multiple key points are selected from the above key points and combined to accurately capture the morphological characteristics and motion information of the trunk and legs.

[0009] The various body size parameters of the sheep in step S3 include body length, body height, abdominal depth, abdominal circumference and hip height.

[0010] The calculation formula of the body oblique length is as follows: ; Among them, the parameters are: : 3D coordinates of the key points of the front edge of the scapula; : The three-dimensional coordinates of the key points at the base of the tail; The calculation formula of the body height is as follows: ; Parameter meaning: : The distance from the withers key point to the front leg key point; : The distance from the front leg key point to the front knee key point; : the distance from the front knee key point to the front hoof key point; The calculation formula of the abdominal depth is as follows: ; parameter: : 3D coordinates of key points of the lower abdomen; : 3D coordinates of key points on the upper abdomen; The calculation process of the abdominal circumference is as follows: ①. Determine the upper and lower abdomen key points: Locate the upper abdomen key point P5 and the lower abdomen key point P11 on the depth map; ②. Path planning: Use the Dijkstra algorithm to generate the optimal path from P5 to P11 on the depth map and extract sampling points on the path ; ③. 3D coordinate conversion: convert the sampling point 2D coordinates Convert to 3D coordinates ; ④. Calculation of total path length: ; The meaning of each parameter in the formula: for The three-dimensional coordinates of the point, for The three-dimensional coordinates of the point; ⑤. Ellipse circumference compensation: ; parameter: : ellipse compensation coefficient; The calculation formula for hip height is as follows: ; parameter: : the height of the key point of the withers; : Height of the key point of the sacrum.

[0011] In step S4, the front leg angle, front knee angle, rear leg angle, and rear knee angle are specifically defined as follows: ①. Front leg angle: Use the front leg key point and the front knee key point. First, determine the front leg key point, draw an auxiliary line vertically downward with the front leg key point as the origin, then connect the front leg key point and the front knee key point, and calculate the angle between the two line segments as the front leg angle; ②. Front knee angle: Use the front leg key point, front knee key point and front hoof key point. With the front knee key point as the origin, connect the front leg key point and the front hoof key point respectively, and calculate the angle between the two line segments; ③. The definitions of hind leg angle and hind knee angle are similar to those of front leg angle and front knee angle above; The specific steps for establishing the "walking posture angle-percentage error" sample in step S4 are: based on the definitions of the front leg angle, front knee angle, hind leg angle, and hind knee angle, collect quantitative walking posture angle data of the sheep during walking; detect key points of the sheep's body while collecting the walking posture angle, and calculate various walking body dimensions based on the detected key points according to the definition of body dimensions; for each type of body dimension parameter, calculate the percentage error between its predicted value and the actual value measured manually, using the calculation formula: percentage error = actual value | predicted value - actual value | × 100%; according to the above method, a "walking posture angle-percentage error" sample set of an appropriate number of sheep of typical body shapes can be formed.

[0012] A random forest was selected as the regression model, with the normalized walking posture quantization angle data as input features and the percentage error data of various body dimensions as output targets. A regression model was constructed between the walking posture quantization angle and the percentage error of various body dimensions. The new walking posture quantization angle data was then input into the trained regression model to obtain the percentage error prediction results of various body dimensions.

[0013] For the key feature points extracted in step S2, in order to improve the accuracy of sheep body key point detection, further correction is performed using an edge detection algorithm, which specifically includes the following steps: (1) Use the YOLOv11-pose model to detect key points of the sheep and its body to obtain the initial key point set; (2) Use the depth image and color image to detect the edge of the sheep in the color image and obtain an edge feature map with depth information; (3) Correcting the key points in the initial key point set according to the edge feature map to obtain a corrected key point set.

[0014] The edge feature detection in step (2) specifically includes the following steps: (a) Grayscale the color image to obtain a grayscale image; (b) Use the Canny operator to detect the edge of the sheep in the grayscale image and obtain a preliminary edge detection result image; (c) using the depth image to generate a mask of the valid depth area, setting a depth threshold range, marking pixels in the depth image whose depth values are within the threshold range as the valid depth area, and marking the remaining pixels as the invalid area, thereby obtaining a mask; (d) performing an AND operation on the preliminary edge detection result image of step (b) and the mask output of step (c) to obtain an edge feature map; (e) Perform morphological expansion processing on the above edge feature map to make the edge more obvious and complete, and obtain an edge feature map with depth information.

[0015] In step (3), for each key point in the initial key point set, a circular area is determined with the key point as the center and a fixed pixel value as the radius. Within the circular area, a search is performed to find a key point that is both on the edge of the sheep body represented by the edge feature map output in step (e) of step (2) and within the effective depth area generated in step (c). The initial key point is corrected according to the search result to obtain a corrected key point set.

[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention does not require the sheep to maintain a stationary standing posture perpendicular to the camera's shooting direction. The sheep only need to walk naturally through a certain area to complete the body size measurement. This conforms to the sheep's natural behavior, greatly reduces the measurement difficulty, improves the measurement efficiency, and avoids the sheep's stress. This makes the method highly feasible and practical in actual breeding scenarios, can better meet the needs of large-scale breeding production, and provides breeders with a more convenient and efficient means of body size measurement; (2) The present invention defines four angle indicators, namely the front leg angle, front knee angle, hind leg angle and hind knee angle, to quantify the standing posture of sheep, and constructs a posture-body size error compensation mechanism; the body size is predicted by the regression model, which effectively reduces the impact of the sheep's posture change on the body size measurement; after using the mixed walking posture angle, the average absolute percentage error of various body size parameters is reduced, thereby improving the accuracy of body size measurement; In summary, the present invention addresses the defects of the existing technology and has made major breakthroughs in measurement methods, measurement accuracy and practical application adaptability. It has significant advantages and broad application prospects, and will provide strong technical support for the development of the sheep breeding industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a flow chart of the steps of the present invention; Figure 2 Schematic diagram of the structure of the channel device; Figure 3 Schematic diagram of the distribution of key points in the sheep image of the present invention; Figure 4 Schematic diagram of the distribution of quantized angles of four walking postures of the present invention; Figure 5 This is the specific process of Canny edge detection in the present invention.

[0018] Reference numerals: 1. Support frame; 2. Walking path; 3. Wire; 4. Background board; 5. Depth camera. DETAILED DESCRIPTION

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

[0020] See also Figure 1-Figure 5 ; A method for estimating standing body dimensions of walking sheep based on gait quantification, the method comprising the following steps: S1. Data Collection A walking channel was built in the sheep farm, and the video data of sheep walking naturally was captured by a depth camera and pre-processed. The dedicated walking channel consists of two parts (such as Figure 1 As shown in the figure, the first part is a channel device, including a walking channel 2 erected by a support frame 1, one side of the shooting position of the walking channel 2 is a fence composed of horizontal wires 3 arranged at intervals above and below, and the other side of the shooting position is a background board 4; the second part is a visual perception module, including a depth camera 5 installed on the outside of the channel on the wire side through a camera bracket; the depth camera 5 transmits the video data of the sheep walking naturally taken to the background processing through a USB signal extension cable, and obtains an RGB image and a depth map saved in bag format (because the video recording function of the camera automatically saves the file in bag format and cannot be directly used for algorithm processing, it is necessary to use the official SDK source code of Orbbec to parse the video file, extract the video file according to the shooting frame rate, and compare the color image frame and the corresponding depth image frame).

[0021] S2. Key point detection and correction Use the keypoint detection model to detect two types of body keypoints of the sheep's torso and legs in the planar image; like Figure 2 The positions of the 12 key points are shown in Table 1 below: Table 1 - Key point names and locations

[0022] When selecting key points, multiple key points are selected from the above key points for combination. This combination can accurately capture the morphological characteristics and motion information of the torso and legs. The specific detection steps are as follows: Use the official parsing source code of the depth camera to parse each video, extract color image frames and corresponding depth image frames from the video according to the shooting frame rate, and align the color image frames and depth image frames. Delete the extracted blurred images and images with high repetition, randomly extract images from each video, divide the images into training set, verification set and test set in proportion, and then use image annotation tools to annotate the images to obtain the target box and key points of each target object.

[0023] Furthermore, in order to further improve the accuracy of sheep body key point detection, the extracted feature key points P1-P12 are further corrected using an edge detection algorithm, which specifically includes the following steps: (1) Key point detection: Use the YOLOv11-pose model to detect key points of the sheep target and its body to obtain an initial set of key points; the YOLOv11-pose model is trained based on a large-scale sheep body posture dataset and can accurately identify the position of each key point on the sheep's body; (2) Detect the edge of the sheep body: Use the depth image and color image to detect the edge of the sheep body in the color image; the specific steps are as follows: (a) Grayscale processing is performed on color images to reduce the complexity of the data, speed up subsequent processing, and obtain grayscale images; (b) Use the Canny operator to detect the edge of the sheep in the grayscale image and obtain a preliminary edge detection result image; (c) Generate a mask of the valid depth area using the depth image. Specifically, set a depth threshold range, mark pixels in the depth image whose depth values are within the threshold range as valid depth areas, and mark the remaining pixels as invalid areas, thereby obtaining a mask. The mask is used to filter out areas with actual depth information and provide a depth reference for subsequent key point correction. (d) performing an AND operation on the preliminary edge detection result image of step (b) and the mask output of step (c) to obtain an edge feature map, wherein each point in the edge feature map is at the edge of the sheep's body and has depth information; (e) Perform morphological expansion processing on the above edge feature map to make the edge more obvious and complete, providing accurate edge information for subsequent key point correction.

[0024] (3) Correcting key points: For each key point detected by the YOLOv11-pose model, a circular area is determined with it as the center and NP pixels as the radius (NP is a pre-set fixed pixel value, which can be adjusted appropriately according to the actual image resolution and sheep body size). In this circular area, a search is performed to find a key point that is located on the edge of the sheep body represented by the edge feature map output in step (2) (e) and is within the effective depth area generated in step (c). The initial key point is corrected according to the search result to obtain a corrected key point set. If there are points that meet the conditions in the search circular area, calculate the Euclidean distance between these points and the original key point as the coordinates of the original key point, select the point with the closest distance, and update the coordinates of the original key point to the coordinates of the closest point; if there are no points that meet the conditions, check whether the original key point has a depth value; if there is a depth value, retain the original key point; if there is no depth value, in the depth image, with the original key point as the center, search for points with depth values within a circle with a radius of NP pixels, calculate the Euclidean distance between these points and the original key point, select the point with the closest distance, and update the coordinates of the original key point to the coordinates of the closest point.

[0025] The Euclidean distance calculation formula is: ; in, represents the coordinates of the original key points, Indicates the coordinates of the edge points that meet the conditions in the search area.

[0026] S3. Calculation of body size parameters Calculate five body measurements based on the three-dimensional coordinates of the new positions of the key points in step S2: body oblique length, body height, abdominal depth, abdominal circumference, and hip height; According to the distance calculation formula of key points: ; in: is the Euclidean distance from point A to point B, is the three-dimensional coordinate of point A, is the three-dimensional coordinate of point B; It can be obtained that the calculation formula of the body oblique length is as follows: ; Among them, the parameters are: is the three-dimensional coordinate of the key point of the front edge of the scapula P1; The three-dimensional coordinates of the key point at the root of P9's tail; The calculation formula of the body height is as follows: ; Parameter meaning: : P12 The distance from the withers key point to the front leg key point; : The distance from the key point of the front leg to the key point of the front knee of P2; : P3 distance from the front knee key point to the front hoof key point; The distance calculation of key points is specifically based on the following formula; ; in: is the Euclidean distance from point A to point B, is the three-dimensional coordinate of point A, is the three-dimensional coordinate of point B; The calculation formula of the abdominal depth is as follows: ; parameter: P5 3D coordinates of key points in the lower abdomen; : P11 three-dimensional coordinates of key points on the upper abdomen; The calculation process of the abdominal circumference is as follows: ①. Determine the upper and lower abdominal key points: Position the upper abdomen key point P5 and the lower abdomen key point P11 on the depth map; ②. Path planning: Use the Dijkstra algorithm to generate the optimal path from P5 to P11 on the depth map and extract sampling points on the path ; ③. 3D coordinate conversion: convert the sampling point 2D coordinates Convert to 3D coordinates ; ④. Calculation of total path length: ; The meaning of each parameter in the formula: for The three-dimensional coordinates of the point, for The three-dimensional coordinates of the point; ⑤. Ellipse circumference compensation: ; parameter: : ellipse compensation coefficient; The calculation formula for hip height is as follows: ; parameter: : The height of the withers key point P12; : The height of the sacral key point P10.

[0027] S4. Construction of error prediction model based on walking posture quantification Construct a standing body size parameter deduction model based on walking posture quantification and walking body size parameters. The specific steps are as follows: a. Define the following four walking posture quantification angles: front leg angle, front knee angle, back leg angle, and back knee angle; like Figure 4 The following are the steps: 1. Front leg angle a: The front leg key point P2 and the front knee key point P3 are used. First, the front leg key point P2 is determined. An auxiliary line is made vertically downward with the front leg key point P2 as the origin. Then, the front leg key point and the front knee key point P3 are connected. The angle between the two line segments is calculated as the front leg angle. ②. Front knee angle b: Using the front leg key point P2, the front knee key point P3, and the front hoof key point P4, with the front knee key point P3 as the origin, connect the front leg key point P2 and the front hoof key point P4, and calculate the angle between the two line segments; ③. Hind leg angle c: This uses the hind leg key point P6 and the hind knee key point P7. First, determine the hind leg key point P6. Draw an auxiliary line vertically downward from the hind leg key point P6 as the origin. Then, connect the hind leg key point and the hind knee key point P7. Calculate the angle between the two line segments as the hind leg angle. ④. Knee angle d: Using the hind leg key point P6, the hind knee key point P7 and the hind hoof key point P8, with the hind knee key point P7 as the origin, connect the hind leg key point P6 and the hind hoof key point P8, and calculate the angle between the two line segments; b. Collect videos of sheep of typical body types walking naturally. For each frame of the image, calculate the four quantitative walking angles of the sheep in both 2D and 3D perspectives, and calculate their walking body dimensions using the S3-step method. The manually measured body dimensions of the sheep while standing are considered the true body dimensions, and the error between the true body dimensions and the walking body dimensions divided by the true body dimensions is defined as the percentage error. Using this method, generate a sample set of "walking angle-percentage error" for an appropriate number of sheep of typical body types. The specific steps for establishing a "walking angle-percentage error" sample set are as follows: based on the definitions of foreleg angle, front knee angle, hind leg angle, and hind knee angle, walking angle data of sheep are collected while they are walking. Key points of the sheep's body are detected while collecting the walking angles. Based on the detected key points, various walking body dimensions are calculated according to the definition of body dimensions. For each type of body dimension parameter, the percentage error between its predicted value and the manually measured true value is calculated using the following formula: Percentage error = true value | predicted value - true value | × 100%. Following this method, a "walking angle-percentage error" sample set can be formed for an appropriate number of sheep of typical body shapes. Normalize the walking angle data and map the normalized walking angle data to the interval [0, 1]. Use SIMCA software to perform variable importance analysis and screen the key angles that affect different body size errors. The specific steps for screening key angles are as follows: (1) Use a table to collect statistics of the four angle data and error percentages, check the data integrity, and standardize the data; (2) Substitute the data in (1) into the SIMCA software, where the error percentage is set as the dependent variable and the four angle values are set as independent variables. Select a suitable model according to the analysis purpose to analyze the contribution to the body size. Use cross-validation and other methods to verify the model, evaluate the stability and predictive ability of the model, set the variable projection importance (VIP) threshold, and generally set the VIP threshold (usually variables with a VIP value greater than 1 are considered important). Screen out angles with a VIP value greater than the threshold as key angles. The relationship between the body size error percentage and the plane angle is shown in Table 2. The relationship between the body size error percentage and the plane angle is shown in Table 2. Table 2 - VIP relationship between body size error percentage and plane angle

[0028] The VIP relationship between body size error percentage and spatial angle is shown in Table 3: Table 3 - VIP relationship between body size error percentage and spatial angle

[0029] c. Based on the above typical samples, a regression model was used to establish a mapping relationship between walking angles and the percentage errors of various body dimensions, forming a percentage error prediction model. A random forest regression algorithm was selected, using the normalized walking angle data as input features and the percentage errors of various body dimensions as output targets to construct a regression model between walking angles and the percentage errors of various body dimensions. The newly quantified walking angle data was then input into the trained random forest regression model to obtain the percentage error prediction results for various body dimensions. By leveraging the powerful nonlinear fitting and feature learning capabilities of the random forest regression model, we deeply explore the potential correlation between angle and error and establish an accurate angle error prediction relationship model. Subsequently, during actual body size measurement, we predict the possible errors at the current measurement angle based on this model, and then perform error compensation prediction on the measurement results to obtain data that is closer to the actual body size.

[0030] S5. Derivation of standing body size parameters based on walking body size and walking posture quantification angles During the collection and processing of body measurement data, raw measurements often contain a certain degree of error due to the combined influence of various factors, including the measurement environment, measurement tool accuracy, and human interaction. To effectively reduce these errors and improve the accuracy of body measurement, this paper uses a prediction error percentage to correct the raw body measurement predictions. Furthermore, during the training of the regression model, a comprehensive evaluation of the model's predictive performance is conducted to ensure that the model possesses good predictive capabilities.

[0031] The percentage error prediction model in step S4 is used to predict the error of the walking body size relative to the standing body size calculated at key points when the sheep walks naturally. The standing body size parameters are derived by substituting the following formula: ; The parameters are: : Estimated standing body size; : Calculate the walking body size value based on key points; : Percent error in the regression model predictions; The specific operation is as follows: First, based on the existing data and model, a preliminary prediction of the original body size value is made, and the error between the predicted value and the actual value is calculated; then, based on this error, the prediction error percentage is calculated; finally, the original body size value is adjusted accordingly using this prediction error percentage to obtain the corrected body size value. This correction step can significantly reduce the error component in the original measurement data, making the corrected body size value closer to the actual value, thereby providing a more accurate and reliable data foundation for subsequent analysis and application; During the body size data processing stage, the predicted error percentage is used to correct the body size values obtained from the original measurement. This correction method effectively reduces the measurement error and thus improves the accuracy of body size measurement.

[0032] During the regression model training phase, we use multiple indicators, including mean error (MAE), mean square error (MSE), root mean square error (RMSE), mean absolute percentage error (MAPE), and coefficient of determination (R²), to comprehensively and carefully evaluate the predictive performance of the regression model from different dimensions to ensure that the model has high accuracy and reliability. The specific indicators are as follows: Mean Average Error (MAE): It is used to measure the average level of error between the predicted value and the actual value. It can intuitively reflect the size of the model prediction error. The smaller the value, the higher the prediction accuracy of the model. Mean Squared Error (MSE): By calculating the average of the squares of the errors between the predicted values and the actual values, it gives greater weight to larger errors, thereby more sensitively reflecting the large deviations that occur in the model during the prediction process, and helps to identify the prediction instability of the model under specific circumstances. Root Mean Squared Error (RMSE): As the square root of the mean squared error, it is consistent with the dimension of the original data, making it easier to intuitively understand the size of the prediction error. It can also reflect the degree of dispersion of the error to a certain extent. It is one of the important indicators commonly used in evaluating model prediction performance; Mean Absolute Percentage Error (MAPE): Expresses prediction errors as a percentage, eliminating the impact of data dimension, making model performance comparisons between different datasets more intuitive and convenient. It is particularly suitable for scenarios where high relative accuracy of prediction results is required. Coefficient of determination (R²): It is used to measure the goodness of fit of the model to the data. Its value range is between 0 and 1. The closer it is to 1, the better the model fits the data, that is, the model can better explain the changes in the dependent variable.

[0033] By comprehensively evaluating the regression model using these multiple metrics during training, we can gain a comprehensive and in-depth understanding of the model's performance in various areas, promptly identifying potential model issues such as overfitting and underfitting. This provides a strong basis for model optimization and improvement, ensuring high accuracy and reliability in practical applications. Therefore, by improving measurement accuracy through the body measurement correction step and ensuring model quality through the regression model prediction performance evaluation step, we provide a scientific, effective, and comprehensive solution for body measurement and data analysis.

[0034] The specific embodiments are as follows: (1) Experimental preparation The experiment was conducted at the Jianghuai Watershed Comprehensive Experimental Station from January 4 to January 7, 2025, involving 30 healthy ewes (18 sheep and 12 goats). Before the formal experiment, the sheep were driven back and forth through the tunnel several times to familiarize them with the environment. Then, a sheep was randomly selected from the flock and fitted with a numbered pendant to identify it. Three staff members worked together to measure its body measurements, and the average of these three repeated measurements was used as the actual body size.

[0035] (2) Data collection Place the sheep in the tunnel and drive them to walk back and forth in the tunnel. Use a depth camera to record the process of each sheep walking through the shooting area. Collect at least 10 valid videos and name the video with the file name "sheep number - round trip sequence number".

[0036] (3) Dataset creation Video data from 10 of the 30 test sheep was used as a test set for the final performance test of the proposed method; data from the remaining 20 sheep was used for training and validation. Three videos were randomly sampled from each of the 20 sheep, for a total of 60 videos used to train the YOLOv11-pose keypoint detection model. Each video was parsed using the official depth camera parsing source code. Color frames and corresponding depth frames were extracted and aligned according to the shooting frame rate, and blurred and highly repetitive images were removed. Fifty images were randomly sampled from each video, resulting in a total of 3,000 original images. These images were then divided into a training set (2,400), a validation set (300), and a test set (300) in an 8:1:1 ratio. The 3,000 images were annotated using the Labelme image annotation tool, generating a JSON-formatted label file.

[0037] (4) Model training and evaluation Data processing was performed on a Windows 10 system equipped with an Intel(R) Core(TM) i9-13900K CPU, 128GB of RAM, an NVIDIA GeForce RTX 3090 GPU, the Python 3.9 runtime environment, and the PyTorch 2.2 deep learning framework. During object detection model training, input images were uniformly resized to a 640×640 resolution. The initial learning rate was set to 0.001, and the Poly strategy was used for dynamic learning rate adjustment. SGD was used as the optimizer for model training, with 500 training iterations, a batch size of 4, and a weight decay of 0.0005.

[0038] The effectiveness of the keypoint correction method was verified by comparing the mean absolute percentage errors of various body dimensions before and after correction at different search radii. The results show that using YOLOv11-pose for keypoint localization and combining image edge features with depth information for correction, the mean absolute percentage errors of body height, abdominal depth, abdominal circumference, and hip height after keypoint correction decreased by 0.13%, 0.51%, 0.58%, and 0.39%, respectively. Although the error in body oblique length increased by 0.05%, overall body measurement accuracy was still improved compared to previous methods, reducing measurement errors caused by keypoint offset.

[0039] The prediction performance of different regression models was evaluated using five metrics: mean error (MAE), mean square error (MSE), root mean square error (RMSE), mean absolute percentage error (MAPE), and coefficient of determination (R²). The results showed that the random forest regression model performed best in predicting body measurement errors. By introducing a hybrid walking posture quantitative correction, the accuracy of body measurement was significantly improved. Compared with the uncorrected results, the mean absolute percentage errors of body length, abdominal depth, abdominal circumference, body height, and hip height were reduced by 2.98%, 5.20%, 7.87%, 2.95%, and 4.04%, respectively.

[0040] Although this specification is described according to implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.

[0041] Therefore, the above description is only a preferred embodiment of the present application and is not intended to limit the scope of implementation of the present application; that is, all equivalent modifications made according to the scope of the claims of the present application are within the scope of protection of the claims of the present application.

Claims

1. A method for estimating standing body dimensions of walking sheep based on walking posture quantification, characterized in that: The following steps are involved: S1. Data Collection Use a depth camera to capture sideways videos of sheep walking naturally, and then pre-process them to obtain two-dimensional and three-dimensional images; S2. Key point detection Detect key points of the sheep's torso and legs using a key point detection model in a two-dimensional image; S3. Calculation of walking body size parameters Transform the detected key points into a three-dimensional image and use their three-dimensional coordinates to calculate various body size parameters of the sheep; S4. Construction of error prediction model based on walking posture quantification a. Define four walking angles: front leg, front knee, back leg, and back knee angles; b. Collect videos of sheep of typical body size walking naturally; In each frame of the sheep's walking image, four walking posture angles were calculated in both plane and space. The walking body size was calculated using the S3 method. The body size manually measured while the sheep was standing was considered the true body size, and the error between the true body size and the walking body size divided by the true body size was defined as the percentage error. This method was used to generate a "walking posture angle-percentage error" sample set for sheep of typical body shapes. c. Based on the sample set, a regression model is used to establish a mapping relationship between walking angles and the percentage errors of various body dimensions, forming a percentage error prediction model; S5. Derivation of standing body size parameters based on walking body size and walking posture angle The S4 model was used to predict the error between the sheep's walking body size and its standing body size. The standing body size parameters were derived by substituting the formula: ; in : Estimated standing body size; : Calculate walking body size at key points; : The percentage error in the regression model's predictions.

2. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 1, characterized in that: The key points in step S2 are distributed at the contours of the trunk and legs, including: P1 at the front edge of the shoulder blade, P2 at the middle of the front leg, P3 at the middle of the front knee, P4 at the bottom of the front hoof, P5 at the lowest point of the abdomen, P6 at the middle of the hind leg, P7 at the middle of the hind knee, P8 at the bottom of the hind hoof, P9 at the base of the tail, P10 at the highest point of the hip contour, P11 at the lowest point of the back contour, and P12 at the bulge of the neck. Specifically, multiple key points are selected from the above key points and combined to accurately capture the morphological characteristics and motion information of the trunk and legs.

3. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 1, characterized in that: The various body size parameters of the sheep in step S3 include body length, body height, abdominal depth, abdominal circumference and hip height.

4. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 3, characterized in that: in, The calculation formula of the body oblique length is as follows: ; Among them, the parameters are: : 3D coordinates of the key points of the front edge of the scapula; : The three-dimensional coordinates of the key points at the base of the tail; The calculation formula of the body height is as follows: ; Parameter meaning: : The distance from the withers key point to the front leg key point; : The distance from the front leg key point to the front knee key point; : the distance from the front knee key point to the front hoof key point; The calculation formula of the abdominal depth is as follows: ; parameter: : 3D coordinates of key points of the lower abdomen; : 3D coordinates of key points on the upper abdomen; The calculation process of the abdominal circumference is as follows: ①. Determine the upper and lower abdomen key points: Locate the upper abdomen key point P5 and the lower abdomen key point P11 on the depth map; ②. Path planning: Use the Dijkstra algorithm to generate the optimal path from P5 to P11 on the depth map and extract sampling points on the path ; ③. 3D coordinate conversion: convert the sampling point 2D coordinates Convert to 3D coordinates ; ④. Calculation of total path length: ; The meaning of each parameter in the formula: for The three-dimensional coordinates of the point, for The three-dimensional coordinates of the point; ⑤. Ellipse circumference compensation: ; parameter: : ellipse compensation coefficient; The calculation formula for hip height is as follows: ; parameter: : the height of the key point of the withers; : Height of the sacral key point.

5. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 1, characterized in that: In step S4, the front leg angle, front knee angle, rear leg angle, and rear knee angle are specifically defined as follows: ①. Front leg angle: Use the front leg key point and the front knee key point. First, determine the front leg key point, draw an auxiliary line vertically downward with the front leg key point as the origin, then connect the front leg key point and the front knee key point, and calculate the angle between the two line segments as the front leg angle; ②. Front knee angle: Use the front leg key point, front knee key point and front hoof key point. With the front knee key point as the origin, connect the front leg key point and the front hoof key point respectively, and calculate the angle between the two line segments; ③. The definitions of the hind leg angle and the hind knee angle are similar to those of the front leg angle and the front knee angle mentioned above.

6. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 5, characterized in that: The specific steps for establishing the "walking angle-percentage error" sample in step S4 are: based on the definitions of the front leg angle, front knee angle, hind leg angle, and hind knee angle, collect the walking angle data of the sheep during walking; while collecting the walking angle, detect the key points of the sheep's body, and calculate various walking body dimensions based on the detected key points according to the definition of body dimensions; for each type of body dimension parameter, calculate the percentage error between its predicted value and the actual value measured manually, using the calculation formula: percentage error = actual value | predicted value - actual value | × 100%; using the above method, a "walking angle-percentage error" sample set can be formed for an appropriate number of sheep of typical body shapes.

7. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 1, characterized in that: A random forest was selected as the regression model, with the normalized walking posture quantization angle data as input features and the percentage error data of various body dimensions as output targets. A regression model was constructed between the walking posture quantization angle and the percentage error of various body dimensions. The new walking posture quantization angle data was then input into the trained regression model to obtain the percentage error prediction results of various body dimensions.

8. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 1, characterized in that: For the key feature points extracted in step S2, in order to improve the accuracy of sheep body key point detection, further correction is performed using an edge detection algorithm, which specifically includes the following steps: (1) Use the YOLOv11-pose model to detect key points of the sheep and its body to obtain the initial key point set; (2) Use the depth image and color image to detect the edge of the sheep in the color image and obtain an edge feature map with depth information; (3) Correcting the key points in the initial key point set according to the edge feature map to obtain a corrected key point set.

9. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 8, characterized in that: The edge feature detection in step (2) specifically includes the following steps: (a) Grayscale the color image to obtain a grayscale image; (b) Use the Canny operator to detect the edge of the sheep in the grayscale image and obtain a preliminary edge detection result image; (c) using the depth image to generate a mask of the valid depth area, setting a depth threshold range, marking pixels in the depth image whose depth values are within the threshold range as the valid depth area, and marking the remaining pixels as the invalid area, thereby obtaining a mask; (d) performing an AND operation on the preliminary edge detection result image of step (b) and the mask output of step (c) to obtain an edge feature map; (e) Perform morphological expansion processing on the above edge feature map to make the edge more obvious and complete, and obtain an edge feature map with depth information.

10. The method for estimating standing body size of walking sheep based on walking posture quantification according to claim 8, characterized in that: In step (3), for each key point in the initial key point set, a circular area is determined with the key point as the center and a fixed pixel value as the radius. Within the circular area, a search is performed to find a key point that is both on the edge of the sheep body represented by the edge feature map output in step (e) of step (2) and within the effective depth area generated in step (c). The initial key point is corrected according to the search result to obtain a corrected key point set.

Citation Information

Patent Citations

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

    CN117576733A

  • Livestock weight estimation method, device and equipment and computer readable storage medium

    CN111243005A

  • Animal body size measuring method and device, electronic equipment and storage medium

    CN116558411A

  • Non-contact livestock body size measuring method and electronic equipment

    CN118196175A

  • Cow body size measuring method based on colorized point cloud multi-view key point positioning

    CN119380041A