As the world population is growing rapidly, Precision Livestock Farming addresses the task of providing a sustainable food production  . The objective of Precision Livestock Farming is to automatically inform farmers on the current health  or welfare status  of their animals and to help them make decisions based on analysed sensor data. Many developments have been presented in multidisciplinary studies using various cameras   , microphones  , accelerometers   , and different other kinds of sensors. Unfortunately, most projects were never successfully implemented in the field. On the one hand, all developments need to be accepted and handled by the farmers  . Even if farmers are motivated to enhance their performance, they often lack time or experience to change operating procedures  . On the other hand, many projects do not reach the state of full development. Problems that arise are for example impractically high computational costs of a working solution or too much unexplained variance in the results as well as between animal variations in the measurement precision with regard to the target variable. The present study investigates the possible influence of animal behaviour during the collection of sensor data on the target variable.
Animal behaviour has become an important field of scientific investigation. To express individual and species appropriate behaviour is an issue of animal welfare. But predispositions towards stress, fear of novelty or humans as well as sociability   do not only affect welfare or herd status, but also the performance of farm animals  . Behavioural traits are already taken into account in breeding decisions regarding for example the behaviour in the milking parlour or performance related temperament traits as part of the breeding goal  . Additionally, animal behaviour is an issue of human animal interaction in terms of work safety  . Reference  suggests that animal behaviour could be assessed through sensor data. However, the effect of individual animal temperament on the sensor data that is used to address specific target variables has so far not been investigated. Usually, the sensor data that is modelled and analysed in Precision Livestock Farming to obtain the desired target variable was measured from the animal directly and was already animal related information (for example ultrasound measurements of backfat thickness), or raw sensor data from the animal was gathered to calculate information from it. The latter, exemplarily, takes place with camera based studies. Reference  presented the concept of a 3D cow scanner that combined the fields of view of six Microsoft Kinect cameras to collect 3D information of the surface of walking cows. That project aimed at an objective evaluation of the animals’ body measures, as dairy cattle breeding decisions are based on manual and visual classification of cows’ exterior  . Especially during the recording of walking cows, individual animal behaviour is expressed. In the present study as elementary behavioural traits the time spans the cows avoided the recording unit or needed to pass it as well as the number of times the cows stopped walking during recording are used. It is investigated how the cows adjust to being recorded with the cow scanner without any conspecifics present. Furthermore, the target variable “udder depth” calculated from the recordings is analysed with respect to an effect of the behaviour of the recorded cow.
2. Material and Methods
2.1. Recording Unit
As recording unit (Figure 1) a framework with 2.08 m passage height and 2.05 m passage width was equipped with six Microsoft Kinect v1 cameras. On both sides single Kinect cameras were located in 0.6 m height to deliver a close up of udder, rump, and legs (sideview cameras). Additionally, paired Kinect cameras were positioned in the upper corners of the framework (topview cameras). As they are mounted with an angle of 56˚ between their fronts, one camera of each pair saw the approaching cow and the other camera recorded the cow after it has passed the center of the framework. A more detailed description of the recording unit can be found in  .
On the research farm Karkendamm of Kiel University, a separate room (12.5 m × 4.9 m) with a direct entrance to the cow’s stable was designed as a recording chamber. The cow scanner was installed along the side of the room and a firm round path was constructed to guide the cows through the cow scanner without being led by halter (Figure 2). An additional video camera (Creative Live! Cam Chat HD, 720pUSB Webcam, run by Central 3 Lite software) was installed on one end of the passage through the scanner and gathered video footage of the scene during recording took place. From this footage parameters regarding the behaviour of the cows during recording (behavioural traits) were assessed (section 2.2.3) by visual inspection. The round path was divided into the areas Scanner passage, Avoidance, and Unseen. Scanner passage was the area in which the cow was in the field of view of at least one of the Kinect cameras. Avoidance was the area the cows stepped in when entering the recording chamber. Both
Figure 1. True to scale technical drawing of the recording unit. Left: A framework was equipped with six Kinect cameras. Middle: On each side one Kinect camera was mounted in sideview position. Right: Pairs of Kinect cameras were fixated in topview positions.
Figure 2. Schematic representation of the installation of the recording unit. The cows could access the recording chamber directly from the stable. Spring gates (dashed grey lines) and pipes (solid grey lines) formed a round path that guided them through the framework. Imaginary lines (thin black lines) partition the round path in the areas Avoidance, Scanning passage, and Unseen. A video camera was mounted at the right end of Scanning passage. The surveilled area is covered in grey.
areas Avoidance and Scanner passage were in the field of view of the video camera. Unseen was the area in which the cows were not recorded by the video camera.
2.2. Data Collection
2.2.1. Recorded Cows
In total 18 Holstein-Frisian cows were recorded once a month between November 2015 and May 2016. The cows were led into the recording chamber and walked through the scanner counter clockwise. The same handling person was present for every recording and only motivating the cow to move again, once it stopped walking. One cow was excluded from analysis, because it was randomly chosen as source for the udder model that was needed for the model based 3D object recognition  . Due to loss of video footage no behavioural traits were available for another three cows. The remaining 14 cows completed 9 to 11 cycles (10.1 ± 0.5) through the scanner. Cows were in their first to fifth lactation (2.6 ± 1.3) and between 144 cm and 149 cm in height (146.6 ± 1.9 cm). The milk yields during morning milking on the day of recording ranged from 13.5 kg to 32.7 kg (23.6 ± 6.9 kg). The body mass of the cows after morning milking on the day of recording varied between 540 kg and 831 kg (659.1 ± 72.1 kg).
2.2.2. Calculating “Udder Depth”
For each cow all recorded material was processed. The images were tested to be suitable by preprocessing methods  before object recognition was applied. All suitable images in which the udder could be found were handed on to the calculation of “udder depth”. The height of the udder bottom above the scenery’s floor was defined as “udder depth”. A detailed description on the algorithm for “udder depth” determination can be found in  . Cow wise means UD in “udder depth” were calculated from all suitable images.
2.2.3. Behavioural Traits
The video recordings were analysed by visual inspection to determine parameters regarding the behaviour the cows showed during recording with the cow scanner. The cycle wise gathered parameters (avoidance, runtime, totaltime, stops) are listed below:
Parameters regarding the behaviour observed during a cycle C
・ avoidance(C): The time in seconds the cow spend in the area Avoidance during cycle C, i.e. the time the cow avoided to approach the cow scanner.
・ runtime(C): The time in seconds the cow spend in the area Scanner passage during cycle C, i.e. the time the cow needed to pass the scanner.
・ totaltime(C): The sum consisting of avoidance(C), runtime(C) and the time the cow spend in the area Unseen, i.e. the time it took the cow to complete cycle C.
・ stops(C): The number of times the cow stopped within the Scanner passage during cycle C.
avoidance(C) started as soon as the front end of the cow appeared in the field of view of the video camera and ended when the cow stepped into Scanner passage with the front legs. runtime(C) ended when the rear end of the cow disappeared from Scanner passage. To receive animal wise behavioural traits, the cycle wise gathered parameters were for each animal (cow) averaged over all cycles the respective cow had performed ( ). Definitions can be found in Equations (1)-(4):
Avoid_time (cow) := (1)
Run_time (cow) := (2)
Total_time (cow) := (3)
No_stops (cow) := (4)
2.3. Statistical Analysis
All statistical calculations were conducted using  .
2.3.1. Statistical Analysis of Cycle Wise Values
For all four parameters avoidance, runtime, totaltime, and stops (Section 2.2.3) two-factorial analyses of variance were performed. The factors under investigation were the animal (“cow”) and the number of the cycle that the parameter was gathered in (“cycle”). The factor “cycle” was defined with two levels: “cycles 1 - 5” and “cycles ≥ 6”. The interaction term between “cow” and “cycle” was also included in the analyses, and interaction plots were generated. Given the null hypothesis that all groups equal in means, the R-procedure aov() calculates the conditional probability (p-value), that the data under analysis is consistent with the null hypothesis. Small p-values suggest that the null hypothesis can be rejected. Effect sizes (partial ω2;  ) were calculated where the p-value did not exceed 0.07. As the effect size η2 is prone to overestimating the proportion of explained variance, ω2 was proposed by  which is determined by using unbiased estimators of the variance components associated with the sources of variation in the design. However, comparability across analyses is limited with ω2, because the total variance of the analysis―used as denominator in the computation of ω2―changes with the design of the study. As a solution to the comparability problem was recommended. With regard to the within-subject design of the analyses the formula,
= dffactor ∗ (MSfactor − MSerror)/SSfactor+ (N − dffactor) ∗ MSerror (5)
was used  , where dffactor, MSfactor, and SSfactor denote the degrees of freedom, the mean squares, and the sum of squares due to the corresponding factor. MSerror and SSerror denote mean squares and sum of squares of the error, and N denotes the total number of observations.
2.3.2. Statistical Analysis of Cycle Wise Values
Data set. The data set held cow wise means in “udder depth” (UD). As a parameter for the measurement precision, the standard error (SEUD) was merged as well as the percentage of images used for the calculation of UD regarding the total number of images available for the respective cow (compUD, min (compUD) = 0.62, max (compUD) = 1, mean (compUD) = 0.89 ± 0.09). The lactation number (LacNo) of the cows, the sacrum heights (ST), the body mass (mass) after morning milking on the day of recording, and the milk yield (milk KG) during morning milking on the day of recording were also included. The cow wise behavioural traits Avoid_time, Run_time, Total_time, and No_stops were merged to the data set. Additionally, each behavioural trait was transformed into a two-class categorical variable. The class distinction is presented in Table 1. The categorical variables were named Cat_Avoid, Cat_Run, Cat_Total, and Cat_Stops and were included in the data set.
Statistical calculations. Kruskal-Wallis tests were conducted for the behavioural traits (Equations (1)-(4)) with respect to a grouping after lactation numbers. The R-procedure kruskal. test() was used and p-values were calculated. The fourth and fifth lactations were combined in one group in order to achieve a more balanced design. The corresponding boxplots were generated. In addition, Wilcoxon rank-sum tests were carried out for the variables UD and SEUD with respect to the categorical variables Cat_Avoid, Cat_Run, Cat_Total, and Cat_Stops (Table 1). Boxplots were generated. To explain the calculated linear traits and their measurement precision in terms of behavioural traits and animal related parameters, multiple linear regression models for UD and SEUD were build using the remaining data set variables as predictors. The models were evaluated due to the Goodness-of-Fit measures Akaike’s An Information Criterion (AIC), Bayesian Information Criterion (BIC), adjusted coefficient of determination (adjR2), the statistic (Fstat) of the F-test that checks if at least one coefficient is nonzero as well as the corresponding p-value (pFstat), and root mean squared error (RMSE). Furthermore, for UD and SEUD least square means (lsmeans) with respect to the factors LacNo and Run_time, respectively, LacNo and Avoid_time were computed. The covariates mass, milkKG, and ST were included for UD. For SEUD the categorical variable Cat_Run and compUD were included as covariates. 3D barplots were generated to illustrate the dependencies from the factors.
Interaction between the factors “cow” and “cycle” for avoidance, runtime, and totaltime are presented in Figure 3. Qualitative and quantitative interactions were present for all three parameters. For six cows (5017, 5048, 5790, 5967, 6009, 6037) higher values in all three parameters were observed in “cycles ≥ 6” compared to “cycles 1 - 5”. Another group of six cows (4771, 4843, 4939, 5820, 6129, 6169) show increases from “cycles ≥ 6” to “cycles 1 - 5” in two of the parameters but a decrease in the third. For only two cows (4508, 6147) the values in all three parameters were decreasing. No parallel lines were found. The descriptive statistics as well as the results of the analyses of variance concerning the cycle wise parameters avoidance, runtime, totaltime, and stops can be found in Table 2.
Table 1. The behavioural traits Avoid_time, Run_time, Total_time, and No_stops were split into two categories each, defining the categorical variables Cat_Avoid, Cat_Run, Cat_Total, and Cat_Stops.
Figure 3. Interaction plots illustrating the interaction between the factors “cow” and “cycle” with regard to the cycle wise parameters avoidance (left), runtime (middle), and totaltime (right).
Table 2. Descriptive statistics, p-value regarding the effects of “cow” and “cycle”, and effect sizes for cycle wise gathered parameters in cow behaviour.1
1: The number of observations (N), minimum (Min), maximum (Max), mean value (Mean), and standard deviation (SD) are given (rows 1 - 5). Rows 6 - 11 hold p-values and effect sizes ( ). N.S. denotes that the factor had no significant effect.
The behavioural traits Total_time and No_Stops significantly depended on the lactation number with p-values p = 0.05 and p = 0.07, respectively. Both traits were observed on a higher level in the first and the combined fourth and fifth lactation than the second and third lactation. The boxplots (Figure 4, top row) revealed monotonous increases from second to fourth and fifth lactation in both traits. In No_stops the highest mean was observed for primiparous cows, whilst cows in their fourth or fifth lactation showed the highest mean in Total_time. Significant effects of the behavioural traits Avoid_time and Run_time on SEUD were found with p-values p = 0.06 and p = 0.03, respectively. While higher standard errors in UD were observed with the cows that avoided to pass the scanner longer than 12 seconds, a Run_time greater than 15 seconds led to lower standard errors in UD (Figure 4, bottom row). The model with the best Goodness-of-Fit measures for UD was given by
UDijklm = µ + LacNoi + massj + milkKGk + Cat_Runl + STm + εijklm, (6)
where UDijklm are the cow wise means of the “udder depth”, µ is the overall mean, LacNoi is the fixed effect of ith lactation, massj is the fixed effect of the jth body mass after morning milking on the day of recording, milk KGk is the fixed effect of the kth milk yield during morning milking on the day of recording, Cat_Runl is the fixed effect of the lth category of the behavioural trait Run_time, STm is the fixed effect of the mth sacrum height, and εijklm is the random residual effect. The model with the best Goodness-of-Fit measures for SEUD was given by
= µ + LacNoi + Cat_Avoidj + Cat_Runk + + εijkl, (7)
where are the standard errors of UD, µ is the overall mean, LacNoi is the fixed effect of ith lactation, Cat_Avoidj is the fixed effect of the jth category of the variable Avoid_time, Cat_Runk is the fixed effect of the kth category of the behavioural trait Run_time, is the fixed effect of the lth percentage of images from which a value for “udder depth” was computed, and εijkl is the random residual effect. Goodness-of-Fit measures for both models can be found in Table 3.
Figure 5 presents dependencies of the lsmeans for UD and SEUD across the factors LacNo and Run_time, respectively, Avoid_time. For both categories of Run_time, the adjusted means in UD were strictly monotonously decreasing with increasing lactation number. For every lactation number, smaller lsmeans in UD were observed with Run_time values lower or equal to 15 seconds. The
Figure 4. The boxes upper and lower boundaries mark the 75% and 25% quartiles, respectively. The black line denotes the medians. Whisker lengths correspond to 1.5 times the boxes’ interquartile ranges. Outliers are marked with rectangles. Top row: Boxplots illustrating the differences in Total_time (left) and No_stops (right) depending on the lactation number. Bottom row: Boxplots illustrating the differences in standard error of UD depending on the behavioural traits Avoid_time (left) and Run_time (right).
Table 3. Goodness-of-Fit measures for the multiple linear regression models describing UD and SEUD.2
2: Given are Akaike’s An Information Criterion (AIC), Bayesian Information Criterion (BIC), adjusted coefficient of determination (adjR2), F-test statistic (Fstat) and p-value (pFstat) regarding the test if at least on coefficient is nonzero, and root mean squared error (RMSE).
Figure 5. 3D barplots of the least square means of UD (left) and SEUD (right) regarding the factors lactation number and Run_time, respectively, Avoid_time. For the sake of better visibility, the arrangement of bars with respect to the lactation number was reversed in the left 3D barplot. The statistics for the models applied to calculate the least square means for UD and SEUD were adjusted coefficient of determination adjR2 = 0.82, F-test statistic Fstat = 7.39, and p-value pFstat = 0.06, respectively, adjR2 = 0.53, Fstat = 3.43, and pFstat = 0.06.
adjusted cow wise means in SEUD increased monotonously with increasing lactation number. For every laction number, the lsmeans in SEUD were smaller with Avoid_time values lower or equal to 12 seconds. The statistics for the models applied to calculate the least square means for UD and SEUD were adjusted coefficient of determination adjR2 = 0.82, F-test statistic Fstat = 7.39, and p-value pFstat = 0.06, respectively, adjR2 = 0.53, Fstat = 3.43, and pFstat = 0.06.
The goal of this study was to analyse how the recorded image data and the results calculated from it were affected by individual animal behaviour during recording. In the analyses of cycle wise gathered parameters the factors “cow” and “cycle” were considered. The interaction between these factors needed to be taken into account as well, because it was likely that animal temperament, age or herd status influenced the reactions to the repeated passages through the scanner. It was anticipated that cows had individual walking speeds and experienced individual amounts of fear or curiosity towards the cow scanner as a novel object  . Since  found that learning behaviour of calves depended on their temperament, it was also expected that the animal reactions changed individually during repeated scanner passages. Although the interaction term was not significant for avoidance and runtime, it remained in the model, because in this way the effect of “cycle” could be interpreted depending on the effect “cow”  . As illustrated by Figure 3, qualitative interactions between the factors “cow” and “cycle” were present in the analyses of variance with regard to avoidance, runtime, and totaltime. This refers to the fact that lines with positive and negative gradients intersected in all interaction plots, meaning that in the later cycles longer time spans in avoidance, runtime, and totaltime compared to the earlier cycles were noted for some animals and for other cows the higher values were noted in the first five completed cycles. Lines with negative gradient might indicate cows that adapted to passing the scanner after the fear of novelty subsided, whereas lines with positive gradient possibly correspond to the cows’ unwillingness to participate any longer. Possible stressors might have been the length of the data collection and that recording was carried out without returning to the conspecifics between the completion of cycles. Reference  stated that cows showed stronger attention towards the task to perform with a conspecific demonstrator present. It was also proven, that cows adjust their behaviour to external motivation like the access to pasture  or food reward  . In contrast, the presented setting did not provide any motivation for the cows to participate. As the recorded cows were kept in a loose-housing barn, locomotor activity was no motivation itself  . Frustration in cows was, thus, likely to occur. Within specific subgroups of cows change in parameter values had the same sign but differed in amount (quantitative interaction), but similarities between the respective cows were not explained by herd management data (lactation number, height, body mass, and milk yield; results not shown). The recorded cows also behaved inhomogeneously when avoidance, runtime, and totaltime were considered simultaneously. Exemplarily, higher values in avoidance, runtime, and totaltime in “cycles ≥ 6” were observed for half of the animals, indicating that these cows expressed unwillingness within every section of the round path (Figure 2). However, the second main group of animals showed increases in two of the three parameters, but a decrease from “cycles 1 - 5” to “cycles ≥ 6” in the third one. Again, no significant differences in lactation number, height, body mass or milk yield were indicated between these groups of cows (results not shown) to provide an explanation. The findings were likely to be related to the animals temperament regarding fear, social behaviour, and stress resistance   . As no temperament tests were performed in this study, and no former evaluation of the temperament of the recorded cows was available, it remained an item for specially designed future studies to reaffirm these connections. The dependency on the individual animal is supported by the effect sizes . According to “Cohen’s rule of thumb”  , the “cow” effect was large for the parameters avoidance and totaltime and medium for runtime. In contrast, the effect sizes for “cycle” and the interaction term were small to medium. Interestingly, runtime, i.e. the time to pass the scanner, exhibited the smallest “cow” effect compared to avoidance and totaltime. This might indicate that the cows tried to pass the unknown cow scanner quickly once they stopped avoiding the scanner passage. The cycle wise parameter stops was possibly not influenced by “cow” or “cycle”, because external stimuli like sounds from outside the recording chamber might have caused the animals to stop. On the contrary, the cow wise averaged behavioural trait No_stops significantly depended on the lactation number of the cow. A relatively high p-value (p = 0.07) was observed. However, the authors decided on reporting this finding, because it illustrated that analyzing the changes in animal behaviour during recording does not necessarily reveal the same information than an investigation of the overall performance of this animal. Assuming that external stimuli led to unexplained variance in stops, these might carry less weight in the averaged behavioural trait No_stops, and the effect of the age in terms of lactation number became visible (Figure 4, top row). The significant differences in Total_time due to lactation number might be explained by dissimilar agility and experience of cows of different ages. The primiparous cows were less experienced and, thus, more uncertain of the situation. They probably acted more hesitantly which led to a reduced total time compared to cows in their second to third lactation. The individual walking speed of younger cows might have been higher than that of animals in the fourth or fifth lactation due to juvenile energy and, because less pregnancies strained the locomotor system.
When it came to the effects of cow behaviour on the calculated “udder depth” and its measurement precision, significant dependency of SEUD on Avoid_time and Run_time, i.e. cow wise averaged avoidance and runtime, was observed. The standard error SEUD served as a measure of precision in the determination of cow wise averaged “udder depth” UD, whereat low SEUD corresponded to high measurement precision. The p-value with regard to Avoid_time (p = 0.06) was again larger than the usually reported limit 0.05. However, the authors considered it an interesting observation that SEUD increased with increasing Avoid_time and decreased with increasing Run_time (Figure 4, bottom row). A reason for this might be that Avoid_time did not only depend on walking speed but a high Avoid_time corresponded to cows that were trying to avoid passing the scanner. Reference  stated that the exit velocity after being held in squeeze chute was valuable for assessing temperament and stress responsiveness in animal handling events. Although cows were not held in a squeeze chute in the area Avoidance, the animals associated with high Avoid_time might have been more stressed out while passing the scanner. They might have started the passage at a higher speed which could have affected their posture and the homogeneity of their gate leading to suboptimal recordings of the udder. In the same way high Run_time values were not only caused by low walking speed but time spend standing within the Scanner passage also led to increased Run_time. In this way, udders might have been recorded in standstill which increased the quality of the recordings  and hence the measurement precision   . In fitting the multiple linear regression model for UD and SEUD, it could be distinguished between information not directly related to cow behaviour (lactation number, height, body mass, milk yield) and information directly related to the behavior during recording process. The most successful―in terms of Goodness-of-Fit measures―model describing UD only held the categorised Run_time as behaviour related information, but three predictors that were not directly related to cow behaviour. In contrast, the most successful model describing SEUD held only the lactation number as information that was not directly related to cow behaviour. This indicated that the measurement precision depended on the behaviour of the animal more strongly than the linear trait itself. A closer inspection of Figure 5 supported this assertion. When it came to the behavioural traits, large differences in least square means between categories I and II in Avoid_time (Table 1) were observed for SEUD, but UD was only slightly larger for the category with longer Run_time values. Least square means of UD further showed that the udder lowered towards the ground with increasing lactation number. This was expected, and was already found and discussed in  . Least square means in SEUD were increasing with increasing lactation number indicating that measurement precision decreased. Since the udder tissue became more stretched with every additional lactation, this was anticipated. The udder tissue was stressed during milking  and refilling, and occurrences of mastitis which affected the udder firmness  were more likely with increasing lactation number. Stretched tissue and less firm udders varied more strongly during animal movement and were less defined in shape, leading to reduced precision in object recognition as well as udder bottom definition and, thus, to reduced measurement precision in UD.
In Precision Livestock Farming studies often the question arose why implemented analyzing algorithms produced precise and meaningful results for some animals whilst with other animals an additional source of variance seemed to have altered the results, although the measuring conditions were the same for all animals. Using the cow scanner recordings as an example, the authors’ aim was to show that successful analyses of sensor based data in an animal related context might not only depend on the precision of the sensor, but also on the behaviour of the animals during gathering the sensor data. Individual animal temperament is likely to introduced variance to the sensor data that might be difficult to explain during data analysis. However, developments that might be sold to farmers later need to deliver reliable results for the whole herd. As it was with most sensors impossible to measure animal temperament during data collection or to conduct contemporary external temperament tests, it seemed difficult to model the target variable including the temperament. The authors recommend to record general behavioural traits during test phases of product development in order to quantify the effects and to be able to better understand and report the variability in measurement precision across animals.
In this study, it was analysed how body traits calculated from image material that was recorded with a scanning passage (cow scanner) depended on animal behaviour during recording. Behaviour related parameters were observed during recording with the cow scanner and analysed with regard to their effect on the actual target variable automatically calculated “udder depth”. Qualitative and quantitative interactions between the effect of the cow and the effect of repeatedly passing the scanner were found, indicating that animal individuality led to different ways the cows adjusted to the scanner. The observed behavioural traits significantly affected the measurement precision in cow wise averaged “udder depth”. As information on animal temperament is often unavailable while the target variable is calculated, behavioural parameters should be observed during the test phase of a developed product so that the underlying effect on the measurement precision can in retrospect be described.
Gratitude is expressed to Stiftung Schleswig-Holsteinische Landschaft and to Rinderzucht Schleswig-Holstein eG for advice and financial support.