Abstract:Abstract: Calf is the key to the sustainable development of farms, however, due to autoimmune problems and the external environment, lead to the elimination rate of newborn calves is extremely high, so calves need to be cared, for example, colostrum should be fed to calf immediately after birth in order to improve the calf's ability to fight disease, and keep calf warm at low temperatures to prevent freezing, etc. In addition, try to avoid the impact of the death of cows and calves caused by dystocia on pasture production efficiency and development. Traditional manual monitoring is time-consuming and laborious, while sensors are easy to damage, and affect animal behavior and welfare and other problems, so it is difficult to be applied in the actual production process. In order to improve the calving live rate and survival rate of the calf, which improve the management efficiency and production benefit of the farm, a non-contact automatic monitoring method of cow calving behavior was proposed, that is, based on computer vision technology, the calving behavior of cows can be forewarned by the characteristic of increased frequency of standing up and lying down before calving, which can reduce the rate of missed detection and false detection and avoid the spread of zoonotic diseases without affecting animal welfare. This study was tested in Baotou City, Inner Mongolia, China in 2022. First of all, the surveillance videos and camera videos of cattle farms were collected, and the videos were decomposed into images, from which the standing and lying behaviors of various positions in different environments were selected, annotated, and enhanced, making the dataset of cattle standing and lying behavior. YOLOv5, the object detection model, was trained on this dataset and was used to detect the standing and lying behaviors of multi-object cows before calving, which had good performance in actual different complex scenes, its precision, recall and mean average precision (mAP) reached 99.75%, 99.55%, and 99.5%, respectively. Under the NVIDIA GeForce GTX3090 24G GPU environment, the average detection time of each image is about 7.6 ms, that is, the detection rate can reach 131 FPS. Through real-time detection of the YOLOv5 model, obtaining coordinates and categories of all the behavior of the cattle is possible. Then on this basis, the tracking algorithm was built to continuously track a single cow for a long time through IOU matching and center point distance matching successively, and the time series vector of the behavior of standing and lying was obtained, to recognize the behavior of standing up and lying down according to the transformation of standing and lying behavior with recording the behavior and its time points in the database. At each occurrence of the behavior of standing up and lying down of cattle, the data were collected from the behavior database to count the times of standing up and lying down of each hour during the consecutive 6 hours before the current time point. Finally, the frequency of standing up and lying down for 6 consecutive hours was collected and labeled to make the dataset of standing up and lying down, after six classification models were compared by K-fold cross-validation on this dataset, the support vector machine (SVM) model was selected and used to predict whether calving was likely to occur by the frequency of standing up and lying down, the average Precision, average Recall, Accuracy, and Macro-F1 reached 98.28%, 95.45%, 97.44%, and 96.74%, respectively. After the abnormal results of the SVM model were output, the calving warning signal was sent to the management and nursing staff of the cattle farm. After that, the management and nursing staff or computer could further confirm the calving behavior of the cattle through the changes in the lying time and other characteristics, so as to take corresponding scientific nursing countermeasures and provide a guarantee for the safety of calving. This method realizes abnormal detection of standing up and lying down frequency, provides technical support for automatic warning of cattle calving and reduces the cost of cattle calving monitoring. It is of practical significance to improve the quality and development of modern animal husbandry to increase the overall reproduction rate of cattle.