A method for automatically detecting the appearance quality of a plastic shell
By analyzing the curvature and direction abnormality of edge pixel points in the plastic shell image, combined with Canny edge detection, the problem of Canny algorithm being sensitive to slight changes is solved, and the accuracy of burrs detection of plastic shells and appearance quality detection results are improved .
Patent Information
- Application Number
- CN202410507809.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-25
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-04-25
AI Technical Summary
The existing Canny edge detection algorithm is allergic to slight changes when detecting burly defects of plastic shells, resulting in a high false detection rate and reducing the accuracy of appearance quality detection.
By acquiring plastic shell images for edge detection, calculate the curvature size and direction of each edge pixel point, segment the edge lines, analyze the curvature size and direction abnormal performance, adjust the gradient vector, and combine Canny edge detection to improve detection accuracy.
Effectively suppress the detection of non-burnt edge pixel points, improve the accuracy of burnt defect detection, and improve the accuracy of plastic shell appearance quality detection.
Smart Images

Figure CN118279285B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an automatic detection method for the appearance quality of a plastic shell. Background Art
[0002] Plastic housings usually refer to housings or housing parts made of plastic materials, which are used to wrap and protect the external structure of electronic equipment, home appliances, mechanical equipment and other products. During the production process of plastic housings, due to mold wear and uneven cooling, burrs may appear on the edges of the plastic housings, reducing the appearance quality of the plastic housings and the durability of the products. Therefore, burr defects need to be detected on the plastic housings before leaving the factory.
[0003] Currently, the Canny edge detection algorithm is commonly used to detect burr defects in plastic shells. However, during the detection process, since the Canny edge detection is very sensitive to small changes, when detecting pixels in the burr area, many non-burr edges may be detected, thereby increasing the false detection rate of burr detection and reducing the accuracy of the appearance quality detection of the plastic shell. Summary of the invention
[0004] The invention provides an automatic detection method for the appearance quality of a plastic shell to solve the existing problems.
[0005] The present invention provides an automated method for detecting the appearance quality of a plastic housing using the following technical solutions:
[0006] An embodiment of the present invention provides an automatic detection method for the appearance quality of a plastic housing, the method comprising the following steps:
[0007] Acquire a plastic shell image; perform edge detection on the plastic shell image to obtain a plurality of edge lines; the edge lines include a plurality of edge pixel points;
[0008] Obtain the curvature magnitude, curvature direction and gradient vector of each edge pixel point; obtain the horizontal axis gradient component and the vertical axis gradient component of each edge pixel point according to the curvature direction and gradient vector of each edge pixel point on each edge line;
[0009] The edge line is divided into a plurality of updated edge lines; the updated edge lines include a plurality of updated edge pixel points; according to the change of the curvature size of each updated edge pixel point, the abnormal performance of the curvature size of each edge pixel point is obtained; according to the abnormal performance of the curvature size of the edge pixel point and the horizontal axis gradient component, the updated horizontal axis gradient component of each edge pixel point is obtained;
[0010] According to the difference in grayscale values between each updated edge pixel and the surrounding pixels on each updated edge line, the curvature direction abnormal performance of each edge pixel is obtained; according to the longitudinal axis gradient component of the edge pixel and the curvature direction abnormal performance, the updated longitudinal axis gradient component of each edge pixel is obtained;
[0011] According to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel, an updated gradient vector of each edge pixel is obtained; according to the updated gradient vectors of all edge pixels, an appearance detection result of the plastic shell is obtained.
[0012] Furthermore, the step of obtaining the horizontal axis gradient component and the vertical axis gradient component of each edge pixel point according to the curvature direction and the gradient vector of each edge pixel point on each edge line includes the following specific steps:
[0013] A two-dimensional rectangular coordinate system is established with any edge pixel point as the origin, the curvature direction of the edge pixel point as the horizontal axis, and the vertical direction of the curvature direction of the edge pixel point as the vertical axis; the gradient vector of the edge pixel point is projected onto the horizontal axis and the vertical axis of the two-dimensional rectangular coordinate system respectively to obtain the horizontal axis gradient component and the vertical axis gradient component of the edge pixel point.
[0014] Furthermore, the step of dividing the edge line into a plurality of updated edge lines includes the following specific steps:
[0015] Corner detection algorithm is used to detect corners of the plastic shell image to obtain several corner points; for any corner point, if there are no other corner points in a window with a side length of S constructed with the corner point as the center, the corner point is recorded as a target corner point; the edge pixel point with the closest Euclidean distance to any target corner point is recorded as a segmentation point; each edge line in the plastic shell image is segmented into several updated edge lines based on the segmentation point.
[0016] Furthermore, the abnormal performance of the curvature size of each edge pixel point is obtained according to the change of the curvature size of each updated edge pixel point, and the specific steps include the following:
[0017] For any updated edge line, any endpoint pixel point of the updated edge line is selected and recorded as the initial pixel point, and the other endpoint pixel point of the updated edge line is recorded as the termination pixel point; the length of each updated edge pixel point on the updated edge line from the initial pixel point along the updated edge line is taken as the horizontal coordinate, and the curvature size of each updated edge pixel point on the updated edge line is taken as the vertical coordinate, a curvature rectangular coordinate system is established, and each updated edge pixel point on the updated edge line is mapped to the curvature rectangular coordinate system to obtain a number of data points in the curvature rectangular coordinate system;
[0018] Obtaining a first abnormality degree of each updated edge pixel point according to a plurality of data points in a rectangular coordinate system of a curvature of the updated edge line;
[0019] According to the curvature size and the first abnormality degree of each updated edge pixel point, the curvature size abnormality performance of each updated edge pixel point is obtained; the updated edge pixel points correspond to the edge pixel points to obtain the curvature size abnormality performance of each edge pixel point.
[0020] Furthermore, the step of obtaining the first abnormality degree of each updated edge pixel point according to a plurality of data points in the curvature rectangular coordinate system of the updated edge line includes the following specific steps:
[0021] In the curvature rectangular coordinate system of the updated edge line, a curvature prediction curve is obtained by least square fitting based on all data points; for any updated edge pixel point on the updated edge line, a corresponding value of the length of the updated edge pixel point from the initial pixel point along the updated edge line on the curvature prediction curve is recorded as the predicted curvature of the updated edge pixel point, and a normalized result of the absolute value of the difference between the curvature of the updated edge pixel point and the predicted curvature is recorded as the first abnormality degree of the updated edge pixel point.
[0022] Furthermore, the method of obtaining the abnormal performance of the curvature size of each updated edge pixel point according to the curvature size of each updated edge pixel point and the first abnormality degree includes the following specific steps:
[0023] On any updated edge line, with any updated edge pixel as the center, a one-dimensional window of length Q is constructed along the updated edge line, where Q is a preset length; on the updated edge line, the calculation method of the curvature size abnormality of the jth updated edge pixel is as follows:
[0024]
[0025] Where P j The curvature of the jth updated edge pixel is abnormal; R j Q is the variance of the curvature of all updated edge pixels in the one-dimensional window of the jth updated edge pixel; j The number of edge pixels updated in the one-dimensional window for the jth updated edge pixel; d j,w is the length of the updated edge line between the jth updated edge pixel and the wth updated edge pixel in its one-dimensional window; P j ′ ,w is the first abnormality degree of the wth updated edge pixel in the one-dimensional window of the jth updated edge pixel; norm() is the normalization function.
[0026] Furthermore, the abnormal curvature direction performance of each edge pixel is obtained according to the difference in grayscale values between each updated edge pixel and the surrounding pixels on each updated edge line, and the specific steps include the following:
[0027] In the plastic shell image, for any updated edge pixel point on any updated edge line, L pixels are respectively obtained along the horizontal axis direction and the reverse direction of the horizontal axis of the two-dimensional rectangular coordinate system of the updated edge pixel point, and are respectively recorded as the first reference pixel set and the second reference pixel set of the updated edge pixel point; wherein L is a preset reference pixel length; the average grayscale value of all pixel points in the first reference pixel set of any updated edge pixel point on the updated edge line is recorded as the initial standard grayscale of the updated edge pixel point; the average of the initial standard grayscales of all updated edge pixels on the updated edge line is recorded as the first standard grayscale of the updated edge line;
[0028] According to the first reference pixel set, the second reference pixel set and the first standard grayscale of the updated edge line of the updated edge pixel point, the abnormal performance of the curvature direction of the updated edge pixel point is obtained; the updated edge pixel point corresponds to the edge pixel point to obtain the abnormal performance of the curvature direction of each edge pixel point.
[0029] Furthermore, the abnormal performance of the curvature direction of the updated edge pixel point is obtained according to the first reference pixel set, the second reference pixel set, and the first standard grayscale of the updated edge line, and the specific steps include the following:
[0030] The absolute value of the difference between the initial standard grayscale of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the first distance of the updated edge pixel point, and the absolute value of the difference between the mean grayscale value of all pixels in the second reference pixel set of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the second distance of the updated edge pixel point; if the first distance of the updated edge pixel point is less than or equal to the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 0; if the first distance of the updated edge pixel point is greater than the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 1.
[0031] Furthermore, the step of obtaining the updated gradient vector of each edge pixel point according to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel point includes the following specific steps:
[0032] For any edge pixel point in the plastic shell image, the vector sum of the updated horizontal axis gradient component and the updated vertical axis gradient component of the edge pixel point is used as the updated gradient vector of the edge pixel point.
[0033] Furthermore, the updated gradient vectors of all edge pixels are used to obtain the appearance detection result of the plastic shell, and the specific steps include the following:
[0034] Based on the updated gradient vector of each edge pixel point, the double threshold of Canny edge detection is performed to determine the edge, and the burr edge pixel point is obtained; the curve composed of a number of continuous burr edge pixel points is recorded as a burr curve; if the number of pixels of any burr curve is greater than or equal to the preset number threshold V, the appearance quality inspection result of the plastic shell is unqualified; if the number of pixels of all burr curves is less than the preset number threshold V, the appearance quality inspection result of the plastic shell is qualified.
[0035] The beneficial effects of the technical solution of the present invention are as follows: the present invention predicts the curvature size of the edge pixel points of the plastic shell by combining the irregular change of the curvature size of the burr of the plastic shell and the straight or smooth characteristics of the normal edge of the plastic shell, and combines the distribution and aggregation characteristics of the edge pixel points corresponding to the burr to analyze and obtain the abnormal performance of the curvature size of each edge pixel point, and judge the possibility that each edge pixel point is a burr edge pixel point; the concave area of the burr interferes with the defect detection of the burr, and the abnormal performance of the curvature direction is obtained by the grayscale change of the surrounding pixels of the edge pixel point in the curvature direction; according to the abnormal performance of the curvature size and the abnormal performance of the curvature direction, the gradient vector of the edge pixel point is adjusted, and the non-burr edge pixel points are suppressed during the Canny edge detection process, thereby improving the accuracy of the burr defect detection, and thereby improving the accuracy of the appearance quality inspection result of the plastic shell. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 The present invention is a flowchart of the steps of an automated method for detecting the appearance quality of a plastic housing. DETAILED DESCRIPTION
[0038] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, features and effects of an automatic detection method for the appearance quality of a plastic shell proposed by the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0039] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0040] The specific scheme of the automatic detection method for the appearance quality of a plastic housing provided by the present invention is described in detail below with reference to the accompanying drawings.
[0041] See also Figure 1 , which shows a flowchart of a method for automatically detecting the appearance quality of a plastic housing provided by an embodiment of the present invention, the method comprising the following steps:
[0042] Step S001: Acquire a plastic shell image; perform edge detection on the plastic shell image to obtain a plurality of edge lines.
[0043] The purpose of this embodiment is to detect burr defects of a plastic housing. The burr defects of a plastic housing generally exist at the edge of the plastic housing, so it is necessary to collect edge images of the plastic housing.
[0044] Specifically, a blue collection background is arranged in the area to be detected, and the plastic shell is placed in the area to be detected. The plastic shell is photographed from multiple angles using an industrial camera to obtain several original RGB images of the plastic shell; the original RGB image of the plastic shell is grayscaled to obtain an original grayscale image of the plastic shell; any original grayscale image of the plastic shell is recorded as a plastic shell image. The Canny edge detection algorithm is used on the plastic shell image to obtain several edge lines in the plastic shell image, and the edge lines contain several edge pixels; grayscale and Canny edge detection algorithm are well-known technologies, and the specific methods are not introduced here.
[0045] Step S002: Obtain the curvature size, curvature direction and gradient vector of each edge pixel; obtain the horizontal axis gradient component and the vertical axis gradient component of each edge pixel according to the curvature direction and gradient vector of each edge pixel on each edge line.
[0046] It should be noted that in the collected plastic shell image, the overall color of the plastic shell is consistent, and the grayscale difference between the plastic shell and the blue collection background is large, so several edge lines detected in the plastic shell image include the non-burr edge of the plastic shell and the possible burr edge. The burr defect of the plastic shell is mainly judged based on the distribution of burr edge pixel points, so it is necessary to adjust the gradient value of the non-burr edge pixel points during edge detection to achieve the purpose of suppressing the non-burr edge pixel points.
[0047] It should be further explained that the main difference between a burr edge and a non-burr edge is the change in the size of the curvature and the change in the direction of the curvature, so the gradient of the edge pixel points in the plastic shell image is adjusted to suppress the non-burr edge pixel points; since the curvature direction is close to the gradient direction of the edge pixel points, the projection component of the gradient of the edge pixel points in the curvature direction is larger, while the projection component in the direction perpendicular to the curvature direction is smaller; and since the change in the size of the curvature has a greater impact on the judgment of the burr edge pixel points, while the curvature direction has a smaller impact on the judgment of the burr edge pixel points, the change in the size of the curvature of the edge pixel points is used to adjust the projection component of the edge pixel points in the curvature direction, and the curvature direction is used to adjust the projection component of the edge pixel points in the direction perpendicular to the curvature direction.
[0048] Specifically, a 3×3 Sobel operator is used to obtain the gradient vector of each edge pixel point; for any edge pixel point, the curvature size and the center of the curvature circle of the edge pixel point are obtained, and the direction from the edge pixel point to the center of the curvature circle is recorded as the curvature direction of the edge pixel point; a two-dimensional rectangular coordinate system is established with the edge pixel point as the origin, the curvature direction of the edge pixel point as the horizontal axis, and the vertical direction of the curvature direction of the edge pixel point as the vertical axis; the gradient vector of the edge pixel point is projected onto the horizontal axis and the vertical axis of the two-dimensional rectangular coordinate system respectively to obtain the horizontal axis gradient component and the vertical axis gradient component of the edge pixel point, and both the horizontal axis gradient component and the vertical axis gradient component are vectors; the method of obtaining the curvature size and curvature direction of the edge pixel point and calculating the gradient by the Sobel operator are well-known technologies, and the specific method will not be introduced here.
[0049] Step S003: dividing the edge line into a number of updated edge lines; obtaining the abnormal curvature performance of each edge pixel according to the change of the curvature size of each updated edge pixel; obtaining the updated horizontal axis gradient component of each edge pixel according to the abnormal curvature size performance of the edge pixel and the horizontal axis gradient component.
[0050] It should be noted that the single edge line of the plastic shell is relatively straight or smooth, that is, the normal edge in the plastic shell image tends to be a straight line, or the curvature of the normal edge pixel shows a gradual trend, while the curvature of the burr edge pixel shows an irregular trend, and compared with the normal edge pixel of the plastic shell, the burr edge pixel of the plastic shell accounts for a smaller proportion of all edge pixel points, so the curvature of each edge pixel is predicted based on this, and the difference between the predicted curvature and the actual curvature is used to determine the possibility that the edge pixel is a burr edge pixel.
[0051] Specifically, a corner point detection algorithm is used to detect corner points of the plastic shell image to obtain a number of corner points; corner point detection is a well-known technology, and the specific method is not introduced here; for any corner point, if there are no other corner points in a window with a side length of S constructed with the corner point as the center, the corner point is recorded as a target corner point; S is a preset window side length, S=5, and this embodiment is described as an example; the edge pixel point with the closest Euclidean distance to any target corner point is recorded as a segmentation point; based on the segmentation point, each edge line in the plastic shell image is divided into a number of updated edge lines, and the updated edge line contains a number of updated edge pixel points; for any updated edge line, any endpoint pixel point of the updated edge line is selected and recorded as the initial pixel point, and the other endpoint pixel point of the updated edge line is recorded as the termination pixel point; the length of each updated edge pixel point on the updated edge line from the initial pixel point along the updated edge line is taken as the horizontal coordinate, and each updated edge pixel point on the updated edge line is The curvature of the edge pixel point is used as the ordinate, a curvature rectangular coordinate system is established, and each updated edge pixel point on the updated edge line is mapped to the curvature rectangular coordinate system to obtain a number of data points in the curvature rectangular coordinate system, and each data point corresponds to an updated edge pixel point; in the curvature rectangular coordinate system, a curvature prediction curve is obtained by fitting based on all data points by the least squares method; the least squares method is a well-known technology, and the specific method is not introduced here; for any updated edge pixel point on the updated edge line, the corresponding value of the length of the updated edge pixel point from the initial pixel point along the updated edge line on the curvature prediction curve is recorded as the predicted curvature of the updated edge pixel point, and the normalized result of the absolute value of the difference between the curvature of the updated edge pixel point and the predicted curvature is recorded as the first abnormality degree of the updated edge pixel point. The normalization method adopts the linear normalization method, and the normalization object is the absolute value of the difference between the curvature of all updated edge pixels on all updated edge lines and the predicted curvature.
[0052] It should be noted that the burrs are relatively small and clustered, and the curvature of the edge pixels around the burr edge pixels varies greatly, so this is used to further judge the possibility that the edge pixel is a burr edge pixel; and then the projection component of the edge pixel in the curvature direction is adjusted.
[0053] Further, on any updated edge line, with any updated edge pixel point as the center, a one-dimensional window with a length of Q is constructed along the updated edge line, where Q is a preset length. This embodiment is described by taking Q=10 as an example, and other values may be set in other embodiments, which are not specifically limited in this embodiment. It should be noted that if the number of updated edge pixels in the one-dimensional window with any pixel point as the center is less than Q, only the window formed by the existing updated edge pixels is recorded as the one-dimensional window of the updated edge pixel point. On the updated edge line, the calculation method of the abnormal performance of the curvature size of the j-th updated edge pixel point is:
[0054]
[0055] Where P j The curvature of the jth updated edge pixel is abnormal; R j Q is the variance of the curvature of all updated edge pixels in the one-dimensional window of the jth updated edge pixel; j The number of edge pixels updated in the one-dimensional window for the jth updated edge pixel; d j,w is the length of the updated edge line between the jth updated edge pixel and the wth updated edge pixel in its one-dimensional window; P j ′ ,w is the first abnormality degree of the wth updated edge pixel in the one-dimensional window of the jth updated edge pixel; norm() is a linear normalization function, and the normalization object is the normalization value of all updated edge pixels on all updated edge lines.
[0056] It should be noted that Indicates the degree of abnormal aggregation at the jth updated edge pixel point. The larger its value is, the higher the degree of aggregation of abnormal updated edge pixels near the jth updated edge pixel point is, and the jth updated edge pixel point is more likely to be a burr edge pixel point. j The larger the value of , the greater the change in the curvature size near the j-th updated edge pixel point. The more likely it is that there are burr edge pixels in the one-dimensional window of the j-th updated edge pixel point, and the higher the credibility of the abnormal aggregation degree at the j-th updated edge pixel point.
[0057] Furthermore, since each edge pixel is an updated edge pixel on the corresponding updated edge line, the curvature size abnormality of each edge pixel is obtained, and the product of the curvature size abnormality of any edge pixel and the horizontal axis gradient component of the edge pixel is calculated and recorded as the updated horizontal axis gradient component of the edge pixel.
[0058] Step S004: According to the difference in grayscale values between each updated edge pixel and the surrounding pixels on each updated edge line, the curvature direction abnormal performance of each edge pixel is obtained; according to the longitudinal axis gradient component of the edge pixel and the curvature direction abnormal performance, the updated longitudinal axis gradient component of each edge pixel is obtained.
[0059] It should be noted that the burr of the plastic shell presents a continuous convex shape compared to the normal edge, and there will be a relatively concave area between the two convexities. The curvature of the edge pixels of the concave area may be similar to the curvature of the normal edge pixels, resulting in a smaller abnormal aggregation degree of the burr edge pixels, affecting the detection of the burr edge pixels; however, the curvature direction of the edge pixels of the concave area is opposite to the curvature direction of the normal edge pixels, so the projection component of the edge pixels in the direction perpendicular to the curvature direction is adjusted accordingly.
[0060] Specifically, in the plastic shell image, for any updated edge pixel point on any updated edge line, L pixels are obtained along the horizontal axis direction and the reverse direction of the horizontal axis of the two-dimensional rectangular coordinate system of the updated edge pixel point, respectively, and are recorded as the first reference pixel set and the second reference pixel set of the updated edge pixel point; wherein L is the preset reference pixel length, L=5, and this embodiment is described as an example; the average grayscale value of all pixels in the first reference pixel set of any updated edge pixel point on the updated edge line is recorded as the initial standard grayscale of the updated edge pixel point; the average initial standard grayscale of all updated edge pixels on the updated edge line is recorded as the first standard grayscale of the updated edge line; in particular, if a certain updated edge pixel point cannot obtain enough The first reference pixel set or the second reference pixel set is constructed by using pixel points that actually exist; for any updated edge pixel point on the updated edge line, the absolute value of the difference between the initial standard grayscale of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the first distance of the updated edge pixel point, and the absolute value of the difference between the mean grayscale value of all pixels in the second reference pixel set of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the second distance of the updated edge pixel point; if the first distance of the updated edge pixel point is less than or equal to the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 0; if the first distance of the updated edge pixel point is greater than the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 1.
[0061] Furthermore, since each edge pixel is an updated edge pixel on the corresponding updated edge line, the curvature direction abnormal performance of each edge pixel is obtained, and the product of the longitudinal gradient component of any edge pixel and the curvature direction abnormal performance of the edge pixel is calculated and recorded as the updated longitudinal gradient component of the edge pixel.
[0062] Step S005: obtaining an updated gradient vector for each edge pixel according to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel; obtaining an appearance detection result of the plastic shell according to the updated gradient vectors of all edge pixels.
[0063] It should be noted that the updated gradient vector of each edge pixel is obtained according to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel, which realizes the gradient enhancement of the burr edge pixels and the gradient suppression of the non-burr edge pixels.
[0064] Specifically, for any edge pixel point in the plastic shell image, the vector sum of the updated horizontal axis gradient component and the updated vertical axis gradient component of the edge pixel point is used as the updated gradient vector of the edge pixel point; the double threshold of Canny edge detection is performed based on the updated gradient vector of each edge pixel point to determine the edge, and a burr edge pixel point is obtained; a curve composed of a number of continuous burr edge pixels is recorded as a burr curve; if the number of pixels of any burr curve is greater than or equal to a preset number threshold V, the appearance quality inspection result of the plastic shell is unqualified; if the number of pixels of all burr curves is less than the preset number threshold V, the appearance quality inspection result of the plastic shell is qualified; wherein, V=15, and this embodiment is described as an example.
[0065] So far, the present invention is completed.
[0066] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An automated method for detecting the appearance quality of a plastic housing. It is characterized in that The method comprises the following steps: Acquire a plastic shell image; perform edge detection on the plastic shell image to obtain a plurality of edge lines; the edge lines include a plurality of edge pixel points; Obtain the curvature magnitude, curvature direction and gradient vector of each edge pixel point; obtain the horizontal axis gradient component and the vertical axis gradient component of each edge pixel point according to the curvature direction and gradient vector of each edge pixel point on each edge line; The edge line is divided into a plurality of updated edge lines; the updated edge lines include a plurality of updated edge pixel points; according to the change of the curvature size of each updated edge pixel point, the abnormal performance of the curvature size of each edge pixel point is obtained; according to the abnormal performance of the curvature size of the edge pixel point and the horizontal axis gradient component, the updated horizontal axis gradient component of each edge pixel point is obtained; According to the difference in grayscale values between each updated edge pixel and the surrounding pixels on each updated edge line, the curvature direction abnormal performance of each edge pixel is obtained; according to the longitudinal axis gradient component of the edge pixel and the curvature direction abnormal performance, the updated longitudinal axis gradient component of each edge pixel is obtained; According to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel point, an updated gradient vector of each edge pixel point is obtained; according to the updated gradient vectors of all edge pixels points, an appearance detection result of the plastic shell is obtained; The step of obtaining the horizontal axis gradient component and the vertical axis gradient component of each edge pixel point according to the curvature direction and the gradient vector of each edge pixel point on each edge line includes the following specific steps: A two-dimensional rectangular coordinate system is established with any edge pixel point as the origin, the curvature direction of the edge pixel point as the horizontal axis, and the vertical direction of the curvature direction of the edge pixel point as the vertical axis; the gradient vector of the edge pixel point is projected onto the horizontal axis and the vertical axis of the two-dimensional rectangular coordinate system respectively to obtain the horizontal axis gradient component and the vertical axis gradient component of the edge pixel point; The specific steps of obtaining the abnormal curvature performance of each edge pixel point according to the change of the curvature size of each updated edge pixel point are as follows: For any updated edge line, any endpoint pixel point of the updated edge line is selected and recorded as the initial pixel point, and the other endpoint pixel point of the updated edge line is recorded as the termination pixel point; the length of each updated edge pixel point on the updated edge line from the initial pixel point along the updated edge line is taken as the horizontal coordinate, and the curvature size of each updated edge pixel point on the updated edge line is taken as the vertical coordinate, a curvature rectangular coordinate system is established, and each updated edge pixel point on the updated edge line is mapped to the curvature rectangular coordinate system to obtain a number of data points in the curvature rectangular coordinate system; Obtaining a first abnormality degree of each updated edge pixel point according to a plurality of data points in a rectangular coordinate system of a curvature of the updated edge line; According to the curvature size of each updated edge pixel point and the first abnormality degree, the abnormal performance of the curvature size of each updated edge pixel point is obtained; the updated edge pixel point corresponds to the edge pixel point, and the abnormal performance of the curvature size of each edge pixel point is obtained; The step of obtaining the first abnormality degree of each updated edge pixel point according to a plurality of data points in the curvature rectangular coordinate system of the updated edge line comprises the following specific steps: In the curvature rectangular coordinate system of the updated edge line, a curvature prediction curve is obtained by fitting the least square method based on all data points; for any updated edge pixel point on the updated edge line, a corresponding value of the length of the updated edge pixel point from the initial pixel point along the updated edge line on the curvature prediction curve is recorded as the predicted curvature of the updated edge pixel point, and a normalized result of the absolute value of the difference between the curvature of the updated edge pixel point and the predicted curvature is recorded as the first abnormality degree of the updated edge pixel point; The specific steps of obtaining the abnormal performance of the curvature size of each updated edge pixel point according to the curvature size of each updated edge pixel point and the first abnormality degree are as follows: On any updated edge line, with any updated edge pixel as the center, a one-dimensional window of length Q is constructed along the updated edge line, where Q is a preset length; on the updated edge line, the calculation method of the curvature size abnormality of the jth updated edge pixel is as follows: Where P j The curvature of the jth updated edge pixel is abnormal; R j Q is the variance of the curvature of all updated edge pixels in the one-dimensional window of the jth updated edge pixel; j The number of edge pixels updated in the one-dimensional window for the jth updated edge pixel; d j,w is the length of the updated edge line between the jth updated edge pixel and the wth updated edge pixel in its one-dimensional window; P j ′ ,w is the first abnormality degree of the wth updated edge pixel in the one-dimensional window of the jth updated edge pixel; norm() is the normalization function; The method of obtaining the abnormal curvature direction performance of each edge pixel point according to the difference in the grayscale value of each updated edge pixel point and the surrounding pixels on each updated edge line includes the following specific steps: In the plastic shell image, for any updated edge pixel point on any updated edge line, L pixels are respectively obtained along the horizontal axis direction and the reverse direction of the horizontal axis of the two-dimensional rectangular coordinate system of the updated edge pixel point, and are respectively recorded as the first reference pixel set and the second reference pixel set of the updated edge pixel point; wherein L is a preset reference pixel length; the average grayscale value of all pixel points in the first reference pixel set of any updated edge pixel point on the updated edge line is recorded as the initial standard grayscale of the updated edge pixel point; the average of the initial standard grayscales of all updated edge pixels on the updated edge line is recorded as the first standard grayscale of the updated edge line; According to the first reference pixel set and the second reference pixel set of the updated edge pixel point, and the first standard grayscale of the updated edge line, the abnormal performance of the curvature direction of the updated edge pixel point is obtained; the updated edge pixel point corresponds to the edge pixel point, and the abnormal performance of the curvature direction of each edge pixel point is obtained; The method of obtaining the abnormal curvature direction performance of the updated edge pixel point according to the first reference pixel set, the second reference pixel set, and the first standard grayscale of the updated edge line includes the following specific steps: The absolute value of the difference between the initial standard grayscale of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the first distance of the updated edge pixel point, and the absolute value of the difference between the mean grayscale value of all pixels in the second reference pixel set of the updated edge pixel point and the first standard grayscale of the updated edge line is recorded as the second distance of the updated edge pixel point; if the first distance of the updated edge pixel point is less than or equal to the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 0; if the first distance of the updated edge pixel point is greater than the second distance, the abnormal performance of the curvature direction of the updated edge pixel point is recorded as 1.
2. According to claim 1, a method for automatically detecting the appearance quality of a plastic housing, It is characterized in that The step of dividing the edge line into a plurality of updated edge lines includes the following specific steps: Corner detection algorithm is used to detect corners of the plastic shell image to obtain several corner points; for any corner point, if there are no other corner points in a window with a side length of S constructed with the corner point as the center, the corner point is recorded as a target corner point; the edge pixel point with the closest Euclidean distance to any target corner point is recorded as a segmentation point; each edge line in the plastic shell image is segmented into several updated edge lines based on the segmentation point.
3. According to the method for automatically detecting the appearance quality of a plastic housing as described in claim 1, It is characterized in that The step of obtaining the updated gradient vector of each edge pixel point according to the updated horizontal axis gradient component and the updated vertical axis gradient component of each edge pixel point includes the following specific steps: For any edge pixel point in the plastic shell image, the vector sum of the updated horizontal axis gradient component and the updated vertical axis gradient component of the edge pixel point is used as the updated gradient vector of the edge pixel point.
4. According to claim 1, a method for automatically detecting the appearance quality of a plastic housing, It is characterized in that The method of obtaining the appearance detection result of the plastic shell according to the updated gradient vectors of all edge pixels includes the following specific steps: Based on the updated gradient vector of each edge pixel point, the double threshold of Canny edge detection is performed to determine the edge, and the burr edge pixel point is obtained; the curve composed of a number of continuous burr edge pixel points is recorded as a burr curve; if the number of pixels of any burr curve is greater than or equal to the preset number threshold V, the appearance quality inspection result of the plastic shell is unqualified; if the number of pixels of all burr curves is less than the preset number threshold V, the appearance quality inspection result of the plastic shell is qualified.
