INTRODUCTION
Pig production plays a significant role in global meat production, with pork being one of the most consumed meats worldwide [1]. Indeed, according to the Food and Agriculture Organization (FAO), pork accounts for approximately 38% of global meat production [2]. The demand for pork is expected to increase further, driven by population growth, urbanization, and rising incomes in developing countries [3]. However, the pig industry faces several challenges, including disease outbreaks, environmental concerns, and the need for sustainable production practices.
Modern pig farms are crucial for meeting the increasing demand for pork, but their larger scales of operation pose challenges for breeders, including shorter monitoring periods for each pig [4]. Identifying health issues and improving living conditions for vulnerable pigs is essential for maintaining their welfare [5]. Respiratory and digestive diseases are significant concerns, leading to reduced productivity and profits if not managed effectively through proper prevention strategies and veterinary care [6]. Disease outbreaks can have devastating economic effects on pig farms and threaten food security [7]. Traditional disease monitoring methods depend heavily on observation, which can be labor-intensive, time-consuming, and susceptible to subjectivity and human error. Furthermore, close visual observation may stress animals [8–10] and may not be reliably effective in detecting early signs of disease or identifying individuals that require medical attention [11].
Driven by rapid scientific and technological progress, significant advances have been made in integrating information technology with agriculture and livestock industries [12]. In particular, the incorporation of machine vision sensing has elevated this integration to new levels: the use of machine vision and RGB imaging technology in agriculture and livestock has seen significant growth due to the increasing availability of affordable and high-resolution cameras, coupled with advances in image processing algorithms [13]. These technologies have the potential to revolutionize the health management of pigs by providing real-time, non-invasive, and automated monitoring of behavior, health, and environmental conditions [11].
Machine vision, RGB imaging, and artificial intelligence (AI) equip computers with the remarkable ability to extract and organize meaningful information from digital images and videos. In essence, machine vision attempts to replicate the sophisticated visual perception of humans and animals, while RGB imaging—a fundamental pillar of machine vision—involves capturing visual data within the visible light spectrum, encompassing the red, green, and blue color channels [14]. Various image processing approaches, such as segmentation and extraction, aid in the automatic detection of diseases and visual symptoms, facilitating pig farm management [6]. Their primary focus is on individual identification using properties like color, texture, and shape, aiding in assessing body size, weight, and posture [15]. Furthermore, recent research has utilized advanced technologies like object detection [16], support vector machines (SVMs) [17], and convolutional neural network (CNN)-based methods [18,19] to identify sick pigs and their symptoms.
These methods have been utilized to enhance pig monitoring and health management on farms as early detection through single-image or video analysis enables farmers to intervene quickly, improving animal welfare and minimizing the spread of disease. Studies have shown that early intervention significantly reduces mortality rates and improves treatment efficacy, contributing to enhanced productivity [19]. Moreover, machine vision and RGB imaging can be used to monitor environmental conditions (e.g., temperature, humidity, and air quality), which can have a significant impact on pig health. By integrating data from various sensors and cameras, a comprehensive picture of the farm environment can be obtained, enabling more effective management of housing conditions. However, several challenges need to be addressed in order to fully realize this potential. The objective of this review was to provide an overview of the current state of the art in machine vision and RGB imaging for pig disease monitoring and health management.
HEALTH MONITORING AND VISUAL SYMPTOMS OF PIG DISEASES
Recognizing diseases and other health issues in pigs primarily relies on visual symptoms (e.g., lethargy, reduced appetite, shivering, and weight loss), but detecting sickly individuals within larger groups can be challenging, especially for less experienced farm workers. For example, respiratory diseases can be categorized based on their rapid spread and severity or their prolonged presence among a large population of pigs [20]; while the severity varies, visual symptoms often start with the respiratory system itself and become manifest through sneezing, snuffling, and nasal discharge, which are indicators of irritation, or through eye issues like tear staining [21]. In severe cases, facial deformity can occur, with pigs exhibiting twisting or shortening of the snout [22]. In piglets, stunted growth could also be a sign of respiratory illness [23]. Early detection through these visual symptoms is crucial for prompt intervention and improved pig health.
Digestive diseases often manifest through more general symptoms, such as diarrhea, vomiting, and abdominal discomfort. Severe conditions like stomach ulcers present as dark, coffee-like stool [24]. Diarrhea poses the greatest threat, particularly to weaned pigs, and is accompanied by weight loss, teeth grinding, hunching, and bloating [25]. Other symptoms include high temperature, neck swelling, depression, vomiting, reluctance to feed, darkened skin over swollen areas, jowl swelling, lethargy, coma, convulsions, coughing, and jaundice [6]. The primary cause of piglet crushing and overlaying is the size difference between the mother pig and the newborn piglet, often when the mother lies down to rest or nurse [26]. However, it can also result from the mother’s illness or behavioral issues, causing her to neglect or inadvertently harm the piglets. Insufficient segregation between piglets and larger pigs on the farm exacerbates the problem, leading to noticeable instances of crushing [27]; piglets can also be crushed due to various factors, including disease, hunger, hypoglycemia, splay legs, joint issues, and other related conditions [28]. Each of these risks could be predicted by visual cues and are thus potential targets for machine vision-based interventions.
Behavior patterns of pigs and environmental factors on the farm can contribute, including inadequate pig and litter separation, excessive straw bedding affecting piglet mobility, poor rail or crate design, and insufficient temperature and lighting [27]. The sound of a screaming piglet may indicate crushing, with dead piglets often found under the mother or exhibiting injuries consistent with being crushed [29]. Lame or squealing piglets, congenital tremors, splayed limbs, and limited mobility suggest crushing if accompanied by distressed piglet sounds [30].
In summary, there are numerous common visual cues of illness in pigs, including fractured bones, bruises, bleeding, decreased viability in newborns, scratches from piglet teeth on the udder indicating mastitis or agalactia, immobility, ear and tail bites, lameness in sows, and behavioral issues in gilts such as savaging [31]. In piglets, failure may manifest through hunger, hypoglycemia, joint issues, weakness at birth, and exposure to cold temperatures [32]. Since visual changes are often the earliest indicators of health problems, RGB imaging provides a non-invasive and proactive method for monitoring pig populations, enabling early detection and intervention to minimize losses and improve pig welfare.
RGB IMAGING: MACHINE VISION, SENSORS, AND DATA PROCESSING
Machine vision aims to replicate human vision capabilities using algorithms and machines, with the core goal of enabling computers to interpret and extract meaningful insights from digital images or videos. This process involves several stages, as shown in Fig. 1. The first step, image acquisition, captures visual data using cameras or sensors—such as RGB or infrared sensors—which translate real-world information into digital pixel grids. In animal health monitoring, infrared sensors often complement RGB cameras by detecting temperature changes that could indicate fever [8].

Once images are captured, pre-processing techniques such as filtering, noise reduction, color correction, and histogram equalization are applied to improve image quality and remove irrelevant detail. Pre-processing is particularly important in pig health monitoring to enhance features like skin lesions or abnormal tissue growth, which might otherwise go unnoticed [5]. Following pre-processing, feature extraction identifies distinctive patterns (e.g., edges, corners, textures, and colors) that are crucial for analysis and recognition. For example, changes in pig skin color or texture may indicate conditions like dermatitis or other infections. The extracted features are then transformed into suitable formats for processing and analysis. In the object detection and recognition phase, algorithms such as CNNs are often employed to locate and classify objects, including identifying individual pigs and detecting behavioral anomalies [5]. The image understanding step provides contextual information about the visual data, such as tracking pig movements or monitoring interactions between animals. Finally, machine learning and deep learning techniques further enhance system performance by automating feature extraction and enabling predictive analysis based on the visual data. These methods allow for early detection of health issues in pigs, improving the accuracy and timeliness of interventions [8].
RGB imaging is a foundational technique used in digital photography, machine vision, and image processing. Each pixel in an RGB image is represented by the three primary color channels, where the intensity of each channel determines the color of a pixel, enabling a vast array of colors to be created through combination. Fig. 2 shows the electromagnetic radiation spectrum, highlighting the visible spectrum band. Following the principle of additive color mixing, varying intensities of red, green, and blue light produce different colors, with full illumination resulting in white light and an absence in all channels yielding black. The color gamut, defining the range of representable colors in an RGB color space, varies among devices and technologies, influencing perceived color accuracy. Manipulating the intensity of each channel enables diverse color effects and adjustments. Color filtering techniques are often implemented to selectively capture specific wavelengths of light, enhancing image quality and discerning between colors. Besides RGB, alternative color spaces (e.g., CMYK, HSL, and HSV) offer different methods for color representation and manipulation, which are tailored for specific applications in imaging and machine vision.

Precision livestock farming utilizes intelligent technology for comprehensive monitoring of individual animals in farms, addressing a critical challenge in disease monitoring and prevention. Early disease detection is essential for averting large-scale outbreaks and economic losses. Cameras have become widely available and affordable for scientific purposes over the past two decades. The predominant image sensor devices in use are standard digital and surveillance cameras, which capture visible light spectra for generating color and grayscale images [33]. Camera sensors have the advantage of offering more rapid data capture compared to other sensor types in pig farms [34]. Various types of cameras (including charge-coupled device [CCD], infrared, depth, and 3D cameras) are used for animal monitoring and surveillance, each providing unique information [34]. More complex arrays of images—such as three-dimensional (3D), multispectral, and hyperspectral image cameras—are also available but tend to be costly. Each imaging technology suits particular applications. However, the current review primarily focuses on RGB cameras, which are extensively utilized in various studies conducted on pig farms. Automated identification of diseases and behaviors is crucial, with cameras playing an increasingly vital role in observing abnormal behaviors. Traditional farm inspections are inadequate for monitoring individual pigs effectively, considering factors like radiation, floor type, growth stage, and health status [35]. Fig. 3 and Table 1 show the common RGB cameras used in the pig farm for disease symptom detection and behavior and activity monitoring.

Image acquisition is the initial step in image-based analysis and involves obtaining numeric information through cameras [33,36]. Analyzing pig behaviors via image processing enables accurate real-time recording without disrupting their normal activities [37]. CCD cameras detect object pixels in red, green, and blue bands, converting them into parameters like grey, hue, saturation, and intensity using various image processing algorithms [36]. Video processing enhances sound captured in video files and adjusts images accordingly, often using filter algorithms for editing purposes [38]. Different software and peripheral devices aid in loading video files into the system, allowing users to compile and process images and videos using pre-filters, intra-filters, and post-filters [39]. Pre-processing of input images involves restoration, augmentation, or presentation of real data as required. Segmentation divides the image into constituent parts, extracting specific characteristics for further analysis [40]. Segmented images are then fed into classifiers or image understanding systems for interpretation and classification. Image classification assigns distinct parts or segments of an image to various objects with corresponding labels. An image comprehension system must detect relationships between different objects to generate a comprehensive description of the image [38].
The integration of RGB imaging into pig farms holds promising potential for streamlining livestock management practices. From remote health assessments to automated weight estimation, camera-based monitoring offers a non-invasive way to gather valuable insights into pig well-being and productivity [41]. However, the success of such systems depends on the quality and reliability of the captured images. Within the unique environment of a pig farm, several factors combine to affect RGB image clarity and, consequently, the accuracy of any analysis derived from the images [6]. Lighting conditions wield substantial influence; optimal lighting, whether natural or artificial, is crucial for clear and consistent image capture, with variations potentially impacting image quality [42]. The choice and positioning of cameras are equally significant; high-resolution cameras positioned strategically can mitigate obstacles and ensure comprehensive coverage of the farm [34]. Optimizing the camera distance, angle, and height above the ground is crucial, as longer distances increase random error while shorter distances enhance accuracy. Adjusting these parameters ensures the capture of the entire pen while minimizing the distance to the pigs [43]. Furthermore, environmental conditions like fluctuating light levels, dust accumulation, and humidity pose significant challenges. Camera setup, including resolution, lens quality, and calibration, plays a crucial role [44].
Additionally, the inherent characteristics of the pigs themselves—such as their coloration, movement, and body positioning—introduce further complexities for image analysis algorithms [45]. Allowing pigs to move freely presents challenges in image processing, including reduced height repeatability and motion blur, necessitating extra filtering to remove low-quality images [43]. Cameras should effectively capture fast movements and changes in posture to provide accurate monitoring data in farm conditions [15]. The quality of software tools and image processing algorithms is thus critical to facilitate the extraction of meaningful insights from RGB images [8].
There is a lack of extensive high-quality datasets and data standards for pig farming data, as commercial and biosecurity restrictions make data collection and publication difficult. The extensive data storage requirements for high-quality cameras and sensors are a challenge for establishing a precision livestock farming system [46]. Furthermore, installation in harsh environments can lead to hardware degradation and sensor damage, especially in remote rural areas, making it inconvenient for personnel to maintain the devices [44], while skilled farming staff are required to operate high-tech devices or systems. Regular maintenance and calibration of cameras are essential to sustain optimal performance and ensure reliable data for informed decision-making [47,48]. Understanding and mitigating the impact of these factors is essential for unlocking the benefits of RGB imaging in pig farm operations.
Data acquisition and processing algorithms for RGB imaging in pig farms are essential components for effective monitoring and management. In data acquisition, high-resolution RGB cameras are strategically positioned throughout the farm to capture real-time images of the pigs and their surroundings [34]. These cameras may be mounted on poles, walls, or other structures to provide comprehensive coverage. Optimizing data acquisition involves considering lighting, camera placement, and environmental factors like dust and humidity to ensure clear and consistent image capture [49]. Once the images are acquired, sophisticated processing algorithms are used to extract valuable insights from the RGB data. These algorithms typically involve several steps, including image segmentation, feature extraction, and analysis [33]. Fig. 4 shows a schematic of RGB image pre-processing, feature extraction, segmentation, and classification techniques for pig image data analysis. Image segmentation divides the images into meaningful regions—such as individual pigs or different areas of the farm—using techniques like thresholding or clustering [50]. Feature extraction then identifies key characteristics within these regions, such as pig count, size, or behavior [33]. The extracted features are analyzed to provide insights for farm management. Image processing algorithms can track the movement patterns of pigs, detect signs of distress or illness, or assess feeding behavior and activity levels [51].

Video denoising is the process of removing noise from a video stream to improve visual clarity; it is applied to each frame through spatial, temporal, or spatio-temporal methods [52]. Noise reduction is crucial in video processing as noise distorts images and impacts the effectiveness of subsequent processing steps. Many noise reduction techniques that were originally developed for color image processing have been successfully adapted for video applications [53]. Machine learning techniques, such as deep learning, may be applied to improve the accuracy and efficiency of these analyses by training algorithms on large datasets of annotated images [54]. Throughout the data acquisition and processing pipeline, quality control measures are implemented to ensure the accuracy and reliability of the results. This may involve regular calibration of cameras, validation of algorithm performance against ground truth data, and ongoing refinement of processing techniques based on feedback from farm operators [55]. The integration of advanced data acquisition and processing algorithms for RGB imaging enables pig farms to gain valuable insights into animal behavior, health, and welfare, ultimately supporting more informed decision-making and optimizing farm productivity.
APPLICATIONS OF RGB IMAGING FOR PIG DISEASE AND HEALTH MANAGEMENT
RGB imaging holds significant promise in the field of pig disease and health management. It enables non-invasive monitoring of pig health through various applications. It facilitates the detection of skin conditions, respiratory problems, and lameness by analyzing visual cues on the body. For vulnerable piglets, RGB imaging helps to identify signs of distress or injury, promoting quick action to prevent crushing. Moreover, RGB technology enables tracking of individual pigs, body condition scoring, and behavioral analysis, supporting precision livestock farming practices. This non-invasive and cost-effective approach allows for early disease detection, data-driven decision-making, and overall improvements in pig health and welfare. Table 2 shows the overall usage of RGB imaging to enhance the early detection, prevention, and management of diseases and sickness in pig farming.
Disease detection is crucial for timely intervention to increase treatment success and reduce negative impacts on pig welfare. It helps to mitigate the spread of illness, reduces mortality rates, and safeguards both animal and human health. In 2018, several countries—including China, Vietnam, Korea, and Laos—experienced significant outbreaks of swine flu, leading to the culling of millions of pigs [56]. This devastating event underscored the critical importance of effective disease monitoring and early detection measures.
While traditional epidemiological models like susceptible, infectious, and recovered (SIR) and susceptible, exposed, infectious, and recovered (SEIR) are effective for short-term outbreak prediction, they struggle with complex dynamics and early detection [57]. Furthermore, conventional disease monitoring methods often involve frequent testing of genetic materials, which can be impractical, time-consuming, and costly [34]. As an alternative, correlating physical indicators provides a viable solution for ongoing surveillance. By observing and analyzing physiological markers (e.g., temperature, respiratory rate, and behavior patterns), farmers can achieve early detection of potential health issues, enabling prompt intervention and treatment [8,58]. Moreover, non-invasive data collection methods offer a safe approach for both humans and animals. Minimizing direct contact between humans and potentially infected animals reduces the risk of disease transmission between species.
Therefore, implementing RGB image-based and machine-learning techniques for non-invasive disease detection in pig farms is a promising approach [54,59,60]. By utilizing RGB cameras or imaging devices installed within the farm environment, continuous monitoring of the physical characteristics, behaviors, and activity of pigs can be achieved to diagnose diseases and illnesses [34,61]. Captured images can then be processed using machine learning algorithms to detect patterns indicative of potential diseases, symptoms, and other health issues. Through machine learning, algorithms can be trained to recognize subtle changes in pig behavior, posture, or appearance that may signal the presence of disease. This approach enables early detection of illnesses, allowing farmers to intervene promptly and prevent the spread of diseases within the pig farm.
Monitoring and tracking the daily activities of pigs, including their movements, eating habits, drinking patterns, and behavior, have been found to be valuable for detecting potential diseases and health issues [36]. Pigs exhibit various behaviors and activity patterns that can serve as indicators of their well-being or potential health issues [62]. By monitoring these behaviors and activities, it becomes possible to detect deviations from normal behavior that may signify underlying health problems [62]. For instance, changes in feeding behavior (e.g., reduced appetite or increased feeding frequency) can be indicative of digestive issues or metabolic disorders [63]. Similarly, alterations in locomotion patterns (e.g., lameness or reluctance to move) may signal musculoskeletal problems or infectious diseases like foot and mouth disease [64]. Additionally, monitoring resting behaviors (e.g., prolonged lying down or restlessness) can help to identify pain, discomfort, or respiratory distress [65]. Integrating RGB imaging with behavioral observations enables automated monitoring of pigs, offering real-time data for early disease detection and health assessment. Advanced image processing and machine learning models can identify disease indicators, facilitating timely veterinary intervention and improved management practices.
Zhu et al. [66] experimented with a novel approach combining wireless technology and image processing to predict the probability of pig illness. Their approach integrated monitoring equipment with USB cameras and an advanced moving object detection algorithm, which was bolstered by background reduction techniques. Their setup facilitated real-time image capture and swift transmission of alarm images and pig locations upon anomaly detection. However, the effectiveness of detection might vary based on factors like pig population size and camera placement relative to their movement zones. Weixing and Zhilei [67] introduced a real-time monitoring system for tracking pig breathing using image-based methods, which captured RGB images and utilized Concave–Convex recognition to locate key points along the ventral lines of pigs. Using enhanced chain coding, they then calculated the length of the line connecting these points, enabling respiratory rate estimation. Their study reported a 6.05% relative error compared to manual observation, offering a non-invasive and accurate means for real-time monitoring of pig breathing, which is crucial for pig welfare and health management. A machine vision-based method was developed in another study [68] to measure respiration rate in group-housed pigs. The method utilized an oriented object detector to select the region of interest and analyzed time-varying features to extract the respiration rate. Testing on videos of group-housed pigs using an RGB camera showed a correlation coefficient of 0.92 for pigs wearing belts and 0.95 for controls. However, movement may disrupt signal accuracy, limiting its applicability to resting pigs.
Chung et al. [69] introduced an automated method for monitoring the daily activities of group-housed pigs using RGB video data, focusing on their circadian rhythm under varying light conditions. Their system used a cost-effective video sensor with a resolution of 1280 × 720 pixels and a frame rate of 30 fps, along with a server. Experimentation on data from two pig farms demonstrated the effectiveness of the Gaussian Mixture Model in detecting management issues within group-housed pig environments. In a different study [70], a smart system was developed to monitor body temperature and motion in real time for early infectious disease detection. The system utilized biosensors and accelerometers in ear tags alongside continuous video monitoring. In a study involving 10 pigs infected with African swine fever (ASF), the system detected infection onset (indicated by elevated body temperature and decreased movement) before or simultaneously with other indicators. Video analysis identified reduced movement effectively, offering a cost-effective alternative to direct motion measurement. The system provided alerts to the owner following changes in body temperature or movement, potentially reducing the need for periodic sampling and enhancing the early detection of infections in farms, which in turn could help mitigate economic losses and logistical challenges in pig farming. Several image processing methods have been applied to the RGB images collected under pig farm conditions to analyze pig activity and disease conditions, as illustrated in Fig. 5.

Jorquera-Chavez et al. [5] investigated the remote monitoring of pigs for early symptoms of respiratory disease using FLIR Duo Pro R cameras, which integrate high-resolution radiometric thermal and 4K visible RGB sensors. Custom MATLAB algorithms processed images, focusing on the eye area for infrared thermography and remote heart rate measurement. Two algorithms assessed heart rate: one tracking spatial patterns in the eye area and the other using photoplethysmography principles. Remote heart and respiration rates correlated positively with standard measures (r = 0.61–0.66). Overhead cameras detected physiological changes before clinical signs appeared, with differences in eye temperature and heart rate evident two days prior to clinical symptoms and significant respiration rate changes occurring the day before.
Fernández-Carrión et al. [71] proposed a system to monitor pig activity and detect ASF infection using RGB video and data processing techniques. Video recordings at 6 fps with a resolution of 704 × 576 pixels in RGB24 format were analyzed, focusing on the red channel for optimal contrast. Animal movements were tracked using the Optical Flow algorithm based on the Horn-Schunck methodology, implemented within MATLAB. Motion smoothing was achieved through a simple moving average filter, and changes indicative of infection onset were identified using the k-means algorithm coupled with the gap criterion algorithm. A gradual decline in pig mobility, statistically significant at the 95% confidence level, was observed four days post-infection, with a 10% decrease in daily motion even before clinical signs appeared. The study recommended using high-definition cameras for improved data quality and accuracy; HD cameras improve data quality and accuracy by automatically adjusting contrast and brightness, reducing background noise and blurring. These findings highlight the potential of machine vision for continuous monitoring and early illness detection in commercial pigs.
Kashiha et al. [72] explored the feasibility of automating the detection of marked pigs within a pen for experimental and behavioral research purposes using image processing techniques. The videos were captured in MPEG-1 format, with a resolution of 720 × 576 pixels and a frame rate of 25 fps. Image segmentation isolated pig areas, addressing lighting effects through histogram equalization and binarization. Binarization involved 2-D Gaussian low-pass filtering and Otsu’s method for global thresholding, followed by morphological closing. Ellipse fitting located pigs accurately, and pattern recognition algorithms differentiated individuals based on unique paint patterns, achieving an 88.7% recognition rate validated by expert visual labeling. However, reliance on individual pig marking limits practicality for large-scale commercial applications, and issues like fading paint patterns, unclear patterns due to pig movements, and mark invisibility in low-light conditions pose challenges.
The lying behavior of groups of pigs was investigated [36] in commercial farm settings using image processing and Delaunay triangulation. Over 15 days, two pens with 22 growing pigs were monitored using top-view CCD cameras. Image processing algorithms were applied to isolate pigs from their background, and their x-y coordinates were utilized for ellipse fitting, enabling precise localization of each pig. Changes in lying posture and location due to temperature fluctuations were accurately detected through analysis of region properties and the Delaunay triangulation perimeter. This method holds promise for studying environmental influences on pig behavior, production efficiency, and welfare in commercial farms. Pig behavior detection was conducted using various image processing fusion methods, as shown in Fig. 6.

Tu et al. [73] proposed a pig detection algorithm for grey-scale video footage, focusing on foreground object segmentation. Their method comprised three stages: updating background modeling with texture information, computing pseudo-wavelet coefficients, and generating a probability map using a factor graph with a second-order neighborhood system and a loopy belief propagation (BP) algorithm. However, computational complexity arose due to factor graphs and the BP algorithm. Zhang et al. [55] proposed an effective method for detecting and tracking individual pigs in video footage, addressing challenges like variable lighting conditions, similar appearance of individual pigs, deformations, and occlusions. The approach combined a CNN-based detector with a correlation filter-based tracker and used a novel hierarchical data association algorithm. By leveraging features from multiple scales in a single-stage prediction network, the detector achieved a balance between accuracy and speed. The method defined a tag-box for each pig to extract local features for learning and conducted multiple object tracking using correlation filters. It handled tracking failures by refining detection hypotheses and correcting drifted tracks through re-initialization. Experimental results on a commercial farm dataset demonstrated the robustness of the approach, suggesting its potential for long-term individual pig monitoring in complex environments.
Ahrendt et al. [74] presented a real-time machine vision system for tracking pigs in loose-housed farms. Utilizing a camera and a personal computer, the system employed a two-step tracking algorithm. Preliminary pig segments were identified in each frame using support maps, followed by constructing a 5D-Gaussian model encompassing position and shape. Software correction for fisheye distortion enabled monitoring of a larger stable area. Developed in MATLAB and implemented in C, the system operated in real-time and demonstrated robustness in continuously tracking at least three pigs for over 8 minutes without losing track or identity. Lu et al. [75] introduced an ellipse-based segmentation algorithm for adhesive piglet images in farm conditions. Initially, ellipse fitting established parameter ranges for different age groups. Contours of connected components were then extracted and segmented using concave points. Ellipse fitting was applied to each contour segment, with additional rules proposed for ellipse merging. Experimental results in Matlab showed an accuracy exceeding 86% for piglet counts under 7. This algorithm lays the groundwork for piglet weight monitoring systems.
Various methods have been implemented to assess movement patterns in pigs. In one study, color video was used to measure 2D locomotion by overlaying multiple images of motion [76], providing insights into movement structure and patterns. Video images were captured using a Microsoft OEM Life Cam web camera mounted on the ceiling, with a height of 3.2 m. RGB images were cropped and converted to grayscale for efficiency. The Otsu method was applied for segmentation, producing binary images of pigs. Background noise was filtered out, and a motion filter isolated moving pigs. Morphological operations refined the images, and the pigs were repositioned and oriented. Head and ear positions were determined using width curves and derivatives. Stacked binary images created a movement map with a threshold of 15 frames to ensure significant movements were captured.
In contrast, Stavrakakis et al. [77] used commercial motion capture cameras arranged in an array at a distance of 3 m from the pig pens. Coupled with motion capture software, this setup enabled the precise tracking of reflective markers on pigs, facilitating accurate measurement of locomotion in 3D. For practical applications in commercial settings, a more accessible solution was proposed [78] using a single-camera system with a Microsoft Kinect V1 motion sensor, along with the Kinect developer toolkit and algorithm for 3D lameness measurement. Kulikov et al. [79] also used a single camera to measure the height of pigs, particularly when lying down, demonstrating the versatility of camera-based approaches in assessing various aspects of pig behavior and locomotion.
RGB cameras have become widely adopted in machine vision due to their cost-effectiveness and efficiency. Researchers have extensively explored various algorithms aimed at extracting livestock body dimensions from 2D images using these cameras. Wu et al. [80] developed a 3D reconstruction system comprising six cameras recording RGB images, using stereovision techniques to achieve 3D reconstruction of pigs. Similarly, Pezzuolo et al. [81] introduced a structure from motion (SfM) photogrammetric approach for 3D reconstruction; their study proposed an analysis of pig body 3D SfM characterization across various conditions, including different numbers of camera poses and animal movements. The assessment utilized the total reconstructed surface as a reference index to quantify the quality of 3D reconstruction; the results demonstrated the potential to characterize up to 80% of the total animal area with this method. Fig. 7 shows the 3D reconstructed pig point cloud from pig body weight and movement analysis using RGB images.

However, RGB-based reconstruction methods face significant limitations due to the absence of a third dimension, potential distortions, the necessity for calibration procedures, and the requirement for multiple cameras. Consequently, their effectiveness has been greatly constrained. A summary of pig disease detection and tracking using RGB imaging and image processing algorithms is provided in Table 3.
Camera type | Detection type | Method / algorithm | Accuracy | Reference |
---|---|---|---|---|
DH-SD1A203T-GN | Diseases, tracking | Object detector+ time-varying features | 92.0 | [68] |
- | Enhanced moving object detection | - | [66] | |
- | Concave-Convex recognition technique | 93.9 | [67] | |
- | Gaussian mixture model (GMM) | 92–96 | [69] | |
Panasonic WV-BP330 | Histogram equalization and binarization | 88.7 | [72] | |
- | Optical flow and k-means algorithms | 95 | [71] | |
FLIR DuoPro R | Pattern recognition and photoplethysmography (PPG) | 66 | [5] | |
Kinect depth camera | filter-based tracker and hierarchical algorithm | 89.5 | [55] | |
VIVOTEK & Hikvision | Behavior, activity | Ellipse fitting, Delaunay triangulation | 82 | [36] |
Monacor TVCCD-140IR | Loopy belief propagation (BP) algorithm | 93.3 | [73] | |
Elphel NC353L | Segmentation and 5D-Gaussian model | - | [74] | |
Nikon D90 | Ellipse-based segmentation algorithm | 86 | [75] | |
Microsoft OEM Life Cam | Otsu method, binarization, morphological operation | - | [76] | |
Kodak DCS760 | Body weight | Structure from motion (SfM) | [80] | |
Nikon D5100 | Structure from motion (SfM) | 80 | [81] |
Detection and tracking of pig diseases through machine learning and RGB imaging represent a promising advancement in livestock farming. Machine learning is a branch of AI that focuses on the development of algorithms and statistical models that enable computers to learn and improve from experience without being explicitly programmed [82]. By utilizing the capabilities of machine learning algorithms and RGB imaging technology, farm owners can accurately identify and monitor various pig diseases. RGB imaging-based monitoring of livestock struggles with noise and data overload from light source variations and image resolution differences. However, studies have shown that machine learning can mitigate noise and manage large datasets, improving the accuracy and efficiency of livestock monitoring [36]. Commonly used machine learning techniques for analyzing RGB image data in pig monitoring include linear discriminant analysis, artificial neural networks, and SVMs. However, deep learning—which is a growing field within machine learning, with its deeper architecture and superior learning capabilities (particularly through CNNs)—has gained growing recognition over recent years [83]. Pig diseases, behavior detection, and tracking have been analyzed using various machine learning algorithms, as illustrated in Fig. 8.

Deep learning has been applied to detect and recognize pig behaviors in farm conditions across various imaging systems. For instance, Zheng et al. [84] proposed a detection system for pig postures utilizing a Kinect v2 sensor and the Faster R–CNN technique with a region proposal network and Zeiler and Fergus Net (ZFnet). Using RGB and depth images captured by the camera, a program was developed to identify sow postures and locations in bounding boxes. Testing on a dataset acquired at 5 fps yielded a detection accuracy of 87.1%. The study authors acknowledged that RGB image-based identification was affected by color and illumination variations from factors like heat lamps and day-night cycles. Automatic detection from depth images can overcome such disturbances.
Tu et al. [85] introduced PigMS R–CNN, a framework based on mask scoring R–CNN (MS R–CNN) for segmenting adhesive pig areas in images of pig groups for identification and localization. A 101-layer residual network with the feature pyramid network served as the feature extraction network. The PigMS R–CNN head network included three branches for regression, classification, and segmentation, enabling extraction of location, classification, and segmentation information for detected pigs. Results showed an F1 score of 0.9228 with traditional NMS, improving to 0.9374 with a soft-NMS threshold of 0.7. Ju et al. [86] addressed the segmentation of touching pigs in crowded environments using low-contrast images from a Kinect sensor capturing both depth and RGB images at 512 × 424 pixels resolution and 30 fps. Initially, the you only look once (YOLO) technique, a rapid CNN-based object detection method, was used for segmentation challenges. Additionally, possible boundary lines between the touching pigs were identified by analyzing their shape. Results demonstrated effectiveness in separating touching pigs in real time with 91.96% accuracy, despite the low-contrast images. However, the model could only segment two touching pigs, suggesting room for potential future improvement, particularly with the integration of transfer learning into the YOLO processing module.
Faster R–CNN and YOLO were introduced in a different study [87] for the automatic detection of pig postures and drinking behaviors in group-housed pigs on commercial farms. A Munkres variant of the Hungarian assignment algorithm was applied to maintain pig identity across consecutive frames. A Kalman filter was utilized to locate missing tracks and associated pig IDs, which were then used to create individual pig profiles. Utilizing a custom data acquisition system, a Microsoft Kinect RGB camera recorded videos of the pen floor and behavior at 25 fps with a resolution of 640 × 360 pixels. The system accurately detected behavior changes during routine management, achieving a mean average precision of 0.989 for individual behavior identification across various conditions, including disruptions in feeding.
Yang et al. [88] proposed a deep learning technique to automatically recognize nursing behaviors in sows from 2D images. They recorded top-view color videos of sows with piglets using a commercial camera, with a capture rate of 5 fps and 960 × 540 pixels resolution. Sows were segmented using a fully convolutional network (FCN) model with a Visual Geometry Group network having 16 layers (VGG16). Temporal features from the training set were then fed into an SVM binary classifier with a linear function kernel. Parameters of an additional sigmoid function were trained to map the SVM outputs into probabilities. The method achieved an accuracy rate of 97.6%, with 90.9% sensitivity and 99.2% specificity. However, challenges were observed in extremely uneven light conditions, low light, and persistent massage, affecting real-world applications. In another study, Yang et al. [89] also addressed sow image segmentation from different backgrounds in top-view 2D images using an FCN based on the VGG16, achieving an accuracy of 96.4%. The study indicated the potential of deep learning for accurately segmenting pigs from diverse background conditions.
Mazhar et al. [90] explored the application of machine learning techniques in precision pig farming. They applied a Random Forest (RF) algorithm in the Boruta package for image analysis and a neural network with a K-Nearest Neighbor algorithm for predictive big data analysis. The study demonstrated the effectiveness of these methods in enhancing precision farming practices, enabling accurate analysis of images and predictive analysis of large datasets. Cowton et al. [91] combined a deep CNN object localization method, Faster R–CNN, with the real-time, multi-object tracking method Deep SORT to create a system that autonomously localized and tracked individual pigs. This system enabled the extraction of metrics related to individual pig behaviors from RGB sensors within the Microsoft Kinect v2. Pigs could be localized with an accuracy of 90.1% and tracked individually across video footage with an accuracy of 92%.
Monitoring body weight is crucial for the early detection and management of various diseases in pig farming. Changes in body weight can offer valuable insights into potential health issues and aid in disease detection. For example, sudden weight loss may signal the presence of diseases such as swine fever, respiratory infections, or digestive disorders, while obesity can increase the risk of conditions like arthritis, heart disease, and metabolic disorders. Kárpinszky and Dobsinszki [92] developed an RGB-based system to estimate daily pig weights, eliminating the need for stressful weighing procedures. Tested on a commercial farm with 32 pigs over 100 days, the system identified key pig features (e.g., head, shoulder, belly, and rump) using Mask R–CNN, Pretty Contour Picker’s, and Multi-Layer Perceptron models. Achieving a rate of 97.4% accuracy compared to manual records, the system introduced a convenient web interface for pig management and monitoring, aiding informed decision-making in farming operations. Further testing across various pig facilities with diverse camera setups, feeders, and lighting conditions, particularly in low-light environments.
Paudel et al. [93] compared the prediction of pig weight using a weight-to-volume correlation and a PointNet-based 3D deep learning model. An Intel Real-Sense camera was used to capture 3D images and point cloud data from pigs in a holding pen, which underwent pre-processing to remove background scenes before input into the deep learning architecture for training and testing. Despite noisy training data, the deep learning model exceeded volume correlation with 94.2% accuracy on unseen point clouds, even for larger pig sizes. The model accurately detected individual pig weights and had the potential to predict the weights of multiple pigs simultaneously, addressing challenges such as free movement and adverse conditions. Wang et al. [94] introduced a rapid estimation technique of pig body size using a YOLOv5 model with MobilenetV3 integration and incorporating a lightweight object detection network as the feature extraction network, along with an attention mechanism. A depth camera captured the pig’s backside information at a fixed height, enabling calculation of the body height. A gradient-boosting regression algorithm established the body size prediction model based on the Euclidean distance between these key measurement points and actual body size data. The result demonstrated an accuracy of 98% for the body size estimation using the model. Other studies have also demonstrated pig body weight estimation using RGB imaging. A summary of pig disease detection and tracking using RGB imaging and machine learning algorithms is presented in Table 4.
Camera type | Detection type | Method / algorithm | Accuracy | Reference |
---|---|---|---|---|
FL3-U3-88S2C-C | Diseases, posture, and tracking | PigMS R–CNN | 93.0 | [85] |
Kinect v2 | Faster R–CNN | 87.1 | [84] | |
Kinect v2 | YOLO | 91.96 | [86] | |
Kinect RGB | Faster R–CNN, YOLO | 98.9 | [87] | |
DS-2CD1321D-I | FCN+VGG16 | 97.6 | [88] | |
DS-2CD1321D-I | FCN+VGG16 | 96.4 | [89] | |
IFM O3D313 | Locomotion | RF + KNN | – | [90] |
Kinect v2 | Faster R–CNN+ Deep SORT | 90.1 | [91] | |
Dahua IPC-HFW1230S-S4 | Body weight | Mask R–CNN, PCP, MLP | 97.4 | [92] |
Intel Real Sense D435 | PointNet | 94.2 | [93] | |
Basler TOF 640 | YOLOv5 + MobilenetV3 | 97.8 | [94] | |
Kinect camera | Structure from motion (SfM) | – | [81] | |
Kinect camera | CNN | – | [84] |
Furthermore, machine learning algorithms can be continuously refined and improved as more data are collected, leading to more accurate and reliable disease detection systems over time. Overall, the integration of image-based technology with machine learning holds great promise for non-invasive disease detection in pig farms, ultimately contributing to improvements in animal welfare and farm productivity.
In commercial pig farming, RGB sensors enhance management practices by enabling real-time behavior monitoring, feeding management, environmental regulation, and health surveillance. These sensors track pig activity and food consumption and monitor environmental conditions (e.g., temperature and humidity) to ensure optimal living environments. Additionally, RGB sensors assist in detecting illness or injury through machine vision algorithms. Table 5 highlights various commercial products used for behavior monitoring, disease detection, and body weight measurement in pig farming.
Measure | System name | System type | Monitoring performance | Website |
---|---|---|---|---|
Behavior, diseases, activity | Pig Guard | Handheld | Yes | https://www.serket-tech.com/ |
– | Mounted | No | https://www.hikvision.com/en/ | |
– | Handheld | Yes | https://www-en.yingzi.com/index.html | |
EdgeFarm | Mounted | No | https://intflow.ai/en/home/ | |
Body weight | – | Handheld | No | https://lembergsolutions.com/ |
Viiew, Viiew Pro | Handheld | Yes | https://illuvation.kr/_eng | |
PigVision | Mounted | Yes | https://asimetrix.co/en/ | |
optiSCAN | Handheld | No | https://www.hl-agrar.de/cms/en/Home.html | |
Pigxcel | Mounted | Yes | https://www.smartagritech.se/?lang=en | |
eYeGrow | Mounted | Yes | https://www.fancom.com | |
WUGGL | Handheld | No | http://www.wuggl.com |
Pig Guard (Serket, Amsterdam, the Netherlands) is an AI-powered livestock management software that uses camera vision to monitor pig behavior, detect early signs of illness, and manage feeding and treatment. In partnership with Hikvision (China), it tracks movements, feeding, and aggression in real time, offering alerts to improve herd health and farm management. Yingzi Technology (Guangzhou, China) developed a pig facial recognition system with 98% accuracy, using deep learning algorithms to update profiles with details like individual identity, breed, weight, and gender. EdgeFarm (Intflow, Gwangju, Korea) provides an AI solution that monitors biometric data to detect injuries and diseases while tracking eating habits, social interactions, and weight gain. Lemberg Solutions (Lviv Oblast, Ukraine) developed an AI-based image recognition system for automatic pig weight measurement, reducing stress and improving efficiency. Viiew and Viiew Pro (Illuvation, Jeonju, Korea) offer AI-integrated docking systems for accurate weight management. PigVision (Asimetrix, North Carolina, USA) uses compact cameras with AI to estimate pig weights, while optiSCAN (Holscher & Leuschner, Emsbüren, Germany) employs a 3D camera and AI to provide precise measurements from over two million data points. Pigxcel Edge (Smart Agriculture Solution, Sjövik, Sweden) uses machine learning to track daily pig weights, with data analyzed in the cloud. The eYeGrow monitor (Fancom BV, Panningen, The Netherlands) automates weight monitoring with a 3D camera, and WUGGL One (WUGGL GmbH, Lebring, Austria) combines high-precision cameras with a contactless temperature sensor for real-time monitoring.
RGB sensors, combined with AI technology, present a promising approach for pig farms to enhance animal welfare, improve farm management, and boost profitability in commercial applications. As AI and sensor technology continue to evolve, their potential applications in pig farming are expected to expand, driving further innovation and improvements across the industry. These advances will enable more precise monitoring, automated decision-making, and optimized resource management, contributing to the future of smart farming.
FUTURE PERSPECTIVES, CHALLENGES AND SUMMARY
Machine vision and RGB imaging provide significant advantages in pig health management by enabling early disease detection and real-time monitoring of behavior, surpassing traditional observation-based methods. These technologies analyze large datasets to detect subtle changes in behavior or appearance that indicate disease onset, enhancing welfare monitoring by tracking social interactions and stress indicators [95]. The integration of sensor and camera data offers a comprehensive view of the farm environment, aiding in the effective management of housing conditions. Cameras are widely used for disease detection, behavior monitoring, and health assessment in controlled environments, with notable benefits for farm monitoring [34,44].
However, several challenges hinder the full potential of machine vision in pig health management. A primary issue is the need for robust, accurate image processing algorithms that are capable of handling broad variability in pig appearance and behavior. Developing machine learning models that are trained on large, labeled datasets is both resource-intensive and time-consuming [45]. Commercial farm settings present additional obstacles, such as the clustering of animals, varied feeding habits, unmarked animals, inconsistent lighting, environmental debris, and background interference [6,44]. Surveillance systems also face challenges such as abrupt lighting changes that cause shadows, similar pig features that complicate the identification of individuals, and occlusions from group interactions or debris [55,96]. Object deformation and temporary obstructions further complicate tracking and identification processes [6,59,97].
Implementing machine vision and RGB imaging in pig farms is complex due to the diversity of sensors and data systems already in use. Additionally, privacy and ethical concerns surrounding data usage and regulatory compliance must be carefully addressed when integrating these technologies. Despite these challenges, machine vision holds substantial promise for advancing health management in modern pig farming systems. Continued research and development efforts are essential to further refine image acquisition techniques, enhance the accuracy of algorithms, and address privacy and ethical considerations surrounding data usage. The immersive adoption of these technologies—alongside complementary advances in sensor technology, drones, and robotics—promises to revolutionize pig farming practices. By exploring the insights provided by machine vision and RGB imaging, farmers can optimize disease management strategies, improve pig welfare, and ultimately enhance the sustainability and profitability of pig production systems.