A light source band automatic recommendation method and system for machine vision
By using a high-angle ring light source and an adversarial network to generate the optimal light source band in the machine vision system, the problem of low efficiency in light source band selection is solved, achieving efficient and accurate defect detection and enhancing the system's adaptability and versatility.
Patent Information
- Application Number
- CN202411730598.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-11-29
AI Technical Summary
Existing machine vision systems have low efficiency, limited adaptability and versatility when selecting light source bands, which affects the accuracy of defect detection.
By controlling the light source of a color industrial camera in a dark room using a high-angle ring light source, adjusting the hue using HSV mode, generating the optimal light source band using an adversarial network, and selecting the light source based on adversarial equalization of texture feature vectors, an automatic light source band recommendation system is constructed.
It improves the accuracy and efficiency of defect detection, reduces manual intervention, enhances the adaptability and versatility of the system, ensures the accuracy and reliability of detection results, and reduces production costs.
Smart Images

Figure CN119625241B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision, and in particular to a method and system for automatically recommending light source bands for machine vision. Background Art
[0002] In machine vision, the choice of light source is crucial, directly impacting image quality and system performance. Selecting the correct light source wavelength helps improve image quality and information extraction accuracy. Different light source wavelengths have varying effects on the reflection, absorption, and scattering of target objects. Therefore, in different application scenarios, it is necessary to select the appropriate light source wavelength for the specific task to achieve optimal imaging results. Traditional methods typically rely on experience and experimentation to determine the optimal light source wavelength, which is subject to subjectivity and uncertainty. Therefore, to overcome the problems of traditional light source wavelength selection methods, automated methods can be used to recommend the optimal light source wavelength. These automated methods can be based on machine learning, data-driven approaches, or physical models and simulations.
[0003] Different industries have different requirements for light source color. In the field of medical imaging, for imaging technologies such as X-rays, CT scans, and MRI, light source color requirements are usually not the primary consideration. However, in some cases, such as when used to display and interpret image results, a light source with natural colors and consistent color temperature may be more helpful for doctors to make accurate diagnoses. In this case, a common approach is to select a light source with a high color rendering index (CRI) to ensure that the image colors are true and reliable. In the field of industrial inspection, the color of the light source is crucial for detecting defects, surface features, etc. of the target object. For example, in metal surface inspection, a blue light source with high contrast may be selected to highlight surface defects; while in food packaging inspection, a near-infrared light source may be selected to penetrate the packaging material to detect foreign matter.
[0004] Chinese invention patent CN112232399A discloses a method for detecting automotive seat defects based on multi-feature fusion machine learning. This method extracts color and texture features from multiple categories of automotive seat materials and trains a multi-feature fusion classifier to identify material categories. Based on the classification results, defect detection is performed in conjunction with blob analysis to determine the presence of damage or stains. An industrial robot receives the defect detection results, grabs the workpiece, and automatically sorts it into designated areas for abnormal, damaged, stained, and qualified materials. This method is applicable to materials of different colors and materials, eliminating the need for multi-template matching. The industrial robot can automatically sort the workpieces into designated areas based on the detection results. Training the multi-feature fusion machine learning model requires significant computing resources and time, especially for high-precision inspection tasks, which may require the use of complex deep learning models. Furthermore, changes in the production environment or the introduction of new materials may require retraining or adjustment of the model, increasing the difficulty and cost of system maintenance. Furthermore, this patented method primarily focuses on the subsequent detection phase of the defect detection method, lacking the initial defect collection process.
[0005] Chinese invention patent CN105806849A discloses a machine vision-based system and method for detecting surface defects in automotive seats. The system includes a light source, a single-chip numerical control device, an image acquisition device, an image processing and analysis platform, a database system, and hardware. After acquiring images, the system uses a combination of machine vision algorithms, such as color recognition and template matching, to determine whether the seat has defects. The key to this patented visual defect detection solution lies in using a database system to perform multi-template matching on the detection image. The system sequentially calculates the similarity with each template in each search space to determine the detection image type, then obtains the color and material characteristics of the detection image and compares them with the template data. Because automotive seats come in a wide variety of shapes, colors, and other materials, creating a template for each material and then performing multi-template matching on each material is inefficient. Therefore, this patented method can only be used in scenarios with a limited number of defect types or where efficiency requirements are low. Furthermore, this method has a high initial cost and requires a large number of cameras, resulting in a high initial investment in the machine vision system. Regarding adaptability, seat surfaces with different materials, colors, and textures may require different light sources and detection strategies, potentially limiting the system's adaptability and versatility. In terms of detection range, the system may have limited detection capabilities for some complex, hard-to-detect defects, such as very fine cracks or slight color differences. Furthermore, factors such as ambient light fluctuations, vibration, and dust may affect the stability of image acquisition and processing, thereby affecting the accuracy of inspection results. Summary of the Invention
[0006] In response to the problems that existing machine vision systems have low efficiency, limited adaptability and versatility in selecting light source bands, which affects the accuracy of defect detection, the present invention provides a method and system for automatically recommending light source bands for machine vision.
[0007] In order to solve the above problems, the present invention adopts the following technical solutions:
[0008] A method for automatically recommending light source bands for machine vision, the method comprising the following steps:
[0009] Step 1: Setting parameters for a color industrial camera, providing the camera with a high-angle ring light source in a dark room environment, converting the light source control to HSV mode, and adjusting the hue of the high-angle ring light source according to a preset step size. Each time the hue is adjusted, the color industrial camera captures an image of the target object, and the saturation and brightness of each image remain unchanged.
[0010] Step 2: Label all target object images captured by the color industrial camera according to defect categories;
[0011] Step 3: For each defect category, segment the marked defect part from the target image to obtain the corresponding defect image;
[0012] Step 4: Convert the defect image into a grayscale image and calculate the grayscale co-occurrence matrix of the grayscale image. Use the grayscale co-occurrence matrix to estimate the texture features of the target image, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. Construct a texture feature vector based on each texture feature, and calculate the sample average of the texture feature vector of the defect image, which is recorded as AVG_base.
[0013] Step 5: The color industrial camera captures an image of the target object under white light, and inputs the image of the target object under white light into the generator in the adversarial network to generate virtual light sources of different colors. The RGB colors of the virtual light sources of different colors are assigned to the image of the target object under white light to generate RGB images under different virtual lighting conditions. The average value of the texture feature vector of each generated RGB image is calculated and recorded as AVG_check;
[0014] Step 6: Use the discriminator of the adversarial network to determine whether the sample average value AVG_base obtained in step 4 and the average value AVG_check obtained in step 5 reach a mutually adversarial Nash equilibrium state. If so, the virtual light source generated by the generator is determined to be the optimal light source, and the RGB value of the virtual light source is output. The output RGB value is used as the recommended light source band for the corresponding defect category. The high-angle ring light source controls the brightness and mixing ratio of LEDs of different colors according to the recommended light source band.
[0015] A system for automatically recommending light source bands for machine vision, the system comprising a sample placement table, a shading device, a color industrial camera, a high-angle ring light source, a digital constant voltage controller, and an image processing platform. The sample placement table is used to place a target object. The shading device provides a darkroom environment for the color industrial camera to capture an image of the target object. The high-angle ring light source provides lighting conditions for the color industrial camera to capture the target object image in the darkroom environment, and the color industrial camera sends the captured target object image to the image processing platform. The digital constant voltage controller is connected to the high-angle ring light source and the image processing platform, respectively. Under the control of the image processing platform, the digital constant voltage controller adjusts the brightness and mixing ratio of different color LEDs of the high-angle ring light source. The image processing platform is configured to execute the steps of the method for automatically recommending light source bands for machine vision as described above.
[0016] The beneficial effects of the present invention are:
[0017] The present invention provides a method and system for automatically recommending light source wavelength bands for machine vision. This method and system automatically selects the spectral range of the light source used to capture images. This spectral range improves the visibility of defects, maximizing image information acquisition during defect detection while reducing manual intervention and optimizing time. By adapting to different light source environments and conditions, the present invention calculates texture and color differences of defective parts to recommend an optimal light source for capturing target samples, significantly improving the accuracy of defect detection in target samples. This is highly valuable for implementing intelligent, adaptive machine vision systems.
[0018] At the same time, the present invention photographs the target sample in a dark box environment, avoiding the interference of stray light and no secondary defects caused by environmental factors, thereby improving the accuracy of the experimental results and the reliability of the experiment.
[0019] The present invention combines the previous image acquisition part with the subsequent image processing algorithm to provide a method and system for automatically recommending light source bands. The entire process is relatively complete, greatly improving the efficiency of target object defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flowchart of a method for automatically recommending light source wavelength bands according to one embodiment of the present invention;
[0021] Figure 2 This is a schematic structural diagram of a light source band automatic recommendation system according to another embodiment of the present invention;
[0022] Figure 3 is a structural schematic diagram of a shading device;
[0023] Figure 4 The experimental images collected.
[0024] Explanation of the accompanying symbols: 1. Sample placement table; 2. Shading device; 2-1. Industrial aluminum profile frame; 2-2. Black flocked light-absorbing cloth; 2-3. Acrylic plate; 2-4. Black optical light-absorbing paper; 3. Color industrial camera; 4. High-angle ring light source; 5. Digital constant voltage controller; 6. Image processing platform; 7. Camera holder. DETAILED DESCRIPTION
[0025] In order to make the purpose and technical solution of the present invention clearer, the technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0026] In one embodiment, Figure 1 As shown, this embodiment provides a method for automatically recommending light source bands for machine vision, which specifically includes the following steps 1 to 6.
[0027] Step 1: Parameters are set for the color industrial camera 3. A high-angle ring light source 4 provides darkroom lighting for the color industrial camera 3. The HSV model is used for data acquisition. Specifically, the high-angle ring light source 4 transforms the light source control into an HSV model. The HSV model divides the hue into a circular ring from 0° to 360°, representing the color progression from red, yellow, green, cyan, blue, to purple. Next, the hue of the high-angle ring light source 4 is adjusted according to a preset step size. Each time the hue changes according to the HSV model, the color industrial camera 3 is driven to capture an image of the same defective target object. During this process, the saturation and brightness of each image captured by the color industrial camera 3 remain unchanged. The target images of different defects captured by the color industrial camera 3 are stored in a designated folder. The preset step size in this embodiment can be selected based on actual needs and is not limited here. For example, the preset step size ranges from 5 to 10 degrees.
[0028] Step 2: Use the target detection and annotation tool LabelImg to label all target object images captured by color industrial camera 3 according to defect categories. For example, for several typical indicators of seat inspection: pinholes, scratches, stains, foreign objects, and wrinkles, the five defect categories are labeled as Pinholes, scratches, stains, foreign objects, and wrinkles respectively.
[0029] Step 3: For each defect category, segment the marked defect part from the target object image to obtain the corresponding defect image. In the XML file, Xmin, Ymin, Xmax, and Ymax are usually used to define a bounding box. Xmin represents the x-coordinate of the upper left corner of the bounding box, indicating the leftmost position of the bounding box in the image, and is used to mark the position of the target object in the image; Ymin represents the y-coordinate of the upper left corner of the bounding box, indicating the uppermost position of the bounding box in the image; Xmax represents the x-coordinate of the lower right corner of the bounding box, indicating the rightmost position of the bounding box in the image; Ymax represents the y-coordinate of the lower right corner of the bounding box, indicating the lowermost position of the bounding box in the image. Through the four values of Xmin, Ymin, Xmax, and Ymax, a rectangular area can be uniquely determined to represent the range of the target object in the image. Within this range, the marked defect part is segmented from the sample image to obtain a defect image, which is denoted as I n , n=1,2,…N, where N is the total number of target object images captured by the color industrial camera 3 under this defect category.
[0030] Step 4: Due to the defective image I n It is a color HSV image, so this step requires first transforming the defect image I n The image is converted to grayscale and its gray-level co-occurrence matrix (GLCM) is calculated. The calculated GLCM is then used to estimate various texture features of the corresponding target image, including contrast, heterogeneity, homogeneity, energy, and correlation. Contrast, dissimilarity, homogeneity, energy, and correlation are calculated. These features work together to comprehensively describe the image texture, including its roughness, uniformity, repeatability, and directionality. Multiple texture features are fused into a texture feature vector, denoted as (Contrast, Dissimilarity, Homogeneity, Energy, Ccorrelation). The sample average of the texture feature vector (Contrast, Dissimilarity, Homogeneity, Energy, Ccorrelation) is calculated by calculating the average value F of all features in the texture feature vector (Contrast, Dissimilarity, Homogeneity, Energy, Ccorrelation). AVG_base is the sample average of the texture feature vector, denoted as (AVG_base), which takes the form of (F, red, green, blue).
[0031] Step 5: The color industrial camera 3 also separately collects one image of the target object under white light and one under completely dark conditions. The target object image under white light is input into the generator in the adversarial network. The generator in the adversarial network generates virtual light sources of different colors, and the R, G, and B colors of the virtual light sources of different colors are assigned to the target object image under white light. Under the virtual light source and virtual illumination, each target object image under white light generates an RGB image under different virtual illumination. The average value of the texture feature vector of each generated RGB image is calculated and recorded as AVG_check.
[0032] Similar to obtaining the sample average AVG_base of the texture feature vector, in step 5, after generating the RGB image, the RGB image is first converted into a grayscale image, and the grayscale co-occurrence matrix of the grayscale image is calculated. The grayscale co-occurrence matrix is then used to estimate various texture features corresponding to the RGB image, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. A texture feature vector is constructed based on each texture feature, and the average value of the texture feature vector of the RGB image is obtained by calculating the average value of all features in the texture feature vector, which is recorded as AVG_check, and the form of AVG_check is the same as that of AVG_base.
[0033] Step 6: Use the adversarial network to select the optimal light source. In this step, the discriminator of the adversarial network is used to determine whether the sample average value AVG_base obtained in step 4 and the average value AVG_check obtained in step 5 have reached a mutually antagonistic and Nash equilibrium state to evaluate whether the optimal light source has been selected. When the loss function of the network is in a constant state, it means that the sample average value AVG_base and the average value AVG_check have reached a mutually antagonistic and Nash equilibrium state. At this time, the virtual light source generated by the generator is determined to be the optimal light source, and the RGB value of the virtual light source is output. The output RGB value is used as the recommended light source band. The high-angle ring light source 4 controls the brightness and mixing ratio of LEDs of different colors according to the recommended light source band. If the loss function of the network is not in a constant state, an optimal RGB value that has been generated is output.
[0034] The automatic light source band recommendation method proposed in this embodiment uses a process and algorithm to select an appropriate light source. Combining multiple extracted features, the algorithm calculates the average value AVG_check of the texture feature vector of the generated RGB image and the sample average value AVG_base of the texture feature vector of the defect image through weighted or fusion methods. Machine learning or deep learning models are then used to achieve a Nash equilibrium through adversarial networks, ultimately outputting RGB light source values suitable for defect detection. This results in a light source band for machine vision, improving the efficiency and accuracy of defect detection. Using extensive experimental data, the model is trained to learn which light source band provides the best detection results under different feature conditions, and the final RGB value output corresponds to the defect category.
[0035] In another embodiment, Figure 2 As shown, this embodiment provides an automatic light source band recommendation system for machine vision, which mainly includes a sample placement table 1, a shading device 2, a color industrial camera 3, a high-angle ring light source 4, a digital constant voltage controller 5 and an image processing platform 6.
[0036] The sample placement table 1 is used to place a target object or sample with defects, and is arranged opposite to the color industrial camera 3 .
[0037] The sample placement table 1 is placed inside the shading device 2. The shading device 2 is used to provide the required dark room environment for the color industrial camera 3 to capture the image of the target object, avoiding the interference of natural light.
[0038] The color industrial camera 3 is used to capture images of the target object and transmit the target object images to the image processing platform 6. The color industrial camera 3 is nested and fixed with the high-angle ring light source 4 directly above the target object, and collects image data of the target object on the sample placement platform 1 directly below.
[0039] The high-angle ring light source 4 is used to provide lighting conditions in a dark room environment for the color industrial camera 3 to capture the target object image. It can provide clear and uniform lighting conditions, which is helpful for detecting and identifying defects on the surface of the material.
[0040] The digital constant voltage controller 5 is connected to the high-angle ring light source 4 and the image processing platform 6. The digital constant voltage controller 5 is used to adjust and control the color of the high-angle ring light source 4, collect, transmit, and store data, and perform related control operations. The digital constant voltage controller 5 is connected to the high-angle ring light source 4 and can adjust the brightness and mixing ratio of the different colored LEDs in the high-angle ring light source 4 according to the different background colors of the defect samples and the different colors of the defects. This improves the contrast of features such as pinholes, scratches, stains, foreign matter, and wrinkles on the sample surface, allowing the color industrial camera 3 to better capture the defect features.
[0041] The high-angle ring light source 4 is a multi-color light source system composed of multiple LEDs (Light Emitting Diodes) that can provide light output in multiple colors. It usually includes three types of LEDs: red (R), green (G) and blue (B) to achieve a wide range of color selection and mixing. The brightness and color intensity of each LED color can be independently adjusted to achieve the desired color effect. Under the control of the image processing platform 6, the digital constant voltage controller 5 can control and adjust the brightness and mixing ratio of LEDs of different colors, so that a variety of colors and color temperatures can be produced. The high-angle ring light source 4 is an HSV model, which divides the color tone into a circle from 0° to 360°, representing the color change from red, yellow, green, cyan, blue to purple.
[0042] like Figure 3 As shown, the shading device 2 includes an industrial aluminum profile frame 2-1, black flocked light-absorbing cloth 2-2, an acrylic plate 2-3, and black optical light-absorbing paper 2-4. Multiple acrylic plates 2-3 are sealed to the industrial aluminum profile frame 2-1 using hot melt adhesive. Then, the black optical light-absorbing paper 2-4 is pasted on both sides of each acrylic plate 2-3 to create a completely dark environment and completely block interference from external natural light sources. The remaining side of the industrial aluminum profile frame 2-1 serves as an entrance and exit for sample placement. This entrance is sealed with black flocked light-absorbing cloth 2-2, ultimately forming a cavity for accommodating the sample placement table 1 and the high-angle ring light source 4. The shading device 2 in this embodiment can solve the problem of effective image acquisition and processing in a dark environment, achieving efficient and reliable image acquisition and processing in a dark environment.
[0043] The color industrial camera 3 and the high-angle ring light source 4 are nested perpendicular to the sample placement table 1. The color industrial camera 3 is fixed on the acrylic plate 2-3 on the top of the shading device 2 through the camera holder 7. When the color of the high-angle ring light source 4 begins to change, the color industrial camera 3 takes a picture of the target object every time the light source color changes, and then stores the captured image in the image processing platform 6.
[0044] Furthermore, the system of this embodiment further includes an expansion dock, and the image processing platform 6 is connected to the color industrial camera 3 via the expansion dock to expand the number of peripheral interfaces.
[0045] After the image processing platform 6 receives the target image captured by the color industrial camera 3, the image processing platform 6 is configured to execute the steps of the automatic light source band recommendation method for machine vision described in the above embodiment. The specific steps are as follows:
[0046] Step 1: The image processing platform 6 sets the parameters of the color industrial camera 3 through the camera driver, and adjusts the hue of the high-angle ring light source 4 according to the preset step size through the digital constant voltage controller 5. When the color of the light source changes according to the HSV light source, the image processing platform 6 drives the color industrial camera 3 to take pictures each time the adjustment changes, and collects an image of the target object with the same defect. During this process, the saturation and brightness of each image taken by the color industrial camera 3 remain unchanged; and the target object images collected by the color industrial camera are stored in a designated folder. In this embodiment, the preset step size can range from 5 degrees to 10 degrees.
[0047] Step 2: The image processing platform 6 uses the object detection and annotation tool LabelImg to label all target object images captured by the color industrial camera 3 according to defect categories. For example, for several typical indicators of seat inspection: pinholes, scratches, stains, foreign objects, and wrinkles, the five defect categories are labeled as Pinholes, Scratches, Stains, ForeignObjects, and Wrinkles respectively;
[0048] Step 3: For each defect category, segment the marked defect part from the target object image to obtain the corresponding defect image; in the XML file, Xmin, Ymin, Xmax, and Ymax are usually used to define a bounding box. Xmin represents the x-coordinate of the upper left corner of the bounding box, indicating the leftmost position of the bounding box in the image, and is used to mark the position of the target object in the image; Ymin represents the y-coordinate of the upper left corner of the bounding box, indicating the uppermost position of the bounding box in the image; Xmax represents the x-coordinate of the lower right corner of the bounding box, indicating the rightmost position of the bounding box in the image; Ymax represents the y-coordinate of the lower right corner of the bounding box, indicating the lowermost position of the bounding box in the image. Through the four values of Xmin, Ymin, Xmax, and Ymax, a rectangular area can be uniquely determined to represent the range of the target object in the image. Within this range, the marked defect part is segmented from the sample image to obtain a defect image, which is denoted as I n , n=1,2,…N, where N is the total number of target object images captured by the color industrial camera 3 under this defect category;
[0049] Step 4: Due to the defective image I n It is a color HSV image, so this step requires first transforming the defect image I nConvert to a grayscale image and calculate the Gray-Level Co-occurrence Matrix (GLCM) of the converted grayscale image. Then use the calculated GLCM to estimate various texture features of the corresponding target image, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. By calculating Contrast, Dissimilarity, Homogeneity, Energy, and Correlation, these features work together to fully describe the characteristics of the image texture, including its roughness, uniformity, repeatability, and directionality. Fusion of multiple texture features into a texture feature vector, denoted as (Contrast, Dissimilarity, Homogeneity, Energy, Ccorrelation), by calculating the average value F of all features in the texture feature vector (Contrast, Dissimilarity, Homogeneity, Energy, Ccorrelation), the sample average value of the texture feature vector is obtained, denoted as AVG_base, and the form of AVG_base is (F, red, green, blue).
[0050] Step 5: The color industrial camera 3 also separately collects one target object image under white light and one under completely dark conditions. Only the target object image under white light is selected and input into the generator in the adversarial network. The generator in the adversarial network generates virtual light sources of different colors, and the R, G, and B colors of the virtual light sources of different colors are assigned to the target object image under white light. Under the virtual light source and virtual illumination, each target object image under white light generates an RGB image under different virtual illumination. The average value of the texture feature vector of each generated RGB image is calculated and recorded as AVG_check;
[0051] Similar to obtaining the sample average AVG_base of the texture feature vector, in step 5, after generating the RGB image, first convert the RGB image into a grayscale image, calculate the grayscale co-occurrence matrix of the grayscale image, and then use the grayscale co-occurrence matrix to estimate the texture features of the corresponding RGB image, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. A texture feature vector is constructed based on each texture feature, and then the average value of the texture feature vector of the RGB image is obtained by calculating the average value of all features in the texture feature vector, which is recorded as AVG_check, and the form of AVG_check is the same as that of AVG_base;
[0052] Step 6: Use the adversarial network to select the optimal light source. In this step, the adversarial network's discriminator determines whether the sample average value AVG_base obtained in step 4 and the average value AVG_check obtained in step 5 have reached a mutually antagonistic, Nash equilibrium state to evaluate whether the optimal light source has been selected. When the network's loss function is in a constant state, it indicates that the sample average value AVG_base and the average value AVG_check have reached a mutually antagonistic, Nash equilibrium state. At this time, the virtual light source generated by the generator is the optimal light source, and the RGB value of the virtual light source is output. The output RGB value is used as the recommended light source band for the corresponding defect category. The image processing platform 6 outputs the optimal RGB value, i.e., the recommended light source band, to the digital constant voltage controller 5. The digital constant voltage controller 5 controls the high-angle ring light source 4 to control the brightness and mixing ratio of different color LEDs according to the recommended light source band to achieve the optimal light source selection. If the loss function is not in a constant state, an already generated optimal RGB value is output.
[0053] The following is a combination of specific experimental data to illustrate the technical effects of the present invention. With a step size of 10 degrees, the hue of the high-angle ring light source 4 is adjusted from 0 to 360 degrees, and the color industrial camera 3 is used to collect 36 color images. In addition, the color industrial camera 3 separately captures one image of the target object in white light and in complete darkness. A total of 38 images are collected at one time for one sample. Figure 4 As shown, the sample average value AVG_base (texture, red, green, blue) of the obtained texture feature vector is (2, 14, 12, 16), and the average value AVG_check (texture, red, green, blue) of the texture feature vector recommended by the simulated light source is (3, 15, 17, 14), so the recommended calculated value is the color channel of (3, 15, 17, 14), that is, the most recommended color value is R = 255, G = 0, B = 42. This color value is transmitted to the digital constant voltage controller 5, so that this light source value is selected to shoot similar samples in the future.
[0054] The present invention can improve detection accuracy and reliability and enhance adaptability. Different detection tasks and detected objects behave differently under different light source bands. By automatically recommending suitable light source bands, the contrast and clarity of the image can be maximized, details can be enhanced, and the accuracy and reliability of detection can be improved. By selecting the most suitable light source band, false detections and missed detections caused by inappropriate lighting can be significantly reduced, thereby ensuring the accuracy of the detection results.
[0055] Furthermore, this invention improves the efficiency and automation of machine vision systems, reducing reliance on human expertise. By automatically recommending light source wavelengths, the system improves automation and reduces the need for operator expertise. The automatic light source wavelength recommendation system can dynamically adjust the wavelength based on the real-time detection environment and the characteristics of the object being measured, thereby improving detection efficiency and flexibility.
[0056] The present invention can adapt to a variety of objects and scenes, and can automatically recommend light source bands, making the machine vision system suitable for detecting objects of different colors, materials, and surfaces, thereby enhancing the versatility and adaptability of the machine vision system. According to environmental changes, the light source band can be automatically adjusted according to changes in ambient light, thereby ensuring that stable detection results can be obtained under different environmental conditions. Reduce trial and error costs. Traditional methods require a lot of trials and adjustments to determine the optimal light source band. The automatic recommendation method reduces these trial and error processes and reduces the waste of time and resources. By optimizing the light source band, the success rate and efficiency of detection are improved, and the rework and defective rate caused by detection errors are reduced, which indirectly reduces production costs.
[0057] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned 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 specification.
[0058] The above-described embodiments merely illustrate several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person skilled in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the patent for this invention shall be determined by the appended claims.
Claims
1. A method for automatically recommending light source bands for machine vision, characterized in that: The following steps are involved: Step 1: Setting parameters for a color industrial camera (3), providing the color industrial camera (3) with a high-angle ring light source (4) under the lighting conditions of a dark room, converting the light source control into an HSV mode, adjusting the hue of the high-angle ring light source (4) according to a preset step length, and each time the hue is adjusted, the color industrial camera (3) captures an image of the target object, and the saturation and brightness of each image remain unchanged; Step 2: labeling all target object images captured by the color industrial camera (3) according to defect categories; Step 3: For each defect category, segment the marked defect part from the target image to obtain the corresponding defect image; Step 4: Convert the defect image into a grayscale image and calculate the grayscale co-occurrence matrix of the grayscale image. Use the grayscale co-occurrence matrix to estimate the texture features of the target image, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. Construct a texture feature vector based on each texture feature, and calculate the sample average of the texture feature vector of the defect image, which is recorded as AVG_base. Step 5: The color industrial camera (3) captures the target image under white light, and inputs the target image under white light into the generator in the adversarial network to generate virtual light sources of different colors, and assigns the RGB colors of the virtual light sources of different colors to the target image under white light to generate RGB images under different virtual illuminations. The average value of the texture feature vector of each generated RGB image is calculated and recorded as AVG_check; Step 6: Through the discriminator of the adversarial network, determine whether the sample average value AVG_base obtained in step 4 and the average value AVG_check obtained in step 5 reach a mutually adversarial and Nash equilibrium state. If so, it is determined that the virtual light source generated by the generator is the optimal light source, and the RGB value of the virtual light source is output. The output RGB value is used as the recommended light source band under the corresponding defect category. The high-angle ring light source (4) controls the brightness and mixing ratio of LEDs of different colors according to the recommended light source band.
2. The method for automatically recommending light source wavelength bands for machine vision according to claim 1, characterized in that: In step 5, after generating RGB images under different virtual illuminations, the RGB images are converted into grayscale images, and the grayscale co-occurrence matrix of the grayscale images is calculated. The grayscale co-occurrence matrix is used to estimate various texture features of the RGB images, including contrast features, heterogeneity features, homogeneity features, energy features, and correlation features. A texture feature vector is constructed based on each texture feature.
3. The method for automatically recommending light source bands for machine vision according to claim 1, characterized in that: The target object images captured by the color industrial camera (3) are stored in a designated folder.
4. The method for automatically recommending light source bands for machine vision according to claim 1, characterized in that: The preset step size ranges from 5 degrees to 10 degrees.
5. An automatic light source band recommendation system for machine vision, characterized in that: The invention comprises a sample placement table (1), a shading device (2), a color industrial camera (3), a high-angle ring light source (4), a digital constant voltage controller (5) and an image processing platform (6), wherein the sample placement table (1) is used to place a target object, the shading device (2) provides a darkroom dark environment for the color industrial camera (3) to collect an image of the target object, the high-angle ring light source (4) provides lighting conditions for the color industrial camera (3) to collect an image of the target object in the darkroom dark environment, and the color industrial camera (3) sends the collected target object image to the image processing platform (6), the digital constant voltage controller (5) is connected to the high-angle ring light source (4) and the image processing platform (6) respectively, and the digital constant voltage controller (5) adjusts the brightness and mixing ratio of different color LEDs of the high-angle ring light source (4) under the control of the image processing platform (6), and the image processing platform (6) is configured to execute the steps of the light source band automatic recommendation method for machine vision as described in any one of claims 1 to 4.
6. The automatic light source band recommendation system for machine vision according to claim 5, characterized in that: The shading device (2) includes an industrial aluminum profile frame (2-1), one side of the industrial aluminum profile frame (2-1) is sealed by black flocked light-absorbing cloth (2-2) as an inlet and outlet, and the other side is sealed by acrylic plates (2-3), forming a cavity for accommodating the sample placement table (1) and the high-angle annular light source (4), and both sides of each acrylic plate (2-3) are covered with black optical light-absorbing paper (2-4).
7. The automatic light source band recommendation system for machine vision according to claim 6, characterized in that: The color industrial camera (3) is fixed on the acrylic plate (2-3) via a camera fixer (7), and the color industrial camera (3) is nested and fixed with the high-angle annular light source (4).
8. The automatic light source band recommendation system for machine vision according to claim 5, characterized in that: It also includes an expansion dock, and the image processing platform (6) is connected to the color industrial camera (3) via the expansion dock.
Citation Information
Patent Citations
Automobile seat surface defect detection system based on machine vision as well as detection method
CN105806849A
Automobile seat defect detection method based on multi-feature fusion machine learning
CN112232399A
Image defect detection model training method and device, image defect detection model testing method and device and storage medium
CN110796637A
Co-prime modulation-based silicon-based dual-polarization Fourier transform spectrum detection method
CN114878477A