# YoloSortC3D: A YOLOv8, DeepSort, and C3D-Based Method for Sheep Rumination Behavior Recognition
## 2 Materials and Methods
### Recognition of Rumination Behavior in Sheep
#### 2.5.2 Introduction to C3D Convolutional Neural Networks  
The C3D convolutional neural network (C3D) [24; 25], developed by the Facebook AI Research team, has wide-ranging applications in areas such as action recognition, scene recognition, and video similarity analysis. Its architecture, as illustrated in Figure 7, consists of 5 convolutional layers and 5 pooling layers (each convolutional layer followed by a pooling layer), 2 fully connected layers, and a softmax loss layer for action label prediction. The number of filters in the convolutional layers increases sequentially from 64 to 128, 256, and 512, resulting in a total of 8 convolution operations and 5 pooling operations. These layers progressively extract high-level spatiotemporal features from the video. The fully connected layers further process these features, and the softmax layer converts the output into a probability distribution across classes, enabling precise action label prediction.  
The constructed rumination classification video dataset was randomly divided into a 75% training set (612 videos) and a 25% validation set (204 videos). The data were then input into three models for training: C3D (3D convolutional neural network), R3D (3D residual network), and R(2+1)D (mixed-dimension convolutional neural network). The training parameters were set as follows: 30 epochs, a learning rate of 1.5 \(\times\) 10\({}^{-3}\), and the stochastic gradient descent (SGD) optimizer. The experiments were conducted on a Windows 10 operating system with hardware configurations including an Intel(R) Core(TM) i5-13400F CPU, an NVIDIA GeForce RTX 4060 Ti GPU, and 8 GB of RAM. The changes in accuracy and loss during training are illustrated in Figure 8. The horizontal axis represents the number of training epochs; in Figure 8a-c, the vertical axis represents accuracy; in Figure 8d-f, the vertical axis represents the loss value. The green lines and dots indicate the performance metrics on the training set, while the red lines and dots correspond to the validation set. It can be seen that, in this study, for the rumination behavior recognition  
Figure 7: C3D network structure diagram.  
task, the C3D model shows significantly better performance compared to the R3D and R(2+1)D models. Therefore, the C3D model was determined to be the optimal solution for rumination behavior recognition.  
In the field of behavior recognition, the C3D model typically uses 16 frames as input to extract spatiotemporal features from videos. However, practical applications have shown that 16 frames may be insufficient for accurately recognizing rumination behavior in sheep. To enhance recognition accuracy and reliability, this study increased the input frame count to 32.  
A 16-frame video sequence, recorded at 30 frames per second, spans approximately 0.53 s. For some behaviors, this duration may be sufficient to capture key features. However, rumination behavior exhibits pronounced periodicity and complex temporal variations, making a 0.53-s window potentially inadequate for capturing the full scope of the rumination process, which may result in decreased recognition accuracy.  
By increasing the frame count to 32, the time span is extended to 1.06 s. This adjustment significantly improves the model's ability to capture the continuity and nuances of rumination behavior. Since rumination is characterized by a series of continuous actions, a longer time span enables the model to gather more temporal information, thereby improving its ability to accurately identify and distinguish rumination behavior.