Optical detection method and system for content of vitamin tablets
By generating gradient fields driven by residual flux and constructing Riemannian manifold curvature tensors, combined with symplectic geometry optimization within the Hamiltonian mechanics framework, the problems of environmental sensitivity and formulation adaptability in the optical detection of vitamin tablets were solved, achieving dynamic maintenance and stability of detection accuracy.
Patent Information
- Application Number
- CN202511178327.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-22
- Publication Date
- 2025-11-14
AI Technical Summary
Existing optical detection methods for vitamin tablets have shortcomings in terms of environmental sensitivity, formulation adaptability, and dynamic optimization mechanisms, leading to decreased detection accuracy and loss of timeliness.
The method employs residual flux-driven gradient field generation, Riemannian manifold curvature tensor construction, and Hamiltonian mechanics framework for symplectic geometry optimization. Through multi-axis robotic arm scanning, derivative spectral analysis, subspace projection, and support vector machine dynamic correction model, parameters are adjusted in real time to adapt to environmental fluctuations and formula changes.
It achieves high precision and stability in vitamin tablet detection under environmental disturbances and formula adjustments, improves the response sensitivity of the detection system and the rapid convergence of detection results, and overcomes the limitations of traditional methods.
Smart Images

Figure CN120948385A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pharmaceutical quality testing technology, and in particular to an optical detection method and system for vitamin tablet content. Background Technology
[0002] Optical content detection technologies for vitamin tablets (such as near-infrared spectroscopy and Raman spectroscopy) are widely used in pharmaceutical quality control due to their rapid and non-destructive characteristics. However, existing methods suffer from the following key bottlenecks: 1. Environmental sensitivity defects: Interference factors such as ambient temperature and humidity, light source fluctuations, etc. can easily cause spectral baseline drift and characteristic peak distortion. Traditional linear correction models (such as multivariate scattering correction and standard normal transformation) are difficult to capture nonlinear perturbation modes, and the detection accuracy decreases significantly with environmental fluctuations.
[0003] 2. Insufficient formulation adaptability: When the ratio of excipients in vitamin preparations is changed, the coupling relationship between spectral absorption characteristics and active ingredients undergoes a nonlinear shift, requiring the existing static calibration model to be recalibrated, resulting in detection interruption and loss of timeliness.
[0004] 3. Lack of dynamic optimization mechanism: Existing algorithms lack the ability to jointly model spectral residual flux, manifold structure and dynamic system, cannot generate gradient field to drive parameter correction in real time, and are even more difficult to maintain stable detection accuracy under environmental disturbances. Summary of the Invention
[0005] This invention provides an optical detection method for vitamin tablet content, which addresses the problem of how to achieve adaptive parameter correction of the vitamin optical detection model under formula changes and environmental fluctuations, and dynamically maintain detection accuracy, through residual flux-driven gradient field generation, Riemannian manifold curvature tensor construction, and Hamiltonian symplectic geometry optimization.
[0006] To address the aforementioned technical problems, this invention provides an optical detection method for vitamin tablet content, comprising: A multi-axis robotic arm controls a fiber optic probe array to perform spatial positioning scanning on the surface of vitamin tablets. Irradiation is carried out at incident angles of 0°, 45°, and 90°. The reflected light signal is captured in real time by an indium gallium arsenide photodetector to generate raw spectral data containing five-dimensional parameters including spatial coordinates, incident angle, wavelength, and light intensity. During the scanning process, a rotating platform drives the vitamin tablets to complete a 360-degree circumferential rotation with a step angle of 2 degrees. At the same time, a vertical lifting mechanism moves along the Z-axis with a step distance of 0.1 mm to form a high-density three-dimensional spatial sampling grid. The characteristic absorption peaks of vitamins were located by derivative spectroscopy, and the signal-to-noise ratio and wavelength synergy were evaluated to generate weighted spectral data with different wavelength contributions. The spectral data is decomposed into two orthogonal spaces using a subspace projection algorithm. Based on the separated spectral dataset and noise-labeled spectra, a support vector machine dynamic correction model is established to output the calibration spectrum. The spectral feature vector is projected onto the pre-trained spectral-concentration mapping matrix built into the online PLS regression model. A dynamic sample queue is constructed using a sliding window mechanism, concentration label calibration is performed, and the updated principal component factor loading coefficients and concentration regression coefficient matrix are output. The standard sample library is retrieved through a four-level index, and the absolute deviation, relative deviation, statistical error, and attribution deviation are calculated. After decomposing the error coefficients, they are synchronized to the dynamic calibration module and the incremental quantitative analysis module through a dual-channel transmission mechanism. The expression for synchronizing the decomposed error coefficients to the dynamic calibration module and the incremental quantitative analysis module through the dual-channel transmission mechanism includes: in, For Hamiltonian; It is the transpose of the generalized momentum vector; Generalized coordinates; Generalized momentum; This is the quality matrix; It is the potential energy term; The mathematical characteristics of the error coefficients are analyzed, the weight ratio of historical model parameters is adjusted based on the time decay function, the fused integrated model parameter set is generated, the PLS regression model is optimized, and the vitamin content detection results are output.
[0007] Furthermore, the process of retrieving the standard sample database through a four-level index and calculating the absolute bias, relative bias, statistical error, and attribution bias includes: The online result verification module obtains the vitamin content calculation results output in real time by the incremental quantitative analysis module through a high-speed data bus. The calculation results include the predicted concentration values of the target vitamin components and their corresponding sample identification codes.
[0008] Furthermore, the process of retrieving the standard sample database through a four-level index and calculating the absolute bias, relative bias, statistical error, and attribution bias also includes: The standard sample library adopts a distributed database architecture, with a four-level index hierarchy based on vitamin type, tablet formulation matrix, production process batch, and storage temperature and humidity conditions. During retrieval, the original spectral features of the current sample are first extracted, and the spectral bands defined by the feature wavelengths are selected and multi-level matching is performed in the standard sample library.
[0009] Furthermore, multi-level matching includes: The first level of matching filters out standard spectral records for the target vitamin type in the vitamin type index layer; The second-level matching uses the Mahalanobis distance algorithm to calculate the similarity between the measured spectrum and the candidate standard spectrum in the characteristic wavelength region, and filters the records that meet the similarity standard. The third-level matching uses a spectral angle mapping algorithm to calculate the spatial angle of the spectral curves in the formulation matrix index layer, and records with an angle less than a set threshold are included in the final candidate set.
[0010] Furthermore, the optical detection method for vitamin tablet content includes: After successful multi-level matching in the standard sample library, the system extracts the standard values of vitamin content and their measurement uncertainty information of each standard sample in the candidate set calibrated by high performance liquid chromatography. The predicted concentration values are then compared with the calibration values of the matched standard samples one by one to generate a structured paired data set.
[0011] Furthermore, the calculation of absolute deviation, relative deviation, statistical error, and attribution bias includes: The first dimension calculates the absolute deviation: Perform an algebraic operation on each paired record by subtracting the standard value from the predicted value to generate the individual absolute deviation value and the mean absolute deviation; The second dimension calculates the relative deviation: the individual absolute deviation value is divided by the corresponding standard value to convert it into a percentage relative deviation, and the standard deviation of the relative deviation within the paired set is calculated. The third dimension performs statistical error analysis: a subset is randomly selected from the paired set using the bootstrap sampling method, the root mean square error of each subset is calculated, and a set percentile is taken as the statistical error index. The fourth dimension performs deviation attribution analysis: the ratio of positive deviation records to negative deviation records is statistically analyzed, and the direction of system deviation is marked when the absolute value of the ratio difference exceeds a set threshold.
[0012] Furthermore, the optical detection method for vitamin tablet content includes: After receiving the deviation data, the error coefficient synthesis engine performs triple-weighted fusion: The spectral matching confidence level is used as the first weighting factor, and the weighting increases by a set percentage for each increase in confidence level by a set value. The standard value uncertainty is used as the second weighting factor, and the weighting is increased by a set percentage for each decrease in the uncertainty by a set value. Historical verification stability is used as the third weighting factor, and the reciprocal of the deviation fluctuation coefficient of the most recent verification of this sample type is taken as the weight value.
[0013] Furthermore, according to the optical detection method for vitamin tablet content, Hamiltonian measurement... With potential energy term The content also includes: in, It is the potential energy term; To output the Riemann curvature tensor (fourth-order tensor). For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; in, Christoffel notation ( (For tensor indexes).
[0014] Furthermore, according to the aforementioned optical detection method for vitamin tablet content, the process of synthesizing error coefficients and feeding them back to the dynamic correction and quantitative analysis module via dual channels also includes: The feedback controller decomposes the error coefficient into two independent data streams, which are then synchronously applied to the downstream module through a dual-channel transmission mechanism. In the feedback channel of the SVM dynamic calibration module, the comprehensive absolute deviation value of the error coefficient, the deviation direction indicator and the dynamic correction factor are analyzed to adjust the SVM model parameters. In the feedback channel of the incremental quantitative analysis module, the statistical error confidence interval, relative deviation percentage range, and dynamic correction factor of the error coefficient are converted into PLS model parameter adjustment amounts.
[0015] Furthermore, an optical detection system for vitamin tablet content, used to implement the method described in any one of the above, includes: Near-infrared dynamic scanning device, including a multi-axis robotic arm, fiber optic probe array and three-angle light source; The spectral processing unit performs derivative spectral analysis, weight matrix synthesis, and subspace projection. The dynamic correction unit is configured with an SVM model that can switch kernel functions and a real-time parameter update interface. Quantitative analysis unit with built-in online PLS model and incremental learning mechanism; The verification feedback unit enables standard sample library retrieval, four-dimensional deviation analysis, and error coefficient synthesis. The results optimization unit performs confidence weight calculation and regression coefficient optimization.
[0016] The key innovations of this invention include: (1) A dynamic gradient field generation mechanism driven by residual flux is proposed. The parameter gradient field is generated in real time by optically detecting the flux change of the residual, providing dynamic directional guidance for model optimization.
[0017] (2) Establish a potential energy constraint mechanism based on the curvature tensor of the Riemannian manifold, use the curvature tensor to characterize the nonlinear structure of the vitamin spectral feature space, and generate the potential energy field function for updating the constraint model parameters.
[0018] (3) Design a symplectic geometry optimization algorithm based on Hamiltonian mechanics framework, integrate gradient field and potential energy constraints into the symplectic geometry iteration process, and realize dynamic adaptive correction of the weight of the detection model.
[0019] The following are its main beneficial effects: (1) This invention uses a gradient field generation mechanism driven by residual flux to capture the dynamic changes in the deviation between the spectral detection value and the theoretical value in real time, and generates a targeted parameter correction direction. Compared with the traditional fixed step size optimization method, this mechanism significantly improves the model's response sensitivity to environmental fluctuations (such as changes in temperature and humidity, and formula adjustments), ensuring that the detection system quickly converges to the optimal state under disturbances.
[0020] (2) The constructed Riemannian manifold curvature potential energy constraint accurately characterizes the intrinsic nonlinear correlation of vitamin spectral features. This mechanism breaks through the limitations of traditional linear models, automatically constrains the parameter update path when the proportion of formulation components changes, effectively suppresses model overfitting and local oscillations, and ensures the stability of detection results under complex component scenarios.
[0021] (3) The dynamic optimization algorithm based on the symplectic geometric framework transforms the gradient field and potential energy constraints into the canonical equations of the Hamiltonian system, and achieves continuous fine-tuning of the weight parameters through structure-preserving iteration. This innovation enables the detection model to autonomously maintain a high-precision state during long-term operation, overcomes the problem of accuracy decay caused by environmental cumulative drift in traditional static models, and achieves dynamic and sustainable maintenance of vitamin content detection accuracy. Attached Figure Description
[0022] Figure 1 A schematic flowchart of an optical detection method for vitamin tablet content provided in an embodiment of this application; Figure 2 This is a structural block diagram of an optical detection system for vitamin tablet content provided in an embodiment of this application. Detailed Implementation
[0023] Example 1: Refer to Figure 1 This is a flowchart illustrating an optical detection method for vitamin tablet content provided in an embodiment of the present invention. The process may include at least steps S100-S600: S100: The multi-axis robotic arm controls the fiber optic probe array to perform spatial positioning scanning on the surface of vitamin tablets. The tablets are irradiated with incident angles of 0°, 45°, and 90°. The reflected light signals are captured in real time by an indium gallium arsenide photodetector to generate raw spectral data containing five-dimensional parameters including spatial coordinates, incident angle, wavelength, and light intensity. S200: The characteristic absorption peaks of vitamins are located by derivative spectral analysis, and the signal-to-noise ratio and wavelength synergy are evaluated to generate weighted spectral data with different wavelength contributions. S300 uses a subspace projection algorithm to decompose the spectral data into two orthogonal spaces. Based on the separated spectral dataset and noise-labeled spectra, a support vector machine dynamic correction model is established to output the calibration spectrum. S400: Perform projection operation on the spectral feature vector and the built-in pre-trained spectral-concentration mapping relationship matrix in the online PLS regression model, construct a dynamic sample queue using a sliding window mechanism, perform concentration label calibration, and output the updated principal component factor loading coefficients and concentration regression coefficient matrix. S500 retrieves the standard sample library through a four-level index, calculates the absolute deviation, relative deviation, statistical error and attribution deviation, and after decomposing the error coefficients, it is synchronized to the dynamic calibration module and the incremental quantitative analysis module through a dual-channel transmission mechanism. S600 analyzes the mathematical characteristics of the error coefficients, adjusts the weight ratio of historical model parameters based on the time decay function, generates the fused integrated model parameter set, optimizes the PLS regression model, and outputs the vitamin content detection results.
[0024] Step S100 includes at least steps S110-S130: S110. Acquire the surface reflection signal of the vitamin tablets, perform multi-angle NIR light source scanning, and obtain the raw spectral data.
[0025] The near-infrared dynamic scanning module uses a multi-axis robotic arm to precisely control a fiber optic probe array to perform spatial positioning scanning on the surface of vitamin tablets. This step employs three sets of near-infrared light sources covering the wavelength range of 800 nm to 2500 nm, simultaneously illuminating the surface of the vitamin tablets at incident angles of 0°, 45°, and 90°. Each incident angle is equipped with an independent indium gallium arsenide photodetector array to capture the reflected light signal in real time. During the scanning process, a rotating platform drives the vitamin tablet to complete a 360-degree circumferential rotation in 2-degree increments, while a vertical lifting mechanism moves along the Z-axis in 0.1 mm increments, thus forming a high-density three-dimensional spatial sampling grid. The light signal collected at each spatial coordinate point is converted into digital spectral data by a 16-bit analog-to-digital converter, ultimately generating a raw spectral dataset containing five-dimensional parameters: spatial coordinates, incident angle, wavelength, and light intensity. The data structure of this dataset is defined as follows: the spatial dimension includes M sampling points along the X-axis, N sampling points along the Y-axis, and P sampling points along the Z-axis; the angle dimension includes three fixed incident angles of 0°, 45°, and 90°; and the wavelength dimension covers a continuous spectrum from 800 nm to 2500 nm. The total number of spatial sampling points is M multiplied by N multiplied by P. The generated raw spectral data is transmitted to the preprocessing unit for buffer storage via a high-speed data bus, completing the output of this step.
[0026] S120. Perform noise filtering and baseline correction on the raw spectral data to generate calibrated spectral data.
[0027] After receiving the raw spectral data output from S110, the preprocessing unit first performs dual-stage processing in the time and frequency domains. In the time domain, a Savitzky-Gore filter is used to perform a moving average of 20 consecutive spatial samples at each wavelength point, with a window width of 7 data points and a polynomial order of 3, effectively eliminating random noise caused by mechanical vibration. In the frequency domain, wavelet transform is used to perform a 5-level decomposition using the sym5 mother wavelet, and the thresholds for the high-frequency coefficients of the 4th and 5th levels are set to 1.8 times the standard deviation of the original signal, significantly suppressing high-frequency electronic noise. After noise filtering, the baseline correction unit uses an adaptive iterative weighted penalized least squares method to correct baseline drift. This algorithm initializes the weight matrix as an all-one matrix and performs iterative calculations on the spectrum of each spatial point until the convergence condition is met. Each iteration includes three core operations: constructing a diagonal weight matrix, solving a system of linear equations with a smoothing parameter, and updating the weight coefficients based on a logistic function. The default value of the smoothing parameter is 1×10^5, the median of the residual is dynamically adjusted, and the weight update coefficient is fixed at 10. The final generated baseline correction spectrum is obtained by subtracting the baseline spectrum from the original spectral data and stored as a calibration spectral dataset containing spatial coordinates, incident angle, wavelength, and correction intensity.
[0028] S130. Perform three-dimensional spatial reconstruction on the calibration spectral data to generate three-dimensional spectral data and perform data preprocessing.
[0029] After receiving the calibration spectral data output from the S120, the spatial reconstruction engine first establishes a three-dimensional voxel mesh model. This model uses a voxel side length of 50 micrometers, dividing the vitamin tablet spatial domain into V_x X-axis units, V_y Y-axis units, and V_z Z-axis units. Based on the spectral data from eight adjacent spatial sampling points, a cubic spline interpolation algorithm is used to calculate the spectral value at the center point of each voxel. This interpolation process uses cubic B-spline basis functions to map spatial coordinates to spectral intensity. After spatial reconstruction, three data preprocessing operations are performed: The first is spectral normalization, which applies a standard normal transformation to the spectrum of each voxel, with the mean and standard deviation of light intensity at each wavelength dynamically calculated based on all voxel data. The second is angle fusion, which weights the spectra at 0°, 45°, and 90° incident angles with fixed weighting coefficients of 1.0, 1.2, and 0.8, respectively. The third is effective band extraction, which extracts spectral data from three characteristic absorption bands of vitamins: 1100-1300 nm, 1600-1800 nm, and 2100-2300 nm. The resulting three-dimensional spectral data cube contains voxel spatial coordinates and characteristic band spectral information, with the characteristic band set Ω in its data structure encompassing the three aforementioned characteristic bands. The output data from this step is transmitted via Gigabit Ethernet to the subsequent characteristic wavelength optimization module.
[0030] Step S200 includes at least steps S210-S230: S210. Extract the characteristic absorption peaks of vitamins from the three-dimensional spectral data and locate the key wavelengths.
[0031] After receiving the three-dimensional spectral data cube generated by the S130 module, the spectral analysis engine performs a full-band scan and analysis of the data. In the three-dimensional data structure containing voxel spatial coordinates and characteristic band spectra, the system first identifies the characteristic absorption regions corresponding to specific chemical bond vibrations in vitamin molecules. Understandably, vitamin A molecules exhibit characteristic absorption peaks in a 5-nanometer bandwidth region around 1210 nm and an 8-nanometer bandwidth region around 1320 nm; vitamin C molecules exhibit typical bimodal absorption characteristics in a 6-nanometer bandwidth region around 1140 nm and a 10-nanometer bandwidth region around 1390 nm. To accurately capture these characteristic absorption peaks, the system employs derivative spectral analysis for enhanced identification: first, the first derivative spectrum of the three-dimensional spectral data is calculated, and the starting boundary of the absorption peak is determined by detecting the zero-crossing position of the spectral curve; then, the minimum point is located in the generated second derivative spectrum, which precisely corresponds to the vertex position of the original absorption peak. For each potential characteristic absorption peak, the system performs a fine-grained localization operation: within a 15-nanometer bandwidth window around the center wavelength, the rate of change of spectral curvature is continuously calculated; when the rate of change of curvature exceeds a preset threshold of 0.15, the peak detection program is activated; a cubic spline interpolation algorithm is used to fit the spectral curve, resolving the peak wavelength position to one decimal place with precision. The final output contains a set of key wavelengths containing 3 to 5 major vitamin characteristic absorption peaks, with the localization error of each wavelength strictly controlled within ±0.8 nanometers. This set of key wavelengths fully retains the original three-dimensional spatial coordinate information and is used as the wavelength optimization reference data transmitted to the S220 module.
[0032] S220. Perform signal-to-noise ratio analysis and collaborative weight calculation on key wavelengths to generate weighted spectra.
[0033] Based on the key wavelength set and its three-dimensional spatial coordinate information input by S210, the system performs a two-dimensional quantitative evaluation. First, signal-to-noise ratio (SNR) analysis is performed: in the three-dimensional spatial domain, spectral intensity data is extracted within a 5×5 pixel region centered on each key wavelength point; the ratio of the arithmetic mean to the standard deviation of the signal intensity within this region is calculated as the SNR quantification index; when the SNR value of a specific wavelength point is lower than 35, the system automatically activates a noise reduction flag. Second, wavelength synergy evaluation is performed: the spectral cross-correlation coefficient between the vitamin characteristic absorption peak and the absorption peak of adjacent excipients is calculated; when the absolute value of the correlation coefficient exceeds 0.7, significant spectral interference is determined. The weight calculation engine then performs a triple-weighted calculation: the basic weight is linearly allocated according to the SNR index, increasing by 0.15 for every 10 units increase in SNR; the synergy weight is generated using an algorithm that subtracts the square of the correlation coefficient from 1, effectively eliminating the influence of spectral collinearity; the spatial weight is calculated based on the recurrence frequency of the wavelength at different spatial locations on the three-dimensional surface. The three weights are combined into a comprehensive weight matrix in a ratio of 0.4:0.3:0.3, and all weight values are normalized to a closed interval of 0 to 1 through a linear transformation. Finally, this weight matrix is multiplied point-to-point with the three-dimensional spectral data generated by S130 to generate a weighted spectral data cube with different wavelength contributions, whose spatial and spectral dimensions are completely consistent with the original data.
[0034] S230. Based on weighted spectral fusion of multi-wavelength data, generate the optimal characteristic wavelength result.
[0035] After receiving the weighted spectral data cube output from the S220, the system performs multi-dimensional data fusion. Feature integration is performed in the wavelength dimension: key wavelengths with a comprehensive weight value greater than 0.6 are selected, and the integrated intensity of the weighted spectral data is calculated within a bandwidth of ±3 nanometers at their center wavelength; this integrated intensity value constitutes the principal feature vector characterizing vitamin concentration. Signal enhancement is performed in the spatial dimension: a 5×5×3 three-dimensional convolution kernel is used to perform sliding calculations on the weighted spectral data cube; spatially consistent feature responses are extracted through convolution operations to form spatial feature vectors. After combining these two types of feature vectors, the system applies principal component analysis for data dimensionality reduction: the covariance matrix of the combined feature vectors and its eigenvalue distribution are calculated; principal components with a cumulative variance contribution rate exceeding 85% are retained; and feature wavelengths with a principal component loading coefficient greater than 0.7 are selected as preferred wavelengths. The final output is a structured feature wavelength optimization result, containing the precise center wavelength values of 2 to 3 core wavelengths and 4 to 6 auxiliary wavelengths, along with spatial distribution template data corresponding to each wavelength. The results are transmitted to the S310 module in a standard data format, and the data fields fully include wavelength number, center wavelength value, comprehensive weighting coefficient, and spatial coordinate range parameters.
[0036] Step S300 includes at least steps S310-S330: S310: Receive the characteristic wavelength optimization results and perform auxiliary material spectral noise separation.
[0037] The system receives the characteristic wavelength optimization results generated by the characteristic wavelength optimization module S230. These results include a set of characteristic absorption peaks of vitamins formed by multi-wavelength data fusion and their corresponding weighting coefficients. The input data directly inherits the wavelength number, center wavelength value, comprehensive weighting coefficient, and spatial coordinate range parameters output by the S230 module. The system performs spectral data deconstruction on the characteristic wavelength optimization results. Specifically, it constructs a three-dimensional spectral matrix slice based on the vibrational frequency characteristics of the functional groups of CH, OH, and NH bonds in the vitamin molecule. Each slice is 0.5 nm thick and contains complete spatial coordinate information. In the wavelength dimension, a spectral window to be processed is formed by extending 20 nm to both sides from the center point of the characteristic absorption peak. The system accurately identifies the interference bands of the excipient matrix using a second-order differential spectral processing method: the absolute value of the second derivative of the spectral curve is calculated, and segments exceeding three standard deviations of the background noise baseline are marked as interference regions. A subspace projection algorithm was used to decompose the spectral data into two orthogonal spaces: the principal component space retained the first eight orthogonal basis vectors corresponding to the characteristic absorption peaks of vitamins, while the residual space separated the broadband scattering noise generated by excipients. Excipient interference mainly manifested as baseline rise in the 1200-1250 nm range, while adhesive interference exhibited a characteristic envelope in the 1400-1450 nm range. During noise separation, 523 pre-stored interference modes in the excipient spectral fingerprint database were dynamically matched. Bandpass filtering with a bandwidth of 15 nm was applied to eliminate characteristic interference from starch excipients near 1300 nm. A characteristic wavelength masking technique was used to mask the sharp interference peak of magnesium stearate metal ions at 1700 nm, with the masking window width set to twice the half-peak width of the interference peak. The final output included a separated spectral dataset containing the absorption characteristics of pure vitamins and a noise-labeled spectrum. Each interference segment in the spectrum was labeled with an interference type code and a confidence score.
[0038] S320. The SVM algorithm is used to correct matrix interference in the separated spectra and generate a calibration spectrum.
[0039] Based on the separated spectral dataset and noise-labeled spectra output by S310, a support vector machine dynamic correction model was established. The separated spectral dataset was converted into a 24-dimensional feature space: the intensity values of the CH bond stretching vibration peak at 1210 nm, the OH bond bending vibration peak at 1450 nm, and the NH bond deformation vibration peak at 1930 nm were used as the principal feature vectors; twelve morphological parameters, including absorption peak half-width ratio, peak-valley offset, spectral symmetry, left-wing gradient, right-wing gradient, and curvature integral, were extracted as auxiliary features, among which the peak-valley offset was obtained by calculating the wavelength difference between the absorption peak apex and the adjacent valley. The kernel function selection mechanism automatically switches according to the vitamin dosage form: for crystalline vitamins, a radial basis function kernel function was used to establish a nonlinear decision surface, and the kernel width parameter σ was set to 0.5 times the median of the Euclidean distance of the feature vectors; for liquid microcapsule vitamins, a Sigmoid kernel function was used, and the scaling factor was fixed at 0.02. During model training, the dynamic penalty factor C was initially set to 5.2. Model complexity was optimized using 10-fold cross-validation. When the characteristic interference code of calcium carbonate at 2300 nm was detected in the noise-labeled spectrum, the penalty factor was automatically increased to 7.8 to enhance correction rigidity. During correction, the residual excipient scattering interference was mapped to a low-probability interval with a confidence level below 5% by finding the optimal hyperplane. Simultaneously, spectral enhancement was performed on the main vitamin absorption peak: weighted Gaussian fitting was performed in the 1210 nm characteristic peak region, with the weight coefficients dynamically determined by the comprehensive weight values provided by the S230 module. Three iterations of fitting improved the peak intensity signal-to-noise ratio to over 15 dB. In the final output calibration spectrum, the separation index between the vitamin characteristic peak and the excipient interference region exceeded 9.5, and the correlation coefficient between its spectral characteristics and the standard vitamin substance reached the threshold requirement of 0.97.
[0040] S330. Dynamically update the SVM weight parameters based on the error coefficients fed back by the online result verification module.
[0041] The system receives error coefficients in real time from the online result verification module S530. These coefficients include the absolute deviation, relative deviation percentage, and 95% confidence interval data between the measured values and standard values of vitamins A, C, and E. The update mechanism first analyzes the bias direction flag in the error coefficients: when the vitamin A detection result shows a positive deviation, the classification weight of the 1210 nm wavelength feature in the SVM model is reduced by 15% of its current value; when the vitamin C detection shows a negative deviation, the decision weight of the OH bond bending vibration feature at 1450 nm wavelength is increased by 20% of its current value. The model update uses incremental gradient descent to adjust the kernel function parameters: the initial learning rate η is set to 0.03, and the learning rate step size is dynamically adjusted based on the trend of the error coefficients over the past thirty detections. When the error coefficient fluctuation exceeds the threshold of 0.5 for three consecutive times, the adaptive learning rate algorithm is activated, and the step size reduction factor is set to 0.7. The weight parameter update process employs a dual verification mechanism: firstly, it cross-validates with the characteristic wavelength selection module S200 by sharing a wavelength weight parameter database, and only parameters with a matching error within the range of 0.1% are adopted; secondly, it compares the correction effect through the partial least squares model feedback loop S420, triggering parameter rollback when the change in the coefficient of determination exceeds 5%. Each update generates a timestamped versioned set of weight parameters, with the version number consisting of a 14-digit number (year, month, day, hour, minute, second). It also retains the five most recent historical versions to support model rollback operations, triggered when two consecutive verification errors exceed the allowable threshold. The updated weight parameters are synchronized to the SVM dynamic correction model via a real-time data bus, forming a closed-loop optimization system.
[0042] Step S400 includes at least steps S410-S430: S410. Input the calibration spectrum into the online PLS regression model to calculate the vitamin content in real time.
[0043] The system receives calibration spectral data output from the S320 module. This data has undergone matrix interference correction and retains vitamin characteristic wavelength information. The online PLS regression model incorporates a pre-trained spectral-concentration mapping matrix, constructed based on spectral feature vectors from historical standard sample sets and laboratory-measured concentration values. During real-time calculation, the calibration spectrum is first vectorized and recombined to generate spectral feature vectors containing the characteristic wavelength optimization results from the S230 module. Further, a projection operation is performed between the spectral feature vectors and the mapping matrix: by iteratively calculating the extreme covariance of the projection vector and the concentration vector in the latent variable space, the principal component factors of the spectral feature vectors are decomposed layer by layer; subsequently, based on the linear combination of the principal component factor loading coefficients and the concentration residuals, the predicted vitamin content is output in real time. This calculation process is executed in the embedded system using a parallel stream processing architecture, with a single scan cycle controlled within 300 milliseconds, synchronously generating a real-time calculation result data stream with timestamps and sample IDs. The input for this step is the S320 calibration spectral data, and the output is the initial predicted vitamin content and the corresponding spectral feature vector set.
[0044] S420. Adjust the PLS model coefficients according to the error coefficients and perform incremental learning.
[0045] The system receives the error generated by the S520 module and converts it into the residual gradient vector of the PLS model output layer. Model coefficients are adjusted based on backpropagation: the partial derivatives of the output layer weight matrix are calculated based on the residual gradient vector, and the chain rule is used to backtrack layer by layer to the input layer feature weight matrix. An adaptive learning rate algorithm is used to dynamically control the coefficient adjustment magnitude: when the confidence interval parameter exceeds a preset threshold, reinforcement learning mode is activated, amplifying the weight update amount by the square of the error coefficient; otherwise, a linear decay strategy is adopted. The spectral feature vector and error coefficients of the current sample are simultaneously retained to construct an incremental training sample set. During incremental learning, the newly added sample set and the original model parameters are input into the regularized least squares solver: the objective function is reconstructed by adding L2 norm constraint terms, and the updated principal component loading coefficient matrix and concentration mapping vector are iteratively solved. The input for this step is the S410 predicted value and S real-time modeling, updating the quantitative analysis model parameters.
[0046] The system continuously receives the new sample spectral data stream from the S120 preprocessing module and performs real-time modeling in conjunction with the incremental training sample set generated by S420. First, it performs feature wavelength matching on the new spectra: convolving and aligning the spectral data with the feature wavelength optimization results from the S230 module to extract band data matching the vitamin absorption peaks. A sliding window mechanism is used to construct a dynamic sample queue: when the number of new samples reaches a threshold of 50 sets, a spectral feature recombination operation is triggered—merging the new sample band data with the historical incremental sample set to construct an extended spectral feature matrix; concentration label calibration is performed—based on the error coefficients retained by S420, the predicted values of the new samples are reverse-corrected to generate calibrated concentration labels; model iterative training is initiated—the extended feature matrix and calibrated concentration labels are input into an improved NIPALS algorithm: updating the latent variable spatial projection vector through a partial least squares path, accelerating eigenvalue decomposition using the Krylov subspace iterative method, and outputting the updated principal component factor loading coefficients and concentration regression coefficient matrix. Simultaneously, the model structure parameters are optimized: the number of retained principal components is adjusted according to the spectral variance distribution of the new samples, and the latent variable dimensions are expanded when the spectral variance entropy value increases by more than 15%. Finally, the updated regression coefficient matrix and structural parameters are written to the embedded system's non-volatile memory, overwriting the original quantitative analysis model parameters. The inputs to this step are the newly added sample spectral data and the historical incremental training set; the output is the updated core parameter set of the quantitative analysis model.
[0047] Step 500 includes at least steps S510-S530: S510. Obtain the vitamin content calculation results and compare the concentration with the standard sample library.
[0048] The online result verification module acquires the vitamin content calculation results output in real time by the incremental quantitative analysis module (S410) via a high-speed data bus. These results include the predicted concentration values of the target vitamin components and their corresponding sample identification codes. The system activates the standard sample library retrieval protocol. This standard sample library is a distributed database architecture with a four-level index hierarchy based on vitamin type (vitamin A, C, E), tablet formulation matrix (gelatin-based, cellulose-based), production process batch (batch number accurate to year, month, and day), and storage temperature and humidity conditions (5℃-25℃, RH 30%-60%). During retrieval, the system first extracts the original spectral features of the current sample obtained by the near-infrared dynamic scanning module (S100). Based on the spectral bands defined by the feature wavelength optimization results generated by the feature wavelength optimization module (S200), multi-level matching is performed in the standard sample library: the first-level matching filters 520 standard spectral records under the target vitamin type in the vitamin type index layer; the second-level matching uses the Mahalanobis distance algorithm to calculate the similarity between the measured spectrum and the candidate standard spectrum in the feature wavelength region, with the distance threshold set to 0.85, and filters 200 records that meet the similarity standard; the third-level matching uses the spectral angle mapping algorithm to calculate the spatial angle of the spectral curve in the formula matrix index layer, and selects the first 50 records with an angle less than 5 degrees to enter the final candidate set. After successful matching, the system extracts the vitamin content standard values of each standard sample in the candidate set calibrated by high-performance liquid chromatography, and simultaneously obtains its measurement uncertainty information (extended uncertainty range 0.5%-1.2%). Finally, the predicted concentration values output by S410 are compared with the calibration values of the matching standard samples one by one to generate a structured pairing data set. Each record contains the measured predicted value, standard value, standard sample number and spectral matching confidence parameters. This set is transferred to the S520 module through a memory-mapped file.
[0049] S520. Calculate the deviation between the measured value and the standard value, and generate the error coefficient.
[0050] Based on the paired dataset output by S510, the system performs a four-dimensional deviation quantification analysis. The first dimension calculates absolute deviation: for each paired record, an algebraic operation is performed to subtract the standard value from the predicted value to generate an individual absolute deviation value; when the paired set contains multiple records, the mean absolute deviation of the sample set is calculated simultaneously. The second dimension calculates relative deviation: the individual absolute deviation value is divided by the corresponding standard value to convert it into a percentage relative deviation; the standard deviation of the relative deviation within the paired set is also calculated. The third dimension performs statistical error analysis: thirty subsets (each containing twenty records) are randomly selected from the paired set using a bootstrap sampling method, and the root mean square error of each subset is calculated, with the 95th percentile used as the statistical error index. The fourth dimension performs deviation attribution analysis: the ratio of positive deviation records to negative deviation records is statistically analyzed; when the absolute value of the ratio difference exceeds 15%, the direction of the system deviation is marked. After receiving the aforementioned deviation data, the error coefficient synthesis engine performs a triple-weighted fusion: The first weighting factor is spectral matching confidence, with the weight increasing by 20% for every 0.1% increase in confidence; the second weighting factor is standard value uncertainty, with the weight increasing by 15% for every 0.1% decrease in uncertainty; and the third weighting factor is historical validation stability, using the reciprocal of the deviation fluctuation coefficient from the most recent ten validations for that sample type. The weighted calculation generates a structured error coefficient, which includes: 1) a comprehensive absolute deviation scalar value (mg / tablet); 2) a relative deviation percentage range (format ±X%); 3) a statistical error confidence interval (95% confidence level); 4) a deviation direction indicator (P indicates positive deviation dominance / N indicates negative deviation dominance); and 5) a dynamic correction factor (calculated based on historical deviation trends, with a value of 0.5-1.5). This coefficient is encapsulated in a binary encoding format, with the data structure header containing a validation timestamp and sample type code.
[0051] S530 feeds back the error coefficients to the SVM dynamic calibration module and the incremental quantitative analysis module.
[0052] The feedback controller decomposes the error coefficients generated by S520 into two independent data streams, which are synchronously applied to downstream modules through a dual-channel transmission mechanism. In the feedback channel of the SVM dynamic calibration module (S310-S330): the comprehensive absolute deviation value of the error coefficients is parsed and converted into the regularization strength adjustment of the SVM loss function, with the adjustment magnitude calculated as a coefficient increase of 0.15 per milligram of deviation; the deviation direction indicator is extracted; when marked "P", the weight of the support vector corresponding to the vitamin feature peak in the SVM model is reduced by 8%; when marked "N", the corresponding weight is increased by 12%; the dynamic correction factor is directly applied to the SVM learning rate parameter, scaling the gradient descent step size proportionally to the factor value. In the feedback channel to the incremental quantitative analysis modules (S410-S430): the statistical error confidence interval of the error coefficients is converted into the PLS model coefficient update threshold. When the confidence interval width exceeds three milligrams, the enhanced update mode is activated. The relative deviation percentage range is used to calculate the weighted matrix of the PLS prediction residuals, with the interval midpoint as the residual benchmark value and the interval radius as the allowable fluctuation range of the residuals. The dynamic correction factor controls the forgetting factor parameter of the recursive least squares algorithm; for every 0.1 increase in the factor value, the forgetting factor increases by 0.05. The feedback execution process implements dual verification: a cyclic redundancy check code is used at the transmission layer to ensure data integrity; a feedback acknowledgment mechanism is set at the application layer. When the weight update of S330 is completed or the model coefficients of S420 are adjusted, an acknowledgment signal containing the fingerprint of the new parameters is sent to the verification module. The system continuously monitors the feedback delay time, and automatically switches to asynchronous transmission mode when it exceeds the three-hundred-millisecond threshold to ensure the real-time performance of closed-loop control.
[0053] In another embodiment, the feedback controller structures the error coefficients. After disassembly, a dynamic correction core algorithm is executed for the PLS incremental analysis channels (S410-S430). When the update threshold activation condition is met ( When this occurs, the system initiates a three-level linkage optimization process: Based on the generated statistical error 95% confidence interval Construct a normal distribution probability density model: in: The lower limit of the 95% confidence interval for the statistical error distribution; The upper limit of the 95% confidence interval for the statistical error distribution; : Input the mean absolute deviation from S520; Confidence interval width converted to standard deviation; :by For the mean, is the normal distribution probability density function of the standard deviation; Output residual flux value, which represents the cumulative probability distribution of error within the confidence interval; Implementation process: from Matrix extraction and , This is a structured error coefficient matrix with dimensions [missing information]. ; Calculate using a numerical integration library (such as SciPy's quad function). to The integral; Output To the manifold curvature correction module; Furthermore, based on the PLS model coefficient matrix ( Principal components, The residual weighting matrix constructed using wavelengths and S520. Constructing Riemannian geometric space: in: : The coefficient matrix input from the PLS incremental analysis module; This is the transpose of the coefficient matrix of the PLS model; : Diagonal weight matrix; : Output The metric tensor represents the metric structure of the model's parameter space. Let be the inverse matrix elements of the metric tensor, where For tensor index ( ); , Let these be local coordinate variables on the Riemannian manifold. For dimension indexing; Christoffel notation ( For tensor index, ); Outputs a Riemann curvature tensor (fourth-order tensor) to describe the local bending characteristics of the model manifold; Implementation process: Computation of metric tensor ; Calculate the partial derivatives of the Christoffel notation using automatic differentiation techniques; Combining to generate a fourth-order curvature tensor ; Output To Hamiltonian optimization framework; Furthermore, a Hamiltonian mechanics framework is constructed to achieve weight iteration: in, For Hamiltonian; It is the transpose of the generalized momentum vector; Generalized coordinates; Generalized momentum; : Quality matrix; Potential energy term; Potential gradient; This is the output of the Hamiltonian equation, used to update the weight parameters.
[0054] Physical meaning: Generalized coordinate vector The components characterize the weight allocation of the output of the characteristic wavelength optimization module: :No. The weighting coefficients of each characteristic wavelength ( ); :No. Weighting coefficients for each characteristic wavelength; :No. Weighting coefficients for each characteristic wavelength; :No. Weighting coefficients for each characteristic wavelength.
[0055] The technical solution in this step breaks through the limitations of traditional static correction. It achieves adaptive evolution of the vitamin optical detection model through: ① gradient field generation driven by residual flux → ② construction of potential energy surface constrained by curvature tensor → ③ symplectic geometric algorithm to ensure optimization stability (Hamilton equation preserves structural characteristics). This enables the system to maintain a detection accuracy of ±1.5mg under scenarios such as formula changes and environmental fluctuations.
[0056] Step S600 includes at least steps S610-S630: S610: Receive the error coefficients and updated quantitative analysis model parameters, and perform model fusion.
[0057] The self-optimization output module first receives the error coefficients transmitted from the online result verification module S510, and simultaneously obtains the updated quantitative analysis model parameters from the incremental quantitative analysis module S430. The error coefficients are the deviation quantification index calculated in step S520 by comparing the measured vitamin content values with the concentration values of the standard sample library, containing information on the direction and magnitude of systematic errors. The updated quantitative analysis model parameters are the iterative model parameter set generated in step S420 by adjusting the partial least squares regression coefficients based on the error coefficients, and then by real-time modeling of the spectra of newly added samples in step S430. The model fusion operation employs a weighted integration strategy, which transforms the error coefficients into model confidence weight factors, thereby dynamically weighting the incremental quantitative analysis model parameters. Specifically, the mathematical characteristics of the error coefficients are first analyzed, and the standard deviation and mean of the error distribution are extracted as the basis for weight calculation; for example, the standard deviation is used to quantify the error fluctuation amplitude, and the mean is used to indicate the deviation direction; both together constitute the basis for weight calculation. Further adjustments to the weighting of historical model parameters based on a time decay function are made to give higher weighting coefficients to recently iterated model parameters. The decay function is designed as an exponential decay function, with a time constant set to five times the detection period to ensure enhanced influence of recent parameters. The implementation process includes establishing a multi-version model parameter storage queue, where each version parameter is marked with a timestamp accurate to the millisecond level; calculating the decay factor for each parameter in the queue based on the fluctuation amplitude index in the error coefficient, decreasing the decay factor by 0.05 for every 10% increase in fluctuation amplitude; and finally, fusing the current version parameters with historical version parameters using a weighted average algorithm. The weighting coefficient is determined by the product of the confidence weighting factor and the decay factor, generating a fused integrated model parameter set. This integrated model parameter set inherits both the real-time characteristics of the incremental quantitative analysis model and the stability characteristics of the historical model, outputting a data structure containing all optimized parameters, directly serving the subsequent S620 algorithm optimization process. The data structure includes core elements such as partial least squares regression coefficients, intercept terms, and covariance matrices.
[0058] S620: Dynamically optimizes the vitamin content calculation algorithm to generate the final content value and confidence level.
[0059] Based on the integrated model parameter set output by S610, this step reconstructs the core computational logic of the vitamin content calculation algorithm. Specifically, a parameter injection optimization operation is performed, injecting the partial least squares regression coefficients, intercept terms, and covariance matrix from the integrated model parameter set into the online PLS computation framework, replacing the original static parameters. For multidimensional spectral data features, a channel-specific parameter loading mechanism is adopted. This mechanism normalizes and scales the regression coefficients of corresponding wavelength channels according to the different wavelength weight allocation values output by the feature wavelength optimization module S230. Wavelength channels with weight values higher than 0.6 have their regression coefficients amplified by 20%, while wavelength channels with weight values lower than 0.3 have their coefficients reduced by 15%, ensuring that high-weight wavelength features have a greater influence in the calculation. The dynamic compensation calculation is further performed, introducing the error coefficient from S510 as a real-time calibration factor. This process constructs an error transfer function, decomposing the error coefficient into baseline offset and sensitivity deviation. The baseline offset directly affects the overall compensation term of the content calculation result; for every milligram increase in the offset, the compensation value is adjusted by 0.8 milligrams. The sensitivity deviation dynamically adjusts the response slope of different concentration ranges. Specifically, a piecewise compensation function is established based on the directional index in the error coefficient. When the directional index is positive, positive nonlinear correction is performed before the vitamin content calculation value is output, increasing the slope by 5% to 15%. When it is negative, negative correction is performed, decreasing the slope by 5% to 15%. Simultaneously, a confidence quantification generation operation is performed to calculate the credibility of the final content value. This operation is based on the parameter stability index of the S610 fusion model, namely the standard deviation of the parameters in each version. For every 0.1 decrease in the standard deviation, the confidence level increases by 2%. It also combines the calibration spectral data quality index output by the spectral preprocessing module S120, including the signal-to-noise ratio (SNR) parameter. When the SNR is higher than 50 decibels, the baseline confidence level increases by 10%. The confidence probability value is calculated through a multivariate coupling equation, which linearly combines the standard deviation and the SNR with weighting coefficients of 0.6 and 0.4, respectively. Furthermore, a dynamic shrinkage mechanism for the confidence interval is established based on the historical trend of the error coefficient. When the fluctuation range of the error coefficient for three consecutive detection cycles is less than the 0.5 mg threshold, the radius of the confidence interval is automatically reduced by 20% to improve detection accuracy. The final generated confidence level includes a probability percentage value such as 95.2 and an interval range such as ±0.3 mg, which together constitute the quantified credibility index. The final content value is obtained by performing real-time calculation on the calibration spectrum generated by the matrix interference correction module S320 using the optimized PLS regression model, which already includes dynamic compensation correction; at the same time, the output confidence data package serves the subsequent output of the S630 results.
[0060] S630, Output the vitamin content detection results with bound confidence levels.
[0061] The final vitamin content value generated by S620 and the corresponding confidence level data are structurally encapsulated to form a standardized test result output. In specific implementation, a data binding operation is performed to establish a content value-confidence level correlation matrix, using a metadata nesting architecture to ensure their inseparability. The vitamin content value is used as the main data field, and parameters such as confidence level probability, confidence interval range, and calculation timestamp are written as extended attribute fields into the same data packet. A key wavelength verification code from the feature wavelength optimization module S230 is added, containing the wavelength number and center wavelength value, ensuring the result is traceable to the original spectral characteristics. Next, the output protocol operation is executed, transmitting the test results through a standardized communication interface. A binary stream containing a data header identifier is generated, with the header embedding a result type marker, such as "Vitamin C content test result V.1.0". The main data area uses a JSON-LD structured format to organize the content value and confidence level data. This format defines the main field as the content value, and the subfields include the confidence probability percentage and interval range. A digital fingerprint generated based on the spectral data calibrated by the spectral preprocessing module S120 is appended to the end of the data. The fingerprint algorithm uses the SHA-256 hash function for subsequent result verification. Simultaneously, a closed-loop verification operation is performed, automatically writing key parameters of the current output result, including content value and confidence interval boundary values, into the standard sample library comparison queue of the online result verification module S510, serving as a dynamic reference benchmark for subsequent testing. When the confidence probability value reaches a preset threshold of 98%, the result is upgraded to a temporary standard sample, participating in the error coefficient calculation of subsequent testing cycles, forming a positive feedback loop. The final transmitted vitamin content detection result includes dynamically optimized vitamin mass fraction units (mg / tablet), confidence probability percentage (e.g., 98.5 ± 0.2), and a result validity timestamp accurate to the second.
[0062] Example 2: Figure 2 A structural block diagram of a vitamin tablet content optical detection system according to an embodiment of the present invention is shown. Figure 2 As shown, the structure may include: The near-infrared dynamic scanning unit 10 includes a multi-axis robotic arm, a fiber optic probe array, and a three-angle light source. The multi-axis robotic arm is driven by a high-precision servo motor, enabling free-trajectory movement in three-dimensional space. A preset path planning algorithm controls the spatial positioning accuracy of the probes to ±0.1 mm. The fiber optic probe array consists of 12 groups of quartz fiber bundles arranged in a ring structure. Each fiber bundle integrates a 200 μm core diameter receiving channel and a light source emission channel, achieving synchronous scanning coverage of a 10×10 mm area on the tablet surface. The three-angle light source uses a tunable LED array, with angles of 30°, 45°, and [missing information]. An independent light source module is configured at a 60° incident angle, with each module covering the spectral range of 900-1700nm. Pulse width modulation technology enables 0.1ms-level fast light source switching. Each incident angle is equipped with a 256-level adjustable intensity gradient mechanism to match the curvature change of the tablet in real time during the movement of the robotic arm, eliminate surface diffuse reflection interference, and generate a continuous diffuse reflection spectral data stream with a three-dimensional spatial resolution of 0.5mm×0.5mm×0.3mm. It collects 2000 effective spectral points per second and outputs the raw spectral matrix to the spectral processing unit through a gigabit Ethernet interface.
[0063] The spectral processing unit 20 performs derivative spectral analysis, weight matrix synthesis, and subspace projection. After receiving the near-infrared spectral data stream, the spectral processing unit performs third-order derivative spectral analysis, employing a Savitzky-Golay filter for 21-point window smoothing, and calculates the second and third derivative characteristics of the spectrum. The weight matrix synthesis module constructs a dynamic weighting matrix based on the correlation coefficients of characteristic bands. It first extracts 12 key absorption bands, including characteristic peaks of Vitamin C (1208nm, 1440nm), Vitamin D (1160nm, 1392nm), and Vitamin B6 (1284nm, 1516nm), and calculates the signal-to-noise ratio weight of each band in the derivative spectrum. The coefficients are used to establish an inter-band interaction model through covariance matrix analysis, generating a 24×24 dimensional feature weight matrix. The subspace projection module uses an improved NIPALS algorithm to project the weighted spectrum onto the vitamin principal component subspace, which consists of 50 eigenvectors. 97% of the spectral information entropy is retained through singular value decomposition. The residual norm between the original spectrum and the principal component space is calculated in real time during the projection process. When the residual exceeds a set threshold, an abnormal spectrum removal mechanism is triggered. Finally, the dimensionality is reduced to a 50-dimensional feature spectral vector set, with a data compression rate of 0.5% of the original data and a processing latency controlled within 15ms.
[0064] The dynamic correction unit 30 is configured with an SVM model featuring switchable kernel functions and a real-time parameter update interface. The dynamic correction unit is configured with an SVM model featuring switchable kernel functions, incorporating three kernel function architectures: radial basis function (RBF) kernel, polynomial kernel, and sigmoid kernel. Kernel function switching is triggered in real-time based on the spectral quality index: the quadratic polynomial kernel function is activated when the signal-to-noise ratio (SNR) is >45dB, the RBF kernel function is activated when the SNR is between 30-45dB, and the sigmoid kernel function is switched when the SNR is <30dB. The model support vector library uses a circular queue structure to store 500 sets of historical support vectors, and the model parameters are dynamically updated through an incremental learning algorithm. Real-time... The parameter update interface receives the error coefficient from the verification feedback unit, establishes a deviation-parameter mapping table, and automatically adjusts the penalty factor C value (adjustment range 0.8-1.5) when the vitamin C prediction deviation exceeds ±1.2%, and adjusts the kernel function width parameter γ value (adjustment range 0.05-0.3) when the vitamin D deviation exceeds ±0.9%. The parameter update frequency is up to 100 times / second. The correction unit also integrates a temperature compensation module, which collects ambient temperature data through a built-in thermocouple. When the temperature change exceeds ±2℃, it automatically recalibrates the spectral baseline drift.
[0065] The quantitative analysis unit 40 has a built-in online PLS model and incremental learning mechanism. The quantitative analysis unit incorporates an online partial least squares regression model, which includes independent prediction channels for seven components: vitamins A, B1, B2, B6, C, D, and E. The model architecture employs a three-layer hidden-layer neural network structure. The input layer has 50-dimensional feature vectors output by the spectral processing unit, the hidden layer has 38 nodes and uses the Leaky ReLU activation function, and the output layer contains seven vitamin concentration values. An incremental learning mechanism is implemented through a sliding window, automatically triggering a model update every 100 tablets tested. The new data window contains the spectral characteristics of the most recent 30 tablets and their corresponding reference HPLC values. The update process uses a stochastic gradient descent algorithm with a learning rate of 0.002 and a momentum factor of 0.85. The model version management module retains the model parameters from the last five versions. When the root mean square error (RMSE) of the new model exceeds 8% of the historical best model, it automatically rolls back to the previous stable version. A dynamic resource allocation mechanism automatically adjusts the number of threads based on the prediction workload, enabling GPU-accelerated parallel computing during peak loads, ensuring a prediction response time stable within 80ms.
[0066] The verification feedback unit 50 enables standard sample library retrieval, four-dimensional deviation analysis, and error coefficient synthesis. This unit stores 500 sets of standard spectral data for vitamin tablets calibrated by liquid chromatography, divided into 10 level intervals based on concentration gradients. The four-dimensional deviation analysis module calculates the concentration deviation (C_dim1), spectral residual (C_dim2), time drift (C_dim3), and temperature shift (C_dim4) of the currently tested tablet. The concentration deviation dimension calculates the mean absolute percentage error of the seven vitamins, the spectral residual dimension calculates the L2 norm in the 1300-1400nm band, and the time drift dimension calculates... The impact coefficient of the continuous running time of the tracking instrument on the baseline is calculated, and the temperature offset dimension is compensated for based on environmental sensor data. The error coefficient synthesis module adopts a weighted fusion algorithm and automatically loads weight configurations according to the tablet type: effervescent tablets are assigned a concentration weight of 0.6 and a spectral weight of 0.3, and chewable tablets are assigned a concentration weight of 0.4 and a temperature weight of 0.4. The synthesized comprehensive error coefficient (Error_Index) is then used. When the comprehensive error coefficient EI value exceeds the threshold of 0.35, the calibration process is automatically triggered, and the 15 closest samples from the standard library are matched for model recalibration.
[0067] The result optimization unit 60 performs confidence weight calculation and regression coefficient optimization. The result optimization unit performs credibility weight calculation. This module takes into account the predicted values from the quantitative analysis unit, the support vector confidence of the dynamic correction unit, and the comprehensive error coefficient from the verification feedback unit to construct a credibility evaluation function. After independently calculating the credibility weights for the seven vitamin components, the regression coefficient optimization module is activated for components with weight values below 0.8. This module uses a constrained least squares optimization algorithm to perform iterative search in the regression coefficient vector space of the PLS model and solves the objective function using the conjugate gradient method. The regularization parameter λ is adaptively adjusted according to the credibility weight (λ=0.3 when the weight is 0.6-0.8, and λ=0.7 when the weight is <0.6). The optimization process is limited to 5 iterations, with a gradient descent step size of 0.05 in each iteration. Finally, the system outputs the credibility-weighted predicted vitamin concentration values and the optimized regression coefficient vector. At the same time, a test result report is generated, which includes the predicted concentration values of the seven vitamins, relative standard deviation (RSD<2.1%), 95% confidence interval, and comprehensive credibility index. The data is transmitted to the MES system via industrial Ethernet.
[0068] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. An optical detection method for vitamin tablet content, characterized in that, include: A multi-axis robotic arm controls a fiber optic probe array to perform spatial positioning scanning on the surface of vitamin tablets. Irradiation is carried out at incident angles of 0°, 45°, and 90°. The reflected light signal is captured in real time by an indium gallium arsenide photodetector to generate raw spectral data containing five-dimensional parameters including spatial coordinates, incident angle, wavelength, and light intensity. During the scanning process, a rotating platform drives the vitamin tablets to complete a 360-degree circumferential rotation with a step angle of 2 degrees. At the same time, a vertical lifting mechanism moves along the Z-axis with a step distance of 0.1 mm to form a high-density three-dimensional spatial sampling grid. The characteristic absorption peaks of vitamins were located by derivative spectroscopy, and the signal-to-noise ratio and wavelength synergy were evaluated to generate weighted spectral data with different wavelength contributions. The spectral data is decomposed into two orthogonal spaces using a subspace projection algorithm. Based on the separated spectral dataset and noise-labeled spectra, a support vector machine dynamic correction model is established to output the calibration spectrum. The spectral feature vector is projected onto the pre-trained spectral-concentration mapping matrix built into the online PLS regression model. A dynamic sample queue is constructed using a sliding window mechanism, concentration label calibration is performed, and the updated principal component factor loading coefficients and concentration regression coefficient matrix are output. The standard sample library is retrieved through a four-level index, and the absolute deviation, relative deviation, statistical error and attribution deviation are calculated. After the error coefficients are decomposed, they are synchronized to the dynamic calibration module and the incremental quantitative analysis module through a dual-channel transmission mechanism. The expression for the disassembly error coefficient, synchronized to the dynamic calibration module and the incremental quantitative analysis module via a dual-channel transmission mechanism, includes: in, For Hamiltonian; It is the transpose of the generalized momentum vector; Generalized coordinates; Generalized momentum; This is the quality matrix; It is the potential energy term; The mathematical characteristics of the error coefficients are analyzed, the weight ratio of historical model parameters is adjusted based on the time decay function, the fused integrated model parameter set is generated, the PLS regression model is optimized, and the vitamin content detection results are output.
2. The optical detection method for vitamin tablet content according to claim 1, characterized in that, The process of retrieving the standard sample database using a four-level index and calculating absolute bias, relative bias, statistical error, and attribution bias includes: The online result verification module obtains the vitamin content calculation results output in real time by the incremental quantitative analysis module through a high-speed data bus. The calculation results include the predicted concentration values of the target vitamin components and their corresponding sample identification codes.
3. The optical detection method for vitamin tablet content according to claim 2, characterized in that, The process of retrieving the standard sample database using a four-level index and calculating absolute bias, relative bias, statistical error, and attribution bias also includes: The standard sample library adopts a distributed database architecture, with a four-level index hierarchy based on vitamin type, tablet formulation matrix, production process batch, and storage temperature and humidity conditions. During retrieval, the original spectral features of the current sample are first extracted, and the spectral bands defined by the feature wavelengths are selected and multi-level matching is performed in the standard sample library.
4. The optical detection method for vitamin tablet content according to claim 3, characterized in that, Multilevel matching includes: The first level of matching filters out standard spectral records for the target vitamin type in the vitamin type index layer; The second-level matching uses the Mahalanobis distance algorithm to calculate the similarity between the measured spectrum and the candidate standard spectrum in the characteristic wavelength region, and filters the records that meet the similarity standard. The third-level matching uses a spectral angle mapping algorithm to calculate the spatial angle of the spectral curves in the formulation matrix index layer, and records with an angle less than a set threshold are included in the final candidate set.
5. The optical detection method for vitamin tablet content according to claim 4, characterized in that, include: After successful multi-level matching in the standard sample library, the system extracts the standard values of vitamin content and their measurement uncertainty information of each standard sample in the candidate set calibrated by high performance liquid chromatography. The predicted concentration values are then compared with the calibration values of the matched standard samples one by one to generate a structured paired data set.
6. The optical detection method for vitamin tablet content according to claim 1, characterized in that, The calculation of absolute deviation, relative deviation, statistical error, and attribution bias includes: The first dimension calculates the absolute deviation: Perform an algebraic operation on each paired record by subtracting the standard value from the predicted value to generate the individual absolute deviation value and the mean absolute deviation; The second dimension calculates the relative deviation: the individual absolute deviation value is divided by the corresponding standard value to convert it into a percentage relative deviation, and the standard deviation of the relative deviation within the paired set is calculated. The third dimension performs statistical error analysis: a subset is randomly selected from the paired set using the bootstrap sampling method, the root mean square error of each subset is calculated, and a set percentile is taken as the statistical error index. The fourth dimension performs deviation attribution analysis: the ratio of positive deviation records to negative deviation records is statistically analyzed, and the direction of system deviation is marked when the absolute value of the ratio difference exceeds a set threshold.
7. The optical detection method for vitamin tablet content according to claim 6, characterized in that, include: After receiving the deviation data, the error coefficient synthesis engine performs triple-weighted fusion: The spectral matching confidence level is used as the first weighting factor, and the weighting increases by a set percentage for each increase in confidence level by a set value. The standard value uncertainty is used as the second weighting factor, and the weighting is increased by a set percentage for each decrease in the uncertainty by a set value. Historical verification stability is used as the third weighting factor, and the reciprocal of the deviation fluctuation coefficient of the most recent verification of this sample type is taken as the weight value.
8. The optical detection method for vitamin tablet content according to claim 1, characterized in that, Hamiltonian With potential energy term The content also includes: in, It is the potential energy term; To output the Riemann curvature tensor (fourth-order tensor). For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; For the first Weighting coefficients for each characteristic wavelength; in, Christoffel notation ( (For tensor indexes).
9. The optical detection method for vitamin tablet content according to claim 1, characterized in that, The process of feeding back the synthesized error coefficients to the dynamic correction and quantitative analysis module via dual channels also includes: The feedback controller decomposes the error coefficient into two independent data streams, which are then synchronously applied to the downstream module through a dual-channel transmission mechanism. In the feedback channel of the SVM dynamic calibration module, the comprehensive absolute deviation value of the error coefficient, the deviation direction indicator and the dynamic correction factor are analyzed to adjust the SVM model parameters. In the feedback channel of the incremental quantitative analysis module, the statistical error confidence interval, relative deviation percentage range, and dynamic correction factor of the error coefficient are converted into PLS model parameter adjustment amounts.
10. An optical detection system for vitamin tablet content, used to implement the method according to any one of claims 1-9, characterized in that, include: Near-infrared dynamic scanning device, including a multi-axis robotic arm, fiber optic probe array and three-angle light source; The spectral processing unit performs derivative spectral analysis, weight matrix synthesis, and subspace projection. The dynamic correction unit is configured with an SVM model that can switch kernel functions and a real-time parameter update interface. Quantitative analysis unit with built-in online PLS model and incremental learning mechanism; The verification feedback unit enables standard sample library retrieval, four-dimensional deviation analysis, and error coefficient synthesis. The results optimization unit performs confidence weight calculation and regression coefficient optimization.
Citation Information
Patent Citations
Method for quickly detecting tablet weight of medicine tablets through near infrared spectroscopy
CN104132720A
System and method for multi-parameter spectroscopy
CN108780042A
Method for quantitatively monitoring substance content by Raman spectroscopy
CN113670894A
Execution function prediction method, device and equipment based on Riemannian manifold and multi-modal connection group
CN119181512A
AI-based chemical material detection information library retrieval and standard spectrum comparison system
CN120108578A
Cited By
Multi-class material sorting method and system based on hyperspectrum, medium and product
CN121534935A
Method for detecting pure natural royal jelly freeze-dried powder
CN121558676A
Quality-rectification automatic closed-loop acceptance method and system based on actual measurement
CN121684281A
Feed mycotoxin detection method and system based on spectral analysis
CN121762490A
A method and system for detecting mycotoxins in feed based on spectral analysis
CN121762490B