Method and system for detecting mildew and homochromatic foreign matters in perfume and medium

By employing a multimodal collaborative detection process utilizing hyperspectral, visible light, and X-ray imaging technologies, the challenges of identifying mold growth and foreign matter of the same color within spices have been solved, achieving high-precision quality inspection and safety assurance.

CN121577558APending Publication Date: 2026-02-27CHONGQING QIAOTOU FOOD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511694528.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-18
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing fragrance testing equipment cannot effectively identify internal mold and foreign objects of similar color to fragrances, leading to potential product quality and safety hazards.

Method used

A multimodal collaborative detection process employing hyperspectral imaging, visible light imaging, and X-ray imaging technologies is used to identify mold and discolored foreign matter inside spices in a progressive manner. First, hyperspectral imaging technology is used to identify potential abnormal areas, then visible light imaging technology is used to verify the surface morphology, and finally X-ray imaging technology is used to scan the internal density, achieving comprehensive and high-precision detection.

Benefits of technology

It enables comprehensive and high-precision detection of internal and external quality defects in spices, eliminating potential product quality and safety hazards and improving production efficiency and product purity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121577558A_ABST
    Figure CN121577558A_ABST
Patent Text Reader

Abstract

The invention discloses a method, a system and a medium for detecting mildew and homochromatic foreign matters in spices, and relates to the field of food detection. The method comprises the following steps: acquiring hyperspectral image data of detected perfume, and identifying a potential abnormal region by analyzing chemical component characteristics of the detected perfume to obtain a first detection result; obtaining a surface morphological image of the potential abnormal area by utilizing visible light imaging based on the result, and performing morphological analysis to obtain a second detection result; synthesizing the two to generate a third detection result for identifying the highly suspicious region; and performing X-ray penetration scanning on the area to obtain internal density information, and finally determining abnormal material information in combination with a third detection result. According to the invention, through fusion and step-by-step discrimination of three imaging technologies of hyperspectral imaging, visible light imaging and X-ray imaging, efficient and accurate detection of mildew and foreign matters with the same color in the perfume is realized; the problem that a color sorter cannot effectively recognize internal mildew and foreign matters with the same color similar to the color of the perfume, and consequently potential safety hazards of product quality are caused is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of food testing technology, and in particular to a method, system, and medium for detecting mold and foreign matter of the same color inside spices. Background Technology

[0002] In the industrial production and processing of spices (such as chili peppers and Sichuan peppercorns), quality inspection and sorting are crucial steps to ensure product quality and safety. Automated inspection and sorting technologies primarily rely on color sorters.

[0003] Color sorters typically employ visible light imaging technology. A high-speed linear scan camera captures surface images of each spice on the conveyor belt, and image processing algorithms analyze its color, shape, size, and other external characteristics to identify and remove spice with abnormal color, incorrect size, or mixed-color impurities (such as branches, leaves, or stones). Compared to manual sorting, color sorters improve the efficiency and consistency of spice sorting.

[0004] However, internal mold growth in spices may not show obvious changes in external color, and foreign objects of the same color have optical characteristics highly similar to normal spices in the visible light spectrum. Therefore, in related technologies, color sorters often cannot effectively detect internal mold growth in spices, as well as those foreign objects of the same color that are extremely similar to the spice itself, posing a serious risk to product quality. Summary of the Invention

[0005] To address the aforementioned technical problems and deficiencies, the purpose of this invention is to provide a method, system, and medium for detecting mold growth and foreign matter of similar color inside fragrances. This can alleviate the problem that color sorters cannot effectively identify internal mold growth and foreign matter of similar color to fragrances, which could lead to potential product quality and safety hazards.

[0006] To achieve the above objectives, in a first aspect, the present invention provides a method for detecting mold and foreign matter of the same color inside a spice, characterized by comprising: acquiring hyperspectral image data of the spice to be tested; analyzing the chemical composition characteristics of the spice to be tested based on the hyperspectral image data to identify potential abnormal regions of the spice to be tested, and obtaining a first detection result including the location of the abnormal region; in response to the first detection result, acquiring a surface morphology image of the potential abnormal region using visible light imaging technology; performing morphological analysis on the surface morphology image to obtain a second detection result for characterizing the surface features of the potential abnormal region; generating a third detection result for identifying highly suspicious regions based on the first detection result and the second detection result; in response to the third detection result, performing a penetration scan on the highly suspicious region using X-ray imaging technology to obtain internal density information of the highly suspicious region; and determining abnormal material information of the spice to be tested based on the third detection result and the internal density information.

[0007] This invention effectively solves the technical problem of traditional color sorters, which rely solely on visible light imaging and cannot effectively identify internal mold growth and foreign matter of similar color to fragrances, by constructing a multimodal, progressive detection process that integrates hyperspectral imaging, visible light imaging, and X-ray imaging. First, hyperspectral imaging is used to perform preliminary screening based on differences in the chemical composition of substances to identify potential anomalies invisible to the surface. Then, visible light imaging is used to verify the surface morphology of potential anomaly areas, accurately eliminating misjudgments caused by the normal structure of the fragrance. Finally, for highly suspicious areas identified in the first two stages, X-ray imaging is used for internal density penetration scanning for final confirmation. This three-stage verification data fusion strategy organically combines chemical composition, surface morphology, and internal density information, achieving comprehensive and high-precision detection of internal and external quality defects in fragrances, fundamentally eliminating product quality and safety hazards caused by internal mold growth and foreign matter of similar color.

[0008] In some embodiments, after determining the abnormal material information of the detected spice based on the third detection result and the internal density information, the method further includes: generating a rejection control command based on the abnormal material information; and sending the rejection control command to a foreign object driven rejection device to physically remove the abnormal material.

[0009] By adopting the above technical solution, the detection system can physically remove the identified abnormal materials from the production line in real time, ensuring the high purity and quality of the final product. This not only improves product quality but also significantly increases the production efficiency and automation level of spice processing by replacing manual operation with automation.

[0010] In some embodiments, the analysis of the chemical composition characteristics of the detected spice specifically includes: processing the hyperspectral image data using a low-sample machine learning algorithm to extract feature spectra and identify potential anomalous regions.

[0011] By adopting the above technical solution, the number of samples required for model training is reduced, solving the practical problems of difficulty and high cost in collecting large-scale and diverse samples in industrial settings. This makes the construction and deployment of detection models faster and more economical, enhancing the feasibility and economic viability of the detection method in actual industrial production environments and accelerating the industrial application of the technology.

[0012] In some implementations, the morphological analysis of the surface morphology image specifically includes: using a deep learning algorithm to analyze the surface morphology image to determine whether the potential abnormal region is a real abnormality or normal tissue of the detected spice.

[0013] By employing the above technical solution, a deep learning model can automatically learn and extract complex and abstract deep features from images. Compared to traditional image processing algorithms, it can more accurately distinguish between real mold spots and the complex textures, scars, and other normal tissues of spices themselves. This greatly improves the accuracy of the second-level verification, effectively reduces the system's false alarm rate, and provides a more reliable basis for subsequent precise X-ray scanning.

[0014] In some embodiments, in the step of acquiring hyperspectral image data of the detected spice, the spectral range of the hyperspectral image data is 400-2500 nm, and the spectral resolution is 1-10 nm.

[0015] By adopting the above technical solution, and by setting a broad spectral range of 400-2500nm covering visible light, near-infrared, and short-wave infrared, and combining it with a high-precision spectral resolution of 1-10nm, a full-information dimensional spectral fingerprint is constructed for the detected fragrance. This greatly enriches the amount of raw data information obtained in the first-level detection, providing the most solid and comprehensive data foundation for subsequent accurate identification of internal mold and differentiation of various types of foreign matter of the same color. This significantly improves the robustness, accuracy, and applicability of the entire detection system.

[0016] Secondly, the present invention provides a system for detecting mold growth and foreign matter of the same color inside spices, comprising: A conveying device for conveying the spice being tested; A hyperspectral imaging module is provided along the conveying direction of the conveying device to acquire hyperspectral image data of the moving spice being tested. A linear array camera module is located downstream of the hyperspectral imaging module and is used to image the detected spice to obtain a surface morphology image. An X-ray imaging module, located downstream of the linear array camera module, is used to perform a penetrating scan of the detected spice to obtain internal density information. The data processing center is communicatively connected to the hyperspectral imaging module, the linear array camera module, and the X-ray imaging module, and is configured to execute the method described in any one of claims 1-5.

[0017] Thirdly, the present invention provides an electronic device comprising: one or more processors and a memory; the memory being coupled to the one or more processors, the memory being used to store computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof.

[0018] Fourthly, the present invention provides a computer-readable storage medium storing instructions that, when executed on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0019] Fifthly, the present invention provides a computer program product comprising instructions that, when the computer program product is run on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0020] Understandably, the system provided in the second aspect, the electronic device provided in the third aspect, the storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method provided by this invention. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of the architecture of a fragrance internal mold and foreign matter detection system according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating a method for detecting mold and foreign matter of the same color inside spices according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the hardware architecture of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be noted that, where there is no logical conflict, the embodiments and features described herein can be combined with each other. The embodiments described herein are illustrative and are only used to explain this invention, and should not be construed as limiting the invention.

[0023] This invention provides a system for detecting mold growth and foreign matter of the same color inside spices, such as... Figure 1 As shown, the system includes: a conveying device 101, a hyperspectral imaging module 102, a line array camera module 103, an X-ray imaging module 104, and a data processing center 105.

[0024] The conveying device 101 is used to convey the spice being tested.

[0025] In this embodiment, the conveying device 101 can be a conveyor belt running at a constant speed, made of food-grade material to ensure that the detected spices are not contaminated during transport. The speed of the conveying device 101 is adjustable and matches the acquisition frequency of the subsequent imaging modules and the processing speed of the data processing center 105, ensuring that each detected spice can be captured and analyzed completely and clearly. The detected spices, such as chili peppers and Sichuan peppercorns, are laid flat on the conveying device 101 and pass through the detection area below in a single layer without overlap, providing the prerequisite for accurate imaging and positioning.

[0026] The hyperspectral imaging module 102 is arranged along the conveying direction of the conveying device 101 and is used to acquire hyperspectral image data of the moving spice being tested.

[0027] The hyperspectral imaging module 102 can employ a hyperspectral camera, which, unlike ordinary cameras that only capture red, green, and blue colors, divides light into hundreds of very narrow and continuous bands to capture the "spectral fingerprint" of each row of the spice being tested, thereby generating a three-dimensional data cube containing spatial information and complete spectral information.

[0028] In this embodiment, the hyperspectral imaging module 102 is installed at the initial detection position of the conveying device 101. When the spice being tested passes beneath it, the light source (such as a halogen lamp) configured in the hyperspectral imaging module 102 illuminates the surface of the spice, and the reflected light is received by the hyperspectral camera. The hyperspectral camera does not take a single photograph, but rather uses a push-broom method to continuously acquire spectral and spatial information line by line as the spice being tested moves with the conveying device 101, ultimately combining them into a three-dimensional hyperspectral image data. The hyperspectral image data contains the complete spectral curve of each pixel on the spice being tested, and these spectral curves can reflect the internal composition information of the substance. Furthermore, it can capture subtle changes in chemical components (such as moisture, protein, and mold metabolites) on the surface and shallow interior of the spice caused by mold or foreign matter, which are invisible to the naked eye, thereby achieving preliminary anomaly screening based on the molecular structure of the substance.

[0029] The linear array camera module 103 is located downstream of the hyperspectral imaging module 102 and is used to image the detected spice to obtain a surface morphology image.

[0030] In this embodiment, the line scan camera module 103 is a device employing visible light imaging technology, with a linear photosensitive element at its core. As the spice being tested moves through the field of view of the conveying device 101, the line scan camera module 103 scans the surface of the spice line by line and stitches these line images into a complete, high-resolution two-dimensional image, i.e., a surface morphology image. The module's position is precisely calibrated to ensure that it can accurately image the area marked by the upstream hyperspectral imaging module 102. This surface morphology image can clearly display the external physical characteristics of the spice being tested, such as color, shape, size, and texture.

[0031] The X-ray imaging module 104 is located downstream of the linear scan camera module 103 and is used to perform a penetrating scan on the spice being tested to obtain internal density information.

[0032] The X-ray imaging module 104 utilizes the penetrating power of X-rays to irradiate the fragrance being tested beneath it. After penetrating the fragrance, the intensity of the X-rays attenuates due to differences in density and thickness among the various substances within the fragrance. An X-ray detector located below the conveying device 101 receives the attenuated rays and converts them into a digital image signal, i.e., internal density information. This internal density information reveals structural differences within the fragrance; for example, moldy areas, due to tissue decay and decomposition, typically have a lower density than normal tissue, while foreign objects of the same color, such as pebbles, have a significantly higher density than the fragrance itself.

[0033] The data processing center 105 is communicatively connected to the hyperspectral imaging module 102, the linear array camera module 103, and the X-ray imaging module 104, and is configured to execute the method for detecting mold and foreign matter of the same color inside spices provided in the following embodiments.

[0034] The data processing center 105 is the "brain" of the entire detection system, typically composed of a high-performance industrial computer or embedded system. The data processing center 105 receives raw data from the hyperspectral imaging module 102, the linear scan camera module 103, and the X-ray imaging module 104 via a high-speed data interface, and has built-in algorithms for implementing the method of this invention. To support complex computational tasks, the data processing center 105 incorporates low-sample machine learning algorithms for processing hyperspectral data, as well as deep learning algorithms for analyzing surface morphology images.

[0035] Data processing center 105 is responsible not only for data analysis and decision-making, but also for the timing control of the entire system, ensuring that the position of the spices on the conveyor belt is precisely synchronized with the imaging, analysis and rejection actions of each module.

[0036] In some embodiments, the system further includes a rejection device 106. The rejection device 106 is communicatively linked to the data processing center 105 and is located downstream of the X-ray imaging module 104 for physically removing detected abnormal materials.

[0037] In this embodiment, the rejection device 106 can be one or more rows of high-speed solenoid valve-controlled jet nozzles, i.e., a pneumatic rejection device 106. These jet nozzles are precisely aligned with the width of the conveyor 101. When the data processing center 105 determines the location of an abnormal material and the time it is about to arrive at the rejection area, it sends a rejection control command to the solenoid valve controlling the corresponding jet nozzle. The solenoid valve opens instantaneously, spraying out a high-pressure airflow that precisely blows the fragrance detected as abnormal material off the conveyor belt into the waste collection box, while normal fragrance continues to move along the conveyor belt.

[0038] This invention constructs a three-level verification process by organically combining three technologies—hyperspectral imaging, visible light imaging, and X-ray imaging—with a progressive data fusion strategy. Its core breakthrough lies in introducing X-ray imaging as the final and decisive "veto" confirmation step.

[0039] Level 1: Initial screening of chemical composition. Hyperspectral imaging, acting as a "broad-spectrum probe," utilizes its sensitivity to the chemical composition of substances to conduct a large-scale, high-throughput initial screening, identifying potential abnormal areas caused by variations in chemical composition. This marks the first discovery of defects invisible to the surface.

[0040] Level 2: Surface morphology screening. Visible light imaging, acting as a "morphological expert," performs high-resolution surface morphology verification on the suspicious points identified in Level 1, accurately identifying and excluding areas with special chemical compositions but belonging to normal tissue (such as chili pepper stems), effectively filtering out false positives.

[0041] Level Three: Final Verification of Internal Density. X-ray imaging, acting as the "final determinant," performs penetrating scans on highly suspicious areas that the first two levels could not fully determine, obtaining definitive physical evidence of their internal density. For internal mold, tissue decay leads to a significant decrease in density; for high-density, homochromatic foreign objects such as pebbles, their density will be significantly higher than that of the spice itself. This final confirmation based on differences in internal physical structure completely resolves the ambiguity that cannot be addressed by spectral and surface visual information alone, constituting a decisive breakthrough in the detection of internal mold and homochromatic foreign objects.

[0042] This logical progression and step-by-step confirmation process, from "abnormal chemical composition" to "abnormal surface morphology" and then to "abnormal internal density," enables this embodiment to not only "see" the surface but also "see" the interior, thereby effectively solving the technical bottleneck that traditional color sorters cannot deal with such hidden defects.

[0043] This invention also provides a method for detecting mold growth and foreign matter of the same color inside spices. This method is used in the spice internal mold growth and foreign matter detection system provided in the above embodiments, such as... Figure 2 As shown, the method specifically includes the following steps: S201, acquire hyperspectral image data of the spice being tested.

[0044] In this step, the spice being tested (such as chili peppers) is first moved into the detection area of ​​the hyperspectral imaging module by the conveying device.

[0045] The hyperspectral imaging module performs continuous push-broom scanning on the moving spice sample being tested, and the resulting hyperspectral image data is transmitted to the data processing center.

[0046] Specifically, the spectral range of the hyperspectral imaging module can be selected as the near-infrared band of 400-2500nm (more preferably 900-1700nm in this embodiment), and the spectral resolution is preferably 1-10nm (for example, 8nm in this embodiment). This allows for the acquisition of more than 100 spectral signals in a single scan. This range is chosen because the chemical bonds (such as OH, CH, NH bonds) of organic matter such as moisture, protein denaturation, and mycotoxins produced during mold growth have obvious absorption peaks in this band, and their spectral characteristics differ significantly from those of normal fragrance tissue.

[0047] With a single scan, the system can obtain the reflectance values ​​of each pixel on the surface of the detected spice in hundreds of consecutive narrow wavelength bands, thus constructing a hyperspectral image data containing rich information about its internal composition. This data is a three-dimensional data cube, with two dimensions being spatial coordinates (x, y) and the third dimension being the spectral wavelength (λ), providing the raw data foundation for subsequent chemical composition analysis.

[0048] In this embodiment, by setting a broad spectral range of 400-2500nm covering visible light, near-infrared, and short-wave infrared, and combining it with a high-precision spectral resolution of 1-10nm, a full-information "spectral fingerprint" is constructed for the detected fragrance. Specifically, the 400-780nm visible light band inherits the capabilities of traditional color analysis, acquiring surface information such as the color and pigments of materials; while the 780-2500nm near-infrared and short-wave infrared bands delve deeper into the interior of substances, accurately capturing the unique spectral characteristics generated by the vibration and overtone absorption of molecular bonds in organic substances such as water, proteins, fats, cellulose, and even mycotoxins, thereby revealing internal components and physical state changes that are imperceptible to the naked eye.

[0049] Meanwhile, the spectral resolution of 1-10nm ensures that the system can distinguish foreign objects or weak early mold growth characteristic peaks with extremely high precision, and can be flexibly configured according to the needs of production line speed and detection accuracy, thus taking into account both detection depth and efficiency.

[0050] Therefore, the setting of these technical parameters greatly enriches the amount of raw data information obtained by the first-level detection, providing the most solid and comprehensive data foundation for subsequent accurate identification of internal mold and differentiation of various types of foreign objects of the same color, significantly improving the robustness, accuracy and applicability of the entire detection system.

[0051] S202, based on hyperspectral image data, analyze the chemical composition characteristics of the detected spice to identify potential abnormal regions of the detected spice, and obtain the first detection result contained in the location of the abnormal region.

[0052] In this step, the data processing center receives hyperspectral image data from the hyperspectral imaging module and processes and analyzes it.

[0053] In this embodiment, a low-sample machine learning algorithm can be used to process the hyperspectral image data to extract feature spectra and identify potential anomaly regions. By maximizing the information value of limited samples through specific strategies, a model with strong generalization ability can be constructed. The specific implementation process is as follows: First, data preparation and preprocessing are performed. A limited number of spice samples are collected, including samples in known states such as normal and those with internal mold, forming the initial training set. Image data of these samples in the spectral range of 400-2500 nm (more specifically, 900-1700 nm) are acquired using a hyperspectral imaging system. Subsequently, the raw spectral data is preprocessed, including dark current correction, standard whiteboard correction to eliminate system noise, and possibly techniques such as smoothing and denoising, and standard normal transformation, to reduce the impact of scattering effects and random noise, thereby improving data quality.

[0054] Next, we move into the crucial feature spectrum extraction stage. The goal of this stage is to select the most discriminative feature wavelengths from hundreds of bands, thereby effectively reducing dimensionality and avoiding overfitting. The algorithm analyzes the spectral curves of different categories of samples to find the feature bands with the most significant differences. Specific methods include: using principal component analysis to project the high-dimensional spectral data onto the principal components with the largest variance to achieve feature compression; or using successive projection algorithms to select a set of key wavelength combinations with the lowest information redundancy. Essentially, this process allows the algorithm to "learn" from a limited number of samples which spectral features are the core basis for distinguishing between normal and moldy conditions.

[0055] Then, based on these extracted key feature spectra, a lightweight classification model is constructed and trained. Given the limited sample size, complex models are prone to overfitting; therefore, models with fewer parameters or strong regularization constraints are typically chosen. For example, support vector machines (SVMs) are used, which classify by finding the optimal hyperplane that maximizes the class margin, performing robustly with small sample sizes. Simple decision trees or logistic regression models with L1 or L2 regularization can also be used. During training, a strict data utilization strategy is employed, such as leave-one-out cross-validation, where only one sample is used for testing each time, with the rest used for training. This process iterates through all samples to evaluate model performance as accurately as possible and determine the final parameters with extremely limited data.

[0056] Finally, the trained model is deployed. When a new, unknown spice sample passes through the detection system, the system first acquires its hyperspectral data and performs the same preprocessing and feature wavelength extraction operations. Subsequently, the extracted feature spectra are input into the pre-trained lightweight classification model, which quickly outputs a judgment result, such as "normal" or "internal mold," and provides targeted detection guidance for downstream linear scan cameras and X-ray modules.

[0057] In this way, low-sample machine learning algorithms learn essential spectral features using limited data, enabling rapid and accurate preliminary identification of mold growth inside spices.

[0058] The "low-sample machine learning algorithm" described in this embodiment, compared to conventional algorithms, has a core improvement in that it employs a composite strategy combining generative data augmentation and single-class anomaly detection, significantly reducing its reliance on rare anomaly samples. Conventional machine learning models require a large number of positive and negative samples covering various situations for supervised learning. However, in the field of spice detection, obtaining a large number of diverse internal mold or rare foreign matter samples of the same color is extremely costly and impractical. The algorithm in this embodiment solves this problem in the following way: First, it uses a generative adversarial network (GAN) to generate a large amount of highly realistic and diverse virtual anomaly spectral data using a small number of real anomaly samples as "seeds," thereby expanding the training set at the data level. Second, the core paradigm of model training shifts from the traditional "multi-class classification" to "single-class learning," that is, the model mainly learns the feature distribution of massive normal samples to build a "normal" model. Any data point deviating from this model is considered anomaly. This strategy minimizes the need for rare negative samples.

[0059] To verify the effectiveness of the algorithm, a set of comparative experiments were conducted in this embodiment. The experimental results are shown in Table 1: Table 1: Comparison of Detection Performance of Different Algorithms under Different Mold Sample Sizes (Experimental Data Table) Table 1 shows the training results of the internal mold detection model for the same batch of chili peppers using the conventional Support Vector Machine (SVM) algorithm and the low-sample algorithm proposed in this embodiment. The conventional SVM algorithm requires approximately 1000 labeled mold samples to achieve a 95% recognition accuracy. In contrast, the low-sample algorithm proposed in this invention requires only about 300 real mold samples (as seed samples for the GAN) to achieve the same or even higher accuracy of 95.5%, reducing the required sample size by 70%. This experimental data clearly demonstrates the significant improvement and innovation of this embodiment in low-sample training, making it more feasible and economical for industrial applications.

[0060] In some embodiments, this step can also be implemented using prior knowledge of the chemical composition and spectral characteristics of fragrances, identifying anomalies through purely physical models and signal processing techniques, as follows: Step 1: Establish a standard chemical characteristic spectral library.

[0061] This step is fundamental to the entire method and requires collaboration between spectral analysis experts and food chemistry experts. First, for the target spice (e.g., chili peppers), a large number of batches of high-spectral image data of "gold standard" normal samples, confirmed to be free of mold or impurities, are collected. This data undergoes preprocessing, such as black-and-white correction to eliminate the effects of dark current and uneven light source, and noise removal using smoothing filters (e.g., Savitzky-Golay filtering). Then, the preprocessed spectral data is analyzed to identify and extract characteristic absorption peaks representing the core chemical components of the spice (e.g., capsaicin, moisture, cellulose, oils, etc.). These characteristic peaks are typically associated with vibrational modes of specific chemical bonds (e.g., overtone or combination absorption of OH, CH, and NH bonds). For each characteristic peak, its peak wavelength, peak intensity range, peak width, and relative intensity ratio with other peaks are precisely recorded. These parameterized feature sets are then used to construct a "normal spice standard spectral model." Similarly, small but clearly defined internal mold samples (different mold species, different stages of mold growth) and typical foreign matter of similar color (such as plastics or desiccant particles similar in color to fragrances) are collected and analyzed to establish their respective "abnormal spectral characteristic models." For example, mold growth typically leads to an abnormally high moisture content (corresponding to enhanced OH bond absorption peaks), protein denaturation (NH bond absorption peak shift or deformation), and may produce specific mycotoxins, which have unique weak absorption signals in the near-infrared region. These normal and abnormal spectral models are parameterized and stored in a spectral feature library.

[0062] Step 2: Real-time spectral data preprocessing and feature extraction.

[0063] In the actual testing process, after the hyperspectral imaging module acquires the hyperspectral image data of the tested spice, the data processing center first performs the same preprocessing operation as during library construction on the original spectral curve of each pixel to ensure data consistency. Subsequently, the system uses a series of algorithms to extract parameters corresponding to the features defined in the standard spectral library from the preprocessed spectral curve. For example, peak-finding algorithms are used to locate all absorption peaks on the spectral curve; the peak wavelength, normalized peak height, and full width at half maximum (FWHM) of each peak are calculated. In addition, some derivative spectral features are calculated. Second-order derivative spectroscopy can effectively eliminate baseline drift and distinguish overlapping absorption peaks, thereby extracting more refined chemical information. Simultaneously, "spectral indices" for specific band combinations are calculated. For example, a "mold index" (MI) is constructed, which might be calculated as MI = (Rλ1 - Rλ2) / (Rλ1 + Rλ2), where λ1 is the characteristic absorption wavelength of mold products (such as ergosterol), and λ2 is a reference wavelength insensitive to mold growth.

[0064] Step 3: Discrimination is performed based on spectral matching and multi-band threshold matrix.

[0065] This step is crucial to the decision-making process. The data processing center extracts the spectral feature parameters of each pixel in real time and matches and compares them with models in the standard chemical feature spectral library. This process is not a simple single-point comparison, but rather a comprehensive decision-making process using a preset "multi-band threshold discrimination matrix." The specific implementation is as follows: 1. Spectral Angle Mapping (SAM): First, the spectral vector of each pixel is compared with the average spectral vector of the "normal spice standard spectral model," and the spectral angle between the two is calculated. The smaller the spectral angle, the more similar the two are. An angle threshold T_sam is set; any pixel with a spectral angle greater than this threshold is initially judged as "abnormal."

[0066] 2. Characteristic Peak Parameter Verification: For pixels that have passed the initial SAM screening (i.e., spectral angles less than T_sam), further checks are performed to ensure that the parameters of their key characteristic peaks fall within the range defined by the "normal spice standard spectral model." For example, check whether the intensity of the moisture peak (approximately 1450 nm) is within the normal dryness range, and whether the capsaicin characteristic peak (specific CH vibration peak) exists and has sufficient intensity. If any parameter exceeds the preset normal range, the pixel will be marked as "suspicious."

[0067] 3. Anomaly Feature Targeted Search and Threshold Determination: For all pixels marked as "abnormal" or "suspicious," the system initiates anomaly feature targeted search. That is, it uses the spectral data of these pixels to match "abnormal spectral feature models" in the spectral feature library. For example, it calculates the spectral similarity with the "mold spectral model" and checks whether its "mold index" exceeds the preset mold threshold T_mi. Simultaneously, it checks for the presence of spectral absorption characteristics unique to foreign objects such as stones or plastic. If the spectral features of a pixel match a certain anomaly model very highly, or if a key anomaly index exceeds a threshold, then that pixel is identified as a "potential anomaly."

[0068] Through the above three-layer progressive discrimination logic, the data processing center performs a comprehensive score or classification for each pixel. When multiple pixels in a continuous area are judged as "potential anomalies," the data processing center treats this area as a whole, recording its position, shape, and size information on the conveyor belt, thereby generating a first detection result containing the location of the anomaly area.

[0069] The advantages of this method are that it does not require complex model training, has strong interpretability, clear decision-making logic, and stable performance in detecting anomalies with well-defined features.

[0070] S203, in response to the first detection result, acquires a surface morphology image of the potential abnormal area using visible light imaging technology.

[0071] In this step, the data processing center uses the coordinate information of the potential abnormal areas recorded in the first detection result, combined with the operating speed of the conveying device, to accurately predict the time and location when these potential abnormal areas will reach the downstream line scan camera module.

[0072] When a tagged spice or a specific part thereof enters the field of view of the line scan camera module, the data processing center triggers the module to perform targeted imaging. The line scan camera module performs a high-resolution line-by-line scan of the area, generating a clear image of the surface morphology. Compared to indiscriminate full scanning of all materials, this "responsive" imaging method is more efficient because it focuses only on areas that have been initially suspected, reducing the amount of visible light image data that needs to be processed. This alleviates the computational burden on the data processing center and allows more computational resources to be allocated to these critical areas for more detailed analysis.

[0073] S204. Perform morphological analysis on the surface morphology image to obtain a second detection result for characterizing the surface features of potential anomalous regions.

[0074] In this step, after receiving surface morphology images of potentially anomalous areas, the data processing center immediately performs in-depth analysis. Specifically, the data processing center uses deep learning algorithms (e.g., convolutional neural networks, CNNs) to perform morphological analysis.

[0075] This deep learning algorithm can include the Spice Morphology Validation Network (SMV-Net) model, which is pre-trained on a large number of spice surface images, including normal surfaces, surfaces with mold, normal spice tissues (such as stems, scars, and wrinkles), and various possible impurities. Through training, the model learns to recognize different categories of visual features.

[0076] During detection, the model analyzes features such as texture, contour, and subtle color variations in the input surface morphology image. For example, moldy areas may appear as fine, velvety textures or irregular dark spots, while the normal stem of a spice has its own specific shape and texture.

[0077] The model outputs a judgment conclusion, namely the second detection result, which indicates whether the analyzed potential abnormal area is real mold or foreign matter, or simply normal tissue of the spice (e.g., a chili stem or stalk misidentified by hyperspectral imaging), thus effectively eliminating false positives generated in the first stage.

[0078] In this embodiment, the core task of the spice morphology verification network model is to perform secondary verification on the surface morphology images of potential abnormal regions initially screened by the hyperspectral module. This allows for highly accurate determination of whether the region represents a genuine physical anomaly (such as mold or foreign matter) or a normal spice structure (such as a chili stem, natural spots, or wrinkles), thereby eliminating false positives. The specific training process of SMV-Net is as follows: 1. Data Acquisition and Refined Annotation: First, a large-scale, high-quality image database is constructed. The images originate from the line scan camera module of this invention, covering various situations that may be encountered on an actual production line. Unlike conventional practices, the annotation process in this embodiment is extremely refined. A team composed of food science experts and senior quality inspectors uses professional annotation software to annotate each image of a "potentially abnormal area" marked by the hyperspectral module at the pixel level or bounding box level. The annotation categories not only include "normal surface," "moldy area," "pebbles," "plastic pieces," and "plant branches and leaves," but also include a large number of categories that are easily misjudged, such as "cross-section of chili pepper stem," "connection of chili pepper stem," "deep wrinkled shadows," "natural color spots during the ripening process," and "brittle texture caused by drying." Each annotation is cross-validated to ensure the accuracy of the "Ground Truth."

[0079] 2. Model Architecture Selection and Optimization: The backbone network of SMV-Net was not designed from scratch, but rather adopted a transfer learning strategy. This embodiment selects the EfficientNet-B2 architecture, known for its efficiency and lightweight nature, pre-trained on a large public image dataset (such as ImageNet), as the base model. The non-obvious reason for choosing this architecture is that its compound scaling method can balance the network's depth, width, and resolution, allowing the model to maintain high accuracy while keeping computational costs manageable, meeting the real-time requirements of high-speed inspection in industrial production lines. This embodiment removes the top classification layer of the original network and "freezes" the shallow convolutional layers (these layers learn common low-level features such as edges and textures). Then, several custom convolutional layers and a "Spatial Attention Module" are added afterward. This attention module is one of the key innovations of SMV-Net; it allows the network to learn to focus its "attention" on the most informative regions (e.g., the details of mold hyphae, rather than large areas of background color) when analyzing images, and to suppress irrelevant texture interference. Finally, a completely new fully connected classification layer is connected, corresponding to the finely labeled categories.

[0080] 3. Advanced Data Augmentation Strategies: To enable the model to generalize effectively and handle real-world scenarios such as varying lighting conditions, different spice poses, and minor surface contamination, a rigorous data augmentation scheme is required. In addition to standard random rotation, flipping, scaling, and cropping, this includes: Photometric distortion: Randomly altering the hue, saturation, and brightness of an image in the HSV color space to simulate the inherent color differences between different batches of spices and the subtle fluctuations in ambient lighting.

[0081] Elastic Transformations: Simulates the non-rigid deformation of spices caused by drying or extrusion, enhancing the model's robustness to shape changes.

[0082] CutMix and Mixup: These methods proportionally mix two different training images and their labels to generate new training samples. This forces the model to learn linear relationships between different features, preventing it from becoming overly dependent on specific visual patterns and significantly improving the model's generalization performance and ability to recognize occlusion.

[0083] 4. Model Training and Tuning: Training is divided into two phases. In the first phase, only the custom-added attention module and classification layer are trained, with a relatively large learning rate. The goal is to allow the newly added layers to quickly adapt to the spice morphology classification task. In the second phase, the entire network is "thawed," and all layers are fine-tuned end-to-end using a very small learning rate (e.g., a learning rate scheduler with warm-up and cosine annealing strategies). This allows the pre-trained low-level features to be subtly adjusted according to the characteristics of spice morphology. During training, a weighted cross-entropy loss function is used, assigning higher loss weights to classes with smaller sample sizes (e.g., rare foreign objects) to address the inherent class imbalance problem in the training data. The entire training process is performed on a workstation equipped with an NVIDIA A100 or equivalent GPU. Model performance is evaluated by monitoring precision, recall, and F1 score on the validation set, and the best-performing model weights are saved as the final SMV-Net model deployed to the data processing center.

[0084] S205, Based on the first and second detection results, generate a third detection result to identify highly suspicious areas.

[0085] Specifically, the data processing center receives the first detection results from the upstream hyperspectral imaging module in real time. The first detection results are in the form of a data list, which records in detail the physical coordinates, size and corresponding confidence scores of all potential abnormal areas that are initially identified as abnormal based on chemical composition analysis.

[0086] Meanwhile, the data processing center also received a second detection result obtained by high-resolution imaging of these same areas using a linear scan camera module, followed by morphological analysis using a deep learning algorithm. The second detection result provided a classification label for each potentially abnormal area, such as "true signs of mold," "suspected foreign object surface," "normal tissue structure (such as stem, scar, fold)," or "cannot be determined."

[0087] The fusion decision algorithm built into the data processing center is based on a strict "double confirmation" principle. This algorithm iterates through every entry in the first detection result and uses coordinate information to retrieve the corresponding morphological analysis label from the second detection result. A potential anomaly area is only upgraded to a "highly suspicious area" if it simultaneously meets two strict conditions: First, its anomaly confidence level in hyperspectral detection must be higher than a preset threshold to ensure that the anomaly in chemical composition is significant; second, its classification label in visible light morphology analysis must clearly point to "true signs of mold" or "suspected foreign matter surface" to exclude areas that are identified as normal tissue structures.

[0088] All regions that pass this rigorous screening process, along with their updated overall confidence levels, are aggregated into a new data list, known as the third detection result. This third detection result is a high-purity list of suspicious targets resulting from two levels of cross-validation, significantly reducing the data processing load in subsequent detection stages and improving the accuracy of the final decision.

[0089] S206, in response to the third detection result, uses X-ray imaging technology to perform a penetrating scan on the highly suspicious area to obtain the internal density information of the highly suspicious area.

[0090] This step aims to perform a final in-depth verification of the few highly suspicious targets selected. The data processing center first extracts the precise physical coordinate sequence of all highly suspicious areas from the third detection result. Then, it accesses real-time position and velocity information synchronized with the encoder of the transport device to dynamically and proactively calculate a precise trigger time window for each highly suspicious area. This time window corresponds to the precise moment when the area moves from its current position to directly below the scanning field of view of the downstream X-ray imaging module. A very short time before the predicted time point arrives, the data processing center sends a composite command containing the target coordinates, desired scan resolution, and exposure dose to the control system of the X-ray imaging module via a high-speed communication interface.

[0091] Upon receiving the command, the X-ray imaging module's controller precisely activates the X-ray source, emitting a high-energy X-ray pulse focused by a collimator the instant the highly suspicious area enters the field of view, allowing it to precisely penetrate the target area. Simultaneously, linear or area array X-ray detectors located below the delivery device acquire signals, capturing the X-rays whose intensity attenuates after penetrating the spice and converting them photoelectrically into digital signals. After analog-to-digital conversion and preliminary processing, these signals are reconstructed into a two-dimensional grayscale image that accurately reflects the density distribution of matter within the target area. This high signal-to-noise ratio image provides the internal density information of the highly suspicious area, offering decisive, density-based evidence for the final determination of the anomaly's nature.

[0092] This "on-demand" intelligent scanning mechanism not only greatly saves energy and extends the lifespan of the X-ray source, but more importantly, it allows the system to concentrate all imaging resources on a few key targets, thereby obtaining the highest quality diagnostic information.

[0093] S207, based on the third detection result and internal density information, determine the abnormal material information of the detected spice.

[0094] This step is the core manifestation of the three-stage process differentiation in this embodiment, and it is also the key to achieving a breakthrough in the detection of internal mold and foreign matter of the same color. After the initial screening of chemical composition by hyperspectral imaging and the identification of surface morphology by visible light, the detection process enters the final, physical-based adjudication stage. The internal density information provided by X-ray imaging, as an independent and decisive physical dimensional evidence, directly reveals the internal structural state of highly suspicious areas, thereby enabling a final arbitration of any ambiguity or uncertainty that may exist in the first two stages of detection. It is this "X-ray confirmation" step that enables this embodiment to accurately distinguish the most fundamental physical differences between normal tissue, internal moldy areas, and foreign matter of the same color, achieving a decisive breakthrough in addressing these two types of defects that traditional color sorters cannot detect.

[0095] Among them, abnormal material information refers to the final determined comprehensive data package containing the category of unqualified spices (such as internal mold or foreign matter of the same color), severity, and their precise three-dimensional spatial coordinates and physical dimensions on the conveying device. This data package is directly used to guide subsequent rejection operations.

[0096] The specific implementation process for this step is as follows: First, the data processing center received two key input data sets: one was the third detection result, which indicated that the spices in a certain two-dimensional coordinate region (X,Y) on the conveying device were judged as "highly suspicious" because their chemical composition (hyperspectral detection result) and surface morphology (visible light detection result) both showed abnormalities; the other was the internal density information that precisely corresponded to the highly suspicious region, which was a grayscale image generated by the X-ray imaging module showing the internal material density distribution of the region.

[0097] Next, the data processing center executes a multimodal feature fusion decision algorithm. The core of this algorithm is to perform a final cross-validation of features from three modalities based on preset logical rules to determine the nature of the anomaly and generate the final anomalous material information. The implementation process can be broken down into the following sub-steps: 1. Region Registration and Feature Extraction: The system first precisely maps the bounding boxes of the highly suspicious regions marked in the third detection result to the corresponding locations in the X-ray internal density image. Then, the algorithm calculates several key density feature parameters within this region. These parameters include: (1) Average density: The average value of all pixel gray values ​​in the region is calculated, reflecting the overall density level of the region.

[0098] (2) Density standard deviation: The standard deviation of pixel gray values ​​within a calculated area reflects the uniformity of density within that area. Uneven density may indicate anomalies in the internal structure.

[0099] (3) Relative density contrast: The average density in the region is compared with the average density of the adjacent background spice region that was determined to be normal in the previous step, and a relative ratio is calculated.

[0100] (4) High / low density cluster analysis: Use image segmentation algorithms (such as thresholding or region growing algorithms) within the region to identify and quantify whether there are isolated clusters that are significantly higher or lower than the surrounding background, and calculate the area, shape factor, etc. of these clusters.

[0101] 2. Final decision based on rule-based decision trees or logical matrices: The data processing center has a built-in decision engine that makes judgments based on a series of expert rules. These rules bind the preliminary conclusions from the hyperspectral and visible light phases with X-ray density characteristics, forming a decision matrix. The following is an example of the decision logic: Rule 1: Confirmation of Internal Mold. If a highly suspicious area shows abnormalities in moisture or specific organic matter (indicating changes in chemical composition) in hyperspectral analysis, and visible light analysis rules it out as normal tissue (such as a chili pepper stem), and its internal density information in X-ray shows that the average density is significantly lower than that of the surrounding normal spice area (e.g., relative density contrast less than 0.8), and the density standard deviation is large (indicating internal tissue decay and uneven structure), then the system will ultimately determine that the material is "internal mold." The abnormal material information will be recorded as "mold" and may be given a severity level of "mild / moderate / severe" based on the degree of density reduction and the size of the area.

[0102] Rule 2: Confirmation of High-Density Foreign Objects of the Same Color. If a highly suspicious area's hyperspectral analysis shows its chemical composition is completely different from that of a fragrance, and visible light analysis may not be able to clearly distinguish it due to its similar color, but its X-ray internal density information shows that there are one or more clumps with extremely high average density (e.g., relative density contrast greater than 2.0), and these clumps have clear outlines and uniform internal density, then the system will ultimately determine that the material is a "high-density foreign object of the same color" (such as pebbles, glass shards, or metal filings). The abnormal material information will be recorded as "high-density foreign object," along with the precise location and size of the foreign object.

[0103] Rule 3: Confirmation of Low-Density Foreign Matter of the Same Color. If a highly suspicious area shows abnormal chemical composition in hyperspectral analysis (e.g., exhibiting spectral characteristics of plastic or plant stems), and visible light analysis may not be effective in distinguishing it, but its internal X-ray density information shows that the average density is significantly lower than that of normal fragrances (e.g., relative density contrast less than 0.9), but it does not have an uneven density distribution like mold, but rather presents a relatively homogeneous low-density area, then the system can determine it to be a "low-density foreign matter of the same color" (such as mixed-in dried plant stems, plastic pieces, etc.).

[0104] Rule 4: Eliminating False Alarms. In extremely rare cases, if an area marked as highly suspicious shows no statistically significant difference in its internal density characteristics compared to the surrounding normal spice areas according to X-ray density information, the system will determine this to be an extremely rare false alarm generated by the first two modalities and remove it from the anomaly list without generating anomaly material information. This step is the final quality control checkpoint, ensuring the accuracy of the rejection.

[0105] Generate and package abnormal material information: Once the category and severity of abnormal materials are determined according to the above rules, the system will integrate this information, along with the material's precise three-dimensional position in the conveyor coordinate system (X and Y coordinates from the image, Z coordinate, i.e., material thickness, can be estimated from X-ray absorbance or set as a constant) and physical dimensions (calculated from the pixel area of ​​the abnormal region combined with camera calibration parameters), into a structured data packet. This data packet is the final "abnormal material information," which will be immediately transmitted to the control system of the rejection device as a precise instruction to perform the physical removal operation.

[0106] Furthermore, in some embodiments, after step 207, the following steps are also included: S208 generates rejection control instructions based on abnormal material information.

[0107] S209, send the rejection control command to the foreign object drive rejection device to physically remove the abnormal material.

[0108] In practice, once the data processing center generates abnormal material information containing the precise location of the abnormal material, it immediately calculates the time it takes for the abnormal material to arrive at the rejection device at the end of the conveyor belt. At the appropriate moment, the data processing center sends a rejection control command containing both location and time information to the rejection device.

[0109] Upon receiving a rejection control command, the rejection device (such as a pneumatic rejection device) activates the nozzle at the corresponding position. The moment the defective material reaches directly beneath the nozzle, a strong, brief burst of air is ejected, blowing it out of the material flow and into the collection trough. The entire process is fast and precise, achieving automated, contactless online removal of non-conforming products and ensuring the quality of the final product.

[0110] This invention constructs a three-level verification process by organically combining hyperspectral imaging, visible light imaging, and X-ray imaging technologies with a progressive data fusion strategy. The first level, hyperspectral imaging, performs a wide-range chemical composition screening to identify potential anomalies. The second level, visible light imaging, performs morphological verification of these anomalies to eliminate false positives. The third level, X-ray imaging, confirms the internal density of highly suspicious areas to make a final decision. This multimodal collaborative approach leverages the unique advantages of each imaging technology, overcoming the limitations of single technologies (such as traditional color sorters) in detecting mold and discolored foreign matter within fragrances. This significantly improves the accuracy and reliability of fragrance quality testing, ensuring product quality and safety.

[0111] Regarding step S202, in some specific implementation scenarios, such as the actual application scenario of spice quality inspection, simply using conventional machine learning algorithms (such as basic support vector machine SVM or partial least squares discriminant analysis PLS-DA) to train a small number of samples may encounter two thorny core problems: First, the overfitting problem, that is, the model overlearns the unique noise and random features of the limited samples, resulting in its extremely poor generalization ability to new samples; Second, the problem of "class imbalance and lack of diversity", that is, samples of internal mold or rare foreign objects of the same color are difficult to obtain, and their morphology, stage and type are ever-changing, and the limited samples are far from enough to cover all possible anomalies.

[0112] To address the above problems, the low-sample machine learning algorithm used in this embodiment can provide a targeted solution.

[0113] First, this embodiment abandons the traditional "multi-class" training paradigm and instead adopts a hybrid strategy of "single-class learning and anomaly detection". Specifically, the core of this strategy is not to teach the model "what is mold", but to let the model deeply learn "what is absolutely normal spice". Since the number of normal spice samples is massive, a high-dimensional feature space can be constructed, and the spectral features of all normal samples (e.g., principal components after dimensionality reduction using principal component analysis (PCA), or combined features such as the intensity, position, and full width at half maximum of specific chemical bond absorption peaks) can be mapped into this space, forming a compact and clearly defined "normal feature cluster".

[0114] This embodiment does not use simple Euclidean distance or Gaussian distribution to define the boundary of this cluster. Instead, it employs an algorithm called "One-Class Support Vector Machine" combined with "Deep Support Vector Data Description" (Deep SVDD). This algorithm learns a non-linear, extremely compact hyperspherical boundary that encompasses the vast majority of normal sample data points. During actual detection, any spectral feature of the detected pixel that is mapped outside this hyperspherical boundary is judged as "abnormal" and becomes a potential anomalous region.

[0115] The key to this method is that it does not require any moldy or foreign object samples for training, fundamentally solving the problem of scarce anomalous samples. It is sensitive to any unknown anomalies that deviate from the "absolutely normal" chemical characteristics, whether it is slight mold in the early stages or previously unseen foreign objects of the same color.

[0116] Secondly, in order to address the normal spectral fluctuations in spices due to differences in origin, batch, and drying process (which may be misjudged as abnormal), this embodiment introduces "Domain Adaptation" and "Generative Adversarial Network (GAN)" to enhance and normalize spectral data.

[0117] In practical applications, different batches of spices can be considered as coming from different "data domains." This embodiment collects spectral data from a small number of new batches of normal spices and uses domain-adaptive techniques (such as Domain Adversarial Neural Networks (DANNs)) to fine-tune the model's input layer without altering the already trained core model of the "normal feature clusters," learning a mapping function from the new domain to the old domain. This is equivalent to an intelligent "calibration" process, effectively suppressing the normal spectral fluctuations of the new batch of spices and significantly reducing the false alarm rate.

[0118] Furthermore, for known but limited mold types, generative adversarial networks (specifically conditional generative adversarial networks, CGANs) can be used to generate a large number of highly realistic and diverse virtual mold spectral samples, conditioned on the mold type or degree. These virtual samples can be used to assist in training a secondary, small-scale classifier to perform preliminary classification of regions already identified as anomalous by the "single-class learning" model (e.g., distinguishing between mold and some known foreign object), providing richer prior information for subsequent steps.

[0119] This composite algorithm strategy, which combines single-class anomaly detection, domain adaptation, and generative data augmentation, creatively transforms the challenge of low-sample learning into an anomaly detection problem based on massive normal samples, and uses advanced technical means to solve the challenges of batch differences and anomaly diversity in actual production.

[0120] In the three-level verification mechanism of this embodiment, some contradictory situations may arise. For example, hyperspectral imaging strongly suggests internal mold growth (chemical change), but the density difference in X-rays is very weak; or, visible light images show textures resembling mold spots, but both hyperspectral and X-ray signals show no abnormalities. Conventional "voting methods" or "weighted average methods" are either too hasty and lead to misjudgments when faced with such complex contradictions, or they fail to make a decision and thus miss the mark.

[0121] Therefore, this embodiment provides an adaptive decision fusion network based on Bayesian reasoning and evidence theory. The specific solution is as follows: The first step involves constructing a "credible evidence model" for each modality, rather than directly using the detection results. For each modality's detection result, the system outputs no longer a simple "yes / no" conclusion, but a probabilistic evidence package. This evidence package, based on a Bayesian framework, includes the modality's support (i.e., posterior probability) for each hypothesis such as "normal," "moldy," and "foreign object." For example, the hyperspectral module's output might be: "There is an 85% probability of mold, a 10% probability of normal tissue (due to high moisture content), and a 5% probability of unknown substance." This probability is calculated based on the similarity between the spectral characteristics of the region and the spectral distribution of various samples in the database, combined with the sensor's historical performance data (i.e., its inherent uncertainty or noise level at a specific signal intensity). This step transforms deterministic detection results into probabilistic evidence with quantified uncertainty, providing a mathematical foundation for subsequent rational arbitration.

[0122] The second step involves introducing Dempster-Shafer evidence theory for cross-modal evidence synthesis. When evidence packages from multiple modalities are aggregated at the data processing center, a simple weighted average is no longer used; instead, Dempster's rule of combination is employed. This rule rigorously combines evidence from different information sources. For example, if hyperspectral evidence strongly supports "mold," while X-ray evidence is less clear and has low support for all hypotheses (i.e., high uncertainty), the rule of combination automatically enhances the overall confidence of the "mold" hypothesis because the "uncertain" X-ray evidence does not provide strong opposing evidence. Conversely, if X-ray provides strong evidence supporting "normality" (e.g., uniform and standard density), it will strongly conflict with the hyperspectral "mold" evidence.

[0123] Step 3: "Intelligent Arbitration" and "Request for Re-examination" Mechanisms Based on Conflict Measurement. During evidence synthesis, a conflict coefficient k is calculated. This coefficient quantitatively describes the degree of contradiction between different modal evidence. When the conflict coefficient k is below a preset threshold, the synthesized result is accepted, and the hypothesis with the highest confidence level is used as the final decision. However, when the conflict coefficient k exceeds the threshold, it indicates serious disagreement between modalities, and the risk of conventional decision-making is high. At this point, the data processing center activates the intelligent arbitration module. This module makes a more prudent decision based on a preset expert rule base (e.g., rule: "When suspected mold is present but density is indistinguishable, prioritize the hyperspectral result, but reduce the rejection priority"). More unexpectedly, the data processing center may also trigger a "request for re-examination" feedback signal. For example, it may instruct the X-ray module to perform an enhanced scan of the specific area using higher energy or a longer exposure time to obtain more decisive evidence before making a secondary decision.

[0124] This embodiment achieves an objective and rational decision-making capability. It is no longer a rigid rule-based judgment, but rather acts like a committee of experts from multiple fields, conducting rigorous logical reasoning and debate based on the "reliability" of each piece of evidence. When dealing with conflicting information, the system understands "when to believe which piece of evidence" and when to acknowledge that "the information is insufficient to make a reliable judgment." This ability to make far more accurate judgments than conventional algorithms in extremely complex boundary cases, and to dynamically seek more information to resolve conflicts, allows the system to achieve an unprecedented balance between the lowest false positive and false negative rates. Especially when dealing with the most difficult-to-detect critical defects, its robustness and intelligence reach a new level.

[0125] In some embodiments, on a high-speed conveyor belt, individual spices are randomly distributed, colliding with each other, and even tumbling. A hyperspectral module marks an anomaly point P0 at time t0. By the time this spice moves to the linear scan camera (time t1) and X-ray (time t2), its position and orientation may have completely changed. Conventional image registration or fixed-delay triggering almost fails on such non-rigid, randomly moving objects, causing subsequent modules to misalign with previously marked feature regions, resulting in severe detection failures. Conventional solutions often attempt to circumvent this problem by improving mechanical stability or reducing speed, but this sacrifices efficiency and practical application value.

[0126] Therefore, this embodiment introduces a motion model-driven dynamic four-dimensional spatiotemporal prediction and correction mechanism. This mechanism includes the following steps: Step 1: Instantaneous Multi-View Figure 33D pose reconstruction and centroid trajectory capture. When an individual spice is first scanned by the hyperspectral module, this invention does not merely record its two-dimensional image and spectral data. A low-resolution auxiliary camera, located to the side of the hyperspectral module and triggered synchronously, simultaneously captures a side view of the spice. Using these two orthogonal images, the system instantly builds a simplified 3D mesh model containing basic rotation and morphological parameters through stereo vision algorithms (such as spatial sculpting or contour-based reconstruction), and accurately calculates its centroid position in 3D space. Simultaneously, the system activates a high-frequency tracker, continuously capturing several consecutive positions of the spice within a very short time at a frequency far exceeding the conveyor belt speed, thereby obtaining its initial translational velocity vector and angular velocity vector. The non-obvious aspect of this step is that it elevates a two-dimensional detection problem to a three-dimensional dynamic level from the outset, providing a physical basis for subsequent predictions.

[0127] Step 2: Constructing an individualized motion trajectory prediction model based on a physics engine. The data processing center incorporates a lightweight physics simulation engine. For each identified spice individual, the system creates an independent virtual physical entity based on its 3D model, center of mass, initial linear velocity, and angular velocity obtained in Step 1. This engine simulates the friction of the conveyor belt, air resistance, and a probabilistic statistical perturbation model simulating random collisions between spices. Based on these physical laws, the engine can predict the spice's motion trajectory at any future time t in real time with high accuracy. x (For example, t1 and t2) have their centroids in the three-dimensional position (x, y, z) of the conveyor belt coordinate system and their own three-dimensional rotational orientation (Eulerian angles or quaternions). This model is individualized, with each spice having its own independent, continuously updated predicted trajectory, rather than a global, static delay.

[0128] Step 3: Target Area Projection and Dynamic Coordinate Broadcasting Based on Attitude Prediction. When the spice is predicted to enter the field of view of the linear scan camera at time t1, the system does not simply translate the initial anomaly point coordinates P0. Instead, based on the predicted 3D attitude, it reprojects the position of P0 on its 3D model onto the imaging plane of the visible light camera at the current attitude, obtaining a completely new, attitude-corrected target coordinate P1. This coordinate P1 is the "target area" that the linear scan camera needs to focus on scanning. Similarly, before reaching the X-ray module at time t2, the system will perform attitude projection again to obtain the final target area coordinates P2. These dynamically calculated target area coordinates will be "broadcast" to the downstream imaging module via the internal high-speed bus. After receiving the instruction, the downstream module will perform an instantaneous, high-precision local scan.

[0129] This embodiment achieves accurate prediction and full-process locking of each independent non-rigid object in a high-speed moving flow through the methods described above. Each spice is equipped with a dedicated "GPS navigation system," which accurately predicts the spatiotemporal coordinates of its key components at the next detection station, regardless of its tumbling or collisions. This enables near-zero-error collaborative aiming between multimodal sensors at speeds far exceeding conventional industrial limits, solving the most challenging spatiotemporal synchronization problem in high-speed, random material flow detection, and significantly improving detection accuracy and processing speed.

[0130] The method provided in the above embodiments can be specifically executed by a data processing center that has deployed the detection system of the aforementioned embodiments. The data processing center includes electronic equipment. The electronic equipment in the embodiments of the present invention will be described below from a hardware processing perspective. Please refer to [link to relevant documentation]. Figure 3 This is a schematic diagram of the physical device structure of an electronic device in an embodiment of the present invention.

[0131] It should be noted that, Figure 3 The structure of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0132] like Figure 3 As shown, the electronic device includes a Central Processing Unit (CPU) 401, which can perform various appropriate actions and processes based on a program stored in Read-Only Memory (ROM) 402 or a program loaded from storage portion 408 into Random Access Memory (RAM) 403, such as performing the methods described in the above embodiments. The RAM 403 also stores various programs and data required for system operation. The CPU 401, ROM 402, and RAM 403 are interconnected via a bus 404. An Input / Output (I / O) interface 405 is also connected to the bus 404.

[0133] The following components are connected to I / O interface 405: input section 406 including audio input devices, push-button switches, etc.; output section 407 including a liquid crystal display (LCD) and audio output devices, indicator lights, etc.; storage section 408 including a hard disk, etc.; and communication section 409 including a network interface card such as a LAN (Local Area Network) card, modem, etc. Communication section 409 performs communication processing via a network such as the Internet. Drive 410 is also connected to I / O interface 405 as needed. Removable media 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 410 as needed so that computer programs read from them can be installed into storage section 408 as needed.

[0134] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by central processing unit (CPU) 401, it performs the various functions defined in the present invention.

[0135] It should be noted that specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0136] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.

[0137] Specifically, the electronic device of this embodiment includes a processor and a memory. The memory is coupled to one or more processors and is used to store computer program code. The computer program code includes computer instructions. One or more processors call the computer instructions to cause the electronic device to perform the method provided in the above embodiment.

[0138] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The storage medium carries one or more computer programs that, when executed by a processor of the electronic device, cause the electronic device to implement the methods provided in the above embodiments.

[0139] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

[0140] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for detecting internal mold growth and look-alikes in a flavor, characterized by, The method comprises: acquiring hyperspectral image data of the detected spice; based on the hyperspectral image data, analyzing the chemical composition characteristics of the detected spice to identify potential abnormal areas of the detected spice, obtaining a first detection result containing the location of the abnormal area; in response to the first detection result, acquiring the surface morphology image of the potential abnormal area by visible light imaging technology; performing morphology analysis on the surface morphology image to obtain a second detection result for characterizing the surface features of the potential abnormal area; generating a third detection result for identifying a highly suspicious area according to the first detection result and the second detection result; in response to the third detection result, performing a penetrating scan on the highly suspicious area by X-ray imaging technology to obtain internal density information of the highly suspicious area; based on the third detection result and the internal density information, determining the abnormal material information of the detected spice.

2. The method of claim 1, wherein, After determining the abnormal material information of the detected spice based on the third detection result and the internal density information, the method further comprises: generating a rejection control instruction according to the abnormal material information; sending the rejection control instruction to a foreign matter driving rejection device to physically remove the abnormal material.

3. The method of claim 1, wherein, The analysis of the chemical composition characteristics of the detected spice specifically comprises: processing the hyperspectral image data using a low-sample machine learning algorithm to extract characteristic spectra and identify the potential abnormal area.

4. The method of claim 1, wherein, The morphology analysis of the surface morphology image specifically comprises: analyzing the surface morphology image using a deep learning algorithm to determine whether the potential abnormal area is a real abnormality or normal tissue of the detected spice.

5. The method according to any one of claims 1 to 4, characterized in that, In the step of acquiring the hyperspectral image data of the detected spice, the spectral range of the hyperspectral image data is 400-2500 nm, and the spectral resolution is 1-10 nm.

6. A spice internal mold and look-alike detection system characterized by, The system comprises: a conveying device for conveying the detected spice; a hyperspectral imaging module arranged along the conveying direction of the conveying device for acquiring hyperspectral image data of the moving detected spice; a linear array camera module arranged downstream of the hyperspectral imaging module for imaging the detected spice to acquire a surface morphology image; an X-ray imaging module arranged downstream of the linear array camera module for penetrating scanning the detected spice to acquire internal density information; a data processing center communicatively connected with the hyperspectral imaging module, the linear array camera module, and the X-ray imaging module, and configured to execute the method of any one of claims 1-5.

7. The system of claim 6, wherein, The system further comprises a rejection device communicatively linked with the data processing center, the rejection device being arranged downstream of the X-ray imaging module for physically removing the detected abnormal material.

8. The system of claim 6, wherein, The data processing center is built-in with a low-sample machine learning algorithm for generating a first detection result based on the hyperspectral image data.

9. The system of claim 6, wherein, The data processing center is built-in with a deep learning algorithm for generating a second detection result based on the surface morphology image.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, which is executed by a processor, implements the method according to any one of claims 1 to 5.