Next Article in Journal
Impact of Interactions with a Puppy and Handler Versus a Handler Alone on Stress and Vitality in a University Setting: A Crossover Study
Previous Article in Journal
Analgesic Effect of Dexmedetomidine-Nalbuphine Combination vs. Dexmedetomidine Alone in Donkeys Undergoing Field Castration under Total Intravenous Anesthesia
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Automated Measurement of Cattle Dimensions Using Improved Keypoint Detection Combined with Unilateral Depth Imaging

1
College of Computer and Information Engineering, Xinjiang Agricultural University, Urumqi 830052, China
2
Agricultural Information Institute, Chinese Academy of Agricultural Sciences, Beijing 100080, China
3
Ministry of Education Engineering Research Centre for Intelligent Agriculture, Urumqi 830052, China
4
Xinjiang Agricultural Informatization Engineering Technology Research Center, Urumqi 830052, China
5
Hebei Tianhe Beef Cattle Farming Ltd., Shijiazhuang 050000, China
*
Authors to whom correspondence should be addressed.
Animals 2024, 14(17), 2453; https://doi.org/10.3390/ani14172453
Submission received: 27 July 2024 / Revised: 17 August 2024 / Accepted: 21 August 2024 / Published: 23 August 2024

Abstract

:

Simple Summary

In this study, we address the inefficiencies and animal welfare concerns associated with the traditional manual measurements of cattle dimensions by introducing a non-contact, automated measurement method. This method utilizes an improved keypoint detection model coupled with unilateral depth imaging technology. By improved the keypoint detection model, we have improved the model’s capability of processing critical cattle features. Subsequently, cattle body keypoints identified through conditional filtering of the depth image are optimized. Finally, these keypoints are integrated with various algorithms to compute the body size parameters of the cattle. In tests conducted on 23 beef cattle, the mean relative errors for body height, lumbar height, body length, and chest girth were 1.28%, 3.02%, 6.47%, and 4.43%, respectively. This research is of great significance for enhancing animal welfare and contributes to the sustainable development of modern livestock farming.

Abstract

Traditional measurement methods often rely on manual operations, which are not only inefficient but also cause stress to cattle, affecting animal welfare. Currently, non-contact cattle dimension measurement usually involves the use of multi-view images combined with point cloud or 3D reconstruction technologies, which are costly and less flexible in actual farming environments. To address this, this study proposes an automated cattle dimension measurement method based on an improved keypoint detection model combined with unilateral depth imaging. Firstly, YOLOv8-Pose is selected as the keypoint detection model and SimSPPF replaces the original SPPF to optimize spatial pyramid pooling, reducing computational complexity. The CARAFE architecture, which enhances upsampling content-aware capabilities, is introduced at the neck. The improved YOLOv8-pose achieves a mAP of 94.4%, a 2% increase over the baseline model. Then, cattle keypoints are captured on RGB images and mapped to depth images, where keypoints are optimized using conditional filtering on the depth image. Finally, cattle dimension parameters are calculated using the cattle keypoints combined with Euclidean distance, the Moving Least Squares (MLS) method, Radial Basis Functions (RBFs), and Cubic B-Spline Interpolation (CB-SI). The average relative errors for the body height, lumbar height, body length, and chest girth of the 23 measured beef cattle were 1.28%, 3.02%, 6.47%, and 4.43%, respectively. The results show that the method proposed in this study has high accuracy and can provide a new approach to non-contact beef cattle dimension measurement.

1. Introduction

A United Nations report indicates that the global population will reach 9.7 billion by 2050 and peak at 11 billion by the end of this century [1]. The increase in population and changes in consumption patterns have heightened the demand for meat and dairy products, thereby spurring rapid development in the livestock sector. However, the expansion of livestock production has introduced a slew of environmental challenges. Sustainable livestock production and consumption not only pose challenges to the food system but also represent broader challenges for various stakeholders [2]. In modern livestock management, the element of cattle dimensions is a critical production metric. The size of cattle not only significantly influences their market value, genetic improvement [3], and management strategies [4] but also directly relates to their health status [5], meat quality [6], and reproductive performance [7].
In traditional livestock production, body weight and dimensions are typically measured using direct contact tools [8]. However, manual measurement methods require experienced workers, are time-consuming and labor-intensive, and the results are highly subjective, being easily influenced by external environments and experience. These measurements can also compromise animal welfare [9]. Non-contact sensor technology, as a relatively new and advanced method, provides a convenient means of real-time monitoring, aiding in the precision management of the livestock industry [10]. Non-contact methods for measuring cattle dimensions are crucial for the intensification and sustainable production of the livestock industry.
Currently, research on cattle body measurement mainly focuses on the following two technological approaches: two-dimensional image analysis and three-dimensional reconstruction techniques. Measurements using two-dimensional images generally involve capturing images of cattle with visible-light cameras. Subsequently, machine learning or deep learning technologies are applied to identify bovine features, which are then processed. Seo and others utilized a PC, a capture card, and two cameras to construct an image processing system. This system calculates body dimensions based on the relationship between image pixels and the actual dimensions of the cattle. Apart from the chest girth and pelvis height, the error in other body parameters is less than 5%. However, this method is sensitive to sunlight exposure and changes in the cattle’s posture, and the system structure is also relatively complex [11]. Tasdemir and others set up four Canon EOS400D cameras at the exit of the milking parlor to capture two images of the cattle from the side and the top. Using image processing software, they converted 2D image pixels into 3D spatial coordinates to calculate the cattle’s dimensions. Their research showed accuracies of 97.72% for wither height, 98% for hip height, 97.89% for body length, and 95.25% for hip width [12]. Viazzi and others noted that using two-dimensional images for body measurement in farm environments might not always be effective. Shadows and continuous changes in the background also make it challenging to capture image features accurately, and this can be well overcome by using depth cameras [13]. Spoliansky and others have shown that, although 2D sensors play an important role in body dimension detection, they lack the utilization of depth information provided by the third dimension compared to 3D sensors [14].
As the cost-effectiveness and practicality of consumer-grade depth sensors continues to improve, these technologies are increasingly penetrating precision agriculture and livestock management. Gao and colleagues used a ZED2I depth camera to capture images of corn plants and applied the modified YOLOv7-Pose to extract plant phenotypic parameters [15]. Rodríguez Alvarez and others utilized the Kinect v2 camera to capture images from the top of dairy cows and then employed the SqueezeNet model to automatically estimate the Body Condition Score (BCS) of the cows [16]. Miller and his team used a Time-of-Flight (ToF) camera to capture images of the back of cattle and employed artificial neural networks (ANNs) and Halcon software (MVTec Software GmbH, München, Germany) to predict weight based on 60 potential variables (including length, height, width, area, volume, and ratios), resulting in an R-squared score of 0.7 and a root mean square error (RMSE) of 42 kg [17].
For body dimension measurements, Ruchay utilized three Kinect v2 depth cameras to capture RGB-D data of cattle as they passed, including left, right, and top view depth images along with RGB images. Measurements such as body height, body diagonal length, and chest girth were calculated using 3D reconstruction and manual annotation of point cloud data [18]. Shuai designed a swine body dimension measurement system that uses three Kinect cameras positioned at different angles along the pen alley to collect data. The system then measures the swine’s dimensions after 3D reconstruction, achieving an average relative error of less than 5% for body length, height, width, and girth [19]. Huang and colleagues used a LiDAR sensor to capture raw data from Qinchuan cattle and employed techniques such as filter fusion, k-means clustering, RANSAC plane segmentation, FPFH feature detection, BRKD tree ICP registration, and GPT reconstruction. The cattle body dimensions were calculated using surface fitting and curve correction functions, resulting in an error close to 2 mm. However, this method requires different measurement systems to be built according to the body type of cattle at different ages, and the animals must remain as still as possible [20]. Le Cozler and others developed the Morpho3D automatic body measurement system using laser triangulation technology combined with five cameras and a laser projector to generate a detailed 3D point cloud of cattle bodies. Measurements are extracted from visually determined locations using Metrux2α® software (3DOuest company, Lannion, France) [21]. Wang and his team obtained swine chest circumference slices through point cloud cross-sections and fitted curves to measure the perimeter for calculating the chest girth. The accuracy in detecting swine chest measurement locations was 96.5%, with an average relative error of 7.67% for chest girth [22]. Building on Wang’s work, Du combined the DeepLabCut toolkit to capture the key body-dimension points of pigs and cattle, mapping these points to the livestock point cloud to compute body dimensions. The average absolute error for cattle chest circumference was 10.76 cm, and it was 10.30 cm for swine [23]. Yang and colleagues captured about 55 images around dairy cows using a smartphone, employing Structure from Motion (SfM) photogrammetry, Random Sample Consensus (RANSAC), and Euclidean clustering to reconstruct the dairy cow point cloud. The calculations of key body dimensions showed that the relative errors for shoulder height, chest width, and chest girth mainly were below 5%, with most chest girth measurements being below 7.5% [24]. In summary, while point cloud or 3D reconstruction technologies can ensure the accuracy of livestock body measurements, these methods have certain limitations, as follows:
(1) Most related studies rely on specific data collection environments, lacking universality, which limits the widespread adoption of these technologies in various agricultural scenarios. (2) The deployment of multi-camera systems and body measurement equipment often involves significant costs. (3) These technologies frequently require manual marking of keypoints or rely on complex algorithms to extract features for calculating the specific dimensions of livestock, which is a laborious and error-prone process, especially in environments with limited computational and storage resources.
Given the many challenges faced by existing cattle size measurement technologies, such as low accuracy, high costs, and complex operations, this study aims to explore a new method combining keypoint detection models with single-side depth imaging. The scientific purpose of the research is to validate the applicability and accuracy of this technique in real farm environments, while the practical purpose is to simplify the measurement process, reduce costs, and improve efficiency. The method proposed in this study can effectively reduce costs and optimize the detection efficiency of cattle characteristic points while ensuring accuracy, which is of great significance in promoting the development of precision livestock farming.

2. Materials and Methods

2.1. Data Collection

The data collection site for this study is located at a professional beef cattle farm in Longhua County, Hebei Province, China. The subjects of the study are Simmental cattle who were raised in an environment that complies with national livestock welfare standards. The design of the livestock building takes into consideration ventilation, lighting, and spatial arrangement to ensure the health and welfare of the cattle. The bedding material is straw, which is regularly replaced to maintain dryness and cleanliness, preventing the occurrence of diseases. Microclimatic conditions such as temperature and humidity are regulated by an automated monitoring system to ensure they remain within the optimal range for cattle growth. The collection of image data was conducted in two phases, with the first being from 28 November 2023 to 14 December 2023 and the second being from 18 March 2024 to 29 March 2024, totaling 28 days. The selection of animals was based on the diversity of health conditions and ages to ensure the representativeness and scientific validity of the data. Furthermore, all the cattle included in the study came from the same herd, which consists of approximately 150 heads, to enhance the statistical power of the research.
To ensure high-quality data, the ZED2I depth camera was used to simultaneously capture side-view RGB and depth images of the cattle. The image data collection was facilitated using a laptop connected to the ZED2I depth camera, which was mounted on a tripod approximately 1 m high. The camera was positioned 1 to 5 m directly in front of the cattle’s abdomen, then set to record at 1080 p @30 fps. Video recording of the RGB and the corresponding depth images was synchronized to capture each cow as it naturally passed in front of the camera from appearance to disappearance from the lens. This method of collection ensured flexibility in image capturing while considering animal welfare, effectively capturing side images of the cattle in their natural state.
To ensure data diversity and complexity, image acquisition was conducted at distances ranging from 1 to 5 m both inside and outside the barn during different time periods, ensuring effective capturing of cattle’s natural behaviors and postures under varying conditions. Actual body measurements of the cattle, including body height, lumbar height, chest girth, and body length, were precisely measured with the assistance of professional breeders using measuring sticks and tape measures. Ultimately, the study collected approximately 73 GB of video data of 95 cattle, including the actual measurement data for body height, body length, lumbar height, and chest girth for 23 cattle. The data collection and body measurement scenes are depicted in Figure 1.

2.2. Dataset Construction

We converted the 73 GB of video data from 95 cattle into RGB images and corresponding left-view depth images using the code provided by the ZED2i depth camera. From this, 2485 RGB images were selected, which include diverse data that vary in regard to distance, lighting, and posture. To ensure the generalizability and robustness of our model, we employed data augmentation techniques such as mirroring, rotating, translating, adding Gaussian and motion blur, and simulating different weather conditions to expand the dataset with an additional 500 augmented images. Ultimately, the 2985 images were split into a training set and a test set at a 7:3 ratio. Examples of the dataset are shown in Figure 2.
We used Labelme [25], a widely employed annotation tool in the field of computer vision, to mark keypoints on the bovine dataset. With assistance from professional livestock measurement experts, bounding boxes were used to label parts of the cattle body, named “Cow_Body”. Key anatomical landmarks such as the highest point of the withers, hoof, shoulder end, the external edge of the ischium, the rear edge of the withers, the vertical chest baseline, and the lumbar point were labeled, respectively, as Withers, Sole, Shoulder, Pin, Chest1, Chest2, and Lumbar. The data annotation is depicted in Figure 3.

2.3. Technical Route

First, images of cattle, including single-sided depth images and RGB images, are acquired through data collection and video extraction processes. Then, the YOLOv8-pose model is enhanced to extract keypoints of the cattle based on the requirements of real-world scenarios. Subsequently, these points are refined and optimized on the depth images through conditional filtering. Finally, the cattle’s body height, lumbar height, body length, and chest girth are calculated using various algorithms. The technical roadmap is shown in Figure 4.

2.4. Improvements to Keypoint Detection Models

2.4.1. Keypoint Detection Based on YOLOv8-Pose

Current 2D human pose estimation techniques are primarily divided into the following two approaches: top-down and bottom-up. The top-down approach first detects each human figure and then estimates the pose for each individually, which is suitable for complex scenes but computationally intensive. Conversely, the bottom-up approach identifies all keypoints first and then groups them, offering faster processing but potentially lower accuracy in densely populated scenes. YOLO-pose integrates the advantages of both methods based on the popular YOLO object detection framework. It accomplishes human detection and pose estimation in a single inference without the need for complex post-processing [26]. This method optimizes the keypoint similarities (OKSs) directly through end-to-end training, foregoing the conventional indirect loss functions based on heatmaps, significantly enhancing computational efficiency and accuracy. YOLO-pose exhibits excellent performance in the COCO dataset, demonstrating its efficacy and precision in practical applications, being particularly suitable for scenarios requiring high real-time performance and accuracy. Hence, we employ YOLOv8-pose for detecting cattle body keypoints.

2.4.2. Content-Aware Restructuring Architecture: CARAFE

CARAFE (Content-Aware ReAssembly of FEatures) is an innovative feature upsampling technique that adaptively reassembles feature maps through a composite framework, as illustrated in Figure 5. This method primarily consists of the following two modules: the kernel prediction module and the content-aware reassembly module [27]. Initially, the kernel prediction module utilizes the input feature map X , generating an adaptive kernel through a channel compressor and content encoder. This adaptive kernel is dynamically produced by considering the content of the feature map and is subsequently standardized through a kernel normalization step. In the content-aware reassembly module, this adaptive kernel is used to spatially transform and reassemble the original feature map, producing the upsampled output feature map X . This method not only improves the accuracy of feature upsampling but also effectively maintains the spatial consistency and content dependency of features, which is particularly crucial for preserving the details and structure in the edge images of cattle bodies. The overall architecture of CARAFE is depicted in Figure 5.

2.4.3. SimSPPF Network

SimSPPF (Simplified Spatial Pyramid Pooling-Fast) is an optimized version of spatial pyramid pooling technology. The core of SPPF (Spatial Pyramid Pooling-Fast) is spatial pyramid pooling, a special pooling technique that performs pooling operations at multiple scales to capture multi-level features of images, enhancing the model’s robustness to scale variations. Introduced in YOLOv6 [28], SimSPPF simplifies this process compared to SPPF, reducing the complexity of convolution and pooling, and replaces the SiLU activation function with ReLU. ReLU features simple threshold operations, while SiLU involves more complex exponential computations. This change enhances performance and reduces the computational burden. By simplifying subsequent convolutions and activation functions, SimSPPF is better suited for resource-constrained environments, such as real-time applications on edge devices, providing a balanced solution between efficiency and performance. The network structure of SimSPPF is depicted in Figure 6.

2.4.4. Improved YOLOv8-Pose Network Model Structure

In the original YOLOv8-pose network, the use of standard Upsample upsampling and SPPF (Spatial Pyramid Pooling-Fast) modules performs well in a variety of scenarios, yet there remains room for improvement in efficiency and accuracy, particularly for cattle keypoint detection tasks in complex environments. This is especially true for edge devices, where resources are limited and a more efficient and accurate model is necessary.
The traditional Upsample module implements upsampling through nearest neighbor or bilinear interpolation. Although simple, this method may lead to upsampling feature maps that need more content awareness and effectively utilize local features, impacting the accuracy of keypoint localization. The integration of the CARAFE (Content-Aware ReAssembly of Features) module allows for content-based adaptive upsampling. CARAFE enhances feature representation and keypoint detection accuracy by predicting an upsampling kernel at each location and reassembling features to generate finer feature maps. Additionally, while the original SPPF module increases the receptive field and captures multi-scale information, it does not maximize operational efficiency. Replacing SPPF with SimSPPF (Simplified Spatial Pyramid Pooling-Fast) reduces computational complexity and model parameters. SimSPPF lightens the model load with a simplified structure while still effectively capturing multi-scale information, making it suitable for use in environments with limited parameters and computational resources.
The improved YOLOv8-pose network, with optimizations in these two major modules, not only enhances the model’s ability to recognize cattle features in complex environments and improves keypoint detection accuracy but also optimizes computational efficiency, making it well suited for edge computing devices. With content-aware upsampling technology and an efficiency-optimized backbone network, the model ensures effective operation even on resource-constrained devices, providing support for real-time cattle monitoring and the keypoint measurement of body dimensions. The structure of the improved YOLOv8-pose network is shown in Figure 7.

2.5. Measuring Methods of Beef Cattle Body Size

2.5.1. Keypoint Processing of Cow Body Depth Image

In this study, after obtaining the cattle body keypoints from RGB images using the improved keypoint detection algorithm, it is essential to ascertain their precise positions in three-dimensional space using information from the depth image. The accuracy of the keypoints identified on the depth image directly influences the effectiveness of cattle body dimension measurements. This process involves multiple steps to ensure optimal mapping and localization of keypoints on the depth image. Initially, we load the depth image stored in 16-bit unsigned integer format and convert it to a single-channel image. Based on multiple experiments, and in conjunction with our method of data collection using a depth camera aligned parallel to the abdomen of the cattle, we have identified the midpoint value between the shoulder and the ischial tuberosity of the cattle as a reliable reference for effective keypoint depth. The average depth of the midpoint and its surrounding points is calculated using neighborhood depth sampling, selecting the average of valid depths (0 to 7000 mm) within a 3 × 3 pixel window around the midpoint as the benchmark depth. This approach provides a stable measurement basis and reduces the impact of depth noise. Subsequently, within a set maximum radius, we locate the nearest valid depth where the difference from the midpoint’s average depth is less than 500 mm, enhancing the accuracy of keypoint depths. The keypoint localization algorithm is illustrated in Algorithm 1. Finally, by combining the image coordinates with the optimized depth values through inverse projection transformation and using the camera’s intrinsic matrix, the conversion to three-dimensional world coordinates is achieved, ensuring precise mapping from two-dimensional images to three-dimensional space. The specific conversion formula is shown in Equation (1), and a schematic diagram of the pixel coordinate transformation to world coordinates is presented in Figure 8.
Z c u v 1 = f x 0 c x 0 f y c y 0 0 1 X c Y c Z c
where ( u , v ) are the pixel coordinates; ( x , y ) are the image coordinates; X c , Y c , Z c are the three-dimensional coordinates of the point in the camera coordinate system; c x , c y are the center coordinates of the image; f x , f y are the focal lengths of the camera.
The following Algorithm 1 is the pseudo-code for this part of the keypoint localization algorithm:
Algorithm 1: Depth Image Processing for Keypoint Localization
path: input file path
shoulder: coordinates of the shoulder endpoint
pin: coordinates of the tuber ischium
avg_depth: average depth value near the midpoint
max_radius: maximum search radius
K: internal parameter matrix
coords: stores the converted world coordinates
1: Function LoadDepthImage(path):
2: image ← cv2.imread(path,cv2.IMREAD_UNCHANGED)
3: if image = None then
4:  exit(1)
5: else
6:  return image[:,:,0]
7: Function GetAverageDepth(image,shoulder,pin):
8: mid ← ((shoulder + pin)/2)
9: return mean depth at 3×3 gird around mid
10: Function FindNearestValidDepth(image,x,y,avg_depth,max_radius):
11: for dx ∈ [−max_radius,max_radius] do
12:  for dy ∈[−max_radius,max_radius] do
13:   depth ← image[y+dy][x+dx]
14:   if 0 < depth ≤ 7000 and |depth − avg_depth| ≤ 500 then
15:    return depth
16: Function GetWorldCoordinates(image,keypoints,K):
17: coords ← {}
18: foreach key,(x,y) ∈ keypoints do
19:  depth ← image[y][x]
20:  if depth valid then
21:   coords[key] ← K−1 ∙ [x,y,1] ∙ depth
22: return coords

2.5.2. Body Height and Body Length Calculation

In the field of livestock and animal science, professionals commonly use measuring sticks and tape measures to measure the body height and body oblique length of cattle. The body height is measured by placing the measuring stick vertically on the ground and aligning it with the highest point of the withers of the cattle, reading the scale value. The body oblique length is measured using a tape measure, stretching it straight from the shoulder endpoint (Shoulder) to the outer edge of the tuber ischium (Pin) along the side of the cattle, recording the distance between these two keypoints. Mimicking the manual measurement method, we use the Euclidean distance formula to calculate the spatial length from the highest point of the withers (Withers) to the bottom of the hoof (Sole) to obtain the cattle’s body height. Similarly, the body oblique length calculation is derived from the Euclidean distance d between the shoulder endpoint (Shoulder) and the outer edge of the tuber ischium (Pin). The Euclidean distance formula is shown in Equation (2), and the calculations for body height and body oblique length are illustrated in Figure 9.
d = X 2 X 1 2 + Y 2 Y 1 2 + Z 2 Z 1 2
where ( X 2 , Y 2 , Z 2 ) and ( X 1 , Y 1 , Z 1 ) are the world coordinates of two points, respectively.

2.5.3. Lumbar Height Calculation

Professionals typically use a measuring stick to measure the lumbar of cattle manually. The operator places the measuring stick vertically on the ground, ensuring that its base is flush with the ground and the top end is snug against the cattle’s lumbar point. The height reading on the stick represents the lumbar height. In this study, we first identify the sole point (Sole) as a key marker for contact with the ground, with its depth value reflecting the distance from the depth camera to the ground. Subsequently, we combine the lateral coordinate of the lumbar point (Lumbar) with the longitudinal coordinate of the sole, and, using the depth value of the sole point (Sole), we construct a new three-dimensional point located on the ground plane directly beneath the lumbar point. Finally, the lumbar height is calculated using the Euclidean distance between the lumbar point (Lumbar) and this new three-dimensional point. The calculation of lumbar height is illustrated in Figure 10.

2.5.4. Chest Girth Calculation

Professional measurers typically stand at the side of the cattle, wrapping a tape measure from the rear edge of the withers (Chest1) around the chest to the vertical point of the chest base (Chest2), ensuring the tape is horizontal and snug against the cow’s skin, and recording the measurement on the tape as the chest girth. Previous methods of measuring cattle chest girth often required the use of two or more depth cameras to create three-dimensional reconstructions or point clouds from the depth images obtained. These methods are generally costly, difficult to maintain, and slower in generating and processing point clouds compared to simple two-dimensional image processing, especially when dealing with large data volumes, which may affect real-time analysis and processing capabilities.
This study proposes a method using depth imaging combined with machine learning techniques to estimate livestock chest girth. Initially, several intermediate points are generated between the established 3D space keypoints Chest1 and Chest2, forming a continuous curve segment in three dimensions. The upper half’s intermediate points are symmetrically transformed along the Y-axis to create mirror points on the other side of the chest girth. Next, to optimize the spatial positioning of these intermediate points, the Moving Least Squares (MLS) method [29] and Radial Basis Function (RBF) [30] are applied to adjust the set of points. This method not only considers the position of each point but also the distribution of nearby points to fine-tune each point’s coordinates, effectively addressing local anomalies caused by outlier points and ensuring the curve’s overall consistency. Through RBF processing, the coordinates of each interpolation point are recalculated, enhancing the overall structural stability of the point set while maintaining the continuity of the curve. After obtaining the data points curve for the upper half, the cubic B-spline interpolation method [31] is used to predict and complete the lower half of the chest girth curve. Finally, the distances between adjacent points on the loop are summed using the Euclidean distance formula to calculate the chest girth. The pseudo-code for chest girth calculation and its visualization are shown in Algorithm 2 and Figure 11.
The following Algorithm 2 is the pseudo-code for this part of chest girth calculation algorithm:
Algorithm 2: Calculate Chest Circumference from Depth Image
Chest1: coordinates of the rear edge of the withers
Chest2: coordinates of the vertical point of the chest base
t: a linear space
smooth_factor: smoothing factor
rbf_x, rbf_y, and rbf_z: radial basis function interpolation objects
t_new: newly generated time series
tck: parameters of the strip interpolation
x_fine, y_fine, and z_fine: interpolated x, y, and z coordinates
1: Function GenerateIntermediatePoints(world_coords,num_points):
2:  point1 ← world_coords[“Chest1”]
3:  point2 ← world_coords[“Chest2”]
4:  t ← np.linspace(0,1,num_points)
5:  return point1 + t[:,None] ∙ (point2 – point1)
6: Function MlsFitting(points,smooth_factor):
7:  x,y,z ← points[:,0],points[:,1],points[:,2]
8:  rbf_x ← Rbf(np.arange(len(x)),x,’multiquadric’,smooth = smooth_factor)
9:  rbf_y ← Rbf(np.arange(len(y)),y,’multiquadric’,smooth = smooth_factor)
10: rbf_z ← Rbf(np.arange(len(z)),z,’multiquadric’,smooth = smooth_factor)
11: t_new ← np.linspace(0,len(x) – 1,len(x) × 10)
12: return np.vstack(rbf_x(t_new),rbf_y(t_new),rbf_z(t_new)).T
13: Function CompleteEllipse(upper_points):
14: mirrored_points ← np.copy(upper_points)
15: mirrored_points[:,1] ← − mirrored_points[:,1]
16: all_points ← np.vstack(upper_points,mirrored_points)
17: (tck,u) ← splprep([all_points[:,0],all_points[:,1],all_points[:,2]],s = 0)
18: u_fine ← np.linspace(0,1,len(all_points) × 10)
19: (x_fine,y_fine,z_fine) ← splev(u_fine,tck)
20: return np.vstack(x_fine,y_fine,z_fine).T

2.6. Evaluation Indicators

2.6.1. Keypoint Detection Model Evaluation Indicators

In this study, we utilize the Object Keypoint Similarity ( O K S ) to quantify the degree of match between the predicted keypoints and the true keypoints. The O K S is a widely used metric for human pose estimation tasks and is applicable for evaluating the performance of any type of keypoint detection, including animals. The formula for calculating the O K S is shown in Equation (3).
O K S P = i   e x p d p i 2 / 2 S p i 2 σ i 2 δ v p i > 0 i   δ v p i > 0
δ = = 1 v p i > 0 = 0 v p i 0
where d p i represents the Euclidean distance between the predicted position and the true position of the i keypoint. p   and   i represent the IDs of the target cow and keypoints, respectively. S p represents the object scale of p . σ i represents the normalization factor of the i keypoint. v i represents the visibility of the i keypoint, 0 means unmarked, 1 means marked but obscured, and 2 means marked and visible.
Therefore, we use the threshold defined by the O K S to calculate the Average Precision ( A P ). If the O K S is greater than 0.5, the result is classified as a true positive; if O K S is less than or equal to 0.5, the result is classified as a false positive. Thus, the mean A P calculated at an O K S value of 0.5 is used as the evaluation metric. The formula for calculating A P is shown in Equation (4), and the formula for m A P is shown in Equation (5).
A P = p   δ O K S p > 0.5 p   1
m A P = i = 1 N A P i N
Additionally, to ensure the efficiency and reliability of the model in various real-world application scenarios and to lay the foundation for practical deployment and application, we use Precision, Recall, GFLOPs, and Parameters as performance metrics to measure model detection accuracy, robustness, computational complexity, and resource consumption. Equation (6) provides the formula for calculating Precision and Equation (7) provides the formula for calculating Recall.
P r e c i s i o n = T P ( T P + T N )
R e c a l l = T P ( T P + F N )

2.6.2. Body Size Measurement Evaluation Index

We employ Mean Absolute Error (MAE) and Mean Relative Error (MRE) as metrics to evaluate the accuracy of body dimension measurements, which offer distinct advantages. Firstly, MAE, a fundamental regression metric, directly reflects the average deviation between predicted and actual values, quantifying the precision of the body measurement model and delivering a clear measure of error. This is crucial for assessing the algorithm’s applicability across various scenarios.
Secondly, MRE, by calculating the error as a proportion of the actual value, offers a relative scale for error assessment. This method of measuring relative error better adapts to the scale differences in body measurements of cattle of varying sizes, enhancing the universality and robustness of the error evaluation. When dealing with cattle of diverse body types or significant differences in body dimensions in particular, MRE effectively represents the model’s stability and consistency across different scales. Therefore, by integrating both MAE and MRE, we provide a dual verification that allows for a comprehensive assessment of the body dimension measurement model’s performance. The formulas for MAE and MRE are shown in Equations (8) and (9).
MAE   = 1 n i = 1 n   x ^ i x i
    M R E   = 100 % n i = 1 n   x ^ i x i x i

3. Results and Analysis

3.1. Improved Results of YOLOv8-Pose

3.1.1. Comparison of Keypoint Detection Using Different Algorithms

To enhance the accuracy of keypoint detection in cattle, we evaluated several models, including YOLOv5-Pose, YOLOv7-Pose, RTMpose[32], YOLOv8-Pose, and an improved version of YOLOv8-Pose. As indicated in Table 1, while YOLOv5-Pose and YOLOv7-Pose require relatively more parameters and computational resources, RTMpose has the lowest GFLOPs but suffers from lower mAP and a larger model size, which could compromise keypoint detection performance. YOLOv8-Pose exhibited the highest accuracy and performed well in terms of parameter count and model size. This confirms the practical applicability and superiority of the improvements made to the YOLOv8-Pose keypoint detection model.

3.1.2. Model Performance Ablation Experiment

In this study, the YOLOv8-pose network model was employed, with enhancements such as the incorporation of SimSPPF in the backbone to optimize spatial pyramid pooling within the convolutional neural network and the integration of CARAFE in the neck to improve feature upsampling. A series of ablation studies were conducted to assess the impact of these modifications on the overall model performance. These experiments were designed to pinpoint the specific contributions of each component towards enhancing the model’s keypoint detection accuracy in complex environments.
As shown in Table 2, using YOLOv8-pose alone resulted in a Precision of 95.7%, a Recall of 87%, and a mAP of 92.4%, with the model size being 6.17 MB. The introduction of CARAFE increased the Precision to 96.3%, although the Recall was slightly decreased to 86.6%, while the mAP improved to 93.5% and the model size slightly increased to 6.47 MB, demonstrating the benefits of CARAFE-enabled upsampling technology. Furthermore, the sole use of SimSPPF, despite a slight decrease in Precision to 93.5%, saw an increase in Recall to 88.4% and an enhancement in mAP to 93.8%, with the model size remaining unchanged, indicating the efficacy of SimSPPF in optimizing feature extraction efficiency. Ultimately, the simultaneous incorporation of CARAFE and SimSPPF showcased optimal performance, with the highest Precision being 96.7% and the mAP reaching a peak of 94.4%, while the model size only marginally increased to 6.45 MB. These results confirm that meticulous integration and optimization of functionalities can significantly enhance the performance of deep learning models while controlling the model size to ensure efficiency.

3.1.3. Improved Keypoint Detection Results

The enhanced YOLOv8-pose model was compared with the original model under various conditions. Figure 12a depicts a scenario with good outdoor lighting, Figure 12b shows the cattle standing, Figure 12c illustrates the cattle with their heads down, and Figure 12d captures the cattle walking. Due to the movement of the cattle or the influence of the surrounding environment, keypoints on the cattle’s body are prone to extend beyond the edges of the body. The improved YOLOv8-pose model is able to more accurately identify keypoints on the cattle’s edges in complex situations.

3.2. Body Size Measurement Results

3.2.1. Normality Test

Normality testing ensures that the data conforms to the basic assumptions of many statistical analysis methods, which is an important step in assessing model accuracy, as standard error estimation methods typically assume data follow a normal distribution. By conducting Anderson–Darling tests, Shapiro–Wilk tests, and analyses of skewness and kurtosis [33,34] on manually measured cattle size parameters, we can accurately determine the distribution of small sample data. In Figure 13, the light blue histograms represent the frequency distribution of body size parameters, the black curve represents the normal distribution curve fitted based on the data’s mean and standard deviation, the orange dashed line represents the mean of the data, and the green dashed lines define the 95% confidence interval for the mean. From Table 3 and Figure 13, the following conclusions can be drawn: In the Shapiro–Wilk test, the statistics for the four parameters (body height, lumbar height, body length, and chest circumference) are close to 1, with p-values above the 0.05 significance level of 5%. In the Anderson–Darling test, the statistics for all parameters are below the critical value of 0.699 corresponding to the 5% significance level. Furthermore, the skewness and kurtosis of these body size parameters are close to 0, indicating that these parameters all exhibit characteristics of a normal distribution. These findings validate the normality of manually measured data, ensuring that the measurement results truly reflect the actual production situation, enhancing the practicality and universality of the study.

3.2.2. Measurement Results and Analysis

In this study, we measured the body dimensions of 23 cattle, including body height, lumbar height, body length, and chest girth. Using the improved YOLOv8-pose network model, we automatically detected keypoints on the cattle’s body and calculated the corresponding body dimensions based on these points. The measurement results are shown in Table 4, demonstrating the accuracy and consistency of this method across four types of body dimensions. Table 5 further summarizes the Mean Absolute Error (MAE), Mean Relative Error (MRE), and maximum relative error as follows: the average absolute error for Body height is 1.52 cm, with an average relative error of 1.28%, and a maximum relative error of 3.94%. The MAE for lumbar height is 3.83 cm, the MRE is 3.02%, and the maximum error is 6.30%. The MAE for body length is 9.77 cm, the MRE is 6.47%, and the maximum error is 12.03%, which may be influenced by the choice of measurement points or the posture of the cattle. The MAE for chest girth is 7.39 cm, the MRE is 4.43%, and the maximum error is 9.80%, reflecting the challenges in measuring complex body shapes. Additionally, Figure 14 further reveals the variability in error distribution across the four dimensions; the box plots for body height and lumbar height show very compact error distributions, indicating high consistency and reliability of measurements across the sample for these dimensions. The box plots for body length and chest girth reveal a relatively wider range of errors; the median and mean for body length are relatively far apart, possibly indicating potential challenges during measurement, such as chest girth measurements being affected by the breathing and muscle tension of the cattle, and body length is potentially affected by the natural standing posture of the animals.
Our study confirms that the method of automatic measurement of cattle body dimensions, based on improved keypoint detection combined with single-side depth images, is both practical and reliable. The method demonstrates significant accuracy and consistency, particularly in the measurements of body height, lumbar height, and chest girth, making it a valuable tool for real-world applications.

4. Discussion

In the discussion section of this paper, we meticulously explore the impact of various environmental factors on the accuracy of measuring cattle body dimensions. Specifically, this study systematically analyzes the specific effects of images with different noise levels, various measuring distances, and different cattle postures on cattle body dimension measurements. Discussing these factors is crucial for understanding and optimizing the application of automatic body measurement systems in real agricultural production environments. Additionally, we also thoroughly discuss the applications of the model.

4.1. Effects of Different Noises on the Measurement of Beef Cattle Body Dimensions

Different noises may affect the detection of keypoints on RGB images, thereby impacting the accuracy of body dimension measurements. To explore the impact of environmental noise, 51 randomly selected cattle images from the dataset were processed under simulated conditions of foggy, rainy, and snowy weather. In foggy conditions, image contrast and saturation are reduced, and slight Gaussian blur is added to simulate visual blurring and color fading, as fog can reduce image clarity. Rain simulation involves adding random noise and motion blur to mimic the dynamic impact of raindrops, as raindrops might be misidentified as part of the cattle. For snowy conditions, white noise, slight blur, and increased brightness threshold are used to simulate snow cover and bright winter environments, as the reflective properties of snowflakes can introduce optical noise.
Specifically, in foggy noise environments, the Mean Absolute Error (MAE) for body height increased by 0.43 cm and the Mean Relative Error (MRE) increased by 0.36%; the MAE for lumbar height increased by 0.78 cm and the MRE increased by 0.58%; the MAE for body length increased by 0.67 cm and the MRE by 0.45%; and the MAE for chest girth increased by 0.96 cm and the MRE by 0.55%. In rainy noise environments, the MAE for body height increased by 1.09 cm and the MRE increased by 0.91%; the MAE for lumbar height increased by 1.11 cm and the MRE by 0.85%; the MAE for body length increased by 3.11 cm and the MRE by 2.09%; and the MAE for chest girth increased by 1.16 cm and the MRE increased by 0.67%. In snowy noise environments, the MAE for body height increased by 1.38 cm and the MRE by 0.96%; the MAE for lumbar height increased by 1.38 cm and the MRE by 1.07%; the MAE for body length increased by 3.25 cm and the MRE by 2.17%; and the MAE for chest girth slightly increased by 0.03 cm and the MRE increased by 0.02%. The results show that, even when cattle images are affected by blurring, noise, and other factors, the improved keypoint detection model maintains high recognition accuracy and robustness. Although MAE and MRE have increased, they are still within acceptable ranges, demonstrating the practicality of our automatic body dimension measurement system in complex environments. The effects of different noises on keypoint detection and body dimension measurement outcomes are illustrated in Figure 15.

4.2. Effects of Different Distances on the Measurement of Beef Cattle Body Size

We evaluated the accuracy of cattle body dimension measurements at different distances to explore the impact of distance on the measurements. We randomly selected cattle for study at distances of 1–2 m, 2–3 m, 3–4 m, and 4–5 m. We found that the impact of distance on measurement results showed clear differences. Specifically, the Mean Relative Error (MRE) within the 1–2 m distance range was 6.16%, while the MRE decreased to 3.89% in the 2–3 m range. Within the 3–4 m range, the error further reduced to 2.62%, but, in the 4–5 m range, the MRE increased to 5.07%. These results indicate a significant correlation between measurement accuracy and distance while also displaying that increasing distance does not always lead to increased error but rather shows a nonlinear trend, with 2–4 m being the optimal distance for the automatic body dimension measurement system. Moreover, even at longer distances (4–5 m), the resulting error remains within acceptable limits, validating the reliability and practicality of the measurement system used in this study for real-world applications. The impact of different distances on cattle body dimension measurements is shown in Figure 16.

4.3. Effects of Different Postures on the Measurement of Beef Cattle Body Size

Validating the robustness of the model under different cattle postures holds critical practical value for actual production. We randomly selected cattle to study their measurement accuracy in three common postures: upright standing, head-lowering, and walking. Results indicate that posture differences significantly impact measurement accuracy. The lowest mean relative error, at 3.83%, occurred in the upright standing posture, demonstrating high reliability in reflecting the natural body shape and dimensions of cattle. In the head-lowering posture, the stretching of the neck and back, along with adjustments in the shoulders and forelimbs, cause morphological changes in skeletal and muscle structures. This head-lowering action may cause displacement of key measurement points or obstruct the view, increasing the mean relative error to 4.62%. In the natural walking state, the muscular and skeletal structures of cattle exhibit significant dynamic adaptability. As cattle walk, their limbs move back and forth in a coordinated gait cycle, pulling muscle groups to contract and relax accordingly, maintaining balance and propulsion. This continuous dynamic change can cause real-time shifts in the positions of key measurement points, increasing measurement errors, reflected by a mean relative error of 7.04%. The impacts of different postures on cattle body dimension measurements are shown in Figure 17.

4.4. Model Application and Outlook

In the context of the rapid development of precision livestock farming [35], the importance of non-contact cattle body measurement techniques is increasingly prominent. The complexity of modern farming environments is primarily reflected in the variability of climatic conditions, diverse geographical environments, and varied farming methods. These factors make standardized management and monitoring extremely difficult. Although non-contact measurement methods using point clouds or 3D reconstruction ensure accuracy, they come with limitations such as high costs, complex algorithms, and dependence on specific measurement conditions.
Against this backdrop, we have designed a new method for measuring cattle body dimensions using edge devices. These devices, such as robotic dogs, can autonomously navigate and operate in complex farm terrains without direct human–animal contact, significantly reducing labor intensity and enhancing operational flexibility. First, images captured by depth cameras mounted on robots are transmitted in real-time to a central server or cloud platform via wireless networks for processing. Then, the server runs an improved YOLOv8-pose model that can accurately identify keypoints on the cattle, such as the withers and chest base, in real-time. Finally, these keypoints are used by the server to calculate cattle body dimensions like body height, lumbar height, body length, and girth, which are then visually displayed for real-time viewing by veterinarians and farmers. The non-contact body measurement system is depicted in Figure 18.
In real application scenarios, where measurement of specific target cattle among multiple animals is required, we plan to integrate target detection [36], tracking technology [37] and individual identification techniques [38,39]. First, target detection and tracking technology can identify and monitor the dynamic positions of cattle in complex environments in real-time, which is crucial for continuous tracking of cattle’s natural behavior and social interactions. At the same time, individual identification technology ensures that each measurement is accurately attributed to the corresponding cattle. By combining these technologies, not only can efficient data collection be achieved, but the accuracy of the data and the precise identification of individuals can also be ensured.

5. Conclusions

This paper proposes an automatic cattle body measurement method tailored for practical scenarios, utilizing an improved keypoint detection technique based on the YOLOv8-pose model integrated with single-side depth images of cattle. The YOLOv8-pose model was selected, and its architecture was optimized by replacing the original SPPF with SimSPPF in the backbone for improved spatial pyramid pooling and incorporating CARAFE in the neck to replace the Upsample layer for upsampling. The improved YOLOv8-pose achieved an mAP of 94.4%, which is a 2% improvement over the baseline model. The improved model exhibits enhanced sensitivity to keypoints at the edges. Subsequently, cattle body keypoints from RGB images captured by the refined YOLOv8-pose were mapped onto depth images. These keypoints were then refined using conditional filtering and calculated using techniques such as Euclidean distance, Moving Least Squares (MLS), Radial Basis Function (RBF), and Cubic B-spline Interpolation (CB-SI) to determine the cattle’s body dimensions. Comparative analysis against the actual dimensions of 23 cattle revealed that the average absolute errors (MAE) for body height, lumbar height, body length, and chest girth were 1.52 cm, 3.83 cm, 9.77 cm, and 7.39 cm, respectively, with average relative errors (MRE) of 1.28%, 3.02%, 6.47%, and 4.43% and maximum relative errors of 3.94%, 6.30%, 12.03%, and 9.80%. These results indicate that the measurement method using single-side depth images of cattle is highly accurate and could reduce equipment costs, demonstrating potential for application in real farm environments and offering a new approach for non-contact cattle body measurement.

Author Contributions

Conceptualization, C.P. and W.S.; methodology, C.P.; software, C.P.; validation, W.S., S.C. and T.B.; formal analysis, S.L. and Z.Z.; investigation, Z.Z. and T.B.; resources, T.B. and W.S.; data curation, C.P.; writing—original draft preparation, C.P.; writing—review and editing, W.S. and S.C.; visualization, C.P. and S.C.; supervision, S.L. and T.B.; project administration, S.L. and W.S.; funding acquisition, W.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research was supported by the Chinese Academy of Agricultural Sciences Science and Technology Innovation Project (10-IAED-RC-09-2024); Jilin Province Key Research and Development Project (20240303079NC); the Fundamental Research Funds for the Universities of the Autonomous Region (XJEDU2022J009); and special Fund for Basic Research Operations of Public Welfare Research Institutes at the Agricultural Information Institute of the Chinese Academy of Agricultural Sciences. (JBYW-AII-2023-10).

Institutional Review Board Statement

In this study, ethical review and approval were not required due to the non-invasive and observational nature of the research. Our procedures ensured that there was no direct contact with the cattle, nor did our methods induce any stress or disrupt the normal activities of the animals. Therefore, the study adhered to ethical guidelines by maintaining a non-intrusive approach that safeguarded the welfare of the cattle involved.

Informed Consent Statement

Written informed consent has been obtained from the owner(s) of animals involved in this study.

Data Availability Statement

Data are available on request from the authors.

Conflicts of Interest

We declare that Hebei Tianhe Beef Cattle Farming Ltd. provided the experimental site and technical guidance in the filed of animal husbandry for this study, but did not influence the research design, data interpretation or final results, ensuring the objectivity and fairness of the research findings.

References

  1. Growing at a Slower Pace. World Population Is Expected to Reach 9.7 Billion in 2050 and Could Peak at Nearly 11 Billion around 2100|UN DESA|United Nations Department of Economic and Social Affairs. Available online: https://www.un.org/development/desa/en/news/population/world-population-prospects-2019.html (accessed on 13 July 2024).
  2. Henchion, M.; Moloney, A.P.; Hyland, J.; Zimmermann, J.; McCarthy, S. Review: Trends for Meat, Milk and Egg Consumption for the next Decades and the Role Played by Livestock Systems in the Global Production of Proteins. Animal 2021, 15, 100287. [Google Scholar] [CrossRef]
  3. Jeffery, H.B.; Berg, R.T. An Evaluation of Several Measurements of Beef Cow Size as Related to Progeny Performance. Can. J. Anim. Sci. 1972, 52, 23–37. [Google Scholar] [CrossRef]
  4. Heng-wei, Y.; Raza, S.H.A.; Almohaimeed, H.M.; Alzahrani, S.S.; Alkhalifah, S.M.; Yasir B, A.L.; Yasir B, A.L.; Zan, L. The Body Weight Heritability and the Effect of Non-Genetic Factors on the Body Measurement Traits in Qinchuan Cattle. Anim. Biotechnol. 2023, 34, 4387–4393. [Google Scholar] [CrossRef]
  5. Dirksen, N.; Gygax, L.; Traulsen, I.; Wechsler, B.; Burla, J.-B. Body Size in Relation to Cubicle Dimensions Affects Lying Behavior and Joint Lesions in Dairy Cows. J. Dairy Sci. 2020, 103, 9407–9417. [Google Scholar] [CrossRef] [PubMed]
  6. Hozáková, K.; Vavrišínová, K.; Neirurerová, P.; Bujko, J. Growth of Beef Cattle as Prediction for Meat Production: A Review. Acta Fytotech. Zootech. 2020, 23. [Google Scholar] [CrossRef]
  7. Sieber, M.; Freeman, A.E.; Kelley, D.H. Effects of Body Measurements and Weight on Calf Size and Calving Difficulty of Holsteins1. J. Dairy Sci. 1989, 72, 2402–2410. [Google Scholar] [CrossRef]
  8. Wang, Y.; Mücher, S.; Wang, W.; Guo, L.; Kooistra, L. A Review of Three-Dimensional Computer Vision Used in Precision Livestock Farming for Cattle Growth Management. Comput. Electron. Agric. 2023, 206, 107687. [Google Scholar] [CrossRef]
  9. Qiao, Y.; Kong, H.; Clark, C.; Lomax, S.; Su, D.; Eiffert, S.; Sukkarieh, S. Intelligent Perception for Cattle Monitoring: A Review for Cattle Identification, Body Condition Score Evaluation, and Weight Estimation. Comput. Electron. Agric. 2021, 185, 106143. [Google Scholar] [CrossRef]
  10. Yin, M.; Ma, R.; Luo, H.; Li, J.; Zhao, Q.; Zhang, M. Non-Contact Sensing Technology Enables Precision Livestock Farming in Smart Farms. Comput. Electron. Agric. 2023, 212, 108171. [Google Scholar] [CrossRef]
  11. Seo, K.-W.; Lee, D.-W.; Choi, E.-G.; Kim, C.-H.; Kim, H.-T. Algorithm for Measurement of the Dairy Cow’s Body Parameters by Using Image Processing. J. Biosyst. Eng. 2012, 37, 122–129. [Google Scholar] [CrossRef]
  12. Tasdemir, S.; Urkmez, A.; Inal, S. Determination of Body Measurements on the Holstein Cows Using Digital Image Analysis and Estimation of Live Weight with Regression Analysis. Comput. Electron. Agric. 2011, 76, 189–197. [Google Scholar] [CrossRef]
  13. Viazzi, S.; Bahr, C.; Van Hertem, T.; Schlageter-Tello, A.; Romanini, C.E.B.; Halachmi, I.; Lokhorst, C.; Berckmans, D. Comparison of a Three-Dimensional and Two-Dimensional Camera System for Automated Measurement of Back Posture in Dairy Cows. Comput. Electron. Agric. 2014, 100, 139–147. [Google Scholar] [CrossRef]
  14. Spoliansky, R.; Edan, Y.; Parmet, Y.; Halachmi, I. Development of Automatic Body Condition Scoring Using a Low-Cost 3-Dimensional Kinect Camera. J. Dairy Sci. 2016, 99, 7714–7725. [Google Scholar] [CrossRef]
  15. Gao, Y.; Li, Z.; Li, B.; Zhang, L. Extraction of Corn Plant Phenotypic Parameters with Keypoint Detection and Stereo Images. Agronomy 2024, 14, 1110. [Google Scholar] [CrossRef]
  16. Rodríguez Alvarez, J.; Arroqui, M.; Mangudo, P.; Toloza, J.; Jatip, D.; Rodriguez, J.M.; Teyseyre, A.; Sanz, C.; Zunino, A.; Machado, C.; et al. Estimating Body Condition Score in Dairy Cows From Depth Images Using Convolutional Neural Networks, Transfer Learning and Model Ensembling Techniques. Agronomy 2019, 9, 90. [Google Scholar] [CrossRef]
  17. Miller, G.A.; Hyslop, J.J.; Barclay, D.; Edwards, A.; Thomson, W.; Duthie, C.-A. Using 3D Imaging and Machine Learning to Predict Liveweight and Carcass Characteristics of Live Finishing Beef Cattle. Front. Sustain. Food Syst. 2019, 3, 30. [Google Scholar] [CrossRef]
  18. Ruchay, A.; Kober, V.; Dorofeev, K.; Kolpakov, V.; Miroshnikov, S. Accurate Body Measurement of Live Cattle Using Three Depth Cameras and Non-Rigid 3-D Shape Recovery. Comput. Electron. Agric. 2020, 179, 105821. [Google Scholar] [CrossRef]
  19. Shi, S.; Yin, L.; Liang, S.; Zhong, H.; Tian, X.; Liu, C.; Sun, A.; Liu, H. Research on 3D Surface Reconstruction and Body Size Measurement of Pigs Based on Multi-View RGB-D Cameras. Comput. Electron. Agric. 2020, 175, 105543. [Google Scholar] [CrossRef]
  20. Huang, L.; Li, S.; Zhu, A.; Fan, X.; Zhang, C.; Wang, H. Non-Contact Body Measurement for Qinchuan Cattle with LiDAR Sensor. Sensors 2018, 18, 3014. [Google Scholar] [CrossRef]
  21. Le Cozler, Y.; Allain, C.; Caillot, A.; Delouard, J.M.; Delattre, L.; Luginbuhl, T.; Faverdin, P. High-Precision Scanning System for Complete 3D Cow Body Shape Imaging and Analysis of Morphological Traits. Comput. Electron. Agric. 2019, 157, 447–453. [Google Scholar] [CrossRef]
  22. Wang, K.; Zhu, D.; Guo, H.; Ma, Q.; Su, W.; Su, Y. Automated Calculation of Heart Girth Measurement in Pigs Using Body Surface Point Clouds. Comput. Electron. Agric. 2019, 156, 565–573. [Google Scholar] [CrossRef]
  23. Du, A.; Guo, H.; Lu, J.; Su, Y.; Ma, Q.; Ruchay, A.; Marinello, F.; Pezzuolo, A. Automatic Livestock Body Measurement Based on Keypoint Detection with Multiple Depth Cameras. Comput. Electron. Agric. 2022, 198, 107059. [Google Scholar] [CrossRef]
  24. Yang, G.; Xu, X.; Song, L.; Zhang, Q.; Duan, Y.; Song, H. Automated Measurement of Dairy Cows Body Size via 3D Point Cloud Data Analysis. Comput. Electron. Agric. 2022, 200, 107218. [Google Scholar] [CrossRef]
  25. LabelMe: A Database and Web-Based Tool for Image Annotation|International Journal of Computer Vision. Available online: https://link.springer.com/article/10.1007/s11263-007-0090-8 (accessed on 12 July 2024).
  26. Maji, D.; Nagori, S.; Mathew, M.; Poddar, D. YOLO-Pose: Enhancing YOLO for Multi Person Pose Estimation Using Object Keypoint Similarity Loss. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition 2022, New Orleans, LA, USA, 18–24 June 2022; pp. 2637–2646. [Google Scholar]
  27. Wang, J.; Chen, K.; Xu, R.; Liu, Z.; Loy, C.C.; Lin, D. CARAFE: Content-Aware Reassembly of Features. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Seoul, Republic of Korea, 27 October–2 November 2019; pp. 3007–3016. [Google Scholar]
  28. Li, C.; Li, L.; Geng, Y.; Jiang, H.; Cheng, M.; Zhang, B.; Ke, Z.; Xu, X.; Chu, X. YOLOv6 v3.0: A Full-Scale Reloading 2023. arXiv 2023, arXiv:2301.05586. [Google Scholar]
  29. Lancaster, P.; Salkauskas, K. Surfaces Generated by Moving Least Squares Methods. Math. Comput. 1981, 37, 141–158. [Google Scholar] [CrossRef]
  30. Buhmann, M.; Jäger, J. On Radial Basis Functions. Snapshots of modern mathematics from Oberwolfach. Numer. Sci. Comput. 2019, 2019, 2. [Google Scholar] [CrossRef]
  31. Unser, M.; Aldroubi, A.; Eden, M. Fast B-Spline Transforms for Continuous Image Representation and Interpolation. IEEE Trans. Pattern Anal. Mach. Intell. 1991, 13, 277–285. [Google Scholar] [CrossRef]
  32. Jiang, T.; Lu, P.; Zhang, L.; Ma, N.; Han, R.; Lyu, C.; Li, Y.; Chen, K. RTMPose: Real-Time Multi-Person Pose Estimation Based on MMPose. arXiv 2023, arXiv:2303.07399. [Google Scholar]
  33. Zhang, Q.; Hou, Z.; Huang, L.; Wang, F.; Meng, H. Reparation with Moving Least Squares Sampling and Extraction of Body Sizes of Beef Cattle from Unilateral Point Clouds. Comput. Electron. Agric. 2024, 224, 109208. [Google Scholar] [CrossRef]
  34. Babcock, A.H.; Cernicchiaro, N.; White, B.J.; Dubnicka, S.R.; Thomson, D.U.; Ives, S.E.; Scott, H.M.; Milliken, G.A.; Renter, D.G. A Multivariable Assessment Quantifying Effects of Cohort-Level Factors Associated with Combined Mortality and Culling Risk in Cohorts of U.S. Commercial Feedlot Cattle. Prev. Vet. Med. 2013, 108, 38–46. [Google Scholar] [CrossRef] [PubMed]
  35. Tahir, M.N.; Lan, Y.; Zhang, Y.; Wenjiang, H.; Wang, Y.; Naqvi, S.M. Chapter 4—Application of Unmanned Aerial Vehicles in Precision Agriculture. In Precision Agriculture; Zaman, Q., Ed.; Academic Press: Cambridge, MA, USA, 2023; pp. 55–70. ISBN 978-0-443-18953-1. [Google Scholar]
  36. The Theory of Search. II. Target Detection|Operations Research. Available online: https://pubsonline.informs.org/doi/abs/10.1287/opre.4.5.503 (accessed on 11 July 2024).
  37. Gardenier, J.; Underwood, J.; Clark, C. Object Detection for Cattle Gait Tracking. In Proceedings of the 2018 IEEE International Conference on Robotics and Automation (ICRA), Brisbane, Australia, 21–25 May 2018; IEEE: Brisbane, Australia, 2018; pp. 2206–2213. [Google Scholar]
  38. Xu, X.; Wang, Y.; Hua, Z.; Yang, G.; Li, H.; Song, H. Light-Weight Recognition Network for Dairy cows Based on the Fusion ofYOLOv5s and Channel Pruning Algorithm. Trans. Chin. Soc. Agric. Eng. 2023, 39, 152–162. [Google Scholar] [CrossRef]
  39. Xu, X.; Deng, H.; Wang, Y.; Zhang, S.; Song, H. Boosting Cattle Face Recognition under Uncontrolled Scenes by Embedding Enhancement and Optimization. Appl. Soft Comput. 2024, 164, 111951. [Google Scholar] [CrossRef]
Figure 1. Data collection and body measurement scenes. (a) Image acquisition environment. (b) Image acquisition equipment. (c) Measurement equipment. (d) Body scale measurement environment.
Figure 1. Data collection and body measurement scenes. (a) Image acquisition environment. (b) Image acquisition equipment. (c) Measurement equipment. (d) Body scale measurement environment.
Animals 14 02453 g001
Figure 2. Dataset example graph.
Figure 2. Dataset example graph.
Animals 14 02453 g002
Figure 3. Data Annotation.
Figure 3. Data Annotation.
Animals 14 02453 g003
Figure 4. Technology Roadmap.
Figure 4. Technology Roadmap.
Animals 14 02453 g004
Figure 5. Overall architecture of CARAFE.
Figure 5. Overall architecture of CARAFE.
Animals 14 02453 g005
Figure 6. SimSPFF network structure diagram.
Figure 6. SimSPFF network structure diagram.
Animals 14 02453 g006
Figure 7. Improved YOLOv8-pose network structure diagram.
Figure 7. Improved YOLOv8-pose network structure diagram.
Animals 14 02453 g007
Figure 8. Schematic diagram of pixel coordinates to world coordinates conversion.
Figure 8. Schematic diagram of pixel coordinates to world coordinates conversion.
Animals 14 02453 g008
Figure 9. Schematic diagram of body height and body length calculation.
Figure 9. Schematic diagram of body height and body length calculation.
Animals 14 02453 g009
Figure 10. Schematic diagram of lumbar height calculation.
Figure 10. Schematic diagram of lumbar height calculation.
Animals 14 02453 g010
Figure 11. Chest circumference calculation curve.
Figure 11. Chest circumference calculation curve.
Animals 14 02453 g011
Figure 12. Keypoint prediction results. (a) In excellent lighting conditions; (b) with the cow standing; (c) with the cow bowing its head; (d) with the cow walking.
Figure 12. Keypoint prediction results. (a) In excellent lighting conditions; (b) with the cow standing; (c) with the cow bowing its head; (d) with the cow walking.
Animals 14 02453 g012
Figure 13. Normality test results: (a) indicates the results of body height; (b) indicates the results of lumbar height; (c) indicates the results of body length; (d) indicates the results of chest girth.
Figure 13. Normality test results: (a) indicates the results of body height; (b) indicates the results of lumbar height; (c) indicates the results of body length; (d) indicates the results of chest girth.
Animals 14 02453 g013
Figure 14. Body size measurement box plot results.
Figure 14. Body size measurement box plot results.
Animals 14 02453 g014
Figure 15. Results of keypoint detection and body size measurement under different noise conditions.
Figure 15. Results of keypoint detection and body size measurement under different noise conditions.
Animals 14 02453 g015
Figure 16. Keypoint detection and body measurement results at different distances.
Figure 16. Keypoint detection and body measurement results at different distances.
Animals 14 02453 g016
Figure 17. Keypoint detection and body measurement results for different postures.
Figure 17. Keypoint detection and body measurement results for different postures.
Animals 14 02453 g017
Figure 18. Non-contact body measurement system.
Figure 18. Non-contact body measurement system.
Animals 14 02453 g018
Table 1. Keypoint detection results of different models.
Table 1. Keypoint detection results of different models.
ModelParameters
(M)
GFLOPs
(G)
mAP
(%)
Model-Size
(MB)
YOLOV5-pose7.1216.789.754.83
YOLOV7-pose9.6120.191.219.6
RTMpose-t3.340.391.050.3
YOLOv8-pose3.108.492.46.17
Improved YOLOv8-pose3.248.794.46.45
Table 2. Performance comparison of models under different improvements.
Table 2. Performance comparison of models under different improvements.
YOLOv8-PoseCARAFESimSPPFPrecision
(%)
Recall
(%)
mAp
(%)
Model-Size
(MB)
95.78792.46.17
96.386.693.56.47
93.588.493.86.17
96.787.494.46.45
Table 3. Normality test of artificial cattle body measurement.
Table 3. Normality test of artificial cattle body measurement.
NormBody HeightLumbar Height Body LengthChest Girth
S-W Test0.9780.9480.9410.941
0.8850.2750.1960.197
A-D Test0.2610.4910.6080.598
Skewness0.0640.6610.7200.560
Kurtosis−0.1630.2730.032−0.403
Table 4. Body measurement results of 23 beef cattle.
Table 4. Body measurement results of 23 beef cattle.
IDBH/cm LH/cm BL/cm CG/cm
1126124126129146157187187
2132131133140154169180187
3128127128136145163188181
4127127124137148162181180
5124122126128146146171166
6124124128129144158169168
7111109113117127138167154
8123123129130153153158167
9119118120123132146176169
10121118127127150156162173
11118114118120128145151159
12113114116121134145171167
13129118124129136147170166
14124121126130137151182172
15115114115123147146165160
16123119123126133141156164
17118114118122139144170167
18132123132127145153153177
19124119124124134148186178
20118118118124134141147163
21123122123127139147151166
22118117118123140146149163
23123121123126139150154162
Table 5. Measurement error analysis.
Table 5. Measurement error analysis.
IndexBody HeightLumbar HeightBody LengthChest Girth
MAE(cm)1.523.839.777.80
MRE(%)1.283.026.574.65
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Peng, C.; Cao, S.; Li, S.; Bai, T.; Zhao, Z.; Sun, W. Automated Measurement of Cattle Dimensions Using Improved Keypoint Detection Combined with Unilateral Depth Imaging. Animals 2024, 14, 2453. https://doi.org/10.3390/ani14172453

AMA Style

Peng C, Cao S, Li S, Bai T, Zhao Z, Sun W. Automated Measurement of Cattle Dimensions Using Improved Keypoint Detection Combined with Unilateral Depth Imaging. Animals. 2024; 14(17):2453. https://doi.org/10.3390/ani14172453

Chicago/Turabian Style

Peng, Cheng, Shanshan Cao, Shujing Li, Tao Bai, Zengyuan Zhao, and Wei Sun. 2024. "Automated Measurement of Cattle Dimensions Using Improved Keypoint Detection Combined with Unilateral Depth Imaging" Animals 14, no. 17: 2453. https://doi.org/10.3390/ani14172453

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop