Detection method, detection device, and storage medium

By determining the target application scenario of the object under test and obtaining the corresponding detection parameters in machine vision inspection, the problems of high detection complexity and large error on the production line are solved, and high-precision detection in different scenarios is achieved.

CN116797915BActive Publication Date: 2026-07-10BEIJING XIAOMI MOBILE SOFTWARE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING XIAOMI MOBILE SOFTWARE CO LTD
Filing Date
2023-01-31
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing machine vision-based color detection methods are complex and prone to errors on production lines, making it difficult to meet the detection requirements of multiple production stages.

Method used

By acquiring a second image of the object to be tested, its current target application scenario is determined, and the target detection parameters are determined based on the scenario. Corresponding image processing operations are then performed to determine whether the detection is qualified.

Benefits of technology

Targeted image processing is performed for different application scenarios, which improves the accuracy and adaptability of detection and meets the detection needs of multiple production stages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116797915B_ABST
    Figure CN116797915B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a detection method, a detection device and a storage medium. The method comprises: obtaining a second image in which a to-be-detected object is located based on a first image; the second image is an image region of the first image that contains at least the to-be-detected object; determining a target application scenario in which the to-be-detected object is currently located according to the second image; determining a target detection parameter of the to-be-detected object based on the second image and the target application scenario; wherein the target detection parameter of the to-be-detected object in different target application scenarios is different; and if the target detection parameter meets a preset detection condition, determining that the to-be-detected object in the target application scenario is detected qualified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of color detection technology, and more particularly to a detection method, detection device, and storage medium. Background Technology

[0002] Machine vision technology is a technology that uses machines to replace human eyes and brains to perform various measurements and judgments. Color detection and recognition is an important application of machine vision technology. By using certain algorithms to identify different colors based on the differences in color characteristics of the surface of the object being measured.

[0003] Currently, the application of color detection and recognition methods based on machine vision technology on production lines is still in its early stages. Since color detection may be involved in multiple production stages within the production line, the actual detection environment is quite complex, resulting in high detection complexity and large detection errors, making it difficult to meet the detection requirements of multiple different production stages within the production line. Summary of the Invention

[0004] To overcome the problems existing in related technologies, this disclosure provides a detection method, a detection device, and a storage medium.

[0005] According to a first aspect of the present disclosure, a detection method is provided, comprising:

[0006] Based on the first image acquired, a second image is obtained where the object to be tested is located; the second image is an image region within the first image that contains at least the object to be tested.

[0007] Based on the second image, determine the target application scenario in which the object under test is currently located;

[0008] Based on the second image and the target application scenario, the target detection parameters of the object to be tested are determined; wherein, the target detection parameters of the object to be tested are different under different target application scenarios.

[0009] If the target detection parameters meet the preset detection conditions, the object to be tested in the target application scenario is determined to be qualified.

[0010] Optionally, determining the target application scenario where the object under test is currently located based on the second image includes:

[0011] The second image is divided into multiple image regions, and the average gray level of each image region is determined.

[0012] Based on the average gray values ​​of the multiple image regions, determine the maximum and minimum average gray values ​​within the multiple image regions;

[0013] The grayscale range of the second image is determined based on the maximum mean grayscale value and the minimum mean grayscale value.

[0014] Based on the grayscale range of the second image, the target application scenario of the object under test is determined; wherein, different grayscale ranges correspond to different application scenarios.

[0015] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0016] If the target application scenario is the first scenario, the color similarity between the second image and the multiple color template images is determined based on the second image and the multiple color template images;

[0017] Based on the color similarity between the second image and the plurality of color template images, the color parameters of the object to be tested are determined; wherein, the color parameters are used to determine the target color configuration information of the object to be tested;

[0018] Based on the grayscale value of at least one material of the object under test in the second image and the target color configuration information, the color detection parameters of at least one material of the object under test are determined.

[0019] Optionally, the color detection parameters include at least: grayscale mean, grayscale range, and color similarity;

[0020] The step of determining the color detection parameters of at least one material of the test object based on the grayscale value of at least one material of the test object in the second image and the target color configuration information includes:

[0021] At least one third image is obtained from the second image; the third image is the image region within the second image where the material to be tested is located;

[0022] Based on the target color configuration information of the object to be tested, obtain the target color image of at least one of the materials to be tested within the object to be tested;

[0023] Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image;

[0024] Based on the at least one third image and the target color image of the material to be tested within the third image, the color similarity between the material to be tested within the at least one third image and the target color image is determined.

[0025] Optionally, determining the color similarity between the second image and the multiple color template images based on the second image and the multiple color template images includes:

[0026] Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model;

[0027] Based on the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of each color template image in the plurality of color template images, the mean square error value between the second image and each color template image in the plurality of color template images is determined.

[0028] The mean square error value between the second image and each of the multiple color template images is normalized.

[0029] Based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

[0030] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0031] If the target application scenario is the second scenario, determine the target threshold of the second image;

[0032] Based on the target threshold, the second image is binarized to obtain a binarized image of the second image;

[0033] Contour detection is performed on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image;

[0034] Based on the coverage area, a fourth image is obtained from the second image; wherein, the fourth image is an image region within the second image that overlaps with the coverage area;

[0035] Based on the fourth image, the illumination brightness parameters of the object under test are determined.

[0036] Optionally, determining the target threshold of the second image includes:

[0037] Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image;

[0038] Based on the grayscale histogram of the second image, a first class of grayscale levels containing at least two grayscale levels is determined; wherein, the grayscale histogram includes: a first class of grayscale levels and a second class of grayscale levels; the frequency corresponding to any grayscale level in the first class of grayscale levels is greater than the frequency corresponding to any grayscale level in the second class of grayscale levels;

[0039] Based on the gray values ​​corresponding to at least two gray levels within the first type of gray level, determine the target gray level with the largest gray value;

[0040] The target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and the preset threshold.

[0041] Optionally, the step of performing contour detection on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image includes:

[0042] The binarized image is subjected to morphological operations to obtain a processed image;

[0043] Contour detection is performed on the processed image to identify multiple contour images within the processed image;

[0044] Based on the contour area of ​​the multiple contour images, the contour of the target image with the largest contour area is determined.

[0045] Determine the coverage area of ​​the target image contour within the processed image.

[0046] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0047] If the target application scenario is the third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the brightness component of the pixels in the second image.

[0048] Based on the center point of the light spot image, at least two fifth images are obtained from the second image; wherein, any two of the at least two fifth images correspond to different field angles;

[0049] Based on the luminance and / or chromaticity components of multiple image regions in any of the at least two fifth images, the defect detection parameters of the object under test in any of the fifth images are determined.

[0050] Optionally, the defect detection parameters include: uniformity defect parameters;

[0051] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes:

[0052] Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions;

[0053] Based on the luminance and chrominance components of the pixels in the central image region and the corner image region of any of the fifth images, the average luminance and average chrominance corresponding to the central image region and the corner image region in any of the fifth images are determined respectively.

[0054] The brightness uniformity and color uniformity of the corner image region are determined based on the ratio between the average brightness and average chromaticity of the corner image region and the average brightness and average chromaticity of the center image region.

[0055] Based on the brightness uniformity and chromaticity uniformity of the corner image region, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images;

[0056] The uniformity defect parameter of the object under test is determined based on the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

[0057] Optionally, the defect detection parameters include: black spot defect parameters;

[0058] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes:

[0059] Based on the center point of the light spot, any one of the at least two fifth images is divided into four first image regions of equal area;

[0060] Divide any one of the four first image regions into multiple non-overlapping sub-image regions;

[0061] Based on the luminance components of the plurality of sub-image regions, a first luminance difference is determined between a first sub-image region and an adjacent second sub-image region within the plurality of sub-image regions; wherein, the first sub-image region is any sub-image region of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0062] The black spot defect parameters of the object under test are determined based on multiple first brightness differences within a first image region in any one of the at least two fifth images.

[0063] Optionally, the defect detection parameters include: black border defect parameters;

[0064] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes:

[0065] Based on the center point of the light spot, any one of the at least two fifth images is divided into two second image regions of equal area;

[0066] The two second image regions are evenly divided into multiple sub-image regions along the horizontal or vertical direction;

[0067] Based on the luminance components of the plurality of sub-image regions, a second luminance difference is determined between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions; the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot;

[0068] Based on the luminance components of the multiple sub-image regions, a third luminance difference is determined between the third sub-image region and the fifth sub-image region; the third sub-image region and the fifth sub-image region are two sub-image regions within different second image regions, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot;

[0069] The black border defect parameters of the object under test are determined based on multiple second brightness differences and multiple third brightness differences in the second image region within any of the at least two fifth images.

[0070] Optionally, obtaining the second image containing the object under test based on the acquired first image includes:

[0071] Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image;

[0072] Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested;

[0073] Based on the position offset information, adjust the position of the image cropping window;

[0074] Using the adjusted image capture window, the second image containing the object under test is obtained from the first image.

[0075] According to a second aspect of the present disclosure, a detection apparatus is provided, comprising:

[0076] The acquisition module is used to acquire a second image containing the object under test based on the acquired first image; the second image is an image region within the first image that at least contains the object under test.

[0077] The first determining module is used to determine the target application scenario where the object under test is currently located based on the second image;

[0078] The second determining module is used to determine the target detection parameters of the object to be tested based on the second image and the target application scenario; wherein the target detection parameters of the object to be tested are different under different target application scenarios;

[0079] The detection module is used to determine that the object to be tested in the target application scenario is qualified if the target detection parameters meet the preset detection conditions.

[0080] Optionally, the first determining module is configured to:

[0081] The second image is divided into multiple image regions, and the average gray level of each image region is determined.

[0082] Based on the average gray values ​​of the multiple image regions, determine the maximum and minimum average gray values ​​within the multiple image regions;

[0083] The grayscale range of the second image is determined based on the maximum mean grayscale value and the minimum mean grayscale value.

[0084] Based on the grayscale range of the second image, the target application scenario of the object under test is determined; wherein, different grayscale ranges correspond to different application scenarios.

[0085] Optionally, the second determining module is configured to:

[0086] If the target application scenario is the first scenario, the color similarity between the second image and the multiple color template images is determined based on the second image and the multiple color template images;

[0087] Based on the color similarity between the second image and the plurality of color template images, the color parameters of the object to be tested are determined; wherein, the color parameters are used to determine the target color configuration information of the object to be tested;

[0088] Based on the grayscale value of at least one material of the object under test in the second image and the target color configuration information, the color detection parameters of at least one material of the object under test are determined.

[0089] Optionally, the color detection parameters include at least: grayscale mean, grayscale range, and color similarity;

[0090] The second determining module is used for:

[0091] At least one third image is obtained from the second image; the third image is the image region within the second image where the material to be tested is located;

[0092] Based on the target color configuration information of the object to be tested, obtain the target color image of at least one of the materials to be tested within the object to be tested;

[0093] Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image;

[0094] Based on the at least one third image and the target color image of the material to be tested within the third image, the color similarity between the material to be tested within the at least one third image and the target color image is determined.

[0095] Optionally, the second determining module is configured to:

[0096] Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model;

[0097] Based on the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of each color template image in the plurality of color template images, the mean square error value between the second image and each color template image in the plurality of color template images is determined.

[0098] The mean square error value between the second image and each of the multiple color template images is normalized.

[0099] Based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

[0100] Optionally, the second determining module is configured to:

[0101] If the target application scenario is the second scenario, determine the target threshold of the second image;

[0102] Based on the target threshold, the second image is binarized to obtain a binarized image of the second image;

[0103] Contour detection is performed on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image;

[0104] Based on the coverage area, a fourth image is obtained from the second image; wherein, the fourth image is an image region within the second image that overlaps with the coverage area;

[0105] Based on the fourth image, the illumination brightness parameters of the object under test are determined.

[0106] Optionally, the second determining module is configured to:

[0107] Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image;

[0108] Based on the grayscale histogram of the second image, a first class of grayscale levels containing at least two grayscale levels is determined; wherein, the grayscale histogram includes: a first class of grayscale levels and a second class of grayscale levels; the frequency corresponding to any grayscale level in the first class of grayscale levels is greater than the frequency corresponding to any grayscale level in the second class of grayscale levels;

[0109] Based on the gray values ​​corresponding to at least two gray levels within the first type of gray level, determine the target gray level with the largest gray value;

[0110] The target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and the preset threshold.

[0111] Optionally, the second determining module is configured to:

[0112] The binarized image is subjected to morphological operations to obtain a processed image;

[0113] Contour detection is performed on the processed image to identify multiple contour images within the processed image;

[0114] Based on the contour area of ​​the multiple contour images, the contour of the target image with the largest contour area is determined.

[0115] Determine the coverage area of ​​the target image contour within the processed image.

[0116] Optionally, the second determining module is configured to:

[0117] If the target application scenario is the third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the brightness component of the pixels in the second image.

[0118] Based on the center point of the light spot image, at least two fifth images are obtained from the second image; wherein, any two of the at least two fifth images correspond to different field angles;

[0119] Based on the luminance and / or chromaticity components of multiple image regions in any of the at least two fifth images, the defect detection parameters of the object under test in any of the fifth images are determined.

[0120] Optionally, the defect detection parameters include: uniformity defect parameters;

[0121] The second determining module is used for:

[0122] Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions;

[0123] Based on the luminance and chrominance components of the pixels in the central image region and the corner image region of any of the fifth images, the average luminance and average chrominance corresponding to the central image region and the corner image region in any of the fifth images are determined respectively.

[0124] The brightness uniformity and color uniformity of the corner image region are determined based on the ratio between the average brightness and average chromaticity of the corner image region and the average brightness and average chromaticity of the center image region.

[0125] Based on the brightness uniformity and chromaticity uniformity of the corner image region, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images;

[0126] The uniformity defect parameter of the object under test is determined based on the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

[0127] Optionally, the defect detection parameters include: black spot defect parameters;

[0128] The second determining module is used for:

[0129] Based on the center point of the light spot, any one of the at least two fifth images is divided into four first image regions of equal area;

[0130] Divide any one of the four first image regions into multiple non-overlapping sub-image regions;

[0131] Based on the luminance components of the plurality of sub-image regions, a first luminance difference is determined between a first sub-image region and an adjacent second sub-image region within the plurality of sub-image regions; wherein, the first sub-image region is any sub-image region of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0132] The black spot defect parameters of the object under test are determined based on multiple first brightness differences within a first image region in any one of the at least two fifth images.

[0133] Optionally, the defect detection parameters include: black border defect parameters;

[0134] The second determining module is used for:

[0135] Based on the center point of the light spot, any one of the at least two fifth images is divided into two second image regions of equal area;

[0136] The two second image regions are evenly divided into multiple sub-image regions along the horizontal or vertical direction;

[0137] Based on the luminance components of the plurality of sub-image regions, a second luminance difference is determined between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions; the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot;

[0138] Based on the luminance components of the multiple sub-image regions, a third luminance difference is determined between the third sub-image region and the fifth sub-image region; the third sub-image region and the fifth sub-image region are two sub-image regions within different second image regions, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot;

[0139] The black border defect parameters of the object under test are determined based on multiple second brightness differences and multiple third brightness differences in the second image region within any of the at least two fifth images.

[0140] Optionally, the acquisition module is used to:

[0141] Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image;

[0142] Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested;

[0143] Based on the position offset information, adjust the position of the image cropping window;

[0144] Using the adjusted image capture window, the second image containing the object under test is obtained from the first image.

[0145] According to a third aspect of the present disclosure, a detection apparatus is provided, comprising:

[0146] processor;

[0147] Memory used to store executable instructions;

[0148] The processor is configured to, when executing executable instructions stored in the memory, implement the steps of the detection method described in the first aspect of this disclosure.

[0149] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, wherein when instructions in the storage medium are executed by a processor of a detection device, the detection device is enabled to perform steps in the detection method as described in the first aspect of the present disclosure.

[0150] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0151] This embodiment of the disclosure obtains a second image containing the object under test from a first image, and determines the target application scenario in which the object under test is currently located based on the second image. This facilitates the execution of image processing operations corresponding to the target application scenario on the second image. The target detection parameters required for the target application scenario are obtained from the second image. Based on the target detection parameters and the detection threshold corresponding to the target application scenario, it is determined whether the object under test in the target application scenario is qualified for detection. Therefore, when the object under test is in multiple different application scenarios, different image processing operations can be performed on the second image containing the object under test to complete the detection of the object under test in different application scenarios.

[0152] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0153] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0154] Figure 1 This is a flowchart illustrating a color vision detection method based on related technologies.

[0155] Figure 2 This is a flowchart illustrating a detection method according to an exemplary embodiment. Figure 1 .

[0156] Figure 3 This is a schematic diagram illustrating a plurality of sub-image regions of a first image region according to an exemplary embodiment.

[0157] Figure 4 This is a flowchart illustrating a detection method according to an exemplary embodiment. Figure 2 .

[0158] Figure 5 This is a schematic diagram illustrating a process for determining a target application scenario according to an exemplary embodiment.

[0159] Figure 6 This is a flowchart illustrating a detection method for an object under test in a first scenario, according to an exemplary embodiment.

[0160] Figure 7 This is a schematic diagram illustrating the process of color discrimination and material assembly detection of a terminal device in a first scenario according to an exemplary embodiment.

[0161] Figure 8 This is a flowchart illustrating a detection method for an object under test in a second scenario, according to an exemplary embodiment.

[0162] Figure 9 This is a schematic diagram illustrating the process of detecting the brightness of the light-emitting element of a terminal device in a second scenario according to an exemplary embodiment.

[0163] Figure 10 This is a flowchart illustrating a detection method for an object under test in a third scenario, according to an exemplary embodiment.

[0164] Figure 11 This is a schematic diagram illustrating a process for defect detection of the light-emitting element of a terminal device in a third scenario, according to an exemplary embodiment.

[0165] Figure 12 This is a schematic diagram of the structure of a detection device according to an exemplary embodiment. Detailed Implementation

[0166] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0167] In related technologies, such as Figure 1 As shown, Figure 1 This is a flowchart illustrating a color visual detection method based on related technologies. The method involves acquiring a test image of the object to be tested and extracting a test image region containing the object; determining the color histogram of the test image region and the color histograms of multiple color template images; determining the color similarity between the test image region and the multiple color template images based on the color histograms of the test image region and the multiple color template images; and determining the color information of the test image region based on whether the color similarity meets a threshold requirement.

[0168] It should be noted that since the color histogram only counts the colors within an image and ignores the positional information of different colors within the image, the above color visual detection method is only suitable for detection scenarios with large color differences and has low detection accuracy.

[0169] Furthermore, since the application of the aforementioned color vision detection method on the production line is limited to color recognition, and there are many production links related to color detection in the production line, the aforementioned color vision detection method is difficult to adapt to the detection needs of multiple different production links.

[0170] This disclosure provides a detection method, such as... Figure 2 As shown, Figure 2 This is a flowchart illustrating a detection method according to an exemplary embodiment. Figure 1 The method includes:

[0171] Step S101: Based on the acquired first image, obtain the second image where the object to be tested is located; the second image is an image region within the first image that at least contains the object to be tested;

[0172] Step S102: Determine the target application scenario where the object under test is currently located based on the second image;

[0173] Step S103: Based on the second image and the target application scenario, determine the target detection parameters of the object to be tested; wherein, the target detection parameters of the object to be tested are different under different target application scenarios;

[0174] Step S104: If the target detection parameters meet the preset detection conditions, the test object in the target application scenario is determined to be qualified.

[0175] In step S101, a first image can be acquired using an image acquisition component, and the image region where the object to be tested is located can be determined from the first image. The image region can be cropped from the first image to obtain a second image.

[0176] It should be noted that on the production line, an industrial camera can be used to capture the first image of the current production process, and a second image containing the object to be tested can be extracted from the first image; so that the object to be tested can be detected using the second image.

[0177] It is understandable that on a production line, since the position of the processing equipment is usually fixed, the object to be tested will be moved to the processing position corresponding to the processing equipment for processing. Therefore, an industrial camera can be set at the processing position to capture the first image to be tested. The position of the object to be tested in the first image is relatively fixed, and the position information of the object to be tested in the first image can be obtained. Based on the position information, an image cropping window is set, and each first image is cropped using the image cropping window to obtain the second image where the object to be tested is located.

[0178] In step S102, image analysis is performed on the second image, and based on the image analysis results, the target application scenario in which the object under test is currently located is determined.

[0179] It should be noted that since the production line may contain multiple production links related to color detection, and the specific application scenarios of color detection technology may also be different in different production links. For example, the production line of terminal equipment includes at least the packaging section, the assembly section, and the testing section.

[0180] In the packaging stage, it is necessary to determine the color of the terminal device in order to automatically call the corresponding color profile; it is necessary to check whether the color of the components on the terminal device (such as buttons, card trays, etc.) is the same as the component color in the color profile of the terminal device, so as to determine whether there is a problem of mixed components; in the testing stage, it is necessary to check whether the brightness of the light-emitting components (such as flash, power light or front fill light, etc.) in the terminal device meets the standard.

[0181] It is understandable that, since the production operations performed on the object under test are different in different production stages, the placement and processing positions of the object under test may be different in different production stages. Therefore, the target application scenario in which the object under test is currently located can be determined based on the posture of the object under test in the second image and the background environment information in the second image.

[0182] Because the items to be detected for the object under test may differ in different target application scenarios, the detection parameters required to be obtained from the second image will also differ, as will the image processing methods performed on the second image. Therefore, after obtaining the second image containing the object under test, the target application scenario in which the object under test is currently located can be determined based on the second image. This allows for the corresponding image processing to be performed on the second image in subsequent processing to obtain the target detection parameters required for the target application scenario.

[0183] In step S103, after determining the target application scenario in which the object to be tested is currently located, the second image can be processed accordingly based on the detection items corresponding to the target application scenario to obtain the target detection parameters of the object to be tested in the target application scenario.

[0184] It should be noted that different application scenarios correspond to different detection items, and different application scenarios correspond to different image processing operations. Therefore, based on the image processing operations corresponding to different application scenarios, the target detection parameters obtained after image processing of the object to be tested will also be different.

[0185] Since the production line contains multiple production stages related to color detection, and the specific application scenarios of color detection technology may differ in different production stages, the target detection parameters of the object to be tested obtained from the second image may also differ. In order to make the detection method shown in this embodiment adaptable to multiple different production stages related to color detection in the production line, after determining the target application scenario in which the object to be tested is currently located, this embodiment can perform image processing operations corresponding to the target application scenario on the second image, thereby obtaining the target detection parameters required by the target application scenario from the second image, so as to complete the detection items corresponding to the target application scenario for the object to be tested in the target application scenario.

[0186] In step S104, after obtaining the target detection parameters of the object to be tested in the target application scenario, the detection threshold corresponding to the target application scenario can be obtained. The target detection parameters are compared with the detection threshold. Based on the comparison result, it is determined whether the object to be tested meets the preset detection conditions, thereby determining whether the object to be tested is qualified.

[0187] Here, the detection threshold can be a preset default value; it is understood that since the target detection parameters of the object under test may be different in different application scenarios, the detection threshold corresponding to different application scenarios may also be different.

[0188] If the target detection parameter of the object to be tested is greater than or equal to the detection threshold corresponding to the target application scenario, it is determined that the object to be tested meets the preset detection conditions, and the object to be tested in the target application scenario is qualified; if the target detection parameter of the object to be tested is less than the detection threshold corresponding to the target application scenario, it is determined that the object to be tested does not meet the preset detection conditions, and the object to be tested in the target application scenario is unqualified.

[0189] This embodiment of the disclosure obtains a second image containing the object under test from a first image, and determines the target application scenario in which the object under test is currently located based on the second image. This facilitates the execution of image processing operations corresponding to the target application scenario on the second image. The target detection parameters required for the target application scenario are obtained from the second image. Based on the target detection parameters and the detection threshold corresponding to the target application scenario, it is determined whether the object under test in the target application scenario is qualified for detection. Therefore, when the object under test is in multiple different application scenarios, different image processing operations can be performed on the second image containing the object under test to complete the detection of the object under test in different application scenarios.

[0190] Optionally, determining the target application scenario where the object under test is currently located based on the second image includes:

[0191] The second image is divided into multiple image regions, and the average gray level of each image region is determined.

[0192] Based on the average gray values ​​of the multiple image regions, determine the maximum and minimum average gray values ​​within the multiple image regions;

[0193] The grayscale range of the second image is determined based on the maximum mean grayscale value and the minimum mean grayscale value.

[0194] Based on the grayscale range of the second image, the target application scenario of the object under test is determined; wherein, different grayscale ranges correspond to different application scenarios.

[0195] In this embodiment of the disclosure, after acquiring the second image, the second image can be divided into multiple image regions; and based on the grayscale values ​​of the pixels in each of the multiple image regions, the average grayscale value of each image region is determined.

[0196] Here, the multiple image regions do not overlap. The image segmentation method for dividing the second image into multiple image regions can be selected according to the actual situation, and this disclosure does not limit this method.

[0197] For example, a sliding window of a preset size can be used to traverse the second image to obtain multiple image regions of the second image; here, the size of the sliding window can be set by the user as needed, for example, it can be a 3*3, 5*5 or other size window.

[0198] After obtaining the average gray values ​​of multiple image regions of the second image, the maximum and minimum average gray values ​​within the multiple image regions can be determined. Based on the difference between the maximum and minimum average gray values, the gray range of the second image is determined.

[0199] It is understood that the grayscale range can be used to describe the range of changes in the brightness of an image, reflecting the degree of drastic change in the image.

[0200] Based on the grayscale range of the second image, the grayscale range to which the grayscale range of the second image belongs is determined, thereby determining the target application scenario in which the object under test is currently located.

[0201] It should be noted that each application scenario corresponds to a grayscale range, and the grayscale ranges corresponding to different application scenarios do not overlap. The grayscale range to which the second image belongs can be determined based on the grayscale range of the second image, and the application scenario corresponding to the grayscale range to which the second image belongs can be determined as the target application scenario of the object under test.

[0202] In some embodiments, the plurality of grayscale ranges may include: a first range, a second range, and a third range, wherein any grayscale range within the first range is smaller than any grayscale range within the second range, and any grayscale range within the second range is smaller than any grayscale range within the third range.

[0203] The step of determining the target application scenario of the test object based on the grayscale range of the second image includes:

[0204] If the grayscale range of the second image is within the range of the first range, the target application scenario where the object under test is currently located is determined to be the first scenario;

[0205] If the grayscale range of the second image is within the range of the second range, the target application scenario of the object under test is determined to be the third scenario.

[0206] If the grayscale range of the second image is within the range of the third range, the target application scenario of the object under test is determined to be the second scenario.

[0207] It should be noted that, since any grayscale range within the first range is smaller than any grayscale range within the second range, and any grayscale range within the second range is smaller than any grayscale range within the third range.

[0208] If the grayscale range of the second image is within the range of the first range, it indicates that the brightness variation of the second image is relatively weak, that is, the brightness distribution of the second image is relatively uniform; therefore, the target application scenario of the object under test can be determined as the first scenario; it should be noted that the first scenario is the scenario of color recognition of the object under test and detection of the material under test within the object under test.

[0209] If the grayscale difference of the second image is within the range of the second range, it indicates that the brightness of the second image changes significantly, that is, the brightness distribution of the second image is uneven; therefore, it can be determined that the target application scenario of the object under test is the third scenario; it should be noted that the third scenario is the scenario for detecting defects in the light-emitting elements within the object under test.

[0210] If the grayscale range of the second image is within the third range, it indicates that the brightness of the second image changes drastically. Therefore, it can be determined that the target application scenario of the object under test is the second scenario. It should be noted that the second scenario is the scenario for detecting the brightness of the light-emitting element in the object under test.

[0211] This embodiment of the disclosure divides the second image into multiple image regions. Based on the average grayscale value of the multiple image regions, the grayscale range of the second image is determined. Based on the grayscale range to which the grayscale range of the second image belongs, the target application scenario of the object under test is determined. Since the grayscale range of the second image can reflect the changes in brightness of the second image, a target application scenario matching the changes in brightness of the second image is determined based on the changes in brightness of the second image and the brightness changes of different application scenarios. This allows for the execution of image processing operations corresponding to the target application scenario on the second image in subsequent processing to obtain the target detection parameters required by the target application scenario.

[0212] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0213] If the target application scenario is the first scenario, the color similarity between the second image and the multiple color template images is determined based on the second image and the multiple color template images;

[0214] Based on the color similarity between the second image and the plurality of color template images, the color parameters of the object to be tested are determined; wherein, the color parameters are used to determine the target color configuration information of the object to be tested;

[0215] Based on the grayscale value of at least one material of the object under test in the second image and the target color configuration information, the color detection parameters of at least one material of the object under test are determined.

[0216] In this embodiment of the disclosure, when the target application scenario of the object under test is determined to be the first scenario, multiple color template images can be obtained;

[0217] Here, the multiple color template images respectively indicate different color information of multiple terminal devices processed in the production line;

[0218] It is understandable that, since the same production line can process multiple test objects of different colors at the same time, the color of the test material to be installed on the test objects of different colors may also be different. Therefore, before performing color detection on the test material of the test object, it is necessary to determine the color of the test object first.

[0219] Based on the second image and multiple color template images, determine the color similarity between the second image and each of the multiple color template images;

[0220] Here, an image feature extraction model can be used to extract the color features of the second image and each color template image respectively, determine the vector distance between the color features of the second image and the color features of each color template image, and thus determine the color similarity between the second image and each color template image based on the vector distance between the color features of the second image and the color features of each color template image; and determine the color parameter of the color template image with the highest color similarity as the color parameter of the object to be tested.

[0221] It is understandable that if the vector distance between the color features of the second image and the color features of the color template image is larger, it indicates that the color similarity between the second image and the color template image is smaller, and the difference between the color parameters of the object to be tested in the second image and the color parameters indicated by the color template image is larger; if the vector distance between the color features of the second image and the color features of the color template image is smaller, it indicates that the color similarity between the second image and the color template image is larger, and the color parameters of the object to be tested in the second image are more similar to the color parameters indicated by the color template image.

[0222] It should be noted that the color similarity between the second image and the color template image can also be determined by other methods, and this embodiment does not limit this.

[0223] After determining the color parameters of the object to be tested, target color configuration information matching the color parameters can be determined based on the color parameters.

[0224] It is understood that multiple color configuration information can be pre-stored, which may include: the hue range of the material to be installed in the terminal device, a template image of the material to be installed, and / or the installation position of the material to be installed on the terminal device, etc. Furthermore, the color configuration information may differ for terminal devices of different colors.

[0225] After obtaining the target color configuration information of the object to be tested, the material to be tested of the object to be tested can be located in the second image based on the template image of the material to be installed in the target color configuration information and / or the installation position of the material to be installed on the terminal device, and the gray value of the material to be tested can be determined. Based on the gray value of the material to be tested and the hue range of the material to be installed in the target color configuration information, the color detection parameters of the material to be tested can be determined.

[0226] It should be noted that the test object may include multiple test materials. The grayscale value of each test material can be determined separately. Based on the grayscale value of each test material and the hue range of the installation material that matches the test material in the target color configuration information, the color detection parameters of each test material can be determined. Then, the color detection parameters of each test material of the test object are compared with a preset detection threshold. If the comparison result indicates that the color detection parameters of each test material are greater than or equal to the preset detection threshold, the test object can be determined to be qualified.

[0227] If the comparison results indicate that at least one of the test materials has a color detection parameter that is less than a preset detection threshold, it can be determined that the test object is unqualified.

[0228] In this embodiment of the disclosure, after determining that the target application scenario of the object under test is a first scenario, the color similarity between the second image where the object under test is located and multiple color template images is determined. Based on the color similarity between the second image and each color template image, the color parameters of the object under test within the second image are determined, thereby obtaining target color configuration information matching the color parameters. Based on the target color configuration information and the grayscale values ​​of multiple test materials of the object under test within the second image, color detection parameters for multiple test materials are determined respectively, so as to detect whether the assembly of multiple test materials within the object under test is qualified based on the color detection parameters of the multiple test materials.

[0229] Optionally, the color detection parameters include at least: grayscale mean, grayscale range, and color similarity;

[0230] The step of determining the color detection parameters of at least one material of the test object based on the grayscale value of at least one material of the test object in the second image and the target color configuration information includes:

[0231] At least one third image is obtained from the second image; the third image is the image region within the second image where the material to be tested is located;

[0232] Based on the target color configuration information of the object to be tested, obtain the target color image of at least one of the materials to be tested within the object to be tested;

[0233] Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image;

[0234] Based on the at least one third image and the target color image of the material to be tested within the third image, the color similarity between the material to be tested within the at least one third image and the target color image is determined.

[0235] In this embodiment of the disclosure, the color detection parameters include at least: grayscale mean, grayscale range, and color similarity;

[0236] It should be noted that the average grayscale value can be used to reflect the overall brightness of the image; the larger the average grayscale value, the brighter the image, and the smaller the average grayscale value, the darker the image.

[0237] The color similarity can be the color similarity between the material to be tested and the hue range corresponding to the material to be tested within the target color configuration information.

[0238] Based on the contour information of multiple objects to be tested, contour detection can be performed on the second image to determine the image region where each material to be tested is located in the second image. By cropping the image region where each material to be tested is located in the second image, a third image corresponding to each material to be tested can be obtained.

[0239] The average gray value of the material to be tested in the at least one third image is determined based on the gray value of each pixel in the at least one third image.

[0240] The at least one third image is divided into multiple non-overlapping image regions, and the average gray level of the multiple image regions is determined; based on the maximum and minimum average gray level of the multiple image regions, the gray level range of the at least one third image is determined.

[0241] Based on the target color configuration information of the object under test, the target color image of each material under test within the object under test can be obtained; based on the at least one third image and the target color image corresponding to the material under test within the third image, the color similarity between the at least one third image and the target color image can be determined.

[0242] It is understood that the target color image of the material under test can at least be used to describe the hue range of the material under test.

[0243] After obtaining the mean gray level, gray level range, and color similarity of the material to be tested, the mean gray level can be compared with a preset gray level threshold to obtain a first comparison result; the gray level range can be compared with a preset range threshold to obtain a second comparison result; and the color similarity can be compared with a color similarity threshold to obtain a third comparison result.

[0244] If at least two of the first, second, and third comparison results indicate that the detection parameter is greater than or equal to the detection threshold, then the assembly of the multiple test materials of the test object is determined to be qualified.

[0245] If at least two of the first, second, and third comparison results indicate that the detection parameter is less than the detection threshold, it is determined that the assembly of multiple test materials of the test object is unqualified, that is, there may be problems such as missing test materials or incorrect color assembly of test materials.

[0246] In this embodiment, after obtaining the target color configuration information of the object under test, a third image containing at least one material under test of the object under test is obtained from the second image. Based on the third image and the target color image corresponding to the material under test, the grayscale mean, grayscale range, and color similarity of the material under test in the third image are determined. Based on the grayscale mean, grayscale range, and color similarity of the material under test in the third image, the assembly of multiple materials under test of the object under test is jointly determined to be qualified, so as to realize the automatic detection of problems such as missing materials under test or incorrect color assembly of materials under test in the object under test.

[0247] Optionally, determining the color similarity between the second image and the multiple color template images based on the second image and the multiple color template images includes:

[0248] Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model;

[0249] Based on the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of each color template image in the plurality of color template images, the mean square error value between the second image and each color template image in the plurality of color template images is determined.

[0250] The mean square error value between the second image and each of the multiple color template images is normalized.

[0251] Based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

[0252] In this embodiment of the disclosure, the pixel value of each pixel in the second image and multiple color template images can be represented as the channel grayscale component of the pixel in the three channels of the color model;

[0253] By acquiring the image information of the second image, and based on the image information of the second image, the channel grayscale components of each pixel in the second image on the three channels of the color model can be obtained.

[0254] The average gray value of the second image in any one of the three channels is determined based on the gray value component of each pixel in the second image.

[0255] Image information of any one of multiple color template images can be obtained, and based on the image information of any one color template image, the channel grayscale components of each pixel in the color template image on the three channels of the color model can be obtained.

[0256] Based on the channel grayscale component of each pixel in any of the three channels in the color template image, determine the average channel grayscale value of the color template image in any channel.

[0257] Here, the color model includes the Red, Green, Blue (RGB) color model, where the grayscale components of the three channels of the RGB color model are the R channel grayscale component, the G channel grayscale component, and the B channel grayscale component, respectively.

[0258] By acquiring the image information of the second image (or any color template image), and based on the image information of the second image (or any color template image), the channel grayscale components of each pixel in the second image (or any color template image) in the three channels of the color model are obtained, namely the R channel grayscale component, the G channel grayscale component and the B channel grayscale component.

[0259] Based on the R-channel grayscale component of each pixel in the second image (or any color template image), determine the mean R-channel grayscale value of the second image (or any color template image);

[0260] Based on the G channel grayscale component of each pixel in the second image (or any color template image), determine the mean G channel grayscale value of the second image (or any color template image);

[0261] Based on the B-channel grayscale component of each pixel in the second image (or any color template image), determine the mean B-channel grayscale value of the second image (or any color template image).

[0262] Based on the average gray values ​​of the three channels of the second image and the average gray values ​​of the three channels of each of the plurality of color template images, the mean square error value between the second image and each of the color template images is determined.

[0263] It should be noted that the mean square error between the second image and the color template image is an expected value used to reflect the degree of difference between the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of the color template image; the smaller the mean square error between the second image and the color template image, the smaller the difference between the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of the color template image.

[0264] By normalizing the mean square error value between the second image and each of the color template images, and based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

[0265] Here, the color similarity between the second image and each of the plurality of color template images can be determined according to the following formula:

[0266] S = 1 - MSEk;

[0267] Wherein, S is the color similarity, MSE is the mean square error between the second image and the color template image, and k is the normalization coefficient, where k = 3 * 255.

[0268] It is understood that the embodiments of this disclosure directly utilize the mean gray values ​​of the two images and each color template image in the three channels of the color model to determine the mean square error value between the two images and each color template image. Thus, based on the mean square error value, which reflects the degree of difference between the mean gray values ​​of the three channels of the two images and the mean gray values ​​of the three channels of the color template image, the color similarity between the two images and each of the multiple color template images is determined, reducing computational complexity and improving the computational efficiency of color similarity.

[0269] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0270] If the target application scenario is the second scenario, determine the target threshold of the second image;

[0271] Based on the target threshold, the second image is binarized to obtain a binarized image of the second image;

[0272] Contour detection is performed on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image;

[0273] Based on the coverage area, a fourth image is obtained from the second image; wherein, the fourth image is an image region within the second image that overlaps with the coverage area;

[0274] Based on the fourth image, the illumination brightness parameters of the object under test are determined.

[0275] In this embodiment of the disclosure, when the target application scenario of the object to be tested is determined to be the second scenario, the target threshold of the second image can be obtained.

[0276] Here, the target threshold can be a preset default threshold, or the target threshold can be determined based on the illumination brightness when the light-emitting element in the object under test emits light normally.

[0277] It is understandable that, since the target application scenario of the object under test is the second scenario, which is the scenario for detecting the brightness of the light-emitting element within the object under test, the second image is an image captured when the light-emitting element within the object under test is in a light-emitting state. Therefore, the image brightness of the image area corresponding to the illumination area of ​​the light-emitting element in the second image is relatively high, while the image brightness of other image areas within the second image is relatively low, meaning that the brightness variation within the second image is more drastic.

[0278] The second image can be binarized based on the target threshold to obtain a binarized image.

[0279] Here, the grayscale value of each pixel in the second image can be obtained, and the grayscale value of each pixel can be compared with the target threshold. If the comparison result indicates that the grayscale value of the pixel is greater than or equal to the target threshold, the grayscale value of the pixel is updated to a first grayscale value; if the comparison result indicates that the grayscale value of the pixel is less than the target threshold, the grayscale value of the pixel is updated to a second grayscale value; thereby, the binarized image is constructed based on the updated grayscale value of each pixel.

[0280] Wherein, the first gray value is greater than the second gray value; here, the specific values ​​of the first gray value and the second gray value can be set according to actual needs, and this embodiment does not limit this; for example, the first gray value can be 255, and the second gray value can be 0.

[0281] It is understood that the image region formed by multiple pixels of the first gray value in the binarized image is the illumination region of the light-emitting element.

[0282] Contour detection can be performed on the binarized image, and the target image contour corresponding to the object under test can be determined based on the contour detection result; based on the target image contour of the object under test, the coverage area of ​​the target image contour in the binarized image can be determined.

[0283] Here, contour detection can be performed on the binarized image based on a contour detection algorithm; the specific contour detection algorithm can be selected according to actual needs, for example, the contour detection algorithm can be the Sobel algorithm, the Canny algorithm, etc.

[0284] The target image contour of the object to be tested includes at least the pixel positions of each pixel point at the contour line within the binarized image.

[0285] Based on the target image contour, the pixel position of each pixel at the contour line is obtained, and the coverage area of ​​the target image contour in the binarized image is determined based on the image region enclosed by the pixel positions of each pixel at the contour line.

[0286] Based on the coverage area, an image region overlapping with the coverage area is extracted from the second image, and the extracted image region is determined as the fourth image. The illumination brightness parameters of the object under test are determined based on each pixel in the fourth image.

[0287] The average brightness of the fourth image can be determined based on the brightness components of each pixel in the fourth image, and the average brightness of the fourth image can be used as the illumination brightness parameter of the object under test.

[0288] After determining the illumination brightness parameter (i.e., the average brightness) of the object to be tested, the average brightness can be compared with a preset detection threshold. If the average brightness is greater than or equal to the detection threshold, the illumination brightness of the light-emitting element in the object to be tested is determined to be qualified; if the average brightness is less than the detection threshold, the illumination brightness of the light-emitting element in the object to be tested is determined to be unqualified.

[0289] In some embodiments, the channel grayscale components of each pixel in the fourth image in the three channels of the color model can be obtained; the channel grayscale average value of the fourth image in any one of the three channels can be determined based on the channel grayscale component of each pixel in the fourth image; and the illumination brightness parameters of the object under test can be determined based on the three channel grayscale average values ​​of the fourth image.

[0290] Understandably, the average grayscale value of the three channels of the fourth image can be used as the illumination brightness parameter of the object under test; and the average grayscale value of the three channels of the fourth image can be compared with three preset detection thresholds respectively. If the comparison result indicates that the average grayscale value of the three channels is greater than or equal to the detection threshold, it is determined that the illumination brightness of the light-emitting element in the object under test is qualified; if the comparison result indicates that the average grayscale value of at least one of the three channels is less than the detection threshold, it is determined that the illumination brightness of the light-emitting element in the object under test is unqualified.

[0291] In this embodiment of the present disclosure, after determining that the target application scenario of the object under test is the second scenario, a target threshold of the second image is determined, and based on the target threshold, the second image is processed into a binarized image. By performing contour detection on the binarized image, the target image contour of the object under test and the coverage area of ​​the target image contour in the binarized image can be obtained. Based on the coverage area, a fourth image (i.e., a spot image) that overlaps with the coverage area is obtained from the second image. Based on the pixel points of each pixel point in the fourth image, the illumination brightness parameters of the light-emitting element in the object under test are determined, so as to realize the automatic detection of the illumination brightness of the light-emitting element in the object under test.

[0292] Optionally, determining the target threshold of the second image includes:

[0293] Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image;

[0294] Based on the grayscale histogram of the second image, a first class of grayscale levels containing at least two grayscale levels is determined; wherein, the grayscale histogram includes: a first class of grayscale levels and a second class of grayscale levels; the frequency corresponding to any grayscale level in the first class of grayscale levels is greater than the frequency corresponding to any grayscale level in the second class of grayscale levels;

[0295] Based on the gray values ​​corresponding to at least two gray levels within the first type of gray level, determine the target gray level with the largest gray value;

[0296] The target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and the preset threshold.

[0297] In this embodiment of the disclosure, the grayscale value of each pixel in the second image can be obtained; based on the grayscale value of each pixel in the grayscale image of the second image, the grayscale histogram corresponding to the second image is determined.

[0298] Here, the second image can be converted into a grayscale image, thereby based on the grayscale value of each pixel in the grayscale image;

[0299] It is understandable that in the second scenario, the light-emitting element in the object under test is in a light-emitting state, and the second image is an image captured when the light-emitting element in the object under test is in a light-emitting state; therefore, the grayscale of the pixels in the second image can reflect the illumination brightness of the light-emitting element to a certain extent.

[0300] In some embodiments, the grayscale image of the second image may be subjected to mean filtering, and the grayscale histogram corresponding to the second image may be determined based on the grayscale image after mean filtering.

[0301] It should be noted that the mean filtering process refers to using the average gray value of the local image information of the pixel to be processed in the grayscale image as the grayscale value of the pixel after processing; the mean filtering process is also called neighborhood average filtering; each element of the filter convolution kernel in the mean filtering process is the same; it can be understood that by performing mean filtering on the grayscale image of the second image, the grayscale image can be denoised, and because the mean filtering process is relatively simple and fast, this denoising method will cause grayscale blurring while reducing noise.

[0302] The grayscale histogram of the pixels in the second image indicates at least the ratio of the number of pixels at different gray levels to the total number of pixels in the second image; it can be understood that the grayscale histogram can reflect the frequency of occurrence of multiple different gray levels in the second image.

[0303] Based on the grayscale histogram of pixels in the second image, the frequencies corresponding to multiple different grayscale levels in the second image can be determined; based on the frequencies corresponding to the multiple different grayscale levels, the multiple grayscale levels in the grayscale histogram can be divided into a first type of grayscale level and a second type of grayscale level.

[0304] Wherein, the frequency corresponding to any gray level within the first type of gray level is greater than the frequency corresponding to any gray level within the second type of gray level;

[0305] Here, the first type of gray level includes at least two different gray levels;

[0306] Based on the gray values ​​corresponding to at least two gray levels within the first type of gray levels, the gray level with the largest gray value in the first type of gray levels is determined as the target gray level, and the target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and a preset threshold.

[0307] Here, the preset threshold can be set according to the actual image; for example, the preset threshold can be 20.

[0308] It is understandable that, since the test object to be processed on the production line may contain multiple light-emitting elements, and the brightness of the multiple light-emitting elements may be different, the embodiments of this disclosure, based on the gray-level histogram of the second image, determine the target gray-level with the largest gray-level value from the first type of gray-level with higher frequency in the gray-level histogram. According to the difference between the gray-level value corresponding to the target gray-level and the preset threshold, the target threshold of the second image is determined. Thus, the target threshold is determined according to the gray-level distribution that can reflect the actual light emission of the light-emitting elements of the test object in the second image. This makes the target thresholds corresponding to different light-emitting elements of the test object different, so that in the subsequent processing, the second image containing different light-emitting elements of the test object can be binarized in a targeted manner to obtain a more accurate binarized image.

[0309] Optionally, the step of performing contour detection on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image includes:

[0310] The binarized image is subjected to morphological operations to obtain a processed image;

[0311] Contour detection is performed on the processed image to identify multiple contour images within the processed image;

[0312] Based on the contour area of ​​the multiple contour images, the contour of the target image with the largest contour area is determined.

[0313] Determine the coverage area of ​​the target image contour within the processed image.

[0314] In this embodiment of the disclosure, after obtaining the binarized image, considering that there may be some noise in the binarized image, in order to further remove isolated noise in the binarized image, morphological processing can be performed on the binarized image to obtain a processed image.

[0315] It's important to note that the fundamental theory of morphological processing is mathematical morphology. The mathematical foundation and language of mathematical morphology is set theory, which uses sets to describe image objects, the relationships between different parts of an image, and the structural characteristics of the object. In morphology, set reflection and translation are widely used to express operations based on structuring elements (SEs): small sets or sub-images used to study features of interest within an image. Its basic operations include erosion, dilation, opening and closing operations, skeleton extraction, limit erosion, hit-and-miss transformation, and morphological gradients. Advanced morphological processing is often built upon these two fundamental operations: erosion and dilation.

[0316] Here, the morphological processing described is opening operation. It should be noted that the opening operation involves first performing erosion, followed by dilation. Opening operations generally smooth the outline of an object, break up narrow necks, and eliminate fine protrusions; erosion reduces or thins objects in a binarized image; erosion can be viewed as a morphological filtering operation.

[0317] After obtaining the processed image, contour detection is performed on the processed image to obtain multiple contour images within the processed image; and the contour area of ​​each contour image in the multiple contour images is obtained. Based on the contour areas of the multiple contour images, the contour image with the largest contour area is determined as the target contour image.

[0318] Here, the specific contour detection algorithm can be selected according to actual needs. For example, the contour detection algorithm can be the Sobel algorithm, the Canny algorithm, etc.

[0319] Since the target image contour of the object under test includes at least the pixel positions of each pixel point at the contour line within the processed image, the pixel positions of each pixel point at the contour line are obtained based on the target image contour. Then, the coverage area of ​​the target image contour within the processed image is determined based on the image region enclosed by the pixel positions of each pixel point at the contour line.

[0320] This embodiment of the disclosure performs morphological opening operations on a binarized image to eliminate isolated noise points within the binarized image, thereby obtaining a denoised processed image. By performing contour detection on the denoised processed image, a target contour image with the largest contour area within the processed image is determined. Based on the target contour image, the coverage area of ​​the target contour image within the processed image is determined, so as to determine the luminous area of ​​the light-emitting element of the object under test in the second image according to the coverage area of ​​the target contour image. Thus, the illumination brightness parameter of the light-emitting element is determined based on the pixel value of each pixel point within the luminous area.

[0321] Optionally, determining the target detection parameters of the object to be tested based on the second image and the target application scenario includes:

[0322] If the target application scenario is the third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the brightness component of the pixels in the second image.

[0323] Based on the center point of the light spot image, at least two fifth images are obtained from the second image; wherein, any two of the at least two fifth images correspond to different field angles;

[0324] Based on the luminance and / or chromaticity components of multiple image regions in any of the at least two fifth images, the defect detection parameters of the object under test in any of the fifth images are determined.

[0325] In this embodiment of the disclosure, when the target application scenario is determined to be a third scenario, the luminance component of each pixel in the second image can be obtained;

[0326] Here, the second image can be converted into a second image of hue saturation value (HSV) type, and based on the second image of HSV type, the hue saturation value component of each pixel in the second image can be obtained.

[0327] Here, HSV is an intuitive color model. It is a color space established based on the intuitive characteristics of color. It is also called the hexagonal pyramid model. In this color model, the parameters of color are hue (H), saturation (S), and lightness (V), which can also be referred to as three channels.

[0328] The luminance component of each pixel in the V channel image can be obtained by extracting the V channel image of the second HSV type image.

[0329] Based on the luminance component of each pixel in the second image, the central region of the light spot image formed by the light-emitting element of the object under test in the second image is determined, and based on the central region of the light spot image, the center point of the light spot image is determined.

[0330] Here, the second image can be divided into multiple image regions. Based on the luminance component of the pixels in each of the multiple image regions, the average luminance of each of the multiple image regions is determined. According to the average luminance of the multiple image regions, the image region with the largest average luminance is determined as the central region of the spot image, and the center point of the central region is determined as the center point of the spot image.

[0331] It should be noted that the image size of the second image can be obtained, and the size of the image region can be set based on the image size, thereby dividing the second image into proportional images.

[0332] It is understandable that in related technologies, the center point of the image in the second image is directly determined as the center point of the light spot image. However, considering that the position of the object under test on the production line may not be completely fixed when the second image is acquired, the light-emitting element of the object under test may not be centrally distributed in the light spot image formed in the second image, thus making the center point of the image in the second image not the center point of the light spot image.

[0333] Therefore, in determining the center point of the light spot image in the embodiments of this disclosure, the central region of the light spot image in the second image can be determined based on the brightness component of each pixel in the second image, thereby determining the center point of the light spot based on the central region of the light spot image.

[0334] After determining the center point of the light spot, a fifth image with at least two different field of view (FOV) angles can be obtained from the second image based on the center point of the light spot.

[0335] Here, the field of view angles corresponding to at least two second images can be set according to actual needs, and this embodiment does not limit this. For example, two fifth images can be obtained from the second images, wherein the field of view angles of the two fifth images are 0.7 FOV and 1.0 FOV, respectively.

[0336] At least two fifth images are divided into multiple image regions. The luminance and / or chrominance components of the multiple image regions in each fifth image are obtained respectively. Based on the luminance and / or chrominance components of the multiple image regions in the fifth image, the defect detection parameters of the object under test in each fifth image are determined respectively.

[0337] Here, the image size of each fifth image can be obtained, and the size of the image region can be set based on the image size, thereby dividing the fifth image into proportional images; it should be noted that the size of the image region in the fifth image is smaller than the size of the image region in the second image.

[0338] In this embodiment of the present disclosure, after determining that the target application scenario of the object under test is a third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the second image; and multiple fifth images with different field of view angles are extracted from the second image with the center point of the light spot as the center; since the center of the fifth image is the center point of the light spot, and the brightness distribution in the light spot image shows a trend of uniform decay from the center point of the light spot to the surrounding area, the change trend of the brightness components and / or chromaticity components between multiple image regions is determined according to the brightness components and / or chromaticity components of multiple image regions in each fifth image, thereby determining the defect detection parameters of the light-emitting element of the object under test in any fifth image.

[0339] Optionally, the defect detection parameters include: uniformity defect parameters;

[0340] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes:

[0341] Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions;

[0342] Based on the luminance and chrominance components of the pixels in the central image region and the corner image region of any of the fifth images, the average luminance and average chrominance corresponding to the central image region and the corner image region in any of the fifth images are determined respectively.

[0343] The brightness uniformity and color uniformity of the corner image region are determined based on the ratio between the average brightness and average chromaticity of the corner image region and the average brightness and average chromaticity of the center image region.

[0344] Based on the brightness uniformity and chromaticity uniformity of the corner image region, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images;

[0345] The uniformity defect parameter of the object under test is determined based on the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

[0346] In this embodiment of the disclosure, the defect detection parameters may include: uniformity defect parameters;

[0347] It should be noted that, since the light-emitting area of ​​the light-emitting element usually tends to radiate evenly from the central light-emitting point to the surrounding areas, the luminance components and / or chrominance components of the corner areas of the light spot image are smaller than those of the central area of ​​the light spot image, and the luminance components and / or chrominance components of multiple corner areas of the light spot image should be the same or similar.

[0348] The uniformity defect parameter of the fifth image is used to describe at least the difference in luminance components and / or chromaticity components between multiple corner regions of the spot image and the central region of the spot image within the fifth image.

[0349] In this embodiment of the disclosure, after obtaining the at least two fifth images, the at least two fifth images can be divided into multiple image regions, and the center image region and multiple corner image regions of each fifth image can be determined from the multiple image regions.

[0350] Here, the distance between the center points of any two corner image regions and the center point of the central image region is the same.

[0351] Here, the method for dividing the image region can be set according to actual needs, and this embodiment does not limit it. For example, each fifth image can be divided into 3*3 image regions of equal area; the image region of the fifth image includes 1 central image region and 4 corner image regions.

[0352] It should be noted that, since at least two fifth images are images taken from the second image at different field of view angles with the center point of the light spot as the center, the central image region of the fifth image is the central region of the light spot image;

[0353] Based on this, the embodiments of this disclosure obtain the luminance and chrominance components of pixels in the central image region and the corner image regions of any fifth image, and determine the average luminance and average chrominance of the central image region based on the luminance and chrominance components of pixels in the central image region; and determine the average luminance and average chrominance of each corner image region based on the luminance and chrominance components of pixels in each corner image region.

[0354] The average brightness and average chromaticity of each of the plurality of corner image regions are determined, and the ratio between these ratios is given to the average brightness and average chromaticity of the central image region. Based on the ratios of the average brightness, the brightness uniformity of each corner image region is determined. Based on the ratios of the average chromaticity, the chromaticity uniformity of each corner image region is determined.

[0355] Based on the brightness uniformity of multiple corner image regions, the maximum brightness uniformity and the minimum brightness uniformity are determined. Based on the difference between the maximum brightness uniformity and the minimum brightness uniformity, the brightness uniformity range of the object under test in the fifth image is determined.

[0356] It is understood that the extreme difference in brightness uniformity of the test object can be used to describe the difference in brightness uniformity among multiple corner image regions within the fifth image. If the extreme difference in brightness uniformity of the test object is large, it indicates that at least two corner image regions with significant brightness differences exist within the multiple corner image regions of the fifth image, meaning that the light-emitting element may have a brightness uniformity defect. If the extreme difference in brightness uniformity of the test object is small, it indicates that the brightness of multiple corner image regions of the fifth image is the same or similar.

[0357] Based on the chromaticity uniformity of multiple corner image regions, the maximum and minimum chromaticity uniformity are determined. Based on the difference between the maximum and minimum chromaticity uniformity, the chromaticity uniformity range of the object under test in the fifth image is determined.

[0358] It is understood that the color uniformity range of the test object can be used to describe the difference in color uniformity among multiple corner image regions within the fifth image. If the color uniformity range of the test object is large, it indicates that at least two corner image regions with significant color differences exist within the multiple corner image regions of the fifth image, suggesting a possible color uniformity defect in the light-emitting element. If the color uniformity range of the test object is small, it indicates that the color gradations of multiple corner image regions of the fifth image are the same or similar.

[0359] The uniformity defect parameters of the object under test can be determined by the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

[0360] The average brightness of the central image region of any fifth image can be compared with a preset average brightness threshold to obtain a first comparison result;

[0361] The brightness uniformity range of the object under test in any fifth image is compared with a preset first range threshold to obtain a second comparison result;

[0362] The color uniformity range of the object under test in any fifth image is compared with a preset second range threshold to obtain a third comparison result;

[0363] If the first comparison result, the second comparison result, and the third comparison result of any fifth image all indicate that the detection parameter is greater than or equal to the detection threshold, then the uniformity detection of the fifth image is deemed to be qualified.

[0364] If at least one of the first, second, and third comparison results of any fifth image indicates that the detection parameter is less than the detection threshold, then the uniformity detection of the fifth image is determined to be unqualified.

[0365] After determining the uniformity detection result of each of the at least two fifth images, the uniformity detection result of the object to be tested is determined.

[0366] Here, when the uniformity detection of at least two fifth images is qualified, the uniformity detection of the object under test is qualified, that is, the object under test does not have uniformity defects; if the uniformity detection of at least one of the at least two fifth images is unqualified, the uniformity detection of the object under test is determined to be unqualified.

[0367] This embodiment of the disclosure acquires the central image region and corner image regions of each of multiple fifth images, and determines the average brightness and average chromaticity of the central image region and corner image regions of the fifth image. Based on the average brightness ratio and average chromaticity ratio between the corner image regions and the central image region, the brightness uniformity and chromaticity uniformity of the corner image regions are determined, thereby determining the brightness uniformity range that reflects the brightness difference among multiple corner image regions in the fifth image and the chromaticity uniformity range that reflects the chromaticity difference among multiple corner image regions in the fifth image. This facilitates the determination of the uniformity defect parameters of the object under test based on the average brightness, brightness uniformity range, and chromaticity uniformity range of the central image regions of at least two fifth images, thereby realizing the detection of the luminous uniformity of the light-emitting element of the object under test in the second image.

[0368] Optionally, the defect detection parameters include: black spot defect parameters;

[0369] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions in any of the fifth images includes:

[0370] Based on the center point of the light spot, any one of the at least two fifth images is divided into four first image regions of equal area;

[0371] Divide any one of the four first image regions into multiple non-overlapping sub-image regions;

[0372] Based on the luminance components of the plurality of sub-image regions, a first luminance difference is determined between a first sub-image region and an adjacent second sub-image region within the plurality of sub-image regions; wherein, the first sub-image region is any sub-image region of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0373] The black spot defect parameters of the object under test are determined based on multiple first brightness differences within a first image region in any one of the at least two fifth images.

[0374] In this embodiment of the disclosure, the defect detection parameters may include: black spot defect parameters;

[0375] It should be noted that, since the light-emitting area of ​​a light-emitting element typically exhibits a tendency to diffuse uniformly outward from the central light-emitting point, the brightness component of pixels within a light spot image shows a distribution trend of uniformly decreasing outward from the center of the light spot. It can be understood that if the change in brightness component between pixels in two adjacent image regions within the light spot image does not exhibit a uniform attenuation trend from the center of the light spot outward, it can be determined that at least one of the adjacent image regions may have an abnormal brightness attenuation, i.e., the light spot image may contain black spots.

[0376] The black spot defect parameter of the fifth image is used to describe at least the abnormal attenuation of pixels within the spot image of the fifth image;

[0377] In this embodiment of the present disclosure, after acquiring the at least two fifth images, the at least two fifth images can be divided into four first image regions based on the center point of the light spot; here, the four first image regions have the same area and do not overlap with each other.

[0378] It should be noted that since the four first image regions are image regions that are uniformly divided based on the center point of the light spot in the fifth image, and since the difference in brightness component between any pixel in the first image region and the center point of the light spot is positively correlated with the distance difference between the pixel and the center point of the light spot, the brightness component of the pixel in each first image region that is close to the center point of the light spot is greater than the brightness component of the pixel in the first image region that is far away from the center point of the light spot.

[0379] Each first image region is divided into multiple sub-image regions, and the multiple sub-image regions of the first image region do not overlap with each other; based on the positional distribution of the multiple sub-image regions within the first image region, a first sub-image region and a second sub-image region are determined; wherein, the first sub-image region and the second sub-image region are adjacent;

[0380] It should be noted that the first sub-image region can be any of the plurality of sub-image regions; the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0381] Here, the distance between the sub-image region and the center point of the light spot can be determined by the distance between the image center point of the sub-image region and the center point of the light spot.

[0382] It is understandable that a sub-image region can be a first sub-image region or a second sub-image region; for example, such as Figure 3 As shown, Figure 3 This is a schematic diagram illustrating multiple sub-image regions of a first image region according to an exemplary embodiment. The first image region can be divided into 3*3 sub-image regions, wherein sub-image region 1 is the sub-image region within the first image region that is closest to the center point of the light spot, and sub-image region 9 is the sub-image region within the first image region that is furthest from the center point of the light spot. Wherein, when sub-image region 1 is the first sub-image region, sub-image region 5 can be the second sub-image region adjacent to the first sub-image region (i.e., sub-image region 1); when sub-image region 5 is the first sub-image region, sub-image region 9 can be the second sub-image region adjacent to the first sub-image region (i.e., sub-image region 5).

[0383] By acquiring the luminance components of pixels within multiple sub-image regions, the average luminance of each sub-image region is determined; based on the average luminance of the multiple sub-image regions, a first luminance difference is determined between any first sub-image region and an adjacent second sub-image region within the multiple sub-image regions.

[0384] It should be noted that, since the luminance component of the pixels closer to the center of the light spot in the first image region is greater than the luminance component of the pixels farther away from the center of the light spot in the first image region, and the distance between the second sub-image region and the center of the light spot is greater than the distance between the adjacent first sub-image region and the center of the light spot, the average brightness of any first sub-image region in the multiple sub-image regions is greater than the average brightness of the adjacent second sub-image regions. That is, the first brightness difference between the first sub-image region and the adjacent second sub-image region should be greater than the preset first brightness difference threshold.

[0385] Here, the first brightness difference threshold can be set according to actual needs, and this embodiment does not limit it. For example, the first brightness difference threshold can be 0.

[0386] It is understood that the first brightness difference between any first sub-image region and the adjacent second sub-image region within the first image region is greater than 0, indicating that the change in brightness components between pixels in two adjacent sub-image regions within the first image region shows a trend of uniform decay from the center of the light spot outwards, meaning that there are no black spots in the first image region.

[0387] If at least one first sub-image region in the first image region has a first brightness difference less than or equal to 0 with an adjacent second sub-image region, it indicates that the change in brightness components between pixels in two adjacent sub-image regions in the first image region does not show a trend of uniform decay from the center of the light spot outwards, meaning that there may be a black spot image in the first image region.

[0388] Therefore, multiple first brightness differences in the first image region within each fifth image can be determined as black spot defect parameters of the fifth image; multiple first brightness differences within the fifth image are compared with a first brightness difference threshold to obtain multiple comparison results; if all multiple comparison results indicate that the first brightness difference is greater than the first brightness difference threshold, the black spot detection of the fifth image is determined to be qualified.

[0389] If at least one of the multiple comparison results indicates that the first brightness difference is less than or equal to the first brightness difference threshold, the black spot detection of the fifth image is determined to be unqualified.

[0390] Based on the black spot detection results of the at least two fifth images, if the black spot detection of the at least two fifth images is qualified, it indicates that the black spot detection of the object under test in the second image is qualified; if the black spot detection of at least one of the at least two fifth images is unqualified, it indicates that the black spot detection of the object under test in the second image is unqualified, and the light-emitting element of the object under test has a black spot defect.

[0391] In this embodiment, the center point of the light spot in each of the plurality of fifth images is taken as the center, and the fifth image is divided into four first image regions of equal area. Each first image region is further divided into multiple non-overlapping sub-image regions. A first brightness difference is determined between any one of the first sub-image regions and an adjacent second sub-image region. Since the first brightness difference can reflect the brightness change trend between the first sub-image region and the adjacent second sub-image region, the brightness component of the pixels in the plurality of fifth images is determined based on the multiple first brightness differences of the first sub-image regions in the plurality of fifth images to determine whether the brightness component of the pixels in the plurality of fifth images shows a distribution trend of uniformly decreasing from the center point of the light spot to the surrounding areas, thereby realizing the detection of black spots of the light-emitting element of the object under test in the second image.

[0392] Optionally, the defect detection parameters include: black border defect parameters;

[0393] The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes:

[0394] Based on the center point of the light spot, any one of the at least two fifth images is divided into two second image regions of equal area;

[0395] The two second image regions are evenly divided into multiple sub-image regions along the horizontal or vertical direction;

[0396] Based on the luminance components of the plurality of sub-image regions, a second luminance difference is determined between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions; the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot;

[0397] Based on the luminance components of the multiple sub-image regions, a third luminance difference is determined between the third sub-image region and the fifth sub-image region; the third sub-image region and the fifth sub-image region are two sub-image regions within different second image regions, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot;

[0398] The black border defect parameters of the object under test are determined based on multiple second brightness differences and multiple third brightness differences in the second image region within any of the at least two fifth images.

[0399] In this embodiment of the disclosure, the defect detection parameters may include: black border defect parameters;

[0400] It should be noted that, since the light-emitting area of ​​a light-emitting element typically exhibits a uniform diffusion trend from the central light-emitting point outwards, the brightness component of pixels within a light spot image shows a distribution trend of uniformly decreasing from the center of the light spot outwards. It can be understood that if the change in brightness component between two adjacent rows or columns of pixels within the light spot image does not show a uniform attenuation trend from the center of the light spot outwards, it can be determined that at least one row or column of pixels in the adjacent rows or columns may exhibit abnormal brightness attenuation, meaning that the light spot image may contain black borders.

[0401] The black border defect parameter of the fifth image is used to describe at least one row or at least one column of pixels in the spot image of the fifth image;

[0402] In this embodiment of the present disclosure, after acquiring the at least two fifth images, the at least two fifth images can be divided into two second image regions based on the center point of the light spot; here, the two second image regions have the same area and do not overlap.

[0403] It should be noted that, since the two second image regions are image regions uniformly divided based on the center point of the light spot in the fifth image, the difference in luminance component between any row or column of pixels in the second image region and the center point of the light spot is positively correlated with the distance difference between the pixel and the center point of the light spot. This results in the luminance component of the pixel row (or pixel column) closer to the center point of the light spot in each second image region being greater than the luminance component of the pixel row (or pixel column) farther away from the center point of the light spot in the second image region.

[0404] Each second image region is uniformly divided into multiple sub-image regions along the horizontal or vertical direction. Here, the multiple sub-image regions have the same area and do not overlap with each other.

[0405] Based on the positional distribution of the multiple sub-image regions within the two second image regions, the third, fourth, and fifth sub-image regions are determined.

[0406] The third and fourth sub-image regions are two adjacent sub-image regions within the same second image region; the fifth and third sub-image regions are two sub-image regions within different second image regions.

[0407] It should be noted that the third sub-image region can be any sub-image region of the multiple sub-image regions of the second image region; the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot; the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot. It can be understood that the third sub-image region and the fifth sub-image region are symmetrical along the dividing line between the two second image regions.

[0408] By acquiring the luminance components of pixels within multiple sub-image regions, the average luminance of each sub-image region is determined. Based on the average luminance of the multiple sub-image regions, a second luminance difference between any third sub-image region and an adjacent fourth sub-image region within the multiple sub-image regions is determined; and a third luminance difference between the third sub-image region and a fifth sub-image region is determined.

[0409] It should be noted that, since the light-emitting area of ​​the light-emitting element usually shows a trend of uniformly radiating outward from the central light-emitting point, the brightness component of the pixels in the light spot image shows a distribution trend of uniformly decreasing outward from the center of the light spot; therefore, the average brightness of the third sub-image area should be greater than the average brightness of the adjacent fourth sub-image area; the average brightness of the third sub-image area should be the same as or similar to the average brightness of the fifth sub-image area.

[0410] The second brightness difference between multiple third sub-image regions and adjacent fourth sub-image regions within the fifth image is determined, as well as the third brightness difference between multiple third sub-image regions and symmetrical fifth sub-image regions. The multiple second brightness differences are compared with preset second brightness difference thresholds, and the multiple third brightness differences are compared with preset third brightness difference thresholds.

[0411] Here, the second brightness difference threshold and the third brightness difference threshold can be set according to actual needs. This embodiment does not limit this. For example, the second brightness difference threshold and the third brightness difference threshold can both be 0.

[0412] It is understood that the second brightness difference between any third sub-image region and the adjacent fourth sub-image region within the second image region is greater than 0, and the third brightness difference between the third sub-image region and the symmetrical fifth sub-image region is less than or equal to 0. This indicates that the change in the brightness component between pixels in two adjacent sub-image regions within any second image region shows a trend of uniform decay from the center of the light spot outwards, meaning that there is no black border image within the second image region.

[0413] Therefore, multiple second brightness differences and multiple third brightness differences within the second image region of each fifth image can be determined as the black border defect parameters of the fifth image; multiple second brightness differences within the fifth image are compared with a second brightness difference threshold, and multiple third brightness differences are compared with a third brightness difference threshold to obtain multiple comparison results; if the multiple comparison results indicate that the second brightness difference is greater than the second brightness difference threshold and the third brightness difference is less than or equal to the third brightness difference threshold, the black border detection of the fifth image is determined to be qualified;

[0414] If at least one of the multiple comparison results indicates that the second brightness difference is less than or equal to the second brightness difference threshold, and / or the third brightness difference is greater than the third brightness difference threshold, then the black border detection of the fifth image is determined to be unqualified.

[0415] Based on the black edge detection results of the at least two fifth images, if the black edge detection of the at least two fifth images is qualified, it indicates that the black edge detection of the object under test in the second image is qualified; if the black edge detection of at least one of the at least two fifth images is unqualified, it indicates that the black edge detection of the object under test in the second image is unqualified, and the light-emitting element of the object under test has a black edge defect.

[0416] In this embodiment, the center point of the light spot in each of the plurality of fifth images is taken as the center, and each fifth image is divided into two second image regions of equal area. Each second image region is further divided into multiple non-overlapping sub-image regions along the horizontal or vertical direction. A second brightness difference is determined between any third sub-image region and an adjacent fourth sub-image region, and a third brightness difference is determined between the third sub-image region and a symmetrical fifth sub-image region. Since the second brightness difference can reflect the brightness change trend between two adjacent sub-image regions within the same second image region, and the third brightness difference can reflect the brightness change trend between two symmetrical sub-image regions within different second image regions, the brightness components of pixel rows or pixel columns in the plurality of fifth images are determined to show a distribution trend of uniformly decreasing from the center point of the light spot outwards, thereby realizing the black edge detection of the light-emitting element of the object under test in the second image.

[0417] Optionally, obtaining the second image containing the object under test based on the acquired first image includes:

[0418] Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image;

[0419] Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested;

[0420] Based on the position offset information, adjust the position of the image cropping window;

[0421] Using the adjusted image capture window, the second image containing the object under test is obtained from the first image.

[0422] In this embodiment of the disclosure, a template image of the object to be tested can be obtained, and the position information of the object to be tested can be determined from the first image based on the template image of the object to be tested.

[0423] Here, the template image is used at least to describe the contour information of the object under test;

[0424] It is understandable that, since the processing objects on the same production line may include multiple different test objects, and considering that the structures of different test objects may differ, in order to achieve accurate positioning of the test object, a template image of the test object can be obtained, and the test object can be positioned in the first image based on the contour information of the test object indicated by the template image.

[0425] The cropping position information of the image cropping window is obtained. Based on the position information of the object to be tested and the cropping position information of the image cropping window, the position offset information of the image cropping window relative to the object to be tested is determined. Based on the position offset information, the position of the image cropping window is adjusted so that the object to be tested in the first image is located within the image cropping window, thereby using the image cropping window to obtain the second image from the first image.

[0426] It should be noted that an image cropping window may be set within the first image. The cropping position information of the image cropping window may be preset based on the position information of the object to be tested within the first image, so as to use the image cropping window to crop each of the first images to obtain the second image where the object to be tested is located.

[0427] Since the cropping position information of the image cropping window is preset, that is, the cropping position information is fixed, but considering that the placement position of the object to be tested may be offset, the second image cropped only partially contains the object to be tested, which is not conducive to subsequent processing.

[0428] The position information of the object under test is used to indicate the actual position of the object under test within the first image, while the cropping position information of the image cropping window is used to indicate the predicted position of the object under test within the first image. Ideally, the position information of the object under test should be the same as the cropping position information of the image cropping window. However, considering that the placement position of the object under test may be offset, the position information of the object under test should be different from the cropping position information of the image cropping window. That is, the actual position of the object under test within the first image is different from the predicted position of the object under test within the first image.

[0429] In order to extract a second image containing the complete object under test from the first image, this embodiment of the present disclosure determines position offset information based on the position information of the object under test and the cropping position information of the image cropping window; the position of the image cropping window is adjusted based on the position offset information so that the cropping position information of the adjusted image cropping window is the same as the position information of the object under test, thereby using the image cropping window to obtain a second image containing the object under test.

[0430] This disclosure also provides the following embodiments:

[0431] like Figure 4 As shown, Figure 4 This is a flowchart illustrating a detection method according to an exemplary embodiment. Figure 2 The method includes:

[0432] Step S201: Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image;

[0433] Step S202: Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested;

[0434] In this embodiment of the disclosure, the image cropping window may be a pre-set ROI window;

[0435] Step S203: Based on the position offset information, adjust the position of the image cropping window; using the adjusted image cropping window, obtain the second image containing the object under test from the first image.

[0436] Step S204: Divide the second image into multiple image regions and determine the average grayscale value of each image region;

[0437] In this embodiment of the disclosure, the second image can be converted into a grayscale image, and a sliding window of a preset size can be used to traverse the grayscale image to obtain multiple image regions; based on the grayscale value of each pixel in the multiple image regions, the average grayscale value of the multiple image regions is determined respectively.

[0438] Step S205: Determine the grayscale range of the second image based on the average grayscale values ​​of the multiple image regions;

[0439] The maximum and minimum average gray levels can be determined based on the average gray levels of multiple image regions; the gray level range of the second image can be determined based on the difference between the maximum and minimum average gray levels.

[0440] It should be noted that the grayscale range can reflect the range of brightness variations within the second image.

[0441] Step S206: Based on the grayscale range of the second image, determine the target application scenario where the object under test is currently located;

[0442] It should be noted that on the production line of terminal equipment, the application scenarios for color detection can be divided into three categories: the first scenario is the color discrimination of terminal equipment and the assembly inspection of materials within the terminal equipment; the second scenario is the brightness detection of light-emitting elements (such as flashlights, power lights and / or soft lights) within the terminal equipment; and the third scenario is the defect detection of light-emitting elements within the terminal equipment.

[0443] The target application scenario of the object under test in the second image can be determined based on the gray range to which the gray range of the second image belongs.

[0444] For example, if the grayscale range of the second image is less than 15, it is determined that the test environment where the object under test is located in the second image has relatively uniform brightness, and the target application scenario is the first scenario;

[0445] If the grayscale range of the second image is greater than 30, it is determined that the test environment of the object under test in the second image is not uniformly bright, and the target application scenario is the second scenario.

[0446] If the grayscale range of the second image is greater than or equal to 15 and less than or equal to 30, the target application scenario is determined to be the third scenario.

[0447] Step S207: Based on the second image and the target application scenario, determine the target detection parameters of the object to be tested; if the target detection parameters are greater than or equal to a preset detection threshold, determine that the object to be tested in the target application scenario is qualified for detection.

[0448] Here, the target detection parameters are different for different application scenarios; the preset detection thresholds are also different; it is understandable that the target detection parameters obtained may also be different because different detections are performed on the target object under different application scenarios.

[0449] After determining the target application scenario, the target detection parameters are obtained based on the second image; the target detection parameters are compared with the detection threshold corresponding to the target application scenario to determine whether the object to be tested in the target application scenario is qualified for detection.

[0450] For example, such as Figure 5 As shown, Figure 5 This is a schematic diagram illustrating a process for determining a target application scenario according to an exemplary embodiment.

[0451] like Figure 6 As shown, Figure 6 This is a flowchart illustrating a detection method for an object to be tested in a first scenario, according to an exemplary embodiment. The method includes:

[0452] Step S301: Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model;

[0453] In this embodiment of the disclosure, multiple color template images can be acquired, and the second image and the multiple color template images can be converted into images of the RGB color model; based on the three channel images corresponding to the second image, the grayscale mean of the three channel images corresponding to the second image is determined respectively; based on the three channel images corresponding to each color template image in the multiple color template images, the grayscale mean of the three channel images corresponding to each color template image is determined respectively.

[0454] In some embodiments, if the second image is a grayscale image, the average grayscale value of the second image is directly determined; and the plurality of color template images are converted into grayscale images to determine the average grayscale value of the plurality of color template images.

[0455] Step S302: Based on the average grayscale values ​​of the three channels of the second image and the average grayscale values ​​of the three channels of each color template image in the plurality of color template images, determine the mean square error value between the second image and each color template image in the plurality of color template images.

[0456] Step S303: Normalize the mean square error value between the second image and each of the multiple color template images; based on the normalized mean square error values, determine the color similarity between the second image and each of the multiple color template images.

[0457] Here, the mean square error value between the second image and multiple color template images can be normalized based on a preset normalization coefficient.

[0458] It should be noted that the normalization coefficients for the second image in RGB format are different from those for the second image in grayscale format.

[0459] For example, if the second image is a grayscale image, the normalization coefficient can be 255; if the second image is an RGB image, the normalization coefficient can be 255*3.

[0460] Step S304: Based on the color similarity between the second image and the plurality of color template images, determine the color parameters of the object to be tested; wherein, the color parameters are used to determine the target color configuration information of the object to be tested;

[0461] After determining the color similarity between the second image and each of the multiple color template images, the color parameter corresponding to the color template image with the highest color similarity is determined as the color parameter of the object to be tested; and based on the color parameter, the target color configuration information matching the color parameter is obtained.

[0462] Step S305: Obtain at least one third image from the second image; the third image is the image area where the material to be tested is located in the second image; based on the target color configuration information of the object to be tested, obtain at least one target color image of the material to be tested within the object to be tested;

[0463] The contour information of the material to be tested within the object to be tested can be obtained. Based on the contour matching method, the image region where the material to be tested is located is determined from the second image, and the image region where the material to be tested is located is cropped to obtain the third image.

[0464] Here, considering that the image area of ​​the material to be tested may contain information such as the outline of the material to be tested, when performing color detection, the central image area of ​​the image area where the material to be tested is located can be directly extracted, and the central image area is determined as the third image.

[0465] Step S306: Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image;

[0466] Step S307: Based on the at least one third image and the target color image of the material to be tested within the third image, determine the color similarity between the material to be tested within the at least one third image and the target color image;

[0467] Step S308: Based on the mean gray level, gray level range, and color similarity of the material to be tested in the at least one third image and a preset detection threshold range, determine whether the detection of the object to be tested in the first scene is qualified.

[0468] After obtaining the mean gray level, gray level range, and color similarity of the material to be tested in the third image, the mean gray level, gray level range, and color similarity can be compared with the corresponding detection threshold ranges respectively.

[0469] If the second image is an RGB image, the grayscale mean and grayscale range of the material under test may include the channel grayscale mean and channel grayscale range of the three channels. Then, the seven detection parameters of the third image (three channel grayscale mean, three channel grayscale range and one color similarity) are compared with the preset detection threshold range. If at least four of the seven detection parameters of the third image are within the detection threshold range, it is determined that the material under test of the object under test is not mixed or the material under test has been mounted. Otherwise, it is determined that the color of the material under test of the object under test is mixed or the material under test is not mounted.

[0470] If the second image is a grayscale image, the three detection parameters (grayscale mean, grayscale range, and color similarity) of the third image are compared with the preset detection threshold range. If at least two of the three detection parameters of the third image are within the detection threshold range, it is determined that the test material of the test object is not mixed or the test material has been labeled. Otherwise, it is determined that the test material of the test object is mixed in color or the test material is not labeled.

[0471] For example, such as Figure 7 As shown, Figure 7 This is a schematic diagram illustrating the process of color discrimination and material assembly detection of a terminal device in a first scenario according to an exemplary embodiment.

[0472] like Figure 8 As shown, Figure 8 This is a flowchart illustrating a detection method for an object under test in a second scenario, according to an exemplary embodiment. The method includes:

[0473] Step S401: Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image; based on the gray histogram of the second image, determine a first type of gray level containing at least two gray levels.

[0474] In this embodiment of the disclosure, the second image can be converted into a grayscale image, and a grayscale histogram corresponding to the second image can be determined based on the grayscale image.

[0475] In some embodiments, the second image is converted into a grayscale image, the grayscale image is subjected to mean filtering, and the grayscale histogram corresponding to the second image is determined based on the mean-filtered grayscale image.

[0476] It should be noted that the grayscale histogram includes: a first type of grayscale level and a second type of grayscale level; the frequency corresponding to any grayscale level in the first type of grayscale level is greater than the frequency corresponding to any grayscale level in the second type of grayscale level.

[0477] Step S402: Based on the gray values ​​corresponding to at least two gray levels within the first type of gray levels, determine the target gray level with the largest gray value; determine the target threshold of the second image based on the difference between the gray value corresponding to the target gray level and a preset threshold.

[0478] Step S403: Based on the target threshold, the second image is binarized to obtain a binarized image of the second image;

[0479] Step S404: Perform morphological opening operation on the binarized image to obtain a processed image; perform contour detection on the processed image to determine multiple contour images within the processed image; and determine the target image contour with the largest contour area based on the contour areas of the multiple contour images.

[0480] Step S405: Determine the coverage area of ​​the target image contour within the processed image; based on the coverage area, obtain a fourth image from the second image; wherein, the fourth image is an image region within the second image that coincides with the coverage area;

[0481] After determining the coverage area of ​​the target image contour within the processed image, the pixel values ​​of multiple pixels outside the coverage area in the second image are set to 0, and the pixel values ​​of multiple pixels within the coverage area in the second image are set to the channel grayscale values ​​of the three channels at the corresponding positions in the RGB format of the second image; based on the pixel values ​​of the multiple pixels, a fourth image is determined.

[0482] Step S406: Based on the fourth image, determine the illumination brightness parameters of the object to be tested;

[0483] Based on the grayscale values ​​of the three channels of each pixel in the fourth image, the average grayscale value of the three channels of the fourth image is determined; the average grayscale value of the three channels of the fourth image is determined as the illumination brightness parameter of the object to be tested.

[0484] Step S407: Based on the lighting brightness parameters of the object under test and the preset detection threshold range, determine whether the detection of the object under test in the second scenario is qualified.

[0485] The average gray values ​​of the three channels of the fourth image are compared with the preset detection threshold range. If the average gray values ​​of the three channels are all within the detection threshold range, the brightness detection of the object under test is determined to be qualified. If the average gray value of at least one of the three channels is not within the detection threshold range, the brightness detection of the object under test is determined to be unqualified.

[0486] For example, such as Figure 9 As shown, Figure 9 This is a schematic diagram illustrating the process of detecting the brightness of the light-emitting element of a terminal device in a second scenario according to an exemplary embodiment.

[0487] like Figure 10 As shown, Figure 10 This is a flowchart illustrating a detection method for an object under test in a third scenario, according to an exemplary embodiment. The method includes:

[0488] Step S501: Based on the luminance components of the pixels in the second image, determine the center point of the light spot image formed by the object under test in the second image;

[0489] In this embodiment of the disclosure, the second image can be converted into an HSV format image. The size of the image region is set according to the size and aspect ratio of the HSV format image. The HSV format image is divided into multiple image regions of equal area according to the size of the image region. The luminance component of the pixel in each image region is obtained, and the average luminance of each image region is determined. The image region with the largest average luminance is determined as the central region of the HSV format image, and the center point of the central region is determined as the center point of the spot image.

[0490] Step S502: Based on the center point of the light spot in the light spot image, at least two fifth images are obtained from the second image; wherein, the field of view of any two of the at least two fifth images is different.

[0491] Here, the 0.7 FOV and 1.0 FOV of the second image are determined with the center point of the light spot as the center, and the images of these two fields of view are cropped from the second image as the fifth image.

[0492] Step S503: Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions;

[0493] Here, the size of the image region is set according to the aspect ratio of the width and height of the fifth image. Based on the size of the image region, the fifth image is divided into multiple image regions. And from the multiple image regions, the central image region and the corner image regions are determined.

[0494] Step S504: Based on the luminance and chrominance components of pixels in the center image region and the corner image region of any fifth image, determine the average luminance and average chrominance corresponding to the center image region and the corner image region in any fifth image, respectively; based on the ratio between the average luminance and average chrominance of the corner image region and the average luminance and average chrominance of the center image region, determine the luminance uniformity and chrominance uniformity of the corner image region;

[0495] Step S505: Based on the brightness uniformity and chromaticity uniformity of the corner image regions, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images; based on the average brightness of the central image region of any of the at least two fifth images, the brightness uniformity range and chromaticity uniformity range of the object under test, determine the uniformity defect parameter of the object under test; wherein, the uniformity defect parameter is used to determine whether there is a uniformity defect in the light-emitting element within the object under test;

[0496] Here, the average brightness of the central image region, the brightness uniformity range of the test object, and the chromaticity uniformity range can be compared with preset detection thresholds. If the average brightness, the brightness uniformity range, and the chromaticity uniformity range are all greater than the detection thresholds, it is determined that the light-emitting element in the test object does not have uniformity defects; otherwise, it is determined that the light-emitting element in the test object has uniformity defects.

[0497] Step S506: Based on the center point of the light spot, divide any one of the at least two fifth images into four first image regions of equal area; divide any one of the four first image regions into multiple non-overlapping sub-image regions;

[0498] Here, the fifth image is divided into four equal regions of the first image (i.e., upper left, upper right, lower left, and lower right) with the center point of the light spot as the center.

[0499] Multiple first image regions can be rotated so that all four first image regions are transformed to have the brightest upper left corner; and each first image region is divided into multiple non-overlapping sub-image regions.

[0500] Step S507: Based on the luminance components of the plurality of sub-image regions, determine the first luminance difference between the first sub-image region and the adjacent second sub-image region within the plurality of sub-image regions; based on the plurality of first luminance differences of the first image region within any of the at least two fifth images, determine the black spot defect parameter of the object under test; wherein, the black spot defect parameter is used to determine whether there is a black spot defect in the light-emitting element within the object under test;

[0501] Here, the first sub-image region is any one of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0502] The average brightness of each sub-image region can be determined based on the brightness components of multiple sub-image regions; and the first brightness difference between each sub-image region (i.e., the first sub-image region) and its adjacent sub-image region to the lower right (i.e., the second sub-image region) can be determined by traversing the region.

[0503] It is understandable that, since the top left corner of each of the multiple first image regions is the brightest after rotation, the average brightness of each sub-image region is greater than the average brightness of its adjacent sub-image region to the lower right. That is, the first brightness difference between two sub-image regions cannot be less than 0. If the first brightness difference between two sub-image regions is less than or equal to 0, it indicates that the first sub-image region is a black spot region.

[0504] Step S508: Based on the center point of the light spot, divide any one of the at least two fifth images into two second image regions of equal area; divide the two second image regions into multiple sub-image regions evenly along the horizontal or vertical direction;

[0505] The fifth image can be divided into two second image regions of equal area (i.e., upper and lower image regions) with the center point of the light spot as the center; and each of the two second image regions can be divided horizontally into multiple sub-image regions of equal area (i.e., horizontal image regions).

[0506] Step S509: Based on the luminance components of the plurality of sub-image regions, determine the second luminance difference between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions, and the third luminance difference between the third sub-image region and the fifth sub-image region;

[0507] Here, the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot;

[0508] The third sub-image region and the fifth sub-image region are two sub-image regions within different regions of the second image region, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot;

[0509] It can obtain the luminance components of pixels in multiple sub-image regions and determine the average luminance of multiple sub-image regions; in a traversal manner, it determines the second luminance difference between each sub-image region (i.e., the third sub-image region) and the adjacent fourth sub-image region; and determines the third luminance difference between each sub-image region (i.e., the third sub-image region) and the symmetrical fifth sub-image region.

[0510] Step S510: Based on multiple second brightness differences and multiple third brightness differences in the second image region within any of the at least two fifth images, determine the black edge defect parameters of the object under test; wherein, the black edge defect parameters are used to determine whether there is a black edge defect in the light-emitting element within the object under test.

[0511] It is understandable that, since the sub-image regions closer to the center of the light spot are brighter among the multiple second image regions, when determining whether the light-emitting element of the object under test has a black edge defect, it should be determined whether the second brightness difference and the third brightness difference simultaneously meet the preset conditions.

[0512] Here, if the second brightness difference is less than 0 and the absolute value of the second brightness difference is less than a preset detection threshold, it is determined that the second brightness difference meets the preset condition.

[0513] If the absolute value of the third brightness difference is less than the preset detection threshold, the third brightness difference is determined to meet the preset condition.

[0514] When the second brightness difference and the third brightness difference simultaneously meet the preset conditions, it is determined that the light-emitting element of the object under test does not have a black edge defect; if at least one of the second brightness difference and the third brightness difference does not meet the preset conditions, it is determined that the light-emitting element of the object under test has a black edge defect.

[0515] For example, such as Figure 11 As shown, Figure 11 This is a schematic diagram illustrating a process for defect detection of the light-emitting element of a terminal device in a third scenario, according to an exemplary embodiment.

[0516] This disclosure also provides a detection device. Figure 12 This is a schematic diagram of the structure of a detection device according to an exemplary embodiment, such as... Figure 12 As shown, the device is applied to a terminal device, and the detection device 100 includes:

[0517] The acquisition module 101 is used to acquire a second image containing the object under test based on the acquired first image; the second image is an image region within the first image that contains at least the object under test.

[0518] The first determining module 102 is used to determine the target application scenario where the object under test is currently located based on the second image;

[0519] The second determining module 103 is used to determine the target detection parameters of the object to be tested based on the second image and the target application scenario; wherein the target detection parameters of the object to be tested are different under different target application scenarios;

[0520] The detection module 104 is used to determine that the object to be tested in the target application scenario is qualified if the target detection parameters meet the preset detection conditions.

[0521] Optionally, the first determining module 102 is configured to:

[0522] The second image is divided into multiple image regions, and the average gray level of each image region is determined.

[0523] Based on the average gray values ​​of the multiple image regions, determine the maximum and minimum average gray values ​​within the multiple image regions;

[0524] The grayscale range of the second image is determined based on the maximum mean grayscale value and the minimum mean grayscale value.

[0525] Based on the grayscale range of the second image, the target application scenario of the object under test is determined; wherein, different grayscale ranges correspond to different application scenarios.

[0526] Optionally, the second determining module 103 is configured to:

[0527] If the target application scenario is the first scenario, the color similarity between the second image and the multiple color template images is determined based on the second image and the multiple color template images;

[0528] Based on the color similarity between the second image and the plurality of color template images, the color parameters of the object to be tested are determined; wherein, the color parameters are used to determine the target color configuration information of the object to be tested;

[0529] Based on the grayscale value of at least one material of the object under test in the second image and the target color configuration information, the color detection parameters of at least one material of the object under test are determined.

[0530] Optionally, the color detection parameters include at least: grayscale mean, grayscale range, and color similarity;

[0531] The second determining module 103 is used for:

[0532] At least one third image is obtained from the second image; the third image is the image region within the second image where the material to be tested is located;

[0533] Based on the target color configuration information of the object to be tested, obtain the target color image of at least one of the materials to be tested within the object to be tested;

[0534] Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image;

[0535] Based on the at least one third image and the target color image of the material to be tested within the third image, the color similarity between the material to be tested within the at least one third image and the target color image is determined.

[0536] Optionally, the second determining module 103 is configured to:

[0537] Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model;

[0538] Based on the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of each color template image in the plurality of color template images, the mean square error value between the second image and each color template image in the plurality of color template images is determined.

[0539] The mean square error value between the second image and each of the multiple color template images is normalized.

[0540] Based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

[0541] Optionally, the second determining module 103 is configured to:

[0542] If the target application scenario is the second scenario, determine the target threshold of the second image;

[0543] Based on the target threshold, the second image is binarized to obtain a binarized image of the second image;

[0544] Contour detection is performed on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image;

[0545] Based on the coverage area, a fourth image is obtained from the second image; wherein, the fourth image is an image region within the second image that overlaps with the coverage area;

[0546] Based on the fourth image, the illumination brightness parameters of the object under test are determined.

[0547] Optionally, the second determining module 103 is configured to:

[0548] Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image;

[0549] Based on the grayscale histogram of the second image, a first class of grayscale levels containing at least two grayscale levels is determined; wherein, the grayscale histogram includes: a first class of grayscale levels and a second class of grayscale levels; the frequency corresponding to any grayscale level in the first class of grayscale levels is greater than the frequency corresponding to any grayscale level in the second class of grayscale levels;

[0550] Based on the gray values ​​corresponding to at least two gray levels within the first type of gray level, determine the target gray level with the largest gray value;

[0551] The target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and the preset threshold.

[0552] Optionally, the second determining module 103 is configured to:

[0553] The binarized image is subjected to morphological operations to obtain a processed image;

[0554] Contour detection is performed on the processed image to identify multiple contour images within the processed image;

[0555] Based on the contour area of ​​the multiple contour images, the contour of the target image with the largest contour area is determined.

[0556] Determine the coverage area of ​​the target image contour within the processed image.

[0557] Optionally, the second determining module 103 is configured to:

[0558] If the target application scenario is the third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the brightness component of the pixels in the second image.

[0559] Based on the center point of the light spot image, at least two fifth images are obtained from the second image; wherein, any two of the at least two fifth images correspond to different field angles;

[0560] Based on the luminance and / or chromaticity components of multiple image regions in any of the at least two fifth images, the defect detection parameters of the object under test in any of the fifth images are determined.

[0561] Optionally, the defect detection parameters include: uniformity defect parameters;

[0562] The second determining module 103 is used for:

[0563] Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions;

[0564] Based on the luminance and chrominance components of the pixels in the central image region and the corner image region of any of the fifth images, the average luminance and average chrominance corresponding to the central image region and the corner image region in any of the fifth images are determined respectively.

[0565] The brightness uniformity and color uniformity of the corner image region are determined based on the ratio between the average brightness and average chromaticity of the corner image region and the average brightness and average chromaticity of the center image region.

[0566] Based on the brightness uniformity and chromaticity uniformity of the corner image region, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images;

[0567] The uniformity defect parameter of the object under test is determined based on the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

[0568] Optionally, the defect detection parameters include: black spot defect parameters;

[0569] The second determining module 103 is used for:

[0570] Based on the center point of the light spot, any one of the at least two fifth images is divided into four first image regions of equal area;

[0571] Divide any one of the four first image regions into multiple non-overlapping sub-image regions;

[0572] Based on the luminance components of the plurality of sub-image regions, a first luminance difference is determined between a first sub-image region and an adjacent second sub-image region within the plurality of sub-image regions; wherein, the first sub-image region is any sub-image region of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot;

[0573] The black spot defect parameters of the object under test are determined based on multiple first brightness differences within a first image region in any one of the at least two fifth images.

[0574] Optionally, the defect detection parameters include: black edge defect parameters;

[0575] The second determining module 103 is used for:

[0576] Based on the center point of the light spot, any one of the at least two fifth images is divided into two second image regions of equal area;

[0577] The two second image regions are evenly divided into multiple sub-image regions along the horizontal or vertical direction;

[0578] Based on the luminance components of the plurality of sub-image regions, a second luminance difference is determined between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions; the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot;

[0579] Based on the luminance components of the multiple sub-image regions, a third luminance difference is determined between the third sub-image region and the fifth sub-image region; the third sub-image region and the fifth sub-image region are two sub-image regions within different second image regions, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot;

[0580] The black border defect parameters of the object under test are determined based on multiple second brightness differences and multiple third brightness differences in the second image region within any one of the at least two fifth images.

[0581] Optionally, the acquisition module 101 is configured to:

[0582] Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image;

[0583] Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested;

[0584] Based on the position offset information, adjust the position of the image cropping window;

[0585] Using the adjusted image capture window, the second image containing the object under test is obtained from the first image.

[0586] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

[0587] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A detection method, characterized in that, The method includes: Based on the first image acquired, a second image is obtained where the object to be tested is located; the second image is an image region within the first image that contains at least the object to be tested. Based on the second image, determine the target application scenario in which the object under test is currently located; Based on the second image and the target application scenario, the target detection parameters of the object to be tested are determined; wherein, the target detection parameters of the object to be tested are different under different target application scenarios. If the target detection parameters meet the preset detection conditions, the object to be tested in the target application scenario is determined to be qualified. The step of determining the target application scenario of the object under test based on the second image includes: The second image is divided into multiple image regions, and the grayscale range of the second image is determined based on the average grayscale value of the multiple image regions. Based on the grayscale range to which the grayscale range of the second image belongs, the target application scenario of the object under test is determined; wherein, different grayscale ranges correspond to detection scenarios under different production stages of the terminal equipment production line.

2. The method according to claim 1, characterized in that, Determining the grayscale range of the second image based on the average grayscale values ​​of the multiple image regions includes: Based on the average gray values ​​of the multiple image regions, determine the maximum and minimum average gray values ​​within the multiple image regions; The grayscale range of the second image is determined based on the maximum mean grayscale value and the minimum mean grayscale value.

3. The method according to claim 1, characterized in that, The step of determining the target detection parameters of the object to be tested based on the second image and the target application scene includes: If the target application scenario is the first scenario, the color similarity between the second image and the multiple color template images is determined based on the second image and the multiple color template images; Based on the color similarity between the second image and the plurality of color template images, the color parameters of the object to be tested are determined; wherein, the color parameters are used to determine the target color configuration information of the object to be tested; Based on the grayscale value of at least one material of the object under test in the second image and the target color configuration information, the color detection parameters of at least one material of the object under test are determined.

4. The method according to claim 3, characterized in that, The color detection parameters include at least: grayscale mean, grayscale range, and color similarity; The step of determining the color detection parameters of at least one material of the test object based on the grayscale value of at least one material of the test object in the second image and the target color configuration information includes: At least one third image is obtained from the second image; the third image is the image region within the second image where the material to be tested is located; Based on the target color configuration information of the object to be tested, obtain the target color image of at least one of the materials to be tested within the object to be tested; Based on the at least one third image, determine the mean gray level and gray level range of the material to be tested within the at least one third image; Based on the at least one third image and the target color image of the material to be tested within the third image, the color similarity between the material to be tested within the at least one third image and the target color image is determined.

5. The method according to claim 3, characterized in that, The step of determining the color similarity between the second image and the multiple color template images based on the second image and the multiple color template images includes: Obtain the average grayscale values ​​of the second image and the plurality of color template images in the three channels of the color model; Based on the mean gray values ​​of the three channels of the second image and the mean gray values ​​of the three channels of each color template image in the plurality of color template images, the mean square error value between the second image and each color template image in the plurality of color template images is determined. The mean square error value between the second image and each of the multiple color template images is normalized. Based on the normalized mean square error values, the color similarity between the second image and each of the multiple color template images is determined.

6. The method according to claim 1, characterized in that, The step of determining the target detection parameters of the object to be tested based on the second image and the target application scene includes: If the target application scenario is the second scenario, determine the target threshold of the second image; Based on the target threshold, the second image is binarized to obtain a binarized image of the second image; Contour detection is performed on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image; Based on the coverage area, a fourth image is obtained from the second image; wherein, the fourth image is an image region within the second image that overlaps with the coverage area; Based on the fourth image, the illumination brightness parameters of the object under test are determined.

7. The method according to claim 6, characterized in that, Determining the target threshold of the second image includes: Based on the gray value of each pixel in the second image, determine the gray histogram corresponding to the second image; Based on the grayscale histogram of the second image, a first class of grayscale levels containing at least two grayscale levels is determined; wherein, the grayscale histogram includes: a first class of grayscale levels and a second class of grayscale levels; the frequency corresponding to any grayscale level in the first class of grayscale levels is greater than the frequency corresponding to any grayscale level in the second class of grayscale levels; Based on the gray values ​​corresponding to at least two gray levels within the first type of gray level, determine the target gray level with the largest gray value; The target threshold of the second image is determined based on the difference between the gray value corresponding to the target gray level and the preset threshold.

8. The method according to claim 6, characterized in that, The step of performing contour detection on the binarized image to obtain the target image contour of the object to be tested within the binarized image and the coverage area of ​​the target image contour within the binarized image includes: The binarized image is subjected to morphological operations to obtain a processed image; Contour detection is performed on the processed image to identify multiple contour images within the processed image; Based on the contour area of ​​the multiple contour images, the contour of the target image with the largest contour area is determined. Determine the coverage area of ​​the target image contour within the processed image.

9. The method according to claim 1, characterized in that, The step of determining the target detection parameters of the object to be tested based on the second image and the target application scene includes: If the target application scenario is the third scenario, the center point of the light spot image formed by the object under test in the second image is determined based on the brightness component of the pixels in the second image. Based on the center point of the light spot image, at least two fifth images are obtained from the second image; wherein, any two of the at least two fifth images correspond to different field angles; Based on the luminance and / or chromaticity components of multiple image regions in any of the at least two fifth images, the defect detection parameters of the object under test in any of the fifth images are determined.

10. The method according to claim 9, characterized in that, The defect detection parameters include: uniformity defect parameters; The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes: Divide any one of the at least two fifth images into multiple image regions; wherein the multiple image regions include at least: a central image region and corner image regions; Based on the luminance and chrominance components of the pixels in the central image region and the corner image region of any of the fifth images, the average luminance and average chrominance corresponding to the central image region and the corner image region in any of the fifth images are determined respectively. The brightness uniformity and color uniformity of the corner image region are determined based on the ratio between the average brightness and average chromaticity of the corner image region and the average brightness and average chromaticity of the center image region. Based on the brightness uniformity and chromaticity uniformity of the corner image region, determine the brightness uniformity range and chromaticity uniformity range of the object under test in any of the fifth images; The uniformity defect parameter of the object under test is determined based on the average brightness of the central image region of any one of the at least two fifth images, the brightness uniformity range, and the color uniformity range of the object under test.

11. The method according to claim 9, characterized in that, The defect detection parameters include: black spot defect parameters; The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes: Based on the center point of the light spot, any one of the at least two fifth images is divided into four first image regions of equal area; Divide any one of the four first image regions into multiple non-overlapping sub-image regions; Based on the luminance components of the plurality of sub-image regions, a first luminance difference is determined between a first sub-image region and an adjacent second sub-image region within the plurality of sub-image regions; wherein, the first sub-image region is any sub-image region of the plurality of sub-image regions, and the distance between the second sub-image region and the center point of the light spot is greater than the distance between the adjacent first sub-image region and the center point of the light spot; The black spot defect parameters of the object under test are determined based on multiple first brightness differences within a first image region in any one of the at least two fifth images.

12. The method according to claim 9, characterized in that, The defect detection parameters include: black border defect parameters; The step of determining the defect detection parameters of the object under test within any of the at least two fifth images based on the luminance and / or chrominance components of multiple image regions of any of the at least two fifth images includes: Based on the center point of the light spot, any one of the at least two fifth images is divided into two second image regions of equal area; The two second image regions are evenly divided into multiple sub-image regions along the horizontal or vertical direction; Based on the luminance components of the plurality of sub-image regions, a second luminance difference is determined between the third sub-image region and the fourth sub-image region within the plurality of sub-image regions; the third sub-image region and the fourth sub-image region are two adjacent sub-image regions within the same second image region, and the distance between the fourth sub-image region and the center point of the light spot is greater than the distance between the third sub-image region and the center point of the light spot; Based on the luminance components of the multiple sub-image regions, a third luminance difference is determined between the third sub-image region and the fifth sub-image region; the third sub-image region and the fifth sub-image region are two sub-image regions within different second image regions, and the distance between the third sub-image region and the center point of the light spot is the same as the distance between the fifth sub-image region and the center point of the light spot; The black border defect parameters of the object under test are determined based on multiple second brightness differences and multiple third brightness differences in the second image region within any of the at least two fifth images.

13. The method according to claim 1, characterized in that, The step of obtaining a second image containing the object under test based on the acquired first image includes: Obtain a template image of the object to be tested, and determine the position information of the object to be tested within the first image based on the template image; Obtain the cropping position information of the image cropping window within the first image, and determine the position offset information based on the cropping position information of the image cropping window and the position information of the object to be tested; Based on the position offset information, adjust the position of the image cropping window; Using the adjusted image capture window, the second image containing the object under test is obtained from the first image.

14. A detection device, characterized in that, The device includes: The acquisition module is used to acquire a second image containing the object under test based on the acquired first image; the second image is an image region within the first image that at least contains the object under test. The first determining module is used to determine the target application scenario where the object under test is currently located based on the second image; The second determining module is used to determine the target detection parameters of the object to be tested based on the second image and the target application scenario; wherein the target detection parameters of the object to be tested are different under different target application scenarios; The detection module is used to determine that the object to be tested in the target application scenario is qualified if the target detection parameters meet the preset detection conditions. The first determining module is used to divide the second image into multiple image regions, determine the grayscale range of the second image based on the grayscale mean of the multiple image regions, and determine the target application scenario of the object under test according to the grayscale range to which the grayscale range of the second image belongs; wherein, different grayscale ranges correspond to detection scenarios under different production stages of the terminal equipment production line.

15. A detection device, characterized in that, include: processor; Memory used to store executable instructions; The processor is configured to implement the detection method according to any one of claims 1 to 13 when executing executable instructions stored in the memory.

16. A non-transitory computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of a detection device, the detection device is enabled to perform the detection method of any one of claims 1 to 13.