AI-powered video monitoring in pig pens makes it possible to track individual animals and groups, and to observe how their behavior develops hour by hour and day by day. This provides new insights into animal welfare.
A typical day in a pig barn. The pigs are lying close together along the wall of the pen, breathing calmly. A ceiling-mounted camera detects them as warm spots of activity. One of them wakes up, grunts, gets to its feet, and pushes its snout into the bedding as if searching for something. It nudges another pig, which startles awake. Suddenly, they all get up, and the pen comes to life.
The camera records each animal moving across the floor. It captures not only where the pigs are and where they go, but also the shape of their bodies and how they hold their heads, ears, and tails. As the hours pass, these movements are transformed into crisscrossing lines of activity, until the group eventually settles down together again to sleep.
AI Learns the Behavior of Each Individual Pig
Over time, the camera gathers enough information for artificial intelligence to learn the behavior of each individual pig: when it is active, how much it usually moves, where it prefers to spend time, and how it plays and interacts, or quarrels, with other pigs.
However, AI does not understand the meaning behind the behavior it records. It is only when these observations are combined with scientific knowledge of pig behavior that they can reveal how the animal is actually feeling.
“To understand a pig’s welfare, we must first understand the pig itself. This is at the heart of behavioral science,” says Marko Ocepek.
Ocepek is a researcher in ethology, the scientific study of animal behavior, at the Norwegian University of Life Sciences (NMBU).
For the past five years, he has been working on precision livestock farming in pigs. This modern approach to animal production combines computer vision, artificial intelligence, and behavioral science to develop new methods for understanding and monitoring animal welfare.

From Manual Observations to Modern Technology
In the past, animal behavior was recorded through direct observation. These observations were limited in time and provided only snapshots of life in the pig pen. It was also difficult to monitor many animals simultaneously, and the results could be influenced by the observer’s judgment.
Artificial intelligence now makes it possible to monitor animals around the clock. Measurements become objective and standardized, while allowing both large groups and individual animals to be analyzed simultaneously.
“The most exciting aspect of this research is the ability to continuously track both individuals and groups over time. We can understand how behavior develops hour by hour and day by day, giving us insights into animal welfare in ways that were previously impractical,” says Ocepek.
How the Researchers Do It
In integrating AI with animal behavior research, Ocepek followed a multi-step process.
The work begins with biological knowledge of animal behavior and identifying what should be measured based on behavioral characteristics, why the behavior occurs, what triggers it, and how it develops over time.
Researchers then conduct manual observations, either directly or through video analysis. Behaviors such as resting, movement, social interaction, and aggression are identified and categorized.
“The behaviors must be both biologically relevant and precisely defined so that observations are recorded consistently, even when different observers are involved,” says Ocepek.
Next comes a process known as annotation, in which behavior is manually marked in video frames. This makes the information machine-readable and allows an AI model to be trained to recognize the behavior automatically, which is the final stage of the process.
Different methods were used to identify pigs in the videos. In some trials, pigs wore RFID ear tags. These tags transmit wireless signals to a reader that records individual activity. In other studies, camera and AI systems tracked each pig over time and identified animals based on body shape, position, and movement patterns.
New Insights into Behavior Bring Surprises
Modern pig pens are designed to meet animals’ needs through designated functional zones. Solid flooring with bedding serves as a resting area, while slatted flooring is intended for manure deposition. This design is based on both biological assumptions and regulatory requirements, such as minimum lying-area standards.
However, detailed information about how pigs actually use these areas throughout the day has been limited. Earlier studies relied on relatively short observation periods and manual recording, providing only a partial picture.
Through several research projects, Ocepek and his colleagues developed methods for tracking activity, movement patterns, and environmental use by individual pigs over extended periods. Their findings revealed some surprises.
“Pigs have a more flexible activity pattern than previously assumed. They do not always use pen areas as intended. For example, they often rest on slatted floors even when conditions would suggest otherwise,” says Ocepek.
The researchers also found considerable activity during nighttime hours.
AI Detects Individual Differences
The research showed that pigs are highly synchronized in their behavior. Often, much of the group was active or resting at the same time. This is because pigs are social animals that influence each other’s behavior.
Even so, researchers observed clear differences between individuals.
“Some pigs moved extensively and used the entire pen, while others stayed within limited areas. This combination of group behavior and individual variation provides a more nuanced picture of how pigs actually experience life in a conventional pig pen,” says Ocepek.
Deviations in Activity Patterns Provide Valuable Information
The results also showed that activity levels varied from day to day for each pig. Because individual pigs differ, it is not useful to apply a single common threshold for what constitutes normal activity. Instead, each pig should be compared against its own normal activity level.
Monitoring these variations is important because it can help detect abnormalities, such as illness or stress, at an early stage. Another advantage is the ability to analyze long-term patterns, providing a better understanding of what happens before and after specific behaviors and why they occur.
“A decline in activity only becomes truly interesting when it falls below the pig’s own normal level. A pig that suddenly moves less than usual may be showing an early warning sign,” says Ocepek.
Supporting More Sustainable Food Production and Greater Consumer Trust
Continuous monitoring and early warning systems could become valuable tools for farmers. They can help improve efficiency, reduce losses, and use resources more sustainably. This may lower veterinary expenses and reduce the need for medication.
The technology can also contribute to better documentation and greater transparency in pig farming, strengthening trust among consumers and society as a whole.
References
Marko Ocepek mfl.: DigiPig: First Developments of an Automated Monitoring System for Body, Head and Tail Detection in Intensive Pig Farming. Agriculture, 2022. Doi.org/10.3390/agriculture12010002
Marko Ocepek mfl.: DigiPig: First developments of an automated monitoring system for body, head and tail detection in intensive pig farming. Agriculture, 2022. Doi.org/10.3390/agriculture12010002
Marko Ocepek: Diurnal and day-to-day movement patterns of finishing pigs on deep straw bedding during the last 20 d before slaughter. Journal of Animal Science, 2026. Doi.org/10.1093/jas/skag122
