Nondestructive detection method for black spots of hickory nut based on spatial offset near infrared spectrum
By using a spatially offset near-infrared spectroscopy method, the optimal spatial offset and spectral migration correction were determined, solving the accuracy and stability problems of non-destructive testing of black spots in pecans. This method enables rapid and accurate non-destructive testing, is applicable to existing instruments, and meets industrial needs.
Patent Information
- Application Number
- CN202511976299.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-03-17
AI Technical Summary
Existing technologies cannot achieve non-destructive detection of black spots inside pecans, and existing near-infrared spectroscopy detection is affected by the shell, resulting in low accuracy and failing to meet the needs of industrial production.
By using a spatially offset near-infrared spectroscopy method, the optimal spatial offset is determined, multi-position spectral migration correction is performed, and a shell-and-unshell spectral migration correction model is established to construct a binary classification detection model and achieve non-destructive testing.
It enables rapid, accurate, and non-destructive detection of black spots on pecans, is compatible with existing near-infrared spectrometers, meets the needs of industrial production, and reduces equipment modification costs.
Smart Images

Figure CN121678583A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of non-destructive testing methods for black spots on pecans, and in particular to a non-destructive testing method for black spots on pecans based on spatially offset near-infrared spectroscopy. Background Technology
[0002] Pecans, also known as small walnuts, are a high-end nut variety. Their kernels are rich in unsaturated fatty acids, protein, and various trace elements, and their unique crisp and crunchy texture makes them highly popular with consumers and gives them significant economic value. However, during the growth, harvesting, storage, and processing of pecans, they are susceptible to fungal infection, which can cause black spots inside the kernel. These black spots result in a bitter taste, loss of nutrients, and severely reduce the commercial quality and safety of pecans.
[0003] Currently, the detection of black spots inside pecans faces two major challenges: First, the black spot defect is located inside the kernel, and the hard shell of an intact pecan obstructs visual identification. Confirmation can only be achieved through visual observation after cracking the shell or through laboratory physicochemical analysis (such as microbial culture and component analysis). However, cracking the shell is a destructive operation, making batch testing impossible. Furthermore, laboratory testing procedures are cumbersome and time-consuming, failing to meet the rapid testing needs of industrial production. Second, while existing near-infrared spectroscopy non-destructive testing technology is widely used in agricultural product quality testing, the spectral information from the pecan shell severely interferes with the kernel's spectral signal, resulting in indistinct black spot features in the spectral data and low detection accuracy. In addition, existing technologies do not consider the impact of the pecan's posture and position, and the spatial offset of the measurement point on spectral acquisition—differences in shell thickness and the distance between the kernel and the probe under different postures can lead to different spectral data for the same pecan, further reducing detection stability. Summary of the Invention
[0004] To address the technical problems mentioned in the background art, the present invention provides a non-destructive detection method for black spots in pecans based on spatially offset near-infrared spectroscopy.
[0005] The technical solution adopted in this invention is: a non-destructive detection method for black spots in pecans based on spatially shifted near-infrared spectroscopy, characterized by the following steps: Step 1: Prepare pecan samples and collect spectra; Step 2: Determine the optimal spatial offset; Step 3: Multi-position spectral migration correction to the optimal offset; Step 4: Shell-to-shell spectral migration correction and final detection model establishment; Step 5: Unknown sample detection.
[0006] In one embodiment, step 1 is specifically as follows: Select n hickory nut samples that are uniform in size and have no damage to their appearance, covering different degrees of black spots and normal samples, and number them 1-n; Six standard posture positions for hickory nuts are defined: based on the plane where the largest diameter of the hickory nut shell is located, they are "face up", "face down", "side tilted 90° to the left", "side tilted 90° to the right", "top face up", and "bottom face up". At room temperature, using a near-infrared spectrometer, spectra were collected from five measurement points sequentially from bottom to top for each pose of each sample. Each measurement point was recorded three times, and the average value was taken to form a three-dimensional raw spectral dataset S representing the "sample-pose-measurement point" sequence. i i = 1~6; the 5 measurement points are measurement point 1, measurement point 2, measurement point 3, measurement point 4, and measurement point 5. The distance of each measurement point from the bottom of the hickory nut is denoted as D. i, i = 1~5; After the spectral acquisition was completed, all samples were broken open and divided into "normal samples" and "black spot samples" by visual observation. The actual position of the black spot in the black spot sample was recorded, and the spectral data corresponding to the posture of "black spot at the bottom" was selected to form the initial dataset S0.
[0007] In one embodiment, step 2 is specifically as follows: Taking the spectra of 5 measurement points for each sample in dataset S0 as the object, calculate the spectral offset of measurement points 2-5 relative to measurement point 1. The offset calculation formula is ΔD=|D i -D1|;i=2~5,D i Let be the relative height of the light source at the i-th measurement point; Construct a binary classification machine learning model with "measurement point-offset-spectral data" as input and sample class label Y as output. Train classification models corresponding to 5 measurement points respectively, and calculate the accuracy, precision, and recall of each model. The measurement point corresponding to the model with the best classification performance is selected as the optimal measurement point, and its corresponding offset is denoted as the optimal spatial offset Δ. opt .
[0008] In one embodiment, step 3 is specifically as follows: With optimal spatial offset Δ opt Using the corresponding spectrum as a benchmark, a transfer correction matrix T1 is established using partial least squares regression. The spectral data of the other four measurement points in dataset S0 are used as input X, and the spectral data of the optimal measurement point is used as output Y for model training. By using the migration correction matrix T1, the spectral data of all measurement points in the original spectral dataset S0 are migrated to the optimal spatial offset Δ. optThe corresponding spectral dimensions yield the uniformly offset spectral dataset S. All ; For S All The spectral data of the five measurement points of each sample are averaged to obtain the uniformly offset average spectrum Savg for each sample.
[0009] In one embodiment, step 4 is specifically as follows: Near-infrared spectra of kernels were collected from n samples after shelling: the kernels were crushed, passed through a 60-mesh sieve, and pressed into thin sheets with a thickness of 2 mm. Spectra were collected using the same spectrometer parameters as in step 1 to obtain the shell-free spectral dataset S. Dhell-free ; With S Dhell-free For the target spectrum, S avg For the input spectrum, a shelled-unshelled spectrum transfer correction model is established using domain-adaptive transfer learning. The domain difference between the shelled and unshelled spectra is minimized through adversarial training, and the transfer correction matrix T2 is obtained through training. S avg The simulated shell-free spectrum S was obtained through T2 migration correction. Dim ; With S Dim Using Y as input and sample category label Y as output, a binary classification model is trained to obtain the final detection model M for pecan black spots.
[0010] In one embodiment, step 5 is specifically as follows: For pecan samples with unknown defects, spectra are collected in the manner described in step 1. After being corrected by migration correction matrices T1 and T2 in sequence, simulated shell-free spectra are obtained and input into the final detection model M. The output sample category is either "normal Y=0" or "black spot Y=1".
[0011] In one embodiment, the binary classification machine learning model is a support vector machine or a random forest model.
[0012] The beneficial effects of this invention are as follows: Compared with the prior art, this invention standardizes sample screening and acquisition criteria in the sample preparation and spectral acquisition stages, ensuring data representativeness and consistency, and solving the deviation problem caused by differences in traditional detection samples; the optimal spatial offset determination accurately locks the core detection benchmark, eliminates interference from inconsistent spectra at multiple measurement points, and improves data reliability; multi-position spectral migration correction achieves multi-pose, multi-measurement point spectral standardization, freeing it from the limitations of sample placement and measurement position, and solving the detection instability problem caused by spatial offset; shell-to-shell-less spectral migration correction uses advanced technology to remove spectral interference from the shell, highlighting the black spot characteristics of the kernel, avoiding the destructive nature of traditional shell-breaking detection, and solving the problem of indistinct features caused by shell occlusion; unknown sample detection relies on standardized processes and high-precision models to achieve rapid and non-destructive detection, without the need for special equipment to adapt to existing instruments, solving the drawbacks of traditional detection processes being cumbersome, time-consuming, and unable to perform batch detection, and meeting the needs of industrial production. Attached Figure Description
[0013] Fig. 1 This is a flowchart illustrating the present invention; Fig. 2 This is a schematic diagram of the six standard posture positions of the walnut in this invention, with the reference plane and measurement point distribution of each posture marked. Detailed Implementation
[0014] In the description of this invention, it should be noted that the terms "front", "up", "down", "left", "right", "vertical", "horizontal", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0015] refer to Figs. 1-2 To address the problems existing in the background technology, this application proposes the following technical solution: a non-destructive detection method for black spots in pecans based on spatially offset near-infrared spectroscopy, as detailed below: (a) Experimental equipment and samples; Near-infrared spectrometer: NIR17D type near-infrared spectrometer, wavelength range 900~1700nm, resolution 10nm, integration time 100ms; Pecan samples: 300 "Changhua pecans" from Lin'an, Zhejiang Province were selected, including 150 normal samples and 150 samples with black spots (the black spot area was 5%~30%, and all were confirmed to be infected with Fusarium by microbial testing); Auxiliary equipment: electronic vernier caliper (accuracy 0.01mm), high-speed pulverizer (speed 12000r / min), tablet press (pressure 5MPa).
[0016] (II) Specific steps for implementation: Step 1: Sample preparation and spectral acquisition; Step 1.1: Select n (n≥300) hickory walnut samples of uniform size and without damage, covering different degrees of black spots and normal samples, and number them from 1 to n; Step 1.2, define 6 standard posture positions of the hickory: based on the plane where the maximum diameter of the hickory shell is located, they are "face up", "face down", "side tilted 90° to the left", "side tilted 90° to the right", "top face up" and "bottom face up"; Step 1.3: Under room temperature (25℃±2℃, relative humidity 40%±5%), a near-infrared spectrometer (wavelength range 900~1700nm) was used to collect the spectra of 5 measurement points sequentially from bottom to top for each pose of each sample. The spectra of each measurement point were collected 3 times and the average value was taken to form a three-dimensional raw spectral dataset S of "sample-pose-measurement point". i i = 1~6; the 5 measurement points are measurement point 1, measurement point 2, measurement point 3, measurement point 4, and measurement point 5. The distance of each measurement point from the bottom of the hickory nut is denoted as D. i, i = 1~5; the 5 measurement points are measurement point 1 (3mm from the bottom of the hickory), measurement point 2 (the middle between measurement point 1 and measurement point 3), measurement point 3 (the middle), measurement point 4 (the middle between measurement point 3 and measurement point 5), and measurement point 5 (3mm from the top of the hickory). Step 1.4: After the spectral acquisition is completed, all samples are broken open and the samples are divided into "normal samples" (category label Y=0) and "black spot samples" (black spot area ≥5%, category label Y=1) by visual observation. The actual position of the black spot is recorded and the spectral data corresponding to the posture of "black spot at the bottom" is selected to form the initial dataset S0.
[0017] The above technical solution is explained as follows: This step provides high-quality basic data for subsequent detection by standardizing sample screening, posture definition, spectral acquisition, and data screening processes. ≥300 uniformly sized, undamaged samples are screened, covering different degrees of black spots and normal samples to ensure data representativeness; six standard postures are defined to eliminate the influence of placement differences on detection; spectra are acquired at fixed measurement points and environmental parameters, repeated three times, and the average value is taken to improve data stability, forming a three-dimensional raw spectral dataset D0; after shell breakage classification, specific posture data are selected to form D1, accurately focusing on effective information.
[0018] Significant benefits are achieved: First, the comprehensive and standardized sample coverage avoids detection bias caused by sample differences, providing sufficient and high-quality data sources for model training and ensuring subsequent detection accuracy. Second, fixed posture and measurement point acquisition standardize the operation process, reduce human error, and make the spectral data comparable and consistent. Third, repeated acquisition, averaging, and data screening reduce interference from random factors, highlight the spectral characteristics related to the black spot, lay a reliable foundation for subsequent offset determination and model construction, and effectively improve the stability and accuracy of the overall detection process.
[0019] Step 2: Determine the optimal spatial offset; Step 2.1: Taking the spectra of the five measurement points of each sample in dataset S0 as the object, calculate the spectral offset of measurement points 2-5 relative to measurement point 1. The offset calculation formula is ΔD=|D i -D1|;i=2~5,D i Let be the relative height of the light source at the i-th measurement point; Step 2.2: Construct a binary classification machine learning model. With "measurement point-offset-spectral data" as input and sample category label Y as output, train the classification model corresponding to the 5 measurement points respectively, and calculate the accuracy, precision, and recall of each model. Step 2.3: Select the measurement point corresponding to the model with the best classification performance as the optimal measurement point, and denote the corresponding offset as the optimal spatial offset Δ. opt .
[0020] The above technical solution is explained as follows: This step involves calculating the spectral offset and training a classification model to select the optimal measurement points and their corresponding offsets. Taking the sample spectra in D1 as the object, the offsets of measurement points 2-5 relative to measurement point 1 are calculated using the formula; a binary classification model is constructed, and the models corresponding to the five measurement points are trained respectively. Based on indicators such as accuracy, precision, and recall, the optimal measurement points and their corresponding optimal spatial offsets Δ that meet the performance standards are selected. opt .
[0021] The beneficial effects are significant: First, by quantifying the spectral offset, the spectral differences between different measurement points are clearly defined, providing a clear target for subsequent correction; second, the optimal offset is selected based on the performance of the classification model, ensuring that the selected offset can highlight the black spot features to the greatest extent, making subsequent detection more targeted; third, the determination of the optimal offset effectively solves the problem of inconsistent spectral data caused by spatial offset of different measurement points, improves the reliability of spectral data, provides a core benchmark for unified correction of multi-location spectra, and indirectly improves the classification performance of the final detection model.
[0022] Step 3: Multi-position spectral migration correction to the optimal offset; Step 3.1, with the optimal spatial offset Δ optUsing the corresponding spectrum as a benchmark, a transfer correction matrix T1 is established using partial least squares regression. The spectral data of the other four measurement points in dataset S0 are used as input X, and the spectral data of the optimal measurement point is used as output Y for model training. Step 3.2: Using the migration correction matrix T1, the spectral data of all measurement points in the original spectral dataset S0 are migrated to the optimal spatial offset Δ. opt The corresponding spectral dimensions yield the uniformly offset spectral dataset S. All ; Step 3.3: Average the spectral data of each sample in D2 across 6 poses and 5 measurement points to obtain the uniformly offset average spectrum D for each sample. avg .
[0023] The above technical solution is explained as follows: This step uses the spectrum corresponding to the optimal spatial offset as a benchmark, and uses partial least squares regression to establish a migration correction matrix T1. The spectra of all measurement points in D0 are migrated to the optimal offset dimension, resulting in a dataset D2 with a unified offset. Then, the spectral data of each sample are averaged to obtain the average spectrum D after the unified offset. avg .
[0024] Significant benefits are achieved: First, by using the migration correction matrix, unified standardization of multi-position and multi-pose spectral data is realized, eliminating spatial offset interference caused by attitude and measurement points, and ensuring consistency of spectra acquired under different conditions; second, averaging of spectral data further reduces random errors, strengthens the core spectral features of samples, and improves data quality; third, the corrected spectral data is freed from the limitations of attitude and measurement points, enhancing the adaptability of the detection method, making subsequent model training unaffected by sample placement and measurement location, and improving the stability and versatility of the detection method.
[0025] Step 4: Shell-to-shell spectral migration correction and final detection model establishment; Step 4.1: Collect near-infrared spectra of kernels from n samples after shelling: Crush the kernels and pass them through a 60-mesh sieve, then press them into uniform thin sheets with a thickness of 2 mm. Collect the spectra using the same spectrometer parameters as in Step 1.3 to obtain the shell-free spectral dataset D. Dhell-free ; Step 4.2, with S Dhell-free For the target spectrum, S avg For the input spectrum, a shelled-unshelled spectrum transfer correction model is established using domain-adaptive transfer learning. The domain difference between the shelled and unshelled spectra is minimized through adversarial training, and the transfer correction matrix T2 is obtained through training. Step 4.3, D avg The simulated shell-free spectrum D was obtained through T2 migration correction. Dim ; Step 4.4, with SDim Using Y as input and sample category label Y as output, a binary classification model is trained to obtain the final detection model M for pecan black spots.
[0026] The above technical solution is explained as follows: This step first collects the shell-free spectral dataset D of kernels after they have broken open. Dhell-free Then, domain-adaptive transfer learning is used to establish a shelled-unshelled spectral transfer correction model, and the matrix T2 is obtained through training. avg Corrected to simulated shell-free spectrum D Dim Finally, D Dim Use the input to train a binary classification model and construct the final detection model M.
[0027] The beneficial effects are significant: First, by establishing a calibration model through transfer learning, the interference of the shell spectrum on the kernel spectrum is effectively eliminated, the interference rate is greatly reduced, the black spot characteristics of the kernel are highlighted, and the sensitivity of black spot recognition is improved; Second, simulating the shell-less spectrum retains the key information of the kernel while avoiding the destructive nature of shell-breaking detection, thus meeting the core requirement of non-destructive testing; Third, the detection model trained based on the simulated shell-less spectrum has higher classification accuracy, providing strong model support for subsequent rapid and accurate detection, and ensuring the reliability and accuracy of the detection results.
[0028] Step 5: Unknown sample detection.
[0029] For pecan samples with unknown defects, spectra are collected in steps 1.2 to 1.3. After being corrected by migration correction matrices T1 and T2 in sequence, simulated shell-free spectra are obtained and input into the final detection model M. The output sample category is "normal (Y=0)" or "black spot (Y=1)".
[0030] Binary classification machine learning models include support vector machines or random forest models.
[0031] This method does not require customized special light sources or equipment and can be adapted to existing commercial near-infrared spectrometers. The detection time for a single sample is ≤10 seconds, and the batch detection efficiency reaches 1000 samples / hour. Compared with traditional methods, it not only improves the detection accuracy but also the precision.
[0032] The above technical solution is explained as follows: In this step, the spectrum of the pecan sample with unknown defects is collected according to the standard procedure, and the simulated shell-free spectrum is obtained by T1 and T2 correction in sequence. The spectrum is then input into the final detection model M, and the sample category (normal or black spot) is output.
[0033] The beneficial effects are significant: First, the testing process is highly standardized and automated, with a single sample testing time of ≤10 seconds and a batch testing efficiency of 1000 samples / hour, meeting the needs of industrial batch screening and greatly improving testing efficiency; second, the test results are accurate and reliable, effectively reducing misjudgments; third, no special equipment needs to be customized, and it is compatible with existing commercial near-infrared spectrometers, reducing the equipment modification costs for enterprises. It can be widely used in pre-harvest screening and post-harvest grading of hickory nuts, and has strong practical value and promotion significance.
[0034] The specific steps for the experimental example are as follows: Step 1: Spectral acquisition and sample classification; Step 1.1: Number the 300 samples from 1 to 300, and use an electronic vernier caliper to measure the maximum diameter of each sample (1.8~2.2cm) to ensure uniform size; Step 1.2: Fix the sample in 6 postures: "face up", "face down", "side tilt 30° to the left", "side tilt 30° to the right", "top face up" and "bottom face up". Collect the spectrum of 5 measurement points from bottom to top in each posture. Repeat each measurement point 3 times and take the average value. Step 1.3: After breaking the shell, observe with the naked eye and use the colony counting method (GB4789.2-2022) to mark Y=0 (normal, 150 colonies) and Y=1 (black spots, 150 colonies). Select the spectrum corresponding to the posture where "black spots are located at the bottom" to form S0.
[0035] Step 2: Determine the optimal spatial offset; Step 2.1: Calculate the spectral offset ΔD of each sample measurement point 2~5 in D relative to measurement point 1, and construct 5 sets of input data (spectral data of measurement points 1~5 + offset); Step 2.2: A Support Vector Machine (DVM) is used as the binary classification model. The training set (210 samples) and the test set (90 samples) are divided in a 7:3 ratio. A classification model with 5 measurement points is trained. The performance on the test set is as follows: Step 2.3: The model performance of measurement point 2 is optimal, and its corresponding offset is determined as the optimal spatial offset Δ. opt .
[0036] Step 3, multi-location spectral migration correction; Step 3.1: Using the spectrum of measurement point 2 as a reference, train the transfer correction matrix T (dimension 1500x1500) using PLDR; the goodness of fit of the training set R2=0.982, and the root mean square error RMDE=0.008; Step 3.2: Correct the spectra of all measurement points (6 attitudes x 5 points) and calculate the similarity (cosine similarity ≥ 0.97) between the corrected spectra of each measurement point and the spectrum of measurement point 2. Step 3.3: Take the average of the 6x5 corrected spectra for each sample.
[0037] Step 4, Shell-to-shell spectral migration correction and model training; Step 4.1: After cracking the shell, remove the kernels, crush them through a 60-mesh sieve, press them into tablets (2mm thick), and collect the shell-free spectrum S. Dhell-free (300x1500); Step 4.2: Train a shelled-to-unshelled transfer correction model using DANN, setting the domain loss weight α=0.3. After 100 training rounds, the domain difference loss decreases to 0.015, S avg S after T correction Dim With S Dhell-free The overlap of characteristic peaks is ≥96%; Step 4.3, with S Dim With Y as input and Y as output, the DVM model M is trained, achieving an accuracy of 96.7%, precision of 95.8%, recall of 97.1% on the test set, and an area under the ROC curve (AUC) of 0.985.
[0038] Step 5, Unknown sample detection and verification; Fifty unknown samples were selected (25 normal and 25 black spots). Spectra were collected according to steps 1.2-1.3. After T1 and T2 correction, the spectra were input into model M. The detection results are as follows: 48 samples were correctly identified, with an accuracy of 96%, and 2 samples were misidentified (1 normal sample was misidentified as a black spot and 1 black spot sample was misidentified as normal), which meets the requirements of industrial testing.
[0039] In summary, this embodiment, through standardized sample preparation and multi-dimensional spectral acquisition, ensures data representativeness and consistency from the source by standardizing sample screening criteria, defining fixed postures and measurement points, and conducting spectral acquisition and screening under unified environmental conditions. This avoids detection bias caused by sample differences and non-standard operations, laying a solid data foundation for subsequent analysis. The optimal spatial offset determination step accurately identifies spectral differences between different measurement points and combines this with classification model performance to screen core benchmarks, effectively solving the spectral inconsistency problem caused by multi-location measurements. This makes the detection direction more targeted and improves the reliability and practicality of spectral data. The multi-location spectral migration correction step utilizes professional algorithms to establish a correction model, achieving unified and standardized processing of multi-posture, multi-measurement point spectral data. This eliminates spatial offset interference, strengthens the core spectral characteristics of the sample, and frees the detection method from the limitations of sample placement and measurement location, significantly enhancing adaptability and stability. The shell-and-shell-less spectral transfer correction and detection model construction steps effectively eliminate the interference of the shell spectrum on the kernel signal through advanced transfer learning technology, highlighting the black spot feature information. This retains key kernel detection indicators while avoiding the destructive nature of shell-breaking detection, perfectly meeting the core requirements of non-destructive testing. Simultaneously, a high-precision classification model is built, providing strong algorithmic support for accurate detection. The unknown sample detection stage relies on standardized procedures and optimized models to achieve efficient and rapid detection without the need for customized special equipment. It is compatible with existing commercial instruments, significantly reducing the cost of equipment modification for enterprises. It can be widely applied to various scenarios such as pre-harvest screening and post-harvest grading of pecans, completely solving the problems of low efficiency, poor accuracy, and cumbersome operation of traditional detection methods.
[0040] Although embodiments of the invention have been shown and described, the scope of the invention will be defined by the appended claims and their equivalents by those skilled in the art.
Claims
1. A method for non-destructive detection of black spot in pecan based on spatially offset near infrared spectroscopy, characterized in that, Specifically comprising the following steps: Step 1: Perform sample preparation and spectrum acquisition of hickory nuts; Step 2: Determine the optimal spatial offset; Step 3: Correct the multi-position spectrum to the optimal offset; Step 4: Shell-no shell spectrum migration correction and final detection model establishment; Step 5: Unknown sample detection.
2. The method for nondestructive detection of hickory black spots based on spatial offset near-infrared spectroscopy according to claim 1, characterized in that, Step 1 is specifically as follows: Select n hickory samples of uniform size and appearance without damage, covering different black spot levels and normal samples, numbered 1-n; Define six standard attitude positions of hickory nuts: with the plane of the maximum diameter of the hickory nut shell as the reference, they are "front up", "front down", "side left tilt 90°", "side right tilt 90°", "top up", and "bottom up"; At room temperature, using near infrared spectrometer, the spectrum of each sample in each posture is collected from bottom to top in turn, 5 measuring points, each measuring point is repeated 3 times and the average value is taken to form a "sample-posture-measuring point" three-dimensional original spectrum data set S i , i = 1~6; 5 measuring points are measuring point 1, measuring point 2, measuring point 3, measuring point 4, measuring point 5, and the distance from the bottom of the hickory is recorded as D i, i = 1~5; After spectrum acquisition, break the shells of all samples, and divide the samples into "normal samples" and "black spot samples" by visual observation, record the actual position of the black spot, select the spectrum data corresponding to the attitude of "black spot at the lowest edge", and form an initial data set S0.
3. The method of claim 2, wherein the method is a non-destructive method for detecting black spot of pecan based on spatially offset near infrared spectroscopy. Step 2 is specifically as follows: With the 5-measurement-point spectrum of each sample in the dataset S0 as the object, the spectral offset of measurement points 2-5 relative to measurement point 1 is calculated, and the offset calculation formula is ΔD=|D i - D1|; i = 2 ~ 5, D i is the relative height of the light source of the i-th measurement point; Construct a binary classification machine learning model, with "measurement point-offset-spectrum data" as input and sample category label Y as output, train five classification models corresponding to each measurement point, and calculate the accuracy, precision, and recall of each model; The measurement point corresponding to the model with the best classification performance is selected as the optimal measurement point, and the offset corresponding thereto is denoted as the optimal spatial offset Δ opt .
4. The method of claim 3, wherein the method is a non-destructive method for detecting black spot of pecan based on spatially offset near infrared spectroscopy. Step 3 is specifically as follows: with the optimal spatial offset Δ opt With the corresponding spectrum as the reference, the partial least squares regression is used to establish the migration correction matrix T1, and the spectral data of the other four measuring points in the data set S0 are taken as the input X and the spectral data of the optimal measuring point are taken as the output Y to train the model. By means of the migration correction matrix T1, the spectral data of all measurement points in the original spectral data set S0 are migrated to the optimal spatial offset Δ opt The unified offset spectral data set S is obtained for the corresponding spectral dimension All ; S All The 5 measurement point spectral data of each sample is averaged to obtain the uniform offset average spectrum Savg of each sample.
5. The method of claim 4, wherein the method is a non-destructive method for detecting black spot of pecan based on spatially offset near infrared spectroscopy. Step 4 is specifically as follows: Collecting near infrared spectrum of the kernel of the n samples after breaking the shell: crushing the kernel, passing through a 60-mesh sieve, and compressing into a 2-mm-thick sheet, collecting the spectrum using the same spectrometer parameters as in step 1 to obtain the spectrum data set S of the kernel without shell Dhell-free ; S Dhell-free avg With S as the target spectrum and S as the input spectrum, a shell-no shell spectrum transfer correction model is established by domain adaptive transfer learning, and a transfer correction matrix T2 is trained by minimizing the domain difference between the shell spectrum and the no shell spectrum through adversarial training. S avg By T2 migration correction, get the simulated shell-free spectrum S Dim ; S Dim As input, the sample category label Y is output, and the binary classification model is trained to obtain the final detection model M of black spot of hickory.
6. The method of claim 5, wherein the method is a non-destructive method for detecting black spot of pecan based on spatially offset near infrared spectroscopy. Step 5 is specifically as follows: For unknown defective hickory samples, collect spectra in the manner of step 1, and sequentially correct the simulated shell-free spectrum by migration correction matrices T1 and T2, then input into the final detection model M, and output the sample category as "normal Y=0" or "black spot Y=1".
7. A method for non-destructive detection of black spot in pecan nuts based on spatially offset near infrared spectroscopy according to any one of claims 1 to 6, characterized in that, The binary classification machine learning model is a support vector machine or a random forest model.