1. Introduction
Eggs are one of the best sources of nutrition for human beings and are known as the best protein food. To ensure the quality of eggs, cracked eggs produced in packaging, processing, transportation, and other links should be eliminated. Cracks in eggs will not only lead to a reduction of freshness but also breed bacteria and do harm to health [
1,
2]. The quality and safety of eggs is a matter of concern to the public, so the detection of egg cracks is a necessary operation before the eggs enter the market for consumption. Manual detection is high-cost, low-efficiency, and depends on detection experience. After a long period of operation, the probability of missing cracks and false detection increases due to visual fatigue. This can also cause some damage to the operators’ vision [
3]. With the continuous development of industrialization and informatization, people are trying to find an automatic detection method to reduce the labor intensity of this task while simultaneously improving efficiency and accuracy.
Numerous techniques for egg crack detection have been put forth by researchers and academics, of which acoustic [
4,
5,
6,
7] and visual [
8,
9,
10,
11] methods are the most well-known and established. Crack detection based on acoustic characteristics is realized by collecting knock response signals with sound sensors after mechanical excitation on several parts of the egg surface, analyzing and processing the signal differences between the intact area and the cracked area of the egg surface, and finally extracting characteristic parameters. However, its accuracy easily suffers from interference by eggshell thickness, external noise, and the knock location. The detection of cracks in poultry eggs based on visual characteristics involves taking pictures of the surface of poultry eggs with an industrial camera and transmitting the images to supporting software. By analyzing the images, the software can identify the characteristics of cracked and intact eggs and then construct a model for discrimination. Nevertheless, many simple factors must be considered in practice, such as the camera’s resolution, the recognition algorithm, and the shape of the egg crack. Additionally, the online detection speed and accuracy for microcracks cannot meet today’s requirements. Hence, significant limitations remain on industrial sites.
The detection method based on high-voltage discharge has a good ability to detect leakage. Hu [
12] proposed a “conductivity method” for ampoule bottle detection, applying a 3000 V∼5000 V direct current(DC) on the tested drug bottle and judging the leakage of the test sample by setting the threshold value of the measured current. Yan et al. [
13] used 20 kHz of high voltage to carry out their experiment and finally verified the feasibility of high-voltage discharge for the detection of small leaks of large infusion plastic bottles. The micro-current high-voltage discharge method is similar to the traditional high-voltage discharge method. It requires that the package itself is not conductive and the contents are conductive, creating a difference between the electrical parameters of a defect-free package and a defective package. The micro-current high-voltage discharge method can also be used to detect tiny cracks or damages to sealed packaging in the food industry. With the further deepening of the basic theoretical research on the dielectric properties of eggs, egg crack detection based on electrical properties will become our research direction.
Recent research shows that detecting cracked eggs using the response model of egg electrical characteristics can effectively compensate for the shortcomings of the above methods [
14].
Figure 1 illustrates how the electrical characteristic model can be used to detect egg cracks. The capacitors include the two electrodes and the egg in the center, and the eggshell is the insulator. Due to its low resistance value, the egg liquid is approximately the conductor. The current value detected is either a capacitance jump, a breakdown, or a combination of both. When the egg is intact, the whole system is in equilibrium, and the current value will remain stable. When the egg has a crack, the electrical characteristic model will change when the electrode passes through the crack, resulting in a transient current. Therefore, if the voltage of the two electrodes is kept constant and only the breakdown of the air medium is allowed, it is possible to identify cracked eggs based on the change in the current signal. Traditional machine learning methods have been used to classify the current signals, and the accuracy of detecting eggs with microcracks less than 3 µm compared to intact eggs was found to be
. Relevant experiments also prove that the proposed method has a certain universality and versatility. However, it has three shortcomings. In terms of the experimental device, the electrode position is fixed, which can easily cause the egg size to not fit with the upper electrode, thus causing errors in detection. In signal analysis, the extracted features are inadequate to allow capturing the details and changes of cracked eggs in the current signal, so further study of the feature extraction method of the current signal is necessary. A further area of research is how to reduce the 1500 V voltage used in the experiments because it is too high and might harm the unhatched eggs.
Therefore, this research aimed to propose an accurate and effective nondestructive method based on the electrical characteristics of eggs to detect cracks in poultry eggs in the industrial field on the basis of existing experiments [
14]. The main objectives of the study are as follows:
To modify the experimental device so that the electrode fits the egg to avoid missed or wrong detection due to data acquisition;
To adjust the analysis algorithm, to analyze the characteristics of the microcurrent signal, and to design a feature extraction and classification algorithm that is effective for the current signal;
To investigate how to reduce the voltage while maintaining detection accuracy and reducing the damage caused by high voltage to unhatched eggs.
Employing wavelet scattering transform, Jinghui Li et al. [
15] stratified and dispersed the information of a heart sound signal to each layer so that the information would not be lost and maintained the stability of signal features, which effectively expressed the corresponding characteristic information of the signal. Then they obtained the characteristic matrix of the signal, which was input into a double support-vector machine for classification, yielding excellent results. Ahmad A. Al-Taee et al. [
16] used deep wavelet scattering transform as a feature extraction method for electromyographic signals and compared it with other wavelet methods, significantly improving the performance of electromyographic pattern recognition. Liu Hui et al. [
17] adopted a wavelet scattering network to extract the features of the fault zero sequence current signal. Academics have found that wavelet scattering transform can extract both simple and complex characteristics from low-frequency and high-frequency signals, respectively, and thus can reduce intra-class differences to the greatest extent while preserving inter-class differentiation. The fault feature vector is input into bi-directional LSTM, which has the advantages of high identification accuracy and short training time compared with the fault identification methods in other literature. In addition, wavelet scattering convolutional neural networks have been widely used in sound, image, and time series fields due to their superior performance and perfect mathematical properties, and some achievements have been made [
18,
19,
20,
21]. To our knowledge, no researchers have applied appropriate research methods and ideas to detect microcurrent signals in eggs.
In recent years, deep learning has been rapidly developed. Because of its advantages of automatic feature extraction, ability to process unstructured data, and high accuracy, it has been widely used and studied in industrial defect detection. Yu et al. [
22] combined convolutional neural networks(CNN), migration learning, and decision-level images to propose a vision-based automatic recognition method for the identification of the surface condition of concrete structures and designed an improved Dempster–Shafer (D-S) algorithm, which greatly improved the recognition accuracy of concrete structures. Yu et al. [
23] used the improved bird swarm algorithm to optimize a 2DCNN, which performed better than other machine learning models in the evaluation of the torsional capacity of reinforced concrete (RC) beams. Deep learning has also shown strong performance in the processing of one-dimensional(1D) data. Hu et al. [
24] designed a fault diagnosis method based on a one-dimensional convolutional neural network (1DCNN) and L2-support-vector machine(L2-SVM) for unbalanced data, which, compared with other intelligent methods, significantly improved the recognition accuracy and diagnostic performance of the model compared with other intelligent methods in processing unbalanced data. Le et al. [
25] developed a 1DCNN for automated fault diagnosis, which can autonomously learn damage-sensitive features without pre-processing and can accurately diagnose potential faults that damage the smart chain. Relevant research [
26,
27,
28] also shows that deep learning exhibits good performance in processing time series classifications.
Therefore, this study focuses on applying wavelet scattering on poultry eggs based on real-time electrical characteristics. The main innovations and contributions of this research can be summarized as follows:
In order to solve the problem of missing detection caused by the lack of fit between the egg and the electrode due to the fixed position of the upper electrode, we improved the micro-crack detection system based on discharge analysis. We added a size identification device so that the upper electrode position can be automatically moved and fitted according to the size of the egg.
Given the problem that the extracted features are inadequate to capture the details and changes in a cracked egg in the current signal, we applied the wavelet scattering transform to obtain the features of the micro-current signal. Using deep learning methods, we classified the features extracted and attained satisfactory results with local translation invariance and elastic deformation stability.
The proposed and existing methods’ effects were compared and analyzed. The class-imbalanced dataset and duck egg dataset were used to verify the versatility and effectiveness of the proposed method. Finally, the experiments with different voltage effects were conducted to verify that the proposed method can obtain higher accuracy on data with a low signal-to-noise ratio while reducing the sensing voltage and further reducing the risk of damage to unhatched eggs caused by high voltages.
The remaining chapters are organized as follows.
Section 2 introduces the deployment of experimental equipment and the method of microcurrent signal analysis. In
Section 3, we compare and analyze the experimental results to verify the effectiveness of the proposed method. Finally, the whole paper is summarized and the future research on egg crack detection is prospected in
Section 4.
2. Materials and Methods
2.1. Egg Electrical Characteristic Crack Detection System
In this study, a crack detection system for poultry eggs based on real-time electrical characteristics was developed. As shown in
Figure 2a, the system is mainly composed of four parts: a data acquisition platform, a high-voltage power supply, a controller, and a computer processing system. The data acquisition platform includes a visual detection part and a discharge detection part. The visual detection part is used to detect the size of eggs and control the automatic electrode adjustment mechanism. The discharge detection part comprises a rotating mechanism, a discharge electrode, an automatic electrode regulating mechanism, etc. The rotating mechanism ensures that eggs of different sizes can rotate flexibly and uniformly. The automatic electrode regulating mechanism adjusts up and down according to the data from the visual detection part to provide stable and reliable surface contact, as shown in
Figure 2b. Through preliminary experiments and debugging, conductive silica gel was used as the electrode material for crack detection under a voltage of 1000 V, average humidity of 40%, and an average temperature of 18.5 °C. In this experiment, the current value is strictly controlled, and the automatic protection mechanism is triggered when the current exceeds 1 mA so that no damage will be caused to the eggs. In this study, the microcurrent signal obtained from an egg under the electrical characteristic crack detection system was used to evaluate and detect egg cracks. The detection and collection frequency of the detection system was set at 100 Hz, the collection time was 4.5 s, and the data length was 450 points. The data of egg rotation were collected 2.5 times in a single time, and one datum was collected for each egg.
After the eggs are subjected to the application of a DC voltage, the data acquisition card acquires the micro-current signal from 450 sample points on the eggs. Three representative egg samples are selected for analysis, as shown in
Figure 3a–c, which are examples of cracked egg samples, minimally cracked egg samples, and intact egg samples, respectively.
Figure 3d shows a micro-current detection signal of the cracked egg sample in
Figure 3a. When the electrode is swept to the crack location, a strong current response is generated, and the sample shows a sudden rise in a steady microcurrent signal.
Figure 3f shows the microcurrent detection signal of the intact egg sample, which does not produce a strong current reaction under DC voltage. There is no special change in the whole rotation process, and the sample is very stable. The existing classification algorithm based on the electrical characteristic signals of eggs can have a good classification effect on the above samples. However, for some extremely tiny cracks, such as thsoe in
Figure 3c, a microcurrent signal is used, as shown in
Figure 3e. The strong current response is small, and the performance is similar to that of intact egg samples. Currently, the existing classification algorithms based on the electrical signal characteristics of eggs struggle to distinguish those extremely small cracks.
In order to verify the accuracy of the results, each experiment was executed multiple times. In each experiment, the training set and test set used by different methods remained the same. We randomly selected 70% of the sample data as the training set and the remaining 30% as the testing set for scattering feature extraction and then input these data to the deep learning network for classification for different experiments.
2.2. Detection Framework
The framework of the current crack detection algorithm based on the egg electrical characteristics model is shown in part A of
Figure 4. The time, frequency, and wavelet domain features were manually extracted, and the traditional machine learning algorithm was used for classification [
14]. The features extracted by such methods are fixed, making it challenging to capture multi-scale features and, therefore, easy to overlook feature variations in detail. At the same time, traditional machine learning algorithms have low compatibility with feature dimensions and high dependence on features, leading to limitations in classification. Considering this situation, this paper investigates the feature extraction and classification of current signals separately, using wavelet scattering transform in conjunction with deep learning methods for experiments. Part Proposed of
Figure 4 illustrates the algorithm framework based on the wavelet scattering convolution network used in this paper. In the feature extraction part, we used the wavelet scattering transform to extract the features of the current signal, which has the properties and advantages of translation invariance and local deformation stability and does not require a manual design to extract features from the signal. It is immune to translational and slight deformation information and discards the parts of the signal sensitive to translation and deformation while obtaining high-frequency information. The classification part was analyzed using deep learning methods, which have the advantages of high learning ability, portability, and compatibility with feature dimensions compared to traditional methods. In this paper, we tried different deep-learning methods to study the algorithms that can be used for the classification of microcurrent signals.
2.2.1. Wavelet Scattering Transform-Based Feature Extraction
Wavelet scattering transform (WST) [
29,
30,
31] is an improved time-frequency analysis method based on wavelet transform, which solves the shortcomings of wavelet transform changing with time and has the advantages of translation invariance and local deformation stability of signal analysis and feature extraction. The wavelet scattering network is a framework for automatically extracting input signal features, requiring convolutional, nonlinear, and average cascade operations. After constructing the wavelet scattering network, the scattering coefficient matrix of training data can be obtained. The framework is shown in
Figure 5a. In the wavelet scattering transform network, the convolution task is performed by the wavelet, the modular operator is used for nonlinearization, and the filtering function of the wavelet low-pass filter completes the pooling task.
Wavelet scattering takes the modulus of the wavelet transform, mainly because the mean value of the wavelet coefficient is 0. In contrast, the mean value of linear transformation will not change, so the non-0 wavelet coefficient can be obtained through nonlinear transformation to carry specific information. After removing the complex phase of all wavelet scattering coefficients, operator
can be obtained. By convolving with input signal
X, the operator of the wavelet modulus transformation can be obtained:
Equation (
1) contains two parts:
(see Equation (
2), where
is the low-pass filter) is the invariant part, namely the scattering coefficient, which is the low-pass filtering and averaging of the input signal. It represents the translation invariance of the wavelet scattering transform, with the purpose of extracting the low-frequency information of the input signal and removing the high-frequency information.
(see Equation (
3), where
is high frequency wavelet) is the covariant part, representing the high frequency information on scale
and acting as the exchange modulus of the nonlinear wavelet change. It is also the input to the next transformation and represents the stability of the operator, with the purpose of recovering the high-frequency information lost by the operation of the invariant part.
Therefore, the 0th-order wavelet scattering transform information is:
By taking the 0th-order high-frequency
as the input
of the first-order scattering transform and calculating with the new wavelet modulus operator, the information of the 1st-order wavelet scattering transform is obtained.
Similarly, by iterating the above process, the
-order high-frequency
can be used as the input
of the first-order scattering transform to operate with the new wavelet modulus operator for the higher
g-order scattering transform:
The structure of the scattering transformation is shown in
Figure 5b. Input current signals are iterated successively in layers, forming a series of scattering coefficients from order 0 to order
g:
The scattering coefficient is the extracted micro-current wavelet scattering feature. After collecting the microcurrent signal of the egg, the wavelet scattering network is constructed to extract the wavelet scattering characteristics of the microcurrent signal, and a wavelet time scattering network with two cascaded filter banks is constructed. The first filter bank has eight wavelets per octave, the second filter bank has one wavelet per octave, the wavelet filter in the two filter banks is shown in
Figure 6a,b, and the Littlewood–Paley sums of the filter banks are shown in
Figure 6c.
Figure 6d shows the Gabor small wave used for its low-pass filter to prove the invariance scale, obtain the inverse Fourier transform of the scale function, and center it in 0 s.
2.2.2. Classification Modeling Methods
Compared with traditional machine learning methods, deeper networks can accommodate richer semantic information and are more effective in processing temporal order, feature dimensionality, and scale. LSTM can effectively capture the association between long sequences, which is very effective in processing temporal information and can also alleviate the phenomena of gradient disappearance or explosion. Bi-LSTM is a combination of forward LSTM and backward LSTM, which can effectively use the input forward and backward feature information. GRU can effectively capture the association of long sequences, and the number of parameters used is small, which can also reduce the risk of overfitting. 1DCNN features scale shifts and invariance, region awareness, comprehensive feature learning, and fault tolerance, which can compensate for the shortcomings of other shallow classification algorithms with inadequate feature learning and poor generalization ability.
The data used in this paper are characterized by disorder, mutation, nonlinearity, and time discontinuity. Therefore, in this study, LSTM, Bi-LSTM, GRU, and 1DCNN were used to classify the features extracted from wavelet scattering. The details of these methods are as follows.
Long short-term memory (LSTM) [
32] is a particular recurrent neural network (RNN), which is an improved neural network used to solve the problems of gradient disappearance and gradient explosion inherent to traditional RNNs in long sequence samples. The neural unit of LSTM contains three different gate structures: forgetting gates, input gates, and output gates to control information. Its appearance successfully solves the problem that the original RNN cannot store information for a long time and can effectively reduce the feature input dimension of the signal and enhance the temporal modeling capability.
Bi-directional long short-term memory (Bi-LSTM) [
33] is a variant of LSTM, which refers to the combination of forward LSTM and reverse LSTM. The forward and reverse layers are simultaneously connected to the input and output layers through different weights. There is input each time, while the hidden layer has two node vectors, which can be transmitted from forward to backward or backward to forward. The state transmission is bidirectional. It can learn not only the rule of forward data but also the rule of backward data. Applying LSTM twice can improve the long-term dependence on learning and thus improve the model’s accuracy.
A gated recurrent unit (GRU) [
34] is a simple variant of LSTM, and its working principle is similar to LSTM. It has two gates: update doors and reset doors. GRU aims to reduce parameters to optimize the cell structure and improve operational efficiency, making converging during training more manageable. Its flexible and straightforward structure guarantees accuracy while significantly reducing the time required for classification.
A convolutional neural network (CNN) [
35] is a typical representative of deep learning, consisting of an input layer, convolutional layer, pooling layer, fully connected layer, and output layer. Similar in structure to CNN, a one-dimensional convolutional neural network (1DCNN) [
36] refers to a CNN whose input is a one-dimensional vector; similarly, its convolution kernel is one-dimensional, and it carries out a one-dimensional convolution operation. It is a deep learning algorithm suitable for processing one-dimensional data. Compared with 2DCNN, the convolution kernel of 1DCNN only needs to be scanned in one direction. The convolutional layer performs convolution operations on the one-dimensional input signal and the one-dimensional convolution kernel and then extracts the features through the activation function. The pooling layer scales and maps the input data through the pooling kernel and extracts features while reducing the dimension of the data. This paper uses max pooling, which selects the maximum value of each small region as the output. Pooling operations can reduce the size of spatial information, improve operational efficiency, and reduce the risk of overfitting.
As we all know, the selection of hyperparameters affects the performance of deep learning to a large extent. The improper setting of hyperparameters may lead to under-fitting and over-fitting of the network model during training, so that the samples outside the training samples cannot be accurately classified. In this paper, the method of grid search [
37] is used for hyperparameter selection first, and the optimal hyperparameter method is determined by traversing the given parameter combination to determine the optimal value performance. Finally, we used the methods of LSTM, Bi-LSTM, GRU, and 1DCNN to classify the extracted feature data. The maximum number of rounds of training was 150. The Adam optimizer was applied. The learning rate was 0.01. The learning rate decline factor was set to 0.2. The number of iterations when the learning rate decreases was 5. The fully connected layer had two layers, and the number of corresponding classifications in the second layer was finally classified using the probability of the Softmax layer. The prediction label of the test sample was the output.
2.3. Performance Indicators
We divided all samples in the classification model into positive and negative samples. In this paper, cracked eggs were labeled as positive samples, and intact eggs were marked as negative samples. The prediction category determined by the model was obtained by predicting the sample data output in the model. In order to better evaluate the classification performance of the proposed detection model, five evaluation indicators, accuracy (ACC), precision (P), recall (R), F1-score (F1), and Matthews correlation coefficient (MCC), were used to comprehensively evaluate the algorithm models regarding their classification ability.
We define the false-positive (FP) rate as the number of negative samples that the model incorrectly predicts as positive samples. We define the true-positive (TP) rate as the number of positive samples correctly predicted by the model as positive samples. We define the false-negative (FN) rate as the number of positive samples that the model incorrectly predicts as negative samples and the true-negative (TN) rate as the number of negative samples correctly predicted by the model as negative samples.
Accuracy (
ACC), precision (
P), recall (
R), and F1-Score (
F1) are common performance indicators used to evaluate the predictive ability of classification models, and their calculation formulas are as follows:
The Matthews correlation coefficient (
MCC) [
38] comprehensively considers
TP,
TN,
FP, and
FN. It is considered to be a better measure of the classifier’s performance. The value range of the
MCC is [−1, 1]. A value of 1 means that the prediction is entirely consistent with reality, a value of 0 means that the predicted result is not as good as the result of random prediction, and a value of −1 means that the predicted result is inconsistent with the actual result.
MCC is defined as follows:
We used ACC, P, R, F1, and MCC as the evaluation indicators of the proposed method. In addition, the training time and preference time of the model were considered as a metric for performance evaluation, as they are of great significance to the real-time detection of cracked eggs.
2.4. Experimental Environment
All experimental calculations in this study were performed using MATLAB R2022a software, and the experimental computer processor was an 11th Gen Intel (R) Core (TM) i5-11400H @ 2.70GHz 2.69 GHz, Windows 10 (64-bit) Professional version.
4. Conclusions
This paper constructs a crack detection system for the electrical characteristics of eggs. With the help of a size recognition device, which automatically adapts the upper electrode position to the size of the egg, the system gives a more detailed and consistent view of the egg’s surface, resulting in a more representative collected signal. Given the limitations of disorder, mutation, nonlinearity, and time discontinuity of microcurrent signals, the reliability of signal features dominates the performance of the ultimate classification model. This paper suggests an electrical-based nondestructive detection model for microcracks in poultry eggs, which employs wavelet scattering transform to extract features. Wavelet scattering transform can effectively avoid the loss of valid information and produce a signal representation insensitive to small changes in the input signal. This paper discusses the feature extraction mechanism of wavelet scattering by visualizing the output results of the scattering feature process. Finally, the study feeds the acquired feature vector into the deep learning network for classification. The following are the conclusions that can be drawn from our experiments. The microcurrent signal has unpredictable and sudden transient characteristics. The wavelet scattering transform utilized to extract signal features and develop the corresponding matrix shows a distinguished capacity to collect signals with apparent differentiation and ensure satisfactory results. In this paper, we implement this feature extraction approach combined with appropriate classifiers to discuss the classification of egg microcurrent signals. The results show that WST+1DCNN has the best performance, and the average ACC, P, R, F1, and MCC obtained are 99.4393%, 99.2523%, 99.6226%, 99.4357%, and 98.8819%, respectively. In addition, we set the eggs’ class-imbalanced dataset and the duck egg dataset to verify the performance and universality. Finally, we conduct experiments on egg detection at different voltages. The novel feature extraction and detection method proposed in this paper can reduce the sensing voltage from 1500 V to 500 V and obtain higher detection accuracy on lower signal-to-noise data, dramatically reducing the risk of damage to hatching eggs from high-voltage electricity. In the future, the main direction of our research is how to achieve higher precision in egg crack detection under lower-voltage conditions, which specifically includes the following several aspects. The first is how to improve the shape of the brush so that it can cover a larger area of the eggshell during rotation and reduce the amount of missed area. An increase in the contact region means that we can realize the distinction at lower voltage, as it can also obtain enough current accumulation values in the crack regions. Secondly, at the algorithm level, we hope to extract more abundant and high-dimensional current features in the crack region and improve the existing algorithm to make it more representative. Finally, multi-sensor fusion is also one of our directions. We speculate that an algorithm based on current features combined with image features or acoustic features can have higher accuracy than an algorithm based on single-current features.