# Depth-Oriented Gray Image for Unseen Pig Detection in Real Time
## 1 Introduction  
Pigs are critical in the global livestock industry and are a significant protein source [1]. Pork consumption is projected to grow at an average annual rate of 1.2% from 2018 to 2027 [2], underscoring the importance of health and welfare management for pigs. Early detection of health and welfare issues in pigs is essential for maintaining productivity and preventing the spread of diseases. However, it is impractical to manually monitor subtle behavioral changes in commercial-scale pig farms over extended periods [3], highlighting the need for efficient and automated health monitoring systems. Such systems are essential to enhance productivity while managing pigs' welfare and health conditions. With increasing demands for automation and efficiency in the livestock industry, automated healthmonitoring systems are expected to contribute to real-time management and improved productivity in pig farming [4]. Models with fast detection speeds and high computational efficiency are required to monitor pigs' health status in real time using cameras installed in individual pens within commercial pig farms. However, the corrosive environment caused by ammonia emissions in pig farms limits the use of high-performance computing resources. In this context, convolutional neural network (CNN)-based models are suitable for object detection tasks. Among these, You Only Look Once (YOLO) [5], with its CNN-based end-to-end structure, predicts both object locations and classes simultaneously, offering faster processing speeds compared to those of Region-Based Convolutional Neural Networks (R-CNNs) [6]. While R-CNNs use a step-by-step approach with region proposals to achieve high detection accuracy, their computational demands make them unsuitable for real-time processing. Similarly, transformer-based models [7], leveraging self-attention mechanisms to learn global relationships, provide higher detection accuracy than that of CNN-based models but require high-performance computing resources, posing limitations in real-time commercial pig farm settings. Given the need for computational efficiency and real-time processing, YOLO is well suited for automated health monitoring systems. However, these object detection models rely on red, green, and blue (RGB) images, which can experience reduced detection accuracy in environments with complex lighting conditions or significant background variability [8]. For instance, in top-view footage captured by fixed cameras in the same pen, lighting variations or natural light can cause differences in brightness depending on object positions. Additionally, materials like flooring within the Region of Interest (RoI) may ambiguously blend with objects. Furthermore, these models, trained on seen environments, exhibit limited generalization capabilities and lower detection accuracy in previously unseen environments [9]. Figure 1 illustrates these challenges, highlighting the limitations of object detection in unseen environments and the reduced detection accuracy of the YOLOv11n [10] detector in such scenarios. In Figure 1a, there is a screenshot captured from [11], whereas d is a screenshot captured from [12]. In this study, the YOLO detector is applied to both the training data and unseen environments represented by a and d. The results in b and e, shown with green boxes for detected objects, demonstrate low detection accuracy in these unseen environments. Upon analyzing the causes, it is found that the training utilized the German pig dataset [13]. This dataset, collected in German environments, features a characteristic where the floor is darker than the pigs in the foreground. However, this dataset characteristic leads to detection errors when the floor's brightness is similar to or brighter than the pigs, as observed in b. Furthermore, similar errors occur in e due to brightness variations in objects or walls within pigpens that differ from the training environment.