Next Article in Journal
Heartbeat Detection by Laser Doppler Vibrometry and Machine Learning
Next Article in Special Issue
Environment Monitoring of Rose Crops Greenhouse Based on Autonomous Vehicles with a WSN and Data Analysis
Previous Article in Journal
Assessment of Rice Developmental Stage Using Time Series UAV Imagery for Variable Irrigation Management
Previous Article in Special Issue
Prediction of End-Of-Season Tuber Yield and Tuber Set in Potatoes Using In-Season UAV-Based Hyperspectral Imagery and Machine Learning
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Research on a Dynamic Algorithm for Cow Weighing Based on an SVM and Empirical Wavelet Transform

1
Key Laboratory of Modern Precision Agriculture System Integration Research, Ministry of Education, China Agricultural University, Beijing 100083, China
2
Key Laboratory of Agricultural Information Acquisition Technology, Ministry of Agriculture, and Rural Affairs, China Agricultural University, Beijing 100083, China
3
College of Information and Electrical Engineering, China Agricultural University, Beijing 100083, China
*
Author to whom correspondence should be addressed.
Sensors 2020, 20(18), 5363; https://doi.org/10.3390/s20185363
Submission received: 14 August 2020 / Revised: 11 September 2020 / Accepted: 16 September 2020 / Published: 18 September 2020
(This article belongs to the Special Issue Sensing Technologies for Agricultural Automation and Robotics)

Abstract

:
Weight is an important indicator of the growth and development of dairy cows. The traditional static weighing methods require considerable human and financial resources, and the existing dynamic weighing algorithms do not consider the influence of the cow motion state on the weight curve. In this paper, a dynamic weighing algorithm for cows based on a support vector machine (SVM) and empirical wavelet transform (EWT) is proposed for classification and analysis. First, the dynamic weight curve is obtained by using a weighing device placed along a cow travel corridor. Next, the data are preprocessed through valid signal acquisition, feature extraction, and normalization, and the results are divided into three active degrees during motion for low, medium, and high grade using the SVM algorithm. Finally, a mean filtering algorithm, the EWT algorithm, and a combined periodic continuation-EWT algorithm are used to obtain the dynamic weight values. Weight data were collected for 910 cows, and the experimental results displayed a classification accuracy of 98.6928%. The three algorithms were used to calculate the dynamic weight values for comparison with real values, and the average error rates were 0.1838%, 0.6724%, and 0.9462%. This method can be widely used at farms and expand the current knowledgebase regarding the dynamic weighing of cows.

1. Introduction

The weight of cows is an important parameter for their growth and development [1,2,3]. Notably, weight provides an important basis for breeding staff to determine the production performance of cows, for implementing appropriate feeding strategies [4,5,6], for determining nutrition [7], and for establishing medicine doses. Weight is also an important reference index related to the age of mating, reproductive performance [8,9,10], and the time of delivery [11,12]. Weight variations can also provide early warning for some diseases [13]. Therefore, conveniently and accurately obtaining the weight of cows is important in animal husbandry.
The traditional weighing method is static weighing, and it involves driving a cow onto a measuring device with a fence around it. The cow must remain still for a period of time [14] before a stable weight value can be read. Generally, the weight of cows can be accurately obtained. However, large individual cows usually need to be driven by more than one person, which is dangerous to some extent [15]. Moreover, such an operation will cause stress reactions in cows, resulting in negative effects, such as a decreased milk yield. To avoid man-made interference, Pastell et al. [16] used a milking robot equipped with weighing equipment for cow weight in a stationary state, and this approach had a good effect on standing normal cows. However, if cows are leaning against or not standing completely on the platform, there will be a large weighing error, and some farms do not have the appropriate installation conditions for such structures. Therefore, some scholars studied dynamic weighing modes [17]. Weighing equipment is installed along the only path that animals can use, such as the entrance to a cowshed or milking hall. Dickinson et al. [18] built a gait-based weighing system that combined an RFID (radio frequency identification system) and automatic weighing equipment. They compared the dynamic weights with actual static weights, which confirmed the feasibility and effectiveness of the dynamic weighing method in the evaluation of cow weights. Alawneh et al. [19] recorded the daily live weight variations in 463 cows at a dairy farm in northern New Zealand, and the standard deviation of the measured value was 17 kg; they obtained the live weights of cows through autocorrelation analysis, and these weights were used to adjust the cattle feeding plan and detect changes in the bodies of cows. E. Gonzalez-Garcia et al. [20] designed a mobile automatic weighing system based on an environment with outdoor free-range sheep and encouraged the voluntary weighing of sheep combined with stimulations of water and mineral salt intake; this approach not only saved human and material resources but also improved animal productivity and welfare. The above research showed that a dynamic weighing device does not require human intervention and can automatically obtain weight data when placed along a given pathway. However, an automatic weighing device obtains a dynamic weight curve when cows are walking, and there are generally errors associated with weight values obtained from the curve. To reduce such errors as much as possible, some improved methods have been reported. The initial processing algorithm is the simplest mean filtering method, but when cows move quickly, the error of this algorithm will be large. Cveticanin et al. [21] simplified the four-legged movement system of cows into a bipedal system similar to that of humans and built a model to measure the weights of cows on the basis of their walking speed and the weights of objects; as long as animal crowding on the platform is avoided, the error rate can reach less than 2%. Wen et al. [22] established a Back Propagation (BP) neural network model by using the output signal of the weight sensor and the animal movement speed to obtain the animal weight; this method laid the foundation for the application of BP neural networks in dynamic weighing algorithms. Larios et al. [23] studied a small kestrel breeding colony in southern Spain and used an artificial neural network method to process a large number of dynamic weight data for birds to estimate the weights of individual birds. The results showed that the system has a low cost and does not require human observers; thus, this approach is friendly to wild birds. Wang et al. [24] proposed a dynamic weighting method based on wavelet denoising and empirical mode decomposition (EMD). The sampled signal was subjected to wavelet denoising before performing EMD, and the residual normalized result can be used to obtain the weight value. The EMD algorithm, which displayed excellent adaptability in dynamic weighing, obtained very good results but lacked theoretical support; additionally, endpoint effects were observed [25]. Therefore, this approach must be improved.
When a large cow walks on a weighing platform, any slight movement will have an impact on the waveform of the weight curve. The waveforms of different active degrees during traveling can considerably vary. Therefore, a single algorithm is generally adopted to analyze the weight curves of animals in different moving states, and this approach has certain limitations. At present, there are many dynamic weighing algorithms, but most of them do not consider the active degree of the animal being weighed.
In this paper, for the first time, a method based on the SVM classification algorithm and EWT for the automatic dynamic weighing of cows is presented. We collected the dynamic weight curve of cows by placing the weighing equipment along a path used by cows. The weight curve was used to obtain five eigenvalues that express signal information. The eigenvalues were classified by SVM to obtain three active degrees of cows: low grade, medium grade, and high grade. According to the different exercise statuses of the cows, different methods were selected for weight measurement, and finally, the dynamically determined weight of each cow was obtained.

2. Materials and Methods

2.1. Dynamic Signal Acquisition

The experiment took place on a farm in northern China with more than 500 Holstein cows. The animals go to a milking hall that can hold 32 cows at a time each day, and our laboratory equipment was located in the exit passageway of the milking hall. The experiment lasted for a week and was performed at the same time every day. The field situation is shown in Figure 1. All experimental operations were allowed. Because the familiarity of the cows with the environment suddenly changed, a few days before the experiment officially started, we installed equipment during nonmilking intervals to give the cows time to get used to the weighing environment.
During the experiment, guardrails were placed at each end of the device to ensure that only one cow passed at a time. Two weighing body were placed side by side and calibrated using the same method. There are four weighing sensors in the scale body, which are installed at four support points on the weighing table. The type of the sensor is SQB-500, and its rated load is 500 kg. The accuracy class is C4, and the sensitivity is 3.0 ± 0.003 mv/V. One platform was used to obtain a dynamic weight signal, and the other was used to obtain the true weight. Notably, obstacles were established at the end of the second weighing platform to make cows stay on the weighing platform long enough to obtain their weight at that time. Several consecutively obtained values were used to calculate the average, which was deemed the real cow weight. A schematic diagram of the weighing experiment is shown in Figure 2. Each scale has a length of 250 cm, a width of 80 cm, and a height of 10 cm. The distance of 80 cm ensures that the cows will not touch the guardrail or become crowded. The weighing equipment was placed before and after the sloped areas to facilitate cow movement up and down. A gap of 1–2 cm was left between each weighing instrument and the slope to avoid the error caused by the collision of parts due to the shaking of the weighing table during cow movement. There were video recordings of cow progress, and such a video can aid in the subsequent calibration of the motion state. The weighing device communicated with the upper computer via an RS485 link, and the sampling interval was set to 100 ms. During the experiment, the software was refreshed every time a cow passed on the device to ensure that the net weight was always 0 when no cows were on the scale, thus eliminating the interference of cow dung and urine on the weighing platform. A total of 910 weighing curves were collected in this experiment, and the processing method of the weighing data will be given in the next section.

2.2. Dynamic Weighing Algorithm

2.2.1. Preprocessing of the Dynamic Weight Signal

The collected weight information was plotted as the original weight curve W, and the results are shown in Figure 3a; notably, the dynamic weighing of cows involves three stages: The first half of a cow is on the weighing platform, the entire cow is on the weighing platform, and the second half of a cow is on the weighing platform (i.e., after the front half steps off the scale). All four hooves were required to be on the weighing platform to obtain valid data. The effective data acquisition process was as follows:
  • Set the threshold K 1 = η · W m a x , and set η = 0.8 [26]. When a weight is less than K 1 , the value is set to 0, and the resulting graph is shown in Figure 3b.
  • Take the derivative of the function in Figure 3b and obtain Figure 3c.
  • Find the starting positions of the rising edge and the falling edge, i.e., points A and B; the data between A and B are valid data, as shown in Figure 3d.
The effective signal has different lengths, so it is inconvenient to use it as the x input of the classifier. To unify the standard, the characteristic information contained in the signal needs to be obtained. In this paper, five characteristics were used to express signal information, namely, the range R , standard deviation σ , peak factor P A R , waveform factor F F , and velocity v . The formula for each eigenvalue is as follows:
R = f m a x f m i n ,
where f m a x is the maximum value in the valid data set and f m i n is the minimum value in the valid data set:
σ = i = 1 N ( f ( i ) f ¯ ) 2 N ,
where f ( i ) represents the valid data, f ¯ is the average of the valid data, and N is the number of valid values:
P A R = R i = 1 N ( f ( i ) ) 2 N .
In the formula, R is the peak (range):
F F = i = 1 N ( f ( i ) ) 2 N f ¯ ,
v = 2.5 t ,
where t is the time required for cows to walk across a weighing platform with a length of 2.5 m, as shown in Figure 3a.
In statistical analysis, some eigenvalues much differ in an order of magnitude, and those with large values will dominate in the process of model construction and lead to slow convergence in the optimization process, which is not conducive to performing the subsequent calculations. To improve the accuracy and convergence speed of the model, it is necessary to normalize the eigenvalues. The corresponding formula is as follows:
X = x x m i n x m a x x m i n ,
where x is the eigenvalue data, x m i n is the minimum eigenvalue, and x m a x is the maximum eigenvalue.

2.2.2. SVM Classification

The motion state of cows directly affects the waveform changes in the effective signals. When the cow has a high active degree during moving, the waveform amplitude is large, the overall weighing performance is variable, and the weighing duration is short. When the active degree is low, the waveform amplitude is small, the overall weighing performance is relatively stable, and the weighing duration is comparatively long. Different active degrees lead to different waveforms, and using the same method to analyze the waveforms in different active degrees is too singular and limited, thereby increasing the error rate of measurements. The two-stage method of classification and analysis can be adopted to improve the robustness of the algorithm.
In the experiment, dynamic weight data were collected for 910 cows. According to the comprehensive consideration of five characteristics, the active degree of cows was divided into three grades: low, medium, and high. The videos of the four hooves of cows walking on the weighing platform were used to obtain the effective frame counts, and then the effective weighing time t v was calculated according to the frame counts. Two experts were invited to evaluate and score the state of the cows with information, such as the mental state of the cows, the health of the hooves, and the height of the leg lift. The scores were recorded as grade 0, grade 1, and grade 2. We collected all the effective weighing time t v , and set the threshold value t 1 , t 2 (the threshold value was not fixed, and fluctuated according to the expert score). Considering t v and the scores, each collected data subset was demarcated as 0, 1, or 2 corresponding to a low, medium, or high grade of active degree, respectively. The characteristic average values of the three states were calculated as shown in Table 1. Notably, the eigenvalue distribution is the smallest in the slow state, the largest in the fast state, and moderate in the medium state. The three states have certain differences based on different eigenvalues. After combining the five features, the SVM algorithm was used to classify the data. The specific classification process will be described in detail in the following section.
First, dataset D = { ( x 1 , y 1 ) , ( x 2 , y 2 ) , , ( x m , y m ) } was constructed, where x i = ( R i , σ i , P A R i , F F i , v i ) is a feature vector and y i ϵ { 0 , 1 , 2 } represents the tags for the active degrees. There is commonly a problem with class imbalance in data sets. SMOTE is used to extend the minority sample. Then, the data set is randomly [27] divided into a training set and a test set. The SVM algorithm can appropriately divide the data set based on its inherent characteristics, and the anti-noise performance is represented as a highly robust hyperplane [28] f ( x ) = ω T ϕ ( x ) + b . In this case, ω is the normal vector, b is displacement, and ϕ ( x ) is mapped x to the high-dimensional feature space of the feature vector. For the training set { ( x 1 , y 1 ) , ( x 2 , y 2 ) , , ( x m , y m ) } , where y i ϵ { 0 , 1 , 2 } , the SVM optimization objective is:
min ω , b , ξ i 1 2 ω 2 + C i = 1 m ξ i ,
s . t . y i ( ω T ϕ ( x i ) + b ) 1 ξ i , i = 1 , 2 , , m .
In this case, C > 0 is the penalty factor of the error term, and ξ i 0 is the relaxation variable.
To address optimization objective (7), the following classification function can be obtained:
L ( x ) = s i g n ( i = 1 n α i y i κ ( x i , x ) + b ) ,
where α i is the Lagrangian factor and κ ( x i , x ) is a kernel function that maps the feature vector to the high-dimensional space. According to the statistical findings, the five features conform to the Gaussian distribution, so the RBF was selected as the kernel function; this function can be formulated as follows:
κ ( x i , x j ) = exp ( x i x j 2 2 σ 2 ) ,
where ( κ ( x i , x j ) = < ϕ ( x i ) , ϕ ( x j ) > = ϕ ( x i ) T ϕ ( x j ) , σ > 0 is the bandwidth of the Gaussian kernel.
Here:
g = 1 2 σ 2 .
The penalty factor C and kernel function parameter G are the keys to the classification of the dynamic weight signals for cows. These values influence the quality of the SVM model. In this paper, grid search and cross-validation [29] methods were used to find the optimal C and G values.

2.2.3. Dynamic Weight Value Calculation

Above, the data were divided into three categories according to the active degree, and three algorithms were adopted to process the data and finally calculate the dynamic body weight m c .
1. Weight value calculation at low-grade activity
Figure 4a,b show the original weight signal and the extracted valid signal at a low-grade activity. After analysis, it was found that the amplitude fluctuation range of the effective signal in the low grade is small, the waveform duration is the longest among those for the three states, the overall performance is stable, and the waveform does not considerably deviate from that in the normal state.
The improved mean filtering algorithm was used to process the signal in the low grade of active degree. The algorithm procedure was as follows: The maximum and minimum values in the effective data sequence f ( t ) are removed, and the sequence f ( t ) is obtained. The average value of the sequence is used to obtain the weight value m c under dynamic weighing conditions, as shown in the following formula:
m c = i = 1 n 1 f ( t ) n 1 ,
where n 1 is the number of data points in the signal sequence f ( t ) .
2. Weight value calculation at medium-grade activity
The amplitude fluctuations in the medium grade of active degree dynamic weight signal are larger than those for the low-grade signal, the waveform variations are more obvious, and the waveform duration is slightly shorter. The original weight signal and effective signal in this state are shown in Figure 5a,b. According to the nonstationary and nonlinear characteristics of such signals, the EWT algorithm can be used to process the effective data. The EWT algorithm [30] is adaptive [31], and a tightly supported AM-FM signal component can be extracted according to the characteristics of the effective signal of the cow’s dynamic weigh [32]. A single effective signal is decomposed into multiple modal components with different frequency characteristics; one of the components is associated with the residual volume, which can reflect the trend of the effective signal or mean and be used to obtain the dynamic weight value m c . The EWT decomposition of the effective weight signal f ( t ) of cows at medium speed can be expressed as follows:
  • Calculate the Fourier spectrum F ( w ) of the effective signal f ( t ) .
  • Normalize the Fourier spectrum to the interval [0, π ] and divide the spectrum into N intervals; in addition to the boundary value 0 and π , there are N − 1 boundaries that need to be determined. w n is defined as a boundary, and the minimax method for spectral searches is used to determine the other boundaries. Then, each segment can be expressed as:
    Λ n = [ w n 1 , w n ] n = 1 , 2 , , N , and n = 1 N Λ n = [ 0 , π ] .
  • The empirical wavelet is a band-pass filter defined on the interval Λ n based on the construction of Littlewood-Paley and Meyer theories, the wavelet scale function ϕ ^ m ( w ) and wavelet function ψ ^ n ( w ) can be defined as follows:
    ϕ ^ m ( w ) = { 1 , | w | ( 1 γ ) w m cos [ π 2 β ( 1 2 γ w m ( | w | ( 1 γ ) w m ) ) ] 0 , other , ( 1 γ ) w m | w | ( 1 + γ ) w m ,
    ψ ^ n ( w ) = { 1 , ( 1 + γ ) w m | w | ( 1 γ ) w m + 1 cos [ π 2 β ( 1 2 γ w m + 1 ( | w | ( 1 γ ) w m ) ) ] , ( 1 γ ) w m 1 | w | ( 1 + γ ) w m + 1 sin [ π 2 β ( 1 2 γ w m ( | w | ( 1 γ ) w m ) ) ] , ( 1 + γ ) w m | w | ( 1 γ ) w m ,
    where γ < m i n m ( w m + 1 w m w m + 1 + w m ) and β ( x ) = x 4 ( 35 84 x + 70 x 2 20 x 3 ) .
  • Calculate EWT through the construction method of another wavelet transform. The specific formulas of the detailed function w f ε ( n , t ) and the approximate function w f ε ( 0 , t ) are as follows:
    w f ε ( n , t ) = < f ( t ) , ψ n ( t ) > = f ( τ ) ψ n ( τ t ) ¯ d τ = F 1 [ f ( w ) ψ n ^ ( w ) ] ,
    w f ε ( 0 , t ) = < f ( t ) , φ 1 ( t ) > = f ( τ ) φ 1 ( τ t ) ¯ d τ = F 1 [ f ( w ) ψ 1 ^ ( w ) ] ,
    where ψ n ( t ) represents the EWT; ψ n ^ ( w ) and ψ 1 ^ ( w ) are the Fourier transform of ψ n ( t ) and ψ 1 ( t ) ; ψ n ( t ) ¯ and φ 1 ( t ) ¯ are the complex conjugate functions of ψ n ( t ) and φ 1 ( t ) ; and <,> denotes an inner product operation.
  • After obtaining the wavelet detail coefficient and approximate coefficient through the first four steps, for the effective signal f ( t ) , the mathematical expression after decomposition is as follows:
    f ( t ) = i = 0 N f i ( t ) ,
    where f i ( t ) is the decomposed AM-FM component and N is the number of decomposed signal components. The expression of each component is shown in (18):
    { f k ( t ) = w f ε ( n , t ) ψ k ( t ) f 0 ( t ) = w f ε ( 0 , t ) φ 1 ( t ) .
The components of the effective dynamic weight signal obtained with the EWT algorithm are shown in Figure 6. f k ( t ) ( k = 1 , 2 ) reflects the high-frequency part of the effective weight signals for cows and encompasses the local characteristics of the effective signal. The signal component f 0 ( t ) reflects the low-frequency part of the effective signal and the trend or mean value of the signal. The weight value m c of the medium grade under dynamic weighing conditions can be obtained through the calculation of f 0 ( t ) :
m c = i = 1 m f 0 ( t ) m ,
where m is the number of signal components f 0 ( t ) .
3. Weight value calculation at high-grade activity
The original weight signal and the extracted valid signal in the high grade of active degree are shown in Figure 7a,b. The amplitude fluctuation range of the valid signal is the largest among those at other grades, the waveform duration is short, the whole wave fluctuates, and the waveform largely deviates from the under a normal state. In this case, the cow walks onto the weighing platform for a short time, and the walking speed is relatively fast.
Compared with the signals in the low-grade and medium-grade active degrees, the signal length in the vigorous motion state is shorter, the signal fluctuation is larger, and the signal information cannot be well interpreted. Therefore, the effective signal sequence is regarded as a periodic signal for periodic continuation. Assuming that the length of the wavelet filter is M, the length of the effective signal sequence F (t) is N, and the extended signal is f d ( t ) , then:
f d ( t ) = { f ( t ) , 0 t N 1 f ( t N ) , N 1 t N + M 2 .
EWT decomposition is performed by using the extended signal f d ( t ) . The decomposition process used is consistent with the decomposition process applied for the effective signal at the medium grade and will not be redescribed here. The decomposition result is shown in Figure 8.
The signal component f 0 ( t ) decomposed by the EWT algorithm reflects the trend or mean value of the effective signal for the dynamic weighing of cows in the high grade of active degree. The weight value m c can be obtained through calculating f 0 ( t ) , and the corresponding formula is as follows:
m c = i = 1 m f 0 ( t ) m ,
where m is the number of signal components f 0 ( t ) .

2.2.4. Evaluation

1. Classification evaluation index
In general, we used the accuracy rate to evaluate the classification model because it is a relatively intuitive evaluation index. The accuracy formula is as follows:
Accuracy = TP + TN TP + TN + FP + FN ,
where TP, FN, FP, and TN are the components of the classification confusion matrix; specifically, TP represents the number of correct classifications for positive samples, FN represents the number of incorrect classifications for positive samples predicted to be negative samples, FP represents the number of incorrect classifications for negative samples predicted to be positive samples, and TN represents the number of correct classifications for negative samples [33].
However, using accuracy alone is not sufficient for fully evaluating the classification effect. To better evaluate the classification model, four evaluation indexes were considered: precision, recall, specificity, and the F 1 _ score . The formulas for these indexes are shown in Table 2.
2. Weight as an evaluation index
By comparing the dynamic weight value with the real value, the accuracy of the weight algorithm can be assessed. Therefore, the error, which reflects the difference between the real and predicted values, was selected as the evaluation index. According to the dynamic weight value m c and real value m s , the weight estimation error can be calculated as follows (body weight estimation errors):
e r r o r = | m c m s | m s × 100 % .
Taking the weight data of the cow whose ID number is 130314 as an example, the acquisition process of real values m s is illustrated. With the obstacle placed at the end of the second weighing platform, the cow will be stagnant for a certain period of time. The weighing instrument can read that weight at this moment, as shown in the orange box in Figure 9. The average value of the collected data is calculated as m s and treated as the true value of the cow weight. The m s value of this cow is 602.2 kg.
The dynamic weighing curve corresponding to this cow is shown in the orange curve in Figure 9. The SVM classifier divides its valid signal into the medium-grade activity, so the EWT algorithm is used to calculate its dynamic weighing value. Since the calculation process iis described in Section 2.2.3, it will not be repeated here. In Figure 9, the effective part of the original weighing curve is decomposed by the EWT algorithm to obtain the signal component f 0 ( t ) . The dynamic weighing value m c can be obtained by calculating the average value of f 0 ( t ) , which is 599.1 kg. According to formula (19), the dynamic weighing error rate of the cow with ID number 130314 is about 0.5148%.

3. Results and Discussion

3.1. SVM Classification Results

The classification of weight data with the SVM algorithm is a prerequisite for the accurate acquisition of the dynamic weight values of cows. In this section, the classification results are analyzed and discussed. The original data set for this experiment included 910 values; the unbalanced data were processed with the SMOTE algorithm [34], and the overall number of values increased to 1527. The data were randomly assigned to the training set and the test set at a ratio of 8:2 [35]. The training set was used to train the SVM model, and the test set was used for verification. According to the SVM classification results, the actual classification and predictive classification diagrams of the test set were obtained, as shown in Figure 10.
In Figure 10, a blue ○ represents a correct prediction based on the actual classification for the test set, a lavender * represents a correct prediction, a magenta □ represents an incorrect prediction based on the actual classification, and a red ▽ represents an incorrect prediction. Notably, four red labels and four magenta labels can be observed; the red triangles and magenta squares have a longitudinal one-to-one correspondence, which also means that there are two actual high grades mistaken for medium grades and two medium grades are mistakenly classified as low grades. In addition, other actual and predicted classifications are consistent, and most of the predicted and actual values are similar. According to the statistics for the actual and predicted values of each grade in the figure, the classification confusion matrix is obtained as shown in Table 3:
For the three different active degrees, Table 3 shows that the values of TP, FN, FP, and TN in the low grade are 101, 0, 2, and 203, respectively. At a medium grade, the values of TP, FN, FP, and TN are 88, 2, 2, and 214, respectively. In the high grade, the values of TP, FN, FP, and TN are 113, 2, 0, and 201, respectively. According to the distribution of the confusion matrix under the three grades, the overall accuracy, precision, recall, specificity, and F1_score values were calculated, as shown in Table 4.
Table 4 shows that the overall classification accuracy is 98.6928%, which reflects a good classification effect. Among the evaluation indexes for the three active degrees, the accuracy, specificity, and F1_score of the high grade of active degree are the highest, reaching 100%, 100%, and 0.9912, respectively. The accuracy, recall, and F1 score of the medium-grade state are the lowest at 97.7778%, 97.7778%, and 0.9778, respectively. The highest recall rate was observed for the low grade at 100%, but the specificity was the lowest at 99.0244%. Overall, the classification model designed in this paper has a good effect and can accurately distinguish among the three active degrees. The classification results for the medium state slightly differ from those for the low and high grades. The statistical results in this paper support the effectiveness of the proposed method, and the classification results are reasonable. A method for classifying the active degree before calculating the weight value has not been previously reported, so the proposed approach provides a reference for assessing the active degree during the traveling of cows in actual production.

3.2. Dynamic Weighing Results

After classification, the dynamically obtained weight data were divided into three classes: low grade, medium grade, and high grade of active degrees during walking. The mean error rate and maximum error rate were calculated for the three active degrees, and the results are shown in Table 5.
Table 5 shows the average error rate and maximum error rate for the low, medium, and high active degrees. The average error rate and maximum error rate are the largest at 0.9462% and 1.9696%, respectively, for the high-grade activity. For the low grade, the average error rate and maximum error rate are 0.1838% and 0.5742%, respectively, which are the lowest values obtained. The values for the medium grade are 0.6724% and 1.6924%, respectively. In general, the average error rate calculated by the dynamic weighing algorithm is less than 1%. The calculated values in the three active degrees are consistent with the actual values. In the high grade of active degree, cows move quickly, with severe waveform oscillation and less valid data, so the average error rate of the weight values is largest in this state.
Although the average error rate reflects a good calculation effect, there are still some cases with large error rates, and the maximum error rate in the high grade of active degree approaches 2% in some cases. Based on the dynamic weight data collected and the videos taken during the experiment, the reasons for the high error rate are as follows. During the walking process, cows bounce, sneeze, etc., leading to fluctuations in the data and subsequent effects on the calculated weights. In some cases, cows excrete feces or urine on the first weighing platform and then go to the second weighing platform. This situation can lead to a large difference between the two measured weights, which is also an important factor related to the large error rate. In addition, in some stimulations outside the system, the movement speed of cows will be faster than normal states, leading to the acquisition of less valid data and resulting in a large error rate.
To verify the reliability of the algorithm developed in this paper, the EMD algorithm, a commonly used dynamic weighing signal analysis method, was applied to the collected weight signals of cows, and the average error rate was calculated for the medium and high grades. The results of the EMD algorithm and the algorithm proposed in this study are compared in Figure 11.
According to the comparison and analysis in Figure 11, the average error rate calculated by the EWT algorithm is lower than the average error rate obtained by the EMD algorithm in the dynamic weighing processing of cows at medium and high grades. The error rate of the EWT algorithm is less than 1%, and the average error rate of the EMD algorithm is less than 1.15%. The EWT algorithm performs better than the EMD algorithm in processing the dynamically obtained weights of cows. In fact, the EWT algorithm is an improvement of the EMD algorithm that inherits the advantages of rigorous wavelet transform theory and solves the traditional mode alias and large computational load problems of the EMD algorithm [25]. Taking the dynamic weighing data of the dairy cow with ID number 130314 as an example, the running time of the EWT algorithm is 0.0589 s when processing data, but the EMD algorithm’s is 0.5458 s, a difference of nearly 10 times of order of magnitude. The dynamic weighing equipment of dairy cows is used in the breeding farm and the cow weight value in real time is needed, so the EWT algorithm with a shorter running time is more in line with actual production needs. Therefore, the EWT algorithm can be effectively applied to weight curve processing in medium and high active degrees.

4. Conclusions

In this study, we collected the dynamic weight curve of cows by placing the weighing equipment along a path used by cows and the data were preprocessed. An SVM classification model was used to classify the weight signals, and a classification method for three active degrees during the traveling of cows was proposed for the first time. According to the active degree, the improved mean filtering, EWT algorithms, and the EWT based on the periodic extension algorithm were used to obtain the dynamic weight values. The results showed that the accuracy of the established classification model is 98.6928%. The data can be effectively divided into three categories according to the cow active degrees to provide a good basis for the accurate calculation of body weight. Three different algorithms were used to obtain dynamic weight values, and the average error rates were 0.1838%, 0.6724%, and 0.9462%, respectively, with an average error rate of less than 1%; thus, the proposed method meets the actual management demands. The research in this paper has practical value, and the developed method can be widely applied at farms to greatly reduce the manpower, material resource, and financial resource requirements. However, the error rate may be large in some cases, and research will be continued in the future to improve the accuracy of the proposed algorithm.

Author Contributions

Conceptualization, N.F. and Y.Z.; methodology, N.F. and X.K.; software, N.F.; validation, N.F. and H.H.; formal analysis, N.F. and Y.Z.; investigation, N.F. and H.H.; resources, N.F. and G.L.; data curation, N.F.; writing—original draft preparation, N.F.; writing—review and editing, N.F., X.K. and G.L.; visualization, N.F.; supervision, S.M.; project administration, S.M. and N.F.; funding acquisition, G.L. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the National Key R&D Program of China (No.2018YFD050070502), National Natural Science Foundation of China (Grant No.61871380) and Beijing Natural Science Foundation (Grant No.4172034).

Acknowledgments

We would like to thank the Hebei Dingyuan Breeding Plant for providing us with the experimental site and Shanjie Yang, Aiping Wang and Zhikun Jin for their help during the experiment. In addition, we would like to thank Wenbin Dong for his encouragement and help.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Riley, D.G.; Burke, J.M.; Chase, C.C.; Coleman, S.W. Heterosis and direct effects for Charolais-sired calf weight and growth, cow weight and weight change, and ratios of cow and calf weights and weight changes across warm season lactation in Romosinuano, Angus, and F1 cows in Arkansas1. J. Anim. Sci. 2016, 94, 1–12. [Google Scholar] [CrossRef] [PubMed]
  2. Mäntysaari, P.; Mäntysaari, E. Modeling of daily body weights and body weight changes of Nordic Red cows. J. Dairy Sci. 2015, 98, 6992–7002. [Google Scholar] [CrossRef] [PubMed]
  3. Pszczola, M.; Szalanski, M.; Rzewuska, K.; Strabel, T. Short communication: Improving repeatability of cows’ body weight recorded by an automated milking system. Livest. Sci. 2018, 214, 149–152. [Google Scholar] [CrossRef]
  4. Menezes, G.C.D.C.D.; Filho, S.V.; Lopez-Villalobos, N.; Ruas, J.R.M.; Detmann, E.; Zanetti, D.; Menezes, A.D.C.; Morris, S.; Mariz, L.D.S.; Duarte, M.D.S.D. Effect of feeding strategies on weaning weight and milk production of Holstein × Zebu calves in dual purpose milk production systems. Trop. Anim. Heal. Prod. 2015, 47, 1095–1100. [Google Scholar] [CrossRef]
  5. Bossen, D.; Weisbjerg, M.R.; Munksgaard, L.; Højsgaard, S. Allocation of feed based on individual dairy cow live weight changes. Livest. Sci. 2009, 126, 252–272. [Google Scholar] [CrossRef]
  6. Jensen, C.; Østergaard, S.; Bertilsson, J.; Weisbjerg, M.R. Responses in live weight change to net energy intake in dairy cows. Livest. Sci. 2015, 181, 163–170. [Google Scholar] [CrossRef]
  7. Podlahová, Š.; Smutný, L.; Šoch, M. Potential utilization of automatic cows weighing for evaluation of health and nutritional condition of herd. Lucr. Stiint. Zooteh. Si Biotehnol. 2011, 44, 308–314. [Google Scholar]
  8. Mulliniks, T.; Beard, J.; King, T. 108 impacts of dam age and milk production on cow/calf profitability. J. Anim. Sci. 2019, 97, 60–61. [Google Scholar] [CrossRef]
  9. Jones, F.M.; Accioly, J.M.; Copping, K.J.; Deland, M.P.B.; Graham, J.F.; Hebart, M.L.; Herd, R.M.; Laurence, M.; Lee, S.J.; Speijers, E.J.; et al. Divergent breeding values for fatness or residual feed intake in Angus cattle. 1. Pregnancy rates of heifers differed between fat lines and were affected by weight and fat. Anim. Prod. Sci. 2018, 58, 33–42. [Google Scholar] [CrossRef]
  10. Buckley, F.; O’Sullivan, K.; Mee, J.F.; Evans, R.D.; Dillon, P. Relationships among milk yield, body condition, cow weight, and reproduction in spring-calved Holstein-Friesians. J. Dairy Sci. 2003, 86, 2308–2319. [Google Scholar] [CrossRef]
  11. Aldridge, M.N.; Lee, S.J.; Taylor, J.D.; Popplewell, G.I.; Job, F.R.; Pitchford, W.S. The use of walk over weigh to predict calving date in extensively managed beef herds. Anim. Prod. Sci. 2017, 57, 583–591. [Google Scholar] [CrossRef]
  12. Menzies, D.; Patison, K.P.; Corbet, N.J.; Swain, D.L. Using walk-over-weighing technology for parturition date determination in beef cattle. Anim. Prod. Sci. 2018, 58, 1743–1750. [Google Scholar] [CrossRef] [Green Version]
  13. Segerkvist, K.A.; Höglund, J.; Österlund, H.; Wik, C.; Högberg, N.; Hessle, A. Automatic weighing as an animal health monitoring tool on pasture. Livest. Sci. 2020, 240, 104157. [Google Scholar] [CrossRef]
  14. Wangchuk, K.; Wangdi, J.; Mindu, M. Comparison and reliability of techniques to estimate live cattle body weight. J. Appl. Anim. Res. 2018, 46, 349–352. [Google Scholar] [CrossRef] [Green Version]
  15. Pezzuolo, A.; Milani, V.; Zhu, D.; Guo, H.; Guercini, S.; Marinello, F. On-barn pig weight estimation based on body measurements by structure-from-motion (SfM). Sensors 2018, 18, 3603. [Google Scholar] [CrossRef] [Green Version]
  16. Pastell, M.; Takko, H.; Gröhn, H.; Hautala, M.; Poikalainen, V.; Praks, J.; Veermäe, I.; Kujala, M.; Ahokas, J. Assessing cows’ welfare: Weighing the cow in a milking robot. Biosyst. Eng. 2006, 93, 81–87. [Google Scholar] [CrossRef]
  17. Liu, X.; Cai, Y. Design of automatic weighing system based on RFID and PLC. In Proceedings of the 2017 Chinese Automation Congress (CAC), Jinan, China, 20−22 October 2017; pp. 7020–7024. [Google Scholar]
  18. Dickinson, R.A.; Morton, J.M.; Beggs, D.S.; Anderson, G.A.; Pyman, M.F.; Mansell, P.D.; Blackwood, C.B. An automated walk-over weighing system as a tool for measuring liveweight change in lactating dairy cows. J. Dairy Sci. 2013, 96, 4477–4486. [Google Scholar] [CrossRef] [Green Version]
  19. Alawneh, J.I.; Stevenson, M.A.; Williamson, N.B.; Lopez-Villalobos, N.; Otley, T. Automatic recording of daily walkover liveweight of dairy cattle at pasture in the first 100 days in milk. J. Dairy Sci. 2011, 94, 4431–4440. [Google Scholar] [CrossRef]
  20. González-García, E.; Alhamada, M.; Pradel, J.; Douls, S.; Parisot, S.; Bocquier, F.; Menassol, J.B.; Llach, I.; González, L.A. A mobile and automated walk-over-weighing system for a close and remote monitoring of liveweight in sheep. Comput. Electron. Agric. 2018, 153, 226–238. [Google Scholar] [CrossRef]
  21. Cveticanin, D.; Wendl, G. Dynamic weighing of dairy cows: Using a lumped-parameter model of cow walk. Comput. Electron. Agric. 2004, 44, 63–69. [Google Scholar] [CrossRef]
  22. Wen, C.; Xie, Z.; Deng, Y. Portable dynamic weighing system of yak based on BP neural network. In Proceedings of the 2nd International Conference on Mechatronics Engineering and Information Technology (ICMEIT 2017), Dalian, China, 13–17 May 2017. [Google Scholar]
  23. Larios, D.F.; Rodríguez, C.; Barbancho, J.; Baena, M.; Leal, M.Á.; Marín, J.; Leon, C.; Bustamante, J. An Automatic Weighting System for Wild Animals Based in an Artificial Neural Network: How to Weigh Wild Animals without Causing Stress. Sensors 2013, 13, 2862–2883. [Google Scholar] [CrossRef] [PubMed]
  24. Wang, T.W.; Zhang, H.J.; Lu, D.M.; Zhang, Z.M. Dynamic weighing of full-size wood composite panels based on wavelet denoising and empirical mode decomposition algorithm. Acta Metrol. Sin. 2017, 38, 300–303. [Google Scholar]
  25. Kedadouche, M.; Thomas, M.; Tahan, A. A comparative study between empirical wavelet transforms and empirical mode decomposition methods: Application to bearing defect diagnosis. Mech. Syst. Signal Process. 2016, 81, 88–107. [Google Scholar] [CrossRef]
  26. Long, J.; Takahata, H.; Umetsu, K.; Hoshiba, H.; Takeyama, I. A livestock walk-through scale system. J. Soc. Agric. Struct. Jpn. 1991, 21, 175–182. [Google Scholar]
  27. Ma, Y.; Zhang, S.; Qi, D.; Luo, Z.; Li, R.; Potter, T.; Zhang, Y. Driving drowsiness detection with EEG using a modified hierarchical extreme learning machine algorithm with particle swarm optimization: A pilot study. Electronics 2020, 9, 775. [Google Scholar] [CrossRef]
  28. Attal, F.; Mohammed, S.; Dedabrishvili, M.; Chamroukhi, F.; Oukhellou, L.; Amirat, Y. Physical human activity recognition using wearable sensors. Sensors 2015, 15, 31314–31338. [Google Scholar] [CrossRef] [Green Version]
  29. Wang, D.; Xie, L.; Yang, S.X.; Tian, F. Support Vector Machine Optimized by Genetic Algorithm for Data Analysis of Near-Infrared Spectroscopy Sensors. Sensors 2018, 18, 3222. [Google Scholar] [CrossRef] [Green Version]
  30. Gilles, J. Empirical wavelet transform. IEEE Trans. Signal Process. 2013, 61, 3999–4010. [Google Scholar] [CrossRef]
  31. Xu, X.; Liang, Y.; He, P.; Yang, J. Adaptive Motion Artifact Reduction Based on Empirical Wavelet Transform and Wavelet Thresholding for the Non-Contact ECG Monitoring Systems. Sensors 2019, 19, 2916. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  32. Huang, N.; Qi, J.; Li, F.; Yang, D.; Cai, G.; Huang, G.; Zheng, J.; Li, Z. Short-Circuit Fault Detection and Classification Using Empirical Wavelet Transform and Local Energy for Electric Transmission Line. Sensors 2017, 17, 2133. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  33. Taylor, W.; Shah, S.A.; Dashtipour, K.; Zahid, A.; Abbasi, Q.; Imran, M. An Intelligent Non-Invasive Real-Time Human Activity Recognition System for Next-Generation Healthcare. Sensors 2020, 20, 2653. [Google Scholar] [CrossRef] [PubMed]
  34. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic minority over-sampling technique. J. Artif. Intell. Res. 2002, 16, 321–357. [Google Scholar] [CrossRef]
  35. Zhu, T.; Weng, Z.; Chen, G.; Fu, L. A hybrid deep learning system for real-world mobile user authentication using motion sensors. Sensors 2020, 20, 3876. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Cow weighing scene.
Figure 1. Cow weighing scene.
Sensors 20 05363 g001
Figure 2. Cow weighing diagram: 1—camera; 2—slope; 3—dynamic weighing platform; 4—dynamic weighing indicator; 5—computer; 6—static weighing indicator; 7—static weighing platform; 8—guardrail.
Figure 2. Cow weighing diagram: 1—camera; 2—slope; 3—dynamic weighing platform; 4—dynamic weighing indicator; 5—computer; 6—static weighing indicator; 7—static weighing platform; 8—guardrail.
Sensors 20 05363 g002
Figure 3. Effective signal acquisition process: (a) Original signal from cow weighing; (b) The signal processed based on the threshold K1; (c) The derivative of the signal in (b); and (d) Valid data.
Figure 3. Effective signal acquisition process: (a) Original signal from cow weighing; (b) The signal processed based on the threshold K1; (c) The derivative of the signal in (b); and (d) Valid data.
Sensors 20 05363 g003
Figure 4. Original weight signal and valid signal under the slow grade of active degree conditions: (a) Original weight signal at a low grade; (b) Valid signal at a low grade.
Figure 4. Original weight signal and valid signal under the slow grade of active degree conditions: (a) Original weight signal at a low grade; (b) Valid signal at a low grade.
Sensors 20 05363 g004
Figure 5. Original weight signal and valid signal at a medium grade of active degree: (a) Original weight signal at a medium grade; (b) Valid signal at a medium grade.
Figure 5. Original weight signal and valid signal at a medium grade of active degree: (a) Original weight signal at a medium grade; (b) Valid signal at a medium grade.
Sensors 20 05363 g005
Figure 6. EWT decomposition diagram for a medium-grade activity signal.
Figure 6. EWT decomposition diagram for a medium-grade activity signal.
Sensors 20 05363 g006
Figure 7. Original weight signal and valid signal in the high grade of active degree: (a) Original weight signal at a high grade; (b) Valid signal at a high grade.
Figure 7. Original weight signal and valid signal in the high grade of active degree: (a) Original weight signal at a high grade; (b) Valid signal at a high grade.
Sensors 20 05363 g007
Figure 8. EWT decomposition diagram for a high-grade activity signal.
Figure 8. EWT decomposition diagram for a high-grade activity signal.
Sensors 20 05363 g008
Figure 9. Curve for obtaining the true cow weights.
Figure 9. Curve for obtaining the true cow weights.
Sensors 20 05363 g009
Figure 10. Actual and predicted classification diagram for the test set.
Figure 10. Actual and predicted classification diagram for the test set.
Sensors 20 05363 g010
Figure 11. Comparison of the average error rate between the proposed algorithm and EMD algorithm.
Figure 11. Comparison of the average error rate between the proposed algorithm and EMD algorithm.
Sensors 20 05363 g011
Table 1. Average values for three motion states with different eigenvalues.
Table 1. Average values for three motion states with different eigenvalues.
CharacteristicCategoryAverage
range/kglow grade24.3260
medium grade59.7984
high grade107.9911
standard deviationlow grade10.5815
medium grade19.5883
high grade37.8103
peak factorlow grade0.0650
medium grade0.1090
high grade0.1901
waveform factorlow grade1.0002
medium grade1.0006
high grade1.0022
speed/m/sslow grade0.7525
medium grade1.2500
high grade1.6685
Table 2. Evaluation index formulas.
Table 2. Evaluation index formulas.
Evaluation IndexComputational Formula
Precision/% P r e c i s i o n = T P T P + F P
recall/% R e c a l l = T P T P + F N
specificity/% S p e c i f i c i t y = T N T N + F P
F 1 _ s c o r e F 1 _ S c o r e = 2 P P V R E C P P V + R E C
Table 3. Three categories of the classification confusion matrix.
Table 3. Three categories of the classification confusion matrix.
Predicted ClassificationActual Classification
Low GradeMedium GradeHigh GradeTotal
low grade10120103
medium grade088290
high grade00113113
total10190115306
Table 4. Evaluation index.
Table 4. Evaluation index.
Evaluation IndexCategory
Low GradeMedium GradeHigh Grade
accuracy/%98.6928
precision/%98.058397.7778100
recall/%10097.777898.2601
specificity/%99.024499.0741100
F 1 _ score 0.99020.97780.9912
Table 5. Comparison of the average and maximum error rates for the three active degrees.
Table 5. Comparison of the average and maximum error rates for the three active degrees.
Motion StateMean Error Rate/%Maximum Error Rate/%
low grade0.18380.5742
medium grade0.67241.6924
high grade0.94621.9696

Share and Cite

MDPI and ACS Style

Feng, N.; Kang, X.; Han, H.; Liu, G.; Zhang, Y.; Mei, S. Research on a Dynamic Algorithm for Cow Weighing Based on an SVM and Empirical Wavelet Transform. Sensors 2020, 20, 5363. https://doi.org/10.3390/s20185363

AMA Style

Feng N, Kang X, Han H, Liu G, Zhang Y, Mei S. Research on a Dynamic Algorithm for Cow Weighing Based on an SVM and Empirical Wavelet Transform. Sensors. 2020; 20(18):5363. https://doi.org/10.3390/s20185363

Chicago/Turabian Style

Feng, Ningning, Xi Kang, Haoyuan Han, Gang Liu, Yan’e Zhang, and Shuli Mei. 2020. "Research on a Dynamic Algorithm for Cow Weighing Based on an SVM and Empirical Wavelet Transform" Sensors 20, no. 18: 5363. https://doi.org/10.3390/s20185363

APA Style

Feng, N., Kang, X., Han, H., Liu, G., Zhang, Y., & Mei, S. (2020). Research on a Dynamic Algorithm for Cow Weighing Based on an SVM and Empirical Wavelet Transform. Sensors, 20(18), 5363. https://doi.org/10.3390/s20185363

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop