Method, device and equipment for detecting hardware defects
By generating lines in a hardware grayscale image using a seed growth algorithm, calculating derivative values to determine seed points, and growing defect areas, the problem of low accuracy in hardware defect detection is solved, achieving more efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUZHOU HUAXING YUANCHUANG TECH CO LTD
- Filing Date
- 2023-08-30
- Publication Date
- 2026-06-26
Smart Images

Figure CN117218070B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hardware defect detection, and more particularly to a method, apparatus, and equipment for detecting hardware defects. Background Technology
[0002] Defects on the surface of hardware can range from affecting usability to posing safety hazards. Take circuit boards as an example, such as battery protection boards. Battery protection boards protect batteries from problems like over-discharge, overcharge, overcurrent, and short circuits. Defects on the surface of battery protection boards, such as cracks, can cause them to fail, reducing battery life and even leading to safety accidents. Therefore, it is of great significance to detect hardware defects in advance.
[0003] In the process of realizing this invention, the inventors discovered the following problems with the prior art:
[0004] Conventional CCD cameras do not have high enough accuracy, especially considering the noise on the hardware surface that affects defect detection. In particular, there is more noise on the battery protection board, making it even more difficult to accurately extract the defect area. Therefore, existing technologies cannot solve the problem of hardware defect detection very well. Summary of the Invention
[0005] To address the problem of insufficient accuracy in hardware defect detection in the existing technology, the present invention aims to provide a more efficient and accurate method, apparatus, and device for detecting hardware defects. 。
[0006] To achieve the above-mentioned objective, one embodiment of the present invention provides a method for detecting hardware defects, comprising the following steps:
[0007] Acquire hardware grayscale image;
[0008] Based on the aforementioned hardware grayscale image, several seed points are generated;
[0009] Based on the seed points, region growth is performed to obtain the defect region of the hardware;
[0010] The seed point generation step includes:
[0011] Several lines are generated over the hardware grayscale image, and the lines correspond to pixel bands on the hardware grayscale image;
[0012] The derivative of the grayscale values between adjacent pixels is calculated for the pixel band;
[0013] Pixels whose derivative values are greater than the derivative threshold are set as candidate seed points;
[0014] The seed point is determined based on the candidate seed point.
[0015] As a further improvement of the present invention, the step of generating several lines through the hardware grayscale image includes:
[0016] The type of the line is determined based on the shape of the hardware and / or the type of defect to be detected, wherein the defect type includes cracks and scratches.
[0017] As a further improvement of the present invention, the detected defect type is a crack, which extends substantially along a first direction on the hardware.
[0018] The steps that generate the lines in the hardware grayscale image include:
[0019] A plurality of lines are generated through the grayscale image of the hardware, wherein the plurality of lines divide the hardware in a second direction intersecting the first direction.
[0020] As a further improvement of the present invention, the length of the hardware along the first direction is a first length;
[0021] The steps that generate the lines in the hardware grayscale image include:
[0022] Several lines are generated through the grayscale image of the hardware, wherein the several lines divide the hardware into several equal parts along the first length.
[0023] As a further improvement of the present invention, the step of performing region growth based on the seed point includes:
[0024] Based on criteria one and two, the seed points are used for region growth, and the pixels in the hardware grayscale image that meet the growth requirements are divided into a defect set. Criterion one is that the grayscale value of the current pixel is less than the crack grayscale threshold, and criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold.
[0025] The step of performing region growth on the seed point based on criteria one and criteria two includes:
[0026] Detect the undetected pixels adjacent to the current seed point and check if they meet both criteria one and criteria two. If they meet both criteria, use the adjacent pixel as a new seed point to continue growing until all seed points have been grown.
[0027] As a further improvement of the present invention, the step of performing region growth based on the seed point to obtain the defect region of the hardware further includes:
[0028] Obtain crack determination criteria, wherein the crack determination criteria include a height threshold and a width-to-length ratio threshold;
[0029] Based on the seed points, region growth is performed to obtain several defect-like regions;
[0030] Generate the minimum regular rectangle and the minimum bounding rectangle of the defect-like region;
[0031] If the height of the smallest regular rectangle is greater than the length threshold, and the aspect ratio of the smallest bounding rectangle is greater than the aspect ratio threshold, then the corresponding defect-like region is a defect region.
[0032] As a further improvement of the present invention, the detected defect type is a scratch;
[0033] The steps that generate the lines in the hardware grayscale image include:
[0034] Several lines are generated over the hardware grayscale image, wherein the lines cover the entire hardware grayscale image as evenly as possible.
[0035] As a further improvement of the present invention, the step of performing region growth based on the seed point includes:
[0036] Based on criteria two and three, the seed points are used for region growth, and the pixels in the hardware grayscale image that meet the growth requirements are divided into a defect set. Criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold, and criterion three is that the grayscale value of the current pixel is greater than the scratch grayscale threshold.
[0037] As a further improvement of the present invention, the hardware in the hardware grayscale image is rectangular;
[0038] The steps that generate the lines in the hardware grayscale image include:
[0039] Generate several straight lines along the length direction through the hardware grayscale image, each of the straight lines corresponding to a row of pixels along the length direction of the hardware grayscale image.
[0040] As a further improvement of the present invention, the step of differentiating the grayscale values between adjacent pixels of the pixel band includes:
[0041] Calculate the difference between a pixel on the pixel band and its left-side neighboring pixel, and the difference between the pixel and its right-side neighboring pixel. The quotient of the two differences is the derivative of the pixel.
[0042] As a further improvement of the present invention, the step of determining the seed point based on the candidate seed point further includes:
[0043] Set the candidate seed point as the seed point;
[0044] or,
[0045] Among the multiple adjacent pixels in the pixel band where the candidate seed point is located, the pixel with a gray value lower than the lowest gray value threshold or higher than the highest gray value threshold is selected and set as the seed point.
[0046] To achieve one of the above-mentioned objectives, an embodiment of the present invention provides a hardware defect detection device, comprising:
[0047] The acquisition module is used to acquire hardware grayscale images;
[0048] The seed point generation module is used to generate a number of seed points based on the hardware grayscale image;
[0049] A defect region generation module is used to perform region growth based on the seed points to obtain the defect region of the hardware.
[0050] The seed point generation module is further used for:
[0051] Several lines are generated over the hardware grayscale image, and the lines correspond to pixel bands on the hardware grayscale image;
[0052] The derivative of the grayscale values between adjacent pixels is calculated for the pixel band;
[0053] Pixels whose derivative values are greater than the derivative threshold are set as candidate seed points;
[0054] The seed point is determined based on the candidate seed point.
[0055] To achieve one of the above-mentioned objectives, an embodiment of the present invention provides a hardware defect detection device, comprising:
[0056] The loading and unloading station is used for loading and unloading hardware.
[0057] A conveyor line that connects the loading and unloading stations and transmits hardware.
[0058] Inspection stations are located on or to the side of the conveyor line. There are several inspection stations, which are used to detect several types of hardware defects. The inspection stations use the above-mentioned hardware defect detection methods to detect the hardware and upload the detection data.
[0059] The testing station is equipped with a transport mechanism, which moves the hardware to the testing station and, after testing, transfers the hardware to the conveyor line for the next process of testing or unloading.
[0060] As a further improvement of the present invention, the hardware is a battery protection board, and the testing station includes an appearance defect testing station and an electrical performance testing station.
[0061] To achieve one of the above-mentioned objectives, one embodiment of the present invention provides a readable storage medium storing a computer program that, when executed by a processing module, can implement the steps in the above-mentioned hardware defect detection method.
[0062] Compared with the prior art, the present invention has the following beneficial effects: The hardware defect detection method, device and equipment detect defect areas based on the seed growth algorithm, and combined with the characteristics of the hardware, it determines the appropriate seed points in the hardware scene by calculating the derivative of several strip-shaped pixels based on several lines, and then grows based on the seed points; on the one hand, it accurately generates defect areas, making the defect area determination more efficient, and on the other hand, the generated effect is good, and it is not easy to miss or identify non-defect areas as defect areas. Therefore, the detection method and device can improve both the detection efficiency and the detection accuracy of hardware defects. Attached Figure Description
[0063] Figure 1 This is a flowchart of a hardware defect detection method according to an embodiment of the present invention;
[0064] Figure 2 This is a schematic diagram of a detection image according to an embodiment of the present invention;
[0065] Figure 3 yes Figure 1 A flowchart of one specific implementation of step S20;
[0066] Figure 4 This is a schematic diagram of one embodiment of the present invention for generating several lines;
[0067] Figure 5 This is a schematic diagram of another embodiment of the present invention for generating several lines;
[0068] Figure 6 This is a schematic diagram of another embodiment of the present invention for generating several lines;
[0069] Figure 7 yes Figure 1 A flowchart of one specific implementation of step S30;
[0070] Figure 8 This is a schematic diagram showing that the detected defect area is a crack according to the first embodiment of the present invention;
[0071] Figure 9 This is a schematic diagram of drawing the minimum regular rectangle and the minimum bounding rectangle for a defect-like region according to an embodiment of the present invention;
[0072] Figure 10a This is a schematic diagram of one embodiment of the generation of several lines according to the second embodiment of the present invention;
[0073] Figure 10b This is a schematic diagram of another embodiment of the second embodiment of the present invention for generating several lines;
[0074] Figure 11 This is a schematic diagram showing that the detected defect area is a scratch according to the second embodiment of the present invention;
[0075] Figure 12 This is a schematic diagram of a hardware defect detection device according to an embodiment of the present invention. Detailed Implementation
[0076] The present invention will now be described in detail with reference to the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present invention, and any structural, methodological, or functional modifications made by those skilled in the art based on these embodiments are included within the scope of protection of the present invention.
[0077] One embodiment of the present invention provides a method, apparatus, and device for detecting hardware defects that are more efficient and have higher detection accuracy.
[0078] In this embodiment, defects on the hardware surface are detected. These defects can be identified by analyzing images captured by optical equipment. The defects discussed below mainly include two types: cracks and scratches. Cracks refer to fracture-like patterns on the material surface, while scratches refer to marks left on the material surface by other objects with higher hardness.
[0079] Hardware can be circuit boards, wafers, chips, casings, or other tangible products, such as the battery protection board in the circuit board described in the background art. The battery protection board is mainly used to monitor the battery status, and its upper surface is generally rectangular. Hardware can also be optical lenses or optical glass or display products, such as the glass plate or lens of a camera lens. Such lenses are generally circular.
[0080] Correspondingly, taking a circuit board as an example, the focus is more on defects such as cracks. Of course, scratches can also be detected on circuit boards, as scratches may damage the traces on the circuit board surface. Taking an optical lens as an example, the focus is more on defects such as scratches. Cracks are characterized by a darker color compared to areas without cracks, which is reflected in a lower grayscale value on a grayscale image; scratches are characterized by a lighter color compared to areas without scratches, which is reflected in a higher grayscale value on a grayscale image.
[0081] The following description is divided into two embodiments. Embodiment 1 is described using a crack as an example of a defect type, and Embodiment 2 is described using a scratch as an example of a defect type. The hardware of Embodiment 1 is described using a circuit board as an example. More specifically, the circuit board can be a battery protection board.
[0082] Example 1
[0083] The following description, in conjunction with the accompanying drawings, illustrates a method for detecting hardware defects provided in Embodiment 1 of the present invention. Although this application provides method operation steps as shown in the following embodiments or flowcharts, the execution order of steps in which there is no necessary causal relationship in logic, based on conventional or non-creative labor, is not limited to the execution order provided in the embodiments of this application.
[0084] This embodiment provides a method for detecting hardware defects, such as... Figure 1 As shown, it includes the following steps S10-S30:
[0085] Step S10: Acquire a hardware grayscale image;
[0086] Step S20: Generate several seed points based on the hardware grayscale image;
[0087] Step S30: Perform region growth based on the seed points to obtain the defect region of the hardware.
[0088] The following is a detailed explanation of these three steps.
[0089] Step S10
[0090] Step S10 may include steps S11-S14, or may include step S15 as needed.
[0091] Step S11: Acquire the detection image.
[0092] The detection image includes the hardware to be detected, and may also include other background areas besides the hardware. Figure 2 The black area shown is the circuit board, and the other white or light-colored content is the background area.
[0093] Step S12: Identify the detection image and extract the position and angle of the hardware in the detection image.
[0094] Still with Figure 2 For example, since the detection image contains other content besides the circuit board, and the angle of the circuit board is not fixed, and the bottom edge of the circuit board is not parallel to the bottom edge of the detection image, in order to prevent the background area from affecting the subsequent extraction of defects, it is necessary to separate the circuit board from other background areas. Here, image recognition methods are used to extract the position and angle of the hardware.
[0095] Step S13: Extract the hardware image from the detection image based on the hardware's position and angle.
[0096] The hardware image only includes the hardware. Figure 2The background area was removed. And with Figure 2 Taking the upper surface of the hardware as an example, which is rectangular, based on the angle in step S12, it can be rotated until the bottom edge is horizontal.
[0097] Step S14: Generate a grayscale image based on the hardware image.
[0098] The grayscale image obtained here can be the hardware grayscale image described in step S10.
[0099] In addition, after obtaining the grayscale image in step S14, step S15 can be continued:
[0100] Step S15: Enhance the contrast of the grayscale image using an image enhancement method based on logarithmic transformation to generate a hardware grayscale image.
[0101] The hardware in this embodiment is a circuit board. The hard plastic material on the circuit board surface makes the contrast of the defect targeted in Embodiment 1, namely the crack defect, not obvious. Therefore, step S15 is added to enhance the contrast between the defect area and the background content outside the defect area in the grayscale image, resulting in the final hardware grayscale image. The formula for the logarithmic transformation is as follows:
[0102] s = clog(1+r), where c is a constant and r≥0.
[0103] Step S20
[0104] Step S20 can be as follows Figure 3 As shown, it includes the following steps S21-S24.
[0105] Step S21: Generate several lines passing through the hardware grayscale image, the lines corresponding to pixel bands on the hardware grayscale image.
[0106] Here, several lines can be generated based on the following steps S211-S212, or may also include step S213:
[0107] Step S211: Determine the type of the line based on the shape of the hardware and / or the type of defect to be detected.
[0108] Step S211 specifically includes three cases:
[0109] (1) Determine the type of the line based on the shape of the hardware;
[0110] (2) Determine the type of the line according to the type of defect to be detected;
[0111] (3) Determine the type of the line based on the shape of the hardware and the type of defect to be detected.
[0112] In the first case, Figure 4 , Figure 5 , Figure 6 For example, if the hardware is rectangular, the lines are straight; if the hardware has wavy edges, the lines are also wavy; if the hardware is circular, the lines are also circular. The specific purpose of this setting is to select lines that match the shape of the hardware based on its shape.
[0113] In the second scenario, considering the defect addressed in Example 1 as a crack, cracks generally grow in a certain direction, meaning they have a certain orientation. Here, the crack extends essentially along the first direction on the hardware. Since the crack is not a straight line, "essentially" here means that the crack can bend or tilt to some extent, but it extends essentially along the first direction. For example, on a rectangular circuit board, the crack essentially extends along the width direction. Therefore, in the second scenario, the line is preferably one that can cut through the crack, and this line does not necessarily have to be parallel to the direction of crack extension.
[0114] The third scenario, which combines the first and second scenarios mentioned above, has the effect of a combination of both.
[0115] Step S212: Generate a plurality of lines passing through the grayscale image of the hardware, wherein the plurality of lines divide the hardware in a second direction intersecting the first direction.
[0116] That is, the generated lines can cut into the cracks on the hardware as much as possible. Preferably, the first direction is perpendicular to the second direction, for example, the first direction is vertical and the second direction is horizontal.
[0117] Furthermore, the length of the hardware along the first direction is the first length; with Figure 4 Taking a rectangle as an example, the first direction is the width, and the first length is the width; Figure 5 Taking the irregularly shaped hardware as an example, the first direction is similar to the width of a rectangle, and the first length is similar to the width of a rectangle; Figure 6 Taking a circle as an example, the first direction is the radius direction, and the first length is the radius or diameter.
[0118] Step S213: Generate several lines passing through the grayscale image of the hardware, wherein the several lines divide the hardware into several equal parts along the first length.
[0119] The number of lines can be n, dividing the image into n+1 equal regions, where n≥1. The purpose of this division is that, when n=1, the image is bisected at the center, allowing the lines to intersect the crack as much as possible. When n>1, for example, dividing the image into three equal parts, prevents the crack at one location from being insignificant and affecting detection. This allows for detection across as many areas of the image as possible at multiple locations, improving detection accuracy.
[0120] Here again Figure 4 Taking a rectangular hardware as an example, with straight lines, the hardware grayscale image can be divided into multiple equally sized rectangular strips; Figure 5 Taking an irregularly shaped hardware as an example, with wavy lines, the hardware grayscale image can be divided into multiple equally sized wavy strips; Figure 6 Taking a circle as an example, the lines are circular, and the first length is divided into several equal parts, which are the equal parts of the radius (or diameter). For example... Figure 6 Divide the radius into three equal parts, creating three concentric circles.
[0121] Here again Figure 4 For example, and combining this with the third case mentioned above, that is, considering that the hardware in the grayscale image is rectangular and that the defect in this embodiment is a crack, the process of generating several lines is explained:
[0122] Generate several straight lines along the length direction through the hardware grayscale image, each of the straight lines corresponding to a row of pixels along the length direction of the hardware grayscale image.
[0123] Here, the image is divided into n+1 regions by n straight lines. The positions of these n straight lines in the hardware grayscale image, and the row of pixels where each line is located, constitute a pixel band. Finally, these n pixel bands are extracted.
[0124] Step S22: Calculate the derivative of the grayscale values between adjacent pixels in the pixel band.
[0125] Step S22 specifically includes:
[0126] Calculate the difference between a pixel and its left-side neighboring pixel, and the difference between the pixel and its right-side neighboring pixel. The quotient of the two differences is the derivative of the pixel.
[0127] Step S23: Set the pixels whose derivative values are greater than the derivative threshold as candidate seed points;
[0128] A point with a larger derivative value corresponds to a sudden change in pixel at that location, which may indicate a defect, such as a crack or scratch. The candidate seed point is a possible seed point.
[0129] Step S24: Determine the seed point based on the candidate seed point.
[0130] Step S24 includes two implementation methods, one of which is:
[0131] Set the candidate seed point as the seed point;
[0132] Another implementation method is:
[0133] Among the multiple adjacent pixels in the pixel band where the candidate seed point is located, the pixel with a gray value lower than the lowest gray value threshold or higher than the highest gray value threshold is selected and set as the seed point. Alternatively, in some embodiments, the point with the lowest gray value or the point with the highest gray value can be selected as the seed point.
[0134] The candidate seed points obtained in step S23 are pixels where there is a sudden change in pixel position. These may be at the edge of a crack or scratch. Pixels inside the defect may have relatively small sudden changes in pixel position. Therefore, in this embodiment, seed points located more inside the defect are searched for near the candidate seed points. "Nearby" means that the m pixels to the left and the m pixels to the right of the candidate seed point on the pixel band are all considered as nearby pixels.
[0135] For example, for cracks, the gray values inside the crack are generally lower, so we select pixels with gray values lower than the minimum gray threshold as seed points.
[0136] For example, for scratches, the grayscale value inside the crack is generally higher, so we select pixels with grayscale values higher than the highest grayscale threshold as seed points.
[0137] Step S30
[0138] Step S30 can be as follows Figure 7 As shown, it includes the following steps S31-S35.
[0139] Step S31: Based on criteria one and criteria two, perform region growth on the seed points, and divide the pixels in the hardware grayscale image that meet the growth requirements into a defect set. Criterion one is that the grayscale value of the current pixel is less than the crack grayscale threshold, and criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold.
[0140] Step S32: Obtain crack determination conditions, wherein the crack determination conditions include a height threshold and a width-to-length ratio threshold.
[0141] In this embodiment 1, based on the general morphology of cracks, two judgment conditions, a height threshold and a width-to-length ratio threshold, are determined. Cracks are generally elongated and can even penetrate the entire circuit board in the first direction. For example... Figure 4 For a rectangular plate fracture from top to bottom, all length thresholds are used to determine whether the crack defect is long enough, and the width-to-length ratio threshold is used to determine whether the crack defect is thin enough. When both of these threshold conditions are met, it is considered a crack defect.
[0142] Step S33: Perform region growth based on the seed points to obtain several defect-like regions;
[0143] Based on the above criteria one and two, a seed growth algorithm is applied to the hardware grayscale image to search for pixels close to the seed point. Each search compares the undetected pixels adjacent to the current seed point. For example, if all the pixels adjacent to a seed point are undetected, then the adjacent pixels are the 8 pixels around the seed point. It is then checked whether these pixels meet criteria one and two. If they meet both criteria, they are used as new seed points to continue growing. This process is repeated for all seed points until growth is complete.
[0144] Here you can refer to Figure 8 As shown, a corresponding mask image is generated, in which all pixels in the region grown based on the seed point are 1, and all other pixels are 0.
[0145] Step S34: Generate the minimum regular rectangle and the minimum bounding rectangle of the defect-like region.
[0146] Step S35: Determine whether the height of the smallest regular rectangle is greater than the height threshold, and whether the aspect ratio of the smallest bounding rectangle is greater than the aspect ratio threshold.
[0147] The minimum regular rectangle and the minimum bounding rectangle can be referenced respectively. Figure 9 As shown, one side of the smallest regular rectangle is parallel to the first direction, and the smallest bounding rectangle is the smallest rectangle circumscribed in the defect-like region. The height threshold and the height of the smallest regular rectangle can be referenced... Figure 9 The height of the rectangle; the aspect ratio threshold; and the aspect ratio of the minimum bounding rectangle can be found in [reference]. Figure 9 The ratio of width to length in the text.
[0148] If the height of the smallest regular rectangle is greater than the height threshold, and the aspect ratio of the smallest bounding rectangle is greater than the aspect ratio threshold, that is, both of the above conditions are met, then the corresponding defect-like region is a defect region.
[0149] If at least one of the above two conditions is not met, it is considered noise, not a defect area.
[0150] The final generated mask image is as follows Figure 8 As shown, only the second region on the left is a defect region, that is, a crack region that runs through the width direction; the regions generated by the other seed points are noise regions.
[0151] Example 2
[0152] The difference between Example 2 and Example 1 lies in the type of defect detected; Example 2 detects scratches. Except for the following descriptions of some differences, the implementation methods for other undescribed parts can be found in Example 1.
[0153] Step S21 in Example 1 is specifically described in Example 2 as follows:
[0154] Several lines are generated over the hardware grayscale image, wherein the lines cover the entire hardware grayscale image as evenly as possible.
[0155] Here, "as much as possible" means that it can be either absolutely uniform or, in a general sense, a relative uniformity, such as in Example 1. Figure 4 , 5 The uniformity of 6, or the uniformity of slanted lines, such as Figure 10a As shown, the entire hardware grayscale image can also be evenly divided by a U-shaped line, such as... Figure 10b As shown.
[0156] Because scratches can appear in any location and in any form in the hardware grayscale image, having several lines cover all locations of the entire hardware grayscale image as evenly as possible is beneficial for detecting defects at each location.
[0157] Furthermore, step S31 in Embodiment 1 is replaced in Embodiment 2 as follows:
[0158] Based on criteria two and three, the seed points are used for region growth, and the pixels in the hardware grayscale image that meet the growth requirements are divided into a defect set. Criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold, and criterion three is that the grayscale value of the current pixel is greater than the scratch grayscale threshold.
[0159] Here, since the gray value of the scratch is higher than that of the non-scratched area, the above-mentioned criteria two and three are adopted. Correspondingly, the other steps of step S30 are also adjusted in response to the scratch. For example, step S32 is replaced by: obtaining the scratch judgment condition. Scratches are generally long and thin, so the scratch judgment condition can also include a height threshold and a width-to-length ratio threshold. However, scratches do not necessarily extend along the first direction, so the height threshold and the width-to-length ratio threshold of the judgment condition corresponding to the scratch can be smaller. The specific values can be obtained from experiments.
[0160] The final generated mask image is as follows Figure 11 As shown, only the central area is a defect area, that is, the scratch area extending in the left and right directions; the areas generated by the other seed points are noise areas.
[0161] Compared with the prior art, this embodiment has the following beneficial effects:
[0162] The method and apparatus for detecting hardware defects are based on a seed growth algorithm to detect defect areas. In combination with the characteristics of the hardware, the derivatives of several strip-shaped pixels are calculated based on several lines to determine suitable seed points in the hardware scene. Then, growth is performed based on these seed points. On the one hand, the defect area is accurately generated, making the defect area determination more efficient. On the other hand, the generated effect is good, and it is not easy to miss or identify non-defect areas as defect areas. Therefore, the detection method and apparatus can improve both the detection efficiency and the detection accuracy of hardware defects.
[0163] Hardware defect detection device
[0164] In one embodiment, a hardware defect detection device is provided, such as... Figure 12 As shown. The hardware defect detection device includes the following modules, and the specific functions of each module are as follows:
[0165] The acquisition module is used to acquire hardware grayscale images;
[0166] The seed point generation module is used to generate a number of seed points based on the hardware grayscale image;
[0167] A defect region generation module is used to perform region growth based on the seed points to obtain the defect region of the hardware.
[0168] The seed point generation module is further used for:
[0169] Several lines are generated over the hardware grayscale image, and the lines correspond to pixel bands on the hardware grayscale image;
[0170] The derivative of the grayscale values between adjacent pixels is calculated for the pixel band;
[0171] Pixels whose derivative values are greater than the derivative threshold are set as candidate seed points;
[0172] The seed point is determined based on the candidate seed point.
[0173] It should be noted that for details not disclosed in the hardware defect detection device of this embodiment of the invention, please refer to the details disclosed in the hardware defect detection method of this embodiment of the invention.
[0174] Those skilled in the art will understand that the schematic diagram is merely an example of a hardware defect detection device and does not constitute a limitation on the terminal device of the hardware defect detection device. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, the hardware defect detection device may also include input / output devices, network access devices, buses, etc.
[0175] The hardware defect detection device may also include computing devices such as computers, laptops, handheld computers, and cloud servers, as well as, but not limited to, processing modules, storage modules, and computer programs stored in the storage modules and executable on the processing modules, such as the hardware defect detection method program described above. When the processing module executes the computer program, it implements the steps in the various hardware defect detection method embodiments described above, for example... Figure 1 , 3 The steps shown in 7.
[0176] Hardware defect detection equipment
[0177] In one embodiment, a hardware defect detection device is provided, comprising:
[0178] The loading and unloading station is used for loading and unloading hardware.
[0179] A conveyor line that connects the loading and unloading stations and transmits hardware.
[0180] Inspection stations are located on or to the side of the conveyor line. There are several inspection stations, which are used to detect several types of hardware defects. The inspection stations use the above-mentioned hardware defect detection methods to detect the hardware and upload the detection data.
[0181] The testing station is equipped with a transport mechanism, which moves the hardware to the testing station and, after testing, transfers the hardware to the conveyor line for the next process of testing or unloading.
[0182] In one embodiment, the hardware is a battery protection board, and the testing station includes an appearance defect testing station and an electrical performance testing station.
[0183] In addition, the present invention also proposes an electronic device, which includes a storage module and a processing module. When the processing module executes the computer program, it can implement the steps in the above-mentioned hardware defect detection method, that is, implement the steps in any of the technical solutions of the above-mentioned hardware defect detection method.
[0184] The electronic device can be part of a hardware defect detection device, a local terminal device, or part of a cloud server.
[0185] The processing module can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processing module is the control center of the hardware defect detection device, connecting all parts of the device via various interfaces and lines.
[0186] The storage module can be used to store the computer programs and / or modules. The processing module implements various functions of the hardware defect detection device by running or executing the computer programs and / or modules stored in the storage module and by calling the data stored in the storage module. The storage module may mainly include a program storage area and a data storage area, wherein the program storage area may store the operating system, at least one application program required for a function, etc. In addition, the storage module may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0187] For example, the computer program can be divided into one or more modules / units, which are stored in a storage module and executed by a processing module to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in a hardware defect detection device.
[0188] Furthermore, one embodiment of the present invention provides a readable storage medium storing a computer program, which, when executed by a processing module, can implement the steps in the above-described circuit board defect detection method, that is, implement the steps in any of the technical solutions of the above-described circuit board defect detection method.
[0189] If the integrated module of the circuit board defect detection method is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by the processing module, it can implement the steps of the above-described method embodiments.
[0190] The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include any entity or device capable of carrying the computer program code, recording media, U disks, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0191] It should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This way of describing the specification is only for clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
[0192] The detailed descriptions listed above are merely specific descriptions of feasible embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. All equivalent embodiments or modifications made without departing from the spirit of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for detecting hardware defects, characterized in that, Includes the following steps: Acquire hardware grayscale image; Based on the aforementioned hardware grayscale image, several seed points are generated; Based on the seed points, region growth is performed to obtain the defect region of the hardware; The seed point generation step includes: Based on the shape of the hardware and / or the type of defect to be detected, several lines are generated through the grayscale image of the hardware, the defect types including cracks and scratches, and the lines correspond to pixel bands on the grayscale image of the hardware. The derivative of the grayscale values between adjacent pixels in the pixel band is calculated. The derivative calculation process includes: calculating the difference between a pixel in the pixel band and the pixel to the left of the pixel and the pixel to the right of the pixel. The quotient of the two differences is the derivative corresponding to the pixel. Pixels whose derivative values are greater than the derivative threshold are set as candidate seed points; Based on the candidate seed point, select the pixel with a gray value lower than the lowest gray value threshold or higher than the highest gray value threshold from among the multiple adjacent pixels in the pixel band where the candidate seed point is located, and determine it as the seed point.
2. The method for detecting hardware defects according to claim 1, characterized in that, The steps that generate the lines in the hardware grayscale image include: Determine the type of the line.
3. The method for detecting hardware defects according to claim 2, characterized in that, The detected defect type is a crack, which extends substantially along a first direction on the hardware; The steps that generate the lines in the hardware grayscale image include: A plurality of lines are generated through the grayscale image of the hardware, wherein the plurality of lines divide the hardware in a second direction intersecting the first direction.
4. The method for detecting hardware defects according to claim 3, characterized in that, The length of the hardware along the first direction is the first length; The steps that generate the lines in the hardware grayscale image include: Several lines are generated from the grayscale image of the hardware, wherein the several lines divide the hardware into several equal parts along the first length.
5. The method for detecting hardware defects according to claim 3, characterized in that, The step of performing region growth based on the seed point includes: Based on criteria one and two, the seed points are used for region growth, and the pixels in the hardware grayscale image that meet the growth requirements are divided into a defect set. Criterion one is that the grayscale value of the current pixel is less than the crack grayscale threshold, and criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold. The step of performing region growth on the seed point based on criteria one and criteria two includes: Detect the undetected pixels adjacent to the current seed point and check if they meet both criteria one and criteria two. If they meet both criteria, use the adjacent pixel as a new seed point to continue growing until all seed points have been grown.
6. The method for detecting hardware defects according to claim 3, characterized in that, The step of performing region growth based on the seed point to obtain the defect region of the hardware further includes: Obtain crack determination criteria, wherein the crack determination criteria include a height threshold and a width-to-length ratio threshold; Based on the seed points, region growth is performed to obtain several defect-like regions; Generate the minimum regular rectangle and the minimum bounding rectangle of the defect-like region; If the height of the smallest regular rectangle is greater than the height threshold, and the aspect ratio of the smallest bounding rectangle is greater than the aspect ratio threshold, then the corresponding defect-like region is a defect region.
7. The method for detecting hardware defects according to claim 2, characterized in that, The detected defect type is scratch; The steps that generate the lines in the hardware grayscale image include: Several lines are generated over the hardware grayscale image, wherein the several lines cover the entire hardware grayscale image as evenly as possible. The step of performing region growth based on the seed point includes: Based on criteria two and three, the seed points are used for region growth, and the pixels in the hardware grayscale image that meet the growth requirements are divided into a defect set. Criterion two is that the difference between the grayscale value of the current pixel and the grayscale value of the seed point is less than the difference threshold, and criterion three is that the grayscale value of the current pixel is greater than the scratch grayscale threshold.
8. The method for detecting hardware defects according to claim 2, characterized in that, The hardware in the grayscale image is rectangular; The steps that generate the lines in the hardware grayscale image include: Generate several straight lines along the length direction through the hardware grayscale image, each of the straight lines corresponding to a row of pixels along the length direction of the hardware grayscale image.
9. A hardware defect detection device, characterized in that, include: The acquisition module is used to acquire hardware grayscale images; The seed point generation module is used to generate a number of seed points based on the hardware grayscale image; A defect region generation module is used to perform region growth based on the seed points to obtain the defect region of the hardware. The seed point generation module is further used for: Based on the shape of the hardware and / or the type of defect to be detected, several lines are generated through the grayscale image of the hardware, the defect types including cracks and scratches, and the lines correspond to pixel bands on the grayscale image of the hardware. The derivative of the grayscale values between adjacent pixels in the pixel band is calculated. The derivative calculation process includes: calculating the difference between a pixel in the pixel band and the pixel to the left of the pixel and the pixel to the right of the pixel. The quotient of the two differences is the derivative corresponding to the pixel. Pixels whose derivative values are greater than the derivative threshold are set as candidate seed points; Based on the candidate seed point, select the pixel with a gray value lower than the lowest gray value threshold or higher than the highest gray value threshold from among the multiple adjacent pixels in the pixel band where the candidate seed point is located, and determine it as the seed point.
10. A hardware defect detection device, characterized in that, include: The loading and unloading station is used for loading and unloading hardware. A conveyor line that connects the loading and unloading stations and transmits hardware. The inspection station is located on or to the side of the conveyor line. There are several inspection stations, which are used to detect several types of hardware defects. The inspection station adopts the hardware defect detection method as described in any one of claims 1-8 to detect the hardware and upload the detection data. The testing station is equipped with a transport mechanism, which moves the hardware to the testing station and, after testing, transfers the hardware to the conveyor line for the next process of testing or unloading.
11. The hardware defect detection device according to claim 10, characterized in that, The hardware is a battery protection board, and the testing station includes an appearance defect testing station and an electrical performance testing station.
12. A readable storage medium storing a computer program, characterized in that, When executed by the processing module, the computer program can implement the steps of the hardware defect detection method according to any one of claims 1 to 8.