A method for detecting defects in aluminum electrolytic capacitors based on image processing
Through the image processing method, the region of interest of aluminum electrolytic capacitors is extracted and compared with the reference, and the problem of low and incomplete detection efficiency of aluminum electrolytic capacitors in the prior art is solved, and the aluminum shell, casing, glue plug and The detection of multiple defects of the needle improves the accuracy and efficiency of the detection.
Patent Information
- Application Number
- CN202110520114.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-13
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-05-13
AI Technical Summary
In the prior art, the defect detection efficiency of aluminum electrolytic capacitors is low and the detection is not comprehensive. It depends on the calculation of the area threshold of the target image area, the accuracy requirements are high and the calculation amount is large, and the defects are relatively single during the detection process.
Using an image-based processing method, the image of aluminum electrolytic capacitor is obtained for pre-processing, the region of interest is extracted, and the defect is compared with the preset reference to determine the detection of aluminum shell, sleeve, glue plug and needle, using gray Technical means such as degree graph processing, HSV color space conversion, morphological operation, and histogram calculation to improve the accuracy and efficiency of detection.
It has achieved improvement in detection efficiency, small calculation volume and simple process, and can detect various types of defects, including the top bump defects of aluminum shell, the size defects of the sleeve, the damage to the glue plug, etc., improving the comprehensiveness and accuracy of the inspection. .
Smart Images

Figure CN113658092B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image detection technology, and more specifically, to an aluminum electrolytic capacitor defect detection method based on image processing. Background Art
[0002] Aluminum electrolytic capacitors have good development prospects and huge development space as machines and equipment become increasingly sophisticated. Aluminum electrolytic capacitors have an aluminum tube as the negative electrode, an aluminum strip as the positive electrode, and electrolyte inside. They are mainly composed of aluminum shell, electrolyte liquid, sleeve, rubber plug, pins and other parts. During the production process, it is necessary to inspect the appearance of aluminum electrolytic capacitors. The defect inspection items for its aluminum shell mainly include: whether the top aluminum shell is bulging, whether the explosion-proof valve is leaking, whether the aluminum shell is dented, etc. At present, the inspection of aluminum electrolytic capacitors is mainly based on manual visual inspection. When performing manual inspection processes with a large workload, it is very easy to have false detection and missed detection;
[0003] In the prior art, a Chinese invention patent with publication number CN111008960A disclosed on April 14, 2020 a method for detecting the appearance of the bottom of an aluminum electrolytic capacitor using machine vision. However, the automatic detection of the bottom of the capacitor based on this method mostly relies on the calculation and comparison of the area threshold of the target image area. This method has high requirements on the accuracy of the preset area threshold and has great limitations. In addition, it does not perform more detailed processing on the captured target area image. The amount of calculation during the detection process is large, and the defects detected are relatively simple. Summary of the invention
[0004] In order to solve the problems of low efficiency and incomplete detection of electrolytic capacitor defects in the above-mentioned prior art, the present invention provides an aluminum electrolytic capacitor defect detection method based on image processing.
[0005] The primary purpose of the present invention is to solve the above technical problems. The technical solution of the present invention is as follows:
[0006] A method for detecting defects of aluminum electrolytic capacitors based on image processing comprises the following steps:
[0007] S1: Acquire the image of aluminum electrolytic capacitor and perform preprocessing;
[0008] S2: extract the region of interest ROG from the preprocessed image;
[0009] S3: Perform image conversion processing on the extracted region of interest and compare it with a preset benchmark to determine the defects of the aluminum electrolytic capacitor.
[0010] Furthermore, the defects of the electrolytic capacitor include: defects in the capacitor aluminum shell, defects in the capacitor sleeve, defects in the capacitor rubber plug, and defects in the capacitor lead pins.
[0011] Furthermore, the specific steps for capacitor aluminum shell defect detection are:
[0012] Acquire the aluminum shell image of the capacitor and perform preprocessing, the preprocessing of the aluminum shell image includes: grayscale image processing, mean filtering, HSV color space conversion, morphological opening operation processing;
[0013] After preprocessing, the aluminum shell color and other colors are separated in the HSV color space, the detection area outline is extracted, the detection area outline is traversed pixel by pixel, the area of interest outline is extracted, and the area of interest is determined;
[0014] The region of interest is channel decomposed and image pixel filling is performed, and then the image in the region of interest and the preset reference image are histogram calculated and normalized, the similarity between the two is calculated, and the similarity is compared with the preset threshold to determine the defects of the capacitor aluminum shell.
[0015] Furthermore, the defects of the capacitor aluminum shell include: convex defects on the top of the aluminum shell, leakage defects on the explosion-proof valve, excessive sleeve wrapping defects, bald head defects, bare product defects, discount defects, and dent defects.
[0016] Furthermore, the specific steps of capacitor bushing defect detection are:
[0017] The collected sleeve image is preprocessed to obtain a first extracted image and a second extracted image, wherein the first extracted image is a side view of the aluminum electrolytic capacitor body; the second extracted image is a circular image of the top of the aluminum electrolytic capacitor, and the preprocessing includes: binarization processing, mean filtering processing, and morphological processing in sequence;
[0018] A screenshot is taken of the first extracted image, an area of interest of the first image is extracted, the minimum rectangle inscribed in the outline of the first extracted image is calculated, and a value is assigned to a pixel point aligned with the center point of the minimum rectangle; a Euclidean distance algorithm is applied to the center point of the minimum rectangle to obtain a Euclidean distance between the pixel point aligned with the center point and the pixel point on the edge of the minimum rectangle, and the Euclidean distance is compared with the Euclidean distance corresponding to the center point of the reference image to determine whether the detected capacitor has a mixed-size casing defect;
[0019] Take a screenshot of the extracted image 2, extract the region of interest of the second image, perform histogram calculation and normalization processing on the HSV channel image of the region of interest of the second image and the reference image, calculate the similarity between the two and compare them with the preset similarity threshold, and determine whether the capacitor sleeve has a top bald defect or a top sleeve warping defect.
[0020] Furthermore, the specific steps of capacitor plug defect detection are as follows:
[0021] Collecting the capacitor plug image and preprocessing it, wherein the preprocessing includes: grayscale processing, geometric transformation, and image enhancement;
[0022] Perform pixel traversal on the HSV channel image of the preprocessed image, perform polygon contour operation, separate the specific color corresponding to the rubber plug in the HSV color space, and extract the image region of interest containing the rubber plug contour;
[0023] The extracted region of interest of the image is traversed and thresholded, and a contour tree search is performed. According to the separated specific color, the pixel area corresponding to the rubber plug is found, the area of the area is integrated and calculated, and the calculated area is compared with the preset area threshold. According to the comparison result, it is judged whether the aluminum electrolytic capacitor under inspection has a rubber plug defect.
[0024] Furthermore, the rubber plug defects include: breakage defects, rubber plug missing defects, and rubber plug bulging defects.
[0025] Furthermore, the specific steps of capacitor lead pin defect detection are:
[0026] Obtaining a side image of the aluminum electrolytic capacitor body and performing preprocessing, wherein the preprocessing includes: grayscale, denoising, edge extraction, and image enhancement;
[0027] Traversing the HSV channel image of the preprocessed image, separating specific colors in the HSV color space, and extracting the image region of interest; the image region of interest is set to the minimum regular rectangle covering the outline of the cannula and the guide needle;
[0028] The Hough transform is applied to the extracted image region of interest, and the coordinates of each pixel in the image region of interest are converted into the Hough parameter space, and the pixel coordinate values constituting the image of the region of interest are determined. Then, the coordinate system transformation is performed, and the coordinate values of all pixels in the image of the region of interest are transformed into curves in the parameter space. The curves with the most points passing through the same point are found in the parameter space, and it is determined whether there are straight lines in the image, thereby determining whether there are lead defects in the aluminum electrolytic capacitor being tested.
[0029] Furthermore, the lead pin defects include: polarization defects and lead pin reverse polarity defects.
[0030] Furthermore, the preprocessing of the side image of the aluminum electrolytic capacitor body also includes: creating a contour tree according to the contour of the collected image, and traversing the contour tree structure, wherein the contour includes both embedded contours and contours at the same level.
[0031] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0032] The present invention obtains and preprocesses the image of the aluminum electrolytic capacitor, extracts the region of interest and compares it with a preset benchmark to perform defect detection. The method has a small amount of calculation, a simple process and high detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The figure is a flow chart of the method of the present invention.
[0034] Figure 2 This is a comparison between an aluminum electrolytic capacitor with a convex top defect and a genuine one.
[0035] Figure 3 A comparison chart of aluminum electrolytic capacitors with mixed size defects and genuine ones.
[0036] Figure 4 This is a comparison chart of an aluminum electrolytic capacitor with a damaged rubber plug and a genuine capacitor.
[0037] Figure 5 This is a comparison chart between aluminum electrolytic capacitors with lead pin bias and reverse polarity defects and genuine ones. DETAILED DESCRIPTION
[0038] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0039] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0040] Figure 1 A flow chart of an aluminum electrolytic capacitor defect detection method based on image processing according to the present invention is shown.
[0041] Example 1
[0042] In this embodiment, the aluminum shell image of the electrolytic capacitor is used to detect defects of the aluminum shell, and the specific process is as follows:
[0043] Figure 2 The figure shows a comparison between an aluminum electrolytic capacitor with a top convex defect and a genuine one.
[0044] S1: Preprocess the collected aluminum shell image of the electrolytic capacitor
[0045] In the embodiment of the present invention, the captured target is converted into an image signal through a machine vision product and transmitted to a dedicated image processing system to obtain the morphological information of the captured target, and converted into a digital signal according to the pixel information, brightness, color and other information; in this embodiment, images are collected through an industrial optical imaging system, and mainly two image sensors, CCD and CMOS, are used for image capture; specifically, in this embodiment, the light source is placed directly below the inverted aluminum electrolytic capacitor, and the industrial camera, the light source and the aluminum electrolytic capacitor are arranged on the same straight line, thereby capturing a color image of the top of the aluminum shell.
[0046] The collected images are preprocessed by image processing software, and the preprocessing process is grayscale, geometric transformation, and image enhancement. Specifically, the image preprocessing first converts the collected color image to grayscale, and filters the grayscale image to eliminate noise. It is then binarized and the grayscale value range of the pixels in the binarized image is set to remove the darker areas. The grayscale image is then morphologically opened, that is, eroded first and then expanded. This can eliminate small objects on the image, separate objects in thin areas, and eliminate smooth larger boundaries without significantly changing their volume.
[0047] In this embodiment, the collected image is converted from RGB channels to HSV channels to facilitate channel selection and judgment by subsequent operators. The specific conversion formula is as follows:
[0048] S2: After preprocessing, separate the aluminum shell color and other colors in the HSV color space, extract the detection area outline, perform pixel traversal on the detection area outline, extract the area of interest outline, and determine the area of interest.
[0049] After the image is preprocessed and irrelevant information is eliminated, it is necessary to extract the features of the region of interest (ROI). Extracting the features of the ROI from the original image can reduce the image processing time and increase the accuracy.
[0050] S201: Find edge contours according to image pixels;
[0051] Based on the pre-processed image pixels, the image contour of the top circle of the aluminum electrolytic capacitor is found at the intersection of the image area and another attribute area. At this time, the top circle contour includes both the outer ring casing contour and the inner ring aluminum shell contour.
[0052] The specific principle of contour detection is as follows:
[0053] Each time a line is scanned, the following two situations are encountered to determine the outer boundary (outer boeder) and the hole boundary (hole border):
[0054] (1) f(i, j-1) = 0, f(i, j) = 1; / / f(i, j) is the starting point of the outer boundary
[0055] (2) f(i, j)>=1, f(i, j+1)=0; / / f(i, j) is the starting point of the hole boundary
[0056] Then give it a number (the number is unique and assigned by NBD)
[0057] Here, a unique identifier is assigned to the newly discovered boundary, called NBD. Initially, NBD = 1, and each time a new boundary is discovered, it increases by 1. In this process, when f(p,q) = 1 and f(p,q+1) = 0 are encountered, f(p,q) is set to -NBD, which is the end point of the right boundary.
[0058] The above is a topological analysis of the input digital binary image to determine the surrounding relationship of the binary image boundary, that is, to determine the outer boundary, hole boundary and their hierarchical relationship. These boundaries have a one-to-one correspondence with the area of the original image. The outer boundary corresponds to the connected area with a pixel value of 1, and the hole boundary corresponds to the area with a pixel value of 0. Therefore, we can use the boundary to represent the original image, determine the inclusion relationship of these boundaries and only find the outermost boundary, so that the contour can be determined.
[0059] S202: Recognize the outline of a table from the circular outline image;
[0060] The contour searched in step S201 is a shape with a boundary of the same grayscale value. All (x, y) coordinate types on the shape boundary can be stored in a table, that is, the grayscale values in the H channel, S channel, and V channel are divided. The redundant points on the image contour can be determined based on the numerical values. The algorithm traverses to remove the redundant points on the contour and compresses the contour, thereby saving memory expenses.
[0061] S203: Process pixel coordinates using image geometry;
[0062] Use image array to store the above image data. The rows of the two-dimensional array correspond to the height of the image, the columns of the two-dimensional array correspond to the width of the image, the elements of the two-dimensional array correspond to the pixels of the image, and the values of the two-dimensional array elements are the grayscale values of the pixels. Therefore, the horizontal coordinate u (u corresponds to x) and the vertical coordinate v (v corresponds to y) of the pixel are the column number and row number in the image array respectively.
[0063] S204: Extracting the outline of the region of interest from the original image
[0064] The coordinates of each pixel point on the circular contour of the top of the capacitor including the outer ring casing contour and the inner ring aluminum shell contour obtained in the above step are determined according to the image array in step S203, and then an image including only the inner ring aluminum shell contour, i.e., the contour of the region of interest, is obtained by mathematical offset addition and subtraction, and AND and OR operations are performed.
[0065] S3: Perform channel decomposition on the region of interest and fill in image pixels, then perform histogram calculation and normalization processing on the image in the region of interest and the preset reference image, calculate the similarity between the two, and compare the similarity with the preset threshold to determine the defects of the capacitor aluminum shell.
[0066] In step S1, the image is converted into an HSV color gamut image, that is, the image is divided into three single-channel images, including an H channel image, an S channel image, and a V channel image; and a histogram calculation is performed on the reference image at the same time.
[0067] For the color gamut channel separated from the image, the histogram of the H channel and the histogram of the reference image are normalized to the same scale space. The histogram counts the number of pixels for each pixel intensity value, and the distance between the two histograms is calculated to obtain the similarity of the two histograms, and then the similarity of the images is compared.
[0068] Based on the above detection method, the specific convex defects on the top of the aluminum shell are detected. The convex defects refer to the convexity on the surface of the aluminum shell or the convexity to cracking. The specific steps are as follows:
[0069] After the CCD camera system takes a color image of the top circle of the product to be inspected, the color image is preprocessed: the color image is converted to grayscale, and the grayscale image is filtered to eliminate noise. The grayscale value range of the pixel points of the binary image is set to play a role in removing the darker area. The grayscale image is then morphologically opened, that is, erosion is performed first and then expansion. This can eliminate small objects on the image, separate objects in thin places, and eliminate smooth larger boundaries without significantly changing their volume.
[0070] Afterwards, based on the preprocessed image pixels, the image contour of the top circle of the aluminum electrolytic capacitor is found at the intersection of the image area and another attribute area, that is, the optimal radius of the outer circle of the capacitor is found, the background is removed, and the outer circle contour is intercepted. At this time, the top circle contour includes both the outer ring casing contour and the inner circle aluminum shell contour.
[0071] Then, the region of interest is extracted from the top circle contour extracted above, and the pixel points are traversed. Through mathematical offset addition and subtraction, and AND and OR operations are performed to extract the region of interest, that is, the aluminum shell contour of the inner circle. The histogram image of the region of interest is calculated and compared with the histogram image of the genuine image, as shown in the figure; then, the coincidence of the two histograms can be calculated, and the two histograms can be normalized to the same coordinate system for comparison, and the distance between each point can be calculated, that is, the coincidence of the two histograms can be obtained, and the image can be compared based on this. Similarity, when the overlap of the two histograms falls within a reasonable range, it can be judged that the top of the capacitor aluminum shell under test has no defects and meets the qualified standard. Otherwise, it represents a defective product. In this embodiment, because the specific aluminum shell convex defects are detected, the color of the genuine aluminum shell is relatively uniform, so the curve in its H channel histogram is a gentle curve. Therefore, when the H channel histogram image of the detected product is an image with drastic fluctuations, and the overlap with the genuine H channel histogram after calculation does not meet the requirements, it means that the detected product is a defective product.
[0072] In a specific embodiment, based on the above detection method, a specific aluminum shell explosion-proof valve leakage defect is detected. The explosion-proof valve leakage defect refers to leakage on the surface of the aluminum shell on the top of the capacitor and excessive dirt area. The detection method is as follows:
[0073] After the CCD camera system takes a color image of the top circle of the product to be inspected, the color image is preprocessed, the color image is converted into grayscale, and the grayscale image is filtered to eliminate noise. Then, a morphological opening operation is performed on the grayscale image, which can eliminate small objects on the image so as to better extract image features.
[0074] Based on the preprocessed image pixels, the image contour of the top circle of the aluminum electrolytic capacitor is found at the intersection of the image area and another attribute area, that is, the optimal radius of the outer circle of the capacitor is found, the background is removed, and the outer circle contour is intercepted; then the image is converted from BGR format to RGB format, and the algorithm traverses the set area of interest in the circle, traverses the pixels, accesses, assigns values to the pixels in the circle, and extracts the image of the capacitor body from the original image, removing unnecessary noise interference and areas; in the extracted image of the capacitor body, in order to make the features more obvious, the area of interest is the inner middle circle, as shown in the figure; after resizing the image, it is separated into three RGB channels, and then the histogram similarity value of each RGB channel is calculated, and the histogram of each channel is compared with the histogram of each channel under the genuine RGB color domain for overlap to determine whether the detected product has surface leakage defects.
[0075] Example 2
[0076] Figure 3 A comparison chart of aluminum electrolytic capacitors with mixed-size defects and genuine products is shown.
[0077] In this embodiment, the casing defect detection is performed using the casing image of the electrolytic capacitor, and the specific process is as follows:
[0078] S1: preprocessing the collected sleeve image to obtain a first extracted image and a second extracted image, wherein the first extracted image is a side view of the aluminum electrolytic capacitor body; the second extracted image is a circular image of the top of the aluminum electrolytic capacitor, and the preprocessing includes: binarization processing, mean filtering processing, and morphological processing in sequence;
[0079] In the embodiment of the present invention, the captured target is converted into an image signal through a machine vision product, transmitted to a dedicated image processing system, the morphological information of the captured target is obtained, and converted into a digital signal according to the pixel information, brightness, color and other information; in this embodiment, images are collected through an industrial optical imaging system, and mainly two types of image sensors, CCD and CMOS, are used for image capture; specifically, it includes a light source and an industrial camera; the light source is placed on the side of the aluminum electrolytic capacitor, and the industrial camera, the light source and the aluminum electrolytic capacitor are arranged on the same straight line.
[0080] In this embodiment, the first extracted image is a side view of an aluminum electrolytic capacitor.
[0081] The collected image is preprocessed by image processing software, and the preprocessing process is as follows: the collected color image of the casing is binarized using a preset grayscale value range. In this step, the pixel values within the threshold are set to white (255), and the pixel values outside the threshold interval are set to black (0), to obtain a preliminary extracted image, and then the image is filtered and processed using a mathematical morphology algorithm; during the preprocessing process, a matrix of given pixels is preset in the image. The matrix can be of any shape, generally a square, circle or diamond, and its structural element has a center point.
[0082] S2: Take a screenshot of the first extracted image, extract the region of interest of the first image, calculate the minimum rectangle inscribed in the outline of the first extracted image, and assign values to the pixel points aligned with the center point of the minimum rectangle; apply the Euclidean distance algorithm to the center point of the minimum rectangle to obtain the Euclidean distance between the pixel points aligned with the center point and the edge pixel points of the minimum rectangle, and compare the Euclidean distance with the Euclidean distance corresponding to the center point of the reference image to determine whether the detected capacitor has mixed-size casing defects;
[0083] In this embodiment, the boundingrect function is used to take a screenshot of the first extracted image to extract the image area of interest. The function is to calculate the minimum vertical boundary rectangle of the contour, and the rectangle is parallel to the upper and lower boundaries of the image. Therefore, the area of interest extracted from the image is set to obtain the minimum regular rectangle that covers this contour.
[0084] In this embodiment, the mixed-size defects are mainly judged. The mixed-size defects are that the detection target includes two capacitors of different sizes at the same time, and one of them needs to be eliminated. The difference in size between the detection target and the reference image needs to be judged, so the Euclidean distance algorithm is adopted; the premise of calculating the Euclidean distance is normalization, that is, making the incomparable data comparable while maintaining the relative relationship between the two compared data. In this way, the Euclidean distance between each point on the image region of interest and the center point of the minimum right rectangle can be compared with the Euclidean distance between each point on the reference image template and the center point of the minimum right rectangle. According to the size of the value, it is judged whether the difference between the two falls within the qualified standard range. If the difference is too large or too small, it can be judged that the sleeve corresponding to the image region of interest has defects; similarly, the image region of interest and the reference image can be made on the same picture through normalization scaling, so that it can be judged whether the sleeve has defects according to the relative position on the picture.
[0085] The above detection method is used to detect the specific mixed size defects of the casing. Mixed size defects refer to the mixing of aluminum electrolytic capacitors of different specifications in the test product, which needs to be eliminated. The specific detection method is as follows:
[0086] After the CCD camera system takes the color image of the side of the aluminum electrolytic capacitor, the color image is pre-processed and grayscale converted to eliminate mixed noise in order to better extract image features. After a series of algorithm pre-processing, the color image finds the outer contour of the capacitor, removes the background, and intercepts the outline of the capacitor body.
[0087] In the extracted capacitor body contour, the image HSV range is used for judgment, and the most inscribed rectangle is obtained through a mathematical formula, that is, the rectangular contour image containing only the capacitor but not the pins, which is the image area of interest.
[0088] The capacitor body contour image is sorted to calculate the Euclidean distance of the middle point. According to the pixel measurement ratio provided by the capacitor body contour image, the Euclidean distance algorithm is applied to the center point of the smallest rectangle in the image area of interest to obtain the Euclidean distance between the pixel point aligned with the center point and the pixel point on the rectangle boundary. The Euclidean distance is compared with the Euclidean distance corresponding to the center point of the reference image to calculate the size deviation between the inspected product and the authentic product. According to the preset size deviation range, it is determined whether the inspected product has mixed size defects.
[0089] In a specific embodiment, the above method is used to detect the sleeve defects such as top bald head, top sleeve over-wrapping, and top sleeve warping, and the preliminary extracted image obtained in this embodiment is the top circle image of the aluminum electrolytic capacitor;
[0090] The specific process is as follows: after obtaining the first extracted image, firstly, the edge contour is searched according to the image pixels, and based on the pre-processed image pixels, the image contour of the casing is found at the intersection of the image area and another attribute area; the contour to be searched is a shape with a boundary of the same gray value, and all (x, y) coordinate types on the shape boundary can be stored to form a table, that is, the gray value values in the H channel, S channel, and V channel are divided, and the redundant points on the image contour can be determined according to the numerical values. The algorithm traverses to remove the redundant points on the contour and compresses the contour, thereby saving memory expenses; then the image array is used to store the above image data, the rows of the two-dimensional array correspond to the height of the image, the columns of the two-dimensional array correspond to the width of the image, the elements of the two-dimensional array correspond to the pixels of the image, and the values of the two-dimensional array elements are the gray values of the pixels, so the horizontal coordinate u (u corresponds to x) and the vertical coordinate v (v corresponds to y) of the pixel are the column number and the row number in the image array respectively; the coordinates of each pixel point of the casing contour obtained in the above steps are determined according to the image array, and thus, through mathematical offset addition and subtraction, and AND and OR operations are performed to obtain an image including only the casing contour, that is, the contour of the region of interest.
[0091] In the above process of extracting the image region of interest, the image region of interest is converted into an HSV color gamut image, that is, the image is divided into three single-channel images, including an H channel image, an S channel image, and a V channel image; in this embodiment, a histogram calculation is performed on the image region of interest, and a histogram calculation is performed on the reference image at the same time; then the histogram of the HSV channel and the histogram of the reference image are normalized to the same scale space, and the distance between each point of the histogram of the two is calculated to obtain the similarity of the two histograms, and then the similarity of the images is compared to determine whether the casing has defects.
[0092] Example 3
[0093] Figure 4 A comparison chart of an aluminum electrolytic capacitor with a damaged rubber plug and a genuine capacitor is shown.
[0094] This embodiment performs defect detection on the electrolytic capacitor rubber plug, and the specific process is as follows:
[0095] S1: collecting capacitor plug images and performing preprocessing, wherein the preprocessing includes: grayscale processing, geometric transformation, and image enhancement;
[0096] In the embodiment of the present invention, the captured target is converted into an image signal through a machine vision product, transmitted to a dedicated image processing system, the morphological information of the captured target is obtained, and converted into a digital signal according to the pixel information, brightness, color and other information; in this embodiment, images are collected through an industrial optical imaging system, and mainly two image sensors, CCD and CMOS, are used for image capture; specifically, in this embodiment, the light source and the industrial camera are both set at 45° to the rubber plug surface of the aluminum electrolytic capacitor, and the industrial camera is set on the extension line of the light source.
[0097] The image after acquisition is preprocessed by image processing software, and the preprocessing process is graying, geometric transformation, and image enhancement in sequence; then, in this embodiment, a mathematical fitting method is used to continue processing the acquired image. This method mainly converts a continuous smooth curve into a line and performs multi-deformation fitting on the image contour points. The principle is to use another curve with fewer vertices to approximate a curve or polygon, so that the distance between the two curves is less than or equal to the specified accuracy; the purpose of adopting the mathematical fitting algorithm is that: when the image of the plug surface is acquired, the image of the pin will be captured at the same time, and the image of the pin will interfere with the image of the plug ring, so the mathematical fitting algorithm is used to minimize the interference of the pin image on the plug image, and the acquired pin curve is fitted with the plug contour.
[0098] S2: traverse the pixels of the HSV channel image of the preprocessed image, perform polygon contour operation, separate the specific color corresponding to the rubber plug in the HSV color space, and extract the image region of interest containing the rubber plug contour;
[0099] After the image is preprocessed and irrelevant information is eliminated, the features of the region of interest need to be extracted. Extracting the features of the region of interest from the original image can reduce the image processing time and increase the accuracy. The general method is to find the contour through the edge, identify the table contour, establish mathematical offset coordinates, and extract the feature area. The specific steps are as follows:
[0100] Based on the preprocessed image pixels, the image contour of the bottom circle of the aluminum electrolytic capacitor is found at the intersection of the image area and another attribute area. At this time, the bottom circle contour includes both the outer ring casing contour and the inner ring rubber plug contour; the above-searched contour is a shape with a boundary of the same grayscale value. All (x, y) coordinate types on the shape boundary can be stored to form a table, that is, the grayscale value values in the H channel, S channel, and V channel are divided. The redundant points on the image contour can be determined according to the value size. The algorithm traverses to remove the redundant points on the contour and compresses the contour, thereby saving memory expenses; the image array is used to store the above image data, and the rows of the two-dimensional array correspond to the image The columns of the two-dimensional array correspond to the width of the image, the elements of the two-dimensional array correspond to the pixels of the image, and the values of the elements of the two-dimensional array are the grayscale values of the pixels, so the horizontal coordinate u (u corresponds to x) and the vertical coordinate v (v corresponds to y) of the pixel are the column number and the row number in the image array respectively; according to the above-mentioned image array, the coordinates of each pixel point on the outer ring sleeve contour and the inner ring rubber plug capacitor top circle contour obtained in the above steps are determined, and thus the image including only the rubber plug contour, that is, the contour of the region of interest, is obtained by mathematical offset addition and subtraction, and OR operations are performed; in this embodiment, the region for extracting the region of interest of the image is set to obtain the minimum regular rectangle that wraps this contour.
[0101] S3: Traverse and perform threshold binarization processing on the extracted region of interest of the image, and perform contour tree search. According to the separated specific color, find the pixel area corresponding to the rubber plug, integrate and calculate the area of the area, compare the calculated area with the preset area threshold, and judge whether there is a rubber plug defect in the aluminum electrolytic capacitor under test based on the comparison result.
[0102] In the present embodiment, the defects that need to be detected mainly include broken rubber plugs and missing rubber plugs. When these defects occur, exposed areas with large color difference from the rubber plug will appear on the collected image. These defects can be manifested as changes in the area of the pixel region corresponding to the rubber plug. Therefore, the contour area method is adopted in the present embodiment to traverse the image of the region of interest after preprocessing, perform threshold binarization processing, and then perform contour tree search to find all the pixel regions corresponding to the rubber plug, and integrate and calculate the areas of these regions. Finally, the total area is compared with the preset threshold area to determine whether the rubber plug corresponding to the region of interest has defects.
[0103] In a specific embodiment, the above method is used to detect a specific rubber plug damage defect, and the specific method for detecting the rubber plug damage defect is as follows:
[0104] After the color image is taken by the CCD camera system; the color image is preprocessed and the color image is converted to HSV; after the color image is preprocessed by a series of algorithms, the circle with the largest area of the capacitor is found, the background is removed, the circle is fitted, the discontinuous features are extracted, the pixel points are traversed, the optimal outer circle radius is found, the pixel points inside the circle are assigned, and the image of the capacitor body is cut out from the original image, and unnecessary noise interference and areas are removed;
[0105] For the extracted region of interest, in order to make the contrast more obvious, the region of interest is taken as a feature ring, the image brightness is enhanced, and the image is converted to grayscale and subjected to a series of pre-processing pixel enhancement processes such as median filtering. As shown in the figure, there is an obvious color difference between the area exposed due to the damage of the rubber plug and the rubber plug part. After that, the extracted region of interest of the image is traversed and thresholded binarized, and a contour tree search is performed to find all the pixel areas corresponding to the rubber plug, and the areas of these pixel areas are integrated and calculated. The calculated area is compared with the preset area threshold to determine whether the inspected product is a defective product.
[0106] In a specific embodiment, the above method is used to detect the specific defect of lack of rubber plug, and the specific method is:
[0107] After the color image is taken by the CCD camera system, as shown in the figure; the color image is preprocessed and the color image is converted to HSV; after the color image is preprocessed by a series of algorithms, the circle with the largest area of the capacitor is found, the background is removed, the circle is fitted, the discontinuous features are extracted, the pixel points are traversed, the optimal outer circle radius is found, the pixels inside the circle are assigned, and the image of the capacitor body is extracted from the original image, and unnecessary noise interference and areas are removed; in the extracted contour of the capacitor body, in order to make the contrast more obvious, the feature ring is taken from the area of interest, separated into inner and outer rings, the image is bitwise operated, the inner circle and the outer circle are first subtracted, and the inner circle contour area of interest is obtained; in this embodiment, the areas of interest are all images of the internal filling of the capacitor.
[0108] The extracted region of interest of the image is traversed and thresholded, and a contour tree search is performed to find all pixel regions corresponding to the internal filler. The areas of these pixel regions are integrated and calculated, and the calculated area is compared with the preset area threshold. If the calculated area is greater than the area threshold, it means that the inspected product has a complete lack of a rubber plug, and the rubber plug is not damaged or bulging.
[0109] Example 4
[0110] Figure 5 The figure shows the comparison between the aluminum electrolytic capacitor with lead pin bias and reverse polarity defects and the genuine one.
[0111] In this embodiment, the lead pin defects of the electrolytic capacitor are detected, and the specific process is as follows:
[0112] S1: obtaining a side image of the aluminum electrolytic capacitor body and performing preprocessing, wherein the preprocessing includes: grayscale, denoising, edge extraction, and image enhancement;
[0113] In the embodiment of the present invention, the captured target is converted into an image signal through a machine vision product, and transmitted to a dedicated image processing system to obtain the morphological information of the captured target, and converted into a digital signal according to the pixel information, brightness, color and other information; in this embodiment, an industrial optical imaging system is used to collect images, and two image sensors, CCD and CMOS, are mainly used for image capture; specifically, the light source is placed on both sides of the aluminum electrolytic capacitor, and an industrial camera is provided on the extension line of the connection line between the aluminum electrolytic capacitor and the light sources on both sides, thereby collecting a color image of the entire aluminum electrolytic capacitor, as shown in the figure;
[0114] The image after acquisition is preprocessed by image processing software, and the preprocessing process is graying, denoising, edge extraction, and image enhancement in sequence; then, in this embodiment, a contour tree is created according to the contour of the acquired image, and the contour tree structure traversal is performed, such as Figure 2 As shown, since the cylindrical surface of the aluminum electrolytic capacitor includes two areas of different colors, the contour of the image includes both embedded contours and contours of the same level. The contour tree structure traversal algorithm can enable the feature contour to be embedded in a tree structure, so as to provide a sequence number and provide a base map for the subsequent mathematical offset for selecting the area of interest.
[0115] S2: traversing the HSV channel image of the preprocessed image, separating specific colors in the HSV color space, and extracting the image region of interest; the image region of interest is set to the minimum regular rectangle covering the outline of the cannula and the guide needle;
[0116] After the image is preprocessed and irrelevant information is eliminated, the features of the region of interest need to be extracted. Extracting the features of the region of interest from the original image can reduce the image processing time and increase the accuracy. The general method is to find the contour through the edge, identify the table contour, establish mathematical offset coordinates, and extract the feature area. The specific steps are as follows:
[0117] Based on the preprocessed image pixels, the overall contour of the aluminum electrolytic capacitor is found at the intersection of the image area and another attribute area; the contour found above is a shape with a boundary of the same grayscale value, and all (x, y) coordinate types on the shape boundary can be stored in a table, that is, the grayscale values in the H channel, S channel, and V channel are divided, and the redundant points on the image contour can be determined according to the value. The algorithm traverses to remove the redundant points on the contour and compress the contour, thereby saving memory expenses; the image array is used to store the above image data, and the rows of the two-dimensional array correspond to the height of the image, and the columns of the two-dimensional array correspond to the image The width of the image, the elements of the two-dimensional array correspond to the pixels of the image, and the values of the two-dimensional array elements are the grayscale values of the pixels, so the horizontal coordinate u (u corresponds to x) and the vertical coordinate v (v corresponds to y) of the pixel are the column number and the row number in the image array respectively; according to the above-mentioned image array, the coordinates of each pixel point on the overall outline of the aluminum electrolytic capacitor obtained in the above steps are determined, and thus, through mathematical offset addition and subtraction, and AND and OR operations are performed to obtain an image including only the outline of the sleeve and the lead needle, that is, the outline of the region of interest; in this embodiment, the region for extracting the region of interest of the image is set to obtain the minimum regular rectangle that wraps this outline, as shown in the figure;
[0118] S3: Apply Hough transform to the extracted image region of interest, convert the coordinates of each pixel in the image region of interest into Hough parameter space, determine the pixel coordinate values on the image constituting the region of interest, and then perform coordinate system transformation to transform all pixel coordinate values in the image of the region of interest into curves in parameter space, find the most curves passing through the same point in the parameter space, determine whether there is a straight line in the image, and thus determine whether the aluminum electrolytic capacitor being tested has a lead defect.
[0119] In this embodiment, the defects that need to be detected mainly include lead pin reverse polarity and lead pin bias. The manifestation of these defects can be obtained by detecting whether there is a straight line in the image space of the area of interest. The sleeve on the cylindrical surface of the aluminum electrolytic capacitor is mainly divided into two areas of different colors, among which the smaller area is the negative end of the electrolytic capacitor, and the area is separated from the other large area by two straight lines. If the lead pin is within the area, it means that the lead pin welding position is correct, otherwise it means bias or reverse polarity. Therefore, during the inspection, after the two lead pins of the capacitor are fixed as required, the negative end will be aligned with the industrial camera. If the image captured by the industrial camera contains the above two straight lines, it means that the capacitor lead pin welding material is flawless; if it only contains one straight line, it means that the capacitor lead pin is biased; if it does not contain a straight line, it means that the capacitor lead pin is reversed.
[0120] There is a one-to-one correspondence between the straight lines in the image space and the points in the parameter space, and there is also a one-to-one correspondence between the straight lines in the parameter space and the points in the image space, that is, each straight line in the image space corresponds to a single point in the parameter space, and any part of the line segment on the straight line in the image space corresponds to the same point in the parameter space;
[0121] Therefore, in this embodiment, the pixel coordinate values constituting the image of the region of interest are determined, and then the coordinate system transformation is performed to transform the coordinate values of all pixels in the image of the region of interest into a curve in the parameter space. By detecting the intersection of the curve in the parameter space, it can be determined whether there is a straight line in the image space, thereby judging whether the capacitor lead pin has a defect; Figure 4 As shown, in this embodiment, the coordinate system is changed from y=kx+b to b=-xk+y, which is represented as a bundle of straight lines passing through the point (k, b). Each point on the straight line in the xy space is represented as a straight line passing through (k, b) in the kb coordinate system; the problem of finding all points is transformed into the problem of finding straight lines. For each point in the image, there are many straight lines corresponding to it in the kb coordinate system. Finding the intersection of the straight lines corresponds to finding the straight lines in the image; specifically, the algorithm prepares two containers, a CImg for displaying the hough-space overview, and an array hough-space for storing voting values. The edge data points in the image space are used to calculate the possible trajectory of the reference points in the parameter space, and the count of the reference points is calculated in an accumulator. Finally, the peak value is selected, and the peak value is indicated on a straight line with more collinear points in the image space to judge the number of straight lines.
[0122] In a specific embodiment, the above method is used to detect specific lead pin polarity deviation and lead pin reverse polarity defects, and the specific method is as follows:
[0123] The color image taken by the CCD camera system is shown in the figure; the color image is preprocessed and the color image is converted to HSV; the color image is preprocessed by a series of algorithms to remove the background, extract discontinuous features, traverse the pixels, and extract the image of the capacitor body from the original image, removing unnecessary noise interference and areas; in the extracted capacitor body contour, the area of interest is the smallest regular rectangle that wraps this contour, as shown in the figure.
[0124] Then, the pixel coordinate values on the image of the region of interest are determined, and then the coordinate system transformation is performed to transform the coordinate values of all pixels in the image of the region of interest into a curve in the parameter space. By detecting the intersection of the curve in the parameter space, it can be determined whether there are straight lines in the image space and how many straight lines there are, so as to judge whether there are defects in the capacitor lead pin such as lead pin bias or lead pin reverse polarity.
[0125] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for detecting defects in aluminum electrolytic capacitors based on image processing, characterized in that: The following steps are involved: S1: Acquire the image of aluminum electrolytic capacitor and perform preprocessing; S2: extracting the region of interest from the preprocessed image; S3: performing image conversion processing on the extracted region of interest and comparing it with a preset benchmark to determine the defects of the aluminum electrolytic capacitor; The defects of the electrolytic capacitor include: defects in the capacitor aluminum shell, defects in the capacitor sleeve, defects in the capacitor rubber plug, and defects in the capacitor lead pin; The specific steps of the capacitor aluminum shell defect detection are: Acquire the aluminum shell image of the capacitor and perform preprocessing, the preprocessing of the aluminum shell image includes: grayscale image processing, mean filtering, HSV color space conversion, morphological opening operation processing; After preprocessing, the aluminum shell color and other colors are separated in the HSV color space, the detection area outline is extracted, the detection area outline is traversed pixel by pixel, the area of interest outline is extracted, and the area of interest is determined; The region of interest is channel decomposed and image pixel filling is performed, and then the image in the region of interest and the preset reference image are histogram calculated and normalized, the similarity between the two is calculated, and the similarity is compared with the preset threshold to determine the defects of the capacitor aluminum shell.
2. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 1 is characterized in that: The defects of the capacitor aluminum shell include: convex defects on the top of the aluminum shell, leakage defects on the explosion-proof valve, excessive sleeve wrapping defects, bald head defects, bare product defects, discount defects, and dent defects.
3. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 1, characterized in that: The specific steps for capacitor bushing defect detection are: Preprocessing the collected sleeve image to obtain a first extracted image and a second extracted image, wherein the first extracted image is a side view of the aluminum electrolytic capacitor body; The second extracted image is an image of a top circle of an aluminum electrolytic capacitor, and the preprocessing includes: binarization processing, mean filtering processing, and morphological processing in sequence; A screenshot is taken of the first extracted image, an area of interest of the first image is extracted, the minimum rectangle inscribed in the outline of the first extracted image is calculated, and a value is assigned to a pixel point aligned with the center point of the minimum rectangle; a Euclidean distance algorithm is applied to the center point of the minimum rectangle to obtain a Euclidean distance between the pixel point aligned with the center point and the pixel point on the edge of the minimum rectangle, and the Euclidean distance is compared with the Euclidean distance corresponding to the center point of the reference image to determine whether the detected capacitor has a mixed-size casing defect; Take a screenshot of the extracted image 2, extract the region of interest of the second image, perform histogram calculation and normalization processing on the HSV channel image of the region of interest of the second image and the reference image, calculate the similarity between the two and compare them with the preset similarity threshold, and determine whether the capacitor sleeve has a top bald defect or a top sleeve warping defect.
4. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 2, characterized in that: The specific steps for capacitor plug defect detection are: Collecting the capacitor plug image and preprocessing it, wherein the preprocessing includes: grayscale processing, geometric transformation, and image enhancement; Perform pixel traversal on the HSV channel image of the preprocessed image, perform polygon contour operation, separate the specific color corresponding to the rubber plug in the HSV color space, and extract the image region of interest containing the rubber plug contour; The extracted region of interest of the image is traversed and thresholded, and a contour tree search is performed. According to the separated specific color, the pixel area corresponding to the rubber plug is found, the area of the pixel area is integrated and calculated, and the calculated area is compared with the preset area threshold. According to the comparison result, it is judged whether the aluminum electrolytic capacitor under inspection has a rubber plug defect.
5. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 4 is characterized in that: The capacitor plug defects include: breakage defects, missing plug defects, and bulging plug defects.
6. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 1, characterized in that: The specific steps for capacitor lead pin defect detection are: Obtaining a side image of the aluminum electrolytic capacitor body for preprocessing, wherein the preprocessing includes: grayscale, denoising, edge extraction, and image enhancement; Traversing the HSV channel image of the preprocessed image, separating specific colors in the HSV color space, and extracting the image region of interest; the image region of interest is set to the minimum regular rectangle covering the outline of the cannula and the guide needle; The Hough transform is applied to the extracted image region of interest, and the coordinates of each pixel in the image region of interest are converted into the Hough parameter space, and the pixel coordinate values constituting the image of the region of interest are determined. Then, the coordinate system transformation is performed, and the coordinate values of all pixels in the image of the region of interest are transformed into curves in the parameter space. The curves with the most points passing through the same point are found in the parameter space, and it is determined whether there are straight lines in the image, thereby determining whether there are lead defects in the aluminum electrolytic capacitor being tested.
7. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 6, characterized in that: The capacitor lead pin defects include: polarization defects and lead pin reverse polarity defects.
8. The method for detecting defects of aluminum electrolytic capacitors based on image processing according to claim 6, characterized in that: The preprocessing of the side image of the aluminum electrolytic capacitor body also includes: creating a contour tree according to the contour of the collected image, and traversing the contour tree structure. The contour of the collected image includes both embedded contours and contours at the same level.
