An image recognition-based portable terminal appearance defect intelligent detection method
By extracting the grayscale and gradient features of portable terminals under different lighting conditions and adjusting the threshold using the Canny algorithm, the problem of detection accuracy caused by ambient light interference is solved, and more efficient defect detection is achieved.
Patent Information
- Application Number
- CN202511134017.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-14
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-08-14
AI Technical Summary
The detection of appearance defects in portable terminals is easily affected by ambient light, which reduces the accuracy of the detection.
By acquiring appearance images under different preset lighting intensities, edge points are extracted using grayscale distribution features and gradient features, pixels are clustered, reference points for defect strength are obtained, the dual thresholds of the Canny algorithm are adjusted, and the defect area is determined by combining the overlapping features under lighting intensity.
It improves the accuracy of detecting appearance defects in portable terminals and reduces false detections and missed detections.
Smart Images

Figure CN120635089B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, and more specifically to an intelligent detection method for appearance defects in portable terminals based on image recognition. Background Technology
[0002] In the manufacturing sectors of consumer electronics and precision machinery, defect detection in product appearance is a core aspect of quality control. Currently, machine vision technology is commonly used for large-scale inspection of appearance defects to improve inspection efficiency. The main algorithm for identifying appearance defects in portable terminals is the Canny edge detection algorithm. This algorithm has low computational complexity and is suitable for real-time detection. However, since the casing of terminals is often made of glossy metal or plastic, there may be reflections or light transmission under illumination. This makes the selection of high and low thresholds in the algorithm susceptible to interference from ambient light, and defect edges are easily misdetected or missed, resulting in reduced accuracy in identifying defects in the terminal's appearance. Summary of the Invention
[0003] To address the technical problem mentioned above where ambient light easily interferes with the accuracy of appearance defect detection during the process, the present invention aims to provide an intelligent method for detecting appearance defects in portable terminals based on image recognition. The specific technical solution adopted is as follows:
[0004] Acquire images of the portable terminal under different preset light intensities;
[0005] Edge points are obtained based on the grayscale distribution characteristics of the appearance image; edge distribution feature values are obtained based on the distribution location and direction characteristics of the edge points; and defect strength reference points are obtained based on the edge distribution feature values.
[0006] Gray-level change similarity is obtained based on the gray-level difference characteristics between pixels under different preset illumination intensities; pixels are clustered based on the gray-level change similarity to obtain different point clusters; abnormal pixels are obtained based on the distribution characteristics of gray-level change similarity between pixels in the point clusters; obvious defect points are obtained based on the strong defect reference points and the abnormal pixels; weak defect reference points are obtained based on the neighborhood gradient difference characteristics of the abnormal pixels and the obvious defect points, and the neighborhood gray-level change characteristics of the abnormal pixels.
[0007] The double threshold in the Canny algorithm is obtained based on the gradient features of the strong and weak reference points of the defect; the suspected defect region in the defect appearance image is obtained based on the Canny algorithm; and the appearance defect region is obtained based on the overlapping features of the suspected defect region under different preset illumination intensities.
[0008] Further, the step of obtaining edge points based on the grayscale distribution features of the appearance image includes:
[0009] The pixels in the appearance image are clustered according to their grayscale values to obtain different pixel clusters; the proportion of pixels in each pixel cluster is calculated to obtain the cluster density value; the pixel cluster corresponding to the maximum value among the cluster density values less than a preset density threshold is taken as the target cluster; the maximum and minimum gradient values of the pixels in the target cluster are used as the initial double thresholds in the Canny algorithm, and the edge points in the appearance image are obtained according to the Canny algorithm.
[0010] Further, the step of obtaining edge distribution feature values based on the distribution location and orientation features of the edge points includes:
[0011] Construct different edge lines based on connected edge points in the appearance image; calculate the average gradient direction of the gradient directions of the edge points in the edge lines to obtain the average gradient direction; take the direction perpendicular to the average gradient direction as the edge direction of the edge line; calculate the average of the reciprocals of the absolute values of the differences between any two edge directions in all edge lines to obtain the direction consistency; calculate the Euclidean distance between any edge line and the nearest other edge line to obtain the nearest distance of the arbitrary edge line; calculate the average of the reciprocals of the absolute values of the differences between the nearest distances of all edge lines and the average nearest distance to obtain the distribution consistency; calculate the product of the direction consistency and the distribution consistency to obtain the edge distribution feature value.
[0012] Further, the step of obtaining the defect strong reference point based on the edge distribution feature value includes:
[0013] When the edge distribution feature value is less than the preset distribution threshold, the edge point is a strong defect reference point.
[0014] Furthermore, the step of obtaining the grayscale change similarity based on the grayscale difference features between pixels under different preset illumination intensities includes:
[0015] A grayscale sequence is constructed based on the grayscale values of the same pixel under all preset illumination intensities; the dynamic time-normalized distance between the grayscale sequences of any two pixels is calculated to obtain the first grayscale similarity of the two pixels; the average of the reciprocals of the absolute values of the grayscale differences of the two pixels under the same preset illumination intensity is calculated to obtain the second grayscale similarity; the product of the first grayscale similarity and the second grayscale similarity is calculated to obtain the grayscale change similarity of the two pixels.
[0016] Further, the step of obtaining abnormal pixels based on the distribution characteristics of the similarity of grayscale changes among pixels in the point cluster includes:
[0017] The number of pixels within a point cluster whose grayscale variation similarity exceeds a preset similarity threshold is calculated to obtain a similarity quantity feature value; pixels in point clusters whose similarity quantity feature value is less than the maximum value are identified as abnormal pixels.
[0018] Further, the step of obtaining obvious defect points based on the strong defect reference point and the abnormal pixel points includes:
[0019] The pixel at the same position as the strong reference point of the defect and the abnormal pixel is regarded as the obvious defect point.
[0020] Further, the step of obtaining the weak reference point of the defect based on the neighborhood gradient difference features of the abnormal pixel and the obvious defect point, and the neighborhood grayscale change features of the abnormal pixel includes:
[0021] The difference between the gradient value of a pixel and the average gradient value of other pixels in its eight-neighborhood is calculated to obtain a first value; the average of the first values of all obvious defective pixels is calculated to obtain a grayscale jump threshold; the reciprocal of the absolute value of the difference between the first value of the abnormal pixel and the grayscale jump threshold is calculated to obtain a grayscale jump proximity; in the direction perpendicular to the gradient direction of the abnormal pixel, the absolute value of the sum of the grayscale differences of a predetermined number of other pixels adjacent to the abnormal pixel is calculated to obtain a grayscale gradient feature value; the product of the grayscale jump proximity and the grayscale gradient feature value is calculated to obtain a defect feature value of the abnormal pixel; abnormal pixels whose defect feature values exceed a predetermined defect threshold are used as weak defect reference points.
[0022] Furthermore, the step of obtaining the dual thresholds in the Canny algorithm based on the gradient features of the strong defect reference point and the weak defect reference point includes:
[0023] The minimum gradient at the strong defect reference point is used as the high threshold in the Canny algorithm, and the minimum gradient at the weak defect reference point is used as the low threshold in the Canny algorithm.
[0024] Furthermore, the step of obtaining the appearance defect region based on the overlapping features of the suspected defect region under different preset light intensities includes:
[0025] The overlap rate is obtained by calculating the percentage of times the pixels in the appearance image are in the suspected defect area under all preset lighting conditions; pixels with an overlap rate exceeding a preset overlap threshold are identified as defective pixels; and the area composed of all defective pixels is identified as the appearance defect area.
[0026] The present invention has the following beneficial effects:
[0027] In this invention, edge points are obtained based on the grayscale distribution characteristics of the appearance image, enabling more comprehensive edge point acquisition. Since the distribution of defect edges on the terminal surface is random and irregular, obtaining edge distribution feature values can characterize the probability that an edge point is a defect edge. Obtaining strong defect reference points can preliminarily determine defective pixels in the appearance image. Because the grayscale change characteristics of normal surface areas and defective areas differ under different preset illumination intensities, obtaining grayscale change similarity can distinguish pixels in different areas. Obtaining point clusters can cluster pixels in different areas based on grayscale change similarity, improving the accuracy of abnormal pixel acquisition. Obtaining abnormal pixels can further limit the screening range of defect edges. Obtaining obvious defect points can be used to determine weak defect reference points, improving the accuracy of selecting weak defect reference points. Obtaining weak defect reference points can further determine defect edges in the appearance image. Obtaining dual thresholds in the Canny algorithm based on the gradient characteristics of strong and weak defect reference points can improve the accuracy of dual threshold selection and increase the accuracy of defect region detection. Since the accuracy of defect detection is low under a single light intensity, the appearance defect area is finally obtained based on the overlapping characteristics of the suspected defect area under different preset light intensities, which improves the accuracy of defect detection of portable terminal appearance. Attached Figure Description
[0028] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart of an intelligent detection method for appearance defects of a portable terminal based on image recognition, provided as an embodiment of the present invention. Detailed Implementation
[0030] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an image recognition-based intelligent detection method for appearance defects in portable terminals proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0032] The following description, in conjunction with the accompanying drawings, details the specific scheme of the intelligent detection method for appearance defects in portable terminals based on image recognition provided by the present invention.
[0033] Please see Figure 1 The diagram illustrates a flowchart of an intelligent detection method for appearance defects in portable terminals based on image recognition, according to an embodiment of the present invention. The method includes the following steps:
[0034] Step S1: Obtain the appearance images of the portable terminal under different preset light intensities.
[0035] In this embodiment of the invention, the implementation scenario is to detect defects in the appearance of a portable terminal, thereby improving the accuracy of defect detection. Since defective areas on the terminal's appearance differ from normal areas, this difference can be amplified under certain light intensities by varying the light intensity, thus determining the surface defects. First, images of the portable terminal's appearance under different preset light intensities are acquired. In this embodiment, the surface of the portable terminal is photographed from the same angle using five different preset light intensities, and the images are then converted to grayscale to obtain images of the portable terminal's appearance under different preset light intensities. The implementer can determine the preset light intensities according to the implementation scenario, with no fewer than five intensity types.
[0036] Step S2: Obtain edge points based on the grayscale distribution characteristics of the appearance image; obtain edge distribution feature values based on the distribution location and direction characteristics of the edge points; obtain strong defect reference points based on the edge distribution feature values.
[0037] Because the terminal itself has some design parts, such as vents and speakers, there will be some regular openings on the terminal's appearance. These openings will also be different from the rest of the shell surface in grayscale images. However, dents caused by scratches, bumps and other factors are random, irregular and have low repeatability. Therefore, this characteristic can be used to find defects in the appearance image. First, edge points are obtained based on the grayscale distribution characteristics of the appearance image. Preferably, in this embodiment of the invention, the step of obtaining edge points includes: clustering pixels according to the grayscale values of pixels in the appearance image to obtain different pixel clusters; calculating the proportion of pixels in each pixel cluster to obtain a cluster density value; since most areas of the terminal appearance have a consistent surface color, the larger the cluster density value, the more likely the pixels in that pixel cluster are pixels from normal areas; while the proportion of defective areas on the surface is small, the pixels in pixel clusters with smaller cluster density values are more likely to be suspected defective pixels; since suspected defective pixels have obvious characteristics, they are more likely to exist in a cluster, and the pixel cluster corresponding to the maximum value among the cluster density values less than a preset density threshold is taken as the target cluster; in this embodiment of the invention, the preset density threshold obtained statistically in the experimental scenario is 0.3, which can be determined by the implementer according to the implementation scenario; the pixel cluster corresponding to the maximum value among the cluster density values less than 0.3 is taken as the target cluster. The maximum and minimum gradient values of pixels in the target cluster are used as the initial double thresholds in the Canny algorithm to obtain edge points in the appearance image. Due to different formation conditions, pixels in defective areas may not be recognized as edge points during the identification process due to some design flaws in the terminal itself. Identification is performed using pixel clustering results. While this may identify some edge points in normal designs, it ensures that edge points in defective areas also exist. It should be noted that edge point identification using the Canny edge detection algorithm is existing technology; the specific steps will not be elaborated further.
[0038] Furthermore, since defects are characterized by uneven distribution and random orientation, the more random the edge distribution and orientation, the more likely it is to be a strong reference point for the defect. Therefore, edge distribution feature values are obtained based on the distribution location and orientation characteristics of edge points. Preferably, in this embodiment of the invention, the step of obtaining edge distribution feature values includes: constructing different edge lines based on connected edge points in the appearance image; calculating the average gradient direction of the edge points in the edge line to obtain the average gradient direction; and taking the direction perpendicular to the average gradient direction as the edge direction of the edge line. The average of the reciprocals of the absolute values of the differences between any two edge directions in all edge lines is calculated to obtain the direction consistency. The greater the difference in the edge directions of the edge lines, the smaller the direction consistency, and the more likely the edge points on the edge lines are to be strong reference points for the defect. It should be noted that in this embodiment of the invention, if the denominator is 0 in the calculation process, a preset minimum positive number is introduced into the calculation, which is 0.01. The Euclidean distance between any edge line and the nearest other edge line is calculated to obtain the nearest distance of the arbitrary edge line; the Euclidean distance is the distance between the nearest pixels of two edge lines. The distribution consistency is obtained by averaging the reciprocals of the absolute values of the differences between the nearest distances of all edge lines and the average nearest distance. A larger difference between the nearest distances of all edge lines and the average nearest distance indicates a smaller distribution consistency, meaning the edge line distribution intervals are more discrete and irregular, and the edge points on the edge lines are more likely to be strong defect reference points. The edge distribution characteristic value is obtained by multiplying the directional consistency and distribution consistency. A smaller edge distribution characteristic value indicates that the edge lines are more likely to be caused by defect areas, and the edge points on the edge lines are more likely to be strong defect reference points. The formulas for obtaining the edge distribution characteristic value include:
[0039]
[0040] In the formula, W represents the edge distribution characteristic value, and N represents the number of combinations of any two edge lines. This represents the absolute value of the difference in edge directions between the nth group of edge lines. Indicates directional consistency; M represents the number of edge lines. Let K represent the nearest distance to the m-th edge line, and let K represent the average nearest distance. Indicates the degree of uniformity of distribution.
[0041] After obtaining the edge distribution feature value, the smaller the edge distribution feature value, the more likely the edge point is to be a strong edge point representing a defect. Therefore, a strong reference point for the defect can be obtained based on the edge distribution feature value. Specifically, when the edge distribution feature value is less than a preset distribution threshold, the edge point is a strong reference point for the defect. In this embodiment of the invention, the preset distribution threshold obtained statistically from the experimental scenario is 0.2, which can be determined by the implementer according to the implementation scenario. A strong reference point for the defect is a strong edge point representing a defect. When the edge distribution feature value is not less than the preset distribution threshold, it means that the distribution of the edge lines is relatively regular. Such edge lines are formed by the design of the terminal itself and there is no defect area, so no further defect detection steps are performed.
[0042] Step S3: Obtain grayscale change similarity based on the grayscale difference features between pixels under different preset illumination intensities; cluster pixels based on grayscale change similarity to obtain different point clusters; obtain abnormal pixels based on the distribution features of grayscale change similarity between pixels in the point clusters; obtain obvious defect points based on strong defect reference points and abnormal pixels; obtain weak defect reference points based on the neighborhood gradient difference features of abnormal pixels and obvious defect points, and the neighborhood grayscale change features of abnormal pixels.
[0043] Since the terminal's exterior is generally made of metal or plastic, due to the special properties of the material surface, it exhibits reflective or translucent phenomena under illumination, and this phenomenon varies with different lighting conditions. The grayscale changes in defective areas will differ from those in normal areas when lighting conditions change, and the degree of change may vary depending on the formation of the defect; while the changes in normal surface areas are relatively regular. Therefore, pixel change characteristics of pixels can be obtained through different lighting intensities. Thus, grayscale change similarity is obtained based on the grayscale difference characteristics between pixels under different preset lighting intensities. Preferably, in this embodiment of the invention, the step of obtaining grayscale change similarity includes: constructing a grayscale sequence based on the grayscale values of the same pixel under all preset lighting intensities; this grayscale sequence represents the grayscale values of the same pixel under different lighting conditions. Calculate the dynamic temporal warping distance between the grayscale sequences of any two pixels to obtain the first grayscale similarity between them. It should be noted that dynamic temporal warping distance is existing technology, and the specific steps are not detailed here. The more similar the changes in the two sequences, the larger the dynamic temporal warping distance. A larger first grayscale similarity means that the grayscale sequences of the two pixels have more similar change patterns, and they are more likely to be pixels in two normal regions. Calculate the average of the reciprocals of the absolute values of the grayscale differences between any two pixels under the same preset illumination intensity to obtain the second grayscale similarity. The more similar the grayscale values of the two pixels under the same illumination, the larger the second grayscale similarity, and the more likely the two pixels are to be pixels in two normal regions. Calculate the product of the first grayscale similarity and the second grayscale similarity to obtain the grayscale change similarity between the two pixels. A larger grayscale change similarity means that the grayscale features of the two pixels under different illuminations are more similar, and they are more likely to belong to pixels in normal surface regions.
[0044] Furthermore, pixels can be clustered based on grayscale change similarity to obtain different pixel clusters, with pixels within each cluster exhibiting similar characteristics. If all pixels within a pixel cluster belong to normal surface regions, since the terminal has a flat surface, the grayscale values of pixels in its normal surface regions are relatively close, resulting in a high degree of similarity in grayscale changes among pixels within the pixel cluster. Abnormal pixels can then be identified based on the distribution characteristics of the grayscale change similarity among pixels in the pixel cluster. Preferably, in this embodiment, the step of identifying abnormal pixels includes: calculating the number of pixels within a pixel cluster whose grayscale change similarity exceeds a preset similarity threshold, and obtaining a similarity quantity feature value. In this embodiment, the preset similarity threshold obtained statistically from the experimental scenario is 0.85. The more pixel pairs that exceed this preset similarity threshold, the larger the similarity quantity feature value, meaning that a larger number of pixels in the pixel cluster have a higher degree of similarity in grayscale changes. Therefore, the pixel within the pixel cluster corresponding to the maximum value of the similarity quantity feature value is most likely a pixel on the normal surface of the terminal, while pixels in other pixel clusters are less likely to be pixels on the normal surface of the terminal. Furthermore, pixels in clusters with similar number feature values less than the maximum value are identified as anomalous pixels; anomalous pixels represent pixels in abnormally flat areas on the terminal surface.
[0045] Since anomalous pixels include those that differ from normal flat areas due to design flaws, as well as pixels from defective areas, further analysis of anomalous pixels is necessary. First, obvious defect points are identified based on strong defect reference points and anomalous pixels. Specifically, pixels where the strong defect reference point and the anomalous pixel are in the same location are considered obvious defect points. When a pixel simultaneously satisfies both the strong defect reference point and the anomalous pixel condition, that location is a significant defect area. Because defect edges exhibit similar characteristics, the gradient features at obvious defect points can be compared with the gradient features at other anomalous pixels to determine if they belong to a defective region. Therefore, weak defect reference points are obtained based on the neighborhood gradient difference features of anomalous pixels and obvious defect points, as well as the neighborhood grayscale change features of anomalous pixels.
[0046] Preferably, in this embodiment of the invention, the step of obtaining a weak reference point for a defect includes: calculating the difference between the gradient value of a pixel and the average gradient value of other pixels in its eight neighborhoods to obtain a first value; since the defect edge has the characteristic of a step-like gray-level jump, the larger the first value, the more obvious the gray-level jump feature at that pixel; calculating the average of the first values of all obvious defect points to obtain a gray-level jump threshold; this gray-level jump threshold characterizes the degree of gray-level jump at the defect edge in the appearance image. The reciprocal of the absolute value of the difference between the first value of an abnormal pixel and the gray-level jump threshold is calculated to obtain the gray-level jump proximity; the closer the first value of an abnormal pixel is to the gray-level jump threshold, the greater the gray-level jump proximity, meaning that the abnormal pixel is more likely to be a defect edge point and has gray-level jump characteristics. In the direction perpendicular to the gradient direction of the abnormal pixel, the absolute value of the sum of the gray-level differences of a predetermined number of adjacent pixels is calculated to obtain the gray-level gradient feature value. The direction perpendicular to the gradient direction is taken as the edge direction. If the abnormal pixel is at a defect edge, a gray-level gradient feature exists along the edge direction. In this embodiment, the predetermined number is 5. The larger the absolute value of the sum of the gray-level differences, the more obvious the gray-level gradient feature; the larger the gray-level gradient feature value, the more likely the abnormal pixel is a defect edge point. The product of the gray-level jump proximity and the gray-level gradient feature value is calculated to obtain the defect feature value of the abnormal pixel. The larger the defect feature value, the more likely the abnormal pixel is on a defect edge. It should be noted that the abnormal pixels used to calculate the defect feature value do not include pixels that are also obvious defect points. Abnormal pixels with defect feature values exceeding a predetermined defect threshold are taken as weak defect reference points, which are weak edge points on the defect edge.
[0047] Step S4: Obtain the dual thresholds in the Canny algorithm based on the gradient features of the strong and weak reference points of the defect; obtain the suspected defect region in the defect appearance image based on the Canny algorithm; obtain the appearance defect region based on the overlapping features of the suspected defect region under different preset illumination intensities.
[0048] After obtaining strong and weak defect reference points from the appearance image under any preset illumination intensity, since some pixels in defect areas may not be identified and marked, to further improve the accuracy of defect detection, dual thresholds in the Canny algorithm can be obtained based on the gradient features of the strong and weak defect reference points. Specifically, the minimum gradient value of the strong defect reference points is used as the high threshold in the Canny algorithm, and the minimum gradient value of the weak defect reference points is used as the low threshold. These high and low thresholds enable more accurate identification of defect edges under the corresponding preset illumination intensity, thereby improving the accuracy of defect detection. Furthermore, suspected defect areas in the defect appearance image can be obtained using the Canny algorithm. Defect detection using the Canny algorithm is existing technology, and the specific steps will not be elaborated further.
[0049] Furthermore, since the location of defects in the terminal's appearance does not change, when identifying defects under different light intensities, if the same area is identified as a suspected defect area multiple times, it is highly likely that the area is a real defect area. Therefore, the appearance defect area is obtained based on the overlapping characteristics of suspected defect areas under different preset light intensities. Preferably, in this embodiment of the invention, the step of obtaining the appearance defect area includes: calculating the percentage of times a pixel in the appearance image is in a suspected defect area under all preset light intensities to obtain the overlap rate; the larger the overlap rate, the more times the pixel is detected as a defect, and the more likely it is to be in a defect area, further improving the accuracy of defect detection. Pixels with an overlap rate exceeding a preset overlap threshold are considered defective pixels; in this embodiment of the invention, the preset overlap threshold obtained statistically from the experimental scenario is 0.8, which can be determined by the implementer according to the implementation scenario. The area composed of all defective pixels is considered the appearance defect area; at the appearance defect area, the terminal surface is considered to have a defect.
[0050] In summary, this invention provides an intelligent method for detecting appearance defects in portable terminals based on image recognition. It obtains edge points based on the grayscale distribution characteristics of the appearance image; obtains strong defect reference points based on the distribution location and direction characteristics of the edge points; obtains grayscale change similarity between pixels under different preset illumination intensities and clusters the pixels, then obtains abnormal pixels based on the distribution characteristics of grayscale change similarity within the pixel clusters; obtains weak defect reference points based on the neighborhood gradient difference characteristics between abnormal pixels and obvious defect points, and the neighborhood grayscale change characteristics of abnormal pixels; and obtains the dual thresholds in the Canny algorithm based on the gradient characteristics of the strong and weak defect reference points for detection. This invention obtains appearance defect regions based on the overlapping characteristics of suspected defect regions under different preset illumination intensities, improving the accuracy of defect detection.
[0051] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0052] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
Claims
1. A method for intelligent detection of appearance defects in portable terminals based on image recognition, characterized in that, The method includes the following steps: Acquire images of the portable terminal under different preset light intensities; Edge points are obtained based on the grayscale distribution characteristics of the appearance image; edge distribution feature values are obtained based on the distribution location and direction characteristics of the edge points; and defect strength reference points are obtained based on the edge distribution feature values. Gray-level change similarity is obtained based on the gray-level difference characteristics between pixels under different preset illumination intensities; pixels are clustered based on the gray-level change similarity to obtain different point clusters; abnormal pixels are obtained based on the distribution characteristics of gray-level change similarity between pixels in the point clusters; obvious defect points are obtained based on the strong defect reference points and the abnormal pixels; weak defect reference points are obtained based on the neighborhood gradient difference characteristics of the abnormal pixels and the obvious defect points, and the neighborhood gray-level change characteristics of the abnormal pixels. The double threshold in the Canny algorithm is obtained based on the gradient features of the strong and weak reference points of the defect; the suspected defect region in the defect appearance image is obtained based on the Canny algorithm; and the appearance defect region is obtained based on the overlapping features of the suspected defect region under different preset illumination intensities. The step of obtaining edge points based on the grayscale distribution features of the appearance image includes: The pixels in the appearance image are clustered according to their grayscale values to obtain different pixel clusters. The proportion of pixels in each pixel cluster is calculated to obtain the cluster density value. The pixel cluster corresponding to the maximum value among the cluster density values that are less than a preset density threshold is taken as the target cluster. The maximum and minimum gradient values of the pixels in the target cluster are used as the initial double thresholds in the Canny algorithm, and the edge points in the appearance image are obtained according to the Canny algorithm. The step of obtaining grayscale change similarity based on the grayscale difference features between pixels under different preset illumination intensities includes: A grayscale sequence is constructed based on the grayscale values of the same pixel under all preset illumination intensities; the dynamic time-normalized distance between the grayscale sequences of any two pixels is calculated to obtain the first grayscale similarity of the two pixels; the average of the reciprocals of the absolute values of the grayscale differences of the two pixels under the same preset illumination intensity is calculated to obtain the second grayscale similarity; the product of the first grayscale similarity and the second grayscale similarity is calculated to obtain the grayscale change similarity of the two pixels.
2. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining edge distribution feature values based on the distribution location and orientation features of the edge points includes: Construct different edge lines based on connected edge points in the appearance image; calculate the average gradient direction of the gradient directions of the edge points in the edge lines to obtain the average gradient direction; take the direction perpendicular to the average gradient direction as the edge direction of the edge line; calculate the average of the reciprocals of the absolute values of the differences between any two edge directions in all edge lines to obtain the direction consistency; calculate the Euclidean distance between any edge line and the nearest other edge line to obtain the nearest distance of the arbitrary edge line; calculate the average of the reciprocals of the absolute values of the differences between the nearest distances of all edge lines and the average nearest distance to obtain the distribution consistency; calculate the product of the direction consistency and the distribution consistency to obtain the edge distribution feature value.
3. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining the defect strong reference point based on the edge distribution feature value includes: When the edge distribution feature value is less than the preset distribution threshold, the edge point is a strong defect reference point.
4. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining abnormal pixels based on the distribution characteristics of the similarity of grayscale changes between pixels in the pixel cluster includes: The number of pixels within a point cluster whose grayscale variation similarity exceeds a preset similarity threshold is calculated to obtain a similarity quantity feature value; pixels in point clusters whose similarity quantity feature value is less than the maximum value are identified as abnormal pixels.
5. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining obvious defect points based on the strong defect reference point and the abnormal pixel points includes: The pixel at the same position as the strong reference point of the defect and the abnormal pixel is regarded as the obvious defect point.
6. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining the weak reference point of the defect based on the neighborhood gradient difference features of the abnormal pixel and the obvious defect point, and the neighborhood grayscale change features of the abnormal pixel includes: The difference between the gradient value of a pixel and the average gradient value of other pixels in its eight-neighborhood is calculated to obtain a first value; the average of the first values of all obvious defective pixels is calculated to obtain a grayscale jump threshold; the reciprocal of the absolute value of the difference between the first value of the abnormal pixel and the grayscale jump threshold is calculated to obtain a grayscale jump proximity; in the direction perpendicular to the gradient direction of the abnormal pixel, the absolute value of the sum of the grayscale differences of a predetermined number of other pixels adjacent to the abnormal pixel is calculated to obtain a grayscale gradient feature value; the product of the grayscale jump proximity and the grayscale gradient feature value is calculated to obtain a defect feature value of the abnormal pixel; abnormal pixels whose defect feature values exceed a predetermined defect threshold are used as weak defect reference points.
7. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining the dual threshold in the Canny algorithm based on the gradient features of the strong defect reference point and the weak defect reference point includes: The minimum gradient at the strong defect reference point is used as the high threshold in the Canny algorithm, and the minimum gradient at the weak defect reference point is used as the low threshold in the Canny algorithm.
8. The intelligent detection method for appearance defects of portable terminals based on image recognition according to claim 1, characterized in that, The step of obtaining the appearance defect region based on the overlapping features of the suspected defect region under different preset light intensities includes: The overlap rate is obtained by calculating the percentage of times the pixels in the appearance image are in the suspected defect area under all preset lighting conditions; pixels with an overlap rate exceeding a preset overlap threshold are identified as defective pixels; and the area composed of all defective pixels is identified as the appearance defect area.
Citation Information
Patent Citations
Defect detection method, system and device and computer-readable storage medium
CN110687119A
Sheet metal part quality detection method
CN116777907A