1. Introduction
At present, precision livestock farming (PLF) research has attracted the attention of many researchers [
1]. The breeding of pigs in a noncontact, stress-free, and healthful manner has always been a research field that scholars worldwide have focused on [
2,
3,
4]. During the process of pig breeding, sows play an important role. By scientifically understanding sows’ oestrus state, one can determine the best mating times of sows and increase the overall embryo implantation rate. The oestrus period is the period in which a sow can accept a boar and achieve ovulation and conception. The oestrus cycle of a sow is composed of four periods: pre-oestrus, oestrus, late oestrus, and dioestrus periods. The average duration of oestrus is 21 days, but there are large individual differences between the phases. The oestrus behaviours of sows are cyclical and transient. When a sow exhibits oestrus behaviour, it needs to be bred in time; otherwise, the breeder will miss the optimal breeding time and must wait for another oestrus cycle. Empty sows lead to increased breeding costs and reduced production efficiency [
5,
6].
During sow production, oestrus detection is mostly conducted with the manual observation method and boar test method. During the oestrus period, the sow’s feed intake is reduced, its sensitivity to environmental changes increases, and the amount of activity in the pigpen increases [
7]. The current general observation method for checking sow emotions is to observe the reaction of the sow to a back pressure test (BPT) and any induced changes in the vulva. A back pressure reaction is one in which sow pigs in oestrus appear to stand still and their ears stand still when their backs are manually pressed on, when they are crawled over by boars, when their backs are hunched, and so on. At the same time, the sow’s vulva becomes red and swollen, and more mucus is excreted from it [
8]. The boar test method is used to observe whether a sow has a static reaction through direct contact between a boar and the sow or through the enclosure. This method is simple and convenient to perform but is time-consuming and labour-intensive.
At present, many scholars’ research has shown they have carried out related research on the automatic identification of the process of sow oestrus [
9]. Scolari et al. [
10] explored the changes in the temperatures of the vulvas and buttocks of sows before and after oestrus; the results showed that the temperature of each sow’s vulva increased significantly at the beginning of oestrus and decreased significantly before ovulation, while the temperature of the buttock surface did not change significantly. Sykes et al. [
11] found that the maximum and average temperatures of the vulva during the oestrus period of sows were higher than those during the oestrus cycle period, but there was no difference between the minimum values. Simões et al. [
12] found that the temperatures of the sow vulvas first increased and then decreased; the temperatures of the buttock surfaces were not significantly different. Altmann used a small accelerometer to detect sow activity and found that activity during the oestrus period was twice that of a sow that is not in heat [
13].
Bressers [
14] used accelerometers and set activity thresholds to detect oestrus in sows. The results showed that the acceleration change range of sows during the oestrus period was significantly higher than that of sows during the non-oestrus period. When the threshold was set to 10 m/s2, the amount of exercise detected by the sensor was 10 times higher than that during the non-oestrus period [
14]. Freson used infrared sensors to detect the oestrus of sows; the accuracy rate of the proposed method was 86%, the sensitivity of oestrus detection was 79%, and the specificity was 68% [
15]. Houwers et al. used sensors to automatically record the frequency of sows visiting boars, and the results showed that when the sows had never been in heat and entered the oestrus period, the frequency of boar visits gradually increased [
16]. Korthals counted the average length of sow visits. The statistical results showed that the length of sow visits obeyed the 92 s/d Poisson distribution. The sensitivity of heat detection was 76.4%, and the specificity was 80.3% [
17]. Therefore, it is feasible to predict the oestrus time of a sow through the frequency and duration of the sow’s visits to a boar.
With the development of neural networks, more researchers hope to use the autonomous learning capabilities of neural network models to automatically determine the characteristics of recognition behaviour. The advantage of automatically extracting features lies in the robustness and strong adaptability of this approach. In addition, during the learning process, features with higher degrees of discrimination can be automatically distinguished. However, when the resultant model is established, it is necessary not only to pursue accuracy but also to take the running speed of the model into account so that it can be effectively applied in practice.
There has been some development in the recognition of pig behaviour images. Several scholars have studied sow behaviour image recognition, video analysis, and sow behaviour tracking [
18,
19,
20,
21]. However, there are few reports on the detection of sow oestrus based on the ‘contact windows’ of machine-vision based bionic boars, and the current research has not been applied to sow oestrus detection and pig production.
Thus, the analysis of the behaviours of sows after weaning based on a ‘contact window’ model of a bionic boar using machine vision technology is herein proposed. This research method is intelligent, offers a non-stressful environment, guarantees sow welfare, and ensures biosafety during the detection process. The main contributions of this article are as follows:
- (1)
An information model was researched, developed, and built based on the ‘contact window’ of a bionic boar.
- (2)
The oestrus behaviours of sows were analysed based on machine vision recognition.
2. Materials and Methods
To detect the conditions of sows based on machine vision, in this study, a bionic boar detection model was built, which mainly includes an intelligent mobile platform, a bionic model device, an image acquisition device, and a PC processing terminal. Through simulation of the sound and smell of boars, and analysing the response behaviour of sows through machine-vision based imaging technology, a sow oestrus recognition model was established, and the oestrus times of sows can be accurately obtained.
2.1. Animals and Housing
To identify the oestrus behaviours of empty-breasted sows, this study was carried out at the pig farms of the Shandong and Chongqing Academy of Animal Husbandry (Rongchang, Chongqing, China) pig farms from July 2019 to December 2020. The test subjects were Yorkshire sows that already been weaned. The sows had 2–3 L. The feeding times were 10:00 a.m. and 4:00 p.m. The test tracked a total of 76 large white sows. The data collection platform included a computer, an intelligent mobile platform, an intelligent detection camera (LRCP106_1080P (Zhi fei, China)), and a bionic model device.
In this study, the experimental method mentioned that a total of 76 sows were observed. In other words, 68 sows were observed in the preliminary experiment. At the same time, 68 sows underwent the same experimental observation, the bionic boar, including sound and smell devices that simulate pigs. The actual verification results are based on conducting an inspection with the bionic boar and performing a simultaneous manual back pressing test (BPT) at the same time. A diagram of the test platform is shown in
Figure 1.
The intelligent mobile platform used in this article was the FBL80E3500_X linear actuator (FUYU, China), which can be used to set the speed, position, and time through a program compiled in the C programming language. The FBL80E3500_X is a synchronous belt-based linear module. It is a medium-sized closed linear module for synchronous belt transmission. The horizontal speed under a full load is 300–1700 mm/s, the positioning accuracy is 0.1 mm, the horizontal maximum load is 30 kg, and the maximum thrust is 55 N.
For the image acquisition device, the acquisition frequency was set to 30 fps, the resolution was 1280*720, and the collected sow images were transmitted to the PC processing terminal through a data line. A camera was arranged on the upper backside of the circle, and the PC processing terminal was an Intel Core i7 9th generation processor. The bionic model device, a built-in ultrasonic atomization device, was a YuWell (YW, China) NM211C miniature piezoelectric atomizer and it was used to simulate the release of odours from boars; the sound module, the external amplifier of a voice recording playback device, was a Sony ICD-TX650, with a noise reduction function and the advantages of a stereo microphone layout. To increase the authenticity of the bionic model, the front end of the device was designed with a silicone pig nose, and the ultrasonic atomization outlet was a silicone pig nose, which could effectively capture the interactions between a sow and a boar. MATLAB (MathWorks Inc of America.), Origin8.0 (OriginLab Microcal of America), LabVIEW (the Laboratory Virtual Instrument Engineering Workbench of America), and other software were used for image analysis.
2.2. Bionic Boar for Verifying the Principle
Studies have shown that the boar test method is often used during production to observe whether the sow’s nose and the boar’s nose will have a standing reaction after touching it. and then to determine whether the sow is in heat. Most chosen boars are middle-aged and old, with strong salivation abilities and docile temperaments. The boars used to provoke the sows should be alternated to avoid having the sows lose interest in a single boar. When arranging the situation, the routes of the boars are planned in advance, the staff are arranged to drive the boars, and fences/gates are set up to block the boars from escaping [
22]. At the same time, pressure is put on the back of the examined sow to observe whether the sow has a standing reaction; the knees of the boar are pushed against the sow’s udder, abdomen, and crotch to observe whether the sow is close to exhibiting a standing reaction. It is observed whether changes in the shape and colour of the sow’s vulva occur and whether the sow has frequent urination, irritability, arching, ear erections, body tremors, an inability to eat, and so forth. According to the above procedure for the identification of the sow’s oestrus, it is comprehensively judged whether the sow is in oestrus and the status is marked accordingly [
23,
24]. Although this process has a high accuracy rate, it is time-consuming and labour-intensive, and there is a certain degree of danger.
It is necessary for boars to be on-site when making love. The boars on pig farms can generally be divided into two categories according to their use: love-making boars and semen-providing boars. Both are essential parts of daily pig farm production. Love-making boars refer to a type of boar used for sex checking, sex induction, and assisted artificial insemination. These boars mainly rely on the smell of saliva to stimulate a sow’s physiological and psychological responses. These ‘odour molecules’ at work are boar pheromones [
25].
A boar can stimulate a sow with sight, touch, smell, and sound, the most important of which is smell. Pigs have a large number of olfactory receptors [
26]. When a boar appears in front of a sow in heat, the pheromones in the boar’s saliva stimulate the sow’s sexual behaviours, such as standing still, erecting its ears, arching its back, scraping the stall, and so on, within a short time period [
27]. After the sow in heat comes into contact with the boar, the pheromone molecules produced by the boar can be sensed through breathing and chewing. This explains why the boar needs to be in contact with the sow’s snout and nose for the processes of sex checking, sex induction, and traditional artificial insemination.
Building upon the above theoretical basis, we propose a technical route for research on bionic boar-based sow checking, in
Figure 2.
Firstly, according to the technical roadmap and the pheromone of the boar to detect the heat of the sow and at the same time to observe the degree of reaction of the sow. Then, by simulating sound and smell of boar and simulating the principle of contact window of boar, a bionic boar was constructed in the experiment. Finally, SOB, SOS, SOC, SO-SE, SOW and other behaviors were analyzed and recognized. Behavior detection can be used as the evaluation of the effect of bionic boars on sows in the estrus cycle. The bionic boar device developed in this study was mainly an intelligent detection device (consisting of a sound-releasing device, an odour-releasing device, an image acquisition device, and a bionic silicone pig nose). A scent device and sound player were installed on the intelligent detection device to check the oestrus of sows. The saliva, urine, semen, and so forth of a boar were contained in the scent release device, and these items were atomized and released through a miniature atomizer. The experimental results show that the combination of the saliva and voices of middle-aged boars leads to long-duration and high-frequency contact with sows. During the investigation, the weaned sow actively touched the detection device, contacted it frequently, had a long contact duration, stood still with both ears motionless, and so forth. These interactions were captured by the camera above the detection device and transmitted to the PC through the end of the accompanying data cable.
During the sow’s bionic boar check-up, the response degree of the sow and the bionic device was observed and recorded. In this study, a bionic boar was used to check up on sows for a period of three minutes per sow. Through the artificial BPT on the sow, observations were made regarding whether both ears of the sow were standing still, whether it had a hunched back, and whether the sow’s pubic area was red and swollen. At the same time, the sow’s response behaviour and frequency were recorded through image technology. The response relationship between the sow and the bionic boar was recorded and studied through video analysis.
2.3. Machine Vision Recognition of Oestrus Sow Behaviour in Response to a Bionic Boar
2.3.1. Pre-Processing of Video Image of Bionic Boar
To recognize the response behaviour of a sow in a complex environment, the collected video/image set needed to be pre-processed to reduce background interference and improve the contrast between the target sow and the background. In the home environments of pigs, sows cause imaging problems such as occlusion, complex lighting, and difficulty in capturing target images, and the collection of high-quality images requires computer processing hardware. In MATLAB, the avi2img.m program converted each video into a series of single pictures frame by frame. The grey_frame = rgb2grey(frame) statement was used to convert a colour image into a greyscale image. The contrast between the target sow and the background was improved by transforming the grey level. Establishing different action feature extractions through MATLAB can provide classification data labels for subsequent model classifications.
2.3.2. A Deep Belief Network (DBN) Model for Oestrus Behaviour Identification in Sows
A model is proposed based on bionic boar checking and sow response behaviour identification. Responsive sow behaviours include chewing on railings, standing still, touching the snout of the bionic boar, standing with both ears still, and swinging the head widely. Standing behaviour and contact with the bionic boar snout are the main characteristics that reflect the oestrus behaviour of a sow [
3]. By analysing the response behaviour characteristics of sows, a comprehensive evaluation of standing behaviour and combined contact with the snout and nose of the bionic boar is proposed.
Establishment of an Oestrus Behaviour Recognition Model for Sows
A deep belief network (DBN) was one of the first non-convolutional models to be successfully applied to deep architecture training. The basic unit of this network is the restricted Boltzmann machine (RBM) [
28]. Hinton et al. [
29] first used unsupervised pretraining to initialize the network parameters and then adjusted the network parameters through the backpropagation (BP) algorithm. DBNs are widely used in handwriting recognition, image recognition, speech recognition, and other fields [
29]. Compared with the traditional multilayer neural network, which is difficult to train, a DBN abstracts high-level features from the observed low-level features by applying a layer-by-layer greedy learning method to realize network training [
30,
31,
32].
DBNs are often trained using the contrastive divergence (CD) algorithm. Assuming that there are
explicit layer neurons and
hidden layer neurons in the network model, let
and
denote the state vectors of the explicit layer and the hidden layer, respectively. In the same layer, each unit satisfies an independent and identical distribution, and the following formulas can be obtained:
In the CD algorithm, the training samples are first assigned to the explicit layer
, and the score of the hidden layer neuron state is calculated according to Equation (2). The probability distribution is determined, and then sampling is performed according to this distribution to obtain
. Then,
is calculated from
according to Equation (1), and
and
are subsequently obtained. The update formula for the connection weight is as follows, where
is the update weight and
is the learning rate.
In image processing, pixels are used as visible layer units to deactivate hidden layer units with a certain probability. By running the divergence algorithm, the network model is trained layer by layer to obtain the weight matrix and offset of the visible unit and the hidden unit of each layer. Finally, according to the weight matrix and offset of each layer, it is judged whether the hidden unit is activated. The distribution of the hidden unit is the abstracted high-level feature.
A Sparse Autoencoder (SAE) Model for Female Oestrous Behaviour Recognition
Sparse autoencoder (SAE) neural network technology is an efficient unsupervised feature learning and deep learning classification method. Since it was first proposed, the SAE technology has been widely used in various classification and pattern recognition problems [
33]. An SAE neural network classifier includes multiple training layers, and the training output result of the previous training layer is the training input value for the next training layer. The detection process of the SAE neural network classifier described in this section first involves initializing the parameters; then, feedforward conduction is used to train the neural network; finally, a reverse conduction fine-tuning process is used to determine the minimal cost function with the globally optimal parameters, and a collapsed-lane deviation detection classifier is obtained. The SAE neural network integrates all the advantages of a deep neural network and has a strong expression ability.
A stacked autoencoder neural network is composed of multiple layers of sparse autoencoders, and its training process adopts a layer-by-layer greedy training method. The layer-by-layer greedy training method uses the output of the previous layer of an autoencoder as the input of the next layer of the autoencoder to train the network layer by layer in order from front to back. During each step, the first k-11 layers that have been trained are fixed, and then layer k is added; that is, the output of layer k-1 (which has been trained) is the input of layer k to be trained. The feature input set of the stacked autoencoder neural network is called the input layer, the classification result set is called the output layer, and all the layers between the input layer and the output layer are called hidden layers.
Unlike other neural networks, a single-layer SAE is an unsupervised learning algorithm that does not require the training samples to be calibrated. The overall network performance of the single-layer SAE can be obtained via Equation (4):
Among the parameters, are used to fit the data of the original input , and is the bias node, also called the intercept. is the number of feature inputs, and is the weight attenuation coefficient, which is used to control the relative importance of the first mean squared error term and the second weight attenuation term to prevent overfitting. is the data weight value from the -th unit of the -th layer to the -th unit of layer . represents the number of neurons in each hidden layer, β is the weight of the sparsity penalty term, is the introduced sparsity parameter, and is the average value of the input activations of hidden neuron j. is the relative entropy between a Bernoulli random variable with a mean of and a Bernoulli random variable with a mean of (obtained by measuring the difference between the two distributions) is a regularization term, and is the cost function of the model.
Support Vector Machine (SVM) Model for Sow Oestrus Identification
The support vector machine (SVM) method is a machine learning classification algorithm based on statistical learning. It is based on the principle of achieving the minimum structural risk, and it was first proposed by Vapnik et al. [
34]. Its basic model is a linear classifier with the largest interval in a given feature space. With its solid theoretical foundation and accuracy, the SVM is widely used in text classification and face recognition tasks. In the field of text classification, compared with traditional methods, the SVM approach not only has better robustness but also achieves good results when dealing with high dimensionality [
35].
The learning strategy of an SVM is to maximize the category interval, that is, to find the hyperplane with the largest interval in a given feature sample space. This hyperplane separates the two compared types of data and maximizes the geometric interval; this can be approximately understood as a convex quadratic programming problem. The purpose of an SVM is to determine the separation hyperplane that can divide the dataset correctly and obtain the largest set interval. The equation for dividing the hyperplane is shown in Equation (5).
The separation hyperplane is determined by the normal vector
and the intercept
, which needs to be obtained through training with the sample data. Assuming that the linearly separable training set
represents a feature vector in the training set,
is used to input the classification of
(6):
The distance between a sample point in the space vector and the hyperplane is denoted as
, which can be expressed as follows (7):
Among the variables,
. The objective function and constraint conditions of an SVM are as follows (8):
SVMs are widely used. In addition to text classification, they have also been applied to speech recognition and face recognition tasks, and they have achieved satisfactory results. However, SVMs and other algorithms also have some shortcomings. In cases with small data volumes, the SVM is based on the strategy of minimizing structural risk, and thus, its generalization ability is better. The time required for learning and training in an SVM is longer than for other algorithms.