Calving is an essential event in dairy farming where help from the farmer is often needed, so knowing when a cow is going to calve is very important. For dairy farmers, having access to real-time data of cows‘ behaviors is crucial, since unusual behavior often indicates „troubles“. Thankfully, increasing availability and advances in technology make automated monitoring of animal behavior feasible. Find out in this blog how we use computer vision to analyze signs of cows giving birth.
The role of computer vision
Computer vision is a field of artificial intelligence that trains a computer to understand images like us humans do. It will be able to process, analyze, and make sense of an image instead of just the numerical values. Based on an understanding, it’s able to take action. This makes it possible for systems to monitor and control things more easily in the physical world.
There are already existing (non-computer vision) solutions that can track a cow’s vital functions and activity in real-time. However, these are costly solutions considering they are unique sensors for each cow. Using cameras and computer vision is a cheaper alternative solution that also allows for the tracking of a cow’s behavior. With the camera’s the farmer could check the video feed from their phone, whilst also trusting the system to send them an alert if something is happening that requires the farmer’s attention.
The idea is to use a computer vision technique called “object detection” to analyze signs of cows giving birth. There are a few common visual signs that indicate a cow’s upcoming labor, like a loss of appetite, restlessness through lying down and getting up continuously, lying in an abnormal position, or by the calf’s feet appearing. According to the research of Jensen, M. B., the cow will lay down more often but will shorten their total time spent lying down. This is helpful because based on the available supplied footage, we decided to track a cow’s laying and eating behavior to determine when a cow is about to calve.
You Only Look Once or YOLO is one of the most popular algorithms in real-time object detection, as it’s made to recognize objects in images very quickly, without compromising on quality. Instead of sweeping an image bit by bit, it only needs to pass it once to output a prediction.
OpenCV is an open-source computer programming library and plays a major role in developing a real-time computer vision application. When it’s integrated with various libraries, such as Numpy it’s capable of processing the objects array structure for analysis.
The process of object detection
A detection model needs to be trained to find the right patterns that are used to identify and locate objects. This learning process is supervised and requires a lot of data to train its algorithm for it to predict the right output.
The following must be taken into account to gather the right type of data:
- Quantity: Make sure there are enough images available from each class.
- Variance: Images need to include situations that the model may encounter in real-life. This could be different types of angles, lighting, movements, body shapes, or a cow’s skin color.
- Contrast: The contrast between the cow and the background needs to be clear. Try to prevent harsh shadows and low-quality images.
When there is a larger and more qualitative dataset available, we can create an even more efficient model that can catch direct signals like an abnormal lying position or the calf’s feet showing.
Automating the process of monitoring animals‘ behaviors has become increasingly important, which gives computer vision a significant role in the farming & agriculture industry. So, if you are looking for a computer vision-based application for your company, our team of experts is happy to provide you with the best possible solution. Get in touch with us and also check out our „Farmer Piet“ case, where we used computer vision to improve the well-being of pigs!
This blog is written by Nomi van Laarschot.