Disclosure of Invention
The invention provides a mobile hard disk box production quality rapid detection system, which solves the problem that the surface frosted particles of the existing mobile hard disk box affect defect detection, and adopts the following technical scheme:
one embodiment of the present invention provides a system for rapidly detecting production quality of a mobile hard disk cartridge, comprising:
the hard disk box image acquisition module acquires a mobile hard disk box image and grays the mobile hard disk box image to obtain a gray image;
the target corner screening module: detecting the gray image corner points to obtain a plurality of initial corner points, and obtaining the integral distribution characteristics and representative straight lines of each initial corner point according to the distance and the distribution direction between the initial corner points;
obtaining the target degree of each initial angular point according to the overall distribution characteristics, the local distribution characteristics and the representative straight line of each initial angular point, and screening according to the target degree to obtain a plurality of target angular points;
and the hard disk box quality judging module is used for obtaining the difference degree of the products to be detected according to the target angular point distribution of the products to be detected and the standard samples and finishing the production quality detection of the mobile hard disk box according to the difference degree.
Further, the method for obtaining the overall distribution characteristics and the representative straight lines of each initial corner point comprises the following specific steps:
acquiring angular point distribution characteristics of each detection straight line of each initial angular point according to the distance and the distribution direction between the initial angular points; calculating the absolute value of the difference value of the angular point distribution characteristics of any two detection lines of the reference initial angular point by taking any one initial angular point as the reference initial angular point, and recording the absolute value as the angular point distribution difference;
taking the product of the maximum value of all angular point distribution differences of the reference initial angular point and the average value of angular point distribution characteristics of the reference initial angular point as the integral distribution coefficient of the reference initial angular point; obtaining the overall distribution coefficient of each reference initial angular point, and carrying out linear normalization on the overall distribution coefficients of all the initial angular points, wherein the obtained result is used as the overall distribution characteristic of each initial angular point;
and obtaining a representative straight line of each initial angular point according to the angular point distribution characteristics of each detection straight line of each initial angular point.
Further, the specific obtaining method includes:
taking any initial angular point as a reference initial angular point, taking straight lines by passing through the reference initial angular point, uniformly obtaining a plurality of straight lines, and recording the straight lines as detection straight lines of the reference initial angular point; acquiring the number of initial angular points on each detection straight line and the distance between any two adjacent initial angular points on the same detection straight line;
obtaining the maximum distance between all adjacent two initial angular points on all detection straight lines, and recording the maximum distance as the maximum distance of the reference initial angular points; taking any one detection straight line as a reference detection straight line, acquiring the average value of the distances between all adjacent two initial angular points on the reference detection straight line, and recording the ratio of the average value to the maximum distance as the angular point distribution characteristic of the reference detection straight line;
and acquiring angular point distribution characteristics of each detection straight line of each initial angular point.
Further, the method for obtaining the representative straight line of each initial angular point according to the angular point distribution characteristics of each detection straight line of each initial angular point comprises the following specific steps:
taking any initial angular point as a reference initial angular point, taking any detection straight line of the reference initial angular point as a reference detection straight line, obtaining the average value of differences obtained by subtracting the angular point distribution characteristics of other detection straight lines of the reference initial angular point from the angular point distribution characteristics of the reference detection straight line respectively, recording the average value as the angular point difference characteristics of the reference detection straight line, obtaining the angular point difference characteristics of each detection straight line of the reference initial angular point, and taking the detection straight line with the largest angular point difference characteristics as a representative straight line of the reference initial angular point;
and obtaining a representative straight line of each initial corner point.
Further, the specific obtaining method of the target degree of each initial corner point comprises the following steps:
according to the number of the initial angular points of the adjacent windows of the window where the initial angular points are located and the gradient difference in the windows, combining the representative straight lines to obtain local distribution characteristics of each initial angular point and reference weights of the local distribution characteristics;
for any initial corner point, the target degree of the initial corner pointThe calculation method of (1) is as follows:
wherein ,representing the overall distribution characteristics of the initial corner points, +.>Representing the local distribution characteristics of the initial corner points +.>Reference weights representing local distribution characteristics of the initial corner points; and obtaining the target degree of each initial corner point.
Further, the obtaining the local distribution feature of each initial corner and the reference weight of the local distribution feature comprises the following specific methods:
obtaining local distribution characteristics of each initial corner according to the number of the initial corners of adjacent windows of the window where the initial corner is located and gradient differences in the windows; taking any initial corner as a reference initial corner, acquiring the gradient direction of each initial corner on a representative straight line of the reference initial corner, calculating the variance of the gradient directions of all initial corners on the representative straight line, and calculating the reference weight of the local distribution characteristics of the reference initial corner, wherein the calculation method comprises the following steps:
wherein ,gradient direction variance of all initial corner points on representative straight line representing reference initial corner points, ++>To avoid superparameters with too small reference weight values, < ->An exponential function that is based on a natural constant;
and acquiring the reference weight of the local distribution characteristic of each initial corner point.
Further, the specific obtaining method of the local distribution characteristics of each initial corner point comprises the following steps:
constructing a window in which each initial corner is positioned, acquiring a plurality of adjacent windows of the window in which each initial corner is positioned, acquiring a corner marking value and a gradient of a center point of each adjacent window, and acquiring the gradient of each initial corner;
taking any initial corner point as a reference initial corner point, and referring to local distribution characteristics of the initial corner pointsThe calculation method of (1) is as follows:
wherein ,representing the number of neighboring windows with respect to the window in which the initial corner point is located,/->Indicate->Corner mark values of adjacent windows, +.>Representing the maximum value of the gray level similarity degree of the window where the adjacent window and the reference initial corner point are located; />Indicate->Gray level similarity of each adjacent window and the window where the reference initial corner point is located, < >>Indicate->Gradient direction of the center point of each adjacent window, +.>Representing the gradient direction with reference to the initial corner point +.>Indicate->Gradient magnitude of the center point of each adjacent window, +.>Representing the gradient magnitude with reference to the initial corner, +.>Representation absolute values 180 and 255 are used to normalize the gradient direction and gradient magnitude +.>An exponential function that is based on a natural constant;
and obtaining the local distribution characteristics of each initial corner point.
Further, the specific obtaining method includes:
taking any initial corner point as a reference initial corner point, acquiring a plurality of adjacent windows of the window where the reference initial corner point is located, and for any adjacent window, if the initial corner point exists in the adjacent window, marking the corner point marking value of the adjacent window as 1, and marking the corner point marking value as 0 without the initial corner point;
calculating the gradient of the center point of each adjacent window; and acquiring the corner mark value and the gradient of the center point of each adjacent window.
Further, the method for obtaining the difference degree of the product to be detected comprises the following specific steps:
obtaining a target corner point of a product to be detected and a target corner point of a standard sample; for a product to be detected, acquiring the area of a minimum circumscribed rectangle containing all target corner points, simultaneously acquiring the distance between each target corner point and other target corner points with the minimum distance, taking the ratio of the area of the minimum circumscribed rectangle to the sum of the distances as the corner point distribution degree of the product to be detected, and acquiring the corner point distribution degree of a standard sample;
obtaining the ratio of the angular point distribution degree of the product to be detected to the angular point distribution degree of the standard sample, and recording the absolute value of the difference value obtained by subtracting the ratio from 1 as the difference degree of the product to be detected.
The beneficial effects of the invention are as follows: according to the invention, a plurality of initial corner points are obtained by carrying out corner point detection on the gray level image on the surface of the mobile hard disk box, the target degree is obtained by analyzing the overall distribution characteristics and the local distribution characteristics of the initial corner points, further the target corner points are obtained, the difference degree is obtained by the distribution of the target corner points among products, the production quality judgment is completed, excessive invalid corner points generated by the frosted particles on the surface of the mobile hard disk box are avoided, and the difference exists between the frosted particles of different products, so that the accuracy of the production quality result obtained according to the corner points is influenced; the whole distribution characteristics are obtained through the discrete distribution degrees of the initial angular points in different distribution directions, the local distribution characteristics are quantitatively obtained through the aggregation degrees of the initial angular points in the range of the initial angular points and the ductility of gray level change to a certain extent, the whole distribution characteristics and the local distribution characteristics enable the target degree of the initial angular points generated by the contour edges to be larger, and then the target angular points can be screened out through the target degree, so that the accuracy of the mobile hard disk box production quality detection result is improved.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a block diagram of a system for rapidly detecting production quality of a mobile hard disk cartridge according to an embodiment of the invention is shown, the system includes:
the hard disk cartridge image acquisition module 101 acquires a mobile hard disk cartridge image, and grays the mobile hard disk cartridge image to obtain a gray image.
The purpose of this embodiment is to detect the production quality of the mobile hard disk cartridge, so it is first necessary to acquire the image of the mobile hard disk cartridge; shooting a mobile hard disk box of a discharge hole through an industrial camera in the production process of the production line, and performing semantic segmentation on the shot image, wherein a semantic segmentation network adopts an encoding-decoding structure of a DNN network, a large number of mobile hard disk box images are obtained through the Internet to serve as a training data set, the images in the training data set are labeled, pixel points belonging to the mobile hard disk box in the images are labeled as 1, pixel points belonging to the background part in the images are labeled as 0, a loss function adopts a cross entropy loss function, and the semantic segmentation network is trained through the training data set to obtain a trained semantic segmentation network; inputting the shot image into a semantic segmentation network, outputting to obtain an image only containing the mobile hard disk cartridge, and recording the image as a mobile hard disk cartridge image without a background part; and carrying out graying treatment on the mobile hard disk box image to obtain a gray image.
Thus, a grayscale image of the portable hard disk cartridge is obtained.
Target corner screening module 102:
it should be noted that, due to the granular sensation of the frosted article, the utility of the corner points detected in the corner point detection is not high, the detected corner points need to be further screened, and effective corner points are selected for corner point matching; the particles of the frosted product are disordered, the angular points are distributed in a relatively concentrated mode, the target degree of the angular points is judged according to the aggregation degree of the angular points and the distribution information of the angular points in a local range, the normally acquired angular points cannot be excessively concentrated, the target angular points are screened through the whole aggregation degree judgment and the local distribution information, and then the angular points are matched with the standard sample through the target angular points, so that the production quality judgment of the mobile hard disk box is realized.
(1) Detecting the gray image corner points to obtain a plurality of initial corner points, and acquiring the overall distribution characteristics of each initial corner point according to the distance and the distribution direction between the initial corner points.
It should be noted that, the grayscales of the granular objects with the frosted feeling of the mobile hard disk are disordered, the gray level changes are scattered, the part of the area may be detected as corner points, but the part of the area is caused by the frosted granular objects, the frosted areas of the two qualified products are not identical due to the manufacturing process, the corner points of the frosted areas may influence the judgment of the defect condition of the product to be detected, therefore, the corner points need to be further screened, the target degree of the corner points is judged, and the corner points generated at the frosted areas are eliminated to obtain effective corner points; according to priori knowledge, the surface of the mobile hard disk box is smooth, frosted texture is in disordered distribution when being observed in a part, but gray distribution of the frosted texture is the same as gray change trend of the whole image when being observed in whole, so that judgment of the whole angular point distribution is carried out on each initial angular point, and the whole distribution characteristics of the angular points are obtained.
Specifically, firstly, performing corner detection on a gray image to obtain a plurality of corners marked as initial corners, wherein the corner detection is a known technology, and the embodiment is not repeated, so that a plurality of initial corners in the gray image are obtained.
Further, taking any initial angular point as an example, taking the initial angular point as a straight line, and uniformly obtainingStraight line, the present embodiment adopts +.>Describing, namely, obtaining a straight line every 10 degrees within the 360-degree range, and recording a plurality of obtained straight lines as detection straight lines of the initial angular points; for each detection straight line, acquiring the number of initial angular points on each detection straight line and the distance between any two adjacent initial angular points on the same detection straight line, wherein the distance is calculated by adopting Euclidean distance, and the adjacent angular points are the initial angular points which are adjacent in sequence on the detection straight line; obtaining the maximum distance between all adjacent two initial angular points on all detection straight lines, and recording the maximum distance as the maximum distance of the initial angular points; for any one detection straight line, acquiring the average value of the distances between all adjacent two initial angular points on the detection straight line, and recording the ratio of the average value to the maximum distance as the angular point distribution characteristic of the detection straight line; obtaining the angular point distribution characteristics of each detection straight line of the initial angular point according to the method, calculating the absolute value of the difference value of the angular point distribution characteristics of any two detection straight lines, marking the absolute value as angular point distribution difference, and taking the product of the maximum value of the angular point distribution difference and the average value of the angular point distribution characteristics as the angular point distribution differenceThe overall distribution coefficient of the initial corner points; meanwhile, for any one detection straight line, obtaining the average value of the difference value obtained by subtracting the angular point distribution characteristic of each detection straight line from the angular point distribution characteristic of the other detection straight lines, recording the average value as the angular point difference characteristic of the detection straight line, obtaining the angular point difference characteristic of each detection straight line, and taking the detection straight line with the largest angular point difference characteristic as the representative straight line of the initial angular point; the overall distribution coefficient and the representative straight line of each initial angular point are obtained according to the method, the overall distribution coefficient of all the initial angular points is subjected to linear normalization, and the obtained result is used as the overall distribution characteristic of each initial angular point.
So far, the integral distribution characteristics and representative straight lines of each initial angular point are obtained, the integral distribution characteristics reflect the angular point distribution and aggregation degree of each initial angular point in different distribution directions, the integral distribution characteristics are obtained by the angular point distribution difference maximum value and the angular point distribution characteristic mean value, the larger the angular point distribution difference is, the fewer the initial angular points exist and the distribution discrete detection straight lines are, and the larger the probability that the initial angular point is a target angular point is; the larger the characteristic mean value of the angular distribution is, the more discrete the initial angular distribution in different directions is and the farther the distance is, the larger the probability of being the target angular point is; the representative straight line can reflect the probability that the initial corner point is the target corner point to the greatest extent, and the representative straight line is the detection straight line with the minimum initial corner point number and the most discrete distribution in the distribution direction and is used for subsequent quantification of the reference weight of the whole and local information.
(2) According to the number of the initial corner points of the adjacent windows of the window where the initial corner points are located and the gradient difference in the windows, local distribution characteristics of each initial corner point are obtained, the target degree of each initial corner point is obtained by combining the overall distribution characteristics, and the target corner points are obtained through screening.
After the overall distribution characteristics are obtained, the local distribution information is required to be further judged, a window is constructed for each initial angular point, the local distribution characteristics of each initial angular point are obtained according to the number of the initial angular points in the adjacent windows and the gradient difference between the windows, the smaller the number of the initial angular points in the adjacent windows is, the smaller the local aggregation degree of the initial angular points is, the larger the probability of belonging to the target angular points is, and the local distribution characteristics are larger; and combining gradient differences, wherein the smaller the gradient differences are, the larger the similarity degree of gray distribution among windows is, certain ductility exists among the windows, the better the ductility is indicates that the initial corner points are generated by intersecting edges with certain length, and the larger the probability of the initial corner points belongs to the target corner points is, and the larger the local distribution characteristics are.
Specifically, for each initial corner point, the initial corner point is constructed to be taken as the center,a window of size, this embodiment uses +.>Describing, namely, marking the window as the window of the initial corner point, and simultaneously acquiring a plurality of adjacent windows of the window, wherein the number of the adjacent windows is described by 8, namely, eight adjacent windows of the window are acquired in an eight-neighborhood range of similar pixel points, and it is required to be noted that if the window and the adjacent windows exceed the boundary range of the gray level image, filling and complementing the window by adopting a quadratic linear interpolation method; for any adjacent window, if an initial corner exists in the adjacent window, the corner marking value of the adjacent window is marked as 1, and if the initial corner does not exist, the corner marking value is marked as 0, and meanwhile, for the adjacent window, a gradient of a central point of the adjacent window, including the direction of the gradient and the amplitude of the gradient, is obtained by utilizing a Sobel operator; acquiring the corner mark value and the gradient of the center point of each adjacent window according to the method, and acquiring the gradient of the initial corner at the same time, so that the local distribution characteristic of the initial corner is ∈ ->The calculation method of (1) is as follows:
wherein ,representing the number of adjacent windows +.>Indicate->Corner mark values of adjacent windows, +.>A maximum value representing the gray level similarity degree of the adjacent window and the window where the initial corner point is located; />Indicate->Gray level similarity of each adjacent window and the window where the initial corner point is located, +.>Indicate->Gradient direction of the center point of each adjacent window, +.>Representing the gradient direction of the initial corner point, +.>Indicate->Gradient magnitude of the center point of each adjacent window, +.>Gradient magnitude representing the initial corner, +.>Representation absolute determinationThe pair values, 180 and 255, are used to normalize the gradient direction and gradient magnitude, +.>Representing an exponential function based on natural constants, the present embodiment employs +.>The inverse proportion relation and normalization processing are presented, and an implementer can set an inverse proportion function and a normalization function according to actual conditions; the smaller the gradient amplitude and gradient direction difference is, the larger the gray level similarity is, the maximum value of the gray level similarity is selected to quantify the ductility, and the larger the ductility is, the larger the local distribution characteristic is; meanwhile, the smaller the average value of the corner marking values is, the smaller the number of adjacent windows with initial corners is, and the larger the local distribution characteristics are; and obtaining the local distribution characteristics of each initial corner point according to the method.
It should be further noted that, for each initial corner, the reference weights of the overall distribution feature and the local distribution feature need to be quantized according to the representative straight line, which represents that a plurality of initial corners exist on the straight line, the smaller the variance between gradient directions of the initial corners is, the larger the gradient direction consistency of the initial corners on the representative straight line is, the more likely the representative straight line is a contour edge portion, and the more the local distribution feature should be considered to quantize the target degree of the corners.
Specifically, taking any initial corner as an example, for a representative straight line of the initial corner, where the gradient direction of each initial corner is known, calculating variance for the gradient directions of all initial corners on the representative straight line, and then determining the reference weight of the local distribution feature of the initial corner, wherein ,/>Gradient direction variance of all initial corner points on representative straight line representing the initial corner point, ++>To avoid ginsengSuper-parameters with too small test weight values are adopted in the embodiment>To make a description of->Representing an exponential function based on natural constants, the present embodiment employs +.>The inverse proportion relation and normalization processing are presented, and an implementer can set an inverse proportion function and a normalization function according to actual conditions; the target degree of the initial corner point +.>The calculation method of (1) is as follows:
wherein ,representing the overall distribution characteristics of the initial corner points, +.>Representing the local distribution characteristics of the initial corner points +.>Reference weights representing local distribution characteristics of the initial corner points; according to the method, the target degree of each initial corner is obtained, a target threshold is preset for judging the target corner, the target threshold is described by 0.7, the initial corner with the target degree larger than the target threshold is taken as the target corner, the initial corner with the target degree smaller than or equal to the target threshold is not extracted, and a plurality of target corners are obtained.
So far, the local distribution characteristics of the initial angular points are obtained through judging the local distribution information of the initial angular points, the target degree is obtained by combining the overall distribution characteristics, and the target angular points are obtained through screening.
The hard disk box quality judging module 103 obtains the difference degree of the products to be detected according to the distribution of the target corner points, and completes the production quality detection of the mobile hard disk box according to the difference degree.
After the target corner is obtained, the target corner is obtained according to the method for the product to be detected and the standard sample, and then the target corner is matched so as to finish the production quality detection; the number and position information difference of the target angular points detected by the angular points between the normal products are small; if the product has defects, the number of target corner points is increased, and the position matching of the target corner points has great difference, the difference degree between the target corner point information of the product to be detected and the target corner point information of the standard sample is calculated according to the comparison, and the probability of the defects of the mobile hard disk box can be determined according to the difference degree; analyzing the angular point distribution characteristics of normal products, and analyzing the angular point distribution differences between the products to be detected and the standard samples; if the difference of the angular points is calculated only in one-to-one correspondence, the angles of the product to be detected and the standard sample are rotated, so that the angular points at the same position of the product to be detected and the standard sample are not successfully matched.
Specifically, for any product to be detected and providing a standard sample for production quality detection, acquiring a target corner point of the product to be detected and a target corner point of the standard sample according to the method; for a product to be detected, acquiring the area of a minimum circumscribed rectangle containing all target corner points, simultaneously acquiring the distance between each target corner point and other target corner points with the minimum distance, taking the ratio of the area of the minimum circumscribed rectangle to the sum of the distances as the corner point distribution degree of the product to be detected, and acquiring the corner point distribution degree of a standard sample according to the method; obtaining the ratio of the angular point distribution degree of the product to be detected to the angular point distribution degree of the standard sample, and recording the absolute value of the difference value obtained by subtracting the ratio from 1 as the difference degree of the product to be detected.
Further, in this embodiment, two quality thresholds are preset for judging the production quality of the product to be detected, wherein the two quality thresholds are respectively described by 0.3 and 0.7, and if the difference degree is less than or equal to 0.3, the quality of the product to be detected is superior; if the difference degree is more than 0.3 and less than or equal to 0.7, the quality of the product to be detected is a normal product; if the difference degree is more than 0.7, the product to be detected is a poor product, and the production quality is unqualified.
Thus, the production quality detection of the mobile hard disk cartridge is completed.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.