A product detection method and system based on machine vision

By dynamically adjusting the light source parameters and selecting a spectral imaging system with an appropriate wavelength range, combined with a lightweight deep learning model and classification algorithm, the problems of uneven illumination and unreasonable wavelength selection in machine vision inspection are solved, achieving high-precision and high-efficiency product defect detection.

CN119323659BActive Publication Date: 2026-07-24NANAN BADUO BUILDING MATERIALS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANAN BADUO BUILDING MATERIALS CO LTD
Filing Date
2024-12-18
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing machine vision inspection technologies have shortcomings in terms of adaptability to lighting conditions, wavelength range selection, and real-time processing capabilities, resulting in unstable inspection results and low accuracy.

Method used

The initial lighting conditions are assessed by initializing the ambient light sensor, the light source parameters are dynamically adjusted, a suitable wavelength range is selected to configure the spectral imaging system, a lightweight deep learning model is used for image preprocessing and preliminary defect detection, and the defect types are refined through classification algorithms. Finally, the results are transmitted to the cloud.

Benefits of technology

This improved the stability of image quality and the accuracy of detection under different lighting conditions, enhanced the accuracy and efficiency of defect detection, and increased the intelligence level of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119323659B_ABST
    Figure CN119323659B_ABST
Patent Text Reader

Abstract

The application discloses a product detection method and system based on machine vision, and relates to the technical field of machine vision, which comprises the following steps: initializing an ambient light sensor to evaluate initial light conditions and dynamically adjusting light source parameters to verify and lock optimal settings; selecting a preset wavelength range according to the characteristics of building materials to configure a spectral imaging system to collect image data, obtaining comprehensive spectral images through preliminary processing and image synthesis, and obtaining a high-quality image data set through feature extraction; deploying a deep learning model on an edge device to perform preliminary defect detection after preprocessing the image data set, identifying defect types, and extracting local and frequency domain features; and transmitting the final classification results and image data to the cloud for detection according to the preliminary detection results using a classification algorithm. The application realizes high-precision and high-efficiency product defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision technology, and in particular to a product inspection method and system based on machine vision. Background Technology

[0002] Machine vision technology has made significant progress in industrial inspection, quality control, and automated production in recent years. Traditional rule-based image processing methods are gradually being replaced by data-driven deep learning algorithms, which can more accurately identify complex patterns and subtle defects. Particularly in building material inspection, multispectral and hyperspectral imaging systems have attracted considerable attention due to their ability to capture material properties across different wavelength ranges. These systems not only provide rich spectral information but also enhance the resolution of material surfaces and internal structures through high-resolution imaging. However, early machine vision inspection methods largely relied on fixed light source settings and single-wavelength image acquisition, leading to instability and inaccuracy in inspection results under varying lighting conditions and material properties. With advancements in ambient light sensors and tunable light source technology, dynamically adjusting light source parameters has become possible, thereby improving image quality and inspection accuracy. Furthermore, the application of edge computing devices enables real-time processing and preliminary classification to be efficiently completed in resource-constrained environments, further enhancing the system's response speed and practicality.

[0003] While existing technologies have made some progress in certain aspects, they still have many shortcomings in practical applications. First, existing machine vision inspection systems often fail to adequately consider variations in ambient lighting conditions, leading to uneven or excessively strong / weak illumination during image acquisition. These fluctuations in lighting conditions directly affect image quality, consequently impacting the accuracy of feature extraction and defect detection. To address this, some systems employ fixed light sources or simple illumination compensation mechanisms, but these methods cannot adapt to complex changes in the on-site environment, limiting their application scenarios. Second, existing technologies often lack specificity in selecting wavelength ranges, failing to fully utilize the spectral characteristics of materials for optimal configuration. Different building materials exhibit significant differences in reflectivity and absorptivity at specific wavelengths; therefore, selecting an appropriate wavelength range is crucial for improving detection accuracy. However, many systems rely solely on experience or preset wavelength ranges, ignoring individual differences in material properties, resulting in less than ideal detection results. Furthermore, existing technologies also have limitations in real-time processing and preliminary classification. Due to limited resources on edge devices, traditional deep learning models are difficult to deploy directly and run efficiently, resulting in insufficient real-time processing capabilities. Even though some lightweight models can run on edge devices, their feature extraction and classification results are often unsatisfactory and cannot meet the needs of high-precision detection.

[0004] In summary, existing machine vision inspection technologies have significant shortcomings in terms of adaptability to lighting conditions, wavelength range selection, and real-time processing capabilities. To address these issues, this invention proposes a machine vision-based product inspection method. This method aims to initialize an ambient light sensor and evaluate initial lighting conditions, dynamically adjust light source parameters, verify and lock in the optimal lighting settings, thereby ensuring stable, high-quality image acquisition. Simultaneously, a preset wavelength range is selected based on the characteristics of the building materials, and a high-resolution multispectral or hyperspectral camera with tunable or linearly variable filters is employed to obtain optimal material characterization and comprehensive spectral images. Furthermore, this invention preprocesses the high-quality image dataset on an edge device, deploys a deep learning model for preliminary defect detection, and refines defect types using a classification algorithm. Finally, the classification results and their corresponding image data are integrated and transmitted to the cloud, realizing a complete inspection process. This invention belongs to the field of machine vision and intelligent inspection technology, and is particularly suitable for high-precision defect detection of complex materials such as building materials. Summary of the Invention

[0005] The purpose of this section is to outline some aspects of embodiments of the present invention and to briefly describe some preferred embodiments. Simplifications or omissions may be made in this section, as well as in the abstract and title of this application, to avoid obscuring the purpose of these documents; however, such simplifications or omissions should not be construed as limiting the scope of the invention.

[0006] In view of the aforementioned existing problems, the present invention is proposed.

[0007] Therefore, the present invention provides a product inspection method and system based on machine vision, which can solve the problems mentioned in the background art.

[0008] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0009] In a first aspect, the present invention provides a product inspection method based on machine vision, which includes initializing an ambient light sensor and evaluating initial lighting conditions, dynamically adjusting light source parameters, and verifying and locking the optimal lighting settings.

[0010] A preset wavelength range is selected based on the characteristics of building materials, a spectral imaging system is configured, and image data of the building materials is acquired to obtain material characterization. The material characterization is then preliminarily processed and image synthesized to obtain a comprehensive spectral image. Feature extraction is performed on the comprehensive spectral image to obtain a high-quality image dataset.

[0011] The high-quality image dataset is preprocessed on an edge device, a deep learning model is deployed, and the deep learning model is used to perform preliminary defect detection on the preprocessed image data to identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results.

[0012] Based on the preliminary detection results, a classification algorithm is applied to refine the defect types, and the final classification results are obtained. The final classification results and their corresponding image data are then integrated and transmitted to the cloud to complete the detection.

[0013] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the evaluation of initial illumination conditions includes:

[0014] Deploy and initialize the integrated ambient light sensor, set the measurement frequency and range of the ambient light sensor, and perform an initial assessment of the light intensity and color temperature of the current environment before starting image acquisition to obtain the initial lighting condition assessment results and record the initial lighting conditions.

[0015] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the dynamic adjustment of the light source parameters includes:

[0016] Based on the initial lighting condition assessment results, basic parameters of the light source are set, including brightness, angle, and color temperature. Changes in ambient light are continuously monitored in real-time, and the light source parameters are compensated accordingly. The calculation formula for the lighting compensation function is as follows:

[0017] ;

[0018] in, It is the illumination compensation function. It is the target light intensity. Ambient light intensity at wavelength The measured values ​​below, It's color temperature. It is a correction function, set by taking into account the influence of different color temperatures on different wavelengths. The calculation formula of this function is as follows:

[0019] ;

[0020] in, It is an empirical constant, determined through experiments. It is a reference wave.

[0021] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the step of verifying and locking the optimal illumination settings includes:

[0022] After adjusting the light source parameters, verify whether the lighting quality meets the expected standard through a preset standard test procedure or reference image, and lock the current light source parameter settings.

[0023] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the step of selecting a preset wavelength range based on the characteristics of building materials includes:

[0024] Select a preset wavelength range based on the characteristics of the building materials, and set up a high-resolution multispectral camera or hyperspectral camera and a tunable filter or linear variable filter. The calculation formula for wavelength range selection is as follows:

[0025] ;

[0026] in, These are the weighting coefficients for each wavelength. It is the material at wavelength The reflectivity of the following It is the average reflectance across all wavelengths. It is the standard deviation of reflectivity;

[0027] At the same time, a weighted composition function is introduced. It is used to synthesize image data from different wavelengths, and the calculation formula is as follows:

[0028] ;

[0029] in, It is a weighted composition function. At wavelength The intensity of the captured image, These are the weighting coefficients for each wavelength. It is a regulating factor used to control the degree of nonlinear response. It is the intensity of the reference image, and N is the number of wavelengths.

[0030] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the material characterization includes multi-dimensional information reflecting material properties;

[0031] The preliminary processing and image synthesis of the material characterization include:

[0032] Image data of building materials is captured within a preset wavelength range, and the data is initially cleaned and formatted before being stored in a local or cloud database.

[0033] Image synthesis and feature extraction include:

[0034] Image data from different wavelengths are combined into a single panchromatic image;

[0035] Signal processing techniques are used to extract key parameters reflecting material properties from panchromatic images, including absorptivity, reflectivity, and texture features.

[0036] The texture features include contrast, correlation, energy, and entropy, calculated using the following formula:

[0037] ;

[0038] Where C1 is contrast, C2 is correlation, E1 is energy, and E2 is entropy. These are elements in the gray-level co-occurrence matrix, representing the probability of pixel pairs with pixel values ​​i and j occurring. It is the average gray value. That is the standard deviation.

[0039] As a preferred embodiment of the machine vision-based product inspection method of the present invention, the identification and marking of various types of defects includes:

[0040] Use a deployed lightweight deep learning model to perform real-time feature extraction on preprocessed image data;

[0041] Identify and label various types of defects, using the following formula:

[0042] ;

[0043] in, Let F be the probability of the defect existing, W be the model weight matrix, T be the transpose of the weight matrix W, F be the extracted feature vector, and b be the bias term. It is the sigmoid function, used to convert the output into a probability value.

[0044] Secondly, the present invention provides a product inspection system based on machine vision, which includes: an illumination compensation module, an image extraction module, a defect classification module, and a final inspection module.

[0045] The illumination compensation module is used to initialize the ambient light sensor and evaluate the initial illumination conditions, dynamically adjust the light source parameters, and verify and lock the optimal illumination settings.

[0046] The image extraction module is used to select a preset wavelength range according to the characteristics of building materials, configure a spectral imaging system and collect image data of building materials to obtain material characterization, perform preliminary processing and image synthesis on the material characterization to obtain a comprehensive spectral image, and perform feature extraction on the comprehensive spectral image to obtain a high-quality image dataset.

[0047] The defect classification module is used to preprocess the high-quality image dataset on the edge device, deploy a deep learning model, use the deep learning model to perform preliminary defect detection on the preprocessed image data, identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results.

[0048] The final detection module is used to refine the defect type based on the preliminary detection results using a classification algorithm, obtain the final classification result, integrate the final classification result and its corresponding image data, and transmit them to the cloud to complete the detection.

[0049] Thirdly, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of a product inspection method based on machine vision.

[0050] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of a product inspection method based on machine vision.

[0051] Compared with existing technologies, the advantages of this invention are as follows: By initializing the ambient light sensor and evaluating the initial illumination conditions, this invention achieves an initial assessment of the light intensity and color temperature of the current environment, records the initial illumination conditions, and compensates for them by dynamically adjusting light source parameters (including brightness, angle, and color temperature) and monitoring changes in ambient light in real time. Ultimately, the optimal illumination settings are verified and locked, optimizing image quality and improving detection accuracy. Next, based on the characteristics of the building materials, a preset wavelength range is selected, a spectral imaging system is configured, and image data of the building materials is acquired to obtain detailed material characterization. Then, through preliminary processing and image synthesis of the material characterization, a comprehensive spectral image is obtained. Signal processing techniques are applied to extract key parameters such as absorptivity, reflectivity, and texture features, generating a high-quality image dataset, providing reliable data support for defect detection. Subsequently, the high-quality image dataset is preprocessed on an edge device, a lightweight deep learning model is deployed, and real-time feature extraction and preliminary defect detection are achieved. Various types of defects are identified and marked, and further local and frequency domain features are extracted, enhancing the accuracy and efficiency of defect detection. Finally, based on the preliminary detection results, a classification algorithm is applied to refine the defect types. The final classification results and their corresponding image data are integrated and transmitted to the cloud via a low-latency communication protocol, completing the entire detection process and improving the overall intelligence and reliability of the detection system. In summary, this invention, through a series of carefully designed steps, solves the problems of uneven illumination, unreasonable wavelength selection, and insufficient real-time processing capabilities existing in the prior art, achieving high-precision and high-efficiency product defect detection. Attached Figure Description

[0052] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 A flowchart of a product inspection method and system based on machine vision is provided in one embodiment of the present invention;

[0054] Figure 2 This is an internal structural diagram of a computer device for a product inspection method and system based on machine vision, provided as an embodiment of the present invention. Detailed Implementation

[0055] To make the above-mentioned objects, features, and advantages of the present invention more readily understood, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.

[0056] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0057] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0058] Example 1, Reference Figures 1-2 This is the first embodiment of the present invention, which provides a product inspection method based on machine vision, including:

[0059] This application provides a solution to the problems mentioned above. The following will describe in detail how to implement the machine vision-based product inspection method with reference to several embodiments.

[0060] Figure 1 A flowchart of a product inspection method and system based on machine vision is shown, including:

[0061] S1: Initialize the ambient light sensor and evaluate the initial lighting conditions, dynamically adjust the light source parameters, verify and lock the optimal lighting settings;

[0062] Furthermore, initializing the ambient light sensor and evaluating initial lighting conditions includes:

[0063] Deploy and initialize the integrated ambient light sensor, set the measurement frequency and range of the ambient light sensor, and perform an initial assessment of the light intensity and color temperature of the current environment before starting image acquisition, and record the initial lighting conditions.

[0064] Furthermore, dynamically adjusting the light source parameters includes:

[0065] Based on the initial lighting condition assessment results, basic parameters of the light source are set, including brightness, angle, and color temperature. Changes in ambient light are continuously monitored in real-time, and the light source parameters are compensated to maintain consistent lighting conditions. The formula for the lighting compensation function is as follows:

[0066] ;

[0067] in, It is the illumination compensation function. It is the target light intensity, measured in lux. Ambient light intensity at wavelength The measured values ​​are in lux. It's color temperature; It is a correction function that takes into account the effect of different color temperatures on different wavelengths. This function can be expressed as:

[0068] ;

[0069] in, It is an empirical constant that can be determined experimentally. It is a reference wavelength, usually 555nm (the wavelength that the human eye is most sensitive to).

[0070] when When the value is greater than 0, it indicates that the brightness of the light source needs to be increased to compensate for insufficient ambient light.

[0071] when When the value is less than 0, it indicates that the brightness of the light source needs to be reduced to avoid excessive ambient light interference.

[0072] when When the value is 0, it means that the current lighting conditions are already optimal and no adjustment is needed.

[0073] Further verification and locking in the optimal lighting settings include:

[0074] After adjusting the light source parameters, verify whether the lighting quality meets the expected standard through a preset standard test procedure or reference image, and lock the current light source parameter settings to ensure a stable and optimal lighting environment throughout the entire image acquisition process.

[0075] S2: Select a preset wavelength range based on the characteristics of building materials, configure a spectral imaging system and collect image data of building materials to obtain material characterization, perform preliminary processing and image synthesis on the material characterization to obtain a comprehensive spectral image, and extract features from the comprehensive spectral image to obtain a high-quality image dataset;

[0076] Furthermore, the preset wavelength range selected based on the characteristics of building materials includes:

[0077] Based on the characteristics of the building materials, a preset wavelength range is selected, and a high-resolution multispectral camera or hyperspectral camera, along with a tunable filter or linearly variable filter, is set up to select light within a specific wavelength range to enter the camera. The formula for calculating the wavelength range selection is as follows:

[0078] ;

[0079] in, These are the weighting coefficients for each wavelength. It is the material at wavelength The reflectivity of the following It is the average reflectance across all wavelengths. It is the standard deviation of reflectivity; The value range is [-1, 1], which represents the priority of wavelength selection. A positive value indicates that the reflection characteristics at that wavelength are stronger and it is suitable for selection; a negative value indicates that the reflection characteristics at that wavelength are weaker and it is not selected.

[0080] Simultaneously, a weighted composition function is introduced. This is used to synthesize image data from different wavelengths, and the specific formula is as follows:

[0081] ;

[0082] in, It is a weighted composition function. At wavelength The captured image intensity, in grayscale values. These are the weighting coefficients for each wavelength. It is a regulating factor used to control the degree of nonlinear response. It is the intensity of the reference image, usually taken as the median gray value, and N is the number of wavelengths; The value range is [0, 1], which represents the final gray value of each pixel in the synthesized image. The closer the value is to 1, the higher the importance of the pixel in the synthesized image.

[0083] Furthermore, material characterization includes multi-dimensional information reflecting material properties;

[0084] The preliminary processing and image synthesis of the material characterization include:

[0085] Image data of building materials is captured within the preset wavelength range, and the data is initially cleaned and formatted, then stored in a local or cloud database for subsequent processing.

[0086] Furthermore, image synthesis and feature extraction include:

[0087] Image data from different wavelengths are combined into a panchromatic image. The method of combining the images is an existing technology and will not be described in detail here.

[0088] By applying signal processing techniques, key parameters reflecting material properties, including absorptivity, reflectivity, and texture features, are extracted from panchromatic images.

[0089] Texture features include contrast, correlation, energy, and entropy, calculated using the following formula:

[0090] ;

[0091] Where C1 is contrast, C2 is correlation, E1 is energy, and E2 is entropy. These are elements in the gray-level co-occurrence matrix, representing the probability of pixel pairs with pixel values ​​i and j occurring. It is the average gray value. It is the standard deviation.

[0092] S3: Preprocess the high-quality image dataset on the edge device, deploy a deep learning model, use the deep learning model to perform preliminary defect detection on the preprocessed image data, identify and mark various types of defects, and extract local features and frequency domain features;

[0093] Further preprocessing includes:

[0094] Receive high-quality image datasets from multispectral / hyperspectral cameras;

[0095] Perform necessary preprocessing on edge devices, such as noise filtering and size adjustment, to optimize subsequent analysis;

[0096] Deploy lightweight deep learning models (such as MobileNet and Tiny-YOLO), which can run efficiently in resource-constrained environments and quickly complete image preprocessing tasks.

[0097] Furthermore, a lightweight deep learning model is deployed to perform real-time feature extraction on the preprocessed image data; various types of defects are identified and labeled, as shown in the following formula:

[0098] ;

[0099] in, Let F be the probability of the defect existing, W be the model weight matrix, T be the transpose of the weight matrix W, F be the extracted feature vector, and b be the bias term. It is the sigmoid function, used to convert the output into a probability value.

[0100] Specifically, the formula for calculating the sigmoid function is as follows:

[0101] ;

[0102] Where x represents the input parameter;

[0103] Further extraction of local and frequency domain features, including but not limited to edge information, is achieved through methods including but not limited to the Canny edge detection algorithm and Fast Fourier Transform (FFT) to enhance the accuracy of defect detection.

[0104] S4: Based on the preliminary detection results, a classification algorithm is applied to refine the defect types, and the final classification results and their corresponding image data are integrated and transmitted to the cloud to complete the detection.

[0105] Furthermore, based on the preliminary detection results, classification algorithms are applied to further refine the defect types; the classification algorithms include, but are not limited to, support vector machines, random forests, or convolutional neural networks, and this invention does not impose specific limitations.

[0106] The final classification results and their corresponding image data are integrated;

[0107] Transmitted to the cloud via low-latency communication protocols (such as MQTT or CoAP) for further analysis and decision-making to complete the detection.

[0108] Furthermore, this embodiment also provides a product inspection system based on machine vision, including: an illumination compensation module, an image extraction module, a defect classification module, and a final inspection module;

[0109] The illumination compensation module is used to initialize the ambient light sensor and evaluate the initial illumination conditions, dynamically adjust the light source parameters, and verify and lock the optimal illumination settings.

[0110] The image extraction module is used to select a preset wavelength range according to the characteristics of building materials, configure a spectral imaging system and collect image data of building materials to obtain material characterization, perform preliminary processing and image synthesis on the material characterization to obtain a comprehensive spectral image, and perform feature extraction on the comprehensive spectral image to obtain a high-quality image dataset.

[0111] The defect classification module is used to preprocess the high-quality image dataset on the edge device, deploy a deep learning model, use the deep learning model to perform preliminary defect detection on the preprocessed image data, identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results.

[0112] The final detection module is used to refine the defect type based on the preliminary detection results using a classification algorithm, obtain the final classification result, integrate the final classification result and its corresponding image data, and transmit them to the cloud to complete the detection.

[0113] This embodiment also provides a computer device, which may be a terminal, and its internal structure diagram may be as follows. Figure 2 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a machine vision-based product inspection method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0114] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it performs the following steps: initializing the ambient light sensor and evaluating the initial lighting conditions, dynamically adjusting the light source parameters, and verifying and locking the optimal lighting settings.

[0115] A preset wavelength range is selected based on the characteristics of building materials, a spectral imaging system is configured, and image data of the building materials is acquired to obtain material characterization. The material characterization is then preliminarily processed and image synthesized to obtain a comprehensive spectral image. Feature extraction is performed on the comprehensive spectral image to obtain a high-quality image dataset.

[0116] The high-quality image dataset is preprocessed on an edge device, a deep learning model is deployed, and the deep learning model is used to perform preliminary defect detection on the preprocessed image data to identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results.

[0117] Based on the preliminary detection results, a classification algorithm is applied to refine the defect types, and the final classification results are obtained. The final classification results and their corresponding image data are then integrated and transmitted to the cloud to complete the detection.

[0118] Example 2, refer to Figure 1 - Figure 2 This is the second embodiment of the present invention, which provides a product inspection method based on machine vision. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.

[0119] To verify the effectiveness and superiority of the machine vision-based product inspection method proposed in this invention, a large construction company was selected as the test site to conduct defect detection experiments on several commonly used building materials (concrete, steel, and glass). The experimental equipment included a high-resolution multispectral camera, tunable filters, an ambient light sensor, edge computing devices, and a cloud server.

[0120] First, an integrated ambient light sensor was deployed and initialized in a laboratory environment, with a measurement frequency set to once per second and a measurement range covering the 300-800 nm wavelength range. Before image acquisition, the light intensity and color temperature of the current environment were initially assessed, and the initial lighting conditions were recorded. Experimental results showed that the average light intensity under the initial lighting conditions was 500 lux, and the color temperature was 4500 K.

[0121] Based on the initial lighting condition assessment results, the basic parameters of the light source were set, including brightness, angle, and color temperature. Changes in ambient light were continuously monitored in real-time, and the light source parameters were dynamically adjusted using a lighting compensation function. Specifically, the target illuminance was set to 750 lux, and the color temperature was adjusted to 6000 K to ensure consistent lighting quality under different environments. After multiple iterations and optimizations, a stable lighting setting was finally achieved.

[0122] After adjusting the light source parameters, the illumination quality was verified to meet the expected standards using a preset standard test procedure or reference image. A series of standard test images were used in the experiment to compare image quality under different lighting settings. Finally, an optimal set of parameters was selected and locked to ensure consistency and stability in subsequent image acquisition.

[0123] Next, preset wavelength ranges were selected based on the characteristics of the building materials. For concrete, the visible light band of 400-700 nm was chosen; for steel, the near-infrared band of 800-1100 nm was selected; and for glass, the ultraviolet-visible band of 300-500 nm was selected. A high-resolution multispectral camera and tunable filters were configured to capture image data within these specific wavelength ranges, ensuring the acquisition of spectral information that best reflects the material properties.

[0124] Image data of building materials was captured within a preset wavelength range, and the data underwent preliminary data cleaning and formatting before being stored in a local database. Subsequently, image data from different wavelengths were synthesized into a panchromatic image, and signal processing techniques were applied to extract key parameters such as absorptivity, reflectivity, and texture features. During the experiment, a total of 100 concrete images, 80 steel images, and 60 glass images were acquired, and each image underwent rigorous preprocessing and feature extraction steps.

[0125] High-quality image datasets are preprocessed on edge devices to remove noise and resize images, ensuring the quality of the data input to the deep learning model. The lightweight deep learning model MobileNetV2 is deployed, leveraging its high efficiency to quickly complete image preprocessing, feature extraction, and preliminary classification tasks in resource-constrained environments. In experiments, the model successfully identified and labeled various types of defects, including cracks, voids, and surface inhomogeneities, and further extracted local and frequency domain features, enhancing the accuracy of defect detection.

[0126] Based on the preliminary detection results, a classification algorithm was applied to refine the defect types. The final classification results and their corresponding image data were integrated and transmitted to the cloud via a low-latency communication protocol. In the experiment, the classification algorithm successfully distinguished between different types and degrees of defects, providing detailed classification reports. All data was securely transmitted to the cloud for remote monitoring and data analysis.

[0127] Table 1: Comparison of image quality before and after illumination condition optimization

[0128]

[0129] Table 2: Comparison of Defect Detection Results for Different Materials

[0130]

[0131] Analysis of the data in the two tables above clearly shows that the present invention has significant advantages and innovations in many aspects.

[0132] Table 1 shows the image quality comparison before and after lighting condition optimization. The optimized lighting conditions significantly improved the image contrast and sharpness scores, especially for concrete, steel, and glass, where contrast increased by 25%, 25%, and 25% respectively, and the sharpness score improved from 6 to 9. This not only improved the overall image quality but also greatly increased the accuracy of defect identification from 70%-80% to 90%-95%. Furthermore, processing time was reduced, indicating that the optimized lighting conditions helped improve the system's response speed and efficiency.

[0133] Table 2 compares the defect detection performance of different materials within a preset wavelength range and across the entire wavelength band. The results show that selecting an appropriate wavelength range can more accurately reflect material properties, thereby improving the accuracy of defect identification. For example, concrete has an absorption rate of 30% and a reflectance of 70% in the 400-700 nm wavelength range, while its absorption rate and reflectance across the entire wavelength band are 25% and 75%, respectively. Correspondingly, the defect identification accuracy increased from 85% to 90%, and the processing time decreased from 140 ms to 120 ms. This indicates that selecting a preset wavelength range based on material properties is one of the key factors in improving detection accuracy.

[0134] By deploying a lightweight deep learning model on edge devices, efficient real-time processing capabilities were achieved. Experimental data shows that the MobileNetV2 model can quickly complete image preprocessing, feature extraction, and preliminary classification tasks in resource-constrained environments, identifying and labeling various types of defects. Compared to traditional detection methods, this model not only improves the speed of defect detection but also enhances its accuracy, especially in complex scenarios.

[0135] The application of classification algorithms to refine defect types further improves the accuracy and detail of classification results. In experiments, the classification algorithm successfully distinguished between defects of different types and degrees, providing detailed classification reports. Data is transmitted to the cloud via a low-latency communication protocol, ensuring secure data transmission and centralized management, facilitating remote monitoring and data analysis. This not only enhances the overall intelligence level of the detection system but also provides a reliable basis for subsequent quality control and repair work.

[0136] In summary, this invention, through a series of meticulously designed steps, solves the problems of uneven illumination, unreasonable wavelength selection, and insufficient real-time processing capabilities existing in the prior art, achieving high-precision and high-efficiency product defect detection. Experimental data fully demonstrates the role and beneficial effects of this invention, showcasing its innovation and advantages in practical applications.

[0137] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

[0138] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0139] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0140] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0141] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0142] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0143] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A product inspection method based on machine vision, characterized in that, include: Initialize the ambient light sensor and evaluate the initial lighting conditions, dynamically adjust the light source parameters, verify and lock the optimal lighting settings; A preset wavelength range is selected based on the characteristics of building materials, a spectral imaging system is configured, and image data of the building materials is acquired to obtain material characterization. The material characterization is then preliminarily processed and image synthesized to obtain a comprehensive spectral image. Feature extraction is performed on the comprehensive spectral image to obtain a high-quality image dataset. The high-quality image dataset is preprocessed on an edge device, a deep learning model is deployed, and the deep learning model is used to perform preliminary defect detection on the preprocessed image data to identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results. Based on the preliminary detection results, a classification algorithm is applied to refine the defect types, and the final classification results are obtained. The final classification results and their corresponding image data are then integrated and transmitted to the cloud to complete the detection. The dynamic adjustment of light source parameters includes: Based on the initial lighting condition assessment results, basic parameters of the light source are set, including brightness, angle, and color temperature. Changes in ambient light are continuously monitored in real-time, and the light source parameters are compensated accordingly. The calculation formula for the lighting compensation function is as follows: ; in, It is the illumination compensation function. It is the target light intensity. Ambient light intensity at wavelength The measured values ​​below, It's color temperature. It is a correction function, set by taking into account the influence of different color temperatures on different wavelengths. The calculation formula of this function is as follows: ; in, It is an empirical constant, determined through experiments. It is a reference wave; The selection of a preset wavelength range based on the characteristics of building materials includes: Select a preset wavelength range based on the characteristics of the building materials, and set up a high-resolution multispectral camera or hyperspectral camera and a tunable filter or linear variable filter. The calculation formula for the wavelength range selection is as follows: ; in, These are the weighting coefficients for each wavelength. It is the material at wavelength The reflectivity of the following It is the average reflectance across all wavelengths. It is the standard deviation of reflectivity; Simultaneously, a weighted composition function is introduced. It is used to synthesize image data from different wavelengths, and the calculation formula is as follows: ; in, It is a weighted composition function. At wavelength The intensity of the captured image, These are the weighting coefficients for each wavelength. It is a regulating factor used to control the degree of nonlinear response. It is the intensity of the reference image, and N is the number of wavelengths.

2. The product inspection method based on machine vision as described in claim 1, characterized in that, The initial lighting conditions for the assessment include: Deploy and initialize the integrated ambient light sensor, set the measurement frequency and range of the ambient light sensor, and perform an initial assessment of the light intensity and color temperature of the current environment before starting image acquisition to obtain the initial lighting condition assessment results and record the initial lighting conditions.

3. The product inspection method based on machine vision as described in claim 2, characterized in that, The verification and locking of the optimal lighting settings includes: After adjusting the light source parameters, verify whether the lighting quality meets the expected standard through a preset standard test procedure or reference image, and lock the current light source parameter settings.

4. The product inspection method based on machine vision as described in claim 3, characterized in that, The material characterization includes multi-dimensional information reflecting the material properties; The preliminary processing and image synthesis of the material characterization include: Image data of building materials is captured within a preset wavelength range, and the data is initially cleaned and formatted before being stored in a local or cloud database. Image synthesis and feature extraction include: Image data from different wavelengths are combined into a single panchromatic image; Signal processing techniques are used to extract key parameters reflecting material properties from panchromatic images, including absorptivity, reflectivity, and texture features. The texture features include contrast, correlation, energy, and entropy, calculated using the following formula: ; Where C1 is contrast, C2 is correlation, E1 is energy, and E2 is entropy. These are elements in the gray-level co-occurrence matrix, representing the probability of pixel pairs with pixel values ​​i and j occurring. It is the average gray value. It is the standard deviation.

5. The product inspection method based on machine vision as described in claim 4, characterized in that, The identification and labeling of various types of defects includes: Use a deployed lightweight deep learning model to perform real-time feature extraction on preprocessed image data; Identify and label various types of defects, using the following formula: ; in, Let F be the probability of the defect existing, W be the model weight matrix, T be the transpose of the weight matrix W, F be the extracted feature vector, and b be the bias term. It is the sigmoid function, used to convert the output into a probability value.

6. A product inspection system based on machine vision, based on the product inspection method based on machine vision according to any one of claims 1 to 5, characterized in that, include: The system includes a lighting compensation module, an image extraction module, a defect classification module, and a final detection module. The illumination compensation module is used to initialize the ambient light sensor and evaluate the initial illumination conditions, dynamically adjust the light source parameters, and verify and lock the optimal illumination settings. The image extraction module is used to select a preset wavelength range according to the characteristics of building materials, configure a spectral imaging system and collect image data of building materials to obtain material characterization, perform preliminary processing and image synthesis on the material characterization to obtain a comprehensive spectral image, and perform feature extraction on the comprehensive spectral image to obtain a high-quality image dataset. The defect classification module is used to preprocess the high-quality image dataset on the edge device, deploy a deep learning model, use the deep learning model to perform preliminary defect detection on the preprocessed image data, identify and label various types of defects, and extract local features and frequency domain features to obtain preliminary detection results. The final detection module is used to refine the defect type based on the preliminary detection results using a classification algorithm, obtain the final classification result, integrate the final classification result and its corresponding image data, and transmit them to the cloud to complete the detection.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the product inspection method based on machine vision according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the product inspection method based on machine vision as described in any one of claims 1 to 5.