Disclosure of Invention
In order to solve the technical problem that the defects of the PVC plastic pipe orifice cannot be accurately detected in the prior art, the application aims to provide the method for detecting the defects of the PVC plastic pipe orifice based on image processing, and the adopted technical scheme is as follows:
a PVC plastic pipe orifice defect detection method based on image processing comprises the following steps:
acquiring a gray image and an HSV image corresponding to a pvc plastic pipe orifice; performing edge detection on the gray level image to obtain at least two contour curves, calculating the distance from each contour curve to the center point of the pvc plastic pipe orifice, and selecting the contour curve corresponding to the minimum distance as a defect contour curve;
the method comprises the steps of recording a region surrounded by a defect profile curve as a first region, respectively obtaining the maximum length of the first region corresponding to the vertical direction in the horizontal direction, and calculating the appearance characteristic factor of the pvc plastic pipe orifice based on the maximum length, the area of the first region and the length of the defect profile curve;
obtaining a minimum circumcircle corresponding to the defect profile curve; forming a pixel point pair by any pixel point on the minimum circumscribing circle and any pixel point on the defect contour curve, calculating a weight value of the pixel point pair according to the distance between two pixel points in the pixel point pair and the appearance characteristic factor, and constructing a weight matrix according to the weight value;
constructing a difference vector based on the maximum weight value corresponding to each row in the weight matrix; constructing a similarity vector based on the minimum weight value corresponding to each row in the weight matrix;
the area surrounded by the minimum circumscribing circle is recorded as a second area, and a difference area corresponding to the second area and the first area is obtained; calculating hue consistency according to the hue value of each pixel point in the difference value area and the hue value of the H channel of each pixel point in the second area in the HSV image;
and calculating a defect characteristic vector according to the similarity vector, the difference vector and the hue consistency, and judging whether the PVC plastic pipe orifice has defects or not based on the defect characteristic vector.
In one embodiment, the method for calculating the profile characteristic factor of the pvc plastic pipe orifice based on the maximum length, the area of the first area and the length of the defect profile curve comprises the following steps: for the maximum length of the first area corresponding to the vertical direction in the horizontal direction, acquiring a larger value and a smaller value in the two maximum lengths, and calculating the ratio of the larger value to the smaller value to obtain a first characteristic; calculating the ratio of the length of the defect profile curve to the area of the first region to obtain a second characteristic; the product of the first feature and the second feature is the profile characteristic factor of the pvc plastic orifice.
In one embodiment, the method for calculating the hue consistency according to the hue value of each pixel point in the difference value area and the hue value of the H channel of each pixel point in the second area in the HSV image is as follows: calculating the accumulated sum corresponding to the hue values of the H channels of all pixel points in the difference area in the HSV image, and recording the accumulated sum as a first accumulated sum; and calculating the accumulated sum corresponding to the hue values of the H channels of all the pixel points in the second area in the HSV image, and recording the accumulated sum as a second accumulated sum, wherein the ratio of the first accumulated sum to the second accumulated sum is hue consistency.
In one embodiment, the method for calculating the defect feature vector according to the similarity vector, the difference vector and the hue consistency comprises the following steps: and respectively carrying out transposition operation on the similarity vector and the difference vector to obtain a vector transposed by the similarity vector and the difference vector, constructing a new matrix according to the vector transposed by the similarity vector and the difference vector, and taking the product of the hue consistency and the new matrix as a defect characteristic vector.
In one embodiment, the method for constructing a new matrix according to the transposed vector of the similarity vector and the difference vector comprises the following steps: and taking each element in the vector transposed by the similarity vector as an element of a first column in the new matrix, and taking each element in the vector transposed by the difference vector as an element of a second column in the new matrix.
In one embodiment, the method for calculating the weight value of the pixel point pair according to the distance between two pixel points in the pixel point pair and the appearance characteristic factor is as follows: the weight value of the pixel point pair is the product of the distance between two pixel points in the pixel point pair and the appearance characteristic factor.
In one embodiment, the method for calculating the distance from each profile curve to the center point of the pvc plastic pipe orifice is as follows: and calculating the average value corresponding to the distances from all the pixel points on the contour curve to the center point of the pvc plastic pipe orifice, wherein the average value is the distance from the corresponding contour curve to the center point of the pvc plastic pipe orifice.
In one embodiment, the method for constructing the difference vector based on the maximum weight value corresponding to each row in the weight matrix includes: and taking the maximum weight value corresponding to each row in the weight matrix as the element corresponding to each dimension in the difference vector.
In one embodiment, the method for constructing the similarity vector based on the minimum weight value corresponding to each row in the weight matrix includes: and taking the minimum weight value corresponding to each row in the weight matrix as the element corresponding to each dimension in the similarity vector.
The embodiment of the application has at least the following beneficial effects:
the application obtains the defect contour curve in the gray level image; calculating the appearance characteristic factors of the pvc plastic pipe orifice based on the defect contour curve of the pvc plastic pipe orifice; the calculation of the appearance characteristic factors combines the maximum length and the area of the area surrounded by the defect contour curves and corresponding to the defect contour curves in the horizontal direction and the vertical direction and the length of the defect contour curves, combines various factors, avoids errors caused by single variable calculation, can accurately reflect the shape characteristics of the defect contour curves, and provides accurate information for subsequent judgment and identification. Meanwhile, according to the similarity vector, the difference vector and the hue consistency, the defect feature vector is calculated, and whether the PVC plastic pipe orifice has defects is judged based on the defect feature vector; the difference vector and the similarity vector are obtained through weight values in a weight matrix, the weight values are obtained through distances between a shape feature factor and two pixel points in the pixel point pair, the shape feature factor represents shape features of a defect contour curve, the distances can represent space positions of the pixel point pair, so the difference vector and the similarity vector are combined with the shape features and the space positions, the hue consistency is obtained through hue values, the color features are represented, the calculation of the defect feature vector is based on the color features, the shape features and the space position features, namely, when a pvc plastic pipe orifice has no defect, the corresponding color features, the shape features and the space position features are all greatly different from the color features, the shape features and the space position features corresponding to the pvc plastic pipe orifice when the defect occurs; the difference of different degrees can reflect different defect degrees of the pvc plastic pipe orifice, so that the defects of the pvc plastic pipe orifice can be obtained by analyzing each characteristic, and the application combines three different characteristics, can more comprehensively represent the characteristic information of the pvc plastic pipe orifice, and further obtains the accurate defect judgment result of the pvc plastic pipe orifice.
Detailed Description
In order to further describe the technical means and effects adopted by the present application to achieve the preset purpose, the following detailed description of the specific embodiments, structures, features and effects thereof according to the present application is given with reference to the accompanying drawings and the preferred embodiments. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
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 application belongs.
Referring to fig. 1, a flowchart of a method for detecting defects of a pvc plastic pipe orifice based on image processing according to an embodiment of the present application is shown, the method includes the following steps:
step 1, acquiring a gray image and an HSV image corresponding to a pvc plastic pipe orifice; and carrying out edge detection on the gray level image to obtain at least two contour curves, calculating the distance from each contour curve to the center point of the pvc plastic pipe orifice, and selecting the contour curve corresponding to the minimum distance as a defect contour curve.
In view of the advantages of high sensitivity, high imaging quality and no smear of a CCD camera compared with a CMOS camera, the embodiment utilizes the CCD camera to acquire RGB images corresponding to pvc plastic pipe openings, and in order to clearly and accurately acquire image information corresponding to defects at the pvc plastic pipe openings when the RGB images are acquired, in the embodiment, an LED ring-shaped structure lamp source is used for carrying out illumination treatment on the pvc plastic pipe opening positions above the pvc plastic pipe openings, and then the CCD camera is utilized for overlooking shooting, so that corresponding RGB images are obtained; in this embodiment, the positional relationship among the CCD camera, the LED ring-shaped structure light source, and the pvc plastic pipe to be detected is shown in fig. 2. Thus, the acquired image is a front view of the pvc plastic orifice.
Since the RGB image obtained by shooting with the CCD camera is corresponding to the RGB color space, in the process of capturing the RGB image, the quality of the RGB image is easily affected by the shooting environment, and the low quality RGB image can reduce the accuracy of identifying the defects of the pvc plastic pipe orifice in the subsequent process, so in order to improve the quality of the RGB image and reduce the influence of the shooting environment on the quality of the RGB image, in this embodiment, the Gamma correction method is used to correct the RGB image, and meanwhile, the gaussian filtering method is used to eliminate the noise point in the RGB image, where the Gamma correction and the gaussian filtering are both known techniques, and detailed procedures are not repeated.
In this embodiment, in order to reduce the calculation amount and simplify the identification of the pvc plastic pipe orifice defect, the RGB image is subjected to the graying process to obtain a corresponding gray image, wherein the graying process adopts a weighted average method, and as other embodiments, the practitioner may select any one of the maximum value method, the component method and the average method to perform the graying process on the RGB image. Meanwhile, in order to extract the brightness characteristics at the defective position of the pvc plastic pipe orifice, the RGB image is converted into an HSV image.
After the gray level image is obtained, edge detection is carried out on the gray level image by adopting an EDTER algorithm, at least two contour curves are obtained, the distance between each contour curve and the center point of the pvc plastic pipe orifice is calculated, and the contour curve corresponding to the minimum distance is selected as a defect contour curve. The pvc plastic pipe orifice center point is the point where the pvc plastic pipe axis corresponds to the acquired image. As another embodiment, since the CCD camera is located at a position vertically above the pvc plastic nozzle, the image information corresponding to the pvc plastic nozzle is located at the center position of the entire RGB image for the captured RGB image, so that the position coordinates of the pixel point corresponding to the center point of the pvc plastic nozzle can be obtained from the centroid relation of OpenCVThe specific acquisition process is a well-known technology and will not be described in detail. Specifically, the method for calculating the distance from each profile curve to the center point of the pvc plastic pipe orifice comprises the following steps: calculating the average value corresponding to the distances from all pixel points on the contour curve to the center point of the pvc plastic pipe orifice, wherein the average value is the distance from the corresponding contour curve to the center point of the pvc plastic pipe orifice, and the average value is expressed as the following formula:
wherein D is the distance from any contour curve to the midpoint of the pvc plastic pipe orifice, K is the number of pixel points on the contour curve,the position coordinates of the pixel point corresponding to the center point of the pvc plastic pipe orifice are +.>The position coordinates of the kth pixel point on the contour curve are obtained. Wherein the position coordinates are obtained by an image coordinate system constructed from the gray scale image.
The EDTER algorithm is a Transform-based edge detector, and utilizes complete image context information and detailed local features to extract clear target boundaries and meaningful edges, and the specific process is a known technology and will not be repeated.
When the PVC plastic pipe orifice has an inward concave defect, the shape of the corresponding contour curve at the defect position can be changed greatly, namely, when the PVC plastic pipe orifice does not have the inward concave defect, the shape of each contour curve obtained through edge detection is round, and when the PVC plastic pipe orifice has the inward concave defect, the shape of the corresponding contour curve at the defect position obtained through edge detection is not round. Therefore, the embodiment performs edge detection on the gray level image to obtain each contour curve, calculates the distance from each contour curve to the center point of the pvc plastic pipe orifice, and selects the contour curve corresponding to the minimum distance as the defect contour curve.
And 2, marking the area surrounded by the defect profile curve as a first area, respectively acquiring the maximum length of the first area corresponding to the vertical direction in the horizontal direction, and calculating the appearance characteristic factor of the pvc plastic pipe orifice based on the maximum length, the area of the first area and the length of the defect profile curve.
Since the gray-scale image is built into the two-dimensional coordinate system, the x-axis in the two-dimensional coordinate system can be taken as the horizontal direction and the y-axis as the vertical direction.
The method for calculating the appearance characteristic factors of the pvc plastic pipe orifice comprises the following steps: for the maximum length of the first area corresponding to the vertical direction in the horizontal direction, acquiring a larger value and a smaller value in the two maximum lengths, and calculating the ratio of the larger value to the smaller value to obtain a first characteristic; calculating the ratio of the length of the defect profile curve to the area of the first region to obtain a second characteristic; the product of the first feature and the second feature is a form factor, formulated as:
wherein,,is a profile feature factor->For defect profile->Length of->Is the area of the first region;wherein->Is the larger of the two maximum lengths, +.>For the maximum length of the first region corresponding in the horizontal direction, +.>For the maximum length of the first region corresponding in the vertical direction, +.>As a function of the maximum value;wherein->Is the smaller of the two maximum lengths, < ->For the maximum length of the first region corresponding in the horizontal direction, +.>For the maximum length of the first region corresponding in the vertical direction, +.>To a function that finds the minimum. The maximum length of the first region in the horizontal direction and the vertical direction, the length of the defect contour curve and the area of the first region are all obtained by counting the number of corresponding pixels.
If the pvc plastic pipe orifice has no defect, the shape characteristic of the defect profile curve extracted through the analysis is approximate to a circle, and when the pvc plastic pipe orifice has a defect, the curve characteristic of the extracted defect profile curve is bent and changed due to the bulge formed by inward recessing at the defect position, and the irregular curve characteristic is presented; thus, when the pvc plastic pipe orifice has no defect, the extracted defect contour curve is approximate to a circle, and the defect contour curve is obtained by calculationAnd->The value of (2) is relatively close, the ratio of the two is +.>Near 1; on the contrary, when the PVC plastic tube orifice is defective, the +.>And->The value of (2) is larger than the value of +.>Will be greater than 1, and the greater the ratio the higher the probability of defects occurring in the pvc plastic pipe orifice; meanwhile, when a pvc plastic pipe orifice is defective, the extracted defective profile exhibits a morphology change of irregularities due to the occurrence of defects, and the length of the extracted defective profile is lengthened with respect to a defect-free pvc plastic pipe orifice, i.e., when a pvc plastic pipe orifice is defective>The value of (2) will become larger; and the protrusion formed by the inward depression results in an extracted defect profile +.>The area of the enclosed area is reduced, so that the calculated ratio +.>Will become large; thus form factor->The larger the value of (c) is, the higher the probability of defect occurrence of the PVC plastic pipe orifice is.
Further, the value of the appearance characteristic factor is normalized, namely, the value of the appearance characteristic factor is mapped toIn the interval, in this embodiment, the value of the profile feature factor is normalized by using the method of the maximum-minimum centering operation, and as other embodiments, the practitioner may select other normalization methods, where the normalization is a known technique, and will not be described again. Thus, when a defect occurs at the pvc plastic nozzle location, the profile characteristic factor obtained by calculation +.>The value of (2) becomes larger, i.e. the appearance is specialSyndrome factor->The larger the value is, the higher the probability of defect of the pvc plastic pipe orifice is when the value is close to 1.
Step 3, obtaining a minimum circumcircle corresponding to the defect contour curve; and forming a pixel point pair by any pixel point on the minimum circumscribing circle and any pixel point on the defect contour curve, calculating a weight value of the pixel point pair according to the distance between two pixel points in the pixel point pair and the appearance characteristic factor, and constructing a weight matrix according to the weight value.
In the embodiment, the position coordinates of the pixel points corresponding to the center point of the pvc plastic pipe orificeMinimum circumcircle corresponding to defect contour curve is obtained for the center>If the PVC plastic tube orifice is defect-free, the defect profile obtained by extraction is +.>And minimum circumcircle->The difference should be small. Therefore, according to the defect profile ∈ ->The position coordinates of each pixel point on the display screen are used for obtaining a sequence +.>,/>,/>Characterizing defect contour curves +.>The 1 st pixel pointThe position coordinates of the two points of the object,characterizing defect contour curves +.>Position coordinates of the 2 nd pixel point, < >>Characterizing defect contour curves +.>Position coordinates of the m-th pixel point are arranged; according to the minimum circumcircle->The position coordinates of each pixel point on the display screen are used for obtaining a sequence +.>,,/>Characterization of minimum circumscribed circle->Position coordinates of the 1 st pixel, < ->Characterization of minimum circumscribed circle->Position coordinates of the 2 nd pixel point, < >>Minimum circumcircle->Position coordinates of the nth pixel point are arranged; then forming a pixel point pair by any pixel point on the minimum circumscribing circle and any pixel point on the defect contour curve, and calculating the pixel point pairAnd obtaining the weight value of the pixel point pair by multiplying the distance between two pixel points in the pixel point pair and the appearance characteristic factor.
Specifically, the calculation formula of the weight value is:
wherein,,forming a weight value of a pixel point pair (i, j) for a pixel point i on the minimum circumscribing circle and a pixel point j on the defect contour curve; />Is a profile characteristic factor; />The position coordinates of the pixel point i on the minimum circumscribing circle; />Is the position coordinates of the pixel point j on the defect contour curve.
When no defect occurs in the pvc plastic pipe orifice, the obtained minimum circumcircle and the defect profile curve are similar, the distance between two pixel points in the formed pixel point pair is smaller, and the calculated weight value of the pixel point pair is smaller; when the pvc plastic pipe orifice is defective, the obtained minimum circumcircle has larger morphological difference with the defect contour curve, the obtained distance between two pixel points in the pixel point pair is larger, and the calculated weight value of the pixel point pair is larger; correcting the external feature factor by using the confidence coefficient of the two pixel points in the pixel point pair as the external feature factor to obtain a weight value, wherein when the distance between the two pixel points in the pixel point pair is smaller, the confidence coefficient of the external feature factor is lower, the product of the distance between the two pixel points in the pixel point pair and the external feature factor is used as the weight value, and the characteristic is that the external feature factor is amplified, when the distance is small, the amplification degree is low, and when the distance is large, the amplification degree is high; thus, when pvc plastic pipeWhen the mouth is defective, the obtained defect profile curve has larger deformation, so the weight obtained by calculationIf the value of the pixel point pair is larger, the defect is more likely to occur at the position of the pixel point pair.
And then constructing a weight matrix according to the weight values, wherein the construction of the weight matrix is shown in fig. 3, namely, any pixel point on the defect contour curve and any pixel point on the minimum circumscribing circle can form a pixel point pair. The weight matrix is constructed to solve the problem of the sequence obtained when the PVC plastic pipe orifice has defectsAnd sequence->The problem of inconsistent length of the PVC plastic pipe orifice defect characteristic analysis and research influence caused by unequal sequence lengths is avoided.
And 4, constructing a difference vector based on the maximum weight value corresponding to each row in the weight matrix, and constructing a similarity vector based on the minimum weight value corresponding to each row in the weight matrix.
The weight obtained by calculation is calculated in consideration of the fact that the obtained defect profile curve has larger deformation when the PVC plastic pipe orifice is defectiveIf the value of the (b) is larger, the position of the pixel point pair is more likely to be defective, so that the maximum weight value corresponding to each row in the weight matrix is selected to construct a difference vector +.>Specifically, the maximum weight value corresponding to each row in the weight matrix is taken as a difference vector +.>Elements corresponding to each dimension->Wherein->Representing the set of weight values of row 1 in the weight matrix, +.>Representing the set of weight values of row 2 in the weight matrix, +.>Representing a set formed by weight values of an mth row in the weight matrix; />As a function of the maximum value.
When no defect occurs in the pvc plastic pipe orifice, the shape characteristics of the obtained defect profile curve are approximately equal to the shape characteristics of the minimum circumcircle, so the weight obtained by calculationThe value of (2) is smaller, so that a similarity vector is constructed based on the minimum weight value corresponding to each row in the weight matrix>Specifically, the minimum weight value corresponding to each row in the weight matrix is taken as the element corresponding to each dimension in the similarity vector, +.>Wherein->Representing the set of weight values of row 1 in the weight matrix, +.>Representing the set of weight values of row 2 in the weight matrix, +.>Representing weight value constitution of mth row in weight matrixA collection; />To a function that finds the minimum.
Step 5, marking a region surrounded by the minimum circumscribing circle as a second region, and acquiring a difference value region corresponding to the second region and the first region; and calculating the hue consistency according to the hue value of each pixel point in the difference value area and the hue value of the H channel of each pixel point in the second area in the HSV image.
In this embodiment, the difference operation is performed between the second area and the first area, so as to obtain a difference area corresponding to the second area and the first area, when the pvc plastic pipe orifice has a defect, the tone value of the H channel of each pixel point in the difference area in the HSV image is smaller, the tone value of the H channel of each pixel point in the second area in the HSV image is larger, and the tone values corresponding to each pixel point in different areas have larger difference; when the pvc plastic pipe orifice has no defect, the hue value of the H channel of each pixel point in the difference value area is almost the same as that of the H channel of each pixel point in the second area in the HSV image, and the hue consistency is basically kept consistent, so the hue consistency is calculated through the hue value.
Specifically, the method for acquiring the hue consistency comprises the following steps: calculating the accumulated sum corresponding to the hue values of the H channels of all pixel points in the difference area in the HSV image, and recording the accumulated sum as a first accumulated sum; calculating the accumulation sum corresponding to the hue values of the H channels of all the pixel points in the second area in the HSV image, and recording the accumulation sum as a second accumulation sum, wherein the ratio of the first accumulation sum to the second accumulation sum is hue consistency, and the hue consistency is expressed as follows by a formula:
wherein,,characterization of hue consistency->Characterizing the difference region, ++>The position coordinates of the pixel point u are represented, and the pixel point u is in the difference area +.>In (a) and (b); />Characterizing position coordinates>Hue value of H channel of pixel point u in HSV image; />Characterizing the second region; />The position coordinates of the pixel point v are characterized, and the pixel point v is in the second area +.>In (a) and (b);characterizing position coordinates>The hue value of the H-channel in the HSV image for pixel point v at.
Characterization of the difference region +.>Corresponding accumulated sums of tone values of H channels of all pixel points in the HSV image, namely a first accumulated sum; />Characterization of the second region +.>Corresponding accumulated sums of tone values of H channels of all pixel points in the HSV image, namely second accumulated sums;when the PVC plastic pipe orifice is defective, the black part in the middle of the PVC plastic pipe, namely the background part, is shielded by the bulge formed by the inward recession at the defective position, and the shielded part appears white, so when->The larger the value of (c) is, the more the occluded part is characterized, the larger and more obvious the defect is, based on which, when the value of hue consistency is larger, the larger and more obvious the defect is characterized at the pvc plastic pipe orifice.
Further, in order to intuitively reflect the positional relationship among the difference region, the second region, the minimum circumscribing circle and the defect profile curve, fig. 4 is provided in this embodiment, and fig. 4 intuitively reflects the positional relationship among the difference region, the second region, the minimum circumscribing circle and the defect profile curve; wherein the standard circle in FIG. 4 is the minimum circumscribing circleDefect contour curve formed by the dotted line part and the long circular arc in fig. 4 +.>The area surrounded by the broken line part and the short circular arc in FIG. 4 is a difference area +.>Minimum circumscribed circle +.>The enclosed region is the second region +.>。
And 6, calculating a defect characteristic vector according to the similarity vector, the difference vector and the hue consistency, and judging whether the PVC plastic pipe orifice has defects or not based on the defect characteristic vector.
The method for calculating the defect characteristic vector comprises the following steps: and respectively carrying out transposition operation on the similarity vector and the difference vector to obtain a vector transposed by the similarity vector and the difference vector, constructing a new matrix according to the vector transposed by the similarity vector and the difference vector, and taking the product of the hue consistency and the new matrix as a defect characteristic vector.
The method for constructing the new matrix comprises the following steps: and taking each element in the vector transposed by the similarity vector as an element of a first column in the new matrix, and taking each element in the vector transposed by the difference vector as an element of a second column in the new matrix.
The defect feature vector is formulated as:
wherein,,is a defect feature vector; />For consistency of hue>Is a transposition operation; />For the difference vector, ++>Is a similarity vector; />A set formed by the weight values of the 1 st row in the weight matrix; />A set formed by weight values of an mth row in the weight matrix; />As a function of the maximum value; />A function for obtaining a minimum value; />In the form of a matrix.
In the formula, the hue is consistentThe color characteristic corresponding to the defect of the PVC plastic pipe orifice is represented by the tone value, the difference vector and the similarity vector are obtained through weight values in a weight matrix, the weight values are obtained through distances between the shape characteristic factors and two pixel points in the pixel point pair, the shape characteristic factors represent the shape characteristic of the defect contour curve, the distances can represent the spatial positions of the pixel point pair, so that the difference vector and the similarity vector combine the shape characteristic and the spatial position, and based on the fact, the defect characteristic vector combines the color characteristic, the shape characteristic and the spatial position characteristic, the characteristic information of the PVC plastic pipe orifice can be more comprehensively represented, and an accurate information basis is provided for the subsequent judgment and identification result.
After the defect characteristic vector is obtained, the defect characteristic vector is input into a classifier, and whether the pvc plastic pipe orifice has defects is judged according to the output result. In this embodiment, the SVM judger is selected as the classifier, that is, when the output result of the SVM judger is 0, it is determined that the pvc plastic pipe orifice is not defective, and when the output result of the SVM judger is 1, it is determined that the pvc plastic pipe orifice is defective.
Before the SVM judger is used, a related technician is required to train the SVM judger, so that whether the PVC plastic pipe orifice has defects can be accurately judged according to the output result of the SVM judger. The training set in training is a corresponding defect characteristic vector when the PVC plastic pipe orifice is defective and a corresponding defect characteristic vector when the PVC plastic pipe orifice is not defective, then labels 0 and 1 are manually marked on the training set, the label 0 corresponds to the corresponding defect characteristic vector when the PVC plastic pipe orifice is not defective, and the label 1 corresponds to the corresponding defect characteristic vector when the PVC plastic pipe orifice is defective. During training, an SMO algorithm is used for optimization; the specific training process of the SVM judgment device is a known technology and is not in the protection scope of the present application, so that the description is omitted.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application and are intended to be included within the scope of the application.