Make your own pig counter
Make your own pig counter 🐷
“Pork meat is a good source of proteins since their quality is high biological value and has all required amino-acids to promote simple absorption by the organism,” says nutritionist Magnolia Escobar. Its meat has a high degree of or rate of digestibility, which can reach 92%, and is more similar to white meat than red meat. But how does artificial intelligence relate to the pig breeding industry? Can artificial intelligence and computer vision boost the breeding industry’s output? We’ll put on a quick demonstration in this post. No offense to vegans, but this is only an illustration. We all love Peppa Pig 🐽.
In this article, I’ll show you how to create a basic pig counter using vision studio and inference runtime. You must first realize that object detection and object tracking are two distinct ideas. Finding the class and coordinates of objects in a given frame is the goal of object detection, whereas associating objects in a series of frames is the goal of object tracking. Our toolkits can assist you in solving the object detection issue, and the OpenCV library has at least seven pre-made object tracking methods that you can employ as necessary.
To build a pig detection model, we must first collect photos of pigs for labeling. We can find the labeled photos of pigs from this paper — Tracking Grow-Finish Pigs Across Large Pens Using Multiple Cameras. Sincere thanks to The Imported Swine Research Laboratory (ISRL). Then we can import the dataset into vision studio for model creation.
You may use the nvir-mask-demo repository we previously provided to infer the video once you have finished training the model and establishing the inference endpoint. To incorporate object tracking into your pipeline, you simply need to make a minor modification. In this case, I opt for Kernelized Correlation Filters (KCF), which can consider both speed and accuracy. You can use different algorithms depending on your particular circumstances. The list of pseudo-code is shown below.
With this pipeline, you only need to count the pigs that cross a ROI line in order to calculate the number. Here is a short demonstration video we created. The original author is the rightful owner of the video. I hope you enjoy this demo.
Pigs are highly intelligent, social animals!
The study “Tracking Grow-Finish Pigs Across Large Pens Using Multiple Cameras” indicated how socially active pigs are. Quick social contacts lead to identity shifts. These are the tracking challenges. Difficulties in detection: Pigs gather to stay warm, which might lead to occlusion.
Therefore, today’s demonstration is only for educational purposes; further thought and experimental planning are required to create a reliable pig counter.