Scinovex
article Open Access

Deep learning-based detection and measurement of challenging linear traits in Sahiwal cows

Sunil KumarDeepshikha .

Abstract

Accurate and objective assessment of dairy-cattle conformation is important for animal selection, breed evaluation, and the design of breeding programs. Linear type traits are traditionally assessed by visual appraisal or direct manual measurement; however, traits such as hoof angle and hump area are difficult to quantify consistently and are therefore vulnerable to observer-related variation. This study developed a deep learning-based framework using YOLOv8 to detect the hump and hoof regions of Sahiwal cows and to support automated estimation of hump area and hoof angle from digital images. The study reports the use of 600 annotated images, with image augmentation applied to increase the dataset to approximately 2,000 images. The model achieved a precision of 0.92, recall of 0.89, [email protected] of 0.90, and IoU of 0.87 for hump detection. For hoof detection, the corresponding values were 0.90, 0.87, 0.88, and 0.85. Hump area was estimated from the detected contour, while hoof angle was calculated from vectors representing the detected hoof edges. The proposed approach demonstrates the potential of computer vision to reduce subjectivity in the assessment of difficult morphological traits and to support scalable livestock evaluation. Additional calibration and independent validation are required before the system can be used for precise physical measurement and routine field deployment.

Full Text

Tables and figures are in the full-text PDF.

Introduction

The dairy industry contributes substantially to the agricultural economy, and the identification of animals with desirable production and breeding characteristics is central to herd improvement. Linear type traits, defined as measurable morphological features of the animal, are frequently used to support breed classification and to infer functional or production-related potential. In routine practice, these traits are commonly assessed through visual inspection or manual measurement. Although conventional assessment is accessible, it can be subjective, time-consuming, and sensitive to differences among observers. These limitations are especially important for traits that are difficult to measure directly. Hoof angle is relevant to hoof conformation, locomotion, weight bearing, and animal welfare, while the size and shape of the hump are recognized morphological features of Sahiwal cattle (Kaushik et al. 2020; Kumar et al. 2020; Niu et al. 2022) [8,9,13] . The source manuscript further treats hoof angle as relevant to weight bearing during mounting and hump morphology as an indicator used in breed-purity assessment. Recent developments in artificial intelligence, deep learning, and computer vision have enabled automated analysis of animal images for detection, tracking, behavior recognition, and body-part localization. YOLO architectures are particularly suitable for such applications because they combine object localization with real-time inference (Redmon and Farhadi 2018; Zhao et al. 2019) [14,17] . Recent YOLO-based livestock studies have also demonstrated the feasibility of real-time detection and behavior recognition (Chen et al. 2023) [5] , while edge-AI approaches have been proposed for on-farm monitoring where cloud connectivity is limited (Liu et al. 2021) [11] .

Despite this progress, difficult linear traits such as hump area and hoof angle are still generally described qualitatively or measured manually. Morphological descriptions of Sahiwal cattle emphasize a prominent hump, yet objective imagebased quantification of this feature remains limited. Similarly, hoof-conformation studies have established the importance of hoof structure, but scalable image-based measurement remains challenging. This creates a gap between recognizing that these traits are important and measuring them consistently under field conditions. The present study therefore developed a YOLOv8-based system for detecting the hump and hoof regions of Sahiwal cows. Image-processing procedures were then used to estimate hump area and hoof angle. The intended framework was designed as a non-intrusive and potentially scalable alternative to manual assessment, with possible future application in breed evaluation, posture monitoring, hoofhealth screening, and precision livestock farming.

Materials and methods 2.1 Dataset collection and image acquisition

The source manuscript initially states that a dataset of 650 cow images was used for model training and subsequently reports that 600 images were acquired for the study. Images were obtained from the Sahiwal herd maintained at the Cattle Yard of ICAR-NDRI, Karnal, from local dairy farmers, and from open datasets. Image selection focused on clear visibility of the hump and hoof regions under different body positions and lighting conditions. Images were captured with commonly available handheld mobile devices to improve robustness to practical field conditions. Data collection was undertaken in open areas and milking areas. The camera-to-animal distance was kept consistent as far as possible, and camera height was adjusted in relation to the height of the animal.

Image annotation and data augmentation

Two target regions were annotated: (i) the hump area over the shoulder and upper back and (ii) the hoof region covering the lower limb and hoof. The images were annotated using bounding boxes and formatted for YOLOv8 through Roboflow. The annotations were prepared as precisely as possible to provide clean training labels for the model. Flip, rotation, scaling, and brightness transformations were applied to the original 600 images, producing an augmented dataset of approximately 2,000 images. The Methods section reports that the augmented dataset was divided into 90% training, 5% validation, and 5% testing subsets. Elsewhere, the manuscript reports a split of 540 training, 30 validation, and 30 testing images for the original 600-image dataset.

Model selection and training

YOLOv8 was selected because the study required a fast object-detection model that could be trained with a relatively limited dataset. The Ultralytics implementation of YOLOv8 was used. Training was conducted for 50 epochs with an input image size of 640 × 640 pixels and a batch size of 8. The model was trained through Visual Studio Code on a Mac computer.

Hump detection and area estimation

After training, the model was used to localize the hump in side-view images. The detected region was represented by the predicted bounding box and associated contour or mask. The number of pixels enclosed by the detected hump contour was calculated with the OpenCV cv2.contourArea() function:

where A_pixels is the hump-contour area in pixels², mask_i denotes a detected contour or mask component, and ContourArea is calculated using OpenCV. A_cm² = A_pixels × (H_real / H_pixels)² where H_real is the physical height of the cow, H_pixels is the height of the same cow in the image, and (H_real/H_pixels) is the relative pixel-scaling factor. The manuscript also states that area was retained in pixel units because no physical calibration object was available.

Hoof detection and angle estimation

The predicted hoof bounding box was used to extract the hoof region. Hoof angle was defined as the inclination of the hoof relative to the contact surface. Two vectors were constructed from the detected hoof edges, and the angle between them was calculated using the dot-product relationship:

Here, v₁ • v₂ is the dot product of the edge vectors and ||v₁|| and ||v₂|| are their magnitudes. The resulting angle in degrees was overlaid on the original image using OpenCV.

Performance evaluation

Model performance was evaluated using precision, recall, mean average precision at an intersection-over-union threshold of 0.5 ([email protected]), and intersection over union (IoU). Precision and recall summarized detection performance, [email protected] represented detection accuracy across predictions at the stated threshold, and IoU quantified the overlap between predicted regions and the annotated ground truth.

Results

Hump-region detection

The YOLOv8 model localized the hump region in side-view images. As reported in Table 1, hump detection achieved a precision of 0.92, recall of 0.89, mAP@0.

Hoof-region detection and angle estimation

The model also detected the hoof region and provided the image crop required for geometric angle estimation. Table 2 shows a precision of 0.90, recall of 0.87, [email protected] of 0.88, and IoU of 0.85 for hoof detection. The reported values were slightly lower than those obtained for hump detection but still indicated effective localization within the test data.

Integrated model output

Representative source images and annotated intermediate outputs are shown in Figures 1 and2. Together, the figures illustrate the sequence from image collection and annotation to automated region detection and trait estimation. The model was able to identify both target regions using a comparatively small image dataset and to generate numerical outputs for the selected morphological traits.

Discussion

The study demonstrates the feasibility of using YOLOv8 to localize two morphologically important but difficult-tomeasure regions in Sahiwal cows. Hump detection produced precision, recall, [email protected], and IoU values of 0.92, 0.89, 0.90, and 0.87, respectively, while hoof detection produced corresponding values of 0.90, 0.87, 0.88, and 0.85. The similarity of these results indicates that the model detected both target regions with comparable performance, although the hump model was marginally stronger for each reported metric. The findings are consistent with the broader use of deep learning for agricultural and livestock image analysis. YOLO-based models are attractive in this context because they combine detection speed with spatial localization, and improved YOLOv8 approaches have been applied to livestock detection and behavior recognition (Chen et al. 2023) [5] . The proposed system extends this general approach from wholeanimal detection toward the localization of specific linear-trait regions. This is relevant because hoof conformation is associated with lameness and productivity (Niu et al. 2022) [13] , whereas hump morphology is a recognized phenotypic characteristic of Sahiwal cattle (Kaushik et al. 2020; Kumar et al. 2020) [8,9] . The reported detection metrics support the ability of the model to locate the hump and hoof regions; however, detection performance is not equivalent to validated measurement accuracy. The study does not report comparison of image-derived hump area or hoof angle against independent manual measurements, repeated measurements, or a physical ground-truth standard. Consequently, the numerical outputs in Figure 5 should be interpreted as illustrative model estimates rather than fully validated anatomical measurements.

A further limitation concerns physical calibration. The Methods section states that hump area was retained in pixel units because no calibration object was available, yet it also presents a conversion to square centimeters using the ratio between real and pixel height, and Figure 5 [11] .

Conclusion

A YOLOv8-based framework was developed to detect the hump and hoof regions of Sahiwal cows and to support automated estimation of hump area and hoof angle. The reported detection results were strong for both regions, with precision values of 0.92 and 0.90 and [email protected] values of 0.90 and 0.88 for hump and hoof detection, respectively. The approach offers a practical foundation for reducing subjectivity in the assessment of challenging linear traits. Nevertheless, the present evidence primarily establishes region-detection performance. Reliable physical measurement and field deployment will require consistent dataset documentation, independent measurement validation, physical calibration, animal-level external testing, and evaluation under real-time operating conditions. With these additions, the framework could contribute to objective breed assessment, hoof monitoring, and precision livestock management.

Acknowledgement

AcknowledgementsNo acknowledgement statement was provided in the source manuscript.

References

  1. Abdalla EA, Peñagaricano F, Byrem TM, Weigel KA, Rosa GJM. Genome-wide association mapping and functional annotation of hoof health traits in US Holstein cattle. J Dairy Sci. 2021;104(2):1527-1540.
  2. Bailey KW, Ishler VA. Precision dairy farming technologies: Applications, trends, and future prospects. Anim Front. 2020;10(4):27-33.
  3. Bello NM, Steibel JP. Recent developments in statistical methods for genomic selection in livestock. Anim Genet. 2022;53(1):3-16.
  4. Buch LH, Sørensen AC, Lassen J, Berg P, Eriksson JA, Jakobsen JH. Genetic parameters of hoof disorders in dairy cows. J Dairy Sci. 2020;103(3):2615-2627.
  5. Chen Z, Zhang Y, Zhang W, Li H. An improved YOLOv8-based method for real-time livestock detection and behavior recognition. Comput Electron Agric. 2023;205:107625.
  6. Feng P, He D, Zhang C, Liu Y. Application of artificial intelligence in livestock management: A review. Animals (Basel). 2021;11(10):2973.
  7. Fuentes A, Yoon S, Kim SC, Park DS. A robust deeplearning-based detector for real-time tomato plant diseases and pests recognition. Sensors (Basel). 2021;21(1):341.
  8. Kaushik R, Sharma N, Deka A, Deka PJ, Das M. Phenotypic and morphometrical characteristics of Sahiwal cattle. Curr J Appl Sci Technol. 2020;39(48):462-465.
  9. Kumar S, Singh A, Verma R. Role of Sahiwal cattle in sustainable dairy production: A review. Indian J Anim Sci. 2020;90(8):1057-1064.
  10. Li X, Zhang H, Wang Y. Deep learning in agriculture: Applications, challenges, and opportunities. IEEE Access. 2022;10:53277-53291.
  11. Liu Y, Ma J, Zhao X. Edge AI for precision livestock farming: Real-time monitoring of dairy cows using YOLO models. Comput Ind. 2021;132:103509.
  12. Mokhtari S, Kalantar B. Morphological traits and their importance in cattle breeding programs. Trop Anim Health Prod. 2020;52(3):1335-1343.
  13. Niu H, Chen H, Xu C. Hoof conformation and its relationship with lameness and productivity in dairy cattle. Animals (Basel). 2022;12(6):733.
  14. Redmon J, Farhadi A. YOLOv3: An incremental improvement. arXiv [Preprint]. 2018. arXiv:1804.02767.
  15. Ultralytics. YOLOv8: Real-time object detection [Internet]. 2023. Available from: https://github.com/ultralytics/ultralytics
  16. Zhang J, Wang Y, Yang Q. Deep convolutional neural networks for image-based livestock monitoring: A review. Comput Electron Agric. 2020;174:105456.
  17. Zhao ZQ, Zheng P, Xu ST, Wu X. Object detection with deep learning: A review. IEEE Trans Neural Netw Learn Syst. 2019;30(11):3212-3232.
Citations
0
FWCI
0.00
field-weighted impact
References
0
Percentile
58%
vs. same field & year
Citation Network

How this paper connects to the literature. Drag to explore, click any node to open that paper.