Design and Experiment of a Portable Near-infrared Spectrum Detection System for Fruits and Vegetables Quality-inspection

. To meet the practical needs of rapid and non-destructive detection in fruit and vegetable processing, this paper designs a developed portable near-infrared spectrum quality-detection device. In this design, the digital micromirror device of the near-infrared micro-electromechanical system is used as the light splitting element, and the detection information is obtained by a single-point detector, to realize the miniaturization design of the spectrum detection system and significantly reduce the cost. Moreover, the quality inspection model is established based on the PLS method and the principal component analysis method. From the results of the prediction set, the model established by the logarithm of the original absorption spectrum (1/R) and the PLS method is applicable, with a high correlation coefficient (0.9537) and low corrected root mean square error (0.3776). This research can provide reference data for the design of low-cost, practical, and miniaturized near-infrared spectrum detection systems.


Introduction
As food quality problems appear recently, consumers pay more attention to the quality security of fruits and vegetables [1] . Fresh fruits and vegetables have become a consumption popular trend nowadays [2] . However, the traditional chemical detection methods have several deficiencies, such as time-consuming and high-cost, and cannot satisfy the actual need [3] . To ensure the quality of fruits and vegetables, a rapid and non-destructive testing technology and equipment for fruit and vegetable quality is in urgent need of development.
Near-infrared spectrum analysis technology can be used for qualitative and quantitative data analysis of fullwavelength or multi-wavelength spectra [4] . Owing to its advantages, such as convenience, rapidness, nondestruction, and full of abundant information, the nearinfrared spectrum has been widely used for the quality determination of fruits and vegetables these days. Firmness is an important index of fruit quality [5] , however, there are few studies on the quality of fruits and vegetables based on firmness.
In recent years, with the adjustment of the rural industrial structure, persimmons have become an important source of income for farmers in Shaanxi Province. Nevertheless, as to the present case, the domestic and foreign markets for fresh persimmon sales have not yet fully developed. Persimmon, as a local specialty, cannot meet the market demand, restricting the local economic development. Therefore, this paper takes persimmon as an example to design a portable device for fruits and vegetables quality testing.

Structural design
According to the function and application of portable near-infrared spectrum quality-detection equipment, the design of the hardware system of the apparatus includes a miniature near-infrared light source, a miniature nearinfrared spectrometer module, power supply module, control and communication module, LCD module, and protective shield, as shown in Figure 1. The object to be tested is placed on the soft-rubber gasket over the test window during testing to protect it against extrusion or squeezing. What's more, in the space dimension, the object and the near-infrared spectrometer are in isolation to eliminate the interference of stray-light.
As soon as the test is executed, the miniature light source is turned on and the near-infrared spectrometer is triggered to collecting near-infrared diffuse reflection spectroscopy (NIDRS), which is used to detect the quality of fruits and vegetables. After the near-infrared light exposure to the surface of the target, the light beam is transmitted in the object and the reflected light is accepted by the spectrometer finally. The optical signals are converted into electrical signals and then transmitted by the control circuit to the embedded processor for display and storage.

Miniature near-infrared spectrometer module
The near-infrared spectroscopy mainly produced by molecular vibration frequency within the group absorption and frequency absorption harmony, and only hydrogen-containing functional groups such as C-H, N-H, S-H, and O-H stretching vibration can be detected [6] , which plays significant effects in the quality inspection of fruits and vegetables. These spectrometers have the advantages of high detection precision, however, the shortcoming appears, not only bulky but also costly, which restricts the further application. With the fast development of micro-fabrication technologies, Micro-Electromechanical System (MEMS) technology is a hot spot of science and industry in these days. To make up these insufficiencies of modern spectrometers, the miniature near-infrared spectrometer is being rapidly expanded. Digital Micromirror Device (DMD) is based on light processing technology and MEMS technology, which has advantages of high resolution, high brightness, high contrast, high reliability, digital control, and short response time and has been widely used in digital light processing systems [7] .
Two different types of detectors can be used in the DMD spectrometer: single-point indium gallium arsenide detector and linear array silicon detector [8] . The former has more advantages of low cost, high yield than the latter. In this paper, a near-infrared DMD spectrometer based on the single-point indium gallium arsenide detector is designed, and the cost is only about 1/3 of that of a nearinfrared spectrometer with the linear array silicon detector. The near-infrared spectrometer based on DMD technology has a significant feature of miniaturization. In all, the DMD spectrometer used in this design has lowcost, powerful, practicality, miniaturization, highprecision, and convenient for portable quality testing equipment in the field of agriculture.
Shortwave near-infrared (700~1100nm) molecular vibration spectrum absorption is third and fourth or higher times harmony frequency, which has strong light penetration but weak absorption. While, long-wave nearinfrared (1000~2500nm) molecular vibration spectrum absorption is harmony frequency and second harmony frequency, which has strong absorption peaks. Besides, previous studies have shown that the colors of the surface and flesh of fruits and vegetables have significant effects on the detection accuracy in the short-wave near-infrared region, while the long-wave near-infrared spectrum is hardly affected.
With consideration of all the factors mentioned above, this study chooses the DLP2010NIR DMD module of Texas Instruments in the United States for system design. The internal optical path and signal transmission process in the device are shown in Figure 2. The diffusely reflected light from the sample enters the spectrometer through the slit, and then, passes through the collimating lens and the 900nm long-wave pass filter. Afterward, it is reflected by the diffraction grating and divided into light beams of several wavelengths, and then these beams are projected to the DMD through the focusing lens.
The InGaAs single-point detector is selected to obtain the photoelectric signal, with the semiconductor cooler to improve the accuracy and stability. Also, there is a focusing lens in front of the slit, which can effectively obtain the diffuse reflection light through the 2.5mm window. The spectral resolution and signal-to-noise ratio can be adaptable by adjusting the size of the slit. Through testing, it is found that the system can effectively obtain near-infrared spectra in the range of 900 to 1700 nm.

Miniature light source
In this design, the light source system is mainly composed of a low-power miniature light source and a front lens. Sealed in the quartz tube, the wire inside the light source is made of C-6 tungsten, with high electrode current density and low running voltage, which can radiate broadband near-infrared light. The L1005 front lens micro-precision light source made by ILT of the United States is selected, which can focus the light in a certain direction. Besides, the light intensity can be increased by 10 times. After optimizing the optical field distribution, including light intensity and illumination uniformity, the optical design can be applied to the portable device. From the details, the optical acquisition system operates in reflection mode, with the two light sources are arranged symmetrically. With the main axis of the light source and the incident slit plane are at an angle of 40 degrees, the light beam casts onto the surface of fruits and vegetables and enters the interior, and then the light is reflected and transmitted to the spectrometer.

Control and communication module
The DMD module in the portable near-infrared spectrum quality-detection device is the key to the accuracy. The DLPC150 microcontroller adopted in this system can realize precision control of the DLP2010NIR DMD. The signal of the single-point InGaAs detector passes through the low signal-to-noise ratio differential amplifier and the analog-to-digital converter of the serial peripheral interface, and finally to the embedded processor, as shown in Figure 2. The embedded processor is equipped with a low-energy Bluetooth module and a micro USB connector. Moreover, the dual communication mode is developed to meet the multi-functional needs of different users in the subsequent software development process.

Detection software design
To meet the demand of the portable device, a nearinfrared spectrum detection system based on ARM has been developed, of which the control software previously uses MFC developed in the Windows CE platform and Android platform. What's more, we also design and implement USB and Bluetooth interface based on communication, so that the performance of the device has been promoted and much easier to use. Using the method of multithreading programming technology, the device can reach the aim that can be used for detecting a variety of fruits and vegetables.

Persimmon quality-detection system
In this study, persimmon is selected as the research object to verify the performance of the designed portable nearinfrared spectrum system for fruits and vegetables quality identification. Many studies have shown that the enhancement of fruit and vegetable maturity leads to a decrease in their firmness [5] . Therefore, the maturity and quality of fruits and vegetables can be identified based on changes in firmness. With these considerations mentioned above, we choose firmness as an index to evaluate the quality of persimmons.
A total of 60 persimmon samples is tested, produced by a county persimmon agricultural cooperative in Shaanxi Province. According to the ratio of 2:1, the samples are divided into a training set and prediction set.
The spectrum data is collected by the spectrometer in the device. The distance between the bottom of the persimmon and the spectrometer is 30mm, and the irradiation time for each sample is 10s. The firmness is measured by the GY-1 fruit firmness tester.
The testing results are shown in Table 1. It is found the two sets of values are equivalent to the range, mean, and standard deviation, which demonstrates the process of the samples-selection is specification and scientific.

Collection and analysis of the infrared spectrum of persimmons
The parameters have been optimized in the portable nearinfrared spectrum quality-detection system. The wavelength range is set to 500~2500mm, and the spectral resolution is 4.68nm. The number of scan points is 500, and the number of scans is 3. The 60×500 spectrum matrix is obtained, after the spectrum of 60 samples is collected.
The measured spectral reflectance data is averaged, then converted into ASCII code, and then exported by ASD ViewSpec Pro software. After that, using the MATLAB software to perform principal component analysis. The useful signals of NIR spectroscopy are often mixed with a lot of noise information such as highfrequency random noise, light scattering signals, etc., which will cause interference with the relationship between the NIR spectra and the effective component content in the sample, and directly affect the robustness of the model. Based on the comparison of various spectral pre-processing methods, it is found that the standard normal variate transformation (SNV) pre-processing method can improve the stability of the model, for this method can eliminate the influence of light scattering on the surface and the change of the optical path on the diffuse reflected light signals.

Quality inspection model
In this study, the quality analysis model has established via the partial least square (PLS) method. And the accuracy of the model has appraised through verification of the correlation coefficient of calibration (Rc) and root mean squared error of prediction (RMSEP).
Six specific wavelengths (848nm, 998nm, 1141nm, 1329nm, 2123nm, and 2273nm) are collected through the principal component analysis used based on spectral bands. With the application of the models, the results reveal that the model established by the logarithm of the original absorption spectrum (1/R) and the PLS method is applicable, with a high correlation coefficient and low corrected root mean square error. As shown in Table 2 and Figure 4, the correlation coefficient is 0.9289, and the corrected root mean square error is 0.3914. Under the same conditions, the results calculated from the prediction sample are shown in Table 3 and Figure 5, and the correlation coefficient is 0.9537, and the corrected root mean square error is 0.3776.

Conclusion
The study indicates that the developed portable nearinfrared spectrum quality-detection device can realize the rapid and non-destructive detection of fruits and vegetables and the measurement results with high stability. This research can provide reference data for the design of low-cost, practical, and miniaturized near-infrared spectrum detection systems.
• Based on actual industrial needs of low-cost, practical, and miniaturization, an effective portable nearinfrared spectrum detection device is designed, and the software system is also developed. It is important to note that the combination of digital micromirror device and dot-matrix detectors significantly improve the precision, as well as reduce the cost. At the same time, the miniature light source and communication module are also optimized.
• The quality inspection model is established using the PLS method and the principal component analysis method.
From the results of the prediction set, the model established by the logarithm of the original absorption spectrum (1/R) and the PLS method is applicable, with a high correlation coefficient (0.9537) and low corrected root mean square error (0.3776).