CN115272312B - Plastic mobile phone shell defect detection method based on machine vision - Google Patents

Plastic mobile phone shell defect detection method based on machine vision Download PDF

Info

Publication number
CN115272312B
CN115272312B CN202211177655.7A CN202211177655A CN115272312B CN 115272312 B CN115272312 B CN 115272312B CN 202211177655 A CN202211177655 A CN 202211177655A CN 115272312 B CN115272312 B CN 115272312B
Authority
CN
China
Prior art keywords
contour
edge
mobile phone
image
point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211177655.7A
Other languages
Chinese (zh)
Other versions
CN115272312A (en
Inventor
胡升勇
王晓曼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Xingles Plastic Industry Co ltd
Original Assignee
Jiangsu Xingles Plastic Industry Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Xingles Plastic Industry Co ltd filed Critical Jiangsu Xingles Plastic Industry Co ltd
Priority to CN202211177655.7A priority Critical patent/CN115272312B/en
Publication of CN115272312A publication Critical patent/CN115272312A/en
Application granted granted Critical
Publication of CN115272312B publication Critical patent/CN115272312B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/30Determination of transform parameters for the alignment of images, i.e. image registration
    • G06T7/33Determination of transform parameters for the alignment of images, i.e. image registration using feature-based methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/30Noise filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • G06V10/443Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components by matching or filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/752Contour matching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/761Proximity, similarity or dissimilarity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects

Abstract

The invention relates to the technical field of data processing, in particular to a plastic mobile phone shell defect detection method based on machine vision. The method is a method for identifying by using electronic equipment, and the defect detection of the plastic mobile phone shell is completed by using an artificial intelligence system. Firstly, recognizing a mobile phone shell image through a camera, and carrying out data processing on the mobile phone shell image to obtain a plurality of contour edges; and carrying out contour registration on the plurality of contour edges, eliminating the contour edge corresponding to the minimum shortest distance, wherein other contour edges are defect contours. The identification features and defects of the mobile phone shell are distinguished, and the calculation amount of the traditional shape context algorithm is reduced.

Description

Plastic mobile phone shell defect detection method based on machine vision
Technical Field
The invention relates to the technical field of data processing, in particular to a plastic mobile phone shell defect detection method based on machine vision.
Background
Along with the improvement of the quality requirement of the mobile phone, the consumer simultaneously puts forward the requirement on the appearance of the mobile phone, and when the shell of the mobile phone has scratches or collision defects, the use experience of the consumer can be influenced. At present, a common defect detection method for a mobile phone shell is a template matching positioning method, and a defect position is identified through matching positioning of an image to be detected and a template image. In the template matching process, a large number of data points need to be matched, so that the calculation amount of the algorithm is large, and the requirement on hardware is high.
In the prior art, matched edges can be screened according to the length of the edge in the image to be detected, and the edge with shorter length is removed, so that the calculation amount is reduced. However, this method removes the edge only according to the length, and it is very easy to remove the defect information together, which results in inaccurate defect detection.
Disclosure of Invention
In order to solve the technical problems, the invention aims to provide a method for detecting defects of a plastic mobile phone shell based on machine vision, and the adopted technical scheme is as follows:
acquiring a mobile phone shell image of a mobile phone to be detected, and preprocessing the mobile phone shell image to obtain a shell gray image;
clustering the pixel points in the shell gray image based on the gray values of the pixel points to obtain two classification clusters; obtaining a plurality of contour edges in the shell gray level image based on the classification clusters; calculating an initial positioning value of the upper edge point of the outline edge through the distance between the upper edge point of the outline edge and the edge of the shell and a rotation angle formed by a straight line passing through the gravity center of the outline and a long axis corresponding to the outline edge; for any contour edge, taking the edge point corresponding to the minimum initial positioning value as a contour starting point, taking the edge point corresponding to the maximum initial positioning value as a contour ending point, and obtaining a contour matching direction from the contour starting point and the contour ending point;
screening out partial edge points according to the difference of the initial positioning values corresponding to the adjacent edge points; performing contour registration on the screened partial edge points on the contour edge along the contour matching direction from the contour starting point of the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour starting point of the contour edge in the mobile phone shell image of the standard mobile phone by using a shape context algorithm until the contour starting points are matched with the contour end points to obtain a corresponding shape context histogram matrix and a corresponding local appearance description matrix; combining the shape context histogram matrix and the local appearance description matrix to obtain a total similarity measurement matrix; abstracting a distance matrix according to the total similarity measurement matrix to obtain the corresponding shortest distance, removing the contour edge corresponding to the smallest shortest distance from the multiple shortest distances, and reserving other contour edges as defect contours.
Preferably, the preprocessing the mobile phone shell image to obtain a shell grayscale image includes:
graying and image denoising are carried out on the mobile phone shell image to obtain an initial shell image;
carrying out image segmentation on the initial shell image to obtain an interested area, wherein the interested area comprises a self-contained pattern and a defect area part of the mobile phone shell; the image containing only the region of interest is the shell gray scale image.
Preferably, the calculating of the initial positioning value of the edge point on the contour edge through the distance between the edge point on the contour edge and the edge of the housing and the rotation angle formed by the straight line of the edge point on the contour edge passing through the center of gravity of the contour and the long axis corresponding to the contour edge includes:
the calculation formula of the initial positioning value is as follows:
Figure 941265DEST_PATH_IMAGE002
wherein, the first and the second end of the pipe are connected with each other,
Figure 100002_DEST_PATH_IMAGE003
the initial positioning value of the ith edge point on the contour edge is obtained;
Figure 517128DEST_PATH_IMAGE004
is the manhattan distance of the ith edge point on the contour edge to the nearest point on the shell edge;
Figure 100002_DEST_PATH_IMAGE005
a rotation angle formed by a straight line passing through the center of gravity of the profile and a long axis corresponding to the profile edge is formed for the ith edge point on the profile edge;
Figure 828023DEST_PATH_IMAGE006
is a cosine function
Figure 100002_DEST_PATH_IMAGE007
And sine function
Figure 551129DEST_PATH_IMAGE008
The maximum value in (b) corresponds to the slope of the tangent of the function at the corresponding location.
Preferably, the obtaining of the contour matching direction from the contour starting point and the contour ending point includes:
and (3) along the contour edge, taking the side with the minimum number of pixel points between the contour starting point and the contour tail point as a contour matching method.
Preferably, the screening out a part of the edge points according to the difference between the initial positioning values corresponding to the adjacent edge points includes:
obtaining the absolute value of the difference value of the initial positioning values between the adjacent edge points; when the absolute value of the difference value corresponding to the two adjacent edge points is smaller than a preset first threshold value, the edge point close to the outline starting point is reserved, and the edge point far away from the outline starting point is screened out.
Preferably, the combining the shape context histogram matrix and the local appearance description matrix to obtain an overall similarity metric matrix includes:
calculating a similarity measurement matrix corresponding to the shape context histogram matrix and a similarity measurement matrix corresponding to the local appearance description matrix;
and weighting and summing the similarity metric matrix corresponding to the shape context histogram matrix and the similarity metric matrix corresponding to the local appearance description matrix to obtain a total similarity metric matrix.
The embodiment of the invention at least has the following beneficial effects:
according to the method, the mobile phone shell image of the mobile phone is subjected to image segmentation, and different types of defects are classified into different classification clusters; and then calculating the initial positioning value of the edge point on the contour edge according to the distance between the edge point on the contour edge and the edge of the shell and the rotation angle formed by the straight line of the edge point on the contour edge passing through the center of gravity of the contour and the long axis corresponding to the contour edge, determining the contour initial point, the contour tail point and the contour matching direction based on the initial positioning value corresponding to each edge point, improving the shape context algorithm, and realizing the contour matching through the improved shape context algorithm.
And performing contour registration on the screened partial edge points on the contour edge along the contour matching direction from the contour starting point of the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour starting point of the contour edge in the mobile phone shell image of the standard mobile phone by using a shape context algorithm until the contour end points are matched to obtain a corresponding shape context histogram matrix and a local appearance description matrix. Therefore, on the premise of not reducing the contour matching precision, the calculation amount of the shape context algorithm is reduced. And finally, removing the self-carried patterns of the mobile phone shell and the holes of the mobile phone lens through the total similarity measurement matrix, so that the identification characteristics of the mobile phone shell, the scratch defects and the hole defects on the mobile phone shell are distinguished, the calculated amount of the traditional shape context algorithm is reduced, and the defect detection precision is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for detecting defects of a plastic mobile phone case based on machine vision according to an embodiment of the present invention.
Detailed Description
To further illustrate the technical means and effects of the present invention adopted to achieve the predetermined objects, the following detailed description of the method for detecting defects of plastic mobile phone housing based on machine vision, its specific implementation, structure, features and effects will be given with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The embodiment of the invention provides a specific implementation method of a plastic mobile phone shell defect detection method based on machine vision, which is suitable for a mobile phone shell defect detection scene. The mobile phone shell under the scene only contains a mobile phone lens hole and simple self-contained patterns of the mobile phone shell, such as the name of a mobile phone manufacturer. In order to delete edges whose length is smaller than a certain threshold, the remaining portions that are not deleted are subjected to subsequent processing as edge points. The method only screens the edges through the length, and when a long scratch appears on the shell of the mobile phone, the long scratch is used as an edge point to screen the scratch. According to the method, the mobile phone shell image of the mobile phone is subjected to image segmentation, and different types of defects are classified into different classification clusters; and determining a contour starting point, a contour ending point and a contour matching direction on the contour edge in different classification clusters, further improving a shape context algorithm, and realizing contour matching through the improved shape context algorithm. And performing contour registration on the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour edge in the mobile phone shell image of the standard mobile phone based on the contour starting point, the contour matching direction and the screened partial edge points, so that the calculation amount of the shape context algorithm is reduced on the premise of not reducing the contour matching precision. And finally, removing the self-carried patterns of the mobile phone shell and the holes of the mobile phone lens through the total similarity measurement matrix, so that the identification characteristics of the mobile phone shell, and the scratch defects and hole defects on the mobile phone shell are distinguished, and the defect detection precision of the mobile phone shell is improved.
The specific scheme of the plastic mobile phone shell defect detection method based on machine vision provided by the invention is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flow chart of steps of a method for detecting defects of a plastic mobile phone case based on machine vision according to an embodiment of the present invention is shown, the method includes the following steps:
step S100, collecting a mobile phone shell image of a mobile phone to be detected, and preprocessing the mobile phone shell image to obtain a shell gray image.
The invention needs to detect the defects of the plastic mobile phone shell, so the mobile phone shell image of the mobile phone to be detected is firstly collected through a CCD camera and an LED light source, wherein the CCD camera is arranged right above the mobile phone, the optical axis of the camera is vertical to the mobile phone to be collected, and the LED light source is used for irradiating the mobile phone to be detected, so that the camera can collect a clearer mobile phone shell image under the irradiation of the LED light source. And preprocessing the collected mobile phone shell image to obtain a shell gray image. Preprocessing the mobile phone shell image to obtain a shell gray image, specifically:
firstly, graying and denoising an image of a mobile shell to obtain an initial shell image. The image graying is to simplify the image information quantity and facilitate the subsequent defect detection of the mobile phone shell image; the image denoising is to eliminate the defect detection error caused by the interference of external factors, such as uneven illumination, image transmission equipment and other influence factors, when the defect detection is carried out on the mobile phone shell image. In the embodiment of the invention, the graying method of the image is weighted average graying, and the image denoising method is a median filtering method.
Then, because the defect detection is carried out on the mobile phone shell image, a certain number of defects such as scratch defects, hole defects and the like exist in the mobile phone shell image; there are also mobile phone lens holes and mobile phone shell self-contained patterns, such as mobile phone manufacturer name, etc. When the defect detection of the mobile phone shell is carried out through machine vision, the self-carried patterns of the mobile phone shell need to be distinguished from the defect parts in the mobile phone shell, so that the economic loss caused by disordered detection is avoided, and the shell of a standard mobile phone and the shells of all mobile phones to be detected are ensured to be the same type of mobile phone shell when the defect detection is carried out. And after the initial shell image is obtained, performing image segmentation on the initial shell image to obtain an interested region, wherein the interested region comprises a self-contained pattern and a defect region part of the mobile phone shell, and removing the background region. The image containing only the region of interest is the shell gray scale image. Namely, the interested part in the image is highlighted, the difference between different characteristics in the image is expanded, and the difference between the background and the defect and the difference between patterns carried by the mobile phone are expanded in the plastic mobile phone shell image, so that the subsequent defect detection is facilitated.
S200, clustering the pixel points in the shell gray image based on the gray values of the pixel points to obtain two classification clusters; obtaining a plurality of contour edges in the shell gray level image based on the classification clusters; calculating an initial positioning value of the edge point on the contour edge according to the distance between the edge point on the contour edge and the edge of the shell and a rotation angle formed by a straight line passing through the center of gravity of the contour and a long axis corresponding to the contour edge; and for any contour edge, taking the edge point corresponding to the minimum initial positioning value as a contour starting point, taking the edge point corresponding to the maximum initial positioning value as a contour tail point, and obtaining a contour matching direction from the contour starting point and the contour tail point.
For the mobile phone shell image of the mobile phone to be detected, the gray value difference of each area is smaller no matter whether the mobile phone shell image is a defect part, a background part or a self-contained pattern of the mobile phone shell. Therefore, the pixels in the shell gray image can be clustered according to the gray value of each pixel in the shell gray image corresponding to the mobile phone to be detected through a DBSCAN clustering algorithm, the number of the clusters is the number of different areas in the plastic mobile phone shell image, only an interested area is reserved in the process of preprocessing the mobile phone shell image, and a background area is removed, so that the shell gray image only contains defective holes, mobile phone lens holes, scratch defects and self-contained patterns of the mobile phone shell, wherein the gray value difference between the defective holes and the mobile phone lens holes is small, the defect holes and the mobile phone lens holes are close to black, and the defective holes and the mobile phone lens holes are clustered according to the gray value to be classified into the same classification cluster; the difference between the scratch defect and the gray value of the self-contained pattern of the mobile phone shell is small, clustering is carried out according to the gray value, and the scratch defect and the self-contained pattern of the mobile phone shell are classified into the same classification cluster. That is, based on the gray value of the pixel point, clustering the pixel point in the shell gray image to obtain two classification clusters. It should be noted that the DBSCAN clustering algorithm is well known to those skilled in the art, and will not be described herein.
And obtaining two classification clusters through a DBSCAN clustering algorithm, wherein the two classification clusters do not comprise a background area, namely the background area is removed, the gray value difference between the two classification clusters is larger, and the gray value difference in the two classification clusters is smaller.
Further, defects belonging to the same classification cluster are detected. It should be noted that the mobile phone shell of the mobile phone to be detected according to the present invention is relatively simple, and if there are other types of defects or other mobile phone shell identifiers, the implementer can adjust the number of the classification clusters according to the actual situation.
After the gray level transformation is carried out on the mobile phone shell image and the background is removed, only two gray level value areas, namely two classification clusters, exist in the obtained shell gray level image. Wherein, there are defect hole and cell-phone lens hole in one classification cluster, there are scratch defect and the self-contained pattern of cell-phone shell in another classification cluster, for example cell-phone manufacturer name. Respectively extracting defect holes, mobile phone lens holes, scratch defects and self-patterned outline edges of the mobile phone shell in the classification clusters from the pixel points in the two classification clusters through Sobel edge detection; namely, based on the classification cluster, a plurality of contour edges in the shell gray scale image are obtained. And carrying out image registration on the contours corresponding to the two classification clusters so as to extract the defects and carry out defect detection. It should be noted that Sobel edge detection is a well-known technique for those skilled in the art, and is not described herein in detail. The defect hole and the mobile phone lens hole belong to the same classification cluster, and the scratch defect and the self-contained pattern of the mobile phone shell belong to the same classification cluster.
And realizing image registration of the mobile phone shell image of the standard mobile phone and the mobile phone shell image of the mobile phone to be detected through the shape context operator, thereby completing defect detection of the mobile phone shell image of the mobile phone to be detected. The shapes of defect holes and mobile phone lens holes in the outline edge are approximate to circular, a polar logarithm coordinate system is adopted to realize outline registration, and in order to reduce the calculation amount of shape context operators, the starting points and the outline matching directions of all outlines in the outline edge are defined.
The traditional shape context operator performs one-to-one matching on all contour points in two images, so that image registration is realized, the matching precision is high, but the calculation amount is large. In order to reduce the calculation amount, the invention realizes the positioning of the outline starting point on each outline edge, the determination of the outline matching direction and the screening of pixel points by constructing the rotation distance and the rotation angle. After the matching directions of the initial point and the contour are determined according to the same rule for the contour existing in the image, the matching of each contour point existing in the mobile phone shell image of the standard mobile phone and the mobile phone shell image of the mobile phone to be detected is not needed. The image registration can be realized only by matching the screened partial edge points one by one according to the contour matching direction, the contour registration of the defect holes and the mobile phone lens holes in the mobile phone shell image of the standard mobile phone and the defect holes and the mobile phone lens holes in the mobile phone shell image of the mobile phone to be detected is realized through the constructed rotation distance and rotation angle for the classification clusters of the defect holes and the mobile phone lens holes, and the defect detection can be completed only by having the defect holes in the classification clusters after the matched contours, namely the mobile phone lens holes, are removed.
Specifically, the method comprises the following steps: taking the distance between the upper edge point of the outline edge and the edge of the shell as a rotation distance, and taking the upper edge point of the outline edge to pass through the gravity center of the outline as a straight line to form a rotation angle with a long axis corresponding to the outline edge; and calculating the initial positioning value of the edge point on the contour edge according to the distance between the edge point on the contour edge and the edge of the shell and the rotation angle formed by the straight line of the edge point on the contour edge passing through the center of gravity of the contour and the long axis corresponding to the contour edge. The edge of the shell is the outline edge of the outermost layer of the mobile phone in the mobile phone shell image, such as a rectangular mobile phone, and correspondingly is the largest edge of the outermost layer, which is the rectangular shell edge; the center of the contour is the center of gravity of the edge of the contour.
The calculation formula of the initial positioning value is as follows:
Figure DEST_PATH_IMAGE009
wherein the content of the first and second substances,
Figure 21293DEST_PATH_IMAGE003
the initial positioning value of the ith edge point on the outline edge is obtained;
Figure 640493DEST_PATH_IMAGE004
is the manhattan distance of the ith edge point on the contour edge to the nearest point on the shell edge;
Figure 641947DEST_PATH_IMAGE005
a rotation angle formed by a straight line passing through the center of gravity of the profile and a long axis corresponding to the profile edge is formed for the ith edge point on the profile edge;
Figure 434323DEST_PATH_IMAGE006
is a cosine function
Figure 899939DEST_PATH_IMAGE007
And sine function
Figure 362145DEST_PATH_IMAGE008
The maximum value in (b) corresponds to the slope of the tangent of the function at the corresponding location.
The Manhattan distance is the sum of the transverse distance and the longitudinal distance between the contour pixel point and the closest point on the edge of the shell, and the transverse distance and the longitudinal distance are on the side close to the edge and are perpendicular to each other. And the shell edge of the mobile phone is extracted through Sobel edge detection, the significant difference between the shell edge of the mobile phone and each contour edge in the mobile phone shell image is the contour size, and the shell edge of the mobile phone can be distinguished from each contour edge in the mobile phone shell image through the contour size. The distance alone is not sufficient to position the contour point accurately, and therefore the angle of rotation
Figure 972599DEST_PATH_IMAGE005
The selection of the starting point of the contour in the contour is implemented to reduce the amount of computation of the shape context operator. The long axis corresponding to the outline edge is an axis parallel to the long edge of the rectangular mobile phone shell.
Figure 178452DEST_PATH_IMAGE010
The maximum value of the sine value and the cosine value corresponding to the rotation angle;
Figure 826471DEST_PATH_IMAGE006
is the slope of the tangent at the corresponding position of the corresponding function for the maximum of the sine and cosine values. If the rotation angle is 30 degrees, because
Figure DEST_PATH_IMAGE011
Is greater than
Figure 912108DEST_PATH_IMAGE012
Therefore, it is made
Figure DEST_PATH_IMAGE013
Is composed of
Figure 684892DEST_PATH_IMAGE011
Then correspond to
Figure 756753DEST_PATH_IMAGE014
Is composed of
Figure 259278DEST_PATH_IMAGE011
The slope of the tangent at the corresponding location of the corresponding cosine function.
The slope of the tangent is:
Figure 394112DEST_PATH_IMAGE016
wherein, the first and the second end of the pipe are connected with each other,
Figure 857455DEST_PATH_IMAGE006
the slope of a tangent line of the maximum value of the sine value and the cosine value at the corresponding position of the corresponding function is taken as the slope of the tangent line;
Figure DEST_PATH_IMAGE017
is at an angle of
Figure 592061DEST_PATH_IMAGE005
The slope of a tangent line at a corresponding position on the corresponding cosine function;
Figure 886776DEST_PATH_IMAGE018
is at an angle of
Figure 392844DEST_PATH_IMAGE005
The slope of the tangent at the corresponding location on the corresponding sine function.
Wherein the angle of rotation
Figure 936958DEST_PATH_IMAGE005
The value is 0 to 360 degrees, corresponding sine or cosine functions are selected according to different values of the rotation angle, and the positions of the pixel points corresponding to the rotation angle are uniquely determined according to the tangent slope corresponding to the sine function or the cosine function at the angle. The method comprises the steps of calculating the tangent slope of the sine value and the cosine value of a rotation angle to perform fine cutting positioning on the starting point of the profile, wherein the purpose that the tangent slope of the sine value and the cosine value corresponding to the rotation angle takes the maximum value in the range of 0-360 degrees is that the tangent slope is not repeated in the interval, so that the edge points are distinguished when the rotation distance is repeated. And calculating the initial positioning value of each edge point on each contour edge.
And regarding any contour edge, taking the edge point corresponding to the minimum starting positioning value as a contour starting point, and taking the edge point corresponding to the maximum starting positioning value as a contour tail point. Further, a contour matching direction is obtained from the contour starting point and the contour ending point, specifically: and (3) along the contour edge, taking the side with the minimum number of pixel points between the contour starting point and the contour tail point as a contour matching method. That is, based on the contour edge, along the side where the number of pixels between the contour start point and the contour end point is small, the direction from the contour start point to the contour end point is taken as the contour matching direction. It should be noted that, based on the contour edge, there are only two directions from the contour start point to the contour end point.
S300, screening out partial edge points according to the difference of the initial positioning values corresponding to the adjacent edge points; performing contour registration on the screened partial edge points on the contour edge along the contour matching direction from the contour starting point of the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour starting point of the contour edge in the mobile phone shell image of the standard mobile phone by using a shape context algorithm until the contour starting points are matched with the contour end points to obtain a corresponding shape context histogram matrix and a corresponding local appearance description matrix; combining the shape context histogram matrix and the local appearance description matrix to obtain a total similarity measurement matrix; abstracting a distance matrix according to the total similarity measurement matrix to obtain the corresponding shortest distance, removing the contour edge corresponding to the smallest shortest distance from the multiple shortest distances, and reserving other contour edges as defect contours.
And screening edge points on the outline edge in the mobile phone shell image of the mobile phone to be detected and the outline edge in the mobile phone shell image of the standard mobile phone, and further reducing the calculation amount of the outline matching step. When the initial positioning values of the two adjacent edge points are smaller in difference, the information difference of the two edge points is considered to be smaller, one of the two adjacent edge points with the smaller initial positioning value difference can be taken as a representative, the contour matching can be realized, the edge points do not need to be matched one by one, and the calculation amount of the subsequent steps is reduced by matching the screened partial edge points. Namely, screening out partial edge points according to the difference of the initial positioning values corresponding to the adjacent edge points, specifically: and when the absolute value of the difference value corresponding to the two adjacent edge points is smaller than a preset first threshold value, reserving the edge point which is closer to the initial point of the profile in the two adjacent edge points, and screening out the edge point which is farther from the initial point of the profile.
Starting from the contour starting point, the absolute values of the differences of the starting location values between the adjacent edge points are calculated along the contour matching direction, respectively. In the embodiment of the present invention, the value of the first threshold is preset to be 3, and in other embodiments, an implementer may adjust the value according to an actual situation. And performing contour registration on the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour edge in the mobile phone shell image of the standard mobile phone based on the contour starting point, the contour matching direction and the screened partial adjacent edge points, so that defect detection of classification clusters containing defect holes and mobile phone lens holes is realized, namely defect detection of the defect holes is realized.
After the outline starting point, the outline end point and the outline matching direction are determined, and after the edge points on the outline edge are screened. Based on the contour starting point, the contour matching direction, the contour end point and the screened partial edge points, carrying out contour registration on the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour edge in the mobile phone shell image of the standard mobile phone to obtain a shape context histogram matrix and a local appearance description matrix, specifically: performing contour registration on screened partial edge points on the contour edge from a contour starting point of the contour edge in the mobile phone shell image of the mobile phone to be detected and a contour starting point of the contour edge in the mobile phone shell image of the standard mobile phone along respective contour matching directions by using a shape context algorithm until the screened partial edge points are matched to a contour tail point to obtain a corresponding shape context histogram matrix and a local appearance description matrix; that is, from the outline starting point, along the respective outline matching direction, the edge points screened from each outline edge in the mobile phone shell image of the standard mobile phone and the edge points screened from each outline edge in the mobile phone shell image of the mobile phone to be detected are in one-to-one correspondence until the edge points are matched to the outline end points, and a corresponding shape context histogram matrix and a corresponding local appearance description matrix are obtained. The amount of computation is reduced compared to the original shape context algorithm. After the contour starting point, the contour end point and the contour matching direction are determined, the edge point of a certain contour edge in the mobile phone shell image of the standard mobile phone does not need to be matched with all the edge points of a certain contour edge in the mobile phone shell image of the mobile phone to be detected one by one, and the contour registration can be realized only by matching the screened edge point between the contour starting point and the contour end point in the certain contour edge in the mobile phone shell image of the standard mobile phone and the screened edge point between the contour starting point and the contour end point in the certain contour edge in the mobile phone shell image of the mobile phone to be detected one by one according to the corresponding relation.
It should be noted that, the contour starting point, the contour ending point and the contour matching direction are also determined for each contour edge in the mobile phone shell image of the standard mobile phone, and the edge point screening is also performed for the contour edge in the mobile phone shell image of the standard mobile phone. And on the basis of contour starting points, contour tail points and contour matching directions which correspond to contour edges in the standard mobile phone shell image and the mobile phone shell image of the mobile phone to be detected respectively, corresponding the screened edge points in the contour edges in the mobile phone shell image of the standard mobile phone to the screened edge points in the contour edges in the mobile phone shell image of the mobile phone to be detected one by one.
Similarly, for the classification clusters containing scratch defects and self-contained patterns of the mobile phone shell, the initial positioning value of the edge point on each contour edge is obtained similarly, the edge point corresponding to the minimum initial positioning value is used as the contour initial point, the edge point corresponding to the maximum initial positioning value is used as the contour end point, the contour matching direction is obtained from the contour initial point and the contour end point, and partial edge points are screened out according to the difference of the initial positioning values corresponding to the adjacent edge points. Based on the outline starting point, the outline ending point, the outline matching direction and the screened part of adjacent edge points, the defect detection of the classification cluster containing the scratch defect and the self-contained pattern of the mobile phone shell is realized by registering the outline of the mobile phone shell image of the standard mobile phone and the outline of the mobile phone shell image of the mobile phone to be detected, namely the defect detection of the scratch defect is realized.
The contour registration of the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour edge in the mobile phone shell image of the standard mobile phone is carried out by utilizing a shape context algorithm according to the established rule, the obtained contour starting point, the contour matching direction, the contour end point and the screened partial edge point based on the contour matching of the context operator, so that a shape context histogram matrix and a local appearance description matrix of the context operator are obtained.
After the shape context histogram matrix is obtained, the similarity of the point input graph and the point template graph is calculated by using the chi-square statistics. For each edge point in the outline edge in the mobile phone shell image of the mobile phone to be detected and the outline edge in the mobile phone shell image of the standard mobile phone, K-dimensional histogram vectors are respectively recorded as
Figure DEST_PATH_IMAGE019
And
Figure 85042DEST_PATH_IMAGE020
and substituting the similarity measurement matrix into a chi-square formula to calculate the similarity measurement matrix corresponding to the shape context histogram matrix. It should be noted that the method for obtaining the shape context histogram matrix and the corresponding similarity metric matrix for the shape context is well known to those skilled in the art, and will not be described herein again. In the embodiment of the invention, the mobile phone shell image of the mobile phone to be detected is a point input image, and the mobile phone shell image of the standard mobile phone is a point template image.
Because the local information is obtained according to the shape context histogram matrix, further, the local direction can be used as the local appearance information of the shape context, and the gradient G of the corresponding gray scale image is calculated for the mobile phone shell image of the mobile phone to be detected and the mobile phone shell image of the standard mobile phone x And G y Then finding out the gradient value corresponding to the edge point on the contour edge and calculating the tangential angle
Figure DEST_PATH_IMAGE021
And
Figure 93319DEST_PATH_IMAGE022
introducing a function of dissimilarity of the tangential angle as a basis for measuring the local direction for the tangential angle
Figure 770288DEST_PATH_IMAGE021
And
Figure 2030DEST_PATH_IMAGE022
by cosine and sineAnd converting the similarity into an Euclidean space, calculating the Euclidean distance of the Euclidean space, measuring the similarity of two angles, and transforming a tangential angle non-similarity function to obtain a similarity measurement matrix corresponding to the local appearance description matrix. It should be noted that the method for acquiring the local appearance description matrix and the corresponding similarity measurement matrix related to the shape context is well known by those skilled in the art, and will not be described herein again.
And finally, combining the shape context histogram matrix and the local appearance description matrix to obtain a total similarity measurement matrix, specifically: weighting and summing the similarity measurement matrix corresponding to the obtained shape context histogram matrix and the similarity measurement matrix corresponding to the local appearance description matrix to obtain a total similarity measurement matrix; namely, the two similarity measurement matrixes are weighted and summed to obtain the total similarity measurement matrix. It should be noted that outputting the total similarity metric matrix by combining the shape context histogram matrix and the similarity metric matrix corresponding to the local appearance description matrix is a known technique of those skilled in the art, and is not described herein again.
Of the total similarity measure matrix
Figure DEST_PATH_IMAGE023
The calculation formula is as follows:
Figure DEST_PATH_IMAGE025
wherein the content of the first and second substances,
Figure 547281DEST_PATH_IMAGE026
a similarity measurement matrix corresponding to the shape context histogram matrix;
Figure DEST_PATH_IMAGE027
a similarity measurement matrix corresponding to the local appearance description matrix;
Figure 347747DEST_PATH_IMAGE028
to adjust the weights. In the embodiment of the present invention, the adjustment weight is 0.1, whereThe implementer in other embodiments can adjust the value according to actual conditions.
The similarity measurement matrix corresponding to the shape context histogram matrix corresponds to the shape context, the similarity measurement matrix corresponding to the local appearance description matrix corresponds to the local appearance, and the local features are constrained through local appearance information.
Further, the total similarity metric matrix is abstracted as a distance matrix. Solving the point pair matching which enables the total loss to be minimum by utilizing a Hungarian matching strategy, and further obtaining a distance matrix forming complete matching and a corresponding shortest distance; and combining the similarity measurement matrix corresponding to the obtained shape context histogram matrix with the similarity measurement matrix corresponding to the local appearance description matrix, realizing contour matching by a Hungary matching strategy, abstracting the total similarity measurement matrix into a distance matrix, and performing matching according to the shortest distance extracted from the distance matrix. It should be noted that, after abstracting the total similarity metric matrix into a distance matrix, the specific step of using the hungarian algorithm to find the point pair matching that minimizes the total loss, and further obtaining the shortest distance is a known technique of those skilled in the art, and is not described herein again.
And respectively calculating the shortest distance between each contour edge in the mobile phone shell image of the mobile phone to be detected and the corresponding contour edge in the mobile phone shell image of the standard mobile phone for each contour edge in any classification cluster a, and removing the contour edge corresponding to the minimum shortest distance from a plurality of shortest distances in the classification cluster a, wherein other contour edges are defect contours. And considering the outline edge corresponding to the minimum shortest distance as a mobile phone lens hole in the mobile phone shell image or a self-contained pattern of the mobile phone shell. In the invention, pixel points in the shell gray image corresponding to the mobile phone shell image are divided into two classification clusters, and each classification cluster corresponds to a minimum shortest distance, so that the outline edge corresponding to the minimum shortest distance of one classification cluster is a mobile phone lens hole, and the outline edge corresponding to the minimum shortest distance of the other classification cluster is a self-contained pattern of the mobile phone shell. And eliminating the outline edge corresponding to the minimum shortest distance, namely realizing the elimination of the self-contained patterns of the mobile phone lens hole and the mobile phone shell, and only keeping the defect outline corresponding to the defect scratch and the defect hole.
In summary, the present invention relates to the field of data processing technology. Firstly, acquiring a mobile phone shell image and a corresponding shell gray image of a mobile phone to be detected; clustering pixel points in the shell gray image to obtain two classification clusters; obtaining a plurality of contour edges in the shell gray level image based on the classification clusters; calculating an initial positioning value of an edge point on the edge of the outline; determining a contour starting point, a contour matching direction and screened partial edge points based on the starting positioning value, and performing contour registration on contour edges in a mobile phone shell image of the mobile phone to be detected and a mobile phone shell image of a standard mobile phone to obtain a corresponding total similarity measurement matrix; abstracting a distance matrix according to the total similarity measurement matrix to obtain the corresponding shortest distance, removing the minimum contour edge corresponding to the shortest distance from the multiple shortest distances, wherein other contour edges are defect contours. The invention reduces the calculation amount of the shape context algorithm on the premise of not reducing the contour matching precision by determining the contour starting point based on the traditional shape context algorithm. And finally, removing the self-carried patterns and the mobile phone lens holes of the mobile phone shell through the total similarity measurement matrix, so that the identification characteristics of the mobile phone shell, and the scratch defects and hole defects on the mobile phone shell are distinguished, and the defect detection precision of the mobile phone shell is improved.
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. The processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (6)

1. The plastic mobile phone shell defect detection method based on machine vision is characterized by comprising the following steps:
acquiring a mobile phone shell image of a mobile phone to be detected, and preprocessing the mobile phone shell image to obtain a shell gray image;
clustering the pixel points in the shell gray image based on the gray values of the pixel points to obtain two classification clusters; obtaining a plurality of contour edges in the shell gray level image based on the classification clusters; calculating an initial positioning value of the edge point on the contour edge according to the distance between the edge point on the contour edge and the edge of the shell and a rotation angle formed by a straight line passing through the center of gravity of the contour and a long axis corresponding to the contour edge; for any contour edge, taking the edge point corresponding to the minimum initial positioning value as a contour starting point, taking the edge point corresponding to the maximum initial positioning value as a contour tail point, and obtaining a contour matching direction from the contour starting point and the contour tail point;
screening out partial edge points according to the difference of the initial positioning values corresponding to the adjacent edge points; performing contour registration on the screened partial edge points on the contour edge along the contour matching direction from the contour starting point of the contour edge in the mobile phone shell image of the mobile phone to be detected and the contour starting point of the contour edge in the mobile phone shell image of the standard mobile phone by using a shape context algorithm until the contour starting points are matched with the contour end points to obtain a corresponding shape context histogram matrix and a corresponding local appearance description matrix; combining the shape context histogram matrix and the local appearance description matrix to obtain a total similarity measurement matrix; abstracting a distance matrix according to the total similarity measurement matrix to obtain a corresponding shortest distance, eliminating the profile edge corresponding to the minimum shortest distance from the multiple shortest distances, and keeping other profile edges as defect profiles.
2. The plastic mobile phone shell defect detection method based on machine vision as claimed in claim 1, wherein said preprocessing said mobile phone shell image to obtain a shell gray scale image comprises:
graying and denoising the mobile phone shell image to obtain an initial shell image;
carrying out image segmentation on the initial shell image to obtain an interested area, wherein the interested area comprises a self-contained pattern and a defect area part of the mobile phone shell; the image containing only the region of interest is the shell gray scale image.
3. The method for detecting defects of a plastic mobile phone shell based on machine vision according to claim 1, wherein the step of calculating the initial positioning value of the upper edge point of the outline edge through the distance between the upper edge point of the outline edge and the shell edge and the rotation angle formed by the straight line of the upper edge point of the outline edge passing through the gravity center of the outline and the long axis corresponding to the outline edge comprises the following steps:
the calculation formula of the initial positioning value is as follows:
Figure 514970DEST_PATH_IMAGE002
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE003
the initial positioning value of the ith edge point on the contour edge is obtained;
Figure 522240DEST_PATH_IMAGE004
is the manhattan distance of the ith edge point on the contour edge to the nearest point on the shell edge;
Figure DEST_PATH_IMAGE005
making a rotation angle formed by a straight line passing through the center of gravity of the profile and a long axis corresponding to the profile edge for the ith edge point on the profile edge;
Figure 126528DEST_PATH_IMAGE006
is a cosine function
Figure DEST_PATH_IMAGE007
And sine function
Figure 80709DEST_PATH_IMAGE008
The maximum value in (b) corresponds to the slope of the tangent of the function at the corresponding location.
4. The method for detecting defects of a plastic mobile phone shell based on machine vision as claimed in claim 1, wherein the obtaining of the contour matching direction from the contour starting point and the contour end point comprises:
and (3) along the contour edge, taking the side with the minimum number of pixel points between the contour starting point and the contour tail point as a contour matching method.
5. The method for detecting defects of plastic mobile phone shells based on machine vision according to claim 1, wherein the screening out partial edge points according to the difference of the initial positioning values corresponding to the adjacent edge points comprises:
obtaining the absolute value of the difference value of the initial positioning values between the adjacent edge points; when the absolute value of the difference value corresponding to the two adjacent edge points is smaller than a preset first threshold value, the edge points closer to the outline starting point are reserved, and the edge points farther from the outline starting point are screened out.
6. The machine-vision-based plastic mobile phone case defect detection method of claim 1, wherein the combining the shape context histogram matrix and the local appearance description matrix to obtain a total similarity metric matrix comprises:
calculating a similarity measurement matrix corresponding to the shape context histogram matrix and a similarity measurement matrix corresponding to the local appearance description matrix;
and weighting and summing the similarity metric matrix corresponding to the shape context histogram matrix and the similarity metric matrix corresponding to the local appearance description matrix to obtain a total similarity metric matrix.
CN202211177655.7A 2022-09-27 2022-09-27 Plastic mobile phone shell defect detection method based on machine vision Active CN115272312B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211177655.7A CN115272312B (en) 2022-09-27 2022-09-27 Plastic mobile phone shell defect detection method based on machine vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211177655.7A CN115272312B (en) 2022-09-27 2022-09-27 Plastic mobile phone shell defect detection method based on machine vision

Publications (2)

Publication Number Publication Date
CN115272312A CN115272312A (en) 2022-11-01
CN115272312B true CN115272312B (en) 2022-12-16

Family

ID=83756044

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211177655.7A Active CN115272312B (en) 2022-09-27 2022-09-27 Plastic mobile phone shell defect detection method based on machine vision

Country Status (1)

Country Link
CN (1) CN115272312B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115641332B (en) * 2022-12-01 2023-03-31 中科慧远视觉技术(北京)有限公司 Method, device, medium and equipment for detecting product edge appearance defects
CN117218422B (en) * 2023-09-12 2024-04-16 北京国科恒通科技股份有限公司 Power grid image recognition method and system based on machine learning
CN117197138B (en) * 2023-11-07 2024-02-23 深圳市极摩客科技有限公司 Computer host shell scratch detection method based on image characteristics

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5253307A (en) * 1991-07-30 1993-10-12 Xerox Corporation Image analysis to obtain typeface information
CN103578105B (en) * 2013-11-01 2016-04-27 中北大学 A kind of multi-source foreign peoples method for registering images based on provincial characteristics
CN107798326B (en) * 2017-10-20 2020-09-22 华南理工大学 Contour vision detection method

Also Published As

Publication number Publication date
CN115272312A (en) 2022-11-01

Similar Documents

Publication Publication Date Title
CN115272312B (en) Plastic mobile phone shell defect detection method based on machine vision
CN113450307B (en) Product edge defect detection method
CN115018828B (en) Defect detection method for electronic component
CN115082419B (en) Blow-molded luggage production defect detection method
WO2018019194A1 (en) Image recognition method, terminal, and nonvolatile storage medium
CN116205919B (en) Hardware part production quality detection method and system based on artificial intelligence
CN111709420A (en) Text detection method, electronic device and computer readable medium
CN109409208A (en) A kind of vehicle characteristics extraction and matching process based on video
CN113780259A (en) Road surface defect detection method and device, electronic equipment and readable storage medium
CN114170228A (en) Computer image edge detection method
CN115082451B (en) Stainless steel soup ladle defect detection method based on image processing
CN110047063B (en) Material drop detection method, device, equipment and storage medium
CN115311262A (en) Printed circuit board defect identification method
CN113609984A (en) Pointer instrument reading identification method and device and electronic equipment
CN110348307B (en) Path edge identification method and system for crane metal structure climbing robot
CN111695373B (en) Zebra stripes positioning method, system, medium and equipment
CN115018835A (en) Automobile starter gear detection method
Bello-Salau et al. An examination of different vision based approaches for road anomaly detection
CN112288760B (en) Adherent cell image screening method and system and cell image analysis method
CN110458234B (en) Vehicle searching method with map based on deep learning
WO2024016632A1 (en) Bright spot location method, bright spot location apparatus, electronic device and storage medium
CN116539619A (en) Product defect detection method, system, device and storage medium
CN110349129B (en) Appearance defect detection method for high-density flexible IC substrate
CN112785550A (en) Image quality value determination method, image quality value determination device, storage medium, and electronic device
CN113505811A (en) Machine vision imaging method for hub production

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant