Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
Embedded Imaging System Based Behavior Analysis of Dairy Cow
Dr. Samuel Manoharan,
Professor,
Department of Electronics,
Bharathiyar College of Engineering and Technology,
India.
Email:
[email protected]Abstract: It is essential to develop ambient environmental conditions for counteracting the heat stress in dairy cows by
efficient and reliable monitoring of the activities of the cow and existing environmental conditions. For this purpose, we present
a system with an array of integrated sensor modules that continuously measure and record humidity and ambient temperature
while simultaneously monitoring the dairy cows drinking behavior using a cost-efficient embedded imaging system. Video
streams are collected by installing embedded imaging modules over the drinking troughs for testing and experimentation in
the dairy farm. Convolutional neural network (CNN) model using deep learning techniques is used for analysis of the video
stream by detection of the head of the dairy cow above the drinking trough. The values obtained as true positive rate and F1
score of the detection of the head of the cow are both 0.98. The dairy cows drinking behavior and the effect of heat stress is
analyzed and recorded for varied environmental conditions over a period of twelve months. Based on the results of analysis,
it is evident that the temperature and humidity index (THI) greatly influence the total frequency and length of everyday
drinking habits of dairy cows. The drinking behavior of dairy cows and the effects of heat stress is demonstrated clearly using
the automated imaging system with long-term monitoring and data collection. Quantitative assessment and automation are
possible using this novel monitoring system to be implemented in dairy farms.
Keywords: Imaging sensor node; Object detection; THI; Deep Learning; Image Processing;
1. Introduction
Dairy cows are afflicted largely due to the adverse effects of heat stress in subtropical regions, which is
a prominent challenge in dairy farm management [1]. Heat stress has adverse effects on the dairy cows,
which is difficult to manage and handle especially in the subtropical regions. Lameness, mastitis and
such diseases, low fertility, reduced milk yield and so on are the common effects of heat stress in
lactating cows [2]. Wind speed, solar radiation, humidity, temperature and such environmental and
external factors that cause heat stress and displacement of the body temperature of the animal. The
reduction in yield of milk, sweating, panting, increase in the rate of respiration are some of the
physiological responses to overcome heat stress by dairy cows. Modification in feed intake and drinking
patterns, decreased movement and activity, increased shade seeking and standing time are some of the
behavioral responses for heat stress by dairy cows [3].
148
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
For estimation of the heat stress effects on dairy cows, a common factor of estimation called temperature
and humidity index (THI) is used [4]. The effects of humidity and the environmental temperature are
calculated and indexed with the THI. This factor is used extensively for observation, experimentation
and analysis of the behavior of dairy cows under heat stress. For reduction of heat stress, the dairy barn
management can be performed by environmental control for managing the internal body temperature
of the dairy cow based on the THI indicator [5]. Comparison and evaluation of environmental control
strategies and application of sprinkling, evaporative cooling and forced ventilation can be performed
based on the THI factor. Assessment of animal welfare and heat stress can be overcome by proper
investigation and assessment of heat stress and animal welfare as well as behavioral indicators like
locomotive behavior, lying, drinking and feeding. Video recording and direct observation has been done
traditionally by assessment of behavior of the dairy cow [6].
It is a time consuming and intensive process for measurement of dairy cow behavior. However, with
the increasing technological advancements, it is more feasible to monitor the animal behavior with
automated systems [7]. Wearable sensors, sound and image analysis sensors can be used in the
automation devices for automatic collection of behavioral data of the dairy farm activities. The dairy
cow behavior can be observed and analyzed using several automated systems as seen in various
literatures [8]. Certain researchers have observed the lactating dairy cow feeding behavior using video
recording of time-lapsed format. Wearable ear tag sensors are used in certain research work for
monitoring the ruminating, standing and grazing behavior of cattle [9]. The drinking behavior of
lactating dairy cows are observed with radio frequency identification sensors attached to the collar of
the cow by certain researchers. Maintenance of these processes require human intervention of the farm
personnel making the techniques cumbersome [10]. This paper proposes implementation of machine
vision for efficient and non-contact technique for observation of animal behavior.
2. Materials and methods
2.1 Design of environmental sensor module and integrated imaging
Monitoring and analysis of the drinking behavior can be performed by integrating the environmental
sensor and imaging modules in the imaging system. This general-purpose system helps in long-term
observations of the cattle and can be installed easily in the dairy farm above the drinking troughs [11].
A central processing unit - Raspberry Pi 3B, environmental data collection module - humidity and
temperature sensor MBE280 and Raspberry Pi V2 camera module are the major components of the
embedded sensor module. Data transmission and wireless imaging, dairy cow detection through on-
board image processing, sensor interfacing and acquisition of video stream is performed using an
embedded single-board computer using ARM Cortex called Raspberry Pi. An RGB camera with 8-
megapixel high resolution and fixed focus, Raspberry Pi V2 Camera is used for observing the cattle.
The camera lens is protected with an acrylic cover that is dust-proof, transparent and replaceable [12].
Gathering of environmental information is done by means of the humidity and temperature sensor.
Further, the embedded system calculates the THI value. Animal husbandry makes use of THI for
experimentation and analysis as well as estimation of the thermal stress degree of livestock like dairy
149
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
cows [13]. The NRC 1971 based THI is implemented in this research work. The calculation of THI is
performed using the following formula:
THI= (1.8 x T +32) – [(0.55-0.0055 x RH) x (18 x T -26.8)] ---- (1)
Where the percentage of relative humidity is given by PH and the dry bulb temperature in degree Celsius
is given by T. The environmental sensor module and integrated imaging specification are chosen based
on the size of the farm and the feature requirements [14]. The image monitoring system network
architecture, design and components of the sensor module are represented in the schematic shown in
Figure 1.
Figure 1: Design and integration of sensor module, components and network architecture
A Wi-Fi Sensor network is formed by linking the integrated sensor modules. Internet can be accessed
by a wireless router connected to the remote server that receiver’s information transmitted in the form
of data and images by each sensor node in the network. Addition of extra sensor modules is also possible
in the network as required. The sensor nodes receive the environmental information for every five
minutes. A median filter is used for preprocessing the readings of relative humidity and environmental
temperature in order to remove the fluctuations and noise. Calculation of THI is performed on board
and information transmission to the remote server takes place. A remote server is used for storing the
transmitted environmental and image data in a MySQL database.
The server performs the data analysis and a website is used for making the results readily available for
the users as represented in Figure 1. Graphical representation is used in the website for displaying the
dairy barn’s environmental conditions and the cattle drinking frequency and length. Easy visualization
of the THI levels and drinking behavior and their relationship is made available. Tiny YOLOv3 deep
learning CNN model is used for detection of the dairy cow head. This approach is a modern object
detection technique for feature-based image processing and offers several advantages when compared
to the traditional techniques [15]. The probabilities and bounding boxes of every region is predicted by
150
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
the Tiny YOLOv3 model algorithm on dividing the images into several regions. The predicted
probabilities are used for weighing the bounding boxes. For special separation of associated class
probabilities and the bounding boxes, the major regression problem is detection of the object. Before
transmission of results to the server, the described data and image processing techniques are carried out
on board.
3. Results and Discussion
Figure 2: Data Analysis for a period of one year and distribution of the drinking data
From January to December 2019, the experimentation is carried out for a period of one year on a
continuous basis. This enables covering all the seasons for comparing the drinking behavior and effects
of heat stress on dairy cows for various environmental conditions. The fans in the dairy is turned on for
a duration of 24 hours in the hot season by the farm staff and in the cold season, it is turned off. Based
on the level of THI, the sprinklers are turned on and off. All this information is also made available in
the website. In case of an open-sided farm, the dairy cows can feel the seasonal effects as well. The
frequency and length of the drinking characteristics are detected and recorded continuously by the
image system. Group drinking behavior is reflected by the accumulated data as individual identification
of the dairy cows is not performed.
During the training phase, the hyperparameters are tuned carefully for the detection of dairy cow head
using the Tiny YOLOv3 model for obtaining optimal performance. After over 2000 iterations, quick
convergence of the validation map is performed and over 23,000 iterations cause 0.2 average converged
loss based on the experimental results. At these iterations, selection of optimized weights is done and
the model is converged. Visualization is done with heat map in classification networks for decision
151
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
process and debugging using the Class activation maps (CAM). From the last layer of convolution, the
output images are taken and multiplied with the weights assigned to them and summed for creation of
the heat map for a class. Figure 2 represents the data Analysis for a period of one year and distribution
of the drinking data and Figure 3 represents the histogram of the drinking length.
Figure 3: Analysis of data the year 2019 and histogram of the drinking length
The monitoring system’s overall performance is affected by the dairy cow head detection accuracy in
the image frame. Training with the Tiny YOLOv3 model can be used for creation of a confusion matrix
for the detection of the cow head. A 0.98 F1 score is obtained on implementation of the algorithm for
average detection of the dairy cow head. This value is compared with the manual count for validation
of the information and quantitative analysis. Experiments are conducted for a period of one year and
the median frequency of drinking every day is 2.5 and the median duration of drinking is 1.5 min. Based
on the experimental results, it is observed that there is a seasonal change in the drinking habits and
frequency of the dairy cows. The drinking frequency during the cold season is lesser than that in the hot
season. The THI and average drinking length is compared to establish an exponential relationship of
the range 65 to 90 which is similar to the regression of linear relationship. The detection accuracy is not
affected by the varying lighting conditions of the proposed system. Figure 4 represents the average
histogram of the drinking length for one year on a monthly basis. Around 10% relative absolute error
is obtained on implementation of the system.
152
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
3
2.5 2.7
Average Drinking Length (min) 2.5
2.3
2 2.2
2.1
2 2
1.9
1.8
1.5 1.7
1.6
1.5
0.5
0
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Month
Figure 4: Monthly drinking length average histogram for one year in 2019
5. Conclusion
Successful assessment of the dairy cows group drinking behavior is performed based on the effects of
heat stress using embedded imaging system in this paper. A 0.98 F1 score is obtained on implementation
of the algorithm for average detection of the dairy cow head. This value is compared with the manual
count for validation of the information and quantitative analysis. Experiments are conducted for a period
of one year and the median frequency of drinking every day is 2.5 and the median duration of drinking
is 1.5 min. Based on the experimental results, it is observed that there is a seasonal change in the
drinking habits and frequency of the dairy cows. The drinking frequency during the cold season is lesser
than that in the hot season. The THI and average drinking length is compared to establish an exponential
relationship of the range 65 to 90 which is similar to the regression of linear relationship. These results
verify the environmental condition-based hypothesis that deals with the dairy cow drinking frequency
and drinking length for management of dairy farm and heat stress alert indication. Heat stress largely
affects the milk production and hence prediction can be done for the production in an efficient manner
by using the indicators like drinking frequency and length. Based on the results of this analysis, the
health of the dairy cows can be improved by efficient placement and refilling of the drinking troughs
by the farm staffs so as to manage the farm. Easy implementation of the proposed model in real time
applications can be performed by data analysis coherence and performance detection.
References
[1] Darr, M., & Epperson, W. (2009). Embedded sensor technology for real time determination
of animal lying time. Computers and Electronics in Agriculture, 66(1), 106-111.
[2] Shi, C., Teng, G., & Li, Z. (2016). An approach of pig weight estimation using binocular
stereo system based on LabVIEW. Computers and Electronics in Agriculture, 129, 37-43.
[3] Mattachini, G., Riva, E., & Provolo, G. (2011). The lying and standing activity indices of
dairy cows in free-stall housing. Applied Animal Behaviour Science, 129(1), 18-27.
153
ISSN: 2582-3825 (online)
Journal of Electronics and Informatics (2020)
Vol.02/ No. 02
Pages: 148-154
http://www.irojournals.com/iroei/
DOI: https://doi.org/10.36548/jei.2020.2.006
[4] Leccese, F., Cagnetti, M., Calogero, A., Trinca, D., Pasquale, S. D., Giarnetti, S., &
Cozzella, L. (2014). A new acquisition and imaging system for environmental
measurements: An experience on the Italian cultural heritage. Sensors, 14(5), 9290-9312.
[5] Saint‐Dizier, M., & Chastant‐Maillard, S. (2012). Towards an automated detection of
oestrus in dairy cattle. Reproduction in domestic animals, 47(6), 1056-1061.
[6] Chizzotti, M. L., Machado, F. S., Valente, E. E. L., Pereira, L. G. R., Campos, M. M.,
Tomich, T. R., ... & Ribas, M. N. (2015). Validation of a system for monitoring individual
feeding behavior and individual feed intake in dairy cattle. Journal of dairy science, 98(5),
3438-3442.
[7] Xing, J., Saeys, W., & De Baerdemaeker, J. (2007). Combination of chemometric tools and
image processing for bruise detection on apples. Computers and electronics in agriculture,
56(1), 1-13.
[8] Dutta, R., Smith, D., Rawnsley, R., Bishop-Hurley, G., Hills, J., Timms, G., & Henry, D.
(2015). Dynamic cattle behavioural classification using supervised ensemble classifiers.
Computers and Electronics in Agriculture, 111, 18-28.
[9] Jayashree, S. and D. A. Janeera. “Real-Time Fire Detection, Alerting and Suppression
System using Live Video Surveillance.” (2016).
[10] Miron, J., Zuckerman, E., Adin, G., Solomon, R., Shoshani, E., Nikbachat, M., ... &
Halachmi, I. (2007). Comparison of two forage sorghum varieties with corn and the effect
of feeding their silages on eating behavior and lactation performance of dairy cows. Animal
Feed Science and Technology, 139(1-2), 23-39.
[11] Hudson, C., Kaler, J., & Down, P. (2018). Using big data in cattle practice. In Practice,
40(9), 396-410.
[12] Ruth Anita Shirley D, Ranjani K, Gokulalakshmi Arunachalam, Janeera D.A., "Distributed
Gardening System Using Object Recognition and Visual Servoing" In International
Conference on Inventive Communication and Computational Technologies [ICICCT
2020], Springer, India, 2020
[13] Van De Gucht, T., Saeys, W., Van Nuffel, A., Pluym, L., Piccart, K., Lauwers, L., ... &
Van Weyenberg, S. (2017). Farmers' preferences for automatic lameness-detection systems
in dairy cattle. Journal of dairy science, 100(7), 5746-5757.
[14] Guzhva, O. (2018). Computer vision algorithms as a modern tool for behavioural analysis
in dairy cattle (Vol. 2018, No. 33).
[15] Chen, J. I. Z., & Chang, J. T. (2020). Applying a 6-axis Mechanical Arm Combine with
Computer Vision to the Research of Object Recognition in Plane Inspection. Journal of
Artificial Intelligence, 2(02), 77-99.
Authors Biography
Dr. Samuel Manoharan, is currently work as professor in the Department of Electronics, at Bharathiyar
College of Engineering and Technology, India. His major area of research are Power electronics, Solid-
state electronics, Quantum electronic systems and devices, VLSI, Analog and Digital Circuits, and
Microwave circuits, social informatics, medical informatics, healthcare informatics, Deep Learning,
Convolutional Neural Networks and cybernetics.
154
ISSN: 2582-3825 (online)