Database-driven spectral recognition method, apparatus, device, and medium
By establishing a database-driven spectral recognition method, baseline and scattering corrections are performed for the particle size levels of the cargo, and real-time spectra are aligned based on the reference spectrum to extract and stitch spectral features. This solves the problem of inaccurate foreign object recognition in cargo and achieves high accuracy and stable foreign object recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-10
AI Technical Summary
Existing foreign object identification methods suffer from inaccurate identification of foreign objects in cargo, especially low-density foreign objects and foreign objects with similar colors, resulting in missed or false detections of foreign objects.
By establishing a database, the types and real-time spectra of the goods to be inspected are obtained. Baseline correction and scattering correction are performed according to particle size levels. The real-time spectrum is aligned with the reference spectrum, peak features are extracted, and the absorbance ratio of key component bands is calculated. The spectral features are then spliced together to identify foreign objects.
It significantly improves the accuracy and stability of foreign object identification, adapts to various goods and dynamic detection needs, and can accurately identify foreign objects such as stones and weed seeds.
Smart Images

Figure CN121558652B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of spectral image processing, and in particular to a database-driven spectral recognition method, device, equipment and medium. BACKGROUND
[0002] In the production and transportation process of goods (such as grain), foreign matter often mixes in it. The conventional foreign matter recognition method is to recognize foreign matter by artificial visual recognition. This method has the disadvantages of heavy workload, strong subjectivity, low efficiency, high professional experience requirement, harm to human health, etc.
[0003] The existing intelligent foreign matter recognition methods mainly include x-ray method and computer vision method. The x-ray detection method is a method for detecting foreign matter by using the property that x-rays will produce different reflection intensities when passing through objects with different densities. When there is a difference between the density of the food itself and the foreign matter, the transmittance will also be different. This difference can be reflected on the image with different gray values. Using this method, high-density foreign matter detection can be realized. However, it has poor detection effect on low-density foreign matter with low absorption, such as plastic and silica gel. The computer vision detection method mainly uses the color difference between foreign matter and goods, combined with image segmentation technology to realize foreign matter detection, and has the advantages of fast non-destructive and easy online, and has been widely used in the detection of foreign matter and defects on the surface of goods. However, this method is highly dependent on the high color difference between foreign matter and background. When the color of foreign matter is similar to or the same as the background, the computer vision detection method greatly reduces the detection effect, cannot accurately segment low-color-difference foreign matter and background, and leads to foreign matter missed detection and false detection. SUMMARY
[0004] The embodiments of the present application provide a database-driven spectral recognition method, device, equipment and medium to solve the problem of inaccurate foreign matter recognition in existing methods.
[0005] In a first aspect, the embodiments of the present application provide a database-driven spectral recognition method, comprising:
[0006] obtaining the type and real-time spectrum of the to-be-detected goods;
[0007] According to the type, querying the particle size grade, key component waveband and reference spectrum of the to-be-detected goods from a preset database;
[0008] According to the particle size grade, performing baseline correction and scattering correction on the real-time spectrum, and aligning the real-time spectrum according to the reference spectrum;
[0009] extracting peak features from the real-time spectrum, calculating the absorbance proportion relationship of the key component waveband, and performing feature splicing on the peak features and the absorbance proportion relationship of the key component waveband to obtain spectral features;
[0010] Identify the foreign matter in the to-be-detected goods based on the spectral characteristics.
[0011] In a possible implementation, the real-time spectrum is baseline corrected according to the particle size level, including:
[0012] According to the particle size level, the window size range of the airPLS algorithm is determined; wherein the window size range is positively correlated with the particle size level;
[0013] For each window size in the window size range, the airPLS algorithm is run respectively to fit the baseline and subtract the baseline from the real-time spectrum, so as to obtain a plurality of corrected real-time spectrums;
[0014] According to the baseline flatness and the feature peak retention rate of each corrected real-time spectrum, the optimal corrected real-time spectrum is determined from the corrected real-time spectrums.
[0015] In a possible implementation, the optimal corrected real-time spectrum is determined from the corrected real-time spectrums according to the baseline flatness and the feature peak retention rate of each corrected real-time spectrum, including:
[0016] From the corrected real-time spectrums, the real-time spectrum with the feature peak retention rate greater than a preset feature peak retention rate threshold is determined;
[0017] From the real-time spectrum with the feature peak retention rate greater than the preset feature peak retention rate threshold, the real-time spectrum with the minimum baseline flatness is determined as the optimal corrected real-time spectrum.
[0018] In a possible implementation, the real-time spectrum is scatter corrected according to the particle size level, including:
[0019] A preset scatter correction algorithm corresponding to the particle size level is determined; wherein the preset scatter correction algorithm includes: a standard normal variable transformation algorithm, a multivariate scatter correction algorithm, and a hybrid algorithm of standard normal variable transformation + multivariate scatter correction;
[0020] The real-time spectrum is scatter corrected according to the preset scatter correction algorithm.
[0021] In a possible implementation, the particle size level includes: small particles, medium particles and large particles;
[0022] The preset scatter correction algorithm corresponding to the particle size level is determined, including:
[0023] If the particle size level is small particles, the preset scatter correction algorithm corresponding to the particle size level is determined as the standard normal variable transformation algorithm;
[0024] If the particle size level is a medium particle, the preset scattering correction algorithm corresponding to the particle size level is determined as a hybrid algorithm;
[0025] If the particle size level is a large particle, the preset scattering correction algorithm corresponding to the particle size level is determined as a multiple scattering correction algorithm.
[0026] In a possible implementation, the determining of the preset scattering correction algorithm corresponding to the particle size level further includes:
[0027] If the preset scattering correction algorithm corresponding to the particle size level is determined as the hybrid algorithm, the weight of the standard normal variable transformation and the multiple scattering correction in the hybrid algorithm is determined according to the average particle size of the to-be-detected cargo.
[0028] The weight of the standard normal variable transformation is negatively correlated with the average particle size, the weight of the multiple scattering correction is positively correlated with the average particle size, and the sum of the weights of the standard normal variable transformation and the multiple scattering correction is 1.
[0029] In a possible implementation, the aligning of the real-time spectrum to the reference spectrum includes:
[0030] The spectral similarity between each wavelength point in the real-time spectrum and each wavelength point in the reference spectrum is calculated to obtain a similarity comparison table.
[0031] According to the similarity comparison table, an optimal matching path of the wavelength points of the real-time spectrum and the reference spectrum is found within a preset size of a matching window constraint.
[0032] Based on the optimal matching path of the wavelength points, the real-time spectrum is stretched or compressed.
[0033] In a possible implementation, before the absorbance proportion relationship of the key component waveband is extracted from the real-time spectrum, the method further includes:
[0034] The actual water content of the to-be-detected cargo is obtained, and a water content-spectrum offset correlation model corresponding to the to-be-detected cargo is queried from the database.
[0035] Based on the actual water content and the water content-spectrum offset correlation model, the offset amount of the real-time spectrum is determined, and the intensity of the real-time spectrum is corrected according to the offset amount.
[0036] In a second aspect, an embodiment of the present application provides a database-driven spectrum recognition device, which includes:
[0037] The acquisition module is configured to acquire the category of the to-be-detected cargo and the real-time spectrum.
[0038] The query module is configured to query the particle size level, the key component waveband, and the reference spectrum of the to-be-detected cargo from the preset database according to the category.
[0039] a correction module, configured to perform baseline correction and scattering correction on the real-time spectrum according to the particle size level, and perform alignment on the real-time spectrum according to the reference spectrum;
[0040] a recognition module, configured to extract peak features from the real-time spectrum, calculate absorbance proportional relationships of key component wavebands, splice the peak features and the absorbance proportional relationships of the key component wavebands to obtain spectrum features, and recognize foreign matters in the to-be-detected goods based on the spectrum features.
[0041] In a third aspect, an electronic device is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the method in the first aspect or any possible implementation manner of the first aspect when executing the computer program.
[0042] In a fourth aspect, a computer readable storage medium is provided, storing a computer program, and the computer program implementing the method in the first aspect or any possible implementation manner of the first aspect when executed by a processor.
[0043] In a fifth aspect, a computer program product is provided, including a computer program, and the computer program implementing the method in the first aspect or any possible implementation manner of the first aspect when executed by a processor.
[0044] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0045] The embodiments of the present application pre-establish a database of various goods, quickly match the particle size level, component features and reference spectrum of the to-be-detected goods, perform exclusive baseline correction and scattering correction on the particle size level, effectively offset the spectral interference caused by the heterogeneity of the particles of the goods, reduce the masking of the features of foreign matters by baseline drift and uneven scattering, perform spectral alignment based on the reference spectrum, eliminate the length difference of the spectrum and the stretching / compression deformation of the feature peaks caused by the fluctuation of the flow speed of the goods, avoid the misjudgment of foreign matters due to the distortion of the shape, extract the peak features from the real-time spectrum, calculate the absorbance proportional relationships of the key component wavebands, splice the spectrum features, and strengthen the feature difference between the main body of the goods and the foreign matters, thereby greatly improving the discrimination degree of the recognition of foreign matters. The embodiments of the present application significantly improve the accuracy and stability of the recognition of foreign matters, and adapt to the actual application requirements of multiple goods and dynamic detection. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 is an implementation flowchart of the database-driven spectral recognition method provided by the embodiments of the present application;
[0047] Figure 2is a structural schematic diagram of a database-driven spectrum recognition device provided by an embodiment of the present application;
[0048] Figure 3 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0049] In the following description, for the purpose of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
[0050] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0051] The embodiments of the present application provide a database-driven spectrum recognition method, which is especially suitable for the detection of grains. The method can accurately identify stones, weed seeds, moldy particles and other foreign matters in grains through a closed-loop process of data acquisition-preprocessing-database construction-feature modeling-matching recognition.
[0052] Referring to Figure 1 FIG. 1 shows an implementation flowchart of a database-driven spectrum recognition method provided by an embodiment of the present application, and is described in detail as follows:
[0053] In step S101, the type and real-time spectrum of the goods to be detected are acquired.
[0054] Here, the type of the goods to be detected can be input by a worker, such as wheat, corn, etc. It can also be captured by a synchronous image acquisition system, which captures the features such as the shape and color of the grain particles, and preliminarily determines the type in combination with a simple algorithm. The embodiments of the present application do not limit this.
[0055] In the present embodiment, the goods can be conveyed by a conveyor belt, a rack is placed on the conveyor belt, and a hyperspectral camera is mounted on the rack to acquire the data of the goods flow on the conveyor belt. The hyperspectral camera acquires data in an external push-scan manner, and obtains the spectral data of a column of pixel points in each frame. The hyperspectral camera only scans a line with the same width as the range of the view angle, and the conveyor belt moves at a constant speed below. The product of the moving speed of the conveyor belt and the acquisition time is the actual length of the image acquisition range. Thus, when the image data is acquired, the hyperspectral image data in the image acquisition range surrounded by the length and the width of the range of the view angle can be obtained. The hyperspectral image data contains all component information of the goods and possible foreign matters, such as the starch and protein characteristic peaks of grains, special spectral signals of foreign matters, etc., which are all recorded in the real-time spectrum.
[0056] Step S102, according to the category, query the grain size level, key component wave band and reference spectrum of the to-be-detected goods from the pre-set database.
[0057] The database of the embodiment collects data of various grain samples and foreign matter samples.
[0058] The grain size level is a standardized category divided according to the particle size (grain size) of the to-be-detected goods, and the core is to provide a basis for spectrum pretreatment (such as baseline correction and scattering correction).
[0059] The key component wave band is the core basis for distinguishing grains from foreign matters. For example, the core components of wheat, rice and corn are starch and protein, and the corresponding characteristic absorption peaks are clear. Starch has strong absorption at 1240 nm and 1390 nm, and protein has characteristic absorption at 1550 nm and 1730 nm.
[0060] The reference spectrum is a pure target grain spectrum collected under standard conditions, without foreign matters and uniform components, and is a reference for subsequent spectrum alignment and component comparison. The standard conditions include: standard speed, standard moisture content, pure grain, single particle without stacking, to ensure that the spectrum is not disturbed.
[0061] Step S103, according to the grain size level, perform baseline correction and scattering correction on the real-time spectrum, and align the real-time spectrum according to the reference spectrum.
[0062] The full name of airPLS is adaptive iterative reweighted penalized least squares method, which is one of the most commonly used baseline correction algorithms in spectrum analysis. The core idea is to dynamically separate the baseline drift and effective feature peaks in the spectrum by iteratively adjusting the weight. When performing baseline correction, the number of adjacent wavelength points referred to by the algorithm each time fitting: the smaller the window, the more focused the fitting is locally, which is suitable for steep baseline; the larger the window, the wider the fitting coverage, which is suitable for gentle baseline. Due to the unstable baseline drift caused by the difference in grain particle thickness and stacking state, the existing fixed window airPLS algorithm is changed to adaptive window airPLS. Adjust the baseline correction window according to the grain particle size to accurately eliminate the baseline interference of different thickness particles.
[0063] Due to the irregular shape and uneven size of grain particles, the original unified scattering correction algorithm has limited effect. Here, a new particle size classification scattering correction is added to match dedicated scattering correction parameters for different particle sizes (such as using multivariate scattering correction algorithm for large particles and using standard normal variable transformation algorithm for small particles).
[0064] In online detection, the grain flow is affected by the motor speed and the grain accumulation amount when passing through the conveyor belt, and the speed fluctuates. The same particle spectrum at different speeds is different in characteristic peak position and peak width due to the difference in the number of points and the timing error of scanning (for example, the peak width becomes narrower at 1 m / s, and the peak width becomes wider at 0.5 m / s). The reason is that the spectrum scanning frequency is fixed (for example, 100 Hz), and the faster the speed, the fewer the number of spectrum points of a single particle is scanned, resulting in spectrum feature compression / stretching. Directly used for identification will cause the false detection rate to rise. According to the benchmark spectrum, the real-time spectrum is aligned, which can stretch / compress the spectrum at different speeds to the spectrum dimension of the standard speed, eliminate the characteristic shift caused by the time difference, and ensure the consistency of the spectrum composition feature.
[0065] In step S104, the peak value feature is extracted from the real-time spectrum, and the absorbance proportion relationship of the key component waveband is calculated. The peak value feature and the absorbance proportion relationship of the key component waveband are spliced to obtain a spectrum feature. Based on the spectrum feature, foreign matter in the detected goods is identified.
[0066] For example, the peak value feature can include peak intensity, peak position, peak area, etc., and the present embodiment is not limited. The key component waveband of starch is 1240 nm and 1390 nm, and the absorbance of these two wavebands will increase with the increase of starch content. The key component waveband of protein is 1550 nm and 1730 nm, and the absorbance is positively correlated with the protein content. The absorbance values of the key component wavebands can be extracted, and the absorbance proportion relationship is calculated according to the following formula: main proportion F1=1240 nm absorbance / 1550 nm absorbance; auxiliary proportion F2=1390 nm absorbance / 1730 nm absorbance.
[0067] Splicing the peak value feature and the absorbance proportion relationship can construct a multi-dimensional spectrum feature, which not only retains the direct judgment basis of whether the peak value is normal, but also verifies the authenticity of the component through whether the proportion is stable, forming a double check to avoid the one-sidedness of a single feature. Specifically, the peak value feature vector and the absorbance proportion feature vector are spliced to form a higher-dimensional feature matrix. For example, assuming that 3 peak value features are extracted from the spectrum, and 2 absorbance proportion features are calculated, the splicing obtains a multi-dimensional feature vector with a dimension of 3+2=5.
[0068] Then, the spectral features are input into a preset identification model to identify the foreign matter in the to-be-detected goods. Here, the preset identification model can adopt a hybrid model scheme. The main model adopts a support vector machine, which is suitable for high-dimensional small sample classification; and the auxiliary model adopts a random forest, which is used to process similar foreign matters that are difficult to distinguish by the support vector machine and improve the generalization ability. During training, the training set, the validation set and the test set are divided in a ratio of 7:2:1 to ensure consistent data distribution. The support vector machine and the random forest model are trained by using the training set, and the hyperparameters are optimized by using a grid search method. The model performance is evaluated by using the validation set, and if the accuracy is lower than a set threshold, the feature extraction link is returned to re-screen the features or supplement sample data. The results of the support vector machine and the random forest model are fused, the weights of the two are determined by using a weighted voting method, and a final classification model is output.
[0069] The embodiment of the present application pre-establishes a database of various goods, quickly matches the particle size grade, composition feature and reference spectrum of the to-be-detected goods, performs exclusive baseline correction and scattering correction on the particle size grade, effectively offsets the spectral interference caused by the heterogeneity of the goods particles, reduces the masking of the foreign matter features by the baseline drift and uneven scattering, performs spectral alignment based on the reference spectrum, eliminates the spectral length difference and feature peak stretching / compression deformation caused by the flow speed fluctuation of the goods, avoids the problem of misjudgment of the foreign matter due to the morphological distortion, extracts the peak features from the real-time spectrum, calculates the absorbance proportion relationship of the key component waveband, splices the spectral features, strengthens the feature difference between the goods and the foreign matter, can identify the mildew, and greatly improves the discrimination degree of the foreign matter identification. The embodiment of the present application significantly improves the accuracy and stability of the foreign matter identification, and adapts to the actual application requirements of multiple goods and dynamic detection.
[0070] In some embodiments, the baseline correction on the real-time spectrum according to the particle size grade can include:
[0071] According to the particle size grade, the window size range of the airPLS algorithm is determined; wherein the window size range is positively correlated with the particle size grade;
[0072] For each window size in the window size range, the airPLS algorithm is run respectively to fit the baseline and subtract the baseline from the real-time spectrum, and a plurality of corrected real-time spectrums are obtained;
[0073] According to the baseline flatness and the feature peak retention rate of each corrected real-time spectrum, the optimal corrected real-time spectrum is determined from the corrected real-time spectrums.
[0074] In the embodiment, the particle size grades of the grain can be divided into: small particles (<1 mm), medium particles (1-3 mm), and large particles (>3 mm). Other parameters (such as a penalty factor and the number of iterations) of the airPLS algorithm are fixed, and only the window size is adjusted: the small particle window is set to 5-7 points (the drift curve is steep, and a small window avoids excessive smoothing), the medium particle window is set to 7-9 points, and the large particle window is set to 9-11 points (the drift curve is gentle, and a large window accurately fits the baseline).
[0075] In the embodiment, the baseline flatness (peak-valley difference) reflects whether the baseline of the corrected spectrum is smooth, without residual drift or noise fluctuation. The feature peak retention rate reflects whether the shape, intensity, and position of the characteristic peaks of the core components of the grain and the characteristic peaks of foreign matters in the corrected spectrum are complete, without being overcorrected. Therefore, from each corrected real-time spectrum, a real-time spectrum with a feature peak retention rate greater than a preset feature peak retention rate threshold can be determined. From the real-time spectra with a feature peak retention rate greater than the preset feature peak retention rate threshold, a real-time spectrum with the smallest baseline flatness can be determined as the optimal corrected real-time spectrum.
[0076] In some embodiments, the scattering correction of the real-time spectrum according to the particle size grade can include:
[0077] A preset scattering correction algorithm corresponding to the particle size grade is determined; wherein the preset scattering correction algorithm includes: a standard normal variable transformation algorithm, a multivariate scattering correction algorithm, and a hybrid algorithm of standard normal variable transformation + multivariate scattering correction.
[0078] The real-time spectrum is subjected to scattering correction according to the preset scattering correction algorithm.
[0079] In the embodiment, the scattering effect of the grain particles is positively correlated with the particle size: large particles have strong scattering of light, and the scattering angles are uneven, resulting in an overall increase in the spectral intensity and a fuzzy characteristic peak; small particles have weak scattering, and the spectral intensity is low but the characteristic peak is clear. The standard normal variable transformation algorithm is suitable for weakening the weak scattering system error, and the multivariate scattering correction algorithm is suitable for correcting the spectral deformation caused by strong scattering. The algorithm selects a suitable correction strategy to solve the scattering problems of different particle sizes.
[0080] Exemplarily:
[0081] If the particle size grade is small particles, the preset scattering correction algorithm corresponding to the particle size grade is determined as the standard normal variable transformation algorithm.
[0082] If the particle size level is medium particles, the preset scattering correction algorithm corresponding to the particle size level is determined as a hybrid algorithm; and according to the average particle size of the to-be-detected goods, the weights of the standard normal variable transformation and the multiple scattering correction in the hybrid algorithm are determined; wherein the weight of the standard normal variable transformation is negatively correlated with the average particle size, the weight of the multiple scattering correction is positively correlated with the average particle size, and the sum of the weights of the standard normal variable transformation and the multiple scattering correction is 1.
[0083] If the particle size level is large particles, the preset scattering correction algorithm corresponding to the particle size level is determined as a multiple scattering correction algorithm.
[0084] In some embodiments, aligning the real-time spectrum according to the reference spectrum can include:
[0085] Calculating the spectral similarity between each wavelength point in the real-time spectrum and each wavelength point in the reference spectrum to obtain a similarity comparison table;
[0086] According to the similarity comparison table, finding the optimal wavelength point matching path of the real-time spectrum and the reference spectrum within the constraint of the preset size of the matching window;
[0087] Based on the optimal wavelength point matching path, stretching or compressing the real-time spectrum.
[0088] In the present embodiment, the single-particle spectrum collected at a standard speed (such as 0.8 m / s) is taken as a reference sequence (length N, such as 60 wavelength points). The spectrum collected in real time at different speeds is a to-be-aligned sequence length M, which varies with the speed. Each wavelength point (such as 48 points) of the to-be-aligned spectrum is compared with each wavelength point (60 points) of the reference spectrum one by one, and the similarity (the closer the numerical value, the higher the similarity) is calculated to form a similarity comparison table. In the similarity comparison table, a path is found that penetrates through the entire table from the first wavelength point: the points of the to-be-aligned spectrum are required to correspond to the points of the reference spectrum in order, and to pass through positions with high similarity as much as possible (the dynamic time warping algorithm can be used to find this, which will not be described in detail in the present embodiment). Finally, according to the optimal path found, the wavelength points of the to-be-aligned spectrum are stretched or compressed: if the to-be-aligned spectrum is short (such as 48 points), some points are split into multiple points, corresponding to multiple points of the reference spectrum (for example, 1 point is split into 2 points, and the middle value is supplemented); if the to-be-aligned spectrum is long (such as 96 points), multiple adjacent points are combined into 1 point, and the average value is taken to correspond to 1 point of the reference spectrum; finally, the length of the to-be-aligned spectrum is made consistent with that of the reference spectrum. Through the above steps, the difference in spectrum length caused by speed fluctuations can be eliminated, providing a consistent feature basis for subsequent foreign matter identification.
[0089] In some embodiments, before extracting the absorbance proportion relationship of the key component waveband from the real-time spectrum, the method can further include:
[0090] obtain an actual moisture content of the to-be-detected cargo, and query a moisture content-spectrum offset correlation model corresponding to the to-be-detected cargo in a database;
[0091] based on the actual moisture content and the moisture content-spectrum offset correlation model, determine an offset amount of the real-time spectrum, and correct the intensity of the real-time spectrum according to the offset amount.
[0092] In the embodiment, considering that the change of the moisture content of the grain may cause the spectrum offset, the offset is compensated by establishing the moisture content-spectrum offset correlation model, so as to counteract the interference of the moisture on the grain spectrum, make the grain spectrums with different moisture contents consistent in reflecting the characteristics of the core components such as starch and protein, and avoid that the moisture difference is misjudged as a foreign matter characteristic.
[0093] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0094] The following is a device embodiment of the present application. For details not described in detail, reference can be made to the corresponding method embodiments described above.
[0095] Figure 2 A structure diagram of a database-driven spectrum recognition device provided by an embodiment of the present application is shown. For ease of illustration, only parts related to the embodiment of the present application are shown.
[0096] As shown in Figure 2 The database-driven spectrum recognition device 2 includes:
[0097] The acquisition module 21 is configured to acquire a type of the to-be-detected cargo and a real-time spectrum.
[0098] The query module 22 is configured to query a particle size grade, a key component waveband and a reference spectrum of the to-be-detected cargo from a preset database according to the type.
[0099] The correction module 23 is configured to perform baseline correction and scattering correction on the real-time spectrum according to the particle size grade, and align the real-time spectrum according to the reference spectrum.
[0100] The recognition module 24 is configured to extract a peak value feature from the real-time spectrum, calculate an absorbance proportion relationship of the key component waveband, perform feature splicing on the peak value feature and the absorbance proportion relationship of the key component waveband, obtain a spectrum feature, and recognize a foreign matter in the to-be-detected cargo based on the spectrum feature.
[0101] In a possible implementation manner, the correction module 23 is configured to:
[0102] determine a window size range of the airPLS algorithm according to the particle size grade; wherein the window size range is positively correlated with the particle size grade;
[0103] for each window size in the window size range, respectively run the airPLS algorithm to fit a baseline and subtract the baseline from the real-time spectrum to obtain a plurality of corrected real-time spectra;
[0104] determine an optimal corrected real-time spectrum from the plurality of corrected real-time spectra according to baseline flatness and feature peak retention rate of each corrected real-time spectrum.
[0105] In a possible implementation, the correction module 23 is configured to:
[0106] determine a real-time spectrum with a feature peak retention rate greater than a preset feature peak retention rate threshold from the plurality of corrected real-time spectra;
[0107] determine a real-time spectrum with minimum baseline flatness from the real-time spectrum with the feature peak retention rate greater than the preset feature peak retention rate threshold as the optimal corrected real-time spectrum.
[0108] In a possible implementation, the correction module 23 is configured to:
[0109] determine a preset scatter correction algorithm corresponding to the particle size grade; wherein the preset scatter correction algorithm includes a standard normal variable transformation algorithm, a multivariate scatter correction algorithm, and a hybrid algorithm of standard normal variable transformation + multivariate scatter correction;
[0110] perform scatter correction on the real-time spectrum according to the preset scatter correction algorithm.
[0111] In a possible implementation, the particle size grade includes small particles, medium particles, and large particles; and the correction module 23 is configured to:
[0112] if the particle size grade is small particles, determine that the preset scatter correction algorithm corresponding to the particle size grade is the standard normal variable transformation algorithm;
[0113] if the particle size grade is medium particles, determine that the preset scatter correction algorithm corresponding to the particle size grade is the hybrid algorithm;
[0114] if the particle size grade is large particles, determine that the preset scatter correction algorithm corresponding to the particle size grade is the multivariate scatter correction algorithm.
[0115] In a possible implementation, the correction module 23 is further configured to:
[0116] If it is determined that the preset scattering correction algorithm corresponding to the particle size level is a hybrid algorithm, then according to the average particle size of the to-be-detected cargo, the weight of the standard normal variable transformation and the multivariate scattering correction in the hybrid algorithm is determined;
[0117] The weight of the standard normal variable transformation is negatively correlated with the average particle size, the weight of the multivariate scattering correction is positively correlated with the average particle size, and the sum of the weights of the standard normal variable transformation and the multivariate scattering correction is 1.
[0118] In a possible implementation, the correction module 23 is configured to:
[0119] Calculate the spectral similarity between each wavelength point in the real-time spectrum and each wavelength point in the reference spectrum to obtain a similarity comparison table;
[0120] According to the similarity comparison table, find the optimal matching path of the wavelength points of the real-time spectrum and the reference spectrum within a preset size of a matching window constraint;
[0121] Based on the optimal matching path of the wavelength points, stretch or compress the real-time spectrum.
[0122] In a possible implementation, before extracting the absorbance proportion relationship of the key component waveband from the real-time spectrum, the correction module 23 is further configured to:
[0123] Obtain the actual moisture content of the to-be-detected cargo, and obtain the moisture content-spectrum offset correlation model corresponding to the to-be-detected cargo in the database;
[0124] Based on the actual moisture content and the moisture content-spectrum offset correlation model, determine the offset amount of the real-time spectrum, and correct the intensity of the real-time spectrum according to the offset amount.
[0125] The embodiment of the application pre-establishes a database of various cargos, quickly matches the particle size level, component characteristics and reference spectrum according to the type of the to-be-detected cargo; performs exclusive baseline correction and scattering correction according to the particle size level, effectively offsets the spectral interference caused by the heterogeneity of cargo particles, reduces the masking of foreign matter characteristics caused by baseline drift and uneven scattering; the spectral alignment operation with the reference spectrum as the reference eliminates the spectral length difference and feature peak stretching / compression deformation caused by cargo flow speed fluctuation, avoids the problem of misjudgment of foreign matter due to morphological distortion; extracts the peak features from the real-time spectrum, calculates the absorbance proportion relationship of the key component waveband, and splices the spectral features, thereby strengthening the feature difference between the cargo main body and the foreign matter, and greatly improving the discrimination degree of foreign matter identification. The embodiment of the application significantly improves the accuracy and stability of foreign matter identification, and adapts to the actual application requirements of multiple cargos and dynamic detection.
[0126] Figure 3 is a schematic diagram of an electronic device provided by the embodiment of the application. As shown in Figure 3As shown, the electronic device 3 of the embodiment includes a processor 30 and a memory 31. The memory 31 stores a computer program 32. The processor 30 implements the steps of each of the above method embodiments when executing the computer program 32. Alternatively, the processor 30 implements the functions of each of the modules in the above apparatus embodiments when executing the computer program 32.
[0127] For example, the computer program 32 can be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 30 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program 32 in the electronic device 3.
[0128] The electronic device 3 can include, but is not limited to, the processor 30 and the memory 31. Those skilled in the art can understand that the electronic device 3 can include more or fewer components than those shown, or combine certain components, or include different components, such as an input / output device, a network access device, a bus, etc. Figure 3 The electronic device 3 is only an example and does not constitute a limitation on the electronic device 3, which can include more or fewer components than those shown, or combine certain components, or include different components, such as an input / output device, a network access device, a bus, etc.
[0129] The processor 30 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0130] The memory 31 can be an internal storage unit of the electronic device 3, such as a hard disk or a memory of the electronic device 3. The memory 31 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. provided on the electronic device 3. Further, the memory 31 can include both an internal storage unit and an external storage device of the electronic device 3. The memory 31 is used to store the computer program 32 and other programs and data required by the electronic device 3. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0131] For the convenience and brevity of description, only the above-mentioned division of each functional module / unit is exemplified, and in actual application, the above-mentioned functions can be completed by different functional modules / units according to needs. The above-mentioned modules / units can be realized in the form of hardware, software or a combination of hardware and software.
[0132] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method in each method embodiment described above is realized.
[0133] The embodiment of the present application also provides a computer program product, which comprises a computer program. When the computer program is executed by a processor, the method in each method embodiment described above is realized.
[0134] The computer program comprises computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium can include any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electric carrier wave signal, telecommunication signal and software distribution medium, etc.
[0135] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in a certain embodiment can be referred to the relevant description of other embodiments. If there is no special description and logical conflict, the terms and / or descriptions of different embodiments are consistent and can be mutually referred to, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationship.
[0136] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit it; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A database-driven spectral identification method, characterized by, The method comprises the following steps: acquiring the category and real-time spectrum of the to-be-detected goods; according to the category, querying the particle size grade, key component wave band and reference spectrum of the to-be-detected goods from a preset database; according to the particle size grade, performing baseline correction and scattering correction on the real-time spectrum, and aligning the real-time spectrum according to the reference spectrum; extracting peak features from the real-time spectrum, calculating the absorbance proportion relationship of the key component wave band, splicing the peak features and the absorbance proportion relationship of the key component wave band to obtain a spectrum feature; identifying foreign matter in the to-be-detected goods based on the spectrum feature; performing baseline correction on the real-time spectrum according to the particle size grade, comprising: determining the window size range of the airPLS algorithm according to the particle size grade; wherein the window size range is positively correlated with the particle size grade; for each window size in the window size range, respectively running the airPLS algorithm to fit the baseline and subtract the baseline from the real-time spectrum to obtain a plurality of corrected real-time spectrums; determining the optimal corrected real-time spectrum from the corrected real-time spectrums according to the baseline flatness and feature peak retention rate of each corrected real-time spectrum; performing scattering correction on the real-time spectrum according to the particle size grade, comprising: determining the preset scattering correction algorithm corresponding to the particle size grade; wherein the preset scattering correction algorithm comprises a standard normal variable transformation algorithm, a multivariate scattering correction algorithm, and a hybrid algorithm of standard normal variable transformation + multivariate scattering correction; if the particle size grade is small particles, the preset scattering correction algorithm corresponding to the particle size grade is determined to be the standard normal variable transformation algorithm; if the particle size grade is medium particles, the preset scattering correction algorithm corresponding to the particle size grade is determined to be the hybrid algorithm; if the particle size grade is large particles, the preset scattering correction algorithm corresponding to the particle size grade is determined to be the multivariate scattering correction algorithm; performing scattering correction on the real-time spectrum according to the preset scattering correction algorithm; before extracting the absorbance proportion relationship of the key component wave band from the real-time spectrum, further comprising: acquiring the actual moisture content of the to-be-detected goods, and querying the moisture content-spectrum offset correlation model corresponding to the to-be-detected goods in the database; determining the offset amount of the real-time spectrum based on the actual moisture content and the moisture content-spectrum offset correlation model, and correcting the intensity of the real-time spectrum according to the offset amount.
2. The database-driven spectral identification method of claim 1, wherein, The method for determining the optimal corrected real-time spectrum from the corrected real-time spectrums according to the baseline flatness and feature peak retention rate of each corrected real-time spectrum comprises: from the corrected real-time spectrums, determining the real-time spectrum with a feature peak retention rate greater than a preset feature peak retention rate threshold; from the real-time spectrum with a feature peak retention rate greater than a preset feature peak retention rate threshold, determining the real-time spectrum with the minimum baseline flatness as the optimal corrected real-time spectrum.
3. The database-driven spectral identification method of claim 1, wherein, The method for determining the preset scattering correction algorithm corresponding to the particle size grade further comprises: If it is determined that the preset scattering correction algorithm corresponding to the particle size grade is a hybrid algorithm, weights of standard normal variable transformation and multivariate scattering correction in the hybrid algorithm are determined according to the average particle size of the to-be-detected cargo. The weight of the standard normal variable transformation is negatively correlated with the average particle size, the weight of the multivariate scattering correction is positively correlated with the average particle size, and the sum of the weights of the standard normal variable transformation and the multivariate scattering correction is 1.
4. The database-driven spectral identification method of claim 1, wherein, The aligning the real-time spectrum according to the reference spectrum comprises: calculating the spectral similarity between each wavelength point in the real-time spectrum and each wavelength point in the reference spectrum to obtain a similarity comparison table; finding an optimal wavelength point matching path of the real-time spectrum and the reference spectrum within a preset size of a matching window constraint according to the similarity comparison table; stretching or compressing the real-time spectrum based on the optimal wavelength point matching path.
5. A database driven spectral recognition apparatus, characterized by, The device comprises: an acquisition module configured to acquire the category and real-time spectrum of the to-be-detected cargo; a query module configured to query the particle size grade, key component waveband and reference spectrum of the to-be-detected cargo from a preset database according to the category; a correction module configured to perform baseline correction and scattering correction on the real-time spectrum according to the particle size grade, and align the real-time spectrum according to the reference spectrum; an identification module configured to extract peak features from the real-time spectrum, calculate the absorbance proportion relationship of the key component waveband, splice the peak features and the absorbance proportion relationship of the key component waveband to obtain a spectrum feature, and identify foreign matter in the to-be-detected cargo based on the spectrum feature.
6. An electronic device, comprising: The device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method of any one of claims 1 to 4.
Citation Information
Patent Citations
Spectrophotometric method for identifying pterocarpus santalinus and pterocarpus tinctorius
CN115615940A
Foreign matter identification method and device, equipment and storage medium
CN119723218A