Pure cotton fabric formaldehyde residue detection method
Through the combination of hyperspectral imaging system and one-dimensional convolutional neural network, the lossless, rapid and accurate problems of formaldehyde detection in pure cotton fabrics are solved, and non-destructive rapid detection is achieved, reducing equipment costs and detection time.
Patent Information
- Application Number
- CN202510740903.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the formaldehyde detection of pure cotton fabrics has problems such as destructive sampling, long detection cycle and high equipment costs, making it difficult to achieve fast and accurate formaldehyde residue detection.
The hyperspectral imaging system is used to collect fabric spectral data in a non-contact manner, and combine discrete wavelet transformation and one-dimensional convolutional neural network to realize non-destructive detection, and formaldehyde residue detection results are generated through feature matching.
It realizes lossless, fast and accurate formaldehyde residue detection, reduces equipment costs, and improves detection efficiency and accuracy.
Smart Images

Figure CN120489972A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of textile detection, and specifically to a method for detecting formaldehyde residues in pure cotton fabrics. Background Art
[0002] Formaldehyde is a common organic compound widely used in the printing, dyeing, finishing, and wrinkle-proofing of pure cotton fabrics to improve their color fastness, stiffness, and shrinkage resistance. However, formaldehyde is extremely harmful to human health. Long-term exposure to excessive formaldehyde can cause irritation and allergies to the respiratory tract, eyes, and skin, and may even cause cancer.
[0003] Currently, formaldehyde testing of pure cotton fabrics faces three major technical bottlenecks: 1. Destructive sampling leads to waste of raw materials (according to GB / T3920-2008 standard, a single test requires the destruction of ≥140cm 2 fabrics); 2. The laboratory testing cycle is as long as 48 hours or more (taking ICP-MS as an example); 3. The equipment cost is high (a single ICP-MS costs more than 2 million yuan), making it difficult for small and medium-sized enterprises to popularize it.
[0004] Therefore, how to quickly and accurately detect the formaldehyde residue in pure cotton fabrics to ensure the quality and safety of textile products is an urgent problem that needs to be solved. Summary of the Invention
[0005] Based on this, the purpose of the present invention is to provide a method for detecting formaldehyde residues in pure cotton fabrics to solve the technical problems raised in the above background technology.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A method for detecting formaldehyde residue in pure cotton fabrics comprises the following steps:
[0008] Step 1: Obtain a hyperspectral image of the cotton fabric to be tested: Use a hyperspectral imaging system to non-contactly collect spectral data of the fabric sample and generate a three-dimensional spectral cube containing spatial coordinates and wavelength dimensions;
[0009] The hyperspectral imaging system includes a data acquisition module, a preprocessing module, a classification and decision module, and an industrial interface module;
[0010] Step 2: Feature extraction based on discrete wavelet transform and one-dimensional convolutional neural network: The hyperspectral image is preprocessed and decomposed into 4 layers based on discrete wavelet transform Haar wavelet to extract low-frequency approximate coefficients as dimensionality reduction features; the reduced dimensionality features are input into a one-dimensional convolutional neural network;
[0011] The one-dimensional convolutional neural network includes:
[0012] (1) The first convolutional layer: 3 × 16 convolution kernel, ReLU activation function, extracting local spectral features;
[0013] (2) The second convolutional layer: 5 × 32 convolution kernel, L2 regularization, to capture global spectral correlation;
[0014] (3) Fully connected layer: 64→32 nodes, dropout rate 0.1, outputting probability distributions of six categories: formaldehyde, 4-aminobiphenyl, nonylphenol, melamine, ethanol, and no residue;
[0015] Step 3: Formaldehyde residue detection based on feature matching: The feature vector output by the one-dimensional convolutional neural network is matched with the spectral features in the pre-trained database for similarity, where the cosine similarity threshold is >0.95, and a detection result is generated. The detection result includes the pollutant type, confidence level (range 0-1) and concentration range.
[0016] Preferably, the data acquisition module integrates a hyperspectral camera, a 1000W halogen light source, and a darkroom environment control unit for non-destructive acquisition of fabric spectral data.
[0017] Preferably, the pre-processing module performs black / white correction, SG filtering, and dimension reduction through a DWT algorithm, and supports Haar / bior1.5 / sym5 / db3 wavelet bases.
[0018] Preferably, the classification decision module deploys a one-dimensional convolutional neural network model (TensorRT acceleration) to output pollutant classification results in real time.
[0019] Preferably, the industrial interface module supports RS-485 / Ethernet protocol to transmit the detection results to the production line quality control system.
[0020] Preferably, the preprocessing specifically includes black correction, white correction, and SG filtering denoising.
[0021] Preferably, the dimensionality reduction feature is specifically a dimension reduction from 1200 to 75 dimensions, and the information entropy is 13.02.
[0022] Preferably, the L2 regularization weight attenuation coefficient is 0.001.
[0023] In summary, the present invention mainly has the following beneficial effects:
[0024] Based on hyperspectral imaging and deep learning technology, this invention realizes non-destructive detection of formaldehyde residues in pure cotton fabrics. Through efficient dimensionality reduction of discrete wavelet transform (DWT) and 1D-CNN adaptive feature extraction, it significantly solves the problems of strong destructiveness of traditional chemical detection and low data utilization of spectral technology. As a result, the accuracy of formaldehyde residue detection is also guaranteed, with better results. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a formaldehyde residual detection flow chart of the present invention;
[0026] Figure 2 This is a flow chart of the formaldehyde residue detection model training process of the present invention;
[0027] Figure 3 Schematic diagram of the hardware structure of the present invention;
[0028] Figure 4 This is a one-dimensional convolutional neural network structure diagram of the present invention. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0030] like Figures 1 to 4 As shown, a method for detecting formaldehyde residues in pure cotton fabrics comprises the following steps:
[0031] Step 1: Obtain a hyperspectral image of the cotton fabric to be tested: Use a hyperspectral imaging system to non-contactly collect spectral data of the fabric sample and generate a three-dimensional spectral cube containing spatial coordinates and wavelength dimensions;
[0032] The hyperspectral imaging system includes a data acquisition module, a preprocessing module, a classification and decision module, and an industrial interface module;
[0033] The data acquisition module integrates a hyperspectral camera, a 1000W halogen light source, and a darkroom environment control unit to non-destructively acquire fabric spectral data.
[0034] Preprocessing module: performs black / white correction, SG filtering, and dimension reduction through the DWT algorithm, supporting Haar / bior1.5 / sym5 / db3 wavelet bases.
[0035] The classification decision module deploys a one-dimensional convolutional neural network model (accelerated by TensorRT) to output pollutant classification results in real time.
[0036] The industrial interface module supports RS-485 / Ethernet protocol to transmit the test results to the production line quality control system;
[0037] Step 2: Feature extraction based on discrete wavelet transform and one-dimensional convolutional neural network: The hyperspectral image is preprocessed, including black correction, white correction, and SG filtering denoising. The image is then decomposed into four layers based on the discrete wavelet transform Haar wavelet, and low-frequency approximate coefficients are extracted as dimensionality reduction features. The dimensionality reduction features are specifically reduced from 1200 to 75 dimensions, with an information entropy of 13.02. The reduced dimensionality features are then input into a one-dimensional convolutional neural network.
[0038] One-dimensional convolutional neural network includes:
[0039] (1) The first convolutional layer: 3 × 16 convolution kernel, ReLU activation function, extracting local spectral features;
[0040] (2) The second convolutional layer: 5 × 32 convolution kernel, L2 regularization, L2 regularization weight decay coefficient is 0.001, capturing global spectral correlation;
[0041] (3) Fully connected layer: 64→32 nodes, dropout rate 0.1, outputting probability distributions of six categories: formaldehyde, 4-aminobiphenyl, nonylphenol, melamine, ethanol, and no residue;
[0042] Step 3. Formaldehyde residue detection based on feature matching: The feature vector output by the one-dimensional convolutional neural network is matched with the spectral features in the pre-trained database for similarity, where the cosine similarity threshold is >0.95, and the detection results are generated. The detection results include the pollutant type, confidence level (range 0-1) and concentration range.
[0043] It should be noted that, in this embodiment, the implementation method of the present invention includes three parts: hardware system deployment, software module implementation and detection process execution. The following is a detailed description in combination with physical components, data structure and operation steps. Among them, the "preprocessing module" and the "classification decision module" are merged into the "data operation unit", integrating the entire data processing link.
[0044] 1. Hardware System Composition and Physical Deployment
[0045] The detection system of the present invention is composed of the following physical modules, as shown in Table 1:
[0046]
[0047]
[0048] Table 1 System architecture diagram
[0049] 2. Data Operation Unit Implementation Details
[0050] The data processing unit is the core of the system, integrating pre-processing and classification decision-making functions. Its hardware and software implementation are as follows:
[0051] 1. Hardware composition and physical signal flow
[0052] (1) Computing equipment:
[0053] ① Lab mode: The graphics workstation is connected to the GPU (NVIDIA RTX 6000) via the PCIe 4.0×16 interface for pre-processing with high computing power requirements (such as large-size spectral cube processing).
[0054] ② Production line mode: The embedded device (NVIDIA Jetson AGX Xavier) integrates a CPU (ARM Cortex-A726 core), a GPU (Volta architecture 512 CUDA cores), and a dedicated inference engine (TensorRT), meeting real-time requirements (single sample processing < 1 second);
[0055] (2) Storage medium:
[0056] ① Laboratory mode: NVMe SSD (512GB) stores raw spectral data (path: / data / raw / ), preprocessing parameters (such as dark / white calibration files, path: / data / calibration / ) and model weights (path: / data / model / ).
[0057] ② Production line mode: eMMC flash memory (64GB) stores lightweight models (ONNX format, approximately 15MB) and intermediate features for real-time processing (memory buffer, LPDDR4X 8GB).
[0058] 2. Software modules and data flow
[0059] The software of the data operation unit runs on the computing device and includes a pre-processing submodule and a classification decision submodule. The process is as follows:
[0060] Step 1: Preprocessing submodule (black / white correction, SG filtering, DWT dimensionality reduction)
[0061] (1) Operation subject: Python / C++ hybrid program (calling ENVI library and PyWavelets library).
[0062] (2) Data structure:
[0063] ① Input: three-dimensional spectral matrix RawData[X][Y][λ] (floating point type, range 0-1, X, Y∈[0,1919], λ∈[400,1000]nm).
[0064] ② Output: two-dimensional feature matrix Features[X][Y]
[75] (floating point type, 75-dimensional DWT low-frequency coefficients).
[0065] (3) Execution steps:
[0066] ① Black correction: Calculate Ic = RawData[X][Y][λ] - Idark[X][Y][λ] (Idark is the dark background image, stored in / data / calibration / dark.hdr) pixel by pixel to eliminate camera dark current noise.
[0067] ② White correction: Calculate R = Ic / Iwjite[X][Y][λ] pixel by pixel (Iwjite is a standard whiteboard image, stored in / data / calibration / white.hdr) and convert it to relative reflectance (range 0-1).
[0068] ③SG filtering denoising: Apply Savitzky-Golay filtering (window size 3, polynomial order 2) to the spectral curve (λ dimension) of each pixel, formula:
[0069]
[0070] ④DWT dimensionality reduction: Select the experimentally optimal db3 wavelet basis, perform a 4-layer decomposition on the spectral curve of each pixel, and extract the low-frequency approximate coefficients (the dimension is reduced from 1200 to 75). The formula is:
[0071] Approx = DWT(R smooth ,wavelet=′db3′,level=4)
[0072] Step 1: Classification Decision Submodule (1D-CNN Inference)
[0073] (1) Operation subject: TensorRT optimized C++ inference engine (load ONNX model, storage path: / data / model / 1d_cnn.onnx).
[0074] (2) Data structure:
[0075] ① Input: 75-dimensional feature vector Input
[75] (floating point type, normalized to 0-1).
[0076] ② Output: 6-dimensional probability vector Output[6] (floating point type, ∑Output[i]=1), corresponding to categories: no residue, formaldehyde, 4-aminobiphenyl, nonylphenol, melamine, ethanol.
[0077] (3) Network structure (see Table 2 1D-CNN parameters):
[0078]
[0079] Table 2 1D-CNN parameters
[0080] (4) Physical calculation process:
[0081] ① The feature vector is transferred to the GPU memory via the PCIe bus (lab mode) or the on-chip bus (production mode).
[0082] ②The TensorRT engine calls the CUDA core to perform matrix operations such as convolution and pooling (floating-point operation unit), and outputs the probability vector to the CPU memory.
[0083] 3. Detection Process and Physical Signal Flow
[0084] The physical signal transmission of the complete detection process is as follows:
[0085] (1) Light signal acquisition: Halogen lamp emits 400-1000nm continuous spectrum → irradiates the fabric surface → reflected light is focused by the camera lens → CCD sensor converts light signal into electrical signal (analog voltage) → AD converter quantifies it into digital spectrum data.
[0086] (2) Data transmission: Digital spectral data is transmitted to the computing device memory (DDR4 / LPDDR4X) via Gigabit Ethernet (physical layer: RJ45 interface, protocol: GigEVision).
[0087] (3) Data operations:
[0088] ① Preprocessing submodule: The raw data in the memory undergoes black / white correction, SG filtering, and DWT dimensionality reduction to generate a 75-dimensional feature vector (memory buffer).
[0089] ②Classification decision submodule: Feature vector input 1D-CNN model, GPU performs inference, and outputs probability vector (memory)
[0090] (4) Result output: The probability vector triggers the LED light (red: 3.3V high level; green: 0V low level) through the GPIO interface (physical layer: 3.3V TTL level) and is sent to the production line PLC (Siemens S7-1200) through the Ethernet PHY chip (physical layer: 1000BASE-T).
[0091] 4. Verification of the Example
[0092] Select pure cotton fabric (200g / m 2 ) as a test sample and perform the test according to the following steps:
[0093] (1) Sample preparation: Cut 12 cm × 12 cm pieces of fabric, soak them in formaldehyde solution (450 mg / kg) for 12 hours, and dry them naturally.
[0094] (2) Data acquisition: The hyperspectral camera scans the sample and generates / data / raw / sample_20250519_1030.hdr (1920×1920×1200 three-dimensional matrix).
[0095] (3) Data operations:
[0096] ① Preprocessing: The computing device performs black / white correction and SG filtering, and obtains a 75-dimensional feature vector (information entropy 13.02) after DWT dimensionality reduction.
[0097] ②Classification decision: Load the 1D-CNN model and output the probability vector [0.001, 0.998, 0.000, 0.001, 0.000, 0.000] (99.8% confidence level for formaldehyde).
[0098] (4) Result output: The display shows "Formaldehyde residue exceeds the standard (450mg / kg)", the LED light turns red to alarm, and the PLC controls the robotic arm to mark the sample as defective.
[0099] The above embodiments are only for illustrating the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for detecting formaldehyde residue in pure cotton fabrics, characterized in that: The following steps are involved: Step 1: Obtain a hyperspectral image of the cotton fabric to be tested: Use a hyperspectral imaging system to non-contactly collect spectral data of the fabric sample and generate a three-dimensional spectral cube containing spatial coordinates and wavelength dimensions; The hyperspectral imaging system includes a data acquisition module, a preprocessing module, a classification and decision module, and an industrial interface module; Step 2: Feature extraction based on discrete wavelet transform and one-dimensional convolutional neural network: preprocess the hyperspectral image and perform a 4-layer decomposition based on discrete wavelet transform Haar wavelet to extract low-frequency approximate coefficients as dimensionality reduction features; Input the reduced-dimensional features into a one-dimensional convolutional neural network; The one-dimensional convolutional neural network includes: (1) The first convolutional layer: 3 × 16 convolution kernel, ReLU activation function, extracting local spectral features; (2) The second convolutional layer: 5 × 32 convolution kernel, L2 regularization, to capture global spectral correlation; (3) Fully connected layer: 64→32 nodes, dropout rate 0.1, outputting probability distributions of six categories: formaldehyde, 4-aminobiphenyl, nonylphenol, melamine, ethanol, and no residue; Step 3: Formaldehyde residue detection based on feature matching: The feature vector output by the one-dimensional convolutional neural network is matched with the spectral features in the pre-trained database for similarity, where the cosine similarity threshold is >0.95, and a detection result is generated. The detection result includes the pollutant type, confidence level (range 0-1) and concentration range.
2. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The data acquisition module integrates a hyperspectral camera, a 1000W halogen light source, and a darkroom environment control unit to non-destructively acquire fabric spectral data.
3. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The pre-processing module performs black / white correction, SG filtering, and dimension reduction through the DWT algorithm, supporting Haar / bior1.5 / sym5 / db3 wavelet bases.
4. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The classification decision module deploys a one-dimensional convolutional neural network model (accelerated by TensorRT) to output pollutant classification results in real time.
5. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The industrial interface module supports RS-485 / Ethernet protocol and transmits the test results to the production line quality control system.
6. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The preprocessing specifically includes black correction, white correction, and SG filtering denoising.
7. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The dimensionality reduction feature is specifically that the dimension is reduced from 1200 to 75 dimensions, and the information entropy is 13.
02.
8. The method for detecting formaldehyde residue in pure cotton fabric according to claim 1, wherein: The L2 regularization weight decay coefficient is 0.001.
Citation Information
Patent Citations
A fabric principal component detection method based on a convolution neural network
CN109447097A
High-level semantic image retrieval method based on deep learning
CN111782852A
Method for detecting and quantifying viruses in fluid samples by means of digital processing of hyperspectral images of diffuse optical reflectance obtained in the visible and near infrared ranges
WO2022229413A1