A visual inspection method for precise hardware fittings for loading and unloading boxes
By employing visual inspection methods and utilizing edge detection and mean-shift clustering techniques, the hole defects on the surface of the hardware accessories of the loading and unloading box can be accurately identified. This solves the problem of low detection accuracy in existing technologies and improves the accuracy of detection and the stability of the loading and unloading box structure.
Patent Information
- Application Number
- CN202411762731.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2026-03-17
- Estimated Expiration
- 2044-12-03
AI Technical Summary
Existing technology cannot accurately detect surface defects such as holes in precision hardware components used in loading and unloading containers, resulting in low detection accuracy and affecting the stability of the container structure.
A visual inspection method is adopted to acquire images of the surface of the hardware accessories of the loading and unloading box, identify the hole area, use edge detection and Hough transform to obtain the edge area of the hole area, combine the angle and gray value of the pixel to perform mean drift clustering, adjust the drift vector, and obtain the defect probability of the hole area.
This improves the accuracy of defect detection in the hole area and ensures the stability of the loading and unloading container structure.
Smart Images

Figure CN120931548B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and more specifically to a visual inspection method for precision hardware accessories used in loading and unloading boxes. Background Technology
[0002] During general cargo shipping, handicrafts, electronic machinery, instrument parts, and other miscellaneous products are loaded into cargo containers to facilitate transportation. Meanwhile, to maintain the stability of the transported goods within the containers, various hardware fittings are used to support the container structure.
[0003] However, due to the complex processing of hardware components, defects such as holes and wear on their surfaces easily occur, leading to inconsistent quality and compromising the stability of the loading and unloading box structure. Furthermore, because hardware components vary in shape, the surface hole damage areas generated during processing exhibit irregular and random variations. These random hole damages significantly affect the efficiency of manual inspection of hardware components. Additionally, when using industrial CCD cameras to inspect surface hole wear defects in hardware components, the inability to accurately capture the defect areas results in frequent issues of low inspection accuracy for precision hardware components. Summary of the Invention
[0004] This invention provides a visual inspection method for precision hardware accessories used in loading and unloading boxes to solve existing problems.
[0005] The present invention provides a visual inspection method for precision hardware accessories used in loading and unloading boxes, which adopts the following technical solution:
[0006] This invention provides a visual inspection method for precision hardware components used in loading and unloading boxes, the method comprising the following steps:
[0007] Under a light source at a preset position, acquire the surface image of the loading and unloading box hardware accessories and the hole area in the surface image of the loading and unloading box hardware accessories. Record any hole area as the target area, and obtain the edge area of the target area through the edge line of the target area.
[0008] Based on the grayscale values of pixels in the edge region and the position of the light source, the first pixel, the second pixel, the ideal first pixel, and the ideal second pixel of the target region are obtained. The center of the target region is obtained. Based on the angle formed between the center of the target region, the first pixel, the second pixel, the ideal first pixel, and the ideal second pixel, the degree of angular difference of the target region is obtained.
[0009] The feature angle of a pixel is obtained based on any pixel in the edge region, the second feature point, and the center of the target region. The first and second pixels, or ideal first and ideal second pixels, are designated as the first and second feature points based on the magnitude of the angle difference. An angle-grayscale value sequence of the edge region is obtained starting from the second feature point and passing through the first feature point. Symmetrical pixels are obtained based on the feature angle of the pixel. Pixels at the same position in the target region are obtained based on the distance between the centroids of the target region and other hole regions. The anomaly degree of a pixel is obtained based on the grayscale value difference between the pixel in the target region and its corresponding symmetrical and at-position pixels. The angle-grayscale value sequence is mean-shifted, and the drift increment is obtained based on the anomaly degree of all pixels within the drift interval step before and after the mean shift. The drift vector is adjusted based on the drift increment mean-shift clustering algorithm to obtain the adjusted drift vector.
[0010] The adjusted drift vector is used to cluster the angle-grayscale value sequence to obtain data segments. The defect probability of the data segment is obtained based on the degree of abnormality of the corresponding pixel points of each element in the data segment and the fusion result of the grayscale value. The defect probability of the data segment is used to complete the visual inspection of the surface quality of the hardware accessories of the loading and unloading box.
[0011] Furthermore, the specific steps of acquiring the surface image of the loading and unloading box hardware accessories and the hole area in the surface image of the loading and unloading box hardware accessories under the light source at the preset position, recording any hole area as the target area, and acquiring the edge area of the target area through the edge line of the target area are as follows:
[0012] First, use an industrial camera and preset the light source position to obtain a surface image of the loading and unloading box hardware accessories, which is recorded as the surface image of the loading and unloading box hardware accessories.
[0013] Then, Canny edge detection is used to obtain the edge lines in the surface image of the loading and unloading box hardware accessories. The internal area surrounded by any edge line is recorded as a suspected area. The roundness of any suspected area is calculated. Suspected areas with roundness greater than the preset roundness threshold are recorded as hole areas. Any hole area is recorded as the target area.
[0014] Finally, the hyperparameters are extended outward from the edge line of the target region. The range of pixels will transform the edge of the target area into a width of [missing information]. The region of 100 pixels is denoted as the edge region of the target region.
[0015] Furthermore, the specific steps for obtaining the first pixel, second pixel, ideal first pixel, and ideal second pixel of the target region based on the grayscale value of the pixels in the edge region and the position of the light source are as follows:
[0016] Obtain the pixels corresponding to the maximum and minimum gray values in the edge region of the target region, and denote them as the first pixel and the second pixel of the target region, respectively.
[0017] The pixel with the largest and smallest gray value among the two pixels that intersect the edge region of the target region along the straight line where the center of gravity of the light source and the target region are located, and which are farthest from the center of gravity, are recorded as the ideal first pixel and the ideal second pixel of the target region, respectively.
[0018] Furthermore, the specific steps for obtaining the degree of angular difference in the target region based on the angle formed between the center of the target region, the first pixel, the second pixel, the ideal first pixel, and the ideal second pixel include the following:
[0019] The center of the target region is obtained by using Hough transform. The straight line between any pixel in the edge region and the center of the target region is recorded as the angle between the pixel. The angle between any two pixels in the clockwise direction is recorded as the relative angle between the two pixels.
[0020] The relative angle between the first pixel of the target area and the ideal first pixel is recorded as the first angle, and the relative angle between the second pixel of the target area and the ideal second pixel is recorded as the second angle.
[0021] The maximum value between the first angle and the second angle is recorded as the degree of angular difference in the target area.
[0022] Further, the specific steps of obtaining the feature angle of a pixel based on any pixel on the edge region, the second feature point, and the center of the target region, and recording the first pixel and the second pixel, or the ideal first pixel and the ideal second pixel, as the first feature point and the second feature point according to the degree of angle difference, and obtaining the angle-grayscale value sequence of the edge region starting from the second feature point and passing through the first feature point, are as follows:
[0023] First, when the degree of angular difference is greater than the preset threshold for angular difference, the ideal first pixel and the ideal second pixel are recorded as the first feature point and the second feature point of the target area, respectively; when the degree of angular difference is less than the preset threshold for angular difference, the first pixel and the second pixel are recorded as the first feature point and the second feature point of the target area, respectively.
[0024] Then, obtain the angle line formed between any pixel and the center of the target area, obtain the angle line formed between the second feature point and the center of the target area, and record the relative angle formed by the angle line of the pixel and the angle line of the second feature point as the feature angle of the corresponding pixel; starting from the second feature point, traverse the pixels on the edge area in a clockwise direction. The edge area is a circular area that returns to the second feature point after passing the first feature point. Record the gray value of each pixel in the edge area during the traversal. Record the sequence formed by the feature angles and gray values of all pixels as the angle-gray value sequence.
[0025] Each element in the angle-grayscale value sequence corresponds to an array, an array corresponds to a pixel in the edge region, and an array corresponds to a feature angle and the grayscale value of a pixel.
[0026] Furthermore, the specific steps of obtaining symmetrical pixels based on the feature angle of the pixel, and obtaining pixels at the same position in the target region based on the distance between the centroid of the target region where the pixel is located and other hole regions, are as follows:
[0027] Any pixel on the edge region is recorded as the target pixel, and the pixel corresponding to the feature angle that sums to the feature angle of the target pixel to 360° is recorded as the symmetrical pixel of the target pixel.
[0028] The closest Euclidean distance between the centroid and the target region Each hole region is denoted as a neighboring region of the target region. Pixels in the neighboring region that are at the same position as any pixel in the target region are denoted as pixels at the same position in the target region. These are the preset hyperparameters.
[0029] Furthermore, the specific steps for obtaining the degree of anomaly of a pixel based on the difference in grayscale values between the pixel in the target region and its corresponding symmetrical pixel and pixel at the same position are as follows:
[0030] The specific method for calculating the anomaly level of any pixel in the target region is as follows:
[0031]
[0032] in, Indicates the degree of abnormality of target pixels in the target region; This represents the grayscale value of the target pixel in the target region; This represents the grayscale value of the symmetrical pixel to the target pixel in the target region; The first pixel in the target region represents the target pixel. The grayscale values of pixels at the same location in a neighboring region; This indicates the number of neighboring regions of the target region.
[0033] Furthermore, the specific steps involved in performing mean shift on the angle-grayscale value sequence and obtaining the shift increment based on the degree of anomaly of all pixels within the shift interval step size before and after the mean shift are as follows:
[0034] Get the average value of the abnormality of all pixels within the drift interval step before each drift and record it as the first mean. Get the average value of the abnormality of all pixels within the interval step after each drift and record it as the second mean. Record the absolute value of the difference between the first mean and the second mean as the first absolute value. Record the ratio of the first absolute value to the first mean as the drift increment.
[0035] Furthermore, the specific steps for adjusting the drift vector based on the drift increment mean drift clustering algorithm to obtain the adjusted drift vector are as follows:
[0036]
[0037] in, Indicates the first The adjusted drift vector after mean shift; Indicates the first The drift vector of the second mean shift. Indicates the first The drift increment of the mean drift.
[0038] Furthermore, the specific steps involved in using the adjusted drift vector to cluster the angle-grayscale value sequence to obtain data segments, and obtaining the defect probability of the data segment based on the anomaly degree of the corresponding pixels of each element in the data segment and the fusion result of the grayscale values, are as follows:
[0039] First, obtain the pixel point corresponding to the largest feature angle and the pixel point corresponding to the smallest feature angle in any data segment, and denot them as the first feature pixel point and the second feature pixel point, respectively; obtain the relative angle between the first feature pixel point and the second feature pixel point and denot it as the feature angle of the corresponding data point; obtain the maximum gray value and the minimum gray value in any data segment.
[0040] Then, the specific calculation method for the defect probability of the data segment is as follows:
[0041]
[0042] in, The first part represents the target region. The probability of defects in each data segment; The first part represents the target region. The average anomaly level of all elements corresponding to pixels within a data segment; The first part represents the target region. The maximum grayscale value of each data segment; The first part represents the target region. The minimum grayscale value of each data segment; This represents the grayscale value of the first pixel in the target region. This represents the grayscale value of the second pixel in the target region. Indicates the first The feature angles of each data segment.
[0043] The beneficial effects of the technical solution of the present invention are as follows: By combining the pixel points in the edge region of each hole area in the surface image of the loading and unloading box hardware accessories with the angle and gray value of the pixel points, mean-shift clustering is performed on the formed angle-gray value sequence. The drift vector of the mean-shift clustering is adjusted by using the feature angle formed between the pixel points and the degree of anomaly. The clustering of the angle-gray value sequence is completed by using the adjusted drift vector, and several data segments corresponding to the hole area are obtained. The defect probability of the data segment is obtained according to the gray value change characteristics of the data segment. The defect detection is completed by using the defect probability, which greatly improves the accuracy of mean-shift clustering and further improves the accuracy of defect detection in the hole area. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart illustrating the steps of a visual inspection method for precision hardware accessories used in loading and unloading boxes according to the present invention.
[0046] Figure 2 The target area representing the hole. Detailed Implementation
[0047] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a visual inspection method for precision hardware fittings for loading and unloading boxes proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0049] The following description, in conjunction with the accompanying drawings, details a specific scheme for a visual inspection method for precision hardware accessories used in loading and unloading boxes provided by the present invention.
[0050] Please see Figure 1 The diagram illustrates a flowchart of a visual inspection method for precision hardware fittings used in loading and unloading boxes, according to an embodiment of the present invention. The method includes the following steps:
[0051] Step S001: Acquire an image of the surface of the loading and unloading box hardware accessories, and obtain the target area and the edge area of the target area in the image of the surface of the loading and unloading box hardware accessories.
[0052] In order to identify defects such as holes on the surface of the loading and unloading box hardware, this embodiment needs to first identify all the holes on the loading and unloading box hardware. Since the difference in gray values inside and outside the holes is relatively large, an edge detection algorithm is used to identify all the holes in the image.
[0053] Since the shape of holes in the hardware of loading and unloading boxes has industrial production standards, the holes that need to be identified are extracted by analyzing the contour shape of the edge detection results of the holes.
[0054] First, use an industrial camera and preset the light source position to obtain a surface image of the loading and unloading box hardware accessories, which is recorded as the surface image of the loading and unloading box hardware accessories.
[0055] Then, Canny edge detection is used to obtain the edge lines in the surface image of the loading and unloading box hardware accessories. The internal area surrounded by any edge line is recorded as a suspected area. The roundness of any suspected area is calculated. Suspected areas with roundness greater than the preset roundness threshold are recorded as hole areas. Any hole area is recorded as the target area.
[0056] It should be noted that the preset roundness threshold is 0.9 based on experience, and can be adjusted according to the actual situation. This embodiment does not impose a specific limitation.
[0057] Since edge detection typically results in an edge line one pixel wide, and since an edge line is usually a line segment formed by the pixel with the largest grayscale value difference from other pixels in its neighborhood, and such... Figure 2 The edge corresponding to the target area representing the hole shown is not a line segment formed by a single pixel, but an area of a certain width formed by multiple pixels, and the width of the area is usually 2-3 pixels.
[0058] Finally, the hyperparameters are extended outward from the edge line of the target region. The range of a pixel point is used to change the edge line of the target area into an area with a width of pixel points, which is denoted as the edge area of the target area;
[0059] In addition, preprocess the gray values of the pixel points in the edge area of the target area. Use the Hough transform to obtain the center of the edge area. Denote the line passing through the pixel point with the minimum gray value in the edge area and the center as the reference line, and denote the line passing through any pixel point in the edge area and the center as the special line of the pixel point. Denote the angle between the special line of any pixel point and the reference line in the clockwise direction as the special angle of the pixel point. When there are multiple pixel points with the same special angle, merge all the pixel points with the same special angle, and use the average gray value of all the pixel points with the same special angle as the gray value of the merged pixel point, so as to complete the preprocessing of the gray values of the pixel points in the edge area and ensure that multiple pixel points in one direction correspond to one gray value.
[0060] It should be noted that the hyperparameter is preset to be 2 according to experience, which can be adjusted according to the actual situation and is not specifically limited in this embodiment;
[0061] It should be noted that the Chinese name of the Hough transform is the Hough transform, and the Hough transform is an existing algorithm, so it will not be elaborated in this embodiment.
[0062] So far, the target area and the edge area of the target area in the surface image of the loading and unloading box hardware fittings are obtained.
[0063] Step S002: Obtain the angular difference degree of the target area according to the angle formed between the pixel points in the edge area and the center of the edge area.
[0064] If there are no defects in the target area, there will be a certain pattern in the edge area of the target area.
[0065] First, obtain the pixel points corresponding to the maximum gray value and the minimum gray value in the edge area of the target area, and denote them as the first pixel point and the second pixel point of the target area respectively.
[0066] When there are defects in the target area, due to the influence of the defects, the gray value distribution of the corresponding edge area of the target area causes the positions of the first pixel point and the second pixel point to be different from those when there are no defects in the target area. Therefore, in combination with the position of the light source, obtain the ideal first pixel point and the ideal second pixel point;
[0067] Then, obtain the pixel points with the maximum gray value and the minimum gray value among the two pixel points with the farthest distances from the centroid on both sides of the intersection of the line passing through the light source and the centroid of the target area and the edge area of the target area, and denote them as the ideal first pixel point and the ideal second pixel point of the target area respectively;
[0068] Finally, the center of the target region is obtained using Hough transform. The straight line between any pixel in the edge region and the center of the target region is recorded as the angle between the pixel. The angle between any two pixels in the clockwise direction is recorded as the relative angle between the two pixels. The degree of angular difference in the target region is obtained based on the relative angle. The specific calculation method is as follows:
[0069]
[0070] in, This represents the relative angle between the first pixel of the target region and the ideal first pixel. This represents the relative angle between the second pixel of the target region and the ideal second pixel. This indicates that the maximum value is retrieved.
[0071] pass The function obtains the relative angle with large differences to reflect the degree of difference in the gray values of pixels in the edge region in the distribution direction, that is, the degree of angular difference.
[0072] At this point, the degree of angular difference in the target area has been obtained.
[0073] Step S003: Obtain the first feature point and the second feature point according to the degree of angle difference; obtain the angle-gray value sequence according to the first feature point and the second feature point; and cluster the angle-gray value sequence to obtain several data segments.
[0074] Step (1): First, when the degree of angle difference is greater than the preset angle difference threshold, the ideal first pixel and the ideal second pixel are recorded as the first feature point and the second feature point of the target area, respectively; when the degree of angle difference is less than the preset angle difference threshold, the first pixel and the second pixel are recorded as the first feature point and the second feature point of the target area, respectively.
[0075] It should be noted that the first feature point corresponds to the ideal first pixel or the first pixel point, and the second feature point corresponds to the ideal second pixel or the second pixel point. That is, among the first feature point and the second feature point, the first feature point is the pixel point with the largest gray value, and the second feature point is the pixel point with the smallest gray value.
[0076] It should be noted that the preset threshold for the degree of angle difference is 0.1 based on experience, and can be adjusted according to the actual situation. This embodiment does not impose any specific limitations.
[0077] Then, since the gray values of pixels between two feature points on the edge of the target area gradually change according to a certain rule, the angle line formed between any pixel and the center of the target area is obtained, and the angle line formed between the second feature point and the center of the target area is obtained. The relative angle formed by the angle line of the pixel and the angle line of the second feature point is recorded as the feature angle of the corresponding pixel. Starting from the second feature point, the gray values of each pixel in the edge area are recorded in a clockwise direction after passing through the first feature point and returning to the second feature point. The sequence formed by the feature angles and gray values of all pixels is recorded as the angle-gray value sequence.
[0078] It should be noted that each element in the angle-grayscale value sequence corresponds to an array, an array corresponds to a pixel in the edge region, and an array corresponds to a relative angle and the grayscale value of a pixel.
[0079] Finally, a Cartesian coordinate system is constructed, with the relative angle as the horizontal axis and the gray value of the pixel as the vertical axis, to obtain the angle-gray value distribution curve.
[0080] If there are no defects in the target area, the angle-grayscale value distribution curve will first rise and then fall.
[0081] Step (2): When there is a defect in the target area, the defect will inevitably affect the illumination distribution on the edge area of the target area, that is, the defect will affect the gray distribution on the edge area.
[0082] On the edge of the target area where there are no defects, each pixel will have a symmetrical pixel on the other side of the straight line connecting the first feature point and the second feature point. That is, the gray values of the pixels and the symmetrical pixels are similar. At the same time, since the holes on the surface of the loading and unloading box hardware are usually close together and the positional change between holes that are close together is small, the difference in gray values between the pixels in the target area and the pixels at the same position in the corresponding areas of other holes in the target area is small.
[0083] First, any pixel on the edge region is designated as the target pixel. The pixel corresponding to the feature angles summing to the target pixel (360°) is designated as the symmetrical pixel of the target pixel. Then, the pixel with the closest Euclidean distance to the centroid of the target region is selected as the symmetrical pixel. Each hole region is denoted as a neighboring region of the target region. Pixels in the neighboring region that are at the same position as any pixel in the target region are denoted as pixels at the same position in the target region. These are preset hyperparameters;
[0084] It should be noted that hyperparameters are preset based on experience. The value is 3, which can be adjusted according to the actual situation. This embodiment does not impose a specific limitation.
[0085] Then, based on the grayscale difference between the target pixel and its corresponding symmetrical and in-situ pixels, the degree of anomaly of any pixel in the target region is obtained. The specific calculation method is as follows:
[0086]
[0087] in, Indicates the degree of abnormality of target pixels in the target region; This represents the grayscale value of the target pixel in the target region; This represents the grayscale value of the symmetrical pixel to the target pixel in the target region; The first pixel in the target region represents the target pixel. The grayscale values of pixels at the same location in a neighboring region; Indicates the number of neighboring regions of the target region;
[0088] The greater the degree of anomaly of any pixel in the target area, the more likely that the pixel is the pixel corresponding to the defect.
[0089] Step (3): If the target area has no defects, the change of the angle-grayscale value sequence corresponding to the edge area of the target area will have small fluctuations, and the overall fluctuation range will be within a certain range. However, if there are defects, the angle-grayscale value sequence corresponding to the edge area of the target area will have large fluctuations.
[0090] First, obtain the backward difference sequence of the grayscale value portion in the angle-grayscale value sequence, denoted as the grayscale difference sequence; in the grayscale difference sequence, at preset angle intervals... A seed point is set for the mean-shift clustering algorithm. This seed point serves as the initial center point for the mean-shift clustering algorithm. The shift interval step size of the mean-shift clustering algorithm is preset. The gray-level difference sequence is clustered using the mean-shift clustering algorithm to obtain the center point and mean-shift vector corresponding to multiple mean shifts during the mean-shift clustering process.
[0091] It should be noted that the angle is pre-set based on experience. The preset drift interval step size for the mean-shift clustering algorithm is 10°. The value is 3.
[0092] During the mean shift process, for each mean shift vector At this time, the angle corresponding to the center point is The drift vector of the center point after drifting based on the current drift vector is: At this time, the angle corresponding to the position of the center point is By comparing the average anomaly of pixels within the drift interval step size before and after drifting, the magnitude of the drift vector is modified to obtain the desired clustering result.
[0093] It should be noted that the backward difference corresponding to the backward difference sequence is calculated using existing methods, which will not be elaborated upon in this embodiment;
[0094] Get the average value of the abnormality of all pixels within the drift interval step before each drift and record it as the first mean. Get the average value of the abnormality of all pixels within the interval step after each drift and record it as the second mean. Record the absolute value of the difference between the first mean and the second mean as the first absolute value. Record the ratio of the first absolute value to the first mean as the drift increment.
[0095] Then, during the mean-shift clustering process on the angle-grayscale value sequence, the drift vector of the mean-shift clustering algorithm is adjusted using the feature angle and anomaly degree of the corresponding pixels of each element. The mean-shift clustering process involves multiple mean shifts to obtain the adjusted drift vector. The specific calculation method is as follows:
[0096]
[0097] in, Indicates the first The adjusted drift vector after mean shift; Indicates the first The drift vector of the second mean shift. This represents the drift increment.
[0098] Before and after mean shift, the smaller the difference in average anomaly of pixels within the region of the center point within the shift interval step, the more the data in the cluster obtained by clustering in the angle-gray value sequence belong to the same type of data. Therefore, increasing the shift vector makes it more likely that the same type of data will be clustered into one class.
[0099] Finally, after mean shifting the angle-grayscale value sequence corresponding to the edge region of the target area, several clusters are obtained, which divide the angle-grayscale value sequence into several segments. If any cluster is recorded as a data segment, then the target area corresponds to several data segments.
[0100] It should be noted that the mean-shift clustering algorithm is an existing algorithm, so it will not be described in detail in this embodiment.
[0101] It should be noted that since each element in the angle-grayscale value sequence corresponds to a pixel, after the angle-grayscale value sequence is divided into several data segments by several clusters, each element in the data segment still corresponds to a pixel.
[0102] At this point, the data segment has been obtained.
[0103] Step S004: Obtain the defect probability of the data segment based on the degree of abnormality and grayscale value of the pixels in the data segment, and use the defect probability of the data segment to complete the visual inspection of the surface quality of the hardware accessories of the loading and unloading box.
[0104] For several data segments corresponding to the edge region of the target area, when there is no defect in the target area, the numerical changes of each data segment are within a certain range; however, when there is a defect in the target area, due to the influence of the defect, the numerical changes in some data segments are abnormal.
[0105] First, obtain the pixel corresponding to the largest and smallest feature angles in any data segment, and denote them as the first feature pixel and the second feature pixel, respectively. Then, obtain the relative angle between the first and second feature pixels, denoted as the feature angle of the corresponding data point. Next, obtain the maximum and minimum grayscale values in any data segment. Finally, obtain the defect probability of the data segment, calculated as follows:
[0106]
[0107] in, The first part represents the target region. The probability of defects in each data segment; The first part represents the target region. The average anomaly level of all elements corresponding to pixels within a data segment; The first part represents the target region. The maximum grayscale value of each data segment; The first part represents the target region. The minimum grayscale value of each data segment; This represents the grayscale value of the first pixel in the target region. This represents the grayscale value of the second pixel in the target region. Indicates the first The characteristic angles of each data segment;
[0108] It should be noted that the 0.1 is used to avoid the denominator being 0 in the formula.
[0109] Indicates the first The rate of change of grayscale values in each data segment; This indicates the overall rate of change of gray values in the angle-gray value sequence corresponding to the edge region of the target area.
[0110] The greater the degree of abnormality of pixels in a data segment, the more likely it is to be a data segment affected by defects; the faster the rate of change of gray values in a data segment is relative to the overall rate of change of gray values in the corresponding angle-gray value sequence, and the larger the ratio between the two, the more likely the data segment is to be a data segment affected by defects.
[0111] Then, the defect probability of all data segments corresponding to all hole areas in the surface image of the loading and unloading box hardware accessories is linearly normalized to obtain the normalized defect probability of the data segment. The data segments with normalized defect probabilities greater than the preset probability threshold are recorded as defect data segments, and the hole areas containing defect data segments are recorded as defect hole areas. The defect hole areas are marked in the surface image of the loading and unloading box hardware accessories to realize the visualization of detection.
[0112] It should be noted that the preset probability threshold is 0.8 based on experience, but it can be adjusted according to the actual situation. This embodiment does not impose any specific limitations.
[0113] 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 spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method of visually inspecting precision hardware fittings for a container handling box, characterized by, The method comprises the following steps: Obtaining the surface image of the loading and unloading box hardware fittings and the hole region in the surface image of the loading and unloading box hardware fittings under a light source at a preset position, recording any hole region as a target region, and obtaining the edge region of the target region through the edge line of the target region; According to the size of the pixel gray value in the edge region and the position of the light source, the first pixel point, the second pixel point, the ideal first pixel point and the ideal second pixel point of the target region are obtained, the center of the target region is obtained, and the angle difference degree of the target region is obtained according to the included angle formed between the center of the target region, the first pixel point, the second pixel point, the ideal first pixel point and the ideal second pixel point; According to the feature angle of the pixel point, the first pixel point and the second pixel point, or the ideal first pixel point and the ideal second pixel point are recorded as the first feature point and the second feature point according to the size of the angle difference degree, the angle-gray value sequence of the edge region is obtained through the first feature point with the second feature point as the starting point, the symmetric pixel point of the pixel point is obtained according to the feature angle of the pixel point, the same position pixel point of the pixel point in the target region is obtained according to the distance between the target region and the centroid of other hole regions, the abnormal degree of the pixel point is obtained according to the gray value difference between the pixel point and the corresponding symmetric pixel point and the same position pixel point, the mean shift of the angle-gray value sequence is performed, the drift increment is obtained according to the abnormal degree of all pixel points in the drift interval step range before and after the mean shift, the drift vector of the mean shift clustering algorithm is adjusted according to the drift increment, and the adjusted drift vector is obtained. The data segment is obtained by using the adjusted drift vector to complete the clustering of the angle-gray value sequence, the defect probability of the data segment is obtained according to the fusion result of the abnormal degree and the gray value of the corresponding pixel point in each element in the data segment, and the surface quality visual detection of the loading and unloading box hardware fittings is completed by using the defect probability of the data segment.
2. The visual inspection method of the precise hardware fittings for the container handling according to claim 1, characterized in that, The method comprises the following steps: Firstly, the surface image of the loading and unloading box hardware fittings is obtained by using an industrial camera and presetting the position of the light source, and is recorded as the surface image of the loading and unloading box hardware fittings; Then, the edge line in the surface image of the loading and unloading box hardware fittings is obtained by using Canny edge detection, any internal region surrounded by the edge line is recorded as a suspected region, the circularity of any suspected region is calculated, the suspected region with a circularity greater than a preset circularity threshold is recorded as a hole region, and any hole region is recorded as a target region. Finally, the hyperparameters are extended outward from the edge line of the target region The edge line of the target region is changed to a region with a width of pixels, and is recorded as the edge region of the target region.
3. The method of claim 1, wherein the method is a method of inspecting a precise hardware fitting for a container handling machine. The first pixel point, the second pixel point, the ideal first pixel point and the ideal second pixel point of the target region are obtained according to the size of the pixel gray value in the edge region and the position of the light source, and the specific steps include the following: Obtaining the maximum and minimum gray scale value corresponding to the pixel points in the edge region of the target region, and recording them as the first and second pixel points of the target region respectively; Obtaining the maximum and minimum gray scale value corresponding to the pixel points in the edge region of the target region, and recording them as the first and second pixel points of the target region respectively; 4. The method of claim 1, wherein the method is a method of inspecting a precise hardware fitting for a container handling machine. The specific steps of obtaining the angle difference degree of the target region according to the included angle formed between the center of the target region, the first pixel point, the second pixel point, the ideal first pixel point and the ideal second pixel point are as follows: Obtaining the center of the target region by Hough transformation, recording the straight line between the center of the target region and any pixel point in the edge region as the included angle line of the pixel point, and recording the included angle of the included angle lines of any two pixel points in the clockwise direction as the relative included angle of the two pixel points; Obtaining the relative included angle between the first pixel point and the ideal first pixel point of the target region as the first angle, and the relative included angle between the second pixel point and the ideal second pixel point of the target region as the second angle; Recording the maximum value of the first angle and the second angle as the angle difference degree of the target region.
5. The method of claim 4, wherein the method is a method of visually inspecting a precision hardware fitting for a container handling machine, characterized in that, The specific steps of obtaining the angle difference degree of the target region according to the included angle formed between the center of the target region, the first pixel point, the second pixel point, the ideal first pixel point and the ideal second pixel point are as follows: First, when the angle difference degree is greater than the preset angle difference degree threshold, the ideal first pixel point and the ideal second pixel point are recorded as the first and second feature points of the target region respectively; When the angle difference degree is less than the preset angle difference degree threshold, the first and second pixel points are recorded as the first and second feature points of the target region respectively; Then, obtaining the included angle line formed between any pixel point and the center of the target region, obtaining the included angle line formed between the second feature point and the center of the target region, recording the relative included angle formed between the included angle line of the pixel point and the included angle line of the second feature point as the feature included angle of the corresponding pixel point; traversing the pixel points on the edge region from the second feature point as the starting point in the clockwise direction, the edge region being a ring region, returning to the second feature point after passing through the first feature point, recording the gray scale values of the pixel points in the edge region in the traversal process, and recording the sequence formed by the feature included angles and the gray scale values of all the pixel points as the angle-gray scale value sequence; Each element in the angle-gray scale value sequence corresponds to an array, and an array corresponds to a pixel point in the edge region, and an array corresponds to a feature included angle and a gray scale value of a pixel point.
6. The method of claim 5, wherein the method is a method of visually inspecting a precision hardware fitting for a container handling machine, characterized in that, The specific steps of obtaining the symmetric pixel point of the pixel point according to the feature included angle of the pixel point, and obtaining the same position pixel point of the pixel point in the target region according to the distance between the center of the target region and the center of other hole regions are as follows: An arbitrary pixel point on the edge region is recorded as a target pixel point, and a pixel point corresponding to a feature angle of 360° with the target pixel point is recorded as a symmetric pixel point of the target pixel point; The closest Euclidean distance between the centroid and the target region Each hole region is denoted as a neighboring region of the target region. Pixels in the neighboring region that are at the same position as any pixel in the target region are denoted as pixels at the same position in the target region. These are the preset hyperparameters.
7. The method of claim 6, wherein the method is a method of visually inspecting a precision hardware fitting for a container handling machine, characterized in that, The specific steps of obtaining the abnormal degree of the pixel point according to the gray value difference between the pixel point and the corresponding symmetric pixel point and the same position pixel point in the target region are as follows: The specific calculation method of the abnormal degree of an arbitrary pixel point in the target region is as follows: wherein, represents an abnormality degree of the target pixel point in the target region; represents a gray value of the target pixel point in the target region; represents a gray value of a symmetric pixel point of the target pixel point in the target region; represents a gray value of a pixel point at the same position in the th neighboring region of the target region where the target pixel point is located; represents a number of the neighboring regions of the target region.
8. The method of claim 1, wherein the method is a method of inspecting a precise hardware fitting for a container handling machine. The specific steps of performing mean shift on the angle-gray value sequence and obtaining a drift increment according to the abnormal degrees of all pixel points in the drift interval step range before and after the mean shift are as follows: The average value of the abnormal degrees of all pixel points in the drift interval step range before each drift is obtained and recorded as a first mean value, the average value of the abnormal degrees of all pixel points in the interval step range after each drift is obtained and recorded as a second mean value, the absolute value of the difference between the first mean value and the second mean value is recorded as a first absolute value, and the ratio of the first absolute value to the first mean value is recorded as the drift increment.
9. The method of claim 1, wherein the method is a method of inspecting a precise hardware fitting for a container handling machine. The specific steps of adjusting the drift vector according to the mean shift clustering algorithm of the drift increment to obtain an adjusted drift vector are as follows: in, Indicates the first The adjusted drift vector after mean shift; Indicates the first The drift vector of the second mean shift. Indicates the first The drift increment of the mean drift.
10. The method of claim 1, wherein the method is a method of visually inspecting a precision hardware fitting for a container handling machine, characterized in that, The specific steps of obtaining the defect probability of the data segment according to the fusion result of the abnormal degree and the gray value of the corresponding pixel point of each element in the data segment after completing the clustering of the angle-gray value sequence by using the adjusted drift vector are as follows: Firstly, the pixel point corresponding to the maximum feature angle and the pixel point corresponding to the minimum feature angle in any data segment are obtained and recorded as a first feature pixel point and a second feature pixel point respectively, the relative angle between the first feature pixel point and the second feature pixel point is recorded as the feature angle of the corresponding data point, and the maximum gray value and the minimum gray value in any data segment are obtained; Then, the specific calculation method of the defect probability of the data segment is as follows: in, The first part represents the target region. The probability of defects in each data segment; The first part represents the target region. The average anomaly level of all elements corresponding to pixels within a data segment; The first part represents the target region. The maximum grayscale value of each data segment; The first part represents the target region. The minimum grayscale value of each data segment; This represents the grayscale value of the first pixel in the target region. This represents the grayscale value of the second pixel in the target region. Indicates the first The feature angles of each data segment.
Citation Information
Patent Citations
Adaptive electrical equipment fault detection method based on Meanshift
CN107292882A
Image denoising with information-theoretic, adaptive filtering
WO2006050364A2