Case study: How happy is your pig?

Posted on
Picture of Melvyn Smith

Professor Melvyn Smith was recently interviewed by KTN about his research into the emotional state of pigs. The below case study was written by Alan Cowie at KTN as part of their annual report:

Innovation in agriculture has advanced significantly over the past century. In 1920 it would take a farmer an hour and a half to till one acre of land. In 2020, it takes 5 minutes. It’s not just the technology which has effected change, it’s ever-changing societal attitudes which continue to revolutionise not only agriculture but other industries too.

Today’s farmer is not only interested in their animals’ physical health, but also their emotional wellbeing. We’re not pretending these animals are not being reared for food, but we all have a responsibility to ensure animals are content, happy and healthy throughout their lives, and healthier animals deliver higher yields.

One person who is doing that more than most is Mel Smith, a professor at the Centre for Machine Vision (CMV), based at the Bristol Robotics Laboratory, which is jointly run by the University of the West of England (UWE) and Bristol University. It was originally set up in 1999 to study industrial inspection, metrology, surface analysis and quality control. Over the years, and with extensive support from KTN, the CMV has completed projects in defence, health and, more recently, AgriFood. Projects have involved an EPSRC[1] funded trial using 3D imaging technology for facial recognition, examining the colon and the oesophagus for tumours and polyps, and 2D imaging grass fields using a convolutional neural network to locate and identify species of weed.

Where Mel wants to make a real impact is in animal welfare. “Tagging a pig’s ear can cause pain and distress to the pig” explains Mel. “Tags can also get ripped off and they get dirty. So what if there was a way of identifying the pig without even touching it?” This is where Mel’s photometric stereo technology comes in. In a recent trial[2], a drinker was adapted and fitted with a motion activated webcam, which takes thousands of pictures of the pigs’ faces every day, feeding a computer algorithm which successfully identifies the animal with 97% accuracy. But this goes beyond facial recognition. Mel believes his work shows that pigs are revealing their emotional state through facial expression. Are they happy? Are they content? Are they nervous? 

“You can interrogate the neural network to ask it which parts of the image it’s using to tell whether it’s a happy face or not. It produces a heat map showing the areas of the face it’s using to assess happiness. For pigs’ faces, it is around the eyes, ears and the top of the snout which relate to expression.” 

Mel has been collaborating with other researchers on the potential of using existing technologies and applying them in new ways. In one example, he explains how a system which was originally designed to analyse aggregate particles in the construction industry, has found new uses in agriculture, to check the body condition score of livestock, a measure of the health and welfare of animals. Mel explains how it involves a camera which takes a normal image and a 3D depth image. Looking down on a cow, it captures data as it walks underneath. “We’re looking at how bony the animal is – around its hindquarter, where you have its hook and pin bones. If they’re sticking through, they have a low body condition and if they’re nice and fat and rounded, they have a high body condition.” 

Happier animals are more productive and deliver higher yields, so there is a commercial advantage, as well as a social advantage. In an industry where profit margins are often very tight, new practices which promote efficiency or boost productivity are usually welcomed. We may be some way off seeing widespread livestock facial recognition in all farms, but attention to our environment and ecology is only increasing. Who knows where we’ll be in the next century. We already have ‘free range’ and ‘organic’ stickers on our food. Will we have ‘certified pig happy’ too?

Be it for commercial or animal welfare benefits, it’s clear Mel is passionate about using this technology for good. Mel says “It’s about finding a niche where we can make a contribution and machine vision technology has real value for the wellbeing of animals. If we can be at the forefront of this, and do something that’s cutting edge, that’s quite a motivation for me.”

Whilst many of the technologies Mel describes are not necessarily new, they are being applied in novel ways, and KTN has played a key role creating new opportunities and new connections for Mel.

“KTN have had a transformational impact on helping us to deploy our Machine Vision skills to collaborate with agriculture and food industry partners. We have really benefitted from the ability to network through KTN. Their funding expertise and knowledge of the AgriFood industry has led us to many new innovation opportunities that we would not have identified ourselves. Several of these projects have resulted in products that are now reaching a commercial stage”.


[1] Engineering and Physical Sciences Research Council

[2] Watch “Connected – the hidden science of everything”, episode one, on Netflix.

Alan Cowie is the Partnership, PR and Communications Lead at KTN.