Computer vision (CV), a non-intrusive and cost-effective technology, has furthered the development of precision livestock farming by enabling optimized decision-making through timely and individualized animal care. The availability of affordable two- and three-dimensional camera sensors, combined with various machine learning and deep learning algorithms, has provided a valuable opportunity to improve livestock production systems. However, despite the availability of various CV tools in the public domain, applying these tools to animal data can be challenging, often requiring users to have programming and data analysis skills, as well as access to computing resources. Moreover, the rapid expansion of precision livestock farming is creating a growing need to educate and train animal science students in CV. This presents educators with the challenge of efficiently demonstrating the complex algorithms involved in CV. Thus, the objective of this study was to develop ShinyAnimalCV, an open-source cloud-based web application designed to facilitate CV teaching in animal science. This application provides a user-friendly interface for performing CV tasks, including object segmentation, detection, three-dimensional surface visualization, and extraction of two- and three-dimensional morphological features. Nine pre-trained CV models using top-view animal data are included in the application. ShinyAnimalCV has been deployed online using cloud computing platforms. The source code of ShinyAnimalCV is available on GitHub, along with detailed documentation on training CV models using custom data and deploying ShinyAnimalCV locally to allow users to fully leverage the capabilities of the application. ShinyAnimalCV can help to support the teaching of CV, thereby laying the groundwork to promote the adoption of CV in the animal science community.
Summary We characterized how activity patterns of group-housed dairy calves are influenced by space allowances ranging from current industry-recommended minimum (3.7 m2/calf), to estimates of average on-farm space allowance in the United States (4.6 m2/calf), to more generous space (5.6 m2/calf). Using data collected from leg-based accelerometers, we found that pen-level daily average standing time was not affected by space allowance, but calves had more frequent and shorter standing bouts with increasing space. Withinpen variability in daily and hourly standing time decreased with increasing space, implying greater social synchrony when space was less constrained. Motion heat maps generated using computer vision illustrated that calves preferred to be near the edges of the pen, and restricting space caused more uniform usage of pen space. These results suggest that increasing space beyond current industry practice may allow for greater expression of individual behavioral preferences.
Summary: To provide novel insight into the movement and space use of dairy cattle, we developed AnimalMotionViz, an open-source software tool that processes video data to monitor animal movement patterns using computer vision. The software generates an image and video, a core and full-range image, and motion metrics that highlight and quantify movement intensity and patterns. This software tool is designed to support the broader adoption of computer vision systems to monitor changes in space use that are indicative of animal health and welfare.
1 Assessing cattle behaviors provides insights into animal health, welfare, and productivity to support on-farm management decisions. Wearable accelerometers offer an alternative approach to traditional human evaluation, providing a more objective and efficient method for predicting cattle behavior. Random cross-validation (CV) is commonly used to evaluate behavior prediction by splitting data into training and testing sets, but it can yield inflated results when records from the same animal are included in both sets. Block CV splits data by block effects, offering a more realistic evaluation but remains underexplored for predicting multi-class imbalanced cattle behavior. Additionally, deep learning (DL) models have not been fully explored for behavior prediction compared to machine learning (ML) models. The objectives of this study were to examine the impact of CV designs on multi-class imbalanced cattle behavior prediction and to compare the performance of ML and DL models. Three ML and two DL models were used to predict the four behaviors of six beef cows from a public tri-axial accelerometer dataset, with model performance evaluated using both hold-out and leave-cow-out CV designs representing random and block CV, respectively. In hold-out CV, ML models achieved accuracies of 0.94 to 0.96 and F1 scores of 0.93 to 0.95, while DL models achieved accuracies of 0.9 to 0.92 and F1 scores of 0.89 to 0.91. In the leave-cow-out CV, ML models obtained accuracies of 0.72 to 0.82 and F1 scores of 0.64 to 0.82, whereas DL models obtained accuracies of 0.76 to 0.82 and F1 scores of 0.64 to 0.76. Generally, ML models outperformed DL models in the hold-out CV, but the multi-layer perceptron DL model demonstrated comparable or superior performance in the leave-cow-out CV. All models performed better with hold-out CV than leave-cow-out CV. Our results suggest that CV designs can affect behavior prediction performance. While a random CV produces seemingly good predictions, these results can be artificially inflated by the data partition. A block CV that strategically partitions data could be a more appropriate design.
Monitoring the movement patterns of dairy cattle can provide important insight into space utilization or space occupancy in a barn. Although several precision livestock technologies have been developed to record dairy cattle movements, there is a lack of open source tools to track and visualize cattle movement patterns. Therefore, we developed an open-source computer vision software tool, AnimalMotionViz, that allows users to track and visualize dairy cattle movement patterns using a motion heatmap. The software comes with an easy-to-use web-based graphical user interface built with the Python Dash package. It implements a set of background subtraction algorithms in the OpenCV package to track animal motion patterns in real time. The software processes each frame of the input video and identifies the background and foreground using these algorithms. Foreground objects are then subtracted from the background across all frames and cumulatively overlaid on an empty mask image created with the first frame of the input video to visualize the intensity or frequency of motion across different regions. The user can generate motion heatmaps in an image and video, and also track specific regional motion with a custom mask. The software also returns the top three peak intensity locations, the total percentage of regions used, and the within-quadrant percentage of regions used. In four 5 min sample videos, quadrants with peak intensity of space use, as identified using the software, aligned with quadrants where calves spent the greatest duration of time, according to continuous recording of behavior from video. The motion heatmaps generated by AnimalMotionViz can be used to understand space utilization or space occupation by animals, as well as to assess how space allocation affects dairy cow movement. We conclude that the newly developed AnimalMotionViz is a user-friendly and efficient tool to support research developments in precision livestock farming towards enhancing cattle management practices and improving pen designs.