Capacitive rubber plug cutting production quality detection method and system based on machine vision
By performing grayscale and binarization processing on the capacitor plug image, the midpoint coordinates of the electrode hole and the plug are obtained, and the distance between them is calculated. This solves the problem of difficulty in identifying electrode hole position deviation in the existing technology and improves the accuracy of cutting detection.
Patent Information
- Application Number
- CN202510493663.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-04-18
AI Technical Summary
In existing capacitor plug cutting and inspection technologies, it is difficult to accurately identify electrode hole position deviations, resulting in a low cutting pass rate.
By performing grayscale and binarization processing on the capacitor plug image, the midpoint coordinates of the electrode hole and the plug are obtained, the distance between them is calculated, and compared with the preset qualified distance range to determine whether the cutting position is deviated.
It improves the accuracy of capacitor plug cutting inspection, can more accurately identify cutting position deviations, and increases the accuracy of identifying qualified cut products.
Smart Images

Figure CN120160544B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of cutting detection of rubber plugs, in particular to a cutting production quality detection method and system for capacitive rubber plugs based on machine vision. BACKGROUND
[0002] In the production process of capacitive rubber plugs, there are steps such as extrusion, vulcanization and cutting. Cutting is the last step to determine the quality of capacitive rubber plugs, so the effect after cutting needs to be detected.
[0003] The existing capacitive rubber plug cutting detection method is trained by a model or detected manually. Both detection methods have obvious detection effects on the defects caused by cutting. However, the electrode hole of the capacitive rubber plug is relatively fixed in position on the rubber plug. If the cutting position deviates slightly, it is difficult to identify the error through training and human eye recognition, resulting in low accuracy of identifying the cutting qualified capacitive rubber plug. For example, in the patent application with the publication number CN104677908A, a punching section quality detection system and method based on machine vision are disclosed. The method detects the defects caused by cutting and fails to detect the product itself accordingly, resulting in low accuracy of identifying the cutting qualified capacitive rubber plug. In the existing capacitive rubber plug cutting detection technology, it is difficult to identify the deviation of the electrode hole position by using artificial or model training, resulting in low accuracy of identifying the cutting qualified capacitive rubber plug. SUMMARY
[0004] The application aims to at least solve one of the technical problems in the prior art. The capacitive rubber plug graph is subjected to gray scale processing and binary processing to obtain a capacitive rubber plug binary graph and an electrode hole binary graph. The midpoint coordinates of the capacitive rubber plug binary graph and the electrode hole binary graph are obtained based on a class midpoint acquisition method and are marked as rubber plug class midpoint coordinates and electrode hole class midpoint coordinates, respectively. The distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates is obtained and is marked as a monitoring distance. The qualified distance range is obtained based on the first number of qualified capacitive rubber plug images. It is judged whether the monitoring distance is within the qualified distance range. If yes, the cutting position of the capacitive rubber plug is not deviated. If no, the cutting of the capacitive rubber plug is deviated. The problem of low accuracy of identifying the cutting qualified capacitive rubber plug in the existing capacitive rubber plug cutting detection technology is solved.
[0005] To achieve the above-mentioned purpose, in a first aspect, the application provides a capacitive rubber plug cutting production quality detection method based on machine vision, which comprises the following steps:
[0006] An image of the capacitive rubber plug after cutting is obtained and is marked as a capacitive rubber plug graph.
[0007] The capacitive rubber plug graph is subjected to gray scale processing to obtain a capacitive rubber plug gray scale graph. The capacitive rubber plug gray scale graph is subjected to binary processing to obtain a capacitive rubber plug binary graph.Figure Two The binarization processing obtains a capacitive rubber plug binary image and an electrode hole binary image;
[0008] The midpoint coordinates of the capacitive rubber plug binary image and the electrode hole binary image are obtained based on the class midpoint obtaining method, and are marked as rubber plug class midpoint coordinates and electrode hole class midpoint coordinates respectively. The distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates is obtained, and is marked as a monitoring distance;
[0009] The qualified distance range is obtained based on the first number of qualified capacitive rubber plug images;
[0010] It is judged whether the monitoring distance is within the qualified distance range. If it is, the shearing position of the capacitive rubber plug is not deviated. If it is not, the shearing of the capacitive rubber plug is deviated.
[0011] Further, the capacitive rubber plug image is subjected to grayscale processing to obtain a capacitive rubber plug grayscale image, including the following sub-steps:
[0012] The RGB values of all pixel points in the capacitive rubber plug image are obtained, and are marked as rubber plug RGB values;
[0013] All rubber plug RGB values are converted into grayscale values using a weighted average method, and are marked as rubber plug grayscale values. The weighted average method formula is:
[0014] JSH = ar*R + ag*G + ab*B; wherein JSH is the rubber plug grayscale value, wherein ar, ag, and ab are weight coefficients of R, G, and B respectively, and R, G, and B are R value, G value, and B value in the rubber plug RGB value.
[0015] Further, the capacitive rubber plug grayscale Figure Two The binarization processing obtains a capacitive rubber plug binary image and an electrode hole binary image, including the following sub-steps:
[0016] The rubber plug grayscale values from 0 to 255 are evenly divided into c intervals, and are marked as rubber plug grayscale intervals;
[0017] The frequency of the rubber plug grayscale values in each rubber plug grayscale interval is counted respectively, and is marked as rubber plug grayscale interval frequency;
[0018] A histogram is drawn with the rubber plug grayscale value as the X-axis and the rubber plug grayscale interval frequency as the Y-axis, and is marked as a rubber plug grayscale histogram.
[0019] Further, the capacitive rubber plug grayscale Figure Two The binarization processing obtains a capacitive rubber plug binary image and an electrode hole binary image, including the following sub-steps:
[0020] In the rubber plug grayscale histogram, the rubber plug grayscale interval with a rubber plug grayscale interval frequency greater than that of the two adjacent intervals is obtained, and is marked as a top peak interval;
[0021] Obtain any one peak interval, marked as a reference interval;
[0022] Obtain the peak interval closest to the reference interval on the left and right sides of the X-axis, and mark it as an adjacent peak interval;
[0023] Obtain all the rubber plug gray intervals between the reference interval and any one adjacent peak interval on the X-axis, and mark them as intermediate intervals;
[0024] Calculate the difference between the reference interval and all the intermediate intervals, and mark it as the peak-valley difference;
[0025] Obtain the intermediate interval corresponding to the minimum value of the peak-valley difference, and mark it as the threshold interval, and obtain all the threshold intervals;
[0026] Mark the threshold interval with the smallest range as the smaller threshold interval;
[0027] Mark the threshold interval with the largest range as the larger threshold interval;
[0028] Obtain the middle value of the smaller threshold interval on the X-axis, and mark it as the smaller threshold value;
[0029] Obtain the middle value of the larger threshold interval on the X-axis, and mark it as the larger threshold value.
[0030] Further, the capacitance rubber plug gray Figure Two value processing obtains a capacitance rubber plug binary image and an electrode hole binary image, and further includes the following sub-steps:
[0031] In the capacitance rubber plug gray image, set the rubber plug gray value less than or equal to the smaller threshold value to 0, and set the rubber plug gray value greater than the smaller threshold value to 255, to obtain the electrode hole binary image;
[0032] In the capacitance rubber plug gray image, set the rubber plug gray value less than or equal to the larger threshold value to 0, and set the rubber plug gray value greater than the larger threshold value to 255, to obtain the capacitance rubber plug binary image.
[0033] Further, the midpoint coordinates of the capacitance rubber plug binary image and the electrode hole binary image are obtained based on the midpoint obtaining method, which includes the following sub-steps:
[0034] Establish a plane rectangular coordinate system, marked as the midpoint coordinate system;
[0035] Place the electrode hole binary image in the first quadrant of the midpoint coordinate system, so that the lower left corner of the electrode hole binary image coincides with the origin, and the wide side of the electrode hole binary image coincides with the Y-axis;
[0036] Mark the area with a gray value of 0 in the electrode hole binary image as the electrode hole region;
[0037] The class midpoint acquisition method is used to acquire the class midpoint coordinates of the electrode hole region, which are marked as electrode hole midpoint coordinates;
[0038] The placement of the capacitor rubber plug binary image in the first quadrant of the midpoint coordinate system is performed, so that the lower left corner of the capacitor rubber plug binary image coincides with the origin, and the wide side of the capacitor rubber plug binary image coincides with the Y axis;
[0039] The region with a gray value of 0 in the capacitor rubber plug binary image is marked as a rubber plug region;
[0040] The class midpoint acquisition method is used to acquire the class midpoint coordinates of the rubber plug region, which are marked as rubber plug class midpoint coordinates;
[0041] The distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates is calculated, which is marked as a monitoring distance.
[0042] Further, the class midpoint acquisition method comprises:
[0043] The maximum and minimum values of the horizontal coordinates of the electrode hole region are acquired, which are marked as Xmax and Xmin, respectively;
[0044] The maximum and minimum values of the vertical coordinates of the electrode hole region are acquired, which are marked as Ymax and Ymin, respectively;
[0045] A line segment connecting (Xmin, Ymax) and (Xmin, Ymin) is acquired, which is marked as a wide line segment;
[0046] A line segment connecting (Xmin, Ymin) and (Xmax, Ymin) is acquired, which is marked as a long line segment;
[0047] A perpendicular line of the wide line segment passing through the midpoint of the wide line segment is drawn, which is marked as a wide perpendicular line;
[0048] A perpendicular line of the long line segment passing through the midpoint of the long line segment is drawn, which is marked as a long perpendicular line;
[0049] The intersection coordinates of the wide perpendicular line and the long perpendicular line are acquired, which are marked as class midpoint coordinates.
[0050] Further, the qualified distance range based on the first number of qualified capacitor rubber plug images comprises the following sub-steps:
[0051] The first number of qualified capacitor rubber plug images are acquired, the capacitor rubber plug images are subjected to grayscale and binary processing to obtain normal capacitor rubber plug binary images and normal electrode hole binary images, the midpoint coordinates of the normal capacitor rubber plug binary images and the normal electrode hole binary images are acquired based on the class midpoint acquisition method, and the distance between the midpoint coordinates of the normal capacitor rubber plug binary images and the normal electrode hole binary images is calculated, which is marked as a qualified distance;
[0052] Calculate the qualified distance of all the capacitive rubber plug images, divide the qualified distance into c2 intervals, and mark them as qualified intervals;
[0053] Count the frequency of the qualified distance of each qualified interval, and mark it as the qualified interval frequency;
[0054] Establish a plane rectangular coordinate system with the qualified distance as the abscissa and the qualified interval frequency as the ordinate, and mark it as the qualified coordinate system;
[0055] Get the middle value of each qualified interval, and mark it as the interval middle value;
[0056] Draw the interval middle value and the corresponding qualified interval frequency into the qualified coordinate system as data points to obtain the qualified scatter plot;
[0057] Set the preset fitting function as:
[0058]
[0059] Where Ps is the qualified interval frequency, Qz is the qualified distance, d1 and d2 are parameters, π is the circular constant, and e is the natural constant;
[0060] Mark the data points of the qualified scatter plot as qualified data points;
[0061] Use the preset fitting function as the fitting model to normally fit the qualified data points to obtain the specific values of d1 and d2;
[0062] Set the qualified distance range as (0, d2+2*d1).
[0063] Further, the method for judging whether the monitoring distance is within the qualified distance range comprises the following steps:
[0064] Determine whether the monitoring distance is within the qualified distance range. If it is, the shear position of the capacitive rubber plug is not deviated. If it is not, the capacitive rubber plug is deviated in shear, and the capacitive rubber plug is marked as an abnormal cutting rubber plug and an abnormal cutting signal is sent.
[0065] In a second aspect, the application also provides a capacitive rubber plug cutting production quality detection system based on machine vision, comprising: an image acquisition module, an image processing module, a monitoring distance acquisition module, a qualified distance acquisition module, and an abnormality judgment module;
[0066] The image acquisition module is used to acquire the image of the capacitive rubber plug after cutting, and mark it as the capacitive rubber plug image;
[0067] The image processing module is used to perform grayscale processing on the capacitive rubber plug image to obtain a capacitive rubber plug grayscale image, and perform binarization processing on the capacitive rubber plug grayscale image to obtain a capacitive rubber plug binary image and an electrode hole binary image; Figure Two
[0068] The monitoring distance acquisition module is configured to acquire the midpoint coordinates of the capacitive rubber plug binary image and the electrode hole binary image based on a class midpoint acquisition method, and mark them as the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates respectively; and acquire the distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates, and mark it as the monitoring distance;
[0069] The qualified distance acquisition module is configured to acquire the qualified distance range based on the first number of qualified capacitive rubber plug images.
[0070] The abnormality judgment module is configured to judge whether the monitoring distance is within the qualified distance range, if yes, the shearing position of the capacitive rubber plug is not deviated, and if not, the shearing of the capacitive rubber plug is deviated.
[0071] The present application has the following advantages: the capacitive rubber plug binary image and the electrode hole binary image are obtained by performing gray scale processing and binary processing on the capacitive rubber plug image; the midpoint coordinates of the capacitive rubber plug binary image and the electrode hole binary image are acquired based on a class midpoint acquisition method; the monitoring distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates is acquired; the qualified distance range is acquired based on the first number of qualified capacitive rubber plug images; it is judged whether the monitoring distance is within the qualified distance range, if yes, the shearing position of the capacitive rubber plug is not deviated, and if not, the shearing of the capacitive rubber plug is deviated, the advantages of which are that the class center points of the electrode hole profile and the capacitive rubber plug profile are acquired by image processing, the distance between the two class center points is calculated, and whether the capacitive rubber plug cutting is deviated is judged according to the distance, thereby increasing the accuracy of identifying the deviation of the capacitive rubber plug cutting.
[0072] The present application has the following advantages: the qualified distance range is acquired based on the first number of qualified capacitive rubber plug images, the qualified distance range is acquired by using the qualified capacitive rubber plug image in combination with the normal distribution function, and the accuracy of identifying the deviation of the capacitive rubber plug cutting is increased. BRIEF DESCRIPTION OF DRAWINGS
[0073] Figure 1 It is the principle block diagram of the system of the present application;
[0074] Figure 2 It is the schematic diagram of the rubber plug gray scale histogram of the present application;
[0075] Figure 3 It is the schematic diagram of the electrode hole midpoint coordinate acquisition of the present application;
[0076] Figure 4 It is the schematic diagram of the detection distance acquisition of the present application;
[0077] Figure 5 It is the schematic diagram of the qualified scatter plot of the present application;
[0078] Figure 6 It is the step flow chart of the method of the present application. Detailed Implementation
[0079] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0080] Example 1, please refer to Figure 1 As shown, this application provides a machine vision-based capacitor plug cutting production quality inspection system, including an image acquisition module, an image processing module, a monitoring distance acquisition module, a qualified distance acquisition module, and an anomaly judgment module;
[0081] The image acquisition module is used to acquire images of the cropped capacitor plugs, which are then labeled as capacitor plug images. To facilitate differentiation of the capacitor plugs during image acquisition, the background can be set to white since the capacitor plugs are black.
[0082] The image processing module is used to convert the capacitor plug image to grayscale to obtain a grayscale image of the capacitor plug. Figure Two The binarized images of the capacitor plug and the electrode hole are obtained by the digitization process.
[0083] The image processing module is configured with a grayscale processing strategy, which includes:
[0084] Obtain the RGB values of all pixels in the capacitor plug image and mark them as the RGB values of the plug.
[0085] The weighted average method is used to convert all RGB values of the rubber stoppers to grayscale values, which are then labeled as the rubber stopper grayscale values. The formula for the weighted average method is:
[0086] JSH = ar*R + ag*G + ab*B; where JSH is the gray value of the rubber stopper, and ar, ag, and ab are the weighting coefficients of R, G, and B, respectively. R, G, and B are the R, G, and B values in the RGB values of the rubber stopper. Here, the weights ar, ag, and ab are determined to be 0.299, 0.587, and 0.114, respectively, based on the survey results of human eye sensitivity to different colors.
[0087] The image processing module is configured with a histogram creation strategy, which includes:
[0088] The gray values of the rubber stopper from 0 to 255 are divided into c intervals, which are marked as rubber stopper gray value intervals. The value of c is set to be able to distinguish the distribution of gray values of the rubber stopper, electrode hole and background. Therefore, the range of c is an integer from 5 to 256. The five intervals are the minimum intervals that can distinguish the gray values of the rubber stopper, electrode hole and background.
[0089] Count the frequency of the rubber plug gray value in each rubber plug gray interval, and mark it as the rubber plug gray interval frequency;
[0090] Draw a histogram with the rubber plug gray value as the X-axis and the rubber plug gray interval frequency as the Y-axis, and mark it as the rubber plug gray histogram.
[0091] The image processing module is configured with a threshold acquisition strategy, and the threshold acquisition strategy includes:
[0092] In the rubber plug gray histogram, obtain the rubber plug gray interval whose rubber plug gray interval frequency is greater than that of the rubber plug gray interval on both sides, and mark it as the top peak interval; that is, find the higher distribution area, which generally has three top peaks, which are the top peaks of the gray values of the background, the rubber plug and the electrode hole;
[0093] Obtain any one top peak interval, and mark it as the reference interval;
[0094] Obtain the top peak interval closest to the left and right sides of the reference interval on the X-axis, and mark it as the adjacent top peak interval;
[0095] Obtain all the rubber plug gray intervals between the reference interval and any one adjacent top peak interval on the X-axis, and mark them as the intermediate intervals;
[0096] Calculate the difference between the reference interval and all the intermediate intervals, and mark it as the peak-valley difference;
[0097] Obtain the intermediate interval corresponding to the minimum value of the peak-valley difference, and mark it as the threshold interval, and obtain all the threshold intervals;
[0098] Mark the threshold interval with the smallest range as the smaller threshold interval;
[0099] Mark the threshold interval with the largest range as the larger threshold interval;
[0100] Obtain the middle value of the smaller threshold interval on the X-axis, and mark it as the smaller threshold value;
[0101] Obtain the middle value of the larger threshold interval on the X-axis, and mark it as the larger threshold value.
[0102] The image processing module is configured with a gray map acquisition strategy, and the gray map acquisition strategy includes:
[0103] In the capacitor rubber plug gray map, set the rubber plug gray value less than or equal to the smaller threshold value to 0, and set the rubber plug gray value greater than the smaller threshold value to 255, to obtain the electrode hole binaryzation map;
[0104] In the capacitor rubber plug gray map, set the rubber plug gray value less than or equal to the larger threshold value to 0, and set the rubber plug gray value greater than the larger threshold value to 255, to obtain the capacitor rubber plug binaryzation map;
[0105] Because the background is white, the capacitor rubber plug is black but has light reflection, and the electrode hole is black and basically has no light reflection, the gray value range from small to large is the electrode hole gray value, the capacitor rubber plug gray value, and the background gray value in turn;
[0106] In practical application, please refer to Figure 2 As shown in FIG. 8, c is set as 8, the smaller threshold interval obtained is 63 to 95, the larger threshold interval obtained is 159 to 191, the smaller threshold value obtained is (63+95) / 2=79, the larger threshold value obtained is (159+191) / 2=175, the rubber plug gray value less than or equal to 79 in the capacitor rubber plug gray image is set as 0, and the rubber plug gray value greater than 79 is set as 255, to obtain the electrode hole binary image; the rubber plug gray value less than or equal to 175 in the capacitor rubber plug gray image is set as 0, and the rubber plug gray value greater than 175 is set as 255, to obtain the capacitor rubber plug binary image.
[0107] The monitoring distance obtaining module is configured to obtain the midpoint coordinates of the capacitor rubber plug binary image and the electrode hole binary image based on the class midpoint obtaining method, and mark them as the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates respectively; and obtain the distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates, and mark it as the monitoring distance;
[0108] The monitoring distance obtaining module is configured with a detection distance obtaining strategy, and the detection distance obtaining strategy comprises:
[0109] A plane rectangular coordinate system is established, and marked as the midpoint coordinate system;
[0110] The electrode hole binary image is placed in the first quadrant of the midpoint coordinate system, so that the lower left corner of the electrode hole binary image coincides with the origin, and the wide side of the electrode hole binary image coincides with the Y axis;
[0111] The region with a gray value of 0 in the electrode hole binary image is marked as the electrode hole region;
[0112] The class midpoint coordinates of the electrode hole region are obtained by using the class midpoint obtaining method, and marked as the electrode hole midpoint coordinates;
[0113] The capacitor rubber plug binary image is placed in the first quadrant of the midpoint coordinate system, so that the lower left corner of the capacitor rubber plug binary image coincides with the origin, and the wide side of the capacitor rubber plug binary image coincides with the Y axis;
[0114] The region with a gray value of 0 in the capacitor rubber plug binary image is marked as the rubber plug region;
[0115] The class midpoint coordinates of the rubber plug region are obtained by using the class midpoint obtaining method, and marked as the rubber plug class midpoint coordinates;
[0116] The distance between the midpoint coordinate of the rubber plug and the midpoint coordinate of the electrode hole is calculated and marked as the monitoring distance;
[0117] In practical applications, please refer to Figure 3 and Figure 4 As shown in FIG. 5, the midpoint coordinate of the electrode hole is (3.5, 3.7) and the midpoint coordinate of the rubber plug is (3.8, 4.3). The distance between (3.5, 3.7) and (3.8, 4.3) is calculated as: The calculation result is rounded to an integer, that is, the monitoring distance is 0.78 mm;
[0118] The midpoint obtaining method comprises the following steps:
[0119] The maximum and minimum values of the horizontal coordinates of the electrode hole region are obtained, which are marked as Xmax and Xmin, respectively.
[0120] The maximum and minimum values of the vertical coordinates of the electrode hole region are obtained, which are marked as Ymax and Ymin, respectively.
[0121] A line segment connecting (Xmin, Ymax) and (Xmin, Ymin) is obtained and marked as a wide line segment.
[0122] A line segment connecting (Xmin, Ymin) and (Xmax, Ymin) is obtained and marked as a long line segment.
[0123] A perpendicular line of the wide line segment passing through the midpoint of the wide line segment is drawn and marked as a wide perpendicular line.
[0124] A perpendicular line of the long line segment passing through the midpoint of the long line segment is drawn and marked as a long perpendicular line.
[0125] The intersection coordinate of the wide perpendicular line and the long perpendicular line is obtained and marked as the class midpoint coordinate.
[0126] In practical applications, please refer to Figure 3 As shown in FIG. 5, the maximum and minimum values of the horizontal coordinates of the electrode hole region are Xmax=5.1 mm and Xmin=1.9 mm, respectively. The maximum and minimum values of the vertical coordinates of the electrode hole region are Ymax=4.9 mm and Ymin=2.5 mm, respectively. A line segment connecting (1.9, 4.9) and (1.9, 2.5) is obtained and marked as a wide line segment. A line segment connecting (1.9, 2.5) and (5.1, 2.5) is obtained and marked as a long line segment. A perpendicular line of the wide line segment passing through the midpoint of the wide line segment is drawn and marked as a wide perpendicular line. A perpendicular line of the long line segment passing through the midpoint of the long line segment is drawn and marked as a long perpendicular line. The intersection coordinate of the wide perpendicular line and the long perpendicular line is (3.5, 3.7).
[0127] The qualified distance obtaining module is configured to obtain a qualified distance range based on the first number of qualified capacitor rubber plug images.
[0128] The qualified distance obtaining module is configured with a qualified distance obtaining strategy, and the qualified distance obtaining strategy comprises:
[0129] A first number of qualified capacitor rubber plug images are obtained, the capacitor rubber plug images are subjected to grayscale and binarization processing to obtain a normal capacitor rubber plug binarization image and a normal electrode hole binarization image, the midpoint coordinates of the normal capacitor rubber plug binarization image and the normal electrode hole binarization image are obtained based on a class midpoint obtaining method, the distance between the midpoint coordinates of the normal capacitor rubber plug binarization image and the normal electrode hole binarization image is calculated, and the distance is marked as a qualified distance;
[0130] The qualified distances of all capacitor rubber plug images are calculated, and the qualified distances are evenly divided into c2 intervals, and the intervals are marked as qualified intervals;
[0131] The frequency of the qualified distances of each qualified interval is counted, and the frequency is marked as a qualified interval frequency;
[0132] A plane rectangular coordinate system is established with the qualified distances as the abscissa and the qualified interval frequencies as the ordinate, and the coordinate system is marked as a qualified coordinate system;
[0133] The middle value of each qualified interval is obtained, and the middle value is marked as an interval middle value;
[0134] The interval middle value and the corresponding qualified interval frequency are taken as data points and drawn into the qualified coordinate system to obtain a qualified scatter plot;
[0135] The preset fitting function is set as:
[0136]
[0137] wherein Ps is the qualified interval frequency, Qz is the qualified distance, d1 and d2 are parameters, is the circular constant, and e is the natural constant;
[0138] The data points of the qualified scatter plot are marked as qualified data points;
[0139] The qualified data points are subjected to normal fitting with the preset fitting function as a fitting model to obtain the specific values of d1 and d2; and the specific values of d1 and d2 are substituted into the preset fitting function to obtain a qualified distance function;
[0140] The qualified distance range is set as (0, d2+2*d1); the preset fitting function is set as a normal distribution fitting, so that the range data in the interval of 2 times the standard deviation above and below the mean value covers about 95.45% of the sample data, and because the distance can only be positive and the two centers of the circles should coincide when qualified, i.e., the distance is 0, the minimum value of the qualified distance range is 0, so the qualified distance range can be used as the range of the qualified distance of the capacitor rubber plug image.
[0141] In actual application, please refer to Figure 5As shown, the acceptable distance is divided into 5 acceptable intervals, and the median value of each acceptable interval is obtained as 1.5, ..., 0.20, 0.25; the frequency of the acceptable distance in each acceptable interval is counted as 1.55 million, ..., 852,170, 1200 respectively; the median value of the interval and the corresponding frequency of the acceptable interval are plotted as data points in the acceptable coordinate system, and the acceptable data points are normally fitted with a preset fitting function as the fitting model to obtain d1 = 0.1 and d2 = 0. Therefore, the acceptable distance range is (0 mm, 0.2 mm).
[0142] The anomaly detection module is used to determine whether the monitoring distance is within the acceptable range. If it is, the shearing position of the capacitor plug is not deviated; if it is not, the shearing of the capacitor plug is deviated.
[0143] The exception detection module is configured with exception detection strategies, which include:
[0144] Determine whether the monitoring distance is within the acceptable range. If it is, the cutting position of the capacitor plug is not deviated. If it is not, the cutting of the capacitor plug is deviated. Record the capacitor plug as an abnormal cut plug and issue an abnormal cutting signal.
[0145] In practical applications, the monitoring distance is 0.78mm, and the acceptable distance range is (0mm, 0.2mm). Therefore, 0.78mm is not within the range of (0mm, 0.2mm), so the shearing of the capacitor plug is deviated. The capacitor plug is recorded as an abnormally cut plug and an abnormal cutting signal is issued.
[0146] Example 2, please refer to Figure 6 As shown, this application provides a machine vision-based method for quality inspection in capacitor plug cutting production, including the following steps:
[0147] Step S1: Obtain an image of the cut capacitor plug and label it as the capacitor plug image.
[0148] Step S2: Convert the capacitor plug image to grayscale to obtain a grayscale image of the capacitor plug. Figure Two The binarization process yields a binarized image of the capacitor plug and a binarized image of the electrode hole; step S2 includes the following sub-steps:
[0149] Step S201: Obtain the RGB values of all pixels in the capacitor plug image and mark them as the plug RGB values;
[0150] Step S202, all the rubber plug RGB values are converted into gray values by using the weighted average method, marked as rubber plug gray values, and the weighted average method formula is: JSH=ar*R+ag*G+ab*B; wherein JSH is the rubber plug gray value, wherein ar, ag and ab are the weight coefficients of R, G and B, and R, G and B are the R value, G value and B value in the rubber plug RGB value;
[0151] Step S203, the rubber plug gray values from 0 to 255 are evenly divided into c intervals, marked as rubber plug gray interval; the frequency of the rubber plug gray value in each rubber plug gray interval is counted respectively, marked as rubber plug gray interval frequency;
[0152] Step S204, a histogram is drawn with the rubber plug gray value as the X axis and the rubber plug gray interval frequency as the Y axis, marked as the rubber plug gray histogram;
[0153] Step S205, in the rubber plug gray histogram, the rubber plug gray interval with the rubber plug gray interval frequency greater than that of the left and right sides is obtained, marked as the top peak interval; any one top peak interval is obtained, marked as the reference interval;
[0154] Step S206, the nearest top peak interval on the left and right sides of the reference interval on the X axis is obtained, marked as the adjacent top peak interval;
[0155] Step S207, all the rubber plug gray intervals between the reference interval and any one adjacent top peak interval on the X axis are obtained, marked as the intermediate interval;
[0156] Step S208, the difference between the reference interval and all the intermediate intervals is calculated, marked as the peak-valley difference;
[0157] Step S209, the intermediate interval corresponding to the minimum value of the peak-valley difference is obtained, marked as the threshold interval, and all the threshold intervals are obtained;
[0158] Step S210, the threshold interval with the smallest range is marked as the smaller threshold interval; the threshold interval with the largest range is marked as the larger threshold interval;
[0159] Step S211, the middle value of the smaller threshold interval on the X axis is obtained, marked as the smaller threshold; the middle value of the larger threshold interval on the X axis is obtained, marked as the larger threshold.
[0160] Step S212, in the capacitance rubber plug gray image, the rubber plug gray value less than or equal to the smaller threshold is set to 0, and the rubber plug gray value greater than the smaller threshold is set to 255, to obtain the electrode hole binary image;
[0161] Step S213, in the capacitance rubber plug gray scale image, set the rubber plug gray scale value less than or equal to the larger threshold value to 0, and set the rubber plug gray scale value greater than the larger threshold value to 255, to obtain a capacitance rubber plug binary image.
[0162] Step S3, obtain the midpoint coordinates of the capacitance rubber plug binary image and the electrode hole binary image based on the class midpoint obtaining method, and mark them as the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates respectively; obtain the distance between the rubber plug class midpoint coordinates and the electrode hole class midpoint coordinates, and mark it as the monitoring distance; step S3 includes the following sub-steps:
[0163] Step S301, establish a plane rectangular coordinate system, marked as the midpoint coordinate system;
[0164] Step S302, place the electrode hole binary image in the first quadrant of the midpoint coordinate system, so that the lower left corner of the electrode hole binary image coincides with the origin, and the wide side of the electrode hole binary image coincides with the Y axis;
[0165] Step S303, mark the region with a gray scale value of 0 in the electrode hole binary image as the electrode hole region;
[0166] Step S304, obtain the class midpoint coordinates of the electrode hole region using the class midpoint obtaining method, and mark them as the electrode hole midpoint coordinates; step S304 includes the following sub-steps:
[0167] Step S30401, obtain the maximum and minimum values of the abscissa of the electrode hole region, and mark them as Xmax and Xmin respectively;
[0168] Step S30402, obtain the maximum and minimum values of the ordinate of the electrode hole region, and mark them as Ymax and Ymin respectively;
[0169] Step S30403, obtain the line segment connecting (Xmin, Ymax) and (Xmin, Ymin), and mark it as the wide line segment;
[0170] Step S30404, obtain the line segment connecting (Xmin, Ymin) and (Xmax, Ymin), and mark it as the long line segment;
[0171] Step S30405, draw a perpendicular to the wide line segment through the midpoint of the wide line segment, and mark it as the wide perpendicular;
[0172] Step S30406, draw a perpendicular to the long line segment through the midpoint of the long line segment, and mark it as the long perpendicular;
[0173] Step S30407, obtain the intersection coordinates of the wide perpendicular and the long perpendicular, and mark them as the class midpoint coordinates.
[0174] Step S305, placing the capacitive rubber plug binary image in the first quadrant of the midpoint coordinate system, so that the lower left corner of the capacitive rubber plug binary image coincides with the origin, and the wide side of the capacitive rubber plug binary image coincides with the Y axis;
[0175] Step S306, marking the area with a gray value of 0 in the capacitive rubber plug binary image as a rubber plug area;
[0176] Step S307, obtaining the midpoint coordinates of the rubber plug area by using the midpoint-like obtaining method, and marking the midpoint coordinates as rubber plug midpoint coordinates;
[0177] Step S308, calculating the distance between the rubber plug midpoint coordinates and the electrode hole midpoint coordinates, and marking the distance as a monitoring distance.
[0178] Step S4, obtaining a qualified distance range based on the first number of qualified capacitive rubber plug images; Step S4 includes the following sub-steps:
[0179] Step S401, obtaining the first number of qualified capacitive rubber plug images, and performing gray scale and binary processing on the capacitive rubber plug images to obtain normal capacitive rubber plug binary images and normal electrode hole binary images; obtaining the midpoint coordinates of the normal capacitive rubber plug binary images and the normal electrode hole binary images based on the midpoint-like obtaining method; and calculating the distance between the midpoint coordinates of the normal capacitive rubber plug binary images and the normal electrode hole binary images, and marking the distance as a qualified distance;
[0180] Step S402, calculating the qualified distance of all capacitive rubber plug images, dividing the qualified distance into c2 intervals, and marking the intervals as qualified intervals; and counting the frequency of the qualified distance in each qualified interval, and marking the frequency as a qualified interval frequency;
[0181] Step S403, establishing a plane rectangular coordinate system with the qualified distance as the abscissa and the qualified interval frequency as the ordinate, and marking the coordinate system as a qualified coordinate system;
[0182] Step S404, obtaining the middle value of each qualified interval, and marking the middle value as an interval middle value;
[0183] Step S405, drawing the interval middle value and the corresponding qualified interval frequency into the qualified coordinate system as data points to obtain a qualified scatter plot;
[0184] Step S406, setting a preset fitting function as: where Ps is the qualified interval frequency, Qz is the qualified distance, d1 and d2 are parameters, Π is the circular constant, and e is the natural constant;
[0185] Step S405, marking the data points of the qualified scatter plot as qualified data points;
[0186] Step S407, normal fitting is performed on the qualified data points by using a preset fitting function as a fitting model to obtain specific values of d1 and d2.
[0187] Step S408, the qualified distance range is set as (0, d2+2*d1).
[0188] Step S5, it is judged whether the monitoring distance is in the qualified distance range, if yes, the shear position of the capacitive rubber plug is not deviated, if not, the shear of the capacitive rubber plug is deviated; Step S5 includes the following sub-steps:
[0189] Step S501, it is judged whether the monitoring distance is in the qualified distance range, if yes, the shear position of the capacitive rubber plug is not deviated, if not, the shear of the capacitive rubber plug is deviated, the capacitive rubber plug is recorded as an abnormal cutting rubber plug and an abnormal cutting signal is sent.
[0190] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can adopt a computer program product in the form of being implemented on one or more computer usable storage media containing computer usable program codes. The storage media can be realized by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. These computer program instructions can also be stored in a computer readable storage medium which can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including instruction devices, which realize the functions specified in the flowcharts Figure One one or more flows and / or blocks Figure One one or more flows and / or blocks
[0191] In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. The embodiments described above are merely exemplary, for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation; for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, or the among different units, can be indirect couplings or communication connections through some interfaces, communication interfaces, or a combination of the two, which can be electric, mechanical, or in other forms.
Claims
1. A machine vision-based method for quality inspection in capacitor plug cutting production, characterized in that, Includes the following steps: Obtain an image of the cut capacitor plug and label it as the capacitor plug image; The capacitor plug image is converted to grayscale to obtain a grayscale image of the capacitor plug. The grayscale image of the capacitor plug is then binarized to obtain a binarized image of the capacitor plug and a binarized image of the electrode hole. The midpoint coordinates of the binary images of the capacitor plug and the electrode hole are obtained based on the midpoint acquisition method, and are marked as the midpoint coordinates of the plug class and the electrode hole class, respectively; the distance between the midpoint coordinates of the plug class and the midpoint coordinates of the electrode hole class is obtained and marked as the monitoring distance. The acceptable distance range is obtained based on the first number of qualified capacitor plug images; Determine whether the monitoring distance is within the acceptable range. If it is, the shearing position of the capacitor plug is not deviated; if it is not, the shearing of the capacitor plug is deviated. Obtaining the acceptable distance range based on the first number of acceptable capacitor plug images includes the following sub-steps: Acquire a first number of qualified capacitor plug images. Perform grayscale and binarization processing on the capacitor plug images to obtain normal capacitor plug binarized images and normal electrode hole binarized images. Obtain the midpoint coordinates of the normal capacitor plug binarized images and normal electrode hole binarized images based on the class midpoint acquisition method. Calculate the distance between the midpoint coordinates of the normal capacitor plug binarized images and the midpoint coordinates of the normal electrode hole binarized images and mark it as the qualified distance. Calculate the acceptable distance for all capacitor plug images, divide the acceptable distance into c2 intervals, and mark them as acceptable intervals; Count the frequency of the qualified distance in each qualified interval and mark it as the qualified interval frequency; Establish a Cartesian coordinate system with the qualified distance as the x-axis and the frequency of qualified intervals as the y-axis, and mark it as the qualified coordinate system; Obtain the median value of each qualified interval and mark it as the interval median value; Plot the intermediate value of the interval and the corresponding frequency of the qualified interval as data points into the qualified coordinate system to obtain a qualified scatter plot; The preset fitting function is set as follows: ; Where Ps is the frequency of the qualified interval, Qz is the qualified distance, d1 and d2 are parameters, π is pi, and e is the natural constant; Mark the data points in the qualified scatter plot as qualified data points; The specific values of d1 and d2 are obtained by performing a normal fit on qualified data points using a preset fitting function as the fitting model. The acceptable distance range is set as (0, d2+2*d1).
2. The machine vision-based method for quality inspection of capacitor plug cutting production as described in claim 1, characterized in that, The process of converting the capacitor plug image to grayscale to obtain a grayscale image of the capacitor plug includes the following sub-steps: Obtain the RGB values of all pixels in the capacitor plug image and mark them as the RGB values of the plug. The weighted average method is used to convert all RGB values of the rubber stoppers to grayscale values, which are then labeled as the rubber stopper grayscale values. The formula for the weighted average method is: JSH = ar*R + ag*G + ab*B; where JSH is the grayscale value of the rubber stopper, and ar, ag, and ab are the weighting coefficients of R, G, and B, respectively, and R, G, and B are the R, G, and B values in the RGB values of the rubber stopper.
3. The machine vision-based method for quality inspection of capacitor plug cutting production as described in claim 2, characterized in that, Binarizing the grayscale image of the capacitor plug to obtain a binarized image of the capacitor plug and a binarized image of the electrode hole involves the following sub-steps: The gray values of the rubber stopper from 0 to 255 are divided into c intervals, which are marked as the gray value intervals of the rubber stopper. Count the frequency of the rubber stopper grayscale value in each grayscale interval and mark it as the frequency of the rubber stopper grayscale interval; A histogram was plotted with the grayscale value of the rubber stopper on the X-axis and the frequency of the grayscale intervals of the rubber stopper on the Y-axis, and it was labeled as the rubber stopper grayscale histogram.
4. The machine vision-based method for quality inspection of capacitor plug cutting production as described in claim 3, characterized in that, Binarizing the grayscale image of the capacitor plug to obtain a binarized image of the capacitor plug and a binarized image of the electrode hole also includes the following sub-steps: In the grayscale histogram of rubber stoppers, the grayscale intervals of rubber stoppers whose frequency is greater than that of the grayscale intervals of rubber stoppers on both sides are identified and marked as peak intervals. Obtain any peak interval and mark it as the reference interval; On the X-axis, find the peak intervals that are closest to the left and right sides of the reference interval and mark them as adjacent peak intervals; On the X-axis, obtain all the grayscale intervals of the rubber stopper between the reference interval and any adjacent peak interval, and mark them as the middle interval; Calculate the difference between the reference interval and all intermediate intervals, and mark the peak-to-valley difference; Find the middle interval corresponding to the minimum value of the peak-valley difference, mark it as the threshold interval, and obtain all threshold intervals; The threshold interval with the smallest range is marked as the smaller threshold interval; Mark the threshold interval with the largest range as the larger threshold interval; Find the median value on the X-axis within the smaller threshold range and mark it as the smaller threshold. Obtain the median value of the larger threshold range on the X-axis and mark it as the larger threshold.
5. The machine vision-based method for quality inspection of capacitor plug cutting production as described in claim 4, characterized in that, Binarizing the grayscale image of the capacitor plug to obtain a binarized image of the capacitor plug and a binarized image of the electrode hole also includes the following sub-steps: In the grayscale image of the capacitor plug, the grayscale values of the plugs less than or equal to the smaller threshold are set to 0, and the grayscale values of the plugs greater than the smaller threshold are set to 255, thus obtaining the binary image of the electrode hole. In the grayscale image of the capacitor plug, the grayscale values of plugs less than or equal to the larger threshold are set to 0, and the grayscale values of plugs greater than the larger threshold are set to 255, thus obtaining the binarized image of the capacitor plug.
6. The machine vision-based method for quality inspection of capacitor plug cutting production according to claim 5, characterized in that, Obtaining the midpoint coordinates of the binary images of the capacitor plug and the electrode hole based on the midpoint acquisition method includes the following sub-steps: Establish a Cartesian coordinate system and label it as the midpoint coordinate system; Place the binarized image of the electrode aperture in the first quadrant of the midpoint coordinate system, so that the lower left corner of the binarized image of the electrode aperture coincides with the origin, and the wide side of the binarized image of the electrode aperture coincides with the Y-axis. The region with a grayscale value of 0 in the binarized image of the electrode hole is marked as the electrode hole region; The coordinates of the class midpoint of the electrode hole region are obtained using the class midpoint acquisition method and marked as the electrode hole midpoint coordinates. Place the binary image of the capacitor plug in the first quadrant of the midpoint coordinate system, so that the lower left corner of the binary image of the capacitor plug coincides with the origin, and the wide side of the binary image of the capacitor plug coincides with the Y-axis. The region with a grayscale value of 0 in the binarized image of the capacitor plug is marked as the plug region. Use the class midpoint acquisition method to obtain the class midpoint coordinates of the rubber stopper region and mark them as the rubber stopper class midpoint coordinates; The distance between the midpoint coordinates of the rubber plug type and the midpoint coordinates of the electrode hole type is calculated and marked as the monitoring distance.
7. The machine vision-based method for quality inspection of capacitor plug cutting production according to claim 6, characterized in that, Methods for obtaining the midpoint of a class include: Obtain the maximum and minimum values of the abscissa of the electrode hole region, and label them as Xmax and Xmin, respectively; Obtain the maximum and minimum values of the ordinate of the electrode hole region, and label them as Ymax and Ymin, respectively; Get the line segment connecting (Xmin, Ymax) and (Xmin, Ymin), and mark it as a wide line segment; Get the line segment connecting (Xmin, Ymin) and (Xmax, Ymin) and mark it as the longer line segment; Draw a perpendicular line from the midpoint of the wide line segment to the wide line segment, and mark it as the wide perpendicular line; Draw a perpendicular line from the midpoint of the longer line segment to the longer line segment, and mark it as the longer perpendicular line; Obtain the coordinates of the intersection of the wide perpendicular and the long perpendicular, and mark them as the midpoint coordinates of the class.
8. The machine vision-based method for quality inspection of capacitor plug cutting production according to claim 7, characterized in that, Determining whether the monitoring distance is within the acceptable range includes the following steps: Determine if the monitoring distance is within the acceptable range. If it is, the cutting position of the capacitor plug is not deviated. If it is not, the cutting of the capacitor plug is deviated. Record the capacitor plug as an abnormal cut plug and issue an abnormal cut signal.
9. A machine vision-based capacitor plug cutting production quality inspection system, used to implement the machine vision-based capacitor plug cutting production quality inspection method according to any one of claims 1-8, characterized in that, It includes an image acquisition module, an image processing module, a monitoring distance acquisition module, a qualified distance acquisition module, and an anomaly detection module; The image acquisition module is used to acquire an image of the cut capacitor plug, which is labeled as a capacitor plug image. The image processing module is used to perform grayscale processing on the capacitor plug image to obtain a capacitor plug grayscale image, and to perform binarization processing on the capacitor plug grayscale image to obtain a capacitor plug binarization image and an electrode hole binarization image. The monitoring distance acquisition module is used to acquire the midpoint coordinates of the binary image of the capacitor plug and the binary image of the electrode hole based on the midpoint acquisition method, and mark them as the midpoint coordinates of the plug class and the midpoint coordinates of the electrode hole class, respectively; and acquire the distance between the midpoint coordinates of the plug class and the midpoint coordinates of the electrode hole class, and mark it as the monitoring distance; The qualified distance acquisition module is used to acquire the qualified distance range based on a first number of qualified capacitor plug images; The anomaly detection module is used to determine whether the monitoring distance is within the acceptable range. If it is, the shearing position of the capacitor plug is not deviated; if it is not, the shearing of the capacitor plug is deviated.
Citation Information
Patent Citations
Blanking fracture surface quality detection system based on machine vision and blanking fracture surface quality detection method based on machine vision
CN104677908A
Textile fabric production online detection method and equipment and computer storage medium
CN114372972A
Capping detection method and device for amoxicillin sodium aluminum cap for injection
CN115690067A