Monitoring of milking routines for dairy cows using a computer vision system: A diagnostic accuracy study.
Journal:
Journal of dairy science
Published Date:
Jul 16, 2025
Abstract
The primary objective was to assess the performance of a computer vision system for the detection of reattachment and manual removal of the milking unit, as well as the assessment of the preparation lag time of the milking routine. The secondary objective was to investigate the association between preparation lag time and the milking performance indices milk yield, milking duration, and occurrence of bimodal milk flow curves. In this observational field study, we analyzed video footage containing data from 2,917 cow milking observations collected from one dairy farm. The occurrences of reattachment and manual detachment of the milking unit were identified using both the computer vision system and visual inspection of the same video footage, with the latter serving as the gold standard. The duration of the preparation lag time was assessed by the computer vision system and visual assessment of the video footage and calculated as the time lag between start of the forestripping step and the attachment of the milking unit. Milk yield, milking duration, and the occurrence of bimodality were assessed with electronic on-farm milk flow meters. The κ statistics and diagnostic test performance metrics (95% CI) for the comparison between the computer vision system and the gold standard for reattachment and manual removal of the milking unit, respectively, were κ, 0.96 (0.91-1.00) and 0.85 (0.80-0.90); sensitivity, 0.95 (0.83-0.99) and 0.85 (0.78-0.91); specificity, 1.00 (0.99-1.00) and 0.98 (0.96-0.99), positive predictive value, 0.97 (0.86-1.00) and 0.90 (0.84-0.95); negative predictive value, 1.00 (0.99-1.00) and 0.96 (0.95-0.98); accuracy, 0.99 (0.99-1.00) and 0.95 (0.94-0.97); and F1 score; 0.96 (0.90-1.00) and 0.88 (0.83-0.92). General linear mixed models revealed an association between preparation lag time as assessed with the computer vision system and milk yield, but no association for milking duration. The estimated marginal means (95% CI) for milk yield were 13.1 (12.8-13.4) for a preparation lag time of <90 s, 13.4 (13.1-13.7) for a preparation lag time of 90 to 150 s, and 13.1 (12.6-13.6) kg/milking session for a preparation lag time of >150 s. Milking durations were 314 s (308-320 s) for <90 s, 319 s (311-326 s) for 90 to 150 s, and 321 s (308-334 s) for >150 s. A generalized linear mixed model showed an association between preparation lag time and the occurrence of bimodality. Compared with a preparation lag time of >150 s, the odds (95% CI) of bimodality were 0.52 (0.29-0.93) for <90 s and 0.44 (0.24-0.81) for 90 to 150 s. We conclude that the computer vision system tested here can accurately detect manual removal and reattachments of the milking unit and precisely assess the preparation lag time of the milking routine. Furthermore, our data add to the existing literature suggesting that inadequate preparation lag time can negatively affect milking performance.