Machine vision-based automatic lamb identification and drinking activity in a commercial farm

A. Alon, I. Shimshoni, A. Godo, R. Berenstein, J. Lepar, N. Bergman, I. Halachmi

Research output: Contribution to journalArticlepeer-review


Using ear tags, farmers can track specific data for individual lambs such as age, medical records, body condition scores, genetic abnormalities; to make data-based decisions. However, automatic reading of ear tags using Radio Frequency Identification requires (a) an antenna, (b) a reader, (c) comparable reading standards; consequently, such a system can be expensive and impractical for a large group of lambs, especially in situations where animals are not required to have a compulsory Electronic identification, contrary to the case in Europe, where it is mandatory. Therefore, this paper proposes a machine vision system for indoor animals to identify individual lambs using existing ear tags. Using a camera that is installed such that the trough is visible, the drinking behaviour of the lambs can be automatically monitored. Data from different lamb groups in two different pens were collected. The identification algorithm includes a number of steps: (1) Detecting the lambs' face, and its ear tags in each image; (2) Cropping each ear tag image and discerning the digits on it to obtain the tag number; (3) Tracking each lamb throughout the visit using a tracking algorithm; (4) Recovering the ear tag number using an algorithm that incorporates a list of the ear tag numbers of the lambs in each pen, and the predictions for each lamb in each frame. The You Only Look Once deep learning object detection algorithm was applied to locate and localise the lamb's face and the digits in an image. The models' datasets contained 1 160 and 2 165 images for the training set, and 325 and 616 images for the validation set, respectively. The algorithm output includes the identity of each lamb that came to drink, and its duration. The identification system resulted in a total accuracy of 93% for the data tested, which consisted of approximately 900 visits to the drinking stations, and was collected in real time in a natural environment. The ground truth of each video of a visit was obtained by human observation by studying the video. We checked if there was indeed a visit to the water trough and if so we registered the ear tag number of each lamb whose head was above the water trough. Thus, identifying lambs in a commercial pen using a relatively inexpensive and easily installed system consisting of a RGB camera and a computer vision-based algorithm has potential for farm management.

Original languageEnglish
Article number100923
Issue number9
StatePublished - Sep 2023

Bibliographical note

Publisher Copyright:
© 2023 The Authors


  • Animal identification
  • Artificial Intelligence
  • Deep learning
  • Object detection
  • Sheep and goats

ASJC Scopus subject areas

  • Animal Science and Zoology


Dive into the research topics of 'Machine vision-based automatic lamb identification and drinking activity in a commercial farm'. Together they form a unique fingerprint.

Cite this