A method and system for automatic visual inspection of commutator appearance defects
Through the automated visual detection method, the feature extraction and clustering analysis of the grayscale image of the commutator appearance is solved, and the high accuracy detection of the commutator appearance defect is achieved. .
Patent Information
- Application Number
- CN202410350051.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-03-26
AI Technical Summary
The prior art is not very accurate when detecting appearance defects of commutator, mainly because the commutator structure is complex and has many details, making it difficult for traditional visual detection methods to effectively extract features.
By obtaining the grayscale image of the commutator appearance, the commutator side feature index, structural solid index and defect evaluation index are calculated, and combined with DBSCAN clustering, Radon transformation and grayscale symbiosis matrix entropy are achieved. Automatic detection of commutator appearance defects.
The accuracy of the appearance defect detection of commutator is improved, and the shape and distribution characteristics of the side of the commutator plate can be effectively analyzed, the degree of defects can be evaluated, and the automatic visual detection of the appearance defects of commutator are achieved.
Smart Images

Figure CN118392866B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an automatic visual detection method and system for commutator appearance defects. Background Art
[0002] The commutator is an important component in DC motors, DC generators and certain types of AC commutator motors. It is usually composed of a group of copper plates fixed to the rotating machine. These copper plates are separated by mica sheets to form a cylindrical or disc shape. Its main function is to change the direction of the current in the armature winding through physical contact when the motor rotates, so that the motor can continue to rotate to achieve the starting and operation of the motor.
[0003] Since the commutator plays an important role in the motor, it is necessary to regularly inspect and maintain the commutator to ensure the reliable operation of the motor. The main method for detecting commutator appearance defects is to use automated visual inspection methods, which can automatically and non-destructively complete the detection of commutator appearance defects. However, the structure of the commutator is relatively complex and has many details. It is difficult to extract the features of the commutator appearance, resulting in low accuracy when using traditional visual inspection methods to detect commutator appearance defects. Summary of the invention
[0004] In order to solve the above technical problems, the purpose of the present invention is to provide a method and system for automatic visual inspection of commutator appearance defects. The technical solutions adopted are as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for automatic visual inspection of commutator appearance defects, the method comprising the following steps:
[0006] Collecting the appearance image of the commutator to obtain the appearance grayscale image of the commutator;
[0007] Obtain a commutator appearance binary image and a commutator edge according to the commutator appearance grayscale image; obtain a commutator segment side edge feature index of each commutator edge according to the commutator appearance binary image; obtain a commutator segment side edge and the position of each commutator segment side edge according to the commutator segment side edge feature index of all commutator edges;
[0008] Obtaining the solid theoretical angle of each commutator segment side according to all commutator segment sides; obtaining the commutator segment structure solid index of each commutator segment side according to the positions of all commutator segment sides and the solid theoretical angle;
[0009] A set of points to be tested is obtained according to the solidity index of the commutator segment structure on all sides of the commutator segments; a commutator appearance defect evaluation index of each pixel in the set of points to be tested is calculated according to the grayscale values of all pixels in the grayscale image of the commutator appearance;
[0010] The defective pixel points are obtained according to the commutator appearance defect evaluation index of all pixel points in the point set to be detected, so as to realize the automatic visual detection of the commutator appearance defects.
[0011] Furthermore, the obtaining of the binary image of the commutator appearance and the commutator edge includes:
[0012] The gray image of the commutator appearance is used as the input of the canny edge detection operator, and the binary image of the commutator appearance is output;
[0013] The connected domain in the binary image of the commutator appearance with the number of pixels greater than the preset minimum line length is recorded as the commutator edge.
[0014] Further, the obtaining of the commutator segment side feature index of each commutator edge includes:
[0015] The least square method is used to perform straight line fitting on each commutator edge, the fitting slope of each commutator edge is obtained, and the fitting goodness is calculated; when the fitting slope of the commutator edge does not exist, the fitting slope of the commutator edge is set to a preset maximum fitting slope;
[0016] Performing Radon transform on the binary image of the commutator appearance to obtain the number of edge pixels in the vertical direction at each edge pixel in the binary image of the commutator appearance; recording the number of edge pixels in the vertical direction at each edge pixel on each commutator edge as the vertical edge feature index of each edge pixel on each commutator edge; recording the maximum value of the vertical edge feature indexes of all edge pixels on each commutator edge as the vertical maximum line length of each commutator edge;
[0017] The absolute value of the fitting slope of each commutator edge and the inverse of the sum of the preset coordination factor are multiplied by the fitting goodness, which is recorded as the fitting vertical index of each commutator edge, and the sum of the fitting vertical index and the maximum vertical line length is recorded as the commutator side feature index.
[0018] Further, obtaining the side edge of the commutator segment and the position of each side edge of the commutator segment includes:
[0019] The commutator segment side feature indexes of all commutator edges are used as the input of the DBSCAN clustering algorithm to obtain clusters, and the average value of the commutator segment side feature indexes of all commutator edges in each cluster is recorded as the side clustering index of each cluster;
[0020] The cluster with the largest side clustering index is recorded as the commutator side cluster, each commutator edge in the commutator side cluster is recorded as a commutator side, and the midpoint of the two end points of each commutator side is taken as the position of each commutator side.
[0021] Further, the obtaining of the solid theoretical angle of each commutator segment side includes:
[0022] The number of commutator segment sides minus one is recorded as the commutator segment interval number, and the ratio of 180 degrees to the commutator segment interval number is recorded as the adjacent degrees of the commutator side;
[0023] Arrange all commutator segment sides in ascending order according to the horizontal axis, obtain the number of each commutator segment side, multiply the difference between the number of each commutator segment side and the value 1 by the adjacent degrees of the commutator side to record the absolute angle of each commutator segment side, and record the difference between 90 degrees and the absolute angle as the solid theoretical angle of each commutator segment side.
[0024] Further, the obtaining of the commutator segment structure solidity index of each commutator segment side includes:
[0025] The side of the commutator segment with the smallest horizontal coordinate is taken as the visible left edge, the side of the commutator segment with the largest horizontal coordinate is taken as the visible right edge, and the absolute value of the difference between the horizontal coordinates of the visible left edge and the visible right edge is taken as the diameter length of the commutator;
[0026] The calculation method of the commutator segment structural solidity index on each commutator segment side is as follows:
[0027]
[0028]
[0029] Among them, D d The solidity index of the commutator segment structure represents the commutator segment side d, E represents the number of preset adjacent commutator segment sides, and F d,d+e represents the actual theoretical distance between the commutator segment side d and the commutator segment side d+e, dist d,d+e represents the Euclidean distance between the commutator segment side d and the commutator segment side d+e, ε represents the preset coordination factor, L represents the diameter length of the commutator, sin() represents the sine function, θ d ,θ d+e They respectively represent the solid theoretical angles of the commutator segment side d and the commutator segment side d+e.
[0030] Further, the obtaining of the set of points to be detected includes:
[0031] The commutator segment structural solidity index of all commutator segment sides is used as the input of the Otsu threshold segmentation algorithm, and the deformation segmentation threshold is output. The commutator segment sides above the deformation segmentation threshold are recorded as non-deformed sides, and the set of pixel points on all commutator segment sides except the non-deformed sides is recorded as the point set to be detected.
[0032] Furthermore, the calculation of the commutator appearance defect evaluation index of each pixel point in the set of points to be detected specifically includes:
[0033] For each pixel point in the set of points to be detected, an appearance observation window with a side length of a preset first length and a neighborhood window with a side length of a preset second length are constructed with each pixel point as the center, and the gray level co-occurrence matrix of the appearance observation window of each pixel point in each direction in the preset direction set is obtained, and the entropy of each gray level co-occurrence matrix is calculated, and the maximum value of the entropy of the gray level co-occurrence matrix of each pixel point in all directions in the preset direction set is recorded as the regional texture complexity index of each pixel point;
[0034] The absolute value of the difference between the ratio of the grayscale value of each pixel and each pixel in its neighborhood window and the value 1 is recorded as the grayscale difference between each pixel and each pixel in its neighborhood window. The sum of the grayscale differences between each pixel and all the pixels in its neighborhood window is multiplied by the regional texture complexity index to obtain the commutator appearance defect evaluation index for each pixel.
[0035] Furthermore, the acquisition of defective pixel points to realize automatic visual detection of commutator appearance defects includes:
[0036] The commutator appearance defect evaluation index of all pixel points in the set of points to be detected is used as the input of the Otsu threshold segmentation algorithm, the defect evaluation threshold is output, and the pixel points whose commutator appearance defect evaluation index in the set of points to be detected is greater than or equal to the defect evaluation threshold are regarded as defective pixel points;
[0037] When the proportion of defective pixels in the commutator appearance grayscale image is greater than a preset defect threshold, it is determined that the commutator appearance has defects; otherwise, it is determined that the commutator appearance has no defects.
[0038] In a second aspect, an embodiment of the present invention further provides an automated visual inspection system for commutator appearance defects, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the above-mentioned methods when executing the computer program.
[0039] The present invention has at least the following beneficial effects:
[0040] The shape and length characteristics of the commutator segments in the commutator are analyzed, and a commutator segment side feature index is constructed. The commutator segment side feature indexes of all commutator edges are clustered to obtain the commutator segment side, thereby improving the accuracy of commutator segment side acquisition. Considering that when the commutator is defect-free, the commutator segments are evenly distributed on the periphery of the commutator, the variation characteristics of the commutator segment side spacing are analyzed, and the solid theoretical distance between each commutator segment side and its adjacent commutator segment side is obtained to represent the theoretical distance between the commutator segment sides. The actual Euclidean distance and theoretical distance between each commutator segment side and its adjacent commutator segment side are comprehensively considered to construct a commutator segment structure solid index to reflect the commutator. The regularity of the distribution of the commutator segment sides in the appearance grayscale image improves the accuracy of the deformation degree assessment of each commutator segment side in the commutator; based on the commutator segment structure solidity index of all commutator segment sides, a set of points to be detected is obtained, and the texture features in the appearance observation window of each pixel point in the set of points to be detected and the distribution of grayscale values around the pixel points are analyzed to construct a commutator appearance defect assessment index to reflect the degree of defects such as friction and scratches at each pixel point in the set of points to be detected; defective pixels are obtained based on the commutator appearance defect assessment index of all pixels in the set of points to be detected, and automated visual inspection of commutator appearance defects is realized, thereby improving the accuracy of commutator appearance defect degree assessment. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A flowchart of a method for automatic visual inspection of commutator appearance defects provided by one embodiment of the present invention;
[0043] Figure 2 is a top view of the commutator;
[0044] Figure 3 Schematic diagram of the solid theoretical angle. DETAILED DESCRIPTION
[0045] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the method and system for automatic visual inspection of commutator appearance defects proposed by the present invention, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0046] 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.
[0047] The specific scheme of the automatic visual inspection method and system for commutator appearance defects provided by the present invention is described in detail below with reference to the accompanying drawings.
[0048] See also Figure 1 , which shows a flowchart of a method for automatic visual inspection of commutator appearance defects provided by an embodiment of the present invention, the method comprising the following steps:
[0049] Step S001, collecting and preprocessing the appearance image of the commutator to obtain the grayscale image of the appearance of the commutator.
[0050] Place the CCD camera directly opposite the commutator, shoot the commutator, collect the commutator appearance image, and use the grayscale averaging method to grayscale the commutator appearance image. Since the commutator appearance image may be affected by environmental interference and other factors during the shooting process, noise may exist in the commutator appearance image. In order to denoise the image while retaining the image detail information, the bilateral filtering algorithm is used to denoise the commutator appearance image after grayscale processing, and the denoised grayscale image is recorded as the commutator appearance grayscale image. Since the contrast of the commutator surface defects is low, in order to improve the accuracy of subsequent analysis, this embodiment uses an adaptive contrast enhancement algorithm to enhance the commutator appearance grayscale image, improve the contrast in the image, make the edge details in the image clearer, and facilitate the identification of defects in subsequent steps. Among them, the grayscale averaging method, the bilateral filtering algorithm, and the adaptive contrast enhancement algorithm are all well-known technologies, and this embodiment will not be repeated here.
[0051] At this point, a grayscale image of the commutator appearance is obtained.
[0052] Step S002, obtaining the commutator segment side feature index according to the commutator appearance grayscale image, determining the commutator segment side cluster and the commutator segment side, calculating the commutator segment structure solidity index, obtaining the non-deformed side, determining the point set to be detected, and calculating the commutator appearance defect evaluation index.
[0053] The material of the commutator segment is mainly conductive materials such as copper and iron. It is the conductor part of the commutator. The commutator segments are separated by mica to isolate the current between the commutator segments. The color of mica and commutator segments is different, and the commutator segments are mostly rectangular. If the commutator does not have defects such as deformation, the side of each commutator segment is a vertical straight line, and the length of the side of each commutator segment is roughly equal, which appears as multiple parallel vertical line segments in the grayscale image of the commutator appearance. Based on this, the commutator segment side feature index is constructed to reflect the possibility that each edge in the grayscale image of the commutator appearance is the side of the commutator segment. The construction process of the commutator segment side feature index is as follows:
[0054] The commutator appearance grayscale image is used as the input of the canny edge detection operator, and the commutator appearance binary image is output. The pixel points with a value of 1 in the commutator appearance binary image are edge pixels. The number of pixels in the commutator appearance binary image that is greater than the minimum line length l is min The connected domain is recorded as the commutator edge. In this embodiment, the minimum line length l min The value is 10. The horizontal coordinates of all pixels on each commutator edge in the commutator appearance binary image are used as the dependent variable of the least squares method, and the vertical coordinates are used as the independent variable of the least squares method. The least squares method is used to perform a straight line fit on each commutator edge, and the fitting slope of each commutator edge is obtained. The goodness of fit is calculated. When the fitting slope is closer to 0, it means that the commutator edge is closer to the vertical direction. When the fitting slope does not exist, the fitting slope of the commutator edge is set to the maximum fitting slope k. max , the maximum fitting slope k in this embodiment max The value is 1000. The canny edge detection operator and the least square method are both well-known technologies, and are not described in detail in this embodiment.
[0055] The projection angle of the Radon transform is set to 90°, and the commutator appearance binary image is subjected to the Radon transform to obtain the number of edge pixels in the vertical direction at each edge pixel in the commutator appearance binary image. The Radon transform is a well-known technology and will not be described in detail in this embodiment. The calculation formula of the commutator segment side feature index is as follows:
[0056]
[0057] Among them, A a The commutator segment side characteristic index, K, represents the commutator edge a a , They represent the fitting slope and goodness of fit of the commutator edge a respectively, max{} is the maximum value function, Rd a,i represents the number of edge pixels in the vertical direction at the ith edge pixel on the commutator edge a, ne arepresents the number of edge pixels on the commutator edge a, ε represents the coordination factor, the purpose of which is to prevent the denominator from being 0. In this embodiment, ε is taken as 0.01.
[0058] When the absolute value of the fitting slope of the commutator edge is smaller and the fitting goodness is greater, it means that the commutator edge is closer to the vertical direction, the more likely it is to be the side of the commutator segment, and the larger the commutator segment side feature index value is; when the number of edge pixels in the vertical direction at the edge pixel points on the commutator edge is more, it means that the length of the commutator edge is longer and the closer it is to the vertical direction, the more likely it is to be the side of the commutator segment, and the larger the commutator segment side feature index value is.
[0059] The commutator segment side edge characteristic index of each commutator edge obtained through the above steps reflects the possibility that each commutator edge is a commutator segment side edge.
[0060] Since the shape of the commutator is usually cylindrical to adapt to the rotation of the armature, and the size of the commutator segments is the same and evenly distributed around the commutator, in order to analyze the distribution characteristics between the commutator segments, the commutator segment side feature index of all commutator edges is used as the input of the DBSCAN clustering algorithm to obtain clustering clusters, and the average value of the commutator segment side feature index of all commutator edges in each clustering cluster is recorded as the side clustering index of each clustering cluster, and the clustering cluster with the largest side clustering index is recorded as the commutator segment side cluster, and each commutator edge in the commutator segment side cluster is recorded as a commutator segment side.
[0061] Taking 12 commutator segments as an example, the top view of the commutator is as follows: Figure 2 shown. Figure 2 In the figure, point O is the center of the commutator, points C0 and C 11 , C 21 They are the upper end points of the commutator segments, point C 12 , C 22 Point C 11 , C 21 The projection point on the straight line OC0 is the observed point C in the shooting direction of the CCD camera. 11 The distance between the side of the commutator segment where point C0 is located is the line segment C. 11 C 12 The length of the observed point C 21 The side of the commutator segment and point C 11 The distance between the sides of the commutator segments is the line segment C. 21 C 22 Length.
[0062] Since the commutator segments are evenly distributed around the commutator, when the commutator is free of defects, the angles between the commutator segments are roughly equal. Considering that only the commutator segments within 180 degrees on the commutator can be observed in the shooting direction of the CCD camera, the angle between two adjacent commutator segments is recorded as the adjacent degrees of the commutation side. Wherein, B represents the number of commutator segment sides.
[0063] Arrange all the commutator segment sides in ascending order according to the horizontal axis, and number the sorted commutator segment sides as 1, 2, ..., B, and record the solid theoretical angle of each commutator segment side as θ d =90°-θ0×(d-1), the absolute value of the solid theoretical angle represents the angle between the side of each commutator segment and the shooting direction of the CCD camera when the commutator is free of defects, where θ d is the solid theoretical angle of the commutator segment side d, and θ0 is the adjacent degree of the commutator side. The schematic diagram of the solid theoretical angle is shown in Figure 3 As shown, Figure 3 Middle, point C 21 The solid theoretical angle on the side of the commutator segment is α.
[0064] The midpoint of the two endpoints of each commutator side is taken as the position of each commutator side, the commutator side with the smallest horizontal coordinate is taken as the visible left edge, and the commutator side with the largest horizontal coordinate is taken as the visible right edge. Then the commutator edge 1 and the commutator edge B are the visible left edge and the visible right edge respectively, and the absolute value of the difference between the horizontal coordinates of the visible left edge and the visible right edge is taken as the diameter length of the commutator, wherein the DBSCAN clustering algorithm is a well-known technology and will not be described in detail in this embodiment. Then the calculation formula of the commutator structure solidity index is as follows:
[0065]
[0066]
[0067] Among them, D d The solidity index of the commutator segment structure represents the commutator segment side d, E represents the number of adjacent commutator segment sides, and in this embodiment, E is 3, and F d,d+e represents the actual theoretical distance between the commutator segment side d and the commutator segment side d+e, dist d,d+e represents the Euclidean distance between the commutator side d and the commutator side d+e, ε represents the coordination factor, the purpose is to prevent the denominator from being 0, in this embodiment, ε is taken as 0.01, L represents the diameter length of the commutator, sin() represents the sine function, θ d ,θ d+e They respectively represent the solid theoretical angles of the commutator segment side d and the commutator segment side d+e.
[0068] When the absolute value of the difference between the sine values of the solid theoretical angles of the two commutator segment sides is larger, it means that theoretically, the distance between the endpoints of the two commutator segment sides in the same top view of the commutator is farther, and the solid theoretical distance value is larger; when the difference between the solid theoretical distance between the commutator segment side and its adjacent commutator segment side and the actual Euclidean distance is larger, it means that the distance between the commutator segment side and its adjacent commutator segment side is less in line with the law of uniform distribution, the commutator is more likely to have defects such as deformation, displacement between commutator segments, and the commutator segment structure solid index value is smaller.
[0069] The commutator segment structure solidity index of each commutator segment edge pixel point obtained through the above steps reflects the regularity of the commutator segment side distribution.
[0070] When the commutator is working, it may have surface damage due to mechanical collision, friction, etc., or insulation damage due to overvoltage, overcurrent, etc., which may cause local color changes and irregularities in the grayscale image of the commutator appearance. Based on the above analysis, the commutator appearance defect evaluation index is constructed based on the commutator segment structure solidity index to reflect the degree of defects in the commutator appearance. The construction process of the commutator appearance defect evaluation index is as follows:
[0071] The commutator segment structural solidity index of all commutator segment sides is used as the input of the Otsu threshold segmentation algorithm, and the deformation segmentation threshold is output. The commutator segment sides above the deformation segmentation threshold are recorded as non-deformed sides, and the set of pixel points on all commutator segment sides except the non-deformed sides is recorded as the point set to be detected.
[0072] For each pixel point in the set of points to be detected, take each pixel point as the center, construct an appearance observation window with a side length of l and a neighborhood window with a side length of w, obtain the grayscale co-occurrence matrix of the appearance observation window of each pixel point in each direction in the direction set, and calculate the entropy of each grayscale co-occurrence matrix. In this embodiment, l takes a value of 5, w takes a value of 3, and the direction set includes 0°, 45°, 90°, and 135°. Among them, the Otsu threshold segmentation algorithm, the acquisition of the grayscale co-occurrence matrix, and the calculation of the entropy of the grayscale co-occurrence matrix are all well-known technologies, which will not be described in detail in this embodiment. The calculation formula of the commutator appearance defect evaluation index is as follows:
[0073]
[0074] Among them, G p The commutator appearance defect evaluation index of pixel p, H p,max represents the maximum entropy of the gray-level co-occurrence matrix of pixel p in all directions in the direction set, w 2 Represents the number of pixels in each neighborhood window, Y p Represents the gray value of pixel p, Yp,k Represents the grayscale value of the kth pixel in the neighborhood window of pixel p.
[0075] The entropy of the gray-level co-occurrence matrix in the appearance observation window of the pixel point represents the complexity of the texture of the area where the pixel point is located. The larger the maximum value of the entropy of the gray-level co-occurrence matrix in the appearance observation window of the pixel point, that is, H p,max When the value is larger, it indicates that the gray value distribution in the pixel area is more chaotic and the texture is more complex. The commutator is more likely to have defects such as appearance friction at the pixel, and the commutator appearance defect evaluation index value is larger. When the gray value difference between the pixel and each pixel in its neighborhood window is larger, that is, The larger the value, the more obvious the distribution difference of gray values around the pixel point, that is, the more likely it is that irregular scratches and other defects will appear on the commutator surface, and the larger the commutator appearance defect evaluation index.
[0076] Step S003, obtaining defective pixel points according to the commutator appearance defect evaluation index of all pixel points in the point set to be detected, so as to realize automatic visual detection of commutator appearance defects.
[0077] The commutator appearance defect evaluation index of all pixels in the set of points to be detected is used as the input of the Otsu threshold segmentation algorithm, and the defect evaluation threshold is output. The pixels whose commutator appearance defect evaluation index in the set of points to be detected is greater than or equal to the defect evaluation threshold are used as defective pixels. When the proportion of defective pixels in the commutator appearance grayscale image is greater than the defect threshold, it is determined that the commutator appearance has defects, otherwise, it is determined that the commutator appearance has no defects, and the automatic visual detection of commutator appearance defects is realized. In this embodiment, the defect threshold is 20%. The Otsu threshold segmentation algorithm is a well-known technology, and this embodiment will not be described in detail here.
[0078] Based on the same inventive concept as the above method, an embodiment of the present invention also provides an automated visual inspection system for commutator appearance defects, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the above-mentioned automated visual inspection methods for commutator appearance defects when executing the computer program.
[0079] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The above is a description of a specific embodiment of this specification. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0080] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0081] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An automated visual inspection method for commutator appearance defects, characterized in that: The method comprises the following steps: Collecting the appearance image of the commutator to obtain the appearance grayscale image of the commutator; Obtain a commutator appearance binary image and a commutator edge according to the commutator appearance grayscale image; obtain a commutator segment side edge feature index of each commutator edge according to the commutator appearance binary image; obtain a commutator segment side edge and the position of each commutator segment side edge according to the commutator segment side edge feature index of all commutator edges; Obtaining the solid theoretical angle of each commutator segment side according to all commutator segment sides; obtaining the commutator segment structure solid index of each commutator segment side according to the positions of all commutator segment sides and the solid theoretical angle; A set of points to be tested is obtained according to the solidity index of the commutator segment structure on all sides of the commutator segments; a commutator appearance defect evaluation index of each pixel in the set of points to be tested is calculated according to the grayscale values of all pixels in the grayscale image of the commutator appearance; Defective pixel points are obtained according to the commutator appearance defect evaluation index of all pixel points in the point set to be detected, so as to realize automatic visual detection of commutator appearance defects; The step of obtaining the commutator segment side feature index of each commutator edge includes: The least square method is used to perform straight line fitting on each commutator edge, the fitting slope of each commutator edge is obtained, and the fitting goodness is calculated; when the fitting slope of the commutator edge does not exist, the fitting slope of the commutator edge is set to a preset maximum fitting slope; Performing Radon transform on the binary image of the commutator appearance to obtain the number of edge pixels in the vertical direction at each edge pixel in the binary image of the commutator appearance; recording the number of edge pixels in the vertical direction at each edge pixel on each commutator edge as the vertical edge feature index of each edge pixel on each commutator edge; recording the maximum value of the vertical edge feature indexes of all edge pixels on each commutator edge as the vertical maximum line length of each commutator edge; The inverse of the sum of the absolute value of the fitting slope of each commutator edge and the preset coordination factor is multiplied by the goodness of fit, which is recorded as the fitting vertical index of each commutator edge, and the sum of the fitting vertical index and the maximum vertical line length is recorded as the commutator segment side edge characteristic index; The step of obtaining the solid theoretical angle of each commutator segment side includes: The number of commutator segment sides minus one is recorded as the commutator segment interval number, and the ratio of 180 degrees to the commutator segment interval number is recorded as the adjacent degrees of the commutator side; Arrange all commutator segment sides in ascending order according to the horizontal axis, obtain the number of each commutator segment side, multiply the difference between the number of each commutator segment side and the value 1 by the adjacent degrees of the commutator side to record the absolute angle of each commutator segment side, and record the difference between 90 degrees and the absolute angle as the solid theoretical angle of each commutator segment side; The obtaining of the commutator segment structure solidity index of each commutator segment side includes: The side of the commutator segment with the smallest horizontal coordinate is taken as the visible left edge, the side of the commutator segment with the largest horizontal coordinate is taken as the visible right edge, and the absolute value of the difference between the horizontal coordinates of the visible left edge and the visible right edge is taken as the diameter length of the commutator; The calculation method of the commutator segment structural solidity index on each commutator segment side is as follows: ; ; in, Indicates the side of the commutator segment The solidity index of the commutator segment structure, Indicates the number of preset adjacent commutator segment sides, Indicates the side of the commutator segment With the commutator segment side The solid theoretical distance between Indicates the side of the commutator segment With the commutator segment side The Euclidean distance between represents the preset coordination factor, Indicates the diameter length of the commutator, represents the sine function, , Respectively represent the commutator segment side , Commutator segment side The solid theoretical angle of The step of obtaining a set of points to be detected includes: The commutator segment structural solidity index of all commutator segment sides is used as the input of the Otsu threshold segmentation algorithm, and the deformation segmentation threshold is output. The commutator segment sides above the deformation segmentation threshold are recorded as non-deformation sides, and the set of pixel points on all commutator segment sides except the non-deformation sides is recorded as the set of points to be detected; The step of calculating the commutator appearance defect evaluation index of each pixel point in the set of points to be detected specifically includes: For each pixel point in the set of points to be detected, an appearance observation window with a side length of a preset first length and a neighborhood window with a side length of a preset second length are constructed with each pixel point as the center, and the gray level co-occurrence matrix of the appearance observation window of each pixel point in each direction in the preset direction set is obtained, and the entropy of each gray level co-occurrence matrix is calculated, and the maximum value of the entropy of the gray level co-occurrence matrix of each pixel point in all directions in the preset direction set is recorded as the regional texture complexity index of each pixel point; The absolute value of the difference between the ratio of the grayscale value of each pixel and each pixel in its neighborhood window and the value 1 is recorded as the grayscale difference between each pixel and each pixel in its neighborhood window. The sum of the grayscale differences between each pixel and all the pixels in its neighborhood window is multiplied by the regional texture complexity index to obtain the commutator appearance defect evaluation index for each pixel.
2. The method for automatic visual inspection of commutator appearance defects according to claim 1, characterized in that: The step of obtaining the binary image of the commutator appearance and the commutator edge includes: The commutator appearance grayscale image is used as the input of the canny edge detection operator, and the commutator appearance binary image is output; The connected domain in the binary image of the commutator appearance whose number of pixels is greater than the preset minimum line length is recorded as the commutator edge.
3. The method for automatic visual inspection of commutator appearance defects according to claim 1, characterized in that: The obtaining of the side edge of the commutator segment and the position of each side edge of the commutator segment comprises: The commutator segment side feature indexes of all commutator edges are used as the input of the DBSCAN clustering algorithm to obtain clusters, and the average value of the commutator segment side feature indexes of all commutator edges in each cluster is recorded as the side clustering index of each cluster; The cluster with the largest side clustering index is recorded as the commutator side cluster, each commutator edge in the commutator side cluster is recorded as a commutator side, and the midpoint of the two end points of each commutator side is taken as the position of each commutator side.
4. The method for automatic visual inspection of commutator appearance defects according to claim 1, characterized in that: The method of obtaining defective pixel points to realize automatic visual detection of commutator appearance defects includes: The commutator appearance defect evaluation index of all pixel points in the set of points to be detected is used as the input of the Otsu threshold segmentation algorithm, the defect evaluation threshold is output, and the pixel points whose commutator appearance defect evaluation index in the set of points to be detected is greater than or equal to the defect evaluation threshold are regarded as defective pixel points; When the proportion of defective pixels in the commutator appearance grayscale image is greater than a preset defect threshold, it is determined that the commutator appearance has defects; otherwise, it is determined that the commutator appearance has no defects.
5. An automated visual inspection system for commutator appearance defects, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
