Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 13, No. 2, 2025 41 Research on a Non‐Contact Cattle Weight Measurement System Based on Deep Learning Lihao Qin, Zhongyu Ma, Zhanshuo Zhang, Yongfeng Zuo, Dan He Xinjiang College Of Science & Technology, Kuerle Xinjiang, 841000, China Abstract: As the smart livestock industry continues to evolve, traditional methods of measuring cattle weight are increasingly inadequate for the demands of large-scale farms. Conventional approaches rely on manual weighing or bulky equipment, which are inefficient and lack precision, failing to provide real-time, accurate weight measurements required in modern breeding facilities. To address this challenge, this paper proposes an automatic cattle weight measurement system based on deep learning. The system employs deep learning technology for keypoint detection on cattle and uses these detection results to predict weight, enabling non-contact, high-precision measurement. For keypoint detection, MobileNetV3 is utilized as the backbone architecture, while calibration object recognition technology extracts depth information from images to perform depth correction, thereby enhancing the accuracy of image scaling. Weight prediction is conducted through a regression model that integrates keypoint coordinates with geometric features such as body length, shoulder height, and chest girth to estimate the cattle’s weight. Experimental results demonstrate that the proposed system achieves a high level of accuracy in both keypoint detection and weight prediction tasks, highlighting its potential for automated weight estimation in modern livestock management. Keywords: Computer Vision; Cattle Body Weight Measurement; Deep Learning; Lightweight Network. 1. Introduction Cattle weight is a crucial indicator in livestock production, used to assess growth and development, feed conversion efficiency, disease diagnosis, and precision feeding management [1]. Traditional methods for measuring cattle weight primarily include weighing and estimating body size. While weighing methods are highly accurate, they require specialized equipment, are cumbersome to operate, and can easily cause stress in cattle, making them unsuitable for large- scale, high-frequency measurements [2]. Body size estimation involves measuring parameters such as height, diagonal length, and chest circumference, then applying empirical formulas to estimate weight. However, this method typically requires manual operation, which is inefficient and whose accuracy is heavily influenced by the operator’s experience and the cattle’s cooperation [3]. With the rapid advancement of computer vision and deep learning technologies, non-contact measurement methods offer innovative solutions to overcome the limitations of traditional cattle weight measurement techniques. Deep learning has demonstrated powerful capabilities in image recognition, object detection, and pose estimation, establishing a foundation for automated, high-precision measurement of cattle size and weight [4, 5]. In recent years, researchers both domestically and internationally have conducted extensive studies on non-contact measurement of cattle size and weight using deep learning. In the field of size measurement, Chao Haitian [2] was an early pioneer in exploring non-contact measurement systems for cattle size. Liu Wei [6] and Guan Xiaopeng [7] investigated cattle size measurement methods based on deep learning and depth estimation, respectively. Zhang Xianyu [8] further advanced automatic cattle size measurement techniques using deep learning. Deng Hongxing et al. [9] achieved precise measurement of dairy cattle size by combining binocular stereo matching with an improved YOLOv8n-Pose keypoint detection model. Li et al. [10] also accomplished automated measurement of beef cattle size through keypoint detection and monocular depth estimation. These studies collectively demonstrate significant progress in the non-contact acquisition of cattle size using deep learning. Regarding weight estimation, Zhang Shuai [11] applied deep learning methods to predict the size and weight of Jinnan cattle. Peng Zhaoyuan [12] developed a non-contact weight measurement method for yaks based on deep learning. Lan Leibin [13] focused on algorithms for size and weight estimation of cattle using machine vision. Additionally, Elkhrachy’s research [14] provided a theoretical foundation for constructing three- dimensional structures from two-dimensional images, which is crucial for estimating weight from size data. Despite existing research achieving some progress, challenges remain in enhancing the robustness, accuracy, and real-time performance of non-contact measurement systems within complex breeding environments. Additionally, effectively integrating multimodal data to improve weight estimation accuracy continues to be a significant hurdle. This study aims to thoroughly investigate a non-contact cattle weight measurement system based on deep learning, to develop an efficient, accurate, and non-intrusive solution that supports intelligent management in the livestock industry. 2. Keypoint Detection of Cattle Body 2.1. Cattle Body Image Dataset The cattle image dataset used in this study is derived from a competition dataset titled Weight Detection Model + Dataset (12k~). Side-view images of cattle were selected from this dataset, comprising 1,556 training images and 389 testing images, for a total of 1,945 images. The dataset includes images of cattle from various breeds, poses, and lighting conditions to enhance the model's generalization ability and robustness across diverse environments. Each cattle image is annotated with nine keypoints corresponding to critical parts of the animal's body, such as the shoulder, back, and legs. The filename of each image contains the 42 weight information for the specific animal, and this weight data, extracted from the filename, is directly used as the target value for the regression task. These images and their corresponding weight values are then input into the model for training, as illustrated in Figure 1. Fig 1. Cattle Keypoint Image 2.2. Keypoint Detection Based on Deep Learning To achieve efficient and accurate detection of cattle keypoints, this study employs two convolutional neural network models: MobileNetV3 and ResNet50, conducting a comparative analysis. Each model has distinct architectural characteristics and advantages: MobileNetV3 is a lightweight model suitable for environments with limited computational resources, while ResNet50 is a deep network that typically offers higher accuracy. By comparing the performance of both models on cattle images for the keypoint detection task, we can comprehensively evaluate their effectiveness and select the most suitable model. (1) MobileNetV3 MobileNetV3 utilizes an optimized architecture that incorporates SE modules and the h-Swish activation function. This design enables MobileNetV3 to achieve high detection accuracy while maintaining low computational resource consumption. The model is adapted for the cattle keypoint detection task by modifying its output layer: the original classification layer at the end of MobileNetV3-Small is replaced with a multi-task regression head that outputs the normalized coordinates (x, y) of nine keypoints along with their visibility probabilities (v). The overall network architecture is illustrated in Figure 2. Fig 2. Modified MobileNetV3 Structure (2)ResNet50 The deep architecture of ResNet50 enables it to achieve notable accuracy in detection tasks; however, its depth also results in increased computational complexity. To adapt ResNet50 for keypoint detection, the final fully connected layer has been modified to output 27 dimensions. The overall network architecture is illustrated in Figure 3. 2.3. Model Training During training, the Adam optimizer was selected due to its effectiveness in handling large-scale data and complex models, making it a popular choice in deep learning. The batch size was set to 16; a larger batch size improves computational efficiency, reduces training time, and provides the model with sufficient sample information for effective learning. The number of epochs was set to 100, with early stopping implemented to prevent overfitting. This means training would halt if there were no significant improvements in loss values over several consecutive epochs. Throughout the training process, the loss function value gradually decreases, indicating that the model is progressively improving its ability to predict the coordinates of the keypoints. By tracking the loss on both the training and validation sets, we observe that the loss on the validation set eventually stabilizes. Figure 4 illustrates the changes in the loss functions of both models over the epochs. 43 Fig 3. Modified ResNet50 Structure Fig 4. Loss Variation Graph 3. Body Measurement-Based Weight Prediction System 3.1. Extraction of Body Measurement Parameters In the task of cattle weight prediction, body measurement parameters serve as crucial spatial features. They reflect the geometric shape and size of the cattle’s body, which are essential for accurate weight estimation.. Nine key points on the cattle’s body are identified from the images, and body measurement parameters are calculated based on these points. The locations of these measurement points are shown in Figure 5. To derive the body measurement parameters, five pairs of key points are selected from the cattle images, and the Euclidean distances between each pair are calculated. These distances represent the proportional relationships of different parts of the cattle’s body, thereby enhancing the accuracy of weight prediction. The specific body measurement parameters are listed in Table 1. Fig 5. Body Measurement Information For each pair of key points, first obtain their pixel coordinates in the image. Then use the Euclidean distance formula to calculate the distance between the two points. The formula for calculating the Euclidean distance is shown in Equation (1): 44 d x x y y (1) Table 1. Body measurements parameters Body Measurement Description Image Location Oblique length 1 Distance from the scapula to the tailbone 1-2 Oblique length 2 Distance from the shoulder to the tailbone 2-3 Bust Measurement Distance from the posterior edge of the scapula to the abdomen 4-5 Waist Measurement Distance from the posterior aspect of the lumbar vertebrae to the abdomen 6-7 Height Distance from the sacrum to the ground 8-9 In the formula, (x1, y1) and (x2, y2) represent the pixel coordinates of two key points in the image, and d is the Euclidean distance between them. Using this method, the body measurement parameters derived from the key points accurately reflect the size and proportions of the cow's body. These parameters, combined with other image features, are then input into the weight prediction model. 3.2. Depth of Field Feature Extraction and Integration Depth of field correction is essential for mitigating the effects of variations in shooting angle and distance on the cattle weight prediction model. By identifying the calibration object within the image and measuring its pixel diameter, depth of field features can be extracted. These features are then incorporated as input variables alongside other body measurement parameters to train the weight prediction model. The Hough Circle Transform is employed to detect the calibration disk, as illustrated in Figure 5. This algorithm scans the image for regions that are likely circular, fitting circles based on the radius parameter. Ultimately, the center coordinates and pixel radius of the circular calibration object are determined. These detected center coordinates and pixel radius serve as the basis for subsequent scale correction. Fig 6. Neural Network Architecture Diagram A multi-layer fully connected neural network is employed to predict weight. The input features consist of the Euclidean distances between five pairs of key points, representing body measurement parameters, along with the pixel values of the circle diameter obtained after depth correction. These features are processed through multiple fully connected layers, ultimately producing the predicted weight of the cow. The architecture of the weight prediction network is illustrated in Figure 6. 4. Analysis of Experimental Results 4.1. Evaluation of Keypoint Detection Models This study employs the PCK (Percentage of Correct Keypoints) metric to evaluate the performance of keypoint detection models. PCK primarily measures a model’s ability to accurately detect keypoints within various distance thresholds, effectively reflecting performance under multi- scale imaging conditions. It calculates the percentage of correctly detected keypoints by determining whether the distance between predicted keypoints and ground truth keypoints falls within an acceptable range at each threshold. To comprehensively assess model performance, PCK values are computed on both the training and validation sets. Calculating PCK on the training set allows real-time monitoring of the model’s learning progress, while PCK on the validation set serves as a key indicator of the model’s generalization ability. Higher PCK values indicate that the model correctly recalls more keypoints, demonstrating greater accuracy and robustness. During keypoint detection using the MobileNetV3 and ResNet50 models, PCK values were calculated for both models on the training and validation sets, enabling a comparative analysis. These evaluations confirm the models’ stability and robustness under varying shooting conditions. The changes in PCK metrics for both models are illustrated in Figure 7. The experimental results demonstrate that both models achieved high PCK values on the training and validation sets, indicating strong recall capabilities, especially under varying shooting angles and lighting conditions. The MobileNetV3 model converged rapidly during training, exhibiting lower computational complexity and excellent real-time performance, which enables keypoint detection to be completed quickly. This makes it well-suited for applications with stringent real-time processing requirements. Based on these evaluation metrics, the MobileNetV3 model proves to be more efficient in practical scenarios, particularly in real- world environments that demand both speed and accuracy, showcasing strong adaptability and robustness. Furthermore, the MobileNetV3 model’s stability and high recall rate across different shooting conditions provide robust feature support for subsequent weight prediction models, ensuring the reliability and accuracy of the weight prediction results. 4.2. Evaluation of the Weight Prediction Model This experiment employs a common regression evaluation metric, the Mean Absolute Error (MAE). MAE measures the average absolute difference between predicted and actual values. A smaller MAE indicates a closer match between predictions and actual values, reflecting higher model accuracy. The experiment compares two weight prediction methods: (1) deriving body measurement parameters from keypoint information and applying depth correction technology for weight prediction, with results shown in Figure8(a); and (2) using a model trained on keypoints as a feature extractor to directly predict weight, with results shown in Figure 8(b). The impact of different input features on weight prediction performance is analyzed. The MAE values for both approaches are presented in Table 2. 45 Fig 7. Changes in Different PCK Metrics (a)Plan 1 Weight Prediction Results (b)Plan 2 Weight Prediction Performance Fig 8. Model Performance Evaluation Table 2. MAE of the two schemes Number MAE 1 16 2 23 The experimental results indicate that the mean absolute error (MAE) of the first scheme is relatively low, demonstrating that the model achieves high accuracy in predicting cattle weight. Using this scheme, weight data were collected for 20 cows. Their actual weights, body measurement parameters, calibration object diameters, and predicted weights are presented in Table 3 for comparison. 5. Summary This study proposes an automatic cattle weight measurement system based on deep learning. The system integrates keypoint detection, body measurement parameter extraction, and depth correction techniques to enable automatic weight estimation from cattle images. For keypoint detection, the system is trained using the mean squared error (MSE) loss function and the Adam optimizer, employing a MobileNetV3 model to detect key points on the cattle’s body 46 and obtain their coordinates. These coordinates are then used to calculate body measurement parameters related to weight. Subsequently, depth correction technology is applied to mitigate the effects of variations in shooting angle and distance on image scale. Through these methods, the system acquires more accurate image features, providing stable and high-quality data input for weight estimation. In designing the weight prediction model, a regression neural network based on fully connected layers is utilized, trained with the Smooth L1 loss function. By integrating body measurement parameters and depth features, the model comprehensively captures the relationship between cattle body shape and weight, thereby improving prediction accuracy. Experimental results demonstrate that the system performs well under various shooting angles and lighting conditions. Evaluation metrics such as mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) indicate that the system achieves high precision and strong stability. However, there remains room for improvement, such as enhancing dataset diversity and improving model computational efficiency, especially in complex environments. Table 3. Comparison of Predicted and Actual Body Weight Results Number Oblique length 1 Oblique length 2 Bust Measurement Abdominal Circumference Height Disk Diameter Actual Weight Predict Weight 1 945.70 920.22 455.00 405.39 843.90 100 170 176.94 2 1031.63 1042.67 479.87 460.15 1010.38 92 204 200.47 3 1042.35 1131.92 518.21 481.03 1106.04 108 188 193.49 4 989.10 1014.06 494.38 470.27 1013.53 118 192 132.66 5 1049.19 1138.19 534.07 519.02 1170.03 114 170 159.61 6 949.12 1021.41 444.09 435.33 914.26 102 183 188.74 7 930.31 924.11 480.01 483.26 964.00 102 148 133.64 8 936.23 1045.01 500.68 459.97 979.37 134 156 149.59 9 1117.40 1160.13 506.25 532.01 984.73 120 218 224.30 10 1003.53 1029.79 469.20 432.02 931.09 112 186 192.27 Acknowledgments Xinjiang College of Science & Technology University- level Research Fund Project + 2024-KYPT35+2025-KYZD 01. References [1] United Nations Food and Agriculture Organization, Organisation for Economic Co-operation and Development. OECD-FAO Agricultural Outlook 2022-2031 [EB/OL]. 2022 [2024-12-29]. [2] Chang H T. Research on non-contact measurement system for breeding cattle body size [D]. Changchun: Changchun University of Technology, 2018. [3] Pezzuolo A, Giora D, Guo H, et al. A comparison of low-cost techniques for three-dimensional animal body measurement in livestock buildings [C]//IOP Conference Series: Earth and Environmental Science. IOP Publishing, 2019, 275(1): 012015. [4] Fu L S, Song Z Z, Zhang X, et al. Research progress and application status of deep learning methods in agricultural information [J]. Journal of China Agricultural University, 2020, 25(02): 105-120. [5] Bello R W, Mohamed A S A, Talib A Z. Contour extraction of individual cattle from an image using enhanced Mask R-CNN instance segmentation method [J]. IEEE Access, 2021, 9: 56984-57000. [6] Liu W. Research on cattle body size measurement methods based on deep learning [D]. Baotou: Inner Mongolia University of Science and Technology, 2020. [7] Guan X P. Research on cattle body size measurement methods based on depth estimation [D]. Baotou: Inner Mongolia University of Science and Technology, 2022. [8] Zhang X Y. Research on automatic cattle body size measurement method based on deep learning [D]. Baotou: Inner Mongolia University of Science and Technology, 2023. [9] Deng H X, Xu X S, Wang Y F, et al. Dairy cattle body size measurement method based on binocular stereo matching and improved YOLOv8n-Pose keypoint detection [J]. Journal of South China Agricultural University, 2024, 45(05): 802-811. [10] Li R, Wen Y, Zhang S, et al. Automated measurement of beef cattle body size via key point detection and monocular depth estimation [J]. Expert Systems with Applications, 2024, 244: 123042. [11] Zhang S. Research on body size and weight prediction methods of Jinan cattle based on deep learning [D]. Taiyuan: Shanxi Agricultural University, 2022. [12] Peng Z Y. Research on non-contact yak weight measurement method based on deep learning [D]. Ya'an: Sichuan Agricultural University, 2024. [13] Lan L B. Research on cattle body size and weight estimation algorithms based on machine vision [D]. Hangzhou: Hangzhou Dianzi University, 2024. [14] Elkhrachy I. 3D structure from 2D dimensional images using structure from motion algorithms [J]. Sustainability, 2022, 14(9): 5399.