Automatic Identification of Pigs in a Pen Using Pattern Recognition


The growing demand for animal products is characterized, at the farmer’s end, by an increased need for staff to manage and monitor the stock. It is estimated that by 2030 the world will experience a growth of 40% in the demand for animal products and their derivatives. These figures drive farmers on large farms to look for automated and reliable solutions for monitoring animal location, health and interaction.  The welfare of animals in husbandry is of concern to many farmers. The well-being of animals in crowded – and many time unsanitary – environments, is being improved to prevent spread of diseases and injuries. On large farms, tracking the behavior of a single animal can become difficult. Not only does the animal need to be spotted, but also observed for some period of time. For this end technology can ease the burden.

Because closed circuit TV has become an affordable animal monitoring tool, visual inspection has gained popularity among farmers. Yet what is the potential of visual tracking of animals in farms? Is it really a reliable and accurate means of monitoring animals? This is the subject of this RSIP Vision Learns article.

Automated animal monitoring with pattern recognition

These questions were asked in a paper published in Computer and Electronics in Agriculture. The short answer is visual tracking by means of computer vision methods, which has a huge potential in reducing the cost and labor involved in monitoring animal behavior and health. The author’s group set out to evaluate the feasibility of automated methods to identify marked pigs in a pen. They further wanted to assess the potential of image processing for behavior-related research. In a controlled experimental condition, the authors divided 40 pigs between four pens, with 10 pigs in each. In each pen there was a drinking device, and food was freely available. Continuous recording was undertaken with a camera mounted at the ceiling of each pen throughout the experiment.

Tracking of individual pigs was conducted according to a pattern drawn on the pig’s back. To automatically detect the pattern the images from the surveillance camera were first segmented. Several pre-processing stages were applied prior to segmentation, but the end result was the fitting of an ellipse matching the position of each pig. Extraction of the pattern was followed by an extraction of Fourier descriptors of the pattern and the calculation of its distance from those in the pattern database. Best match was reported. To achieve translation and rotation invariance, the phase coefficients in the Fourier descriptions were ignored, and only their magnitude was used. The end result gave each tracked pig a unique tracking ID.

The automated identification accuracy was tested against a human observer. The authors report an average accuracy of 88.7% correct identification of the pigs. By dividing each pen into zones and locating pigs within them, the researchers were able to identify characteristic behavior of the pigs. For example, the number of times a pig approached the drinking device could be counted; pigs who contract influenza visit 30% less the drinking nipple, which allows for the creation of an alarm and animal monitoring system for illness intervention. Furthermore, the pigs tended to huddle in the corner to sleep and the resting zone in the experiment was shown to be in the opposite part of the pen from the feeder zone; resting behavior at different pens could be observed; and each pig’s body mass could be estimated by geometrical measurement of images, etc.

Overall, the use of algorithmic means to track the behavior of animals was demonstrated nicely by the authors to be a less invasive way to reach the same goal: animal welfare. Considering the alternatives of ear tagging or time consuming inspection, algorithms doing animal monitoring with pattern recognition are a much safer and harmless way to monitor animal health.

Reference: “Automatic identification of marked pigs in a pen using image pattern recognition” Computers and Electronics in Agriculture. Volume 93, April, 2013. Pages 111-120.

Image: “Like mother like daughter – – 578167″ by Evelyn Simak. Licensed under CC BY-SA.


Share The Story