An apple maturity detection system and method based on embedded system
Through the support vector machine algorithm optimized by feature spectrum and genetic algorithm, the Apple maturity classification model was constructed, which solved the problems of cumbersome and inaccurate existing Apple maturity detection methods, achieved efficient and accurate Apple maturity detection, and promoted Apple's Digital and intelligent development of the industry.
Patent Information
- Application Number
- CN202010452754.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-26
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2040-05-26
AI Technical Summary
The existing Apple maturity detection methods are cumbersome and inaccurate, and the equipment is large in size, high testing environment requirements, and slow computing speed, making it difficult to promote.
The Apple maturity classification model is established using feature spectroscopy, combined with principal component analysis and genetic algorithm to optimize the support vector machine algorithm, extract feature wavelengths, and construct an Apple maturity classification model based on near-infrared spectroscopy to achieve lossless prediction.
It reduces the complexity of Apple's maturity determination process, improves detection efficiency and accuracy, reduces redundant information interference, enhances the portability of the model, designs small portable devices, and improves operability.
Smart Images

Figure CN111665215B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of nondestructive testing of agricultural products, and in particular relates to an embedded apple maturity detection system and method. Background Art
[0002] At present, apples are rich in varieties and widely planted. They are the largest fruit in my country, and their planting area and output account for about 50% of the world. China's apple production is huge, but there is still a certain gap compared with the quality of foreign apples. The reason is that the harvesting time of apples for different purposes is not reasonably controlled. In short, apples are picked in advance before they are ripe, which not only affects the quality of apples but also causes waste of apples. Apple maturity can determine the picking time of fruits and evaluate the quality of fruits after harvest. It is one of the important indicators for evaluating apple quality. Harvest maturity is a key factor in determining the taste and flavor of apples, and directly affects the quality grade and economic benefits of apples. Maturity can generally be divided into harvestable maturity, edible maturity and physiological maturity. Insufficient maturity will lead to low sugar content, poor coloring, poor taste, and susceptibility to disease, while excessive maturity will lead to soft texture, poor taste and flavor, and poor storage resistance. Therefore, the judgment of maturity is of great significance to the storage and quality assurance of apples after harvest.
[0003] At present, the judgment of apple maturity is mainly based on the speculation of fruit farmers based on the flowering period. Such speculation requires certain experience and is blind. Different fruit trees are affected by factors such as regional climate and growth differences, which will lead to uneven maturity. At the same time, the physical and chemical property detection method is complex and time-consuming, not suitable for large-scale detection, and requires damage to apples. At present, there are relatively few studies on the evaluation index analysis of apple maturity, the evaluation of physical and chemical quality, and the comprehensive evaluation model at home and abroad. In addition, the selected evaluation standards are different and the overall system is imperfect. However, according to the research of Zhao Zhengyang, Zhang Junke and others, the sugar content, acidity, hardness, coloring and other indicators change greatly with the maturity of apples, which is an important basis for judging apple maturity.
[0004] In summary, the problems existing in the prior art are:
[0005] (1) Currently, the maturity of apples is determined by predicting the apple quality index factors through spectroscopy. The process of using the index factors to determine the maturity of apples is cumbersome, and multiple predictions are required to predict the maturity, which reduces the prediction accuracy.
[0006] (2) The current prediction method uses the full spectrum to establish a maturity prediction model, which contains a lot of redundant information, has a slow calculation speed, and is not easy to promote.
[0007] (3) The existing maturity testing equipment is large in size, has high requirements for the testing environment, and has a long testing cycle.
[0008] Difficulty in solving the above technical problems: There are many advantages in using characteristic spectra to establish an apple maturity classification model, but the selection of characteristic bands is a difficulty. The characteristic bands need to contain most of the content of the entire band, and at the same time, redundant information must be removed. The characteristic bands are no longer arrays of thousands of dimensions, but vectors of only a dozen elements; the quality of the model created based on the support vector machine depends largely on the input parameters. If the input parameters are slightly different, the results will be very different. Therefore, how to choose the appropriate input parameters is another difficulty.
[0009] The significance of solving the above technical problems: The method of directly predicting apple maturity by spectrum solves the shortcomings of inconsistent and inaccurate apple maturity judgment standards, reduces the complexity of the apple maturity judgment process, and improves the efficiency of apple maturity grading; based on the characteristic spectrum, the support vector machine algorithm optimized by genetic algorithm is used to obtain the optimal decision hyperplane and classification model for Fuji apple maturity classification, which not only reduces the complexity of spectral calculations, but also eliminates the interference of useless spectra and increases the portability of the model; the embedded apple maturity detection method and system are applied to small and portable detection equipment, which can reduce the complexity of the detection device and improve the operability of the device, combine technology with products, and promote the research and development of apple maturity judgment methods. Summary of the invention
[0010] In view of the problems existing in the prior art, the present invention provides an apple maturity detection system and method based on embedded system.
[0011] The present invention is implemented in this way: an embedded apple maturity detection method, the embedded apple maturity detection method comprising:
[0012] Step 1: The apple diffuse reflectance laboratory platform uses principal component analysis to cluster the spectrum and replace the original high-dimensional data with new low-dimensional data. Based on the spectral data of principal component analysis, the characteristic wavelength of apple maturity is extracted in combination with the x-loading coefficient method;
[0013] Step 2: Based on the samples of apple maturity characteristic spectra, the data samples are divided into training sets and prediction sets, and the penalty parameter c and kernel function parameter g in the support vector machine model are optimized by using a genetic algorithm; the Gaussian kernel function is used as the kernel function of the support vector machine to construct a classification model for apple maturity;
[0014] Step three, based on the diffuse reflection method of the interaction between near-infrared light and apples; use the driving circuit and control circuit of the halogen light source, the printed circuit board of the external trigger circuit and the main controller to obtain the characteristic spectral data of the sample apples and build an apple maturity classification model; with the apple maturity classification model as the core, write a control program that integrates the apple maturity classification model to achieve non-destructive prediction of apple maturity.
[0015] Furthermore, the embedded apple maturity detection method and the support vector machine apple maturity classification method based on genetic algorithm optimization include:
[0016] The first step is to extract the spectral characteristic wavelengths for apple maturity classification, build an apple maturity diffuse reflectance experimental platform based on visible / near-infrared spectra, and use a ground object spectrometer to obtain the spectral curve of apples; based on the apple diffuse reflectance samples, the spectral data is clustered by principal component analysis to obtain the clustering diagram of the first principal component and the second principal component; the characteristic wavelength of the spectrum is extracted based on the x-load coefficient. The x-load coefficient method is based on the principal component factor coefficient matrix of the spectral data obtained by principal component analysis. The wavelength vector of the spectral data is used as the horizontal axis of the load coefficient diagram, and the principal component factor coefficient matrix is used as the response value of the vertical coordinate to draw the load coefficient diagram of the first three principal components; the x-load coefficient method can obtain the load coefficient corresponding to each wavelength point under each implicit variable, and screen the spectral characteristic wavelength that plays a clustering role on the spectral data sample; according to the local maximum value of the load coefficient, the spectral characteristic wavelength used for apple maturity classification is screened out;
[0017] The second step is to construct an apple maturity classification model, including: using genetic algorithm as the optimization method and support vector machine classification algorithm to construct an apple maturity classification model; the classification model uses the spectral feature band extracted by the x-load coefficient algorithm as input, sets the optimal penalty parameter c and kernel function parameter g obtained by the genetic algorithm, and uses the Gaussian kernel function to achieve fast and lossless prediction of apple maturity information;
[0018] According to the extracted spectral feature bands, the experimental samples were divided into training set and validation set. First, the apple maturity prediction model was trained according to the support vector machine algorithm optimized by genetic algorithm, and the model was verified based on the validation set samples, and finally the model was saved.
[0019] Furthermore, the construction of the second step apple maturity classification model specifically includes:
[0020] (1) Encode the extracted spectral characteristic wavelengths, express the solution space variables as gene string structure data in the genetic space, use the accuracy function of the support vector machine model as the fitness function of the genetic algorithm, and use the roulette method as the selection operator of the genetic algorithm. The probability of each individual being selected is proportional to its fitness. The formula is shown below. The population size is n, where the fitness of individual i is , then the probability that i is selected is P i :
[0021] ;
[0022] In the formula, is the fitness of individual i, P i is the probability of being selected;
[0023] (2) The crossover and mutation operations in the genetic algorithm are all based on the algorithm’s own operation methods. The genetic algorithm is run multiple times to obtain the best penalty parameter c and kernel function parameter g.
[0024] (3) The support vector machine algorithm uses the characteristic wavelength of the apple sample spectrum and the actual maturity of the apple as input. The penalty parameter c and the kernel function parameter g select the optimal value obtained by the genetic algorithm. The kernel function is a Gaussian kernel function. The formula is as follows:
[0025] ;
[0026] In the formula, is the center of the kernel function, X is the input vector, is the squared Euclidean distance between two eigenvectors.
[0027] Furthermore, the embedded apple maturity detection method and the non-destructive detection method based on the apple maturity classification algorithm include: the spectrum acquisition module mainly acquires characteristic spectrum data, one spectrum data is a 23-bit binary data pair, which is converted into a decimal floating point number according to the IEEE standard, that is, the true value of the characteristic spectrum; the controller module is embedded with an embedded apple maturity detection model, the spectrum characteristic data is input by the model network interface, and the apple maturity result is output; the trigger module adopts hardware anti-shake; the display screen communicates with the controller through the SPI bus to realize the real-time display of the apple detection results.
[0028] Furthermore, the embedded apple maturity detection method and the non-destructive detection method based on the apple maturity classification algorithm also include: integrating the apple maturity classification model, after the device is loaded, performing initialization operation, and then performing light source calibration. After the calibration is completed, the device will store the best duty cycle; this duty cycle will always be used to ensure the consistency of the light intensity of the light source. After the interface is successfully loaded, the device will cyclically wait for an external trigger signal. Once a falling edge trigger signal is detected, the device will generate a pulse to control the light source driver board to drive the halogen to light up, and the controller will start to read the spectral data in the sensor register and judge the integrity of the data; based on the acquired characteristic spectral data, the apple maturity classification model is used to obtain the maturity information of the apple to realize the classification of the apple maturity.
[0029] Another object of the present invention is to provide a storage medium for receiving a user input program, wherein the stored computer program causes an electronic device to execute the following steps:
[0030] In the first step, the apple diffuse reflectance laboratory platform uses principal component analysis to cluster the spectrum and replace the original high-dimensional data with new low-dimensional data. Based on the spectral data of principal component analysis, the characteristic wavelength of apple maturity is extracted in combination with the x-loading coefficient method.
[0031] In the second step, based on the samples of apple maturity characteristic spectra, the data samples were divided into training set and prediction set, and the penalty parameter c and kernel function parameter g in the support vector machine model were optimized by genetic algorithm; the Gaussian kernel function was used as the kernel function of the support vector machine to construct the classification model of apple maturity;
[0032] The third step is based on the diffuse reflection method of the interaction between near-infrared light and apples; the driving circuit and control circuit of the halogen light source, the printed circuit board of the external trigger circuit and the main controller are used to obtain the characteristic spectral data of the sample apples and build an apple maturity classification model; with the apple maturity classification model as the core, a control program integrating the apple maturity classification model is written to achieve non-destructive prediction of apple maturity.
[0033] Another object of the present invention is to provide a computer program product stored on a computer-readable medium, including a computer-readable program, which, when executed on an electronic device, provides a user input interface to implement the embedded apple maturity detection method.
[0034] Another object of the present invention is to provide an embedded apple maturity detection system for implementing the embedded apple maturity detection method, the embedded apple maturity detection system comprising:
[0035] The apple diffuse reflectance laboratory platform is used to replace the original high-dimensional data with new low-dimensional data through spectral cluster analysis by principal component analysis, and extract the characteristic wavelength of apple maturity based on the spectral data of principal component analysis combined with the x-loading coefficient method;
[0036] The portable non-destructive testing equipment is based on obtaining the characteristic spectral data of sample apples and combining it to build an apple maturity classification model. With the apple maturity classification model as the core, a control program integrating the apple maturity classification model is written to achieve non-destructive prediction of apple maturity.
[0037] Furthermore, the apple diffuse reflectance laboratory platform uses a ground object spectrometer to obtain a spectral curve graph of apples.
[0038] Furthermore, the portable nondestructive testing device includes a housing, a testing probe, a control module, a light source driving module, and a data acquisition module;
[0039] The control module includes: a spectrum acquisition module, a controller module, a light source driving module, a trigger module, and a power supply module;
[0040] The spectrum acquisition module is used to collect characteristic spectrum data. A spectrum data is a 23-bit binary data pair, which is converted into a decimal floating point number according to the IEEE standard, that is, the real value of the characteristic spectrum.
[0041] The controller module is embedded with an embedded apple maturity detection model. The spectral feature data is input by the model network interface and is used to output the results of apple maturity.
[0042] The trigger module uses hardware anti-shake to ensure that the system will not be triggered multiple times. A 0.1μF large capacitor is connected in parallel to reduce key jitter. A key indicator light is added to the trigger module to prevent users from triggering the key multiple times in a short period of time.
[0043] The power module distributes the 12 V voltage provided by the lithium battery into 7 V and 5 V voltages through the printed circuit board and provides sufficient current.
[0044] Light source driver module: The driver chip of the light source driver module is BP1361, which is packaged in SOT23-5 mode. It is a commonly used buck constant current driver chip. The pin VIM can input a voltage of 5 V to 30 V. When working, BP1361, inductor (L1), and current sampling resistor (R1) form a self-oscillating continuous inductor current mode buck constant current LED controller, and the current is output between leads AD1 and AD2.
[0045] This module is a light source driver module that can use PWM to adjust the light intensity of LED. The pin DIM in the module can receive PWM with a wide frequency range of 0.5-2.5 V. When the voltage of DIM is lower than 0.3V, the power switch is turned off and the driver chip enters a standby state with extremely low working current. The PWM required by the DIM pin can be generated by the software program. The light source driver module combined with the PWM control program can generate a constant power current to ensure that the light intensity generated by the halogen light source is consistent each time;
[0046] The shell and detection probe of the portable non-destructive testing equipment. The shell of the equipment mainly has the functions of protection, support and heat dissipation, and is designed according to the hardware structure of the equipment; the equipment detection probe is one of the most important parts of the equipment, providing guarantee for the equipment detection accuracy.
[0047] The display screen communicates with the controller via the SPI bus to realize real-time display of apple detection results.
[0048] In summary, the advantages and positive effects of the present invention are as follows: in view of the problems that the existing lossless prediction methods for apple maturity are complex and have high environmental requirements, a diffuse reflection light detection optical path (probe) is designed. The present invention uses the spectral characteristic wavelength as input and adopts the support vector machine apple maturity classification model fused with genetic algorithm to directly realize the classification of apple maturity; compared with the traditional method of predicting apple maturity, the prediction of indirect quantities (apple physical and chemical indicators) is reduced, the complexity of the work is reduced, and the work efficiency and accuracy are improved. Based on the apple maturity intelligent classification algorithm, a miniaturized printed circuit board is designed, an embedded operating system is implanted, and a small and portable apple maturity rapid classification device is designed.
[0049] The present invention adopts a new maturity discrimination algorithm, based on the characteristic spectrum wavelength, and adopts a support vector machine maturity classification algorithm based on genetic algorithm optimization to achieve rapid classification of apple maturity; optimizes the detection spectrum and adds a light source correction system to improve the adaptability of the device to the environment; integrates the design of a printed circuit board to reduce the size of the device and make the device easy to carry.
[0050] The present invention includes an apple maturity classification method integrating a genetic algorithm and a support vector machine algorithm and a portable apple maturity rapid nondestructive detection device; the apple maturity rapid nondestructive detection device specifically includes a housing for stabilizing, supporting and protecting the device, a detection optical path designed according to the diffuse reflection principle of light and a halogen light source, a light intensity correction unit for ensuring the stability of the light intensity of the device, a drive control unit of the halogen light source, a trigger unit and a data acquisition module; the support vector machine algorithm for apple maturity classification adopts a Gaussian kernel function, wherein the penalty parameter c and the kernel function parameter g are obtained by optimizing the genetic algorithm; the drive control unit of the halogen light source specifically includes a constant voltage and constant current drive module and a pulse width modulation control module. The embedded apple maturity detection system of the present invention has a simple structure, is convenient to use and carry, can efficiently and quickly realize the judgment of apple maturity, and promotes the digitalization and intelligent development of the apple industry.
[0051] The present invention designs the detection optical path (probe) according to the characteristics of spectral diffuse reflection and the actual situation of halogen light source, which effectively improves the practicality of the equipment; adopts the design method of integrated circuit to closely combine the basic control drive circuit and the control, thereby reducing the cost of equipment research and development; the embedded apple maturity discrimination model based on genetic algorithm and support vector machine algorithm gives the detection equipment real practical significance; the introduction of apple maturity rapid detection system and method promotes the intelligence and digitization of the apple industry, promotes the realization of agricultural Internet of Things, and accelerates the process of visible / near-infrared non-destructive detection of apple technology towards actual production. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 The present invention provides a flowchart of an embedded apple maturity detection method.
[0053] Figure 2 This is a graph of the diffuse reflectance spectrum of apple provided by an embodiment of the present invention.
[0054] Figure 3 Apple spectrum clustering analysis diagram provided by an embodiment of the present invention
[0055] Figure 4 An apple spectrum x-loading coefficient diagram based on principal component analysis provided by an embodiment of the present invention.
[0056] Figure 5 A flow chart of a support vector machine algorithm based on genetic algorithm optimization provided by an embodiment of the present invention.
[0057] Figure 6 An optical path schematic diagram of an embedded apple maturity detection device provided in an embodiment of the present invention.
[0058] Figure 7A physical diagram of the optical path of an embedded apple maturity detection device provided in an embodiment of the present invention.
[0059] Figure 8 A system control diagram of an embedded apple maturity detection device provided in an embodiment of the present invention.
[0060] Fig. 9 Schematic diagram of an apple detection light source driving circuit provided by an embodiment of the present invention.
[0061] Fig.10 A program flow chart provided by an embodiment of the present invention.
[0062] Fig.11 A light source calibration flow chart provided by an embodiment of the present invention.
[0063] Fig.12 A sample classification effect diagram provided by an embodiment of the present invention.
[0064] Fig.13 A diagram showing a device housing provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0066] In view of the problems existing in the prior art, the present invention provides an apple maturity detection system and method based on embedded system, which will be described in detail below in conjunction with the accompanying drawings.
[0067] like Figure 1 As shown, the embedded apple maturity detection method provided by the embodiment of the present invention includes the following steps:
[0068] S101: Build an apple diffuse reflectance laboratory platform based on visible / near-infrared spectroscopy; use principal component analysis to cluster spectral data to replace the original high-dimensional data with new low-dimensional data, and extract the characteristic wavelength of apple maturity based on the spectral data of principal component analysis combined with the x-loading coefficient method.
[0069] S102: Based on the samples of the characteristic spectrum of apple maturity, the data samples are divided into a training set and a prediction set, and a genetic algorithm is used to optimize the penalty parameter c and the kernel function parameter g in the support vector machine model; the Gaussian kernel function is used as the kernel function of the support vector machine to construct a classification model for apple maturity.
[0070] S103: Based on the diffuse reflection mode of the interaction between near-infrared light and apples, 3D printing can be used for the detection light path (probe) on portable devices; drawing the driving circuit and control circuit of the halogen light source, the external trigger circuit and processing the printed circuit board, and cooperating with the main controller to form the hardware platform of the device.
[0071] S104: Based on the unique detection probe and hardware platform, the characteristic spectral data of the sample apples are obtained, and the apple maturity classification model is constructed in combination with the S102 method; then, with the apple maturity classification model as the core, a control program integrating the apple maturity classification model is written to achieve non-destructive prediction of apple maturity.
[0072] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0073] The embedded apple maturity detection method provided by the embodiment of the present invention comprises the following steps:
[0074] (1) Apple maturity classification method based on support vector machine optimized by genetic algorithm
[0075] Step 1: Extraction of spectral characteristic wavelengths for apple maturity classification. Build an apple maturity diffuse reflectance experimental platform based on visible / near infrared spectroscopy, and use a ground object spectrometer (OFS-1100, Ocean Optics, USA) to obtain the spectral curve of apples, such as Figure 2 As shown in the figure, the spectrum wavelength range of 398~1045nm was selected as the effective sample, the spectral resolution was 0.46nm, and there were 1432 sample attributes in total; based on the apple diffuse reflectance sample, the principal component analysis method was used to perform cluster analysis on the spectral data, and the following was obtained: Figure 3 The cluster diagrams of the first and second principal components shown in the figure show that the spectral data are roughly divided into three categories, indicating that the spectral curves of apples of different maturity are different. The characteristic wavelength of the spectrum is extracted based on the x-load coefficient. The x-load coefficient method is based on the principal component factor coefficient matrix of the spectral data obtained by principal component analysis. The wavelength vector of the spectral data is used as the horizontal axis of the load coefficient diagram, and the principal component factor coefficient matrix is used as the response value of the vertical axis to draw the load coefficient diagram of the first three principal components (as shown in Figure 1). Figure 4 As shown); the x-load coefficient method can obtain the load coefficient corresponding to each wavelength point under each implicit variable, and then screen the spectral characteristic wavelengths that have a clustering effect on the spectral data samples; according to the local maximum value of the load coefficient, the spectral characteristic wavelengths that can be used for apple maturity classification are screened out.
[0076] Step 2: Construction of apple maturity classification model. The apple maturity rapid classification algorithm specifically includes: using genetic algorithm as the optimization method and support vector machine classification algorithm to construct an apple maturity classification model; the classification model uses the spectral feature band extracted by the x-load coefficient algorithm as input, sets the optimal penalty parameter c and kernel function parameter g obtained by the genetic algorithm, and uses the Gaussian kernel function to achieve rapid and lossless prediction of apple maturity information.
[0077] When performing a genetic algorithm, it is first necessary to encode the extracted spectral feature wavelengths, express the solution space variables as the gene string structure data of the genetic space, use the accuracy function of the support vector machine model as the fitness function of the genetic algorithm, and use the roulette method as the selection operator of the genetic algorithm. In this method, the probability of each individual being selected is proportional to its fitness. The formula is shown below. Assume that the population size is n, where the fitness of individual i is , then the probability that i is selected is P i :
[0078] ;
[0079] In the formula, is the fitness of individual i, P i is the probability of being selected;
[0080] The crossover and mutation operations in the genetic algorithm all use the algorithm's own operation methods, and the genetic algorithm is run multiple times to obtain the optimal penalty parameter c and kernel function parameter g.
[0081] The support vector machine algorithm uses the characteristic wavelength of the apple sample spectrum and the actual maturity of the apple as input. The penalty parameter c and the kernel function parameter g select the optimal value obtained by the genetic algorithm. The kernel function is a Gaussian kernel function, and its formula is as follows:
[0082] ;
[0083] In the formula, is the center of the kernel function, X is the input vector, is the squared Euclidean distance between two eigenvectors;
[0084] According to the spectral characteristic bands extracted by the device hardware platform, the experimental samples are divided into training sets and validation sets. Figure 5 The support vector machine algorithm flow chart based on genetic algorithm optimization is shown in the figure. The apple maturity prediction model is trained, then the model is verified based on the validation set samples, and finally the model is saved.
[0085] (2) Portable non-destructive testing equipment based on apple maturity classification algorithm
[0086] Step 1: Construction of hardware equipment for the apple maturity rapid detection system. The apple maturity rapid detection equipment includes a housing, a detection probe, a control module, a light source drive module, and a data acquisition module. The housing of the equipment mainly plays the role of support, protection, and stability. The existence of the equipment housing increases the stability of the equipment. Based on the characteristics of visible / near-infrared spectral diffuse reflection and the characteristics of the halogen light source, combined with the actual external environment, the inclination angle of the halogen light source and the distance from the light source to the apple surface are calculated. Figure 6 As shown in the figure, the diffuse reflection light path of the available equipment is designed as shown in the figure. Figure 7 shown.
[0087] Step 2: The device uses Raspberry Pi as the central processor to coordinate the work of each module. The system block diagram of the apple maturity rapid non-destructive testing equipment is as follows: Figure 8 As shown, the entire hardware control system includes a total of 6 modules, mainly spectral acquisition module, controller module, light source drive module, trigger module and power module. The spectral acquisition module is mainly used to collect characteristic spectral data. A spectral data is a 23-bit binary data pair, which is converted into a decimal floating point number according to the IEEE standard, that is, the true value of the characteristic spectrum; the controller module is embedded with an embedded apple maturity detection model. The spectral characteristic data is input by the model network interface and the apple maturity result is output; the trigger module adopts hardware anti-shake technology, which greatly reduces the situation of multiple triggering and increases the stability of the equipment; the display communicates with the controller through the SPI bus to realize the real-time display of apple detection results. Because the lighting of the halogen light source requires a large current (not less than 0.9A), the light source drive module is designed as Fig. 9 As shown, pulses can be used to adjust the light intensity of the halogen light source to increase the universality of the device.
[0088] Step 3: Write a software program that integrates the apple maturity classification model. The flowchart is as follows Fig.10 As shown, after the device is loaded, it is initialized first, and then the light source is calibrated. The specific calibration method is as follows Fig.11 As shown, after the calibration is completed, the device will store the best duty cycle. In the subsequent use of the device, this duty cycle will be used to ensure the consistency of the light intensity of the light source. After the successful interface is loaded, the device waits for the external trigger signal in a loop. Once the falling edge trigger signal is detected, the device generates a pulse to control the light source driver board to drive the halogen to light up. The controller starts to read the spectral data in the sensor register and judge the integrity of the data. Based on the acquired characteristic spectral data, the apple maturity classification model is used to obtain the apple maturity information and realize the classification of apple maturity.
[0089] The apple maturity classification method of the support vector machine integrated with the genetic algorithm of the present invention can be directly applied to the detection device. The multiple characteristic spectra with the greatest correlation with the maturity of apples are used as input to obtain the maturity information of apples. The detection optical path of the non-destructive testing equipment included in the system reduces the impact of the environment on the detection results, and the designed and manufactured printed circuit board provides a hardware environment for the operation of the algorithm. In summary, the non-destructive testing method for apples provides new ideas and new thoughts for the research on apple maturity and other aspects; the rapid detection equipment for apple maturity constructed in combination with the non-destructive testing method included in the present invention has promoted the rapid development of non-destructive testing equipment for apples in my country and accelerated the process of combining intelligent data with agricultural products.
[0090] (3) Experimental verification
[0091] The portable apple maturity detection device constructed based on the embedded apple maturity detection method, system and computer program of this embodiment is as follows: Fig.13 As shown, the detection method and system of this embodiment are verified by using the constructed non-destructive testing equipment; the experimental samples are 60 Fuji apples of different maturity, and the classification accuracy reaches 83.33%, and there is no situation where unripe (over) ripe apples are classified as over (unripe) ripe apples, as shown in FIG. Fig.12 As shown, the apple maturity detection method and system are feasible; there are some errors in the prediction of the system which cannot be ignored. The reason for the error may be that the external natural light interferes with the detection process, so the light-shielding property of the system still needs in-depth research.
[0092] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.
[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An apple maturity detection method based on embedded system, characterized in that: The embedded apple maturity detection method includes: Step 1: The apple diffuse reflectance laboratory platform uses principal component analysis to cluster the spectrum and replace the original high-dimensional data with new low-dimensional data. Based on the spectral data of principal component analysis, the characteristic wavelength of apple maturity is extracted in combination with the x-loading coefficient method; Step 2: Based on the samples of apple maturity characteristic spectra, the data samples are divided into training sets and prediction sets, and the penalty parameter c and kernel function parameter g in the support vector machine model are optimized by using a genetic algorithm; the Gaussian kernel function is used as the kernel function of the support vector machine to construct a classification model for apple maturity; Step 3: Based on the diffuse reflection mode of the interaction between near-infrared light and apples, the driving circuit and control circuit of the halogen light source and the printed circuit board of the external trigger circuit are used in conjunction with the main controller to obtain the characteristic spectrum data of the sample apples and build an apple maturity classification model; with the apple maturity classification model as the core, a control program integrating the apple maturity classification model is written to achieve non-destructive prediction of apple maturity; The embedded apple maturity detection method and the support vector machine apple maturity classification method based on genetic algorithm optimization include: The first step is to extract the spectral characteristic wavelengths for apple maturity classification, build an apple maturity diffuse reflectance experimental platform based on visible / near-infrared spectra, and use a ground object spectrometer to obtain the spectral curve of apples; based on the apple diffuse reflectance samples, the spectral data is clustered by principal component analysis to obtain the clustering diagram of the first principal component and the second principal component; the characteristic wavelength of the spectrum is extracted based on the x-load coefficient. The x-load coefficient method is based on the principal component factor coefficient matrix of the spectral data obtained by principal component analysis. The wavelength vector of the spectral data is used as the horizontal axis of the load coefficient diagram, and the principal component factor coefficient matrix is used as the response value of the vertical coordinate to draw the load coefficient diagram of the first three principal components; the x-load coefficient method can obtain the load coefficient corresponding to each wavelength point under each implicit variable, and screen the spectral characteristic wavelength that plays a clustering role on the spectral data sample; according to the local maximum value of the load coefficient, the spectral characteristic wavelength used for apple maturity classification is screened out; The second step is to construct an apple maturity classification model, including: using genetic algorithm as the optimization method and support vector machine classification algorithm to construct an apple maturity classification model; the classification model uses the spectral feature band extracted by the x-load coefficient algorithm as input, sets the optimal penalty parameter c and kernel function parameter g obtained by the genetic algorithm, and uses the Gaussian kernel function to achieve fast and lossless prediction of apple maturity information; According to the extracted spectral feature bands, the experimental samples were divided into training set and validation set. First, the apple maturity prediction model was trained according to the support vector machine algorithm optimized by genetic algorithm, and the model was verified based on the validation set samples, and finally the model was saved.
2. The embedded apple maturity detection method according to claim 1, characterized in that: The second step of building the apple maturity classification model specifically includes: (1) Encode the extracted spectral characteristic wavelengths, express the solution space variables as gene string structure data in the genetic space, use the accuracy function of the support vector machine model as the fitness function of the genetic algorithm, and use the roulette method as the selection operator of the genetic algorithm. The probability of each individual being selected is proportional to its fitness. The formula is shown below. The population size is n, and the fitness of individual i is f i , then the probability that i is selected is P i : In the formula, f i is the fitness of individual i, P i is the probability of being selected; (2) The crossover and mutation operations in the genetic algorithm are all based on the algorithm’s own operation methods. The genetic algorithm is run multiple times to obtain the best penalty parameter c and kernel function parameter g. (3) The support vector machine algorithm uses the characteristic wavelength of the apple sample spectrum and the actual maturity of the apple as input. The penalty parameter c and the kernel function parameter g select the optimal value obtained by the genetic algorithm. The kernel function is a Gaussian kernel function. The formula is as follows: Where, X p is the center of the kernel function, X is the input vector, ||XX p || 2 is the squared Euclidean distance between two eigenvectors.
3. The embedded apple maturity detection method according to claim 1, characterized in that: The embedded apple maturity detection method is a non-destructive detection method based on an apple maturity classification algorithm, including: a spectrum acquisition module mainly acquires characteristic spectrum data, one spectrum data is a 23-bit binary data pair, which is converted into a decimal floating point number according to the IEEE standard, that is, the true value of the characteristic spectrum; an embedded apple maturity detection model is embedded in the controller module, the spectrum characteristic data is input by a model network interface, and the apple maturity result is output; the trigger module adopts hardware anti-shake; the display screen communicates with the controller through the SPI bus to realize real-time display of the apple detection result.
4. The embedded apple maturity detection method according to claim 1, characterized in that: The embedded apple maturity detection method and the non-destructive detection method based on the apple maturity classification algorithm also include: integrating the apple maturity classification model, after the device is loaded, performing initialization operation, and then performing light source calibration. After the calibration is completed, the device will store the best duty cycle; this duty cycle will always be used to ensure the consistency of the light intensity of the light source. After the interface is successfully loaded, the device will cyclically wait for an external trigger signal. Once a falling edge trigger signal is detected, the device will generate a pulse to control the light source driver board to drive the halogen to light up, and the controller will start to read the spectral data in the sensor register and judge the integrity of the data; based on the acquired characteristic spectral data, the apple maturity classification model is used to obtain the maturity information of the apple to achieve the classification of the apple maturity.
5. A storage medium for receiving user input programs, wherein the stored computer program enables an electronic device to execute the steps of the embedded apple maturity detection method as described in any one of claims 1 to 4.
6. A computer program product stored on a computer-readable medium, comprising a computer-readable program, which, when executed on an electronic device, provides a user input interface to implement the steps of the embedded apple maturity detection method as described in any one of claims 1 to 4.
7. An embedded apple maturity detection system for implementing the embedded apple maturity detection method according to any one of claims 1 to 4, characterized in that: The embedded apple maturity detection system includes: The apple diffuse reflectance laboratory platform is used to replace the original high-dimensional data with new low-dimensional data through spectral cluster analysis by principal component analysis, and extract the characteristic wavelength of apple maturity based on the spectral data of principal component analysis combined with the x-loading coefficient method; Portable non-destructive testing equipment is used to obtain characteristic spectral data of sample apples and combine it to build an apple maturity classification model; with the apple maturity classification model as the core, a control program integrating the apple maturity classification model is written to achieve non-destructive prediction of apple maturity.
8. The embedded apple maturity detection system according to claim 7, characterized in that: The apple diffuse reflectance laboratory platform uses a ground object spectrometer to obtain a spectral curve graph of apples.
9. The embedded apple maturity detection system according to claim 7, characterized in that: The portable nondestructive testing device includes a housing, a testing probe, a control module, a light source driving module, and a data acquisition module; The control module includes: a spectrum acquisition module, a controller module, a light source driving module, a trigger module, and a power supply module; The spectrum acquisition module is used to collect characteristic spectrum data. A spectrum data is a 23-bit binary data pair, which is converted into a decimal floating point number according to the IEEE standard, that is, the real value of the characteristic spectrum. The controller module is embedded with an embedded apple maturity detection model. The spectral feature data is input by the model network interface and is used to output the results of apple maturity. The trigger module uses hardware anti-shake; The display screen communicates with the controller via the SPI bus to realize real-time display of apple detection results.
