Military clothing production defect automatic detection method and system based on machine learning

By constructing a three-dimensional lighting model and five-dimensional image tensor decomposition, combined with machine learning algorithms, the problems of low defect detection efficiency and insufficient accuracy in military clothing production are solved, and efficient and accurate automated detection is achieved.

CN120471860APending Publication Date: 2025-08-12HU BEI YU HE ZHI YI YOU XIAN GONG SI
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510554599.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

The defect detection efficiency in military clothing production is low and prone to missed and missed detection. Traditional image processing methods lack detection accuracy under complex lighting conditions.

Method used

Build a three-dimensional lighting model, combine image five-dimensional tensors and machine learning algorithms, and identify clothing fabric defects through lighting influence features and their own material features.

Benefits of technology

It improves the accuracy and efficiency of defect detection, reduces the influence of human factors, ensures the consistency and reliability of the test results, and meets the needs of large-scale production of military clothing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120471860A_ABST
    Figure CN120471860A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of clothing detection, in particular to a military clothing production defect automatic detection method and system based on machine learning. The method comprises the following steps: constructing a three-dimensional illumination model of a current scene; constructing an image five-dimensional tensor corresponding to the to-be-detected clothing image; according to the illumination parameters corresponding to the three-dimensional space sampling points in the three-dimensional illumination model and the material category labels of the two-dimensional image pixel points corresponding to the three-dimensional space sampling points, determining the physical reflection characteristics of the two-dimensional image pixel points; performing tensor decomposition on the five-dimensional tensor of the image according to the physical reflection characteristics of the pixel points of each two-dimensional image to obtain illumination influence characteristics and self material characteristics of the pixel points of each two-dimensional image; and determining the defect condition of the to-be-detected clothing fabric by adopting a machine learning algorithm according to the material characteristics of the pixel points of each two-dimensional image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of clothing inspection technology, and in particular to a method and system for automatically detecting production defects of military clothing based on machine learning. Background Art

[0002] Military clothing production defect detection refers to the process of using various technical means and methods to comprehensively inspect and evaluate the raw materials, parts, processing technology and finished products of military clothing during the production process of military clothing, in order to discover and identify various possible defects and ensure that the quality and performance of military clothing meet the requirements of military use.

[0003] Military clothing is produced on a large scale, making manual inspection inefficient and prone to missed and false detections. Furthermore, traditional image processing-based inspections perform grayscale, filtering, edge detection, and other operations on clothing images to extract features such as texture and shape, then compare them with standard templates or thresholds to detect defects.

[0004] This method improves the detection efficiency to a certain extent, but it has poor adaptability to defect morphology under complex lighting conditions, and the detection accuracy needs to be improved. Summary of the Invention

[0005] Based on this, it is necessary to provide a method and system for automatic detection of defects in military clothing production based on machine learning that can improve the accuracy of defect detection in response to the above technical problems.

[0006] In a first aspect, the present application provides a method for automatically detecting production defects of military clothing based on machine learning, the method comprising: Construct a 3D illumination model of the current scene. The 3D illumination model includes illumination parameters of each 3D spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and 3D spatial position. Construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; determining the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point; According to the physical reflection characteristics of each two-dimensional image pixel, the five-dimensional image tensor is decomposed to obtain the illumination influence characteristics and material characteristics of each two-dimensional image pixel; Based on the material characteristics of each two-dimensional image pixel, a machine learning algorithm is used to determine the defects of the clothing fabric to be inspected.

[0007] In one embodiment, constructing a five-dimensional image tensor corresponding to the clothing image to be detected includes: Constructing an original four-dimensional tensor based on the multispectral image data of the garment to be inspected; the original four-dimensional tensor includes the image height, width, spectral channel, and the material category label of each two-dimensional image pixel in the garment image to be inspected; Normalize the three-dimensional spatial position of the three-dimensional spatial sampling point corresponding to each two-dimensional image pixel point in the clothing image to be detected to obtain a position encoding vector; Embed the position encoding vector as the fifth dimension into the original four-dimensional tensor to construct the initial five-dimensional tensor; A position-sensitive attention mechanism is used to determine the illumination correlation weight matrix of the clothing image to be detected. The illumination correlation weight matrix includes the illumination correlation weight values between any two 2D image pixels in the clothing image to be detected. The illumination correlation weight values are positively correlated with the spatial position distance, spectral similarity, and material category relevance of the 2D image pixels. The illumination correlation weight matrix is fused with the initial five-dimensional tensor to obtain the five-dimensional image tensor corresponding to the clothing image to be detected.

[0008] In one embodiment, the illumination correlation weight matrix is fused with the initial five-dimensional tensor to obtain a five-dimensional image tensor corresponding to the clothing image to be detected, including: Fuse the illumination-related weight matrix with the initial five-dimensional tensor to obtain a fused five-dimensional vector; Light is randomly emitted on the surface of the garment to be inspected, and the Monte Carlo path tracing algorithm is used to simulate the multiple reflection paths of light on the fabric surface to determine the indirect illumination component of each 2D image pixel. The indirect illumination component includes the intensity, direction and spectral distribution of the indirect illumination. Combining the indirect illumination component and the direct illumination component of each two-dimensional image pixel to form a global illumination component of each two-dimensional image pixel; Identify dark areas in the image to be detected based on the global illumination components of each two-dimensional image pixel; Generate a compensation weight matrix based on the light sensitivity corresponding to the material category label of each two-dimensional image pixel in the dark area; the light intensity of the dark area is less than the intensity threshold; Multiplying the indirect lighting component of each two-dimensional image pixel by the compensation weight matrix to generate an indirect lighting compensation item for each two-dimensional image pixel; According to the indirect illumination compensation item of each two-dimensional image pixel, the fused five-dimensional vector is compensated to obtain the five-dimensional image tensor corresponding to the clothing image to be detected.

[0009] In one embodiment, a position-sensitive attention mechanism is used to determine an illumination-related weight matrix of a clothing image to be detected, including: Obtain the three-dimensional spatial coordinates, multispectral features and material category features of each pixel in the clothing image to be detected; Use a learnable Gaussian kernel function to calculate the spatial distance weight between any two pixels; The spectral feature dot product is used to calculate the spectral similarity weight of any two pixels; The projection similarity of the material category embedding vector is used to calculate the material correlation weight of any two pixels; The spatial distance weight, spectral similarity weight and material correlation weight are fused at the element level to generate the initial correlation weight of any two pixels; The initial association weights of any two pixels are normalized to obtain the illumination association weight values of any two pixels.

[0010] In one embodiment, for any three-dimensional spatial sampling point in a three-dimensional illumination model and the two-dimensional image pixel corresponding to the three-dimensional spatial sampling point in the garment image to be inspected, the physical reflection characteristics of each two-dimensional image pixel are determined based on the illumination parameters corresponding to each three-dimensional spatial sampling point in the three-dimensional illumination model and the material category label of each two-dimensional image pixel corresponding to each three-dimensional spatial sampling point, including: The two-dimensional image pixel point corresponding to the three-dimensional space sampling point in the clothing image to be detected is used as the target two-dimensional pixel point; Extract the basic diffuse reflection features and basic specular reflection response features corresponding to the material category labels of the target two-dimensional pixels based on the pre-built material reflection database; Generate the diffuse reflectance modulation factor and the dynamic adjustment coefficient of the specular reflectance of the target pixel point based on the illumination parameters corresponding to the three-dimensional space sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point; According to the degree of three-dimensional geometric deformation of the cloth surface in the image area where the target two-dimensional pixel is located, the diffuse reflectance modulation factor of the target two-dimensional pixel is smoothly constrained to obtain the optimized diffuse reflectance modulation factor; According to the optimized diffuse reflectance modulation factor, the basic diffuse reflectance characteristics of the target two-dimensional pixel are adjusted to obtain the current diffuse reflectance characteristics of the target two-dimensional pixel point; According to the dynamic adjustment coefficient of the specular reflectivity, the basic specular reflection response characteristics are adjusted to obtain the current specular reflection characteristics of the target two-dimensional pixel point.

[0011] In one embodiment, the physical reflection characteristics include current diffuse reflection characteristics; the base diffuse reflection characteristics include base diffuse reflectance; According to the illumination parameters corresponding to the three-dimensional space sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point, the diffuse reflectance modulation factor and specular reflectance dynamic adjustment coefficient of the target pixel point are generated, including: Determine a first angle cosine value of a first angle between an incident light direction in illumination parameters corresponding to a sampling point in three-dimensional space and a surface normal of a surface where a target pixel point is located; According to the spectral distribution of the illumination parameters corresponding to the three-dimensional spatial sampling points, the basic specular reflectance is spectrally weighted to obtain the weighted specular reflectance; The product of the cosine value of the included angle and the weighted specular reflectivity is used as the diffuse reflectivity modulation factor of the target pixel.

[0012] In one embodiment, the physical reflection characteristics include current specular reflection characteristics; the basic specular reflection response characteristics include basic specular reflectivity and specular reflection index; According to the illumination parameters corresponding to the three-dimensional space sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point, the dynamic adjustment coefficient of the specular reflectivity of the target pixel point is generated, including: Determine the half vector according to the observation direction corresponding to the target pixel point and the incident light direction in the illumination parameter corresponding to the three-dimensional space sampling point; Determine a second angle cosine value of a second angle between the half vector and the surface normal of the surface where the target pixel point is located; The specular reflection index is used as the exponent of the cosine value of the second angle to obtain an exponential calculation result; The dynamic adjustment coefficient of the specular reflectivity of the target pixel point is determined based on the index calculation result, the basic specular reflectivity, and the illumination intensity in the illumination parameters corresponding to the three-dimensional space sampling point.

[0013] In one embodiment, based on the degree of three-dimensional geometric deformation of the cloth surface in the image region where the target two-dimensional pixel is located, a smoothing constraint is applied to the diffuse reflectance modulation factor of the target two-dimensional pixel to obtain an optimized diffuse reflectance modulation factor, including: Constructing a three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located; According to the three-dimensional geometric deformation matrix, the original diffuse reflectance modulation factor matrix formed by the diffuse reflectance modulation factor of each two-dimensional image pixel in the image area is averaged in the neighborhood to obtain a smoothed modulation factor matrix; According to the three-dimensional geometric deformation matrix, the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix are weighted fused to obtain a fused modulation factor matrix; Adaptive Gaussian filtering is performed on the fused modulation factor matrix to output the optimized diffuse reflectance modulation factor.

[0014] In one embodiment, constructing a three-dimensional geometric deformation matrix of the cloth surface in the image region where the target two-dimensional pixel is located includes: Determine the deformation characteristics of the cloth surface in the image region where the target two-dimensional pixel is located using at least one of a depth gradient method, a normal angle method, a texture analysis method, or an optical flow method; According to the deformation characteristics, the three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located is determined.

[0015] In a second aspect, the present application also provides a system for automatically detecting production defects of military clothing based on machine learning, comprising: The scene construction module is used to construct a 3D illumination model of the current scene. The 3D illumination model includes illumination parameters of each 3D spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and 3D spatial position. A tensor construction module is used to construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; A feature analysis module is used to determine the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category label of each 2D image pixel point corresponding to each 3D spatial sampling point; The tensor decomposition module is used to perform tensor decomposition on the five-dimensional image tensor according to the physical reflection characteristics of each two-dimensional image pixel point, and obtain the illumination influence characteristics and material characteristics of each two-dimensional image pixel point; The defect recognition module is used to determine the defects of the clothing fabric to be inspected based on the material characteristics of each two-dimensional image pixel point using a machine learning algorithm.

[0016] The aforementioned machine learning-based method and system for automatically detecting defects in military clothing production takes lighting factors into account: constructing a three-dimensional lighting model can accurately describe the lighting parameters of each three-dimensional spatial sampling point in the current scene, including the direction of the incident light, the spectral distribution, and the three-dimensional spatial position. This can effectively address the problem of lighting conditions interfering with clothing detection. Different lighting conditions can cause the reflective properties of the clothing surface to change, affecting the judgment of defects. By accurately simulating lighting conditions, the impact of lighting on the reflective properties of the clothing surface can be more accurately analyzed, thereby improving detection accuracy in various complex lighting environments.

[0017] Constructing a five-dimensional image tensor incorporates, in addition to conventional image height, width, and spectral channel information, the material category label and three-dimensional spatial position information for each two-dimensional image pixel. Different clothing materials present distinct characteristics during inspection. Material category labels help distinguish regions of varying materials, while three-dimensional spatial position information considers the garment's posture and layout in space. This allows for comprehensive consideration of multiple factors and a more comprehensive description of garment characteristics, providing a richer data foundation for accurate defect detection and addressing the single-dimensional nature of traditional inspection methods.

[0018] The physical reflectance characteristics of each 2D image pixel are determined based on the 3D lighting model and material category labels. The image's 5D tensor is then decomposed to derive lighting-affected features and intrinsic material features. This method separates lighting factors from the garment's inherent material characteristics, allowing defect identification to focus solely on the garment's inherent material features. This avoids the interference of lighting variations on defect feature extraction, enabling more accurate extraction of the essential features of the defect. This addresses the challenge of defect feature extraction under complex lighting and material conditions, further improving defect detection accuracy.

[0019] Machine learning algorithms can be used to identify defects in garment fabrics based on extracted material characteristics, enabling automated defect detection. Compared to manual visual inspection, this significantly improves inspection efficiency, reduces the impact of human factors, and ensures consistent and reliable test results, meeting the demand for efficient and accurate inspection in the large-scale production of military clothing. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.

[0021] Figure 1 1 is a flow chart of a method for automatically detecting production defects of military clothing based on machine learning in one embodiment; Figure 2 This is a structural block diagram of an automatic detection system for military clothing production defects based on machine learning in one embodiment. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0023] In an exemplary embodiment, Figure 1 As shown, a method for automatic detection of production defects of military clothing based on machine learning is provided, the method comprising: S101, constructing a three-dimensional lighting model of the current scene.

[0024] The three-dimensional illumination model includes illumination parameters of each three-dimensional spatial sampling point in the current scene; the illumination parameters include incident light direction, spectral distribution, and three-dimensional spatial position.

[0025] It's understandable that, based on the principles of physical illumination models, natural illumination follows certain physical laws, such as light propagation, reflection, refraction, and absorption. Three-dimensional illumination models draw on these physical principles and use mathematical models to simulate the behavior of light in a scene. For the direction of incident light, it's necessary to determine the direction vector of the light source relative to objects (including clothing) in the scene. This can be calculated using the light source's position and the scene coordinate system. The spectral distribution is based on the characteristics of the light source. Different light sources (such as natural light, incandescent lamps, and fluorescent lamps) have different spectral power distributions. The spectral power distribution data of the light source can be combined with the light propagation model in the scene to determine the spectral composition of the light reaching each sampling point in three-dimensional space. For the three-dimensional spatial position, a unified scene coordinate system must be established to precisely determine the position of each sampling point within this coordinate system to accurately describe the characteristics of light at different locations.

[0026] Integrating scene data principles: Utilizing the current scene's light intensity, light source direction, color temperature, and spatial layout data, the lighting model is further refined. Light intensity determines the amount of light energy, which is related to factors such as the light source's power and propagation distance. By measuring or estimating the scene's light intensity, the light intensity parameters in the model can be adjusted. The light source direction directly influences the direction of incident light. Accurate light source direction information helps simulate the light propagation path more realistically. Color temperature is closely related to spectral distribution. Light sources with different color temperatures have different color appearances. For example, low color temperature light sources tend to be yellowish, while high color temperature light sources tend to be bluish. Based on color temperature data, the spectral distribution model can be adjusted to better reflect the characteristics of the actual light source. Spatial layout data includes information such as the position, shape, and material of objects in the scene. This information influences phenomena such as reflection, refraction, and scattering of light in the scene, thereby affecting the lighting parameters at each sampling point.

[0027] Optionally, determine the scene coordinate system: First, select an appropriate scene coordinate system, such as one with a corner of the scene as the origin and three mutually perpendicular directions as coordinate axes. This provides a unified reference for determining the positions of the 3D sampling points.

[0028] Light source direction determination: Calculate the light source's direction vector relative to the scene coordinate system using sensors (such as gyroscopes and accelerometers) or based on known light source positions in the scene. If the light source's coordinates and the scene origin are known, the light source direction vector can be obtained through vector subtraction and normalized to a length of 1 to facilitate subsequent calculations.

[0029] Spectral distribution simulation: Standard spectral power distribution models exist for common light sources, such as natural and artificial light. Based on information such as the light source type and color temperature, you can select an appropriate spectral power distribution model and make appropriate adjustments. For example, if simulating natural light, you can refer to the CIE (International Commission on Illumination) standard for daylight spectral distribution and make fine-tuning adjustments based on local time of day, weather, and other factors. For artificial light sources, such as LEDs, you can construct a spectral distribution model based on the spectral parameters in the product manual.

[0030] Light intensity calculation: Light sensors are used to measure light intensity at different locations in the scene, or light intensity is calculated based on the light source's power, propagation distance, and attenuation model. For point light sources, the inverse square law can be used to calculate the intensity attenuation at different distances. By measuring or calculating at multiple locations in the scene, the spatial distribution of light intensity can be determined.

[0031] Determining 3D sampling points and calculating parameters: 3D sampling points are selected within the scene according to a certain density and rules. For each sampling point, the incident light direction, spectral distribution, and 3D position are calculated based on the previously determined light source direction, spectral distribution, and light intensity, combined with a light propagation model (such as a simplified version of the ray tracing algorithm). The core idea of the ray tracing algorithm is to trace light rays backward from each sampling point, taking into account reflection, refraction, and absorption in the scene, ultimately determining the characteristics of the light reaching that sampling point. In this way, the lighting parameters for each 3D sampling point in the current scene are constructed, completing the construction of the 3D lighting model.

[0032] S102: Construct a five-dimensional image tensor corresponding to the clothing image to be detected.

[0033] The five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel in the clothing image to be detected.

[0034] Limitations of traditional image representation: Conventional images exist as three-dimensional tensors (height, width, and color channels), which can only describe the image's appearance. However, in the context of a machine learning-based automated defect detection method and system for military clothing production, this information is insufficient to fully analyze the clothing's condition. For example, color channels alone cannot accurately distinguish stains or damage on clothing made of different materials, as different materials have different light reflection and absorption properties, resulting in different defect presentation effects.

[0035] The necessity of material category labels: Clothing made of different materials exhibits unique defects. Holes in cotton and silk garments exhibit significant differences in edge shape, light transmittance, and other appearance characteristics. Introducing material category labels provides critical information for subsequent defect recognition models, helping them understand the material characteristics of the pixel and more accurately determine the defect type and characteristics.

[0036] The importance of 3D spatial position: Clothing is a three-dimensional object, and its position and posture in real space affect the lighting, texture, and other information presented in each part of the image. Understanding the 3D spatial position of pixels, combined with a 3D lighting model, can analyze the impact of lighting at different locations on defect identification. It can also assist in determining the position of defects within the overall structure of the garment, helping to locate defects and assess their impact on the overall quality of the garment.

[0037] Image Height and Width: Image acquisition devices (such as cameras) record light intensity information through photosensitive elements, arranging pixels horizontally and vertically at a certain resolution to form rows and columns of an image. The number of rows and columns corresponds to the image's height and width. This principle is based on the basic geometric model of camera imaging: light passes through the lens and is focused onto a photosensitive surface, with each photosensitive unit corresponding to a pixel location.

[0038] Spectral channels: A camera's photosensitive element responds differently to different wavelengths of light. Using filters and other techniques, light is decomposed into different wavelength bands, such as the common RGB (red, green, and blue) channels, and the intensity of each corresponding wavelength is recorded. Different colors of light correspond to different wavelength ranges. The camera quantifies the intensity of these wavelengths to form spectral channel information, thereby presenting the color of the image.

[0039] Material Category Labeling: Based on machine learning classification principles, a classification model is trained using a large sample of clothing images labeled with material categories. The model learns the characteristic patterns of texture, color distribution, and other aspects of clothing images made of different materials. For each image under test, the model determines the material category of each pixel based on the degree of match between the input image features and the characteristics of various materials in the training set.

[0040] 3D spatial position: This method combines camera calibration with multi-view geometry principles. Camera calibration obtains the camera's intrinsic parameters (such as focal length and principal point position) and extrinsic parameters (rotation and translation) to determine the geometric relationship of the camera image. Using multi-view images, a feature matching algorithm finds corresponding pixels in different views. Based on triangulation principles, the pixel's coordinate position in 3D space is calculated from the camera parameters and matching point information.

[0041] Optional Image Height and Width Capture: Directly read the camera's resolution settings in the image acquisition device driver or image acquisition software to determine the number of rows (height) and columns (width) of the image. Once the image is acquired, these parameters are stored as inherent properties of the image, eliminating the need for additional complex calculations.

[0042] Spectral channel generation: The camera hardware performs the light decomposition and quantization process internally. For a color camera, after light passes through a filter, light of different wavelengths is incident on corresponding photosensitive cells. For example, in an RGB camera, the photosensitive cells behind the red filter record the intensity of red light, and similarly for green and blue. These photosensitive cells convert the optical signal into an electrical signal and quantize it. Ultimately, the data is stored sequentially in the RGB channel order, forming spectral channel information.

[0043] Data preparation: We collected a large number of images of various common clothing materials (such as cotton, linen, silk, and chemical fibers), and manually annotated the material category of each image. These annotated images constitute the training dataset.

[0044] Model Building and Training: Use a deep convolutional neural network, such as a modified ResNet or DenseNet architecture. Add fully connected layers and a softmax classifier for material classification to the network structure. Input the training dataset into the network, and continuously adjust the network parameters using a backpropagation algorithm to gradually optimize the network's ability to extract and classify image features of different materials until the model achieves high classification accuracy on the validation set.

[0045] Prediction and Labeling: After preprocessing the garment image according to the model input requirements (such as resizing and normalization), it is fed into the trained material classification model. The model outputs the probability of each pixel belonging to each material type. The category with the highest probability is selected as the material category label for that pixel. This process is then performed point by point to form the material category label for the entire image.

[0046] Camera calibration: Use a calibration pattern, such as a checkerboard, and capture images of the pattern from multiple angles. Use image processing algorithms to detect feature points on the pattern (such as checkerboard corners). Then, using a camera imaging model (such as the pinhole imaging model) and a nonlinear optimization algorithm, calculate the camera's intrinsic and extrinsic parameters to obtain the camera's calibration matrix.

[0047] Multi-view image acquisition and feature matching: Use multiple cameras or a single, mobile camera to capture images of the garment to be inspected from different perspectives. Feature extraction algorithms (such as SIFT, SURF, or deep learning-based feature extractors) are used to extract feature points from the images, and descriptors are used to describe these feature points. Matching algorithms (such as nearest neighbor matching and FLANN matching) are used to find correspondences between feature points in the images from different views and select reliable matching point pairs.

[0048] 3D Coordinate Calculation: Based on the principles of triangulation, a system of equations is constructed using the pixel coordinates of matching point pairs in different views and parameters obtained from camera calibration. By solving the system of equations, the coordinates of each matching point in 3D space are calculated. For pixels in the image that are not included in the matching, their 3D spatial position is estimated using interpolation algorithms (such as bilinear interpolation) or deep learning-based 3D reconstruction methods. Ultimately, the 3D spatial position information of each pixel in the entire image is obtained. This information is sequentially integrated to construct a five-dimensional tensor containing the image height, width, spectral channel, material category label, and 3D spatial position.

[0049] S103 , determining the physical reflection characteristics of each 2D image pixel point according to the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point.

[0050] It's understandable that the reflective properties of clothing surfaces are key to understanding their appearance, and these properties are influenced by both lighting conditions and the clothing material. Accurately understanding the physical reflective properties of pixels in a two-dimensional image can provide a foundation for subsequent analysis of the impact of lighting on clothing appearance and identifying defects related to clothing materials. For example, different materials reflect differently under the same lighting. By determining their physical reflective properties, we can more clearly distinguish between areas of different materials and understand how lighting changes the visual appearance of materials, thereby improving the accuracy of clothing image analysis.

[0051] Principle of interaction between light and material: The interaction between light and the surface of an object follows the laws of optical physics, including light reflection, refraction, and absorption. For opaque clothing materials, the main consideration is light reflection. Different materials have different optical constants, which determine the material's reflectivity and absorptivity to light of different wavelengths. At the same time, the direction of the incident light in the lighting parameters determines the angle of incidence between the light and the material surface, and the spectral distribution determines the components of the light involved in the reflection. Based on these factors, an optical model can be used to calculate the reflective properties of the material surface. For example, based on the bidirectional reflectance distribution function (BRDF), which describes the distribution of light incident from a given direction and emitted in all directions after reflection on the material surface, combined with the lighting parameters in the three-dimensional lighting model and the material optical properties corresponding to the material category label, the physical reflective properties of each pixel can be determined.

[0052] Optionally, a material optical property library is established: First, for common clothing materials, obtain their optical constants at different wavelengths, such as reflectivity, absorptivity, etc., through experimental measurements or consulting optical material manuals, and establish a material optical property library.

[0053] Matching lighting parameters to materials: For each 3D spatial sampling point in the 3D lighting model, find the corresponding 2D image pixel and its material category label. Based on the material category, obtain the corresponding material optical properties from the material optical property library.

[0054] Reflection property calculation: This calculation utilizes the core principles of a simplified BRDF calculation model, combining the illumination parameters (incident light direction, spectral distribution) and the material's optical properties at the sampling point. For example, the incident angle is determined based on the incident light direction. The corresponding wavelength range is selected based on the spectral distribution. Parameters such as reflectivity at the corresponding wavelength are searched in the material's optical properties. This comprehensive calculation then calculates the physical reflectance properties of the pixel under the current lighting conditions, such as the intensity and directional distribution of the reflected light.

[0055] S104 , performing tensor decomposition on the five-dimensional tensor of the image according to the physical reflection characteristics of each pixel point of the two-dimensional image, to obtain the illumination influence characteristics and the material characteristics of each pixel point of the two-dimensional image.

[0056] Understandably, the five-dimensional image tensor contains rich yet complex information. Decomposing it into lighting-affecting features and intrinsic material characteristics helps analyze the respective contributions of lighting and material to the appearance of clothing. This allows for a clearer understanding of which parts of the clothing image are due to lighting variations and which are caused by the inherent material properties of the clothing. When detecting clothing defects, this eliminates lighting interference and focuses on the characteristic variations of the material itself, leading to more accurate defect identification. For example, certain lighting conditions may produce shadows or highlights that can be mistakenly identified as defects. Tensor decomposition can separate these lighting-affecting factors.

[0057] Tensor decomposition principle: Tensor decomposition decomposes a high-order tensor into the product of multiple lower-order tensors to extract the underlying structure and features within the tensor. In this context, a suitable tensor decomposition algorithm (such as CANDECOMP / PARAFAC decomposition, or CP decomposition) is used to decompose a five-dimensional tensor (containing image height, width, spectral channels, material category labels, and three-dimensional spatial position) into two tensors: one representing the characteristics of lighting effects and the other representing the characteristics of the material itself. The core idea is to minimize the reconstruction error and find a set of low-dimensional tensors whose product can reconstruct the original five-dimensional tensor as accurately as possible. During the decomposition process, physical reflectance properties are used to guide the decomposition, as physical reflectance properties are related to both lighting and material, and can be used to better separate the effects of lighting and material on the image.

[0058] Optional, initialize tensors: Initialize the low-dimensional tensors used for decomposition based on the dimensions and size of the 5-dimensional tensor. For example, for CP decomposition, initialize multiple factor matrices corresponding to some of the dimensions of the original tensor.

[0059] Iterative optimization: Using physical reflection characteristics as constraints, the factor matrix is continuously updated through an iterative algorithm. In each iteration, the reconstruction tensor is calculated based on the current factor matrix and compared with the original five-dimensional tensor to calculate the reconstruction error. For example, the reconstruction error is measured by calculating indicators such as mean square error. Then, the factor matrix is adjusted based on the error so that the reconstruction error gradually decreases. In this process, the information related to lighting and material in the physical reflection characteristics is used to adjust the factor matrices corresponding to the lighting influence characteristics and the material characteristics themselves. For example, if the physical reflection characteristics of a pixel point show that it is greatly affected by lighting, then when adjusting the factor matrix corresponding to the lighting influence characteristics, more emphasis will be placed on optimizing the part related to the pixel point, and eventually convergence will be obtained to obtain a stable lighting influence feature tensor and material feature tensor.

[0060] S105 , using a machine learning algorithm based on the material characteristics of each pixel point in the two-dimensional image, to determine the defect of the garment fabric to be inspected.

[0061] Understandably, defects in clothing fabrics often cause changes in their material characteristics. For example, holes can alter the material's continuity, while stains can affect its color and texture. By focusing on the inherent characteristics of the fabric itself, analysis can be performed directly on the fabric's inherent properties, eliminating interference from external factors like lighting. This allows for accurate detection of fabric defects, improving both the accuracy and reliability of defect detection.

[0062] Defect feature identification principle: Build a model or database of normal clothing material characteristics. By comparing the material characteristics of the pixels in the garment image to be inspected with those of normal materials, pattern recognition and machine learning methods are used to identify defects. For example, for texture features, texture analysis algorithms (such as gray-level co-occurrence matrix and local binary pattern) can be used to extract texture features of normal materials and areas with potential defects. Defects are determined by comparing the differences in feature vectors. For color features, color space conversion and statistical analysis methods are used to determine whether the material color deviates from the normal range. If there is a significant difference, the area is considered to be defective.

[0063] Optional: Create a normal material feature library: Collect a large number of sample images of normal clothing fabrics of different materials. For each material, use an appropriate feature extraction algorithm to extract its color, texture, structure, and other characteristics, and store them in a normal material feature library. For example, for cotton fabric, extract its typical fiber texture characteristics and common color range.

[0064] Extraction and comparison of features to be detected: From the material feature tensor derived from the five-dimensional image tensor decomposition, material features such as color and texture are extracted for each region or pixel of the garment image to be detected. These features are then compared with those of corresponding materials in a database of normal material features. For example, the Euclidean distance or other similarity metrics are calculated between feature vectors.

[0065] Defect Judgment and Labeling: A suitable threshold is set. When the feature comparison similarity index exceeds the threshold, the area is judged to have a defect and the defective area is labeled. For example, if the Euclidean distance between the texture feature vector of a certain area and the texture feature vector of normal cotton fabric is greater than the set threshold, the area is considered to have defects such as holes or wear and tear. This area is marked on the image, and a defect report is ultimately output for the garment fabric being inspected, including information such as the location, type, and severity of the defect.

[0066] In an exemplary embodiment, constructing a five-dimensional image tensor corresponding to the clothing image to be detected includes: (1a) Based on the multispectral image data of the garment to be inspected, a raw 4D tensor is constructed. The raw 4D tensor includes the image height, width, spectral channel, and the material category label of each 2D image pixel in the garment image to be inspected.

[0067] It's no secret that multispectral image data provides richer spectral information than traditional RGB images, enabling more accurate identification of clothing materials and characteristics. By constructing a raw four-dimensional tensor containing image height, width, spectral channels, and material category labels, this critical information can be integrated, providing the foundational data structure for subsequent analysis. Material category labels are crucial for distinguishing the characteristics of clothing made from different materials. Different materials exhibit differences in spectral reflectance and absorption. Combining spectral channel information allows for more accurate material classification and analysis, aiding in detecting clothing defects.

[0068] How it works: Multispectral image acquisition equipment can capture light information from multiple wavelengths, each corresponding to a spectral channel. By combining image data from these different wavelengths, an image containing rich spectral information can be generated.

[0069] The determination of material category labels is usually based on machine learning algorithms, which use pre-labeled multispectral image datasets to train the classification model so that the model can accurately determine the material category of each pixel based on spectral characteristics.

[0070] Implementation process: Use a multispectral camera to shoot the clothing and obtain multispectral image data, in which each pixel has a corresponding intensity value in different spectral channels.

[0071] The multispectral image data is organized according to the image height and width to form a three-dimensional array, where the third dimension corresponds to different spectral channels.

[0072] Using the trained material classification model, the material category of each pixel in the multispectral image is predicted, and the predicted material category label is added as the fourth dimension information to the above three-dimensional array to construct the original four-dimensional tensor.

[0073] (1b) Normalize the three-dimensional spatial position of the three-dimensional spatial sampling point corresponding to each two-dimensional image pixel point in the clothing image to be detected to obtain a position encoding vector.

[0074] It's understandable that different 3D spatial locations may have different coordinate ranges. Normalization can unify this position information into a standard range, facilitating subsequent processing and analysis. By obtaining the position encoding vector, 3D spatial position information can be represented in a computable and comparable form, providing a foundation for incorporating position information into the 5D tensor and considering the impact of position on lighting and other features.

[0075] Implementation Principle: Normalization is a common data preprocessing method, typically mapping data to a specific interval, such as [0, 1] or [-1, 1], through a linear transformation. In the case of three-dimensional spatial location, normalization can be performed on each dimension (x, y, z) separately to ensure that all location information is on the same scale.

[0076] Implementation process: For each 2D image pixel, determine the coordinates (x, y, z) of its corresponding 3D space sampling point.

[0077] Calculate the minimum and maximum values of each dimension separately, for example, x_min, x_max, y_min, y_max, z_min, z_max.

[0078] Normalize each dimension. For example, for the x dimension, the new normalized coordinate x' = (x - x_min) / (x_max - x_min). Calculate y' and z' similarly.

[0079] Combine the normalized coordinates (x', y', z') into a position encoding vector.

[0080] (1c) Embed the position encoding vector as the fifth dimension into the original four-dimensional tensor to construct the initial five-dimensional tensor.

[0081] It's understandable that embedding 3D spatial position information as an independent dimension into the original 4D tensor explicitly represents the spatial position of each pixel within the tensor structure. This is crucial for subsequent analysis of the effects of lighting at different spatial locations and for considering the influence of spatial position on clothing material characteristics. This allows the 5D tensor to more comprehensively describe the information in the clothing image being inspected.

[0082] Implementation Principle: A tensor is a multidimensional array structure. By adding a dimension to the original four-dimensional tensor and filling this new dimension with the position encoding vector, a five-dimensional tensor containing position information can be constructed. This way, each pixel has a corresponding position in the five-dimensional tensor, and this position information can be processed and analyzed through tensor operations.

[0083] Implementation process: Determines the shape of the original 4D tensor, e.g. (height, width, number of spectral channels, number of material categories).

[0084] Create a new tensor with shape (height, width, number of spectral channels, number of material categories, 3), where the last dimension has size 3 and is used to store the position encoding vector.

[0085] Traverse each pixel point in the original four-dimensional tensor and fill its corresponding position encoding vector into the corresponding position of the new tensor to construct the initial five-dimensional tensor.

[0086] (1d) A position-sensitive attention mechanism is used to determine the illumination-related weight matrix of the clothing image to be detected.

[0087] The illumination correlation weight matrix includes the illumination correlation weight values between any two 2D image pixels in the clothing image to be detected. The illumination correlation weight values are positively correlated with the spatial position distance, spectral similarity, and material category relevance of the 2D image pixels.

[0088] It's understandable that the lighting correlation between different pixels in clothing images is crucial for understanding the overall lighting conditions and analyzing the clothing's appearance. The position-sensitive attention mechanism can determine the lighting correlation weight between any two pixels based on their spatial distance, spectral similarity, and material category relevance. This highlights pairs of pixels with strong lighting correlations, providing more targeted weight information for subsequent fusion operations and helping to more accurately analyze the impact of lighting on clothing.

[0089] Implementation Principle: The Position-Sensitive Attention (PSA) mechanism builds on the concept of attention and determines weights by calculating the similarity between pixels. In this context, the similarity calculation takes into account spatial distance (closer pixels typically have stronger lighting correlation), spectral similarity (pixels with similar spectral characteristics may have more similar light reflections), and material category correlation (pixels of the same material may have more consistent lighting responses). By integrating these factors, a weight matrix is derived that reflects the degree of lighting correlation between pixels.

[0090] Implementation process: Traverse all pixel pairs in the clothing image to be detected, for each pair of pixels (i, j).

[0091] Calculate the distance between their spatial positions, for example using the Euclidean distance formula.

[0092] Compare their spectral features, e.g., compute difference metrics across spectral channels.

[0093] Check whether their material categories are the same or similar, for example using a similarity metric of material category labels.

[0094] Based on the above three factors, the illumination correlation weight value between the pixel pair (i, j) is comprehensively calculated, and the measurement results of these factors can be combined using weighted summation or other methods.

[0095] The calculated weight values are filled into the corresponding positions of the illumination-related weight matrix. After traversing all pixel pairs, the complete illumination-related weight matrix is obtained.

[0096] (1e) The illumination correlation weight matrix is fused with the initial five-dimensional tensor to obtain the five-dimensional image tensor corresponding to the clothing image to be detected.

[0097] It can be understood that by fusing the illumination-related weight matrix with the initial five-dimensional tensor, the illumination-related information between pixels can be incorporated into the five-dimensional tensor. This five-dimensional tensor not only contains basic image information (height, width, spectral channel, material category label, and spatial position), but also considers the illumination-related relationships between pixels. This helps to more accurately account for the impact of illumination on clothing appearance in subsequent analysis, and improves the accuracy and reliability of the machine learning-based automatic detection method and system for military clothing production defects.

[0098] Implementation Principle: Fusion operations can be implemented in a variety of ways, such as matrix multiplication or weighted summation. The core idea is to adjust the pixel information in the initial five-dimensional tensor according to the weight values in the illumination-related weight matrix, so that pixels with strong illumination correlation are more prominently represented in the tensor, thereby enhancing the tensor's ability to express illumination-related information.

[0099] Implementation process: Determines the shape of the lighting-related weight matrix and the initial 5D tensor.

[0100] Based on the fusion method (e.g., matrix multiplication), the illumination-related weight matrix and the initial five-dimensional tensor are operated. For example, if matrix multiplication is used, the illumination-related weight matrix can be multiplied by the appropriate dimension of the initial five-dimensional tensor so that the weight value can act on the pixel information.

[0101] The calculation results are sorted and adjusted to obtain the final five-dimensional image tensor corresponding to the clothing image to be detected. This tensor contains rich image information and the illumination correlation relationship between pixels.

[0102] In an exemplary embodiment, the illumination correlation weight matrix is fused with the initial five-dimensional tensor to obtain a five-dimensional image tensor corresponding to the clothing image to be detected, including: (2a) The illumination-related weight matrix is fused with the initial five-dimensional tensor to obtain a fused five-dimensional vector.

[0103] It can be understood that the fusion of the illumination correlation weight matrix and the initial five-dimensional tensor aims to integrate the illumination correlation information between pixels into the tensor, providing a more comprehensive data basis for subsequent analysis of the illumination characteristics and material characteristics of the image.

[0104] Implementation principle: Through some means (such as matrix multiplication or other fusion operations), the relationship information between pixels contained in the illumination association weight matrix is combined with the position, spectrum, material and other information of the pixels in the initial five-dimensional tensor, so that the fused vector can comprehensively reflect the various characteristics of the image.

[0105] Implementation: Depending on the specific fusion algorithm, the lighting-related weight matrix and the elements of the initial five-dimensional tensor may be traversed, and calculations and combinations may be performed according to certain rules. For example, in the case of matrix multiplication, the rows of the weight matrix are multiplied and added with the corresponding dimensions of the tensor to generate a fused five-dimensional vector.

[0106] (2b) Light is randomly emitted onto the surface of the garment to be inspected. A Monte Carlo path tracing algorithm is used to simulate the multiple reflection paths of light on the surface of the garment to determine the indirect illumination component of each pixel in the two-dimensional image. The indirect illumination component includes the intensity, direction, and spectral distribution of the indirect illumination.

[0107] It is understandable that simulating the multiple reflection paths of light on the fabric surface is to more accurately calculate the indirect lighting component of each pixel. Because multiple reflections of light in actual scenes have a significant impact on the lighting effect of the object surface, considering indirect lighting can make the lighting model more realistic and help to analyze the image more accurately later.

[0108] Principle: The Monte Carlo path tracing algorithm randomly emits light onto the surface of a fabric and simulates its propagation and reflection in the scene. Using probabilistic statistics, it estimates the indirect lighting effect produced by light at each pixel. This algorithm is based on the physical principles of light propagation and takes into account the interaction between light and the surface of the object.

[0109] Implementation process: Randomly select emission points on the cloth surface, determine the initial direction of the light according to a certain probability distribution, then let the light propagate in the scene. When encountering the cloth surface, it performs reflection, refraction and other operations according to the material properties. The contribution of the light on each pixel is recorded. Through a large amount of light sampling and statistics, the indirect lighting component of each 2D image pixel is obtained.

[0110] (2c) The indirect illumination component and the direct illumination component of each two-dimensional image pixel are combined to form the global illumination component of each two-dimensional image pixel.

[0111] It can be understood that combining direct and indirect illumination components can obtain a more comprehensive and accurate global illumination component, thereby more realistically reflecting the actual illumination conditions of each pixel in the image and providing more accurate illumination information for subsequent image analysis and processing.

[0112] How it works: Direct illumination is the lighting effect produced by a light source directly hitting a pixel, while indirect illumination is the lighting effect produced by light reaching the pixel after multiple reflections. Together, these two components constitute the actual illumination of the pixel. By rationally combining them in terms of intensity, direction, and spectral distribution, we can obtain the global illumination component.

[0113] Implementation: Direct and indirect lighting parameters are combined according to specific rules. For example, the intensity values of the two can be added together or weighted according to a certain weight. The direction may require operations such as vector synthesis. The spectral distribution also needs to be integrated based on the spectral information of the two.

[0114] (2d) Identify dark areas in the image to be detected based on the global illumination component of each two-dimensional image pixel.

[0115] It is understandable that identifying dark areas in an image helps to understand the illumination distribution of the image, which is of great significance for subsequent analysis of fabric defects, etc., because the dark areas may hide some information that is not easily perceived under normal lighting, or the dark areas themselves may be related to fabric defects.

[0116] Implementation principle: By comparing the intensity of the global illumination component of each pixel with the set intensity threshold, it is determined which pixels belong to the dark area. If the illumination intensity of the pixel is less than the threshold, it is classified as part of the dark area.

[0117] Implementation process: traverse all pixels in the image, obtain the intensity value of the global illumination component of each pixel, compare it with the intensity threshold, and if it is less than the threshold, mark the pixel as a dark area pixel, and finally obtain a set of dark area pixels.

[0118] (2e) Generate a compensation weight matrix based on the illumination sensitivity corresponding to the material category label of each 2D image pixel in the dark area. The illumination intensity of the dark area is less than the intensity threshold.

[0119] It is understandable that different materials have different sensitivities to light. Generating a compensation weight matrix can perform targeted light compensation on dark area pixels of different materials based on the material category labels of the pixels in the dark area, so as to more accurately process the image and highlight the characteristics of different materials under light, which is conducive to the subsequent accurate judgment of fabric defects.

[0120] How it works: The light sensitivity of each material is determined based on the material category label. Then, based on the material of each pixel in the dark area, a compensation weight is assigned to each pixel to form a compensation weight matrix. Materials with high light sensitivity may require a larger compensation weight in dark areas to highlight their details.

[0121] Implementation process: First, establish the correspondence between material category and light sensitivity, then traverse the pixels in the dark area, obtain the light sensitivity value from the correspondence according to its material category label, and form these values into a compensation weight matrix. The elements of the matrix correspond to the compensation weight of each pixel in the dark area.

[0122] (2f) Multiply the indirect illumination component of each two-dimensional image pixel by the compensation weight matrix to generate an indirect illumination compensation term for each two-dimensional image pixel.

[0123] It can be understood that the purpose of generating indirect lighting compensation items is to adjust the indirect lighting of each pixel in the dark area so that it can better reflect the actual situation. By multiplying it with the compensation weight matrix, the indirect lighting can be reasonably enhanced or adjusted according to the lighting sensitivity of the material.

[0124] Implementation principle: The indirect lighting components are weighted using the compensation weight matrix, so that the indirect lighting of pixels with high lighting sensitivity is compensated to a greater extent, while pixels with low sensitivity receive correspondingly smaller compensation, thereby adjusting the lighting effects of pixels of different materials in dark areas.

[0125] Implementation process: Multiply the indirect lighting component of each pixel in the dark area with the corresponding element in the compensation weight matrix to obtain the indirect lighting compensation item of each pixel to adjust the indirect lighting.

[0126] (2g) According to the indirect illumination compensation term of each two-dimensional image pixel, the fused five-dimensional vector is compensated to obtain the five-dimensional image tensor corresponding to the clothing image to be detected.

[0127] It can be understood that compensating the fused five-dimensional vector according to the indirect lighting compensation term can further optimize the five-dimensional image tensor, making it more accurately reflect the characteristics of each pixel in the image in terms of lighting and material, and provide more accurate data for subsequent fabric defect analysis based on the five-dimensional image tensor.

[0128] Implementation principle: Integrate the indirect lighting compensation term into the fused five-dimensional vector. By adjusting the corresponding dimensions of the fused five-dimensional vector, the compensation information is integrated into the tensor, so that the tensor can more comprehensively and accurately describe the lighting and material characteristics of the image.

[0129] Implementation process: According to the indirect lighting compensation term, the corresponding dimensions of the fused five-dimensional vector are added or other appropriate operations are performed, the compensation information is added to the fused five-dimensional vector, and the final image five-dimensional tensor is generated to complete further processing and optimization of the image data.

[0130] In an exemplary embodiment, a position-sensitive attention mechanism is used to determine an illumination-related weight matrix of a clothing image to be detected, including: (3a) Obtain the three-dimensional spatial coordinates, multispectral features, and material category features of each pixel in the clothing image to be detected.

[0131] Understandably, determining the illumination-related weight matrix for the garment image under inspection requires a comprehensive understanding of the various attributes of each pixel in the image. Three-dimensional spatial coordinates measure the spatial relationship between pixels, multispectral features reflect the spectral characteristics of pixels at different wavelengths, and material category features reflect the material differences at the pixel's location. This information is crucial for accurately calculating the illumination-related weights between pixels, as illumination behaves and interacts differently at different spatial locations, with different spectral characteristics, and on different materials.

[0132] Implementation principle: 3D coordinates: These are typically obtained through camera calibration and multi-view geometry. Camera calibration determines the camera's intrinsic parameters (such as focal length and principal point position) and extrinsic parameters (rotation and translation matrices). By matching features between multi-view images, the coordinates of each pixel in 3D space are calculated based on triangulation principles.

[0133] Multispectral features: These are acquired by a multispectral camera, which senses and records light in different wavelengths. Each pixel has corresponding intensity values across multiple spectral channels, which together form the multispectral features of that pixel.

[0134] Material category feature: Based on a pre-trained material classification model, the pixels in the image are input into the model, and the model outputs the material category label corresponding to the pixel as the material category feature.

[0135] Implementation process: Acquisition of 3D spatial coordinates: Use a camera to capture images of clothing from multiple angles, perform feature extraction (such as SIFT, SURF, and other algorithms) and matching on these images, and combine them with camera calibration parameters to calculate the 3D spatial coordinates of each pixel using a 3D reconstruction algorithm (such as a stereo vision algorithm).

[0136] Multispectral feature acquisition: Use a multispectral camera to shoot clothing images, and directly extract the intensity value of each pixel in different spectral channels from the image data obtained by the camera to form a multispectral feature vector.

[0137] Material category feature acquisition: Multispectral images or other related image data are input into a trained material classification model (such as a convolutional neural network). The model outputs the material category label for each pixel to complete the acquisition of material category features.

[0138] (3b) Use a learnable Gaussian kernel function to calculate the spatial distance weight between any two pixels.

[0139] It's understandable that spatial distance is a significant factor influencing illumination correlation between pixels. Generally, pixels that are closer together have stronger illumination correlation because they are likely affected by similar lighting conditions. Using a learnable Gaussian kernel function, we can adaptively calculate weights based on the spatial distance between pixels. The closer the distance, the greater the weight, thus highlighting the impact of spatial distance on illumination correlation.

[0140] Implementation Principle: The Gaussian kernel function is a commonly used kernel function. Its core concept is to calculate a weight based on the spatial distance between pixels, with smaller distances giving larger weights. The learnable Gaussian kernel function, based on the traditional Gaussian kernel function, optimizes the weight calculation by learning parameters to better reflect actual lighting correlations. For example, by learning the appropriate kernel width parameter from training data, the calculated spatial distance weight more accurately reflects the degree of lighting correlation between pixels.

[0141] Implementation process: For any two pixel points, get their three-dimensional space coordinates.

[0142] Compute the Euclidean distance (or other suitable distance metric) between the two pixels.

[0143] The distance value is substituted into a learnable Gaussian kernel function, and the learned parameters are used to calculate the spatial distance weight between the two pixels. During the training phase, the kernel function parameters are adjusted through optimization algorithms (such as gradient descent) to make the calculated weight more consistent with the actual lighting correlation.

[0144] (3c) Spectral feature dot product is used to calculate the spectral similarity weight of any two pixels.

[0145] It's understandable that spectral signatures reflect the reflection or absorption characteristics of pixels for light of different wavelengths, and illumination is closely related to the spectrum. The more similar the spectral signatures of two pixels are, the more similar their illumination behavior is likely to be. Therefore, calculating a spectral similarity weight helps measure the degree of illumination correlation between pixels. The dot product operation quantifies the similarity between two spectral signature vectors, yielding a spectral similarity weight.

[0146] Implementation Principle: The dot product is a common vector operation that measures the similarity between two vectors. For the spectral feature vectors of two pixels, the dot product is calculated. A larger result indicates greater similarity between the two vectors. In other words, the more similar the spectral features of the two pixels are, the greater the corresponding spectral similarity weight. This simple and effective method can quickly calculate the spectral similarity weight, providing an important basis for determining the illumination correlation weight.

[0147] Implementation process: Get the multispectral feature vector of any two pixels.

[0148] Perform a dot product operation on these two multispectral feature vectors.

[0149] The dot product result is used as the spectral similarity weight of the two pixels. The larger the dot product result, the greater the weight, which means that the spectral characteristics of the two pixels are more similar.

[0150] (3d) The projected similarity of the material category embedding vector is used to calculate the material correlation weight of any two pixels.

[0151] It's understandable that different materials have different properties for reflection, absorption, and scattering of light. Therefore, material category is a significant factor influencing the correlation between light sources. By calculating the material correlation weight, we can measure the degree of light correlation between different pixels due to material differences. Using the projected similarity of the material category embedding vectors, we can transform this discrete information into a continuous vector representation. The material correlation weight is then determined by calculating the similarity between these vectors.

[0152] Implementation Principle: First, each material category is mapped to an embedding vector, which represents the characteristics of the material category in vector space. Then, for any two pixels, their corresponding material category embedding vectors are obtained. By calculating the similarity of these two vectors in a certain projection direction (such as cosine similarity), their material correlation weight is obtained. The higher the similarity, the more similar the materials of the two pixels are, and the stronger their lighting correlation is likely to be.

[0153] Implementation process: An embedding vector is pre-defined for each material category, and these embedding vectors can be optimized through training (e.g., learned during the training process of the material classification model).

[0154] For any two pixels, get their material category labels and find the corresponding material category embedding vector based on the labels.

[0155] Calculate the projection similarity (such as cosine similarity) of the two material category embedding vectors, and use the similarity result as the material relevance weight of the two pixels. The higher the similarity, the greater the weight.

[0156] (3e) The spatial distance weight, spectral similarity weight and material correlation weight are fused at the element level to generate the initial association weight of any two pixels.

[0157] It is understandable that the individual spatial distance weight, spectral similarity weight, and material correlation weight can only reflect the degree of illumination correlation between pixels from one aspect. By fusing them at the element level, we can comprehensively consider the impact of these three factors on illumination correlation and obtain a more comprehensive and accurate initial correlation weight, thereby more realistically describing the illumination relationship between pixels.

[0158] Implementation Principle: Element-level fusion involves performing some operation (such as addition or weighted addition) on the corresponding elements of the three weight values (spatial distance weight, spectral similarity weight, and material correlation weight) to obtain a new weight value that combines the influence of these three factors. This method integrates information from different aspects, allowing the initial correlation weight to more accurately reflect the comprehensive degree of correlation between pixels in terms of lighting.

[0159] Implementation process: For any two pixels, obtain their spatial distance weight, spectral similarity weight, and material correlation weight.

[0160] The three weights are element-wise operated by addition or weighted addition. For example, different weight coefficients can be set to perform weighted addition on the spatial distance weight, spectral similarity weight, and material correlation weight to obtain the initial association weight of the two pixels.

[0161] (3f) Normalize the initial association weights of any two pixels to obtain the illumination association weight values of any two pixels.

[0162] It's understandable that normalizing the initial correlation weights is to map them to a uniform range (e.g., [0, 1]) for ease of subsequent calculations and comparisons. Normalized weights more intuitively represent the degree of illumination correlation between pixels and ensure data consistency and comparability when fused or computed with other data.

[0163] Implementation Principle: Normalization is a common data preprocessing method that maps data to a specified range through linear transformation. For the initial association weights, min-max normalization or another suitable normalization method can be used to adjust the weights based on their relative magnitude among all weights, so that they fall within the [0, 1] interval. This ensures that the illumination association weights between each pixel pair are on the same scale, facilitating subsequent analysis and processing.

[0164] Implementation process: Find the minimum and maximum values of the initial association weights for all pixel pairs.

[0165] For each pixel pair's initial association weight, a normalization formula (such as the minimum-maximum normalization formula) is used to calculate it and map it to the interval [0, 1] to obtain the illumination association weight value for that pixel pair. By traversing all pixel pairs, the entire illumination association weight matrix is normalized.

[0166] In an exemplary embodiment, for any three-dimensional spatial sampling point in a three-dimensional illumination model and the two-dimensional image pixel corresponding to the three-dimensional spatial sampling point in the garment image to be detected, the physical reflection characteristics of each two-dimensional image pixel are determined based on the illumination parameters corresponding to each three-dimensional spatial sampling point in the three-dimensional illumination model and the material category label of each two-dimensional image pixel corresponding to each three-dimensional spatial sampling point, including: (4a) The corresponding two-dimensional image pixel point of the three-dimensional space sampling point in the clothing image to be detected is used as the target two-dimensional pixel point.

[0167] Understandably, to accurately determine the physical reflectance properties of each 2D image pixel, it's necessary to identify the specific research object. By mapping 3D spatial sampling points to 2D image pixels, the information in the 3D illumination model can be accurately mapped onto the 2D image, enabling subsequent reflectance analysis of each specific pixel. This establishes a connection between 3D space and 2D images, making the analysis of illumination and material interactions more precise and targeted.

[0168] Implementation Principle: Based on the principle of camera imaging, points in 3D space are mapped onto a 2D image plane through camera projection transformation. When establishing the 3D illumination model and acquiring the garment image to be inspected, the correspondence between the two is determined (for example, through camera calibration). Therefore, based on this correspondence, the corresponding pixel in the 2D image can be found for the 3D sampling point.

[0169] Implementation process: First, the projection transformation relationship from three-dimensional space to two-dimensional image plane is established using the intrinsic parameters (such as focal length, principal point position, etc.) and extrinsic parameters (rotation matrix, translation vector, etc.) obtained by camera calibration.

[0170] For each 3D spatial sampling point in the 3D illumination model, the corresponding 2D coordinates in the clothing image to be detected are calculated based on its 3D coordinates through the above-mentioned projection transformation relationship, thereby determining the corresponding 2D image pixel point and using it as the target 2D pixel point.

[0171] (4b) Based on the pre-built material reflection database, the basic diffuse reflection features and basic specular reflection response features corresponding to the material category label of the target two-dimensional pixel point are extracted.

[0172] As you can understand, different materials have different reflective properties. The pre-built material reflectance database contains basic reflective feature information for a variety of common materials. By extracting the basic diffuse and specular response characteristics corresponding to the material category label of the target 2D pixel, we provide foundational data for adjusting reflective properties based on specific lighting conditions. This allows us to leverage existing material knowledge to quickly and accurately obtain a material's basic reflective properties, improving computational efficiency and accuracy.

[0173] Implementation Principle: A material reflectance database is built through experimental measurements, theoretical calculations, or data collection. It stores the correspondence between different material categories and their basic reflectance characteristics. Once the material category label of a target 2D pixel is obtained, the corresponding basic diffuse reflectance characteristics (such as diffuse reflectance coefficient and diffuse color) and basic specular reflectance response characteristics (such as specular reflectance coefficient and specular direction) are searched in the database.

[0174] Implementation process: A material reflection database is established to collect basic reflection feature data of various common clothing materials, and classify and store them according to material category labels.

[0175] After the target two-dimensional pixel point is determined, its material category label is obtained.

[0176] In the material reflection database, the material category label is used as an index to find and extract the corresponding basic diffuse reflection features and basic specular reflection response features.

[0177] (4c) Generate the diffuse reflectance modulation factor and the specular reflectance dynamic adjustment coefficient of the target pixel point based on the illumination parameters corresponding to the three-dimensional spatial sampling point and the basic diffuse reflectance characteristics and specular reflectance response characteristics of the target two-dimensional pixel point.

[0178] It's understandable that lighting conditions significantly affect a material's reflective properties. By generating a diffuse reflectance modulation factor and a dynamic specular reflectance adjustment coefficient based on specific lighting parameters (such as incident light direction and spectral distribution) and the material's basic reflective characteristics, we can reflect how the material's diffuse and specular reflectance properties change under current lighting conditions. This helps to more accurately simulate the interaction between light and materials, making the calculated physical reflectance properties more consistent with reality.

[0179] Implementation Principle: Based on optical theory, lighting parameters influence the reflective behavior of a material surface. For example, the direction of incident light affects the angle of incidence between the light and the material surface, thereby affecting the intensity of diffuse and specular reflections. Spectral distribution also affects the reflectivity of light of different wavelengths. By establishing a suitable mathematical model (possibly based on simplified physical optics formulas or machine learning models), the diffuse reflectivity modulation factor and the dynamic adjustment coefficient of specular reflectivity are calculated based on the lighting parameters and basic reflectivity characteristics to quantify the impact of lighting on reflective properties.

[0180] Implementation process: Analyze and process the illumination parameters (incident light direction, spectral distribution, etc.) corresponding to the three-dimensional space sampling points.

[0181] Combining the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel, a pre-designed algorithm or model (such as a computational model based on physical optics or a mapping relationship obtained through machine learning training) is used to calculate the diffuse reflectance modulation factor and the dynamic adjustment coefficient of the specular reflectance. For example, based on the direction of the incident light and the diffuse reflection characteristics of the material, the modulation factor of the diffuse reflectance as it changes with the incident angle is calculated; based on the spectral distribution and specular reflection characteristics, the dynamic adjustment coefficient of the specular reflectance at different wavelengths is calculated.

[0182] (4d) According to the degree of three-dimensional geometric deformation of the cloth surface in the image area where the target two-dimensional pixel is located, the diffuse reflectance modulation factor of the target two-dimensional pixel is smoothly constrained to obtain the optimized diffuse reflectance modulation factor.

[0183] It's understandable that the three-dimensional geometric deformation of a fabric surface affects the reflection path and intensity of light, and thus the diffuse reflectance. Applying a smoothing constraint to the diffuse reflectance modulation factor ensures that the calculated diffuse reflectance more closely matches the actual fabric surface conditions, avoiding inaccurate results caused by sudden changes in reflectance due to geometric deformation. By smoothing the surface with consideration of geometric deformation, the accuracy and stability of the calculated physical reflectance properties can be improved.

[0184] Principle: According to the principles of geometric optics, when a fabric surface deforms, the incident and reflection angles of light change, affecting the diffuse reflectance. By analyzing the degree of 3D geometric deformation of the fabric surface in the image region where the target 2D pixel resides (such as surface curvature acquired through 3D reconstruction techniques), a smoothing algorithm (such as Gaussian smoothing or mean smoothing) is used to adjust the diffuse reflectance modulation factor. This results in a smoother change between adjacent pixels, reflecting the actual reflectance characteristics of the fabric surface.

[0185] Implementation process: Use 3D reconstruction technology (such as stereo vision, structured light, etc.) to obtain the 3D geometric information of the fabric surface in the image area where the target 2D pixel is located, and calculate the degree of geometric deformation of the area (such as surface curvature, slope and other parameters).

[0186] Based on the degree of geometric deformation, an appropriate smoothing algorithm (such as Gaussian smoothing) is selected to process the diffuse reflectance modulation factor. For example, the parameters of the smoothing algorithm (such as the size of the Gaussian kernel) are adjusted based on the degree of geometric deformation to smooth the diffuse reflectance modulation factor and obtain an optimized diffuse reflectance modulation factor.

[0187] (4e) According to the optimized diffuse reflectance modulation factor, the basic diffuse reflectance feature of the target two-dimensional pixel is adjusted to obtain the current diffuse reflectance feature of the target two-dimensional pixel.

[0188] As you can understand, the optimized diffuse reflectance modulation factor reflects the change in diffuse reflectance after accounting for lighting conditions and geometric deformation of the fabric surface. By applying this factor to the base diffuse reflectance characteristics of the target 2D pixel, we can obtain the diffuse reflectance characteristics of the current actual situation. This allows the calculated diffuse reflectance characteristics to more accurately reflect the interaction between light and material in the current scene, providing more reliable diffuse reflectance information for subsequent image analysis.

[0189] Implementation Principle: Based on the fundamental principles of diffuse reflection, changes in diffuse reflectivity directly affect the intensity, color, and other characteristics of diffuse light. By performing operations (e.g., multiplication) on the optimized diffuse reflectivity modulation factor and the basic diffuse reflection characteristics (such as the diffuse reflectance coefficient and diffuse color), the basic diffuse reflection characteristics can be adjusted to obtain the current actual diffuse reflection characteristics.

[0190] Implementation process: Obtain the basic diffuse reflection characteristics (such as diffuse reflection coefficient vector, diffuse reflection color vector, etc.) of the target two-dimensional pixel point and the optimized diffuse reflection rate modulation factor.

[0191] Perform corresponding adjustments to the base diffuse reflection feature. For example, if the base diffuse reflection feature is a diffuse reflection coefficient vector, multiply it element-wise with the optimized diffuse reflection rate modulation factor to obtain the adjusted diffuse reflection coefficient vector, thereby obtaining the current diffuse reflection feature of the target two-dimensional pixel.

[0192] (4f) According to the dynamic adjustment coefficient of the mirror reflectivity, the basic mirror reflection response characteristics are adjusted to obtain the current mirror reflection characteristics of the target two-dimensional pixel point.

[0193] It's understandable that the dynamic specular reflectance adjustment coefficient reflects the impact of lighting conditions on specular properties. By applying it to the basic specular response characteristics, we can determine the actual specular characteristics under current lighting conditions, making the calculated specular characteristics more realistic. This is crucial for accurately simulating specular reflection effects on clothing surfaces and for subsequent analysis of highlights, reflections, and other phenomena in clothing images.

[0194] Implementation Principle: Based on the physical principles of specular reflection, lighting conditions (such as incident light direction and spectral distribution) affect specular reflection characteristics such as intensity, direction, and color. By performing operations (such as multiplication or vector transformation) on the dynamic specular reflectivity adjustment coefficient and basic specular reflection response characteristics (such as specular reflection coefficient and specular reflection direction), the basic specular reflection response characteristics can be adjusted to obtain the current actual specular reflection characteristics.

[0195] Implementation process: Obtain the basic specular reflection response characteristics (such as specular reflection coefficient, specular reflection direction vector, etc.) and the dynamic adjustment coefficient of specular reflectivity of the target two-dimensional pixel point.

[0196] Perform corresponding adjustments to the basic specular reflection response characteristics. For example, if the basic specular reflection characteristic is the specular reflection coefficient, multiply it by the specular reflectivity dynamic adjustment coefficient to obtain the adjusted specular reflection coefficient. If it is the specular reflection direction vector, perform the corresponding vector transformation based on the dynamic adjustment coefficient to obtain the adjusted specular reflection direction vector, thereby obtaining the current specular reflection characteristic of the target 2D pixel.

[0197] In an exemplary embodiment, the physical reflectance property includes a current diffuse reflectance characteristic, and the base diffuse reflectance characteristic includes a base diffuse reflectance.

[0198] Accordingly, based on the illumination parameters corresponding to the three-dimensional spatial sampling points and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel points, the diffuse reflectance modulation factor and the specular reflectance dynamic adjustment coefficient of the target pixel points are generated, including: (5a) Determine the first angle cosine value of the first angle between the incident light direction in the illumination parameters corresponding to the three-dimensional space sampling point and the surface normal of the surface where the target pixel point is located.

[0199] It's understandable that the angle between the incident light direction and the surface normal of the target pixel's surface has a significant impact on diffuse reflection properties. Based on the principles of light reflection, this angle determines the angle of incidence of the light on the surface, which in turn affects the intensity of diffuse reflection. By calculating the cosine of this angle, we can quantify the extent of this influence, providing a key parameter for subsequently generating the diffuse reflectance modulation factor. This allows us to more accurately simulate the interaction between light and the material surface and determine the physical reflectance characteristics of the target pixel.

[0200] Implementation Principle: Based on the principles of geometric optics, the incident angle of light is closely related to its reflection characteristics. In three-dimensional space, given the incident light direction vector and the surface normal vector of the target pixel, vector operations (such as the dot product) can be used to calculate the cosine of the angle between these two vectors. The result of the dot product operation is proportional to the cosine of the angle between the two vectors. Normalization can be performed to obtain the accurate cosine of the angle.

[0201] Implementation process: First, the incident light direction vector in the illumination parameters corresponding to the three-dimensional space sampling point is obtained. This vector represents the propagation direction of the light.

[0202] Then, the surface normal vector of the surface where the target pixel point is located is determined. This can be obtained by analyzing the geometric shape of the area where the target pixel point is located. For example, in a three-dimensional model, it can be obtained based on the normal vector information of the surface where the point is located.

[0203] Next, a dot product operation is performed on the incident light direction vector and the surface normal vector. The result of the dot product is divided by the product of the module lengths of the two vectors to obtain the cosine value of the angle between the two vectors, that is, the first angle cosine value.

[0204] (5b) According to the spectral distribution of the illumination parameters corresponding to the sampling points in the three-dimensional space, the basic specular reflectance is spectrally weighted to obtain the weighted specular reflectance.

[0205] It's understandable that light of different wavelengths may have different specular reflectances on a material's surface, and the spectral distribution of the illumination determines the relative intensities of light of different wavelengths. By spectrally weighting the base specular reflectance, we can account for the influence of the illumination spectrum on specular reflection and more accurately reflect the specular reflectance characteristics under actual lighting conditions. The resulting weighted specular reflectance comprehensively considers the illumination's spectral information, providing more precise parameters for the subsequent calculation of the diffuse reflectance modulation factor.

[0206] Implementation Principle: Based on the spectral distribution, a weighted calculation is performed on the intensity of light at different wavelengths and the base specular reflectance value at the corresponding wavelength. Typically, the spectral distribution can be expressed as an intensity distribution function of light at different wavelengths. By multiplying this function with the base specular reflectance value at each wavelength and summing (integrating) the results, a weighted specular reflectance is obtained. This weighted calculation adjusts the specular reflectance based on the spectral composition of the illumination, making it more consistent with actual conditions.

[0207] Implementation process: Obtain the spectral distribution information of the illumination parameters corresponding to the sampling points in the three-dimensional space, which can be a function or data table representing the intensity of light at different wavelengths.

[0208] Determine the base specular reflectance values of the target pixel at each wavelength. These values can be obtained from a pre-built material reflectance database.

[0209] For each wavelength in the spectral distribution, the light intensity at that wavelength is multiplied by the value of the base specular reflectance at that wavelength.

[0210] The product results of all wavelengths are added together (integration may be required if the spectrum is continuous) to obtain the weighted specular reflectance.

[0211] (5c) The product of the cosine value of the angle and the weighted specular reflectance is used as the diffuse reflectance modulation factor of the target pixel.

[0212] It can be understood that the diffuse reflectance modulation factor is used to adjust the basic diffuse reflection characteristics of the target pixel to reflect the actual diffuse reflection conditions under the current lighting conditions. By combining the previously calculated angle cosine value related to the incident angle and the weighted specular reflectance that takes into account the spectral distribution, the effects of the lighting direction and spectral composition on diffuse reflection can be comprehensively considered by multiplying them. This product operation can integrate the effects of the incident angle and spectral characteristics of light on diffuse reflection, generating a modulation factor that can accurately adjust the diffuse reflectance, thereby obtaining a diffuse reflection characteristic of the target pixel that is more consistent with the actual situation.

[0213] Principle: During the interaction between light and a material's surface, the angle of incidence influences the intensity of diffuse reflection, while the spectral distribution influences the overall reflective properties by weighting the specular reflectance. Multiplying the cosine of the angle and the weighted specular reflectance is based on their combined influence on diffuse reflectance. The cosine of the angle reflects the degree of influence of the angle of incidence on diffuse reflectance, while the weighted specular reflectance reflects the influence of the spectral characteristics on reflection. The product of the two more comprehensively reflects the modulation of diffuse reflectance by lighting conditions.

[0214] Implementation process: Get the cosine value of the first angle and the weighted specular reflectivity calculated previously.

[0215] The cosine of the first angle is multiplied by the weighted specular reflectivity.

[0216] The calculation result is used as the diffuse reflectance modulation factor of the target pixel point for subsequent adjustment of the basic diffuse reflection characteristics.

[0217] In an exemplary embodiment, the physical reflectance property includes a current specular reflection characteristic. The basic specular reflection response characteristic includes a basic specular reflectivity and a specular reflection index.

[0218] According to the illumination parameters corresponding to the three-dimensional space sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point, the dynamic adjustment coefficient of the specular reflectivity of the target pixel point is generated, including: (6a) Determine the half vector based on the observation direction corresponding to the target pixel point and the incident light direction in the illumination parameters corresponding to the three-dimensional space sampling point.

[0219] It's no secret that the half-vector (the vector bisector of the angle between the incident light and the viewing direction) is a key quantity when calculating specular reflectance. It comprehensively considers information about both the incident light and the viewing direction, making it crucial for accurately describing specular reflection. By determining the half-vector, its relationship with the surface normal can be further analyzed, resulting in parameters related to specular reflection and providing the basis for calculating the dynamic adjustment coefficient for specular reflectance.

[0220] Implementation Principle: Based on the principles of vector arithmetic, two vectors (the incident light direction vector and the observation direction vector) are added and normalized to obtain a half-vector. Normalization ensures that the modulus of the half-vector is 1, facilitating subsequent calculations and analysis. This method for calculating the half-vector is based on the principles of light reflection and observation in geometric optics. The direction of the half-vector reflects a state intermediate between the incident light direction and the observation direction, and is closely related to the properties of specular reflection.

[0221] Implementation process: First, obtain the observation direction vector corresponding to the target pixel point, which represents the direction from the observation point to the target pixel point.

[0222] Next, the incident light direction vector in the illumination parameters corresponding to the three-dimensional space sampling point is obtained.

[0223] Add the viewing direction vector and the incident light direction vector to get a new vector.

[0224] Normalize the new vector by dividing it by the modulus of the vector to obtain a half vector.

[0225] (6b) Determine the cosine value of the second angle between the half vector and the surface normal of the surface where the target pixel point is located.

[0226] It's understandable that the cosine of the angle between the half-vector and the surface normal reflects the intensity and direction of specular reflection. According to the principles of geometric optics, this angle is closely related to the quality of specular reflection. A larger cosine indicates a closer proximity between the half-vector and the surface normal, potentially leading to a more pronounced specular reflection. By calculating the cosine of this angle, we can quantify this relationship, providing a crucial parameter for subsequent calculations of specular reflectivity.

[0227] Implementation Principle: Based on the principle of vector dot product, the dot product of two vectors is equal to the product of their magnitudes multiplied by the cosine of the angle between them. Therefore, by calculating the dot product of the half vector and the surface normal vector and dividing it by the product of their magnitudes, we can find the cosine of the angle between the two vectors. This calculation method is simple and effective, accurately obtaining the required cosine of the angle.

[0228] Implementation process: Get the half vector calculated in step (6a) and the surface normal vector of the surface where the target pixel is located.

[0229] Compute the dot product of the half vector and the surface normal vector.

[0230] Calculate the magnitude of the half vector and the surface normal vector respectively.

[0231] Divide the dot product result by the product of the two vector magnitudes to obtain the second angle cosine of the second angle between the half vector and the surface normal.

[0232] (6c) The specular reflection index is used as the exponent of the cosine value of the second angle to obtain the index calculation result.

[0233] As you can understand, the specular index is an inherent property of a material, describing its specular reflection characteristics. Calculating the specular index as an exponent of the cosine of the second angle further adjusts and quantifies the specular reflection effect. This exponential calculation makes the calculated results more consistent with actual specular reflection phenomena, more accurately reflecting the variations in specular reflection intensity across different materials at different angles.

[0234] Implementation Principle: According to the rules of exponential calculation, applying one number as an exponent to another can change the magnitude and trend of that number. In this scenario, applying the specular exponent to the cosine of the second angle adjusts the angle cosine based on the material's specular properties, resulting in a value related to the specular intensity. This calculation method takes into account the influence of the material's inherent properties on specular reflection.

[0235] Implementation process: Obtain the second angle cosine value calculated in step (6b) and the specular reflection index in the basic specular reflection response feature of the target pixel point.

[0236] The cosine value of the second included angle is used as the base, and the mirror reflection index is used as the exponent to perform an exponential operation to obtain an exponential calculation result.

[0237] (6d) Determine the dynamic adjustment coefficient of the specular reflectivity of the target pixel point based on the index calculation result, the basic specular reflectivity, and the illumination intensity in the illumination parameters corresponding to the three-dimensional space sampling point.

[0238] It's understood that the dynamic specular reflectivity adjustment coefficient is used to adjust the base specular reflectivity based on the current lighting conditions and material properties to obtain the actual specular reflectivity. By comprehensively considering the index calculation results (reflecting the influence of angle and material properties on specular reflection), the base specular reflectivity (the material's inherent specular reflectivity property), and light intensity (a key parameter of lighting conditions), we can more comprehensively consider the impact of various factors on specular reflectivity, making the calculated dynamic specular reflectivity adjustment coefficient more accurately reflect the actual situation.

[0239] Implementation Principle: Based on the principles of light reflection and related mathematical models, the index calculation results, basic specular reflectivity, and light intensity are combined through a specific operation relationship. For example, the index calculation result can be multiplied by the basic specular reflectivity, and then further adjusted based on light intensity (such as multiplying or dividing by a coefficient related to light intensity) to obtain a dynamic specular reflectivity adjustment coefficient. This operation relationship comprehensively considers the impact of material characteristics, angle factors, and lighting conditions on specular reflectivity.

[0240] Implementation process: Obtain the index calculation result calculated in step (6c), the basic specular reflectivity in the basic specular reflection response feature of the target pixel point, and the illumination intensity in the illumination parameters corresponding to the three-dimensional space sampling point.

[0241] According to a pre-designed operation relationship, the index calculation result is operated (such as a multiplication operation) with the basic mirror reflectivity.

[0242] Then, the above calculation result is further adjusted according to the light intensity (such as multiplying or dividing by a coefficient related to the light intensity).

[0243] The final calculation result is used as the dynamic adjustment coefficient of the mirror reflectivity of the target pixel.

[0244] In an exemplary embodiment, based on the degree of three-dimensional geometric deformation of the cloth surface in the image region where the target two-dimensional pixel is located, a smoothing constraint is applied to the diffuse reflectance modulation factor of the target two-dimensional pixel to obtain an optimized diffuse reflectance modulation factor, including: (7a) Construct the three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located.

[0245] It's no secret that the 3D geometric deformation of a fabric surface is a significant factor influencing diffuse reflectance. Constructing a 3D geometric deformation matrix quantifies the shape changes of the fabric surface within the image region of interest, providing the foundational data for smoothing the diffuse reflectance modulation factor. This matrix transforms the geometric information of the fabric surface into a mathematical form, facilitating calculations and processing.

[0246] Implementation principle: 3D reconstruction technology is used to obtain 3D point cloud data of the fabric surface. This data contains the 3D coordinate information of each point on the fabric surface. By analyzing and processing this point cloud data, such as calculating the distance and angle between adjacent points, the degree of deformation of the fabric surface can be assessed. This deformation information is organized into a matrix according to specific rules, resulting in a 3D geometric deformation matrix.

[0247] Implementation process: 3D reconstruction methods (such as structured light, stereo vision, etc.) are used to obtain 3D point cloud data of the cloth surface.

[0248] The three-dimensional point cloud data corresponding to the image area where the target two-dimensional pixel is located is extracted and processed.

[0249] The geometric relationships (such as distance, angle, etc.) between the points in the area are calculated, and matrix elements representing the degree of three-dimensional geometric deformation of the cloth surface are generated based on these relationships.

[0250] Arrange these elements into a matrix in a certain order to obtain a three-dimensional geometric deformation matrix.

[0251] (7b) According to the three-dimensional geometric deformation matrix, the original diffuse reflectance modulation factor matrix formed by the diffuse reflectance modulation factor of each two-dimensional image pixel in the image area is averaged and a smoothed modulation factor matrix is obtained.

[0252] Understandably, the original diffuse reflectance modulation factor matrix may contain local fluctuations and noise, which can lead to inaccurate diffuse reflectance calculations. Neighborhood averaging is a simple and effective smoothing method. By considering the average of the diffuse reflectance modulation factors of each pixel and its neighboring pixels, it can reduce the impact of local fluctuations and noise, making the modulation factor smoother and more consistent with the actual diffuse reflectance of the cloth surface.

[0253] Implementation principle: For each element in the original albedo modulation factor matrix (i.e., the albedo modulation factor for each 2D image pixel), select a neighborhood around it (e.g., a 3x3, 5x5, etc. window). Calculate the average of all elements within this neighborhood and use this average as the new albedo modulation factor for that pixel. By traversing all elements in the matrix, the entire matrix is smoothed.

[0254] Implementation process: Determine the size of the neighborhood (for example, a 3x3 neighborhood).

[0255] For each element in the original diffuse reflectance modulation factor matrix, all elements in its neighborhood are selected with the element as the center.

[0256] Compute the average of all elements in a neighborhood.

[0257] The average value is used as the new value of the element and the original diffuse reflectance modulation factor matrix is updated.

[0258] Repeat the above steps until all elements in the matrix are processed to obtain the smoothed modulation factor matrix.

[0259] (7c) According to the three-dimensional geometric deformation matrix, the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix are weighted fused to obtain a fused modulation factor matrix.

[0260] It's understandable that while the smoothed modulation factor matrix reduces noise and fluctuations, it can be over-smoothed, potentially losing important details. The original diffuse reflectance modulation factor matrix, on the other hand, contains more detail but is noisy. Weighted fusion combines the advantages of both. Different weights are assigned to the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix based on the degree of 3D geometric deformation of the fabric surface, thereby preserving detail while reducing the impact of noise.

[0261] Implementation principle: Based on the element values in the 3D geometric deformation matrix, different weights are assigned to the corresponding elements in the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix. In areas with greater deformation, the details in the original diffuse reflectance modulation factor matrix may be more important, so a larger weight is assigned to it. In areas with less deformation, the smoothed modulation factor matrix may be more reliable, so a larger weight is assigned to it. The corresponding elements in the two matrices are then weighted and summed according to the weights to obtain the fused modulation factor matrix.

[0262] Implementation process: Determine a weight distribution rule, for example, design a function to calculate the weights of the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix according to the element values in the three-dimensional geometric deformation matrix.

[0263] Traverse each element position of the fusion modulation factor matrix.

[0264] According to the element value of the corresponding position in the three-dimensional geometric deformation matrix, the weight of the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix at the position is calculated.

[0265] The elements at corresponding positions in the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix are weighted and summed according to the weights to obtain the element value at that position in the fused modulation factor matrix.

[0266] Repeat the above steps until all elements of the fusion modulation factor matrix are calculated.

[0267] (7d) Perform adaptive Gaussian filtering on the fused modulation factor matrix and output the optimized diffuse reflectance modulation factor.

[0268] Understandably, despite the weighted fusion process, the fused modulation factor matrix may still contain some local irregularities. Adaptive Gaussian filtering is a filtering method that automatically adjusts filtering parameters based on local image features. By performing adaptive Gaussian filtering on the fused modulation factor matrix, the matrix can be further smoothed while preserving important edge and detail information. This allows the resulting optimized diffuse reflectance modulation factor to more accurately reflect the actual diffuse reflectance characteristics of the fabric surface.

[0269] Implementation principle: Gaussian filtering is a linear smoothing filter that uses a Gaussian function to convolve an image to achieve smoothing. Adaptive Gaussian filtering builds on this by automatically adjusting the size and standard deviation of the Gaussian kernel based on local image characteristics (such as variance and gradient). In the fused modulation factor matrix, smaller Gaussian kernels and standard deviations are used for edges and areas rich in detail to preserve these important information; larger Gaussian kernels and standard deviations are used for flat areas to enhance the smoothing effect.

[0270] Implementation process: Defines the algorithm for adaptive Gaussian filtering, including methods for calculating the Gaussian kernel size and standard deviation based on local features.

[0271] Traverse each element position of the fusion modulation factor matrix.

[0272] Calculate the characteristics of the local area around the location (such as variance, gradient, etc.).

[0273] According to the local features, the Gaussian kernel size and standard deviation at that location are determined.

[0274] A Gaussian filtering operation is performed on the position using a determined Gaussian kernel and standard deviation to obtain an optimized diffuse reflectance modulation factor for the position.

[0275] Repeat the above steps until all elements in the fusion modulation factor matrix are processed and the optimized diffuse reflectance modulation factor matrix is output. Finally, the corresponding optimized diffuse reflectance modulation factor is extracted based on the position of the target two-dimensional pixel in the matrix.

[0276] In an exemplary embodiment, constructing a three-dimensional geometric deformation matrix of the cloth surface in the image region where the target two-dimensional pixel is located includes: (8a) Determine the deformation characteristics of the cloth surface in the image region where the target two-dimensional pixel is located by using at least one of a depth gradient method, a normal angle method, a texture analysis method, or an optical flow method.

[0277] Understandably, fabric surface deformation is complex and diverse, and a single method may not be able to fully and accurately capture all deformation information. Depth gradient methods, normal angle methods, texture analysis methods, and optical flow methods each describe fabric surface deformation from different perspectives. By employing at least one of these methods, deformation characteristics of the fabric surface can be captured from multiple dimensions, improving the accuracy of deformation understanding and analysis, and providing a richer and more reliable data foundation for the subsequent construction of a 3D geometric deformation matrix.

[0278] Implementation principle: Depth Gradient Method: Calculates the depth gradient based on the depth information of the cloth surface obtained through 3D reconstruction. The depth gradient reflects the rate of change of the cloth surface in space. Areas with large gradient values indicate dramatic surface changes, i.e., large deformations; areas with small gradient values indicate relatively flat surfaces, with small deformations.

[0279] Normal Angle Method: In three-dimensional space, every point on a fabric surface has a corresponding normal vector. The angle between these normal vectors is calculated to measure the curvature of the fabric surface. Areas with larger angles indicate greater curvature and significant deformation, while areas with smaller angles indicate a smoother surface with less deformation.

[0280] Texture Analysis: The texture of a fabric surface changes as it deforms. By analyzing changes in texture distortion, stretching, and other factors, we can infer the deformation characteristics of the fabric surface. For example, the greater the degree of texture distortion, the greater the deformation of the fabric surface in that area.

[0281] Optical flow analysis uses pixel motion information within an image sequence to analyze the motion and deformation of objects. For a fabric surface, when deformation occurs, the pixels on the surface will shift accordingly. By calculating the optical flow field—the field of pixel displacement vectors—we can obtain this surface deformation information. The magnitude and direction of the optical flow vectors reflect the pixel displacement, and thus the deformation of the fabric surface.

[0282] Implementation process: Depth Gradient Method: First, a depth image of the cloth surface is obtained through three-dimensional reconstruction technology (such as structured light, stereo vision, etc.), where the grayscale value of each pixel represents the depth of the point in three-dimensional space.

[0283] Then, the gradient of the depth image is calculated. Usually, edge detection operators such as the Sobel operator and the Prewitt operator can be used to calculate the gradient of the depth image in the horizontal and vertical directions.

[0284] Finally, based on the calculated gradient value, the depth gradient information of the cloth surface is obtained as part of the deformation feature.

[0285] Normal angle method: Using the 3D point cloud data of the cloth surface obtained by 3D reconstruction, the normal vector of each point is calculated. Methods such as local plane fitting can be used to calculate the normal vector.

[0286] For adjacent points, calculate the angle between their normal vectors.

[0287] Based on these angle information, the normal angle characteristics of the cloth surface are obtained to describe the deformation of the cloth surface.

[0288] Texture analysis method: To collect texture images of the cloth surface, a high-resolution camera can be used to capture the texture images of the cloth surface.

[0289] Perform feature extraction on texture images, such as using gray-level co-occurrence matrix, local binary pattern and other methods to extract statistical and structural features of textures.

[0290] Analyze the changes in texture features, such as texture direction, frequency, contrast, etc., to infer the deformation characteristics of the cloth surface.

[0291] Optical flow method: A sequence of images of the cloth surface is captured to record the state of the cloth surface at different moments.

[0292] Use an optical flow calculation algorithm (such as the Lucas-Kanade algorithm, Horn-Schunck algorithm, etc.) to calculate the optical flow field between adjacent frames in an image sequence.

[0293] According to the displacement vector information of pixels in the optical flow field, the deformation characteristics of the cloth surface are obtained.

[0294] (8b) Determine the three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located based on the deformation characteristics.

[0295] It's understandable that deformation features are merely a description of the fabric surface's deformation, requiring conversion into a mathematical matrix for subsequent calculations and processing. A three-dimensional geometric deformation matrix represents the fabric's surface deformation information in a structured manner, providing an intuitive and computationally scalable foundation for operations such as smoothing constraints on the diffuse reflectance modulation factor. This matrix facilitates analysis and application of fabric surface deformation information.

[0296] Implementation principle: Based on the type and representation of the deformation features used, they are converted into matrix elements. For example, if the deformation features are represented by depth gradients, the depth gradient values can be used as matrix elements; if the deformation features are represented by normal angles, the normal angle values can be used as matrix elements. The size and structure of the matrix can be determined based on the size and shape of the image region where the target 2D pixel is located, so that each element in the matrix corresponds to a pixel or a small region in the image region.

[0297] Implementation process: Determine the size and structure of the three-dimensional geometric deformation matrix, and determine the number of rows and columns of the matrix based on the resolution of the image area where the target two-dimensional pixel is located or the size of the divided area.

[0298] According to the deformation features obtained in step (8a), they are quantized into numerical values, and these numerical values are filled into the corresponding positions of the matrix according to the structure of the matrix.

[0299] If multiple deformation features are used, these features can be fused, for example, by combining the values of different features through weighted averaging and then filling them into the matrix.

[0300] Finally, the three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located is obtained for subsequent processing and analysis.

[0301] It is understandable that the specific steps of the current clothing production defect detection process are: Appearance inspection: Check the garment for visible details such as color difference, stains, holes, loose threads, and feel to ensure there are no obvious defects.

[0302] Fabric inspection: Test the shrinkage, pilling and color fastness of the fabric to ensure that the fabric quality meets the standards. Size inspection: Measure the garment size according to the bulk size chart, allowing 1-2cm error (or as agreed), but errors are inevitable.

[0303] Symmetry inspection: Check the collar tip, collar bone, sleeves, shoulders, cuffs, trouser length, left and right pocket positions and sizes to ensure symmetry and consistency.

[0304] Workmanship inspection: Check whether the stitching of each part is smooth, neat and firm, with appropriate tightness, no broken or jumped stitches, and the stitch density is moderate.

[0305] Ironing inspection: Check whether each part is ironed evenly, without yellowing, laser or water stains, and the thread ends must be thoroughly cleaned.

[0306] Material Inspection: Check the mark position and sewing quality, check whether the hanging tags are correct and complete, and whether the folding effect and plastic bag quality must meet the requirements of the material list. Packaging Inspection: Folding is correct and flat, and packaging is carried out strictly according to the packaging instructions.

[0307] The difficulties in each link of garment production defect detection mentioned above are closely related, as follows: The relationship between appearance inspection and other links Related to fabric inspection: Fabric characteristics, such as dimensional changes caused by substandard shrinkage, can affect the smoothness of the surface, further impacting the assessment of details like color variations and loose threads during appearance inspection. For example, wrinkles in the fabric caused by shrinkage can be mistakenly identified as cosmetic defects. Furthermore, if pilling is not detected promptly during appearance inspection, it may indicate a quality issue that must be traced back to the fabric inspection stage.

[0308] Related to size inspection: Size errors can affect the overall appearance of a garment. For example, an oversized garment may appear baggy and affect its crispness; an undersized garment may be tight and wrinkle, interfering with the smoothness of the garment during the appearance inspection.

[0309] Related to symmetry inspection: Asymmetry in garment parts not only affects the aesthetics but also increases the difficulty of appearance inspection. Inspectors must expend considerable effort to identify and determine whether asymmetry is a quality issue. Furthermore, severe asymmetry can directly lead to unacceptable appearance.

[0310] Related to workmanship inspection: Workmanship issues such as uneven wiring and exposed thread ends directly affect the appearance quality. If a large number of workmanship defects are found during the appearance inspection, it is necessary to consider whether they are related to the strictness of the workmanship inspection process or the inspection method.

[0311] Related to pressing inspection: Poor pressing results, such as yellowing, laser stains, and water stains, can significantly affect the appearance of garments. While these pressing issues are easily detected during the visual inspection, they must be traced back to the pressing inspection stage to analyze whether they are caused by problems with the pressing process or equipment malfunction.

[0312] Linked to material inspection: Material issues, such as incorrectly placed marks or missing tags, can disrupt the overall appearance of a garment. If such issues are discovered during the appearance inspection, they should be linked to the material inspection process to identify loopholes in the material supply or inspection process.

[0313] Related to packaging inspection: Improper packaging can cause the garment to be squeezed or rubbed during transportation or storage, resulting in new cosmetic defects. If new damage is found during the appearance inspection, consider whether there is a problem with the packaging inspection.

[0314] The relationship between fabric inspection and other links Related to dimensional inspection: Fabric shrinkage is a key factor affecting garment dimensional stability. Failure to accurately measure fabric shrinkage during fabric inspection can lead to significant dimensional deviations during dimensional inspection, impacting the finished garment's dimensional conformity.

[0315] Related to symmetry inspection: Fabric quality issues, such as localized defects or uneven texture, can lead to uneven stress on different parts of the garment during the production process, affecting symmetry. Failure to detect these issues during fabric inspection increases the difficulty of symmetry inspection and the failure rate.

[0316] Related to workmanship inspection: Fabric properties can affect the difficulty and quality of stitching. For example, fabric that is too soft or stretchy can lead to uneven stitching and other issues. The impact of fabric properties on workmanship must be fully considered during fabric inspection to provide a reference for workmanship inspection.

[0317] Related to ironing inspection: Different fabrics require different ironing processes. Fabric inspection requires accurate identification of fabric composition and characteristics to provide correct ironing parameter recommendations for ironing inspection. Failure to do so may result in poor ironing results or even damage to the fabric.

[0318] Related to material inspection: Fabric quality is closely linked to the adhesion of materials (such as labels and tags). Excessively smooth or rough fabric surfaces can affect the strength of sewing. Fabric inspections must consider the impact of fabric characteristics on material adhesion to ensure accurate inspection.

[0319] Related to packaging inspection: Fabric strength and toughness affect a garment's ability to withstand pressure during packaging. Failure to fully assess fabric strength during fabric inspection can lead to deformation or damage to the packaged garment, affecting the inspection results.

[0320] The relationship between dimensional inspection and other links Related to symmetry inspection: Dimensional errors can affect the symmetry of a garment. For example, inconsistent collar point measurements can lead to asymmetrical collar points, while sleeve length errors can lead to asymmetrical sleeves. Dimensional inspection must be closely coordinated with symmetry inspection to ensure that both garment dimensions and symmetry meet requirements.

[0321] Related to workmanship inspection: Dimensional deviations can increase workmanship difficulties. For example, oversized garments can lead to uneven stitching, impacting workmanship quality. Dimensional inspection results can provide a reference for workmanship inspection, helping inspectors determine whether workmanship issues are related to dimensional deviations.

[0322] Related to ironing inspection: Dimensional stability affects ironing results. Garments with significant dimensional fluctuations are more susceptible to wrinkling and deformation during the ironing process. Dimensional inspection ensures garment dimensional stability to create optimal conditions for ironing inspection.

[0323] Related to material inspection: Garment size can affect the placement and quality of material. For example, if a garment is too small, the marking position may be offset, affecting the appearance. The dimensional inspection process must consider material installation requirements to ensure accurate material inspection.

[0324] Related to packaging inspection: Garment size is an important factor in selecting packaging materials and methods. The dimensional inspection process requires accurate dimensional information for packaging inspection to ensure that the packaging meets garment size requirements.

[0325] Symmetry test and its relationship with other aspects Related to workmanship inspection: Symmetry issues can be linked to poor workmanship. For example, asymmetry between the left and right cuffs may be caused by uneven seams or inaccurate cutting. Issues discovered during the symmetry inspection can provide clues for workmanship inspection, helping to identify the root cause of the workmanship issue.

[0326] Related to pressing inspection: Improper pressing techniques can cause garment deformation and affect symmetry. For example, uneven temperatures during pressing can cause one side of the garment to shrink while the other remains unchanged, resulting in asymmetry. Symmetry inspection should be conducted in conjunction with pressing inspection to analyze the cause of the problem and implement appropriate measures to address it.

[0327] Related to material inspection: Improper material placement can lead to garment asymmetry. For example, inconsistent left and right pocket placement can affect the overall symmetry of a garment. Issues identified during symmetry inspection should be communicated to the material inspection team to ensure that material placement meets requirements.

[0328] Linked to packaging inspection: Improper packaging can cause garments to deform during the packaging process, affecting their symmetry. Symmetry inspection must be coordinated with packaging inspection to ensure that packaging does not disrupt garment symmetry.

[0329] The relationship between workmanship inspection and other links Related to ironing inspection: Workmanship quality can affect the ironing results. For example, poorly cleaned thread ends can result in thread marks after ironing, while loose seams can cause seams to break during ironing. The workmanship inspection ensures that workmanship quality meets requirements, providing a sound foundation for ironing inspection.

[0330] Related to material inspection: Workmanship issues can affect material adhesion. For example, irregular seams can lead to loose seams on the mark, affecting the material's lifespan. Workmanship inspection must be coordinated with material inspection to ensure both workmanship and material quality meet standards.

[0331] Related to packaging inspection: Poorly made garments are more likely to break or deform during the packaging process. The workmanship inspection phase must ensure the quality of garments and reduce the difficulty and rejection rate during the packaging inspection phase.

[0332] The relationship between ironing inspection and other links Linked to material inspection: Ironing temperature and pressure can affect material properties and appearance. For example, high-temperature ironing can cause discoloration of labels or deformation of labels. Ironing inspection must communicate with material inspection to understand the material's tolerance to ironing and ensure the ironing process does not damage the material.

[0333] Related to packaging inspection: Pressing quality can impact garment packaging. For example, garments that are not pressed flat may appear more wrinkled after packaging, affecting the overall appearance of the product. The pressing inspection process ensures that the pressing quality meets requirements, providing a good foundation for packaging inspection.

[0334] The relationship between material inspection and other links Related to packaging inspection: Material quality directly impacts packaging results. For example, substandard plastic bags can cause contamination or damage to garments during packaging. Material inspection ensures that material quality meets packaging requirements, providing support for packaging inspection.

[0335] It should be understood that, although the steps in the flowcharts of the above embodiments are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the flowcharts of the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0336] Based on the same inventive concept, embodiments of the present application also provide a machine learning-based automatic detection system for military clothing production defects, which is used to implement the aforementioned machine learning-based automatic detection method for military clothing production defects. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the machine learning-based automatic detection system for military clothing production defects provided below can be found in the limitations of the machine learning-based automatic detection method for military clothing production defects above, and will not be repeated here.

[0337] In an exemplary embodiment, Figure 2 As shown, a system for automatically detecting production defects of military clothing based on machine learning is provided, comprising: A scene construction module 11 is used to construct a three-dimensional illumination model of the current scene. The three-dimensional illumination model includes illumination parameters of each three-dimensional spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and three-dimensional spatial position. A tensor construction module 12 is used to construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channel, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; A feature analysis module 13 is configured to determine the physical reflection characteristics of each 2D image pixel based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel corresponding to each 3D spatial sampling point; A tensor decomposition module 14 is used to perform tensor decomposition on the five-dimensional image tensor according to the physical reflection characteristics of each two-dimensional image pixel to obtain the illumination influence characteristics and the material characteristics of each two-dimensional image pixel; The defect recognition module 15 is used to determine the defects of the clothing fabric to be detected based on the material characteristics of each two-dimensional image pixel point using a machine learning algorithm.

[0338] Each module in the aforementioned machine learning-based automatic defect detection system for military clothing production can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor within a computer device in hardware form, or stored in a computer device memory in software form, allowing the processor to call and execute the corresponding operations of each module.

[0339] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented: Construct a 3D illumination model of the current scene. The 3D illumination model includes illumination parameters of each 3D spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and 3D spatial position. Construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; determining the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point; According to the physical reflection characteristics of each two-dimensional image pixel, the five-dimensional image tensor is decomposed to obtain the illumination influence characteristics and material characteristics of each two-dimensional image pixel; Based on the material characteristics of each two-dimensional image pixel, a machine learning algorithm is used to determine the defects of the clothing fabric to be inspected.

[0340] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: Construct a 3D illumination model of the current scene. The 3D illumination model includes illumination parameters of each 3D spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and 3D spatial position. Construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; determining the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point; According to the physical reflection characteristics of each two-dimensional image pixel, the five-dimensional image tensor is decomposed to obtain the illumination influence characteristics and material characteristics of each two-dimensional image pixel; Based on the material characteristics of each two-dimensional image pixel, a machine learning algorithm is used to determine the defects of the clothing fabric to be inspected.

[0341] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps: Construct a 3D illumination model of the current scene. The 3D illumination model includes illumination parameters of each 3D spatial sampling point in the current scene. The illumination parameters include incident light direction, spectral distribution, and 3D spatial position. Construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channels, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; determining the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point; According to the physical reflection characteristics of each two-dimensional image pixel, the five-dimensional image tensor is decomposed to obtain the illumination influence characteristics and material characteristics of each two-dimensional image pixel; Based on the material characteristics of each two-dimensional image pixel, a machine learning algorithm is used to determine the defects of the clothing fabric to be inspected.

[0342] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.

[0343] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0344] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for automatically detecting production defects of military clothing based on machine learning, characterized in that: The method comprises: Constructing a three-dimensional illumination model of the current scene, the three-dimensional illumination model including illumination parameters of each three-dimensional spatial sampling point in the current scene; the illumination parameters including incident light direction, spectral distribution, and three-dimensional spatial position; Constructing a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channel, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; determining the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category labels of each 2D image pixel point corresponding to each 3D spatial sampling point; Performing tensor decomposition on the five-dimensional tensor of the image based on the physical reflection characteristics of each pixel point of the two-dimensional image to obtain the illumination influence characteristics and the material characteristics of each pixel point of the two-dimensional image; According to the material characteristics of each pixel point of the two-dimensional image, a machine learning algorithm is used to determine the defects of the clothing fabric to be detected.

2. The method according to claim 1, characterized in that The constructing of a five-dimensional image tensor corresponding to the clothing image to be detected includes: Constructing an original four-dimensional tensor based on the multispectral image data of the garment to be detected; the original four-dimensional tensor includes image height, width, spectral channel, and material category labels of each two-dimensional image pixel point in the garment image to be detected; Normalizing the three-dimensional spatial position of the three-dimensional spatial sampling point corresponding to each two-dimensional image pixel point in the clothing image to be detected to obtain a position encoding vector; Embedding the position encoding vector as the fifth dimension into the original four-dimensional tensor to construct an initial five-dimensional tensor; A position-sensitive attention mechanism is used to determine an illumination correlation weight matrix for the clothing image to be detected. The illumination correlation weight matrix includes illumination correlation weight values between any two two-dimensional image pixels in the clothing image to be detected. The illumination correlation weight values are positively correlated with the spatial position distance, spectral similarity, and material category correlation of the two-dimensional image pixels. The illumination association weight matrix is fused with the initial five-dimensional tensor to obtain a five-dimensional image tensor corresponding to the clothing image to be detected.

3. The method according to claim 2, characterized in that The step of fusing the illumination association weight matrix with the initial five-dimensional tensor to obtain a five-dimensional image tensor corresponding to the clothing image to be detected includes: Fusing the illumination-related weight matrix with the initial five-dimensional tensor to obtain a fused five-dimensional vector; Light is randomly emitted on the surface of the garment fabric to be inspected, and a Monte Carlo path tracing algorithm is used to simulate the multiple reflection paths of the light on the fabric surface to determine the indirect illumination component of each pixel point of the two-dimensional image; the indirect illumination component includes the intensity, direction and spectral distribution of the indirect illumination; Combining the indirect illumination component and the direct illumination component of each two-dimensional image pixel to form a global illumination component of each two-dimensional image pixel; identifying dark areas in the image to be detected based on a global illumination component of each pixel of the two-dimensional image; generating a compensation weight matrix according to the light sensitivity corresponding to the material category label of each two-dimensional image pixel in the dark area; the light intensity of the dark area is less than the intensity threshold; Multiplying the indirect lighting component of each two-dimensional image pixel by the compensation weight matrix to generate an indirect lighting compensation item for each two-dimensional image pixel; The fused five-dimensional vector is compensated according to the indirect illumination compensation item of each two-dimensional image pixel point to obtain a five-dimensional image tensor corresponding to the clothing image to be detected.

4. The method according to claim 2, characterized in that The position-sensitive attention mechanism is used to determine the illumination-related weight matrix of the clothing image to be detected, including: Obtaining the three-dimensional spatial coordinates, multispectral features, and material category features of each pixel point in the clothing image to be detected; Use a learnable Gaussian kernel function to calculate the spatial distance weight between any two pixels; Calculate the spectral similarity weight of any two pixels using the spectral feature dot product; The material correlation weight of any two pixels is calculated using the projection similarity of the material category embedding vector; Performing element-level fusion on the spatial distance weight, the spectral similarity weight, and the material correlation weight to generate an initial correlation weight of any two pixels; Normalizing the initial association weights of the arbitrary two pixels to obtain a light association weight value of the arbitrary two pixels.

5. The method according to claim 1, wherein For any three-dimensional spatial sampling point in the three-dimensional illumination model and the two-dimensional image pixel corresponding to the three-dimensional spatial sampling point in the garment image to be detected, determining the physical reflection characteristics of each two-dimensional image pixel according to the illumination parameters corresponding to each three-dimensional spatial sampling point in the three-dimensional illumination model and the material category label of each two-dimensional image pixel corresponding to each three-dimensional spatial sampling point includes: The two-dimensional image pixel point corresponding to the three-dimensional space sampling point in the clothing image to be detected is used as the target two-dimensional pixel point; Extracting basic diffuse reflection features and basic specular reflection response features corresponding to the material category label of the target two-dimensional pixel point based on a pre-built material reflection database; Generate a diffuse reflectance modulation factor and a dynamic adjustment coefficient of specular reflectance of the target pixel point according to the illumination parameters corresponding to the three-dimensional spatial sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point; According to the degree of three-dimensional geometric deformation of the cloth surface in the image area where the target two-dimensional pixel is located, a smoothing constraint is applied to the diffuse reflectance modulation factor of the target two-dimensional pixel to obtain an optimized diffuse reflectance modulation factor; Adjusting the basic diffuse reflection characteristics of the target two-dimensional pixel according to the optimized diffuse reflectance modulation factor to obtain the current diffuse reflection characteristics of the target two-dimensional pixel; The basic specular reflection response characteristic is adjusted according to the specular reflectivity dynamic adjustment coefficient to obtain the current specular reflection characteristic of the target two-dimensional pixel point.

6. The method according to claim 5, characterized in that The physical reflection characteristics include current diffuse reflection characteristics; The basic diffuse reflection feature includes a basic diffuse reflectance; Generating a diffuse reflectance modulation factor and a dynamic specular reflectance adjustment coefficient of the target pixel point according to the illumination parameters corresponding to the three-dimensional spatial sampling point and the basic diffuse reflectance characteristics and specular reflectance response characteristics of the target two-dimensional pixel point, including: Determine a first angle cosine value of a first angle between an incident light direction in the illumination parameters corresponding to the three-dimensional space sampling point and a surface normal of the surface where the target pixel point is located; performing spectral weighting on the basic specular reflectance according to the spectral distribution of the illumination parameters corresponding to the three-dimensional spatial sampling points to obtain a weighted specular reflectance; The product of the cosine value of the included angle and the weighted mirror reflectivity is used as the diffuse reflectivity modulation factor of the target pixel point.

7. The method according to claim 5, characterized in that The physical reflection characteristics include current specular reflection characteristics; the basic specular reflection response characteristics include basic specular reflectivity and specular reflection index; Generating a dynamic adjustment coefficient of the specular reflectance of the target pixel point according to the illumination parameters corresponding to the three-dimensional spatial sampling point and the basic diffuse reflection characteristics and specular reflection response characteristics of the target two-dimensional pixel point, including: Determining a half vector according to an observation direction corresponding to the target pixel point and an incident light direction in the illumination parameter corresponding to the three-dimensional space sampling point; Determine a second angle cosine value of a second angle between the half vector and the surface normal of the surface where the target pixel point is located; Using the specular reflection index as an exponent of the cosine value of the second angle to obtain an index calculation result; The dynamic adjustment coefficient of the specular reflectivity of the target pixel point is determined according to the index calculation result, the basic specular reflectivity, and the illumination intensity in the illumination parameter corresponding to the three-dimensional space sampling point.

8. The method according to claim 5, characterized in that The step of performing smoothing constraint on the diffuse reflectance modulation factor of the target two-dimensional pixel according to the degree of three-dimensional geometric deformation of the cloth surface in the image area where the target two-dimensional pixel is located, to obtain an optimized diffuse reflectance modulation factor, includes: Constructing a three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located; performing neighborhood averaging calculation on an original diffuse reflectance modulation factor matrix formed by the diffuse reflectance modulation factors of each two-dimensional image pixel in the image area according to the three-dimensional geometric deformation matrix to obtain a smoothed modulation factor matrix; performing weighted fusion on the smoothed modulation factor matrix and the original diffuse reflectance modulation factor matrix according to the three-dimensional geometric deformation matrix to obtain a fused modulation factor matrix; Adaptive Gaussian filtering is performed on the fused modulation factor matrix to output an optimized diffuse reflectance modulation factor.

9. The method according to claim 8, characterized in that The step of constructing a three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located includes: Determine the deformation characteristics of the cloth surface in the image area where the target two-dimensional pixel is located using at least one of a depth gradient method, a normal angle method, a texture analysis method, or an optical flow method; A three-dimensional geometric deformation matrix of the cloth surface in the image area where the target two-dimensional pixel is located is determined according to the deformation feature.

10. A machine learning-based automatic detection system for military clothing production defects, characterized by: The system comprises: A scene construction module is used to construct a three-dimensional illumination model of the current scene, wherein the three-dimensional illumination model includes illumination parameters of each three-dimensional spatial sampling point in the current scene; the illumination parameters include incident light direction, spectral distribution, and three-dimensional spatial position; A tensor construction module is used to construct a five-dimensional image tensor corresponding to the clothing image to be detected; the five-dimensional image tensor includes image height, width, spectral channel, and the material category label and three-dimensional spatial position of each two-dimensional image pixel point in the clothing image to be detected; A feature analysis module is used to determine the physical reflection characteristics of each 2D image pixel point based on the illumination parameters corresponding to each 3D spatial sampling point in the 3D illumination model and the material category label of each 2D image pixel point corresponding to each 3D spatial sampling point; A tensor decomposition module is used to perform tensor decomposition on the five-dimensional image tensor according to the physical reflection characteristics of each two-dimensional image pixel point, so as to obtain the illumination influence characteristics and the material characteristics of each two-dimensional image pixel point; The defect recognition module is used to determine the defect of the clothing fabric to be detected based on the material characteristics of each two-dimensional image pixel point using a machine learning algorithm.

Citation Information

Cited By

  • Textile color fastness intelligent evaluation method and system based on machine vision

    CN121437394A

  • Intelligent evaluation method and system for color fastness of textile based on machine vision

    CN121437394B