Disclosure of Invention
In order to solve the technical problems, the invention provides an intelligent detection method for defects of a watch dial based on artificial intelligence, so as to solve the existing problems.
The intelligent detection method of the watch dial defect based on artificial intelligence adopts the following technical scheme:
the embodiment of the invention provides an intelligent watch dial defect detection method based on artificial intelligence, which comprises the following steps:
Collecting a gray watch dial image;
acquiring an edge line in the grayscale watch dial image by using a canny edge detection operator, acquiring a suspected dial area according to a closed edge in the grayscale watch dial image, and further acquiring a dial area of the grayscale watch dial image; obtaining texture row-change vectors and texture column-change vectors of all pixel points according to LBP values of all pixel points, and obtaining neighborhood texture consistency of all pixel points according to LBP feature descriptors of all pixel points; obtaining texture extension disorder entropy of each pixel point according to the texture row change vector, the texture column change vector and the texture consistency; calculating the relative gray scale of each pixel point in the dial area, and acquiring the defect body self-deviation index of each pixel point in the dial area according to the texture extension disorder entropy and the relative gray scale of the pixel point; obtaining dial defect images according to the defect body self-deviation indexes of the pixel points, obtaining crack lines and crack pixel points in the dial defect images by using a canny edge detection operator, obtaining neighborhood defect characteristic indexes of each crack pixel point according to the defect body self-deviation indexes, further obtaining crack source points on each crack line, obtaining crack expansion end points on each crack line by using a harris corner detection algorithm, and obtaining expansion influence coefficients of each crack line according to the neighborhood defect characteristic indexes, the crack source points and the crack expansion end points; acquiring potential multilateral expansion coefficients of each crack line according to the expansion influence coefficient and the neighborhood defect characteristic index; obtaining dial defect evaluation indexes according to potential multilateral expansion coefficients;
and detecting the defects of the watch dial according to the dial defect evaluation index.
Further, the obtaining the suspected dial area according to the closed edge in the grayscale watch dial image, and then obtaining the dial area of the grayscale watch dial image includes:
The areas in all the closed edge lines in the grayscale wristwatch dial image are designated as suspected dial areas, and the suspected dial area with the largest area in the grayscale wristwatch dial image is designated as the dial area.
Further, the obtaining the texture row-variable vector and the texture column-variable vector of each pixel according to the LBP value of each pixel includes:
the gray scale watch dial image is taken as the center, and the construction side length is taken as the centerIn the neighborhood window of,/>, whereThe window length is preset;
calculating LBP values of all pixel points in a neighborhood window of each pixel point, and arranging the LBP values of all pixel points in the neighborhood window according to the sequence of the pixel points in the neighborhood window from left to right and from top to bottom in rows to obtain texture row variable vectors;
And (3) for LBP values of all pixel points in a neighborhood window of each pixel point, obtaining the texture column change quantity by arranging the LBP values in columns by adopting the same method as the texture column change quantity.
Further, the obtaining the neighborhood texture consistency of each pixel according to the LBP feature descriptor of each pixel includes:
Calculating all pixel points in a neighborhood window of each pixel point, calculating LBP feature descriptors of the pixel points, calculating the Hamming distance of the LBP feature descriptors between two pixel points, calculating the average value of all Hamming distances in the neighborhood window of each pixel point, and taking the calculation result of an exponential function taking a natural constant as a bottom and taking the negative value of the average value as an index as the neighborhood texture consistency of each pixel point.
Further, the obtaining the texture extension disorder entropy of each pixel point according to the texture row-varying vector, the texture column-varying vector and the texture consistency comprises:
and calculating the Euclidean distance between the texture line direction changing quantity and the texture column direction changing quantity of each pixel point, calculating the ratio of the Euclidean distance to the neighborhood texture consistency degree of each pixel point, and taking the normalized value of the ratio as the texture extension disorder entropy of each pixel point.
Further, the calculating the relative gray scale of each pixel point in the dial area, and obtaining the defect body self-deviation index of each pixel point in the dial area according to the texture extension disorder entropy and the relative gray scale of the pixel point, includes:
Dividing a dial area into two types of areas by using an OTSU Ojin threshold segmentation method, marking one type of area with a large number of pixel points as a background area, marking an average value of gray values of all the pixel points in the background area as dial background gray, and marking an absolute value of a difference value between the gray value of each pixel point in the dial area and the dial background gray as the relative gray of each pixel point;
For each pixel point, calculating the sum value of the relative gray scale of the pixel point and a preset adjustment parameter, calculating the negative value of the ratio of the texture extension disorder entropy of the pixel point to the sum value, calculating the calculation result of an exponential function taking the natural constant as the bottom and the negative value as the exponent, calculating the difference value between the number 2 and the calculation result, and taking the product of the difference value and the relative gray scale of the pixel point as the defect body self-deviation exponent of each pixel point.
Further, the obtaining a dial defect image according to the defect body self-deviation index of the pixel points, obtaining crack lines and crack pixel points in the dial defect image by using a canny edge detection operator, obtaining a neighborhood defect characteristic index of each crack pixel point according to the defect body self-deviation index, further obtaining a crack source point on each crack line, obtaining a crack expansion endpoint on each crack line by using a harris corner detection algorithm, and obtaining expansion influence coefficients of each crack line according to the neighborhood defect characteristic index, the crack source point and the crack expansion endpoint, including:
Calculating the self-deviation index of the defect body of all the pixel points in the dial area, replacing the pixel values of the pixel points in the dial area in the watch dial image with the self-deviation index of the defect body of the pixel points, and setting the pixel values of the pixel points in other areas except the dial area in the watch dial image to be 0 to obtain a dial defect image;
Performing edge detection on the dial defect image by using a canny edge detection operator to obtain edge lines in the dial defect image, marking each edge in the dial defect image as crack lines, taking pixel points on all the crack lines as crack pixel points, taking the average value of self-deviation indexes of defect bodies of all the pixel points in a neighborhood window of the crack pixel points as neighborhood defect characteristic indexes of all the crack pixel points, and taking the crack pixel point with the largest neighborhood defect characteristic index on each crack line as a crack source point;
acquiring all corner points on each crack line by using a harris corner point detection algorithm as crack extension end points;
For each crack grain, calculating the absolute value of the difference value of the neighborhood defect characteristic indexes of the crack source point and each crack expansion endpoint, calculating the Euclidean distance between the crack source point and each crack expansion endpoint, calculating the product of the absolute value of the difference value and the Euclidean distance, and calculating the sum of all products on the crack grain as the expansion influence coefficient of the crack grain.
Further, the obtaining the potential multilateral expansion coefficient of each crack line according to the expansion influence coefficient and the neighborhood defect characteristic index comprises:
And for each crack grain, calculating the sum value of neighborhood defect characteristic indexes of all crack expansion endpoints, and calculating the product of the sum value and the expansion influence coefficient of the crack grain as the potential multilateral expansion coefficient of each crack grain.
Further, the obtaining the dial defect evaluation index according to the latent multilateral expansion coefficient includes:
Calculating the sum of potential multilateral expansion coefficients of all crack lines, calculating the calculation result of an exponential function taking a natural constant as a bottom and taking the negative value of the sum as an index, and taking the difference between the number 1 and the calculation result as a dial defect evaluation index.
Further, the detecting the defect of the watch dial according to the dial defect evaluation index includes:
when the dial defect evaluation index is smaller than a preset defect threshold value, judging the defect degree of the watch dial as defect-free; when the dial defect evaluation index is larger than or equal to a preset defect threshold value and smaller than a preset mild threshold value, judging the defect degree of the watch dial as mild; when the dial defect evaluation index is larger than or equal to a preset slight threshold value and smaller than a preset moderate threshold value, judging the defect degree of the watch dial as moderate; and when the dial defect evaluation index is greater than or equal to a preset middle threshold value, judging the defect degree of the watch dial as severe.
The invention has at least the following beneficial effects:
According to the watch dial image, a graying watch dial image is obtained, dial areas are divided, in order to avoid the problem that the defect detection effect of various complex designs and patterns on the watch dial is poor, the defect characteristics on the watch dial are analyzed, the defects on the watch dial are distinguished from the original designs and patterns, the texture extension disorder entropy and the relative gray level are calculated, the defect body self-deviation index is constructed, the dial defect image is obtained, the crack lines are determined, the accuracy of crack extraction on the watch dial is improved, and the problem that the defects on the watch dial are difficult to extract due to various complex designs and patterns on the watch dial is solved; the method comprises the steps of obtaining a crack source point and a crack expansion end point, calculating an expansion influence coefficient of crack lines by analyzing characteristics between the crack source point and the crack expansion end point, comprehensively considering influence caused by the crack lines and influence possibly caused in the future, evaluating potential risks possibly caused by crack defects on a watch dial, obtaining potential multilateral expansion coefficients of the crack lines, further determining a dial defect evaluation index according to the potential multilateral expansion coefficients of all the crack lines, and improving accuracy of defect degree evaluation on the watch dial.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following detailed description is given below of the watch dial defect intelligent detection method based on artificial intelligence according to the invention, which is provided by combining the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, 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 belongs.
The following specifically describes a specific scheme of the watch dial defect intelligent detection method based on artificial intelligence provided by the invention with reference to the accompanying drawings.
The invention provides an artificial intelligence based intelligent detection method for defects of a watch dial, and particularly provides an artificial intelligence based intelligent detection method for defects of a watch dial, referring to fig. 1, comprising the following steps:
and S001, acquiring an image of the dial of the watch, and preprocessing.
The method comprises the steps of placing the watch on the detection platform with the front side facing upwards, capturing detailed information on the watch dial by an industrial camera, shooting the watch on the detection platform by the industrial camera to obtain watch dial images, denoising and enhancing the acquired watch dial images by using an NLM non-local mean value filtering algorithm, eliminating influence caused by partial noise and external interference, enhancing accuracy of subsequent analysis, and carrying out graying treatment on the watch dial images to obtain graying watch dial images.
Step S002, dividing the dial area, calculating the texture extension disorder entropy and the relative gray scale, constructing a self-deviation index of the defect body, obtaining a dial defect image, determining crack lines, obtaining crack source points and crack extension end points, calculating the extension influence coefficient and the potential polygonal extension coefficient of the crack lines, and obtaining a dial defect evaluation index.
The crack is the most common defect of the watch dial, and the crack defect on the watch dial is mainly detected in the embodiment.
Before analyzing defects on the dial of a watch, the dial area is divided to reduce the influence of other factors. And performing edge detection on the grayscale watch dial image by using a canny edge detection operator to obtain an edge line of the grayscale watch dial image. The canny edge detection operator is a known technology and will not be described herein.
Since the dial interior design is complicated, there may be a plurality of closed edges in the grayscale wristwatch dial image, but the dial area is the largest, the area within all the closed edges in the grayscale wristwatch dial image is designated as the suspected dial area, and the suspected dial area with the largest area in the grayscale wristwatch dial image is determined as the dial area.
In order to avoid the influence of various complicated designs and patterns on the watch dial on the defect detection of the watch dial, the characteristics of defects on the watch dial are analyzed, and the defects on the watch dial are distinguished from the original designs and patterns.
The defect that produces on the wrist-watch dial plate is on the basis of original dial plate, often is comparatively close with the whole colour of dial plate, and on the contrary, in order to be convenient for clear reading, scale, the pointer on the wrist-watch often is higher with the different degree of other regional colours on the dial plate, if directly carry out edge detection to wrist-watch dial plate image according to colour characteristic, can divide out scale, the pointer on the wrist-watch, and be difficult to accurately divide out the defect region. Therefore, analysis is performed based on the characteristics of the watch dial at the time of occurrence of the defect, and the grayscale watch dial image is processed.
The defect area on the watch dial can be outwards diffused due to the action of stress to generate certain textures, so that the textures of the defect area are complex.
Taking each pixel point in the gray scale watch dial image as the center, and constructing the side length asNeighborhood window of/>The empirical value is 13, LBP characteristic descriptors of each pixel point in a neighborhood window of each pixel point are calculated, LBP values of all the pixel points in the neighborhood window are arranged in rows according to the sequence of the pixel points from left to right and from top to bottom in the neighborhood window, the LBP characteristic descriptors are a sequence, the LBP values are decimal representations of the LBP characteristic descriptors, the LBP values of the first pixel point are arranged at the first position according to the sequence, the LBP values of the second pixel point are arranged at the second position, and the like, so that texture line change quantity/>. The LBP feature descriptors are well known to those skilled in the art, and are not described herein.
Similarly, LBP values of all pixel points in the neighborhood window are arranged in columns to obtain the direction changing quantity of the texture columnsThe LBP feature descriptor is an 8-bit binary number, the LBP value is a decimal representation of the LBP feature descriptor, and the LBP feature descriptor and the LBP value are both known techniques, which are not described herein. According to texture characteristics in the neighborhood window of the pixel point, texture extension disorder entropy of the pixel point is constructed:
Wherein,Is pixel/>Texture extended unordered entropy,/>Is pixel/>Is used for the neighborhood texture consistency of (1),Representing taking the Euclidean distance between two vectors,/>Is pixel/>Texture row-wise vectors within the neighborhood window,Is pixel/>Texture column change vector within neighborhood window,/>The representation takes the hamming distance between the two vectors,Representing pixel points/>Within neighborhood window/>LBP characteristic descriptor of each pixel point,/>Representing pixel points/>Within neighborhood window/>LBP characteristic descriptor of each pixel point,/>For neighborhood intra window/>The number of the combination of every two pixel points; /(I)As a normalization function,/>Is an exponential function with a base of natural constant.
When the hamming distance between texture feature descriptors of all pixel points in a neighborhood window of the pixel points is larger, the larger the texture feature phase difference in the neighborhood window of the pixel points is, the lower the consistency degree is, and the smaller the neighborhood texture consistency degree value is; when the Euclidean distance between the texture row change vector and the texture column change vector of the pixel point is larger and the neighborhood texture consistency value of the pixel point is smaller, the texture distribution of the surrounding area of the pixel point is not regular, and the texture extension disorder entropy value of the pixel point is larger.
According to the characteristic that the defects on the watch dial are similar to the overall color of the dial, an OTSU Ojin threshold segmentation method is used for segmenting the dial area into two types of areas, and the area with more pixels is marked as a background area. The average value of the gray values of all the pixels in the background area is recorded as the background gray of the dial, and the absolute value of the difference between each pixel in the dial area and the background gray of the dial is recorded as the relative gray of each pixel, wherein the OTSU dyadic threshold segmentation method is a known technology, and the embodiment is not described herein.
The texture extension disorder entropy of the pixel points reflects the disorder degree of the surrounding texture of the pixel points, the relative gray scale of the pixel points reflects the similarity degree of the pixel points and the whole color of the dial, when the watch dial is comprehensively considered to be defective, the gray scale value of a defective area is relatively similar to the gray scale value of the whole watch dial, and the surrounding texture disorder characteristic is considered, and according to the texture extension disorder entropy and the relative gray scale of the pixel points, the self-deviation index of the defective body of the pixel points is represented as follows:
Wherein,Is pixel/>Defect bulk self-bias index,/>As an exponential function based on natural constants,/>To adjust the parameters, prevent the denominator from being zero, the empirical value is 1,/>Is pixel/>Texture extended unordered entropy,/>Is pixel/>Is a relative gray scale of (c).
When the similarity of the pixel points and the whole color of the dial is higher, but the texture of the surrounding area is more chaotic, the pixel points are more likely to be positioned in crack areas on the dial, and a larger amplification factor is set for the relative gray scale of the pixel points, so that the pixel points of the defect area can be segmented even if the gray scale value difference between the pixel points of the defect area and the gray scale value of the surrounding area is smaller; when the similarity of the pixel points and the whole color of the dial is low, but the texture of the surrounding area is simpler, the pixel points are more likely to be the original scales, pointers and the like on the dial, and the relative gray scale of the pixel points is set with smaller magnification factors, so that the influence of the original scales, pointers and the like on the dial on the segmentation of the defect area is prevented.
According to the method, the self-deviation index of the defect body of all the pixel points in the dial area is calculated, the pixel values of the pixel points in the dial area in the watch dial image are replaced by the self-deviation index of the defect body of the pixel points, and the pixel values of the pixel points in the rest areas except the dial area in the watch dial image are set to be 0, so that the dial defect image is obtained.
And carrying out edge detection on the dial defect image by using a canny edge detection operator to obtain edge lines in the dial defect image, and marking each edge in the dial defect image as crack lines.
When the crack on the watch dial plate forms, stress concentration can be generated in the dial plate material, and the stress can enable two sides of the crack to generate tiny cracks, once the watch dial plate is cracked, the cracks are likely to gradually expand due to factors such as weight of the dial plate, movement vibration and the like in the using process of the watch, so that defects of the watch dial plate are aggravated, and even important performances such as water tightness of the watch are affected.
And taking the pixel points on all the crack lines as crack pixel points, and recording the average value of the self-deviation indexes of the defect bodies of all the pixel points in the neighborhood window of the crack pixel points as the neighborhood defect characteristic index of each crack pixel point. And marking the crack pixel point with the largest neighborhood defect characteristic index on each crack grain as a crack source point, and acquiring all corner points on each crack grain as crack extension end points by using a harris corner detection algorithm, wherein the schematic diagrams of the crack source point and the crack extension end points are shown in figure 2.
Analyzing the change of the defect degree from a crack source point to a crack expansion end point, and constructing an expansion influence coefficient of crack lines according to the difference of the self-deviation indexes of the defect bodies between the crack source point and the crack expansion end point:
Wherein,For/>Expansion influence coefficient of crack lines,/>Represents the/>The crack source points of the crack lines,Represents the/>First/>, crack linesEnd points of crack propagation,/>For/>Neighborhood defect characteristic index of crack source points of crack lines,/>For/>First/>, crack linesNeighborhood defect characterization index of individual crack growth endpoints,/>Representing the Euclidean distance between two pixel points,/>For/>The number of crack propagation endpoints of each crack grain.
When the distance between the crack extension end point and the crack source point is shorter and the neighborhood defect characteristic index phase difference is smaller, the influence degree on the surrounding area is lower when the crack source point extends to the periphery, and the extension influence coefficient value of the crack lines is smaller.
Obtaining a dial defect evaluation index according to the expansion influence coefficients of the crack lines and the neighborhood defect characteristic indexes of crack expansion endpoints of all the crack lines:
Wherein,Index for evaluating dial defect,/>As an exponential function based on natural constants,/>Is the number of crack lines on the watch dial/>For/>Potential multilateral expansion coefficient of crack lines,/>For/>Expansion influence coefficient of crack lines,/>For/>First/>, crack linesNeighborhood defect characterization index of individual crack growth endpoints,/>For/>The number of crack propagation endpoints of each crack grain.
When the expansion influence coefficient of the crack lines and the neighborhood defect characteristic index of each crack expansion endpoint are larger, the probability of continuous expansion of the crack is higher, the influence degree on surrounding areas is higher, the potential multilateral expansion coefficient value of the crack lines is larger, and when the potential multilateral expansion coefficient value of each crack line on the watch dial is larger, the influence of the crack lines on the performance of the watch dial is larger, and the dial defect evaluation index value is larger.
The influences caused by crack lines and the influences possibly caused in the future are comprehensively considered, potential multilateral expansion coefficients of the crack lines are obtained, and further, according to the potential multilateral expansion coefficients of all the crack lines, the dial defect evaluation index is obtained, and accuracy of defect degree evaluation on the dial of the watch is improved.
Step S003, according to the dial defect evaluation index, dividing the defect degree of the watch dial into four grades of no defect, slight degree, moderate degree and severe degree.
When the dial defect evaluation index is smaller than the defect threshold valueWhen the defect degree of the watch dial is judged to be defect-free; when the dial defect evaluation index is greater than or equal to the defect threshold/>While being less than the mild threshold/>When the defect degree of the watch dial is judged to be mild; when the dial defect evaluation index is greater than or equal to the mild threshold/>While being less than the medium threshold/>When the defect degree of the watch dial is judged to be moderate; when the dial defect evaluation index is greater than or equal to the medium threshold/>In this case, the degree of defect in the dial of the wristwatch is determined to be severe. Wherein, defect threshold/>The empirical value was 0.3, mild threshold/>Experience value is 0.6, moderate threshold/>The empirical value was 0.9.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. And the foregoing description has been directed to specific embodiments of this specification. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and the same or similar parts of each embodiment are referred to each other, and each embodiment mainly describes differences from other embodiments.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; the technical solutions described in the foregoing embodiments are modified or some of the technical features are replaced equivalently, so that the essence of the corresponding technical solutions does not deviate from the scope of the technical solutions of the embodiments of the present application, and all the technical solutions are included in the protection scope of the present application.