A method for intelligent identification of defects in metal accessories
By using multiple directional illumination exposures and grayscale response analysis, the problem of distinguishing surface shape changes and defects in metal accessories was solved, enabling accurate identification of defects and reducing misjudgments.
Patent Information
- Application Number
- CN202611489790.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies struggle to effectively distinguish between normal shape changes and local defects on the surface of metal accessories. This results in similar brightness variations between normally shaped surfaces and local defects in a single image, making it easy to misjudge or miss defects.
Multiple directional lighting zones are used to expose the surface of metal accessories one after another. By comparing the peak position of grayscale response under different lighting positions, the continuous change trend and normal fluctuation range of local areas are established. Defect areas are identified by using the deviation of pixels and boundary relationships.
It improves the accuracy of identifying surface defects in metal accessories, reduces confusion between normal surfaces and local defects, and ensures the correct output of defect areas.
Smart Images

Figure CN123118602A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of optical vision inspection technology for metal surface defects, and particularly to an intelligent identification method for metal accessory defects. Background Technology
[0002] Metal accessories can be processed into electrical fittings, iron accessories, and enclosures and components for distribution boxes and metering boxes, among other electrical metal products. Surface defect detection can be achieved by using industrial cameras to capture surface images, and then identifying anomalies based on local grayscale, edge variations, or differences from normal images. For metal accessories with normal shape changes such as bending and stamping, different parts of the surface will have different reflection responses to illumination from the same direction. Normal curved surfaces may also exhibit continuous bright or dark bands; scratches, indentations, and other local shape anomalies may also manifest as changes in brightness. Both have similar grayscale representations in a single image. Directly classifying defects based on brightness differences can easily label normally formed areas as anomalies and may also miss local defects located within bright bands. Simply adjusting the illumination intensity or grayscale threshold mainly changes the image brightness or anomaly classification boundary, but it cannot distinguish whether the brightness changes are caused by normal surface shapes or local defects. Inconsistencies may still occur between different shaped parts of the same workpiece. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide an intelligent identification method for defects in metal accessories.
[0004] The technical solution of this invention is a method for intelligent identification of defects in metal accessories, comprising:
[0005] S1. Place the metal accessory to be tested in a light-shielded detection position, control multiple directional lighting zones that are set around the optical axis of the industrial camera and have the same illumination tilt angle relative to the bearing plane of the detection position, and illuminate them sequentially according to their respective illumination directions. During the illumination of each of the directional lighting zones, control the industrial camera to expose the same surface to be tested, and obtain an image sequence ordered according to the illumination directions.
[0006] S2. Compare the grayscale response at the same pixel coordinates in the image sequence under each illumination orientation, take the illumination orientation corresponding to the peak grayscale response as the peak orientation of the pixel, and form an orientation distribution from the peak orientations of each pixel on the surface to be inspected.
[0007] S3. Within a local area of the surface to be inspected, determine the continuous change trend caused by the change in surface shape based on the orientation distribution of the peripheral pixels of the local area, and determine the local normal fluctuation range based on the deviation of the peak orientation of the peripheral pixels from the continuous change trend; group the pixels whose peak orientation deviates from the continuous change trend beyond the local normal fluctuation range according to the deviation direction.
[0008] S4. When the peak orientation of two adjacent groups of pixels is opposite to the deviation direction of the continuous change trend, and the two groups of pixels have a common boundary, the common boundary and the area on both sides are determined as the defect area of abnormal surface shape, and the position of the defect area on the metal accessory to be tested is output.
[0009] In one implementation, in S3, the peak orientation of each pixel is read along a closed path around the periphery of the local region.
[0010] As one implementation, multiple directional lighting zones are simultaneously illuminated before S2 to obtain a contour image of the surface to be inspected. The outer contour and internal structural boundary of the metal attachment are extracted from the contour image, and in S3, boundary bands that connect with the outer contour or the internal structural boundary are excluded from the analysis range of the local area.
[0011] As one implementation method, when the directional lighting zones in S1 are lit sequentially, the exposure parameters of the industrial camera are kept unchanged.
[0012] In one implementation, in S2, the maximum grayscale response and the second largest grayscale response of the same pixel in the image sequence are compared. When the difference between the two is greater than a preset grayscale difference threshold, the illumination orientation corresponding to the maximum grayscale response is determined as the peak orientation of the pixel.
[0013] As one implementation method, after the local normal fluctuation range is initially determined, pixels whose peak orientation deviation continuously exceeds the local normal fluctuation range are removed from the pixels surrounding the local region.
[0014] As one implementation, when adjacent local regions respectively form the common boundary, and the ends of the common boundary in different local regions are adjacent and the extension direction is continuous, and the peak orientation deviation direction of the pixels on both sides of the common boundary in different local regions is consistent, the common boundary in the adjacent local regions and the regions on both sides are merged into the same defect region.
[0015] As one implementation method, when the metal accessory to be tested reaches the detection position, each of the directional lighting zones is controlled to light up sequentially, and the image sequence is acquired under the same detection posture.
[0016] As one implementation, a verification lighting zone is set at the same location as each of the directional lighting zones, and the lighting tilt angle of the verification lighting zone relative to the bearing plane of the detection position is smaller than the lighting tilt angle of the corresponding directional lighting zone;
[0017] For the defective area, select the directional lighting partition whose illumination orientation is closest to the normal direction of the common boundary and its corresponding core lighting partition, and control the directional lighting partition and the core lighting partition to be lit up sequentially. During the lighting of both, control the industrial camera to perform exposure, and determine the connected regions in the defective area that have increased gray level relative to the periphery of the defective area in the two exposure images respectively.
[0018] The determination of the defective region is maintained only when the connected region corresponding to the verification lighting zone moves relative to the connected region corresponding to the directional lighting zone along the normal direction of the common boundary, and both connected regions intersect with the common boundary.
[0019] In one implementation, the plurality of directional lighting zones constitute a first ring light source, and the plurality of composite lighting zones constitute a second ring light source. Both the first ring light source and the second ring light source are coaxially arranged with the optical axis of the industrial camera.
[0020] The advantages of this invention compared to existing technologies are that, for metal accessories where both normal shaped surfaces and local defects can exhibit brightness variations, it does not directly determine defects based on brightness differences in a single image. Instead, it transforms the grayscale response of the same surface location under different lighting orientations into peak orientation. A continuous variation trend and a normal fluctuation range are established from the pixels surrounding the local area, allowing each pixel to be compared with the shape of a nearby normal surface. The continuous reflection direction changes caused by the normal shaped surface do not directly become defect criteria. Furthermore, it simultaneously checks whether two groups of pixels exceeding the normal fluctuation range are adjacent, whether their deviation directions are opposite, and whether they share a common boundary, limiting the defect output to the common boundary and its two sides that satisfy the above spatial relationships. In detection conditions where normal shaped surfaces and local shape anomalies coexist, normal bright bands are not directly labeled as defects due to their prominent brightness, while local shape anomalies can be located based on the directional deviation relationship between the two sides, reducing the possibility of confusion between the two based solely on grayscale representation. Attached Figure Description
[0021] Figure 1 A flowchart illustrating the core technology of an intelligent identification method for metal accessory defects provided in one embodiment of the present invention;
[0022] Figure 2 A flowchart for determining the verification lighting of a defect area provided in one embodiment of the present invention;
[0023] Figure 3 This is a schematic diagram of the peak orientation distribution on the surface to be inspected according to an embodiment of the present invention;
[0024] Figure 4 This is a schematic diagram illustrating the location of a defective region with abnormal surface shape, provided as an embodiment of the present invention. Detailed Implementation
[0025] The embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0026] In one implementation, such as Figure 1 , Figure 3 and Figure 4 As shown, a method for intelligent identification of defects in metal accessories includes: S1, placing the metal accessory to be tested in a light-shielded detection position, controlling multiple directional lighting zones that are set around the optical axis of an industrial camera and have the same illumination tilt angle relative to the bearing plane of the detection position, lighting them sequentially according to their respective illumination directions, and controlling the industrial camera to expose the same surface to be inspected during the illumination of each of the directional lighting zones, thereby obtaining an image sequence ordered according to the illumination directions; S2, comparing the grayscale response at the same pixel coordinates in the image sequence under each illumination direction, taking the illumination direction corresponding to the peak grayscale response as the peak direction of that pixel, and forming an orientation distribution from the peak directions of each pixel on the surface to be inspected; S3. Within a local area of the surface to be inspected, determine the continuous change trend caused by the change in surface shape based on the orientation distribution of the peripheral pixels of the local area, and determine the local normal fluctuation range based on the deviation of the peak orientation of the peripheral pixels from the continuous change trend; group the pixels whose peak orientation deviates from the continuous change trend beyond the local normal fluctuation range according to the deviation direction; S4. When the peak orientations of two adjacent groups of pixels deviate in opposite directions from the continuous change trend, and the two groups of pixels have a common boundary, determine the common boundary and the areas on both sides of it as defect areas with abnormal surface shape, and output the position of the defect area on the metal accessory to be tested.
[0027] In this embodiment, industrial vision is used to visually inspect the surface of metal accessories. The inspection object is a metal accessory that can be processed into power fittings or iron accessories. The surface to be inspected is located within the field of view of the industrial camera. The light source controller controls the illumination of each directional illumination zone, the industrial camera acquires images, and the image processing equipment connected to the industrial camera completes peak orientation comparison, pixel grouping, and defect location output. The illumination orientation refers to the directional position of each directional illumination zone around the optical axis of the industrial camera. The illumination tilt angle is referenced to the bearing plane of the inspection position, and the two are not the same angle. When each directional illumination zone is illuminated sequentially, each exposure is during the illumination period of the current zone, and the image is saved corresponding to the illumination orientation of that zone. The same pixel coordinate corresponds to the same surface to be inspected in each image, so the grayscale response of that position can be compared with the illumination orientation. For each pixel, the grayscale response in the image sequence is read, and the illumination orientation corresponding to the maximum grayscale response is compared and retained. This illumination orientation is called the peak orientation, which represents the incident orientation with the strongest grayscale response at that surface position under the current illumination conditions. It is not the grayscale value, nor is it equivalent to the directly measured three-dimensional surface normal. The peak orientation of each pixel is preserved at the original pixel coordinates, forming an orientation distribution, which is a two-dimensional distribution with pixel coordinates as the position and peak orientation as the value. Figure 3 This diagram illustrates the peak orientation distribution of the surface under inspection. The horizontal and vertical axes represent pixel positions, and the right-hand scale indicates the peak orientation in degrees. The varying shades of gray in the diagram are used to distinguish peak orientations and do not represent the grayscale response of the original image. Subsequent comparisons will shift from image brightness to peak orientation; even if a location on the same surface appears brighter in a particular exposure, this will not be used to directly identify it as a defect.
[0028] In this embodiment, the peripheral pixels of a local region are used to characterize the surface shape changes around that region. The continuous change trend indicates that the peak orientation reflected by these peripheral pixels changes continuously with the image position, and provides a comparison benchmark for the corresponding position within the local region. The fitting in this example is applicable to regions where the peripheral orientation can be continuously expanded and the normal surface orientation change can be locally approximated. The peak orientation is recorded according to a unified zero-degree direction and the direction of angle increase; when adjacent peripheral pixels cross the zero-degree boundary, they are converted according to integer angles, so that the difference between adjacent orientations is greater than -180 degrees and not greater than 180 degrees. Using the horizontal and vertical coordinates of the peripheral pixels as independent variables, the expanded peak orientation is fitted as the sum of the first-order terms of the horizontal and vertical coordinates and a constant term. The least squares method is used to minimize the coefficient of determination by the sum of the squares of the differences between the measured orientation and the fitted orientation; the fitted orientation calculated at each pixel coordinate is the corresponding orientation of the continuous change trend. Both peripheral and internal pixels are calculated by subtracting the corresponding orientation of the continuous trend at the same coordinate from their own peak orientation, converted to an angle greater than -180 degrees and not greater than 180 degrees. The absolute value of the resulting signed angle difference is the deviation, with positive and negative signs indicating opposite deviation directions. The deviation is measured in degrees, not grayscale difference. The local normal fluctuation range uses the same orientation scale as the above deviation, and its data source is the deviation of peripheral pixels in that local area relative to the continuous trend, not the grayscale range of other workpieces, nor the variation range of the peak orientation of the entire surface under inspection. In this example, the mean and standard deviation of the peripheral pixel deviation are calculated, with the mean plus three times the standard deviation as the upper limit. The range from zero to this upper limit is the local normal fluctuation range. Only when the deviation of internal pixels is strictly greater than this upper limit will they be grouped according to the positive and negative signs of the aforementioned angle difference. For example, on a normally formed curved surface, the peak orientation changes continuously with the surface shape. As long as the deviation relative to this continuous trend does not exceed the local normal fluctuation range, the bright band on the surface will not enter the abnormal pixel group simply because of its difference in brightness from adjacent parts. Pixels with the same deviation direction are grouped according to their position in the image, and the boundary where two adjacent groups meet in the image is the common boundary. This common boundary is the meeting position determined in the pixel grouping results, not the pre-given workpiece outline. For two groups of pixels, first check their respective deviation directions relative to the continuous changing trend, and then determine whether the two groups have a common boundary; two spatially separated abnormal pixel groups cannot replace two adjacent groups with a common boundary. The defect location is represented by the pixel coordinates of the defect area in the image of the surface to be inspected, and corresponds to the inspection image of the metal accessory to be tested in this instance. Figure 4 The horizontal and vertical coordinates of pixels indicate the location of defective areas with abnormal surface shapes in the image of the surface to be inspected. Figure 3 and Figure 4 A method of representing the orientation distribution and defect location. Figure 1 The negative branch indicates that the combination condition of S4 is not met, and therefore the entire metal accessory under test is not judged to be defect-free.
[0029] In this embodiment, taking the case of local indentations near a normally shaped curved surface as an example, the bright and dark bands in a single image may simultaneously cover the normal curved surface and the indentation, and the location of the prominent brightness does not directly correspond to the boundary of the indentation. The orientation of the local surface affects the directional conditions of the incident light reflected to the industrial camera. The peak orientation retains the illumination direction that produces the strongest grayscale response, rather than the brightness of this exposure. The illumination tilt angles of each directional illumination zone are the same, so that the orientation comparison does not mix in the differences in illumination tilt angles between different zones. Under the condition that the peripheral pixels can reflect the shape of the nearby normal surface and the surface under inspection has a distinguishable orientation response, the continuous change trend follows the orientation change of the normal shaped curved surface, and the local normal fluctuation range distinguishes the orientation fluctuations near the trend that do not exceed the range from the local deviations that exceed the range. The two determine the comparison benchmark and the conditions for entering the pixel group, respectively. When the local orientation of the two sides of the indentation changes in a different direction relative to the nearby normal surface, the illumination orientation that produces strong reflections on both sides can be shifted accordingly. Furthermore, if the deviations of two groups of pixels exceeding the local normal fluctuation range are required to have opposite deviation directions and a common boundary, then the two groups of deviations are constrained to spatial correspondence on both sides of the same local boundary, and cannot be replaced by two separate abnormal groups or unilateral deviations. Therefore, when the orientation change of the normal bright band conforms to a continuous trend and the deviation does not exceed the local normal fluctuation range, it will not be output as a defect simply because it is brighter. When the deviations on both sides of the indentation exceed the local normal fluctuation range and satisfy the reverse deviation and common boundary conditions, even if they are within the same bright band, the defect output will fall on the common boundary and the areas on both sides, rather than the entire normal bright band.
[0030] In one implementation, in S3, the peak orientation of each pixel is read along a closed path around the periphery of the local region.
[0031] In this embodiment, starting from a pixel position on the periphery of the local region, peak orientations are read sequentially along a closed path on the periphery, maintaining the correspondence between each peak orientation and its pixel coordinates. The reading path returns to the starting position along the periphery of the local region, and the obtained data retains the spatial adjacency order of the peripheral pixels. Each pixel coordinate and peak orientation participates in the periphery orientation distribution analysis in S3 according to this order, and spatially non-adjacent pixels are not considered adjacent pixels simply because they have the same peak orientation.
[0032] In one implementation, prior to S2, multiple directional illumination zones are simultaneously lit to obtain a contour image of the surface to be inspected. The outer contour and internal structural boundary of the metal attachment are extracted from the contour image, and in S3, boundary bands that connect with the outer contour or the internal structural boundary are excluded from the analysis range of the local area.
[0033] In this embodiment, when multiple directional illumination zones are lit simultaneously, a separate contour image is obtained. This image does not replace the image sequence formed by sequential exposure according to a single illumination orientation. The outer contour corresponds to the boundary between the metal attachment and the image background, while the internal structural boundary may correspond to the boundary of holes, slots, or openings within the workpiece itself. The boundary positions extracted from the contour image correspond to the image coordinates of the surface to be inspected, and boundary bands connected to these boundaries are excluded during S3 analysis. For example, the edge of a hole in the metal attachment itself is not a continuously extending curved surface within the surface to be inspected. After excluding its boundary band, the image bright-dark boundary caused by the hole opening is not directly used as the common boundary of surface shape anomalies. This exclusion operation applies to the analysis range and does not indicate that the excluded boundary bands have been determined as defects.
[0034] In one embodiment, when the directional lighting zones in S1 are lit sequentially, the exposure parameters of the industrial camera are kept constant.
[0035] In this embodiment, the industrial camera maintains constant exposure parameters such as exposure time and gain during the acquisition of the same image sequence, and does not change the exposure parameters frame by frame due to changes in image brightness under different directional lighting zones. Therefore, the grayscale response of the same pixel in different images will no longer be affected by brightness differences caused by frame-by-frame changes in exposure parameters, avoiding changes in the illumination orientation corresponding to the pixel's maximum grayscale response simply due to changes in camera exposure settings.
[0036] In one implementation, in step S2, the maximum grayscale response and the second largest grayscale response of the same pixel in the image sequence are compared. When the difference between the two is greater than a preset grayscale difference threshold, the illumination orientation corresponding to the maximum grayscale response is determined as the peak orientation of the pixel.
[0037] In this embodiment, the maximum and second-largest grayscale responses are both taken from the responses of the same pixel in the same image sequence. These responses are compared in magnitude, and the largest and second-largest responses are selected respectively. The grayscale difference is then obtained by subtracting the latter from the former. This grayscale difference is compared with a grayscale difference threshold set before detection. Only when it exceeds the threshold is the peak orientation of the pixel determined based on the maximum grayscale response. When two maximum candidate responses are the same or close, the pixel cannot be considered to have a distinguishable peak orientation simply because one image appears first. The additional judgment in this embodiment is based on the distinguishability of the peak orientation, rather than directly using the grayscale difference as a defect criterion.
[0038] In one implementation, after the local normal fluctuation range is initially determined, pixels whose peak orientation deviation continuously exceeds the local normal fluctuation range are removed from the pixels surrounding the local region.
[0039] In this embodiment, the pixels to be removed are those on the periphery of a local area, not the defective area already identified in S4. "Continuous exceedance" refers to a continuous segment of pixels in the peripheral space whose peak orientations deviate from the continuous trend by an amount exceeding the initially determined local normal fluctuation range. It does not refer to the continuous grayscale exceedance of the same pixel after multiple exposures. For example, if a segment of peripheral pixels is affected by local shape anomalies, this segment is no longer retained as a normal peripheral pixel to avoid indiscriminately using it with other peripheral pixels. This removal operation does not change the meaning that the deviation of each pixel is still determined with reference to the continuous trend.
[0040] In one embodiment, when adjacent local regions respectively form the common boundary, and the ends of the common boundary in different local regions are adjacent and the extension direction is continuous, and the peak orientation deviation direction of the pixels on both sides of the common boundary in different local regions is consistent, the common boundary in the adjacent local regions and the regions on both sides are merged into the same defect region.
[0041] In this embodiment, after each local region completes S4, the end positions and extension directions of each common boundary are compared using the common image coordinates of the surface to be inspected. The corresponding two sides are distinguished according to the same boundary extension direction, and the peak orientation deviation directions of the pixels on both sides are checked to see if they are consistent. When a local shape anomaly spans two adjacent local regions, the common boundary and its two sides that meet the above conditions are merged into the same defect region for output, avoiding the output of a continuous defect as unrelated regions due to local region division. Regions that are only close at the ends but whose two sides do not correspond in their deviation directions are not merged according to this embodiment.
[0042] In one embodiment, when the metal accessory to be tested reaches the detection position, each of the directional lighting zones is controlled to light up sequentially, and the image sequence is acquired under the same detection posture.
[0043] In this embodiment, the metal accessory to be tested is illuminated sequentially after reaching the detection position, maintaining its position and orientation relative to the industrial camera until the entire image sequence is acquired. After acquiring the corresponding image from each illumination position, the process moves to the next illumination position until the image sequence is completed. This timing ensures that the same pixel coordinate used in S2 continuously corresponds to the same surface position to be inspected, avoiding the comparison of grayscale responses when the workpiece changes posture and falls to another surface position of the same pixel.
[0044] In one implementation, such as Figure 2As shown, a verification lighting zone is set at the same location as each of the directional lighting zones. The illumination tilt angle of the verification lighting zone relative to the bearing plane of the detection position is smaller than that of the corresponding directional lighting zone. For the defect area, the directional lighting zone whose illumination orientation is closest to the normal direction of the common boundary and its corresponding verification lighting zone are selected, and the directional lighting zone and the verification lighting zone are controlled to be lit sequentially. During the lighting of both, the industrial camera is controlled to perform exposure, and the connected regions in the defect area with increased gray level relative to the periphery of the defect area are determined in the two exposure images respectively. The determination of the defect area is maintained only when the connected region corresponding to the verification lighting zone moves relative to the connected region corresponding to the directional lighting zone along the normal direction of the common boundary, and both connected regions intersect with the common boundary.
[0045] In this embodiment, the defect area and common boundary already determined in S4 are used for verification, without determining a separate set of detection areas unrelated to the original defect location. The normal direction of the common boundary is the direction perpendicular to the local extension direction of the boundary in the image of the surface to be inspected, not the directly measured three-dimensional normal of the metal surface. In this example, a straight line fitting is performed on the common boundary that can be approximated locally by a straight line, and the line is determined by minimizing the sum of the squares of the perpendicular distances from the boundary point to the line; the direction of the line is tangential, and its perpendicular direction is normal. These two directions remain unchanged when comparing the two exposures. Under the same orientation reference, the direction difference between each directional illumination zone and the normal direction is compared, and the zone with the closest direction and its corresponding verification illumination zone are selected. The orientations of the two illuminations are the same, but the illumination tilt angles relative to the detection position bearing plane are different. The connected regions in the two exposures are both determined within the original defect area, and the gray level of the outer perimeter of the defect area in the current image is used as the comparison basis. The gray level of the defect area in the first exposure cannot be cross-compared with the gray level of the outer perimeter in the second exposure. In this example, pixels on the surface to be inspected immediately outside the defect area are selected as peripheral samples for each image. The grayscale mean plus three times the standard deviation is used as the grayscale threshold for that image. Pixels with grayscale values greater than the threshold within the defect area are retained, and connected regions are marked according to the eight-neighbor rule (horizontal, vertical, or diagonal adjacent). This threshold is used for grayscale comparison within a single image and is different from the grayscale difference threshold used for the difference between the maximum and second-largest grayscale responses.
[0046] In this embodiment, the geometric center is determined by the arithmetic mean of the x and y coordinates of pixels within each connected region, without using grayscale weighting. The normal displacement threshold and tangential positioning error limit are calibrated based on repeated imaging fluctuations of a fixed surface: a fixed surface region with a common boundary determined according to S4, where connected regions can be extracted under both illumination conditions, is selected. Keeping the camera exposure parameters and the driving intensity of each illumination zone constant, repeated exposures are performed under directional illumination and verification illumination. The same connected region is extracted using the method described above, and its geometric center is recorded. The average position of these geometric centers is calculated for each illumination condition. The deviation of each geometric center from this average position is decomposed into the normal and tangential directions of the common boundary, and the maximum absolute deviation in each direction is recorded. The sum of the maximum absolute deviations of the normal directions under both illumination conditions is used as the normal displacement threshold, and the sum of the maximum absolute deviations of the tangential directions is used as the tangential positioning error limit, both in pixels. The calibration results are used for verification under the same detection location, imaging resolution, exposure parameters, and illumination conditions. The two connected regions and the original common boundary are kept in the same image coordinate system. The displacement is obtained by subtracting the geometric center corresponding to the directional lighting from the geometric center corresponding to the verification lighting, and the displacement is decomposed into the normal direction and the tangential direction. When the absolute value of the normal component is greater than the normal displacement threshold and the absolute value of the tangential component is not greater than the tangential positioning error limit, it is determined that a position migration has occurred along the normal direction, and the intersection of the two connected regions with the original common boundary is checked respectively. The increase or decrease in brightness itself does not replace the position migration, and if only one of the two connected regions intersects with the common boundary, the verification condition is not met. When there are multiple connected regions, the same displacement and intersection judgment is performed on each pair, and different connected regions are not combined into a single geometric center. Figure 2 The negative branch indicates that the determination of the defective area is not maintained, and the conclusion that the workpiece as a whole is defect-free is not drawn.
[0047] In this embodiment, the verification targets areas already located by S4, but where surface reflection differences may still be confused with local shape anomalies. For example, if the same area remains brighter under two illuminations with only brightness increases or decreases, the initial determination of the azimuth distribution does not provide a basis for whether the brighter area migrates with the illumination tilt angle. The partition whose illumination azimuth is closest to the normal direction of the common boundary is selected, so that both illuminations correspond to the direction crossing the common boundary; the azimuth is kept the same while the tilt angle is reduced, so that the compared response changes correspond to the change in illumination tilt angle, without introducing a separate illumination azimuth rotation. For local shape anomalies near the common boundary where the surface orientation changes with lateral position, the tilt angle change alters the conditions for incident light to be reflected to the industrial camera at each location. A stronger response can shift from one location to another, manifested as the extracted connected region migrating along the normal direction of the common boundary; what migrates is the brighter connected region formed after the change in illumination conditions, not the metal attachment or defect itself. It is required that both connected regions intersect the original common boundary and that the two responses are associated with the same boundary; a brighter region that has moved to another location and detached from that boundary cannot satisfy the verification conditions. Compared to simply executing S1 to S4, the newly added criterion excludes cases where there is only an increase or decrease in brightness without the aforementioned positional migration, or where migration occurs but the two connected regions do not both intersect with the original common boundary. It does not involve repeatedly judging the reverse deviation of pixel groups. When the above spatial response conditions are met, the determination of the original defective region is maintained; regions where only the brightness changes at their original position are no longer retained due to existing judgments in S4. This effect is conditional on the local surface being able to form comparable connected regions under both illumination tilt angles, and does not imply that any shape anomaly will necessarily cause the aforementioned migration.
[0048] In one embodiment, the plurality of directional lighting zones constitute a first ring light source, and the plurality of composite lighting zones constitute a second ring light source. Both the first ring light source and the second ring light source are coaxially arranged with the optical axis of the industrial camera.
[0049] In this embodiment, the first annular light source is composed of directional illumination zones, and the second annular light source is composed of verification illumination zones, both sharing a common axis with the optical axis of the industrial camera. Each verification illumination zone remains in the same orientation as its corresponding directional illumination zone and maintains a small illumination tilt angle. After selecting a certain illumination orientation, it is possible to switch between the two annular light source zones corresponding to that orientation sequentially, without needing to change the metal attachment detection posture to obtain two illumination tilt angles. Figure 2 The verification relationship for the same common boundary remains unchanged.
[0050] The specific embodiments described above further illustrate the inventive purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, or improvements made by those skilled in the art within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for intelligent identification of defects in metal accessories, characterized in that, include: S1. Place the metal accessory to be tested in a light-shielded detection position, control multiple directional lighting zones that are set around the optical axis of the industrial camera and have the same illumination tilt angle relative to the bearing plane of the detection position, and illuminate them sequentially according to their respective illumination directions. During the illumination of each of the directional lighting zones, control the industrial camera to expose the same surface to be tested, and obtain an image sequence ordered according to the illumination directions. S2. Compare the grayscale response at the same pixel coordinates in the image sequence under each illumination orientation, take the illumination orientation corresponding to the peak grayscale response as the peak orientation of the pixel, and form an orientation distribution from the peak orientations of each pixel on the surface to be inspected. S3. Within a local area of the surface to be inspected, determine the continuous change trend caused by the change in surface shape based on the orientation distribution of the peripheral pixels of the local area, and determine the local normal fluctuation range based on the deviation of the peak orientation of the peripheral pixels from the continuous change trend; group the pixels whose peak orientation deviates from the continuous change trend beyond the local normal fluctuation range according to the deviation direction. S4. When the peak orientation of two adjacent groups of pixels is opposite to the deviation direction of the continuous change trend, and the two groups of pixels have a common boundary, the common boundary and the area on both sides are determined as the defect area of abnormal surface shape, and the position of the defect area on the metal accessory to be tested is output.
2. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, In S3, the peak orientation of each pixel is read along a closed path around the local region.
3. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, Before S2, multiple directional illumination zones are simultaneously lit to obtain a contour image of the surface to be inspected. The outer contour and internal structural boundary of the metal attachment are extracted from the contour image. In S3, boundary bands that connect with the outer contour or the internal structural boundary are excluded from the analysis range of the local area.
4. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, When the directional lighting zones described in S1 are lit sequentially, the exposure parameters of the industrial camera remain unchanged.
5. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, In S2, the maximum grayscale response and the second largest grayscale response of the same pixel in the image sequence are compared. When the difference between the two is greater than a preset grayscale difference threshold, the illumination orientation corresponding to the maximum grayscale response is determined as the peak orientation of the pixel.
6. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, After the local normal fluctuation range is initially determined, pixels whose peak orientation deviation continuously exceeds the local normal fluctuation range are removed from the pixels surrounding the local region.
7. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, When adjacent local regions form the common boundary, and the ends of the common boundary in different local regions are adjacent and the extension direction is continuous, and the peak orientation deviation direction of the pixels on both sides of the common boundary in different local regions is consistent, the common boundary in the adjacent local regions and the regions on both sides are merged into the same defect region.
8. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, When the metal accessory to be tested reaches the detection position, the directional lighting zones are controlled to light up sequentially, and the image sequence is acquired under the same detection posture.
9. The intelligent identification method for metal accessory defects according to claim 1, characterized in that, A verification lighting zone is set at the same location as each of the directional lighting zones, and the lighting tilt angle of the verification lighting zone relative to the bearing plane of the detection position is smaller than the lighting tilt angle of the corresponding directional lighting zone. For the defective area, select the directional lighting partition whose illumination orientation is closest to the normal direction of the common boundary and its corresponding core lighting partition, and control the directional lighting partition and the core lighting partition to be lit up sequentially. During the lighting of both, control the industrial camera to perform exposure, and determine the connected regions in the defective area that have increased gray level relative to the periphery of the defective area in the two exposure images respectively. The determination of the defective region is maintained only when the connected region corresponding to the verification lighting zone moves relative to the connected region corresponding to the directional lighting zone along the normal direction of the common boundary, and both connected regions intersect with the common boundary.
10. The intelligent identification method for metal accessory defects according to claim 9, characterized in that, The plurality of directional lighting zones constitute a first ring light source, and the plurality of composite lighting zones constitute a second ring light source. Both the first ring light source and the second ring light source are coaxially arranged with the optical axis of the industrial camera.
