Lead position offset detection method, system, electronic device, and storage medium
By determining the preset distribution area and specific circumscribed rectangle of the lead in the magnetic image, the problems of low lead position offset detection accuracy and high training difficulty in the existing technology are solved, and efficient and accurate lead offset detection is achieved.
Patent Information
- Application Number
- CN202211309208.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-25
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-10-25
AI Technical Summary
In the existing technology, the detection accuracy of magnet lead position offset is low, the training difficulty is high, the training cycle is long, and the versatility is poor, making it difficult to adapt to the lead position offset defect judgment of different types of magnets.
By determining the preset distribution area of the leads in the image to be detected, the position and direction of each lead are determined, and the method of a specific circumscribed rectangle is used to determine whether the lead is offset. The two sides of the specific circumscribed rectangle are parallel to the direction of the lead, which simplifies the calculation space and improves the detection accuracy.
The efficiency and accuracy of lead position offset detection are significantly improved, the model training process is simplified, the versatility of the solution is enhanced, and it is suitable for lead offset detection in various forms.
Smart Images

Figure CN115908266B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and more specifically to a lead position offset detection method, a lead position offset detection system, an electronic device, and a storage medium. Background Art
[0002] In recent years, computer vision has been widely used in various fields. For example, to prevent the adverse effects of lead wire misalignment on magnet performance, computer vision technology can be applied to images of magnets to determine if each lead wire exhibits misalignment, allowing for rapid detection and repair.
[0003] For example, in the prior art, an image of a magnet to be inspected is fed into a trained classification model. The model then outputs a classification result indicating whether a lead is misaligned, thereby directly making a preliminary determination of the defect. However, the number and position of leads in a magnet are complex and variable, and the criteria for determining a misaligned lead position defect vary for different types of magnets. Consequently, this classification model has low detection accuracy. Furthermore, the classification model requires training with a large number of sample images, which is challenging and time-consuming. Furthermore, any change in the defect determination criteria requires retraining the model, limiting its versatility. Summary of the Invention
[0004] The present application is proposed in consideration of the above-mentioned issues. According to one aspect of the present application, a method for detecting lead position offset is provided, comprising: determining a preset distribution area of lead lines in an image to be detected; determining the position and direction of the lead lines within each preset distribution area; determining a specific bounding rectangle for each preset distribution area, wherein two sides of the specific bounding rectangle are parallel to the direction of the corresponding lead line; and determining whether the lead line is offset based on the position of each lead line within the corresponding specific bounding rectangle.
[0005] Exemplarily, determining the position and direction of the lead in each preset distribution area includes: determining a minimum circumscribed rectangle of the lead; and determining the position and direction of the lead based on the minimum circumscribed rectangle.
[0006] Exemplarily, judging whether the lead is offset based on the position of each lead in the corresponding specific circumscribed rectangle includes: fitting the lead according to the minimum circumscribed rectangle, wherein the lead is parallel to the longer side of the minimum circumscribed rectangle; and determining whether the lead is offset based at least on the relative position relationship between the lead and the specific circumscribed rectangle.
[0007] Exemplarily, judging whether the lead is offset based on the position of each lead in the corresponding specific circumscribed rectangle includes: determining a first distance between the lead and a parallel side of the specific circumscribed rectangle parallel to the direction of the lead; and determining whether the lead is offset based on the first distance.
[0008] Exemplarily, judging whether the lead is offset based on the position of each lead in the corresponding specific circumscribed rectangle includes: determining a second distance between the lead head and / or lead tail of the lead and the vertical side of the specific circumscribed rectangle; and determining whether the lead is offset based on the second distance, wherein the vertical side is perpendicular to the direction of the lead.
[0009] Exemplarily, the number of leads in the image to be detected is at least 2, and at least 2 leads are spaced apart and arranged around a preset object. The method also includes: determining the lead head and lead tail of the lead based on the relative position relationship between the lead and the preset object, wherein the lead end with a larger distance from the preset object is the lead tail, and the lead end with a smaller distance from the preset object is the lead head.
[0010] Exemplarily, there are multiple leads, and at least two leads are spaced apart and distributed around a preset object. The method also includes: determining the center point of each lead; connecting the center points of multiple leads to obtain a closed figure; and determining the lead end of each lead located within the closed figure as the lead head of the lead, and determining the lead end of each lead located outside the closed figure as the lead tail of the lead.
[0011] Exemplarily, the method further includes: determining the center point of the image to be detected; calculating the distance between the two endpoints of each lead and the center point respectively; and determining the lead end of each lead with a larger distance from the center point as the lead tail of the lead.
[0012] Exemplarily, determining the preset distribution area of the leads in the image to be detected includes: inputting the image to be detected into a trained first model to output the preset distribution area of each lead; and / or determining the minimum enclosing rectangle of the leads includes: inputting the image to be detected into a trained second model to output the minimum enclosing rectangle of each lead.
[0013] Exemplarily, the first model includes a segmentation model, and the second model includes a rotation object detection model.
[0014] According to the second aspect of the present application, a lead position offset detection system is also provided, including: a first determination module for determining a preset distribution area of the lead in the image to be detected; a second determination module for determining the position and direction of the lead in each preset distribution area; a third determination module for determining a specific circumscribed rectangle of each preset distribution area, wherein two sides of the specific circumscribed rectangle are parallel to the direction of the corresponding lead; and a judgment module for judging whether the lead is offset based on the position of each lead in the corresponding specific circumscribed rectangle.
[0015] According to a third aspect of the present application, an electronic device is also provided, comprising a processor and a memory, wherein the memory stores computer program instructions, which are used by the processor to execute the above-mentioned lead position offset detection method when the computer program instructions are executed.
[0016] According to a fourth aspect of the present application, a storage medium is further provided, on which program instructions are stored. The program instructions are used to execute the above-mentioned lead position offset detection method when running.
[0017] According to the above scheme, by determining the specific circumscribed rectangle of the preset distribution area of each lead that is parallel to the lead direction, and based on the position of each lead in the specific circumscribed rectangle of its preset distribution area, it is determined whether the lead is offset. In this scheme, the method of using a specific circumscribed rectangle to represent the position of the preset distribution area is adopted. The scheme is simpler, can save computing space to a large extent, and can significantly improve the efficiency of lead position offset detection. Moreover, since the sides of the specific circumscribed rectangle are parallel to the lead, the scheme of using the relative position relationship between each lead and the corresponding specific circumscribed rectangle to determine whether the lead is offset is more accurate and the detection accuracy is also higher. The preset distribution area of the lead and the position and direction of the lead are determined separately, so there is no interference between these two steps. If a model is used to implement these two steps, the model is easier to train. In addition, this scheme can also adapt to the offset detection of leads of various forms. Therefore, the versatility of the scheme is also good.
[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and other purposes, features, and advantages of the present application will become more apparent through a more detailed description of the embodiments of the present application in conjunction with the accompanying drawings. The accompanying drawings are intended to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the present application and do not constitute a limitation of the present application. In the drawings, the same reference numerals generally represent the same components or steps.
[0020] Figure 1 A schematic flow chart of a lead position deviation detection method according to an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram of an image to be detected according to an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram showing the minimum circumscribed rectangle of a lead line in an image to be detected and a preset distribution area of the lead line according to one embodiment of the present application is shown;
[0023] Figure 4 A schematic diagram of a post-processed image of an image to be detected according to one embodiment of the present application is shown;
[0024] Figure 5 A schematic diagram showing a lead position deviation detection method according to another embodiment of the present application is shown;
[0025] Figure 6 A schematic block diagram of a lead position deviation detection system according to an embodiment of the present application is shown; and
[0026] Figure 7 A schematic block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solutions and advantages of the present application more apparent, the following is a detailed description of example embodiments of the present application with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application, and it should be understood that the present application is not limited to the example embodiments described herein. Based on the embodiments of the present application described in this application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of this application.
[0028] As mentioned above, for some electronic devices such as magnets that include leads, the leads should be located in appropriate positions, for example, by fixing the leads in the correct position or desired position of the corresponding soldering area of the disk through a soldering operation. If the position of the lead deviates from the allowable range of its correct position or desired position during soldering, that is, if it is shifted, it may cause the position of the soldered lead to be incorrect, which may affect the performance of the magnet, and further may have an adverse effect on the performance of the electronic device. In the prior art, an image to be detected, such as a magnet, is input into a classification model, so that the classification model directly outputs a determination result of whether the lead is offset, that is, whether the lead is located in the desired position. This solution has low detection accuracy, a long training cycle for the model, and poor versatility.
[0029] In order to at least partially solve the above technical problem, according to one aspect of an embodiment of the present application, a lead position offset detection method is provided. Figure 1 FIG. 1 is a schematic flow chart of a lead position deviation detection method 100 according to an embodiment of the present application. Figure 1 As shown, the lead position deviation detection method 100 may include the following steps S120 , S140 , S160 and S180 .
[0030] Step S120: determining a preset distribution area of the lead wires in the image to be detected.
[0031] According to embodiments of the present application, the image to be detected can be an image of any object to be detected that includes leads. The object to be detected includes, but is not limited to, various magnets with leads, such as magnetic disks containing coils, inductors, and the like. The object to be detected can include one lead or multiple leads. That is, the number of leads in the image to be detected can be one or multiple. For example, if the image to be detected includes two leads, one can be an input lead and the other can be an output lead.
[0032] The image to be detected can be any suitable image. It can be a two-dimensional black and white image or a two-dimensional color image. The image to be detected can be an image of any suitable size and resolution. Of course, the image to be detected can also be an image that meets preset requirements. For example, the image to be detected can be a color RGB image that meets the resolution requirements. The image to be detected can be acquired using any existing or future image acquisition method. The image to be detected can be the original image directly acquired by the image acquisition device, or it can be an image after the original image has been preprocessed. The preprocessing operation can include all operations to improve the visual effect of the image, increase the clarity of the image, or highlight certain features in the image to facilitate the detection of lead position offset. For example, the preprocessing operation can include denoising operations such as filtering, and can also include adjustments to image parameters such as image grayscale, contrast, brightness, etc.
[0033] The preset distribution area can be a fixed area where each lead should be located, and it can be located at any suitable position in the image. For example, the image to be detected can be the image to be detected of the coil disk, and the preset distribution area can be a preset fixed pad area for each lead. The pad area can be an unsoldered pad area. It can also be a soldered solder area of each lead. Since the coil disk has various shapes, the position of the pad area or solder area of each lead can also be set arbitrarily. According to an embodiment of the present application, each lead and the preset distribution area of the lead can be one-to-one corresponding. That is, each lead can uniquely correspond to a preset distribution area, and each preset distribution area can also uniquely correspond to one lead. Of course, in actual applications, each preset distribution area can also correspond to multiple leads, and the lead position offset detection method of the present application is used separately for detection of each lead.
[0034] Figure 2 A schematic diagram showing an image to be detected according to an embodiment of the present application is shown. Figure 2 The image to be inspected shown in FIG is a coil disk image. The number of leads in the coil disk image to be inspected may be four, including a first lead located in the upper left corner, a second lead located in the lower left corner, a third lead located in the upper right corner, and a fourth lead located in the lower right corner. The predetermined distribution areas of the four leads may be four solder pad areas (the silver solder areas in the figure) located at the four corners of the coil disk. As shown in the figure, each lead corresponds to each solder pad area.
[0035] Any suitable computer vision method can be used to determine the preset distribution area of each lead in the image to be detected, including but not limited to using various existing or future developed models such as target detection models and segmentation models to achieve this step. Figure 2 The image to be detected shown in is input into the trained region segmentation model, and a region segmentation image of the same size as the image to be detected can be output. In the region segmentation image, the pixels in the area corresponding to the pad area of each lead can have a first pixel value, such as 255. Thus, the exact position of the preset distribution area of each lead in the image to be detected can be determined. Of course, the preset distribution area of each lead in the image to be detected can also be determined by other suitable methods. For example, the position box of the preset distribution area of each lead in the image to be detected can be output by the target detection model.
[0036] Step S140 , determining the position and direction of the lead wires in each preset distribution area.
[0037] After determining the preset distribution area for each lead in step S120, further lead detection can be performed for each preset distribution area in the image to be inspected to determine the position and direction of the lead. Alternatively, step S140 can be performed simultaneously with step S120 or before step S120. The position and direction of each lead can be determined directly by inspecting the image to be inspected.
[0038] Any suitable computer vision method can be used to determine the position and direction of each lead in the image to be detected. By way of example and not limitation, the image to be detected can be input into a trained rotating target detection model or segmentation model to output the minimum bounding rectangle or position area of each lead. The position and direction of the corresponding lead can be determined directly based on each minimum bounding rectangle or position area. The position of the lead determined in this step can be various suitable information indicating the position of each lead in the image to be detected. For example, it can be the position coordinates of the minimum bounding rectangle, or it can be the position coordinates of the edge pixels or all pixels of the output position area, etc.
[0039] The direction of the lead can be represented by the angle of the lead relative to the preset reference line in the image to be detected. The preset reference line can be set arbitrarily according to needs. For example, it can be a reference line parallel to the width of the image to be detected. The direction of the lead can be the direction of any angle between the lead and the preset reference line. In the image to be detected, since the lead can be regarded as a line segment in the image to be detected. Optionally, each lead can be fitted as a line segment with two endpoints, and the direction of the lead can be determined by the relative angle between the line segment and the preset reference line. From another point of view, in the image to be detected, each lead can also be represented by the minimum circumscribed rectangular frame of the lead. Therefore, alternatively, the direction of each lead is determined by the angle between the longer side of the rectangular frame and the preset reference line.
[0040] Step S160 , determining a specific circumscribed rectangle of each preset distribution area, wherein two sides of the specific circumscribed rectangle are parallel to the direction of the corresponding lead line.
[0041] After determining the preset distribution area and the position and direction of each lead in the image to be inspected in steps S120 and S140, respectively, the preset distribution area can be further processed in step S160 to facilitate determining whether the lead has shifted. As previously mentioned, determining whether the lead is shifted is essentially determining whether the lead is within the allowable range of its correct or expected position. Therefore, determining whether a lead is shifted is unrelated to other leads and their preset distribution areas.
[0042] According to an embodiment of the present application, the specific circumscribed rectangle of the preset distribution area can be further determined based on the preset distribution area of each lead. Since the preset distribution area can be an area of any shape, the circumscribed rectangle of the preset distribution area can be any number. For example, the preset distribution area can be a regular circle, which can have an infinite number of circumscribed rectangles of equal size, and the directions of the corresponding sides of any two circumscribed rectangles are different, or the angles are different. The preset distribution area can also have any irregular shape. For the outline of an irregular shape, it can also have an infinite number of circumscribed rectangles, which can have regular circumscribed rectangles or oblique circumscribed rectangles, and the directions of the corresponding sides of any two circumscribed rectangles are also different. The specific circumscribed rectangle of the preset distribution area determined in step S160 can be a circumscribed rectangle in the circumscribed rectangle of the preset distribution area, whose side direction is a specific direction. The specific direction is the direction in which the two sides of the circumscribed rectangle are parallel to the direction of the corresponding lead. That is, in this step, the circumscribed rectangle of the preset distribution area of each lead, whose any side is parallel to the lead direction, can be determined.
[0043] Any existing or future developed method for determining the bounding rectangle can be used to determine the specific bounding rectangle of the preset distribution area of each lead. By way of example and not limitation, the specific bounding rectangle of the preset distribution area of each lead can be determined by loading a mathematical operation. First, a function that can represent the direction of the lead can be fitted, such as a straight line function that fits the lead. The straight line can then be translated in a direction perpendicular to the straight line, and then two straight lines tangent to the outer edge of the preset distribution area can be determined as the two opposite sides of the specific bounding rectangle. By rotating the straight line 90° and then translating it, two other straight lines tangent to the outer edge of the preset distribution area can be determined, and the other two opposite sides of the specific bounding rectangle can be determined. Of course, the specific bounding rectangle of the preset distribution area of each lead in the image to be detected can also be automatically obtained by loading other suitable algorithms.
[0044] It is easy to understand that the circumscribed rectangle of the preset distribution area can more accurately represent the position information of the preset distribution area. Therefore, the position of each lead in the circumscribed rectangle of its preset distribution area can also accurately represent the position of each lead in the preset distribution area. The method of representing the preset distribution area by the circumscribed rectangle itself has a small amount of data and can save calculation time to a large extent. Moreover, in the embodiment of the present application, the two sides of the specific circumscribed rectangle of the determined preset distribution area are also parallel to the direction of the lead, which makes it more convenient to determine the position of each lead in the specific circumscribed rectangle, reduces the amount of calculation, and can more accurately reflect the positional relationship between each lead and its preset distribution area.
[0045] Step S180 determines whether each lead line is offset based on its position within the corresponding specific bounding rectangle. After determining the position and orientation of each lead line in the image to be inspected and the specific bounding rectangle of each lead line's predetermined distribution area in steps S140 and S160, whether the lead line is offset can be further determined based on its position within the specific bounding rectangle of its predetermined distribution area. For simplicity, the specific bounding rectangle of each lead line's predetermined distribution area will be referred to as the specific bounding rectangle corresponding to each lead line.
[0046] Specifically, the position of each lead can be compared with the position of the corresponding specific circumscribed rectangle, and the relative positional relationship between the two can be determined based on the comparison result. Furthermore, whether the lead is offset can be further determined based on a preset lead offset determination criterion. The preset lead offset determination criterion can be arbitrarily set based on actual needs.
[0047] By way of example and not limitation, the position offset of a lead may be a side offset of the lead or a center point offset of the lead. In an example where the position offset of a lead includes a side offset, the distance by which the lead deviates from a preset center line of a specific circumscribed rectangle can be compared with the position of the lead and the position of the corresponding specific circumscribed rectangle to determine whether the lead is offset. In an example where the position offset of a lead includes a center point offset, the distance by which the center point of the lead deviates from the center point of the specific circumscribed rectangle can be compared with the position of the lead and the position of the corresponding specific circumscribed rectangle to determine whether the lead is offset. Of course, other appropriate criteria and methods may also be used to determine whether a lead is offset.
[0048] According to the above scheme, by determining the specific circumscribed rectangle of the preset distribution area of each lead that is parallel to the lead direction, and based on the position of each lead in the specific circumscribed rectangle of its preset distribution area, it is determined whether the lead is offset. In this scheme, the method of using a specific circumscribed rectangle to represent the position of the preset distribution area is adopted. The scheme is simpler, can save computing space to a large extent, and can significantly improve the efficiency of lead position offset detection. Moreover, since the two sides of the specific circumscribed rectangle are parallel to the lead, the scheme of using the relative position relationship between each lead and the corresponding specific circumscribed rectangle to determine whether the lead is offset is more accurate and the detection accuracy is also higher. The preset distribution area of the lead and the position and direction of the lead are determined separately, so there is no interference between these two steps. If a model is used to implement these two steps, the model is easier to train. In addition, the scheme can also adapt to the offset detection of leads of various forms. Therefore, the versatility of the scheme is also good.
[0049] Exemplarily, step S140 determines the position and direction of the lead in each preset distribution area, including step S141 and step S142.
[0050] In step S141, the minimum bounding rectangle of each lead in each preset distribution area is determined. The same principle as that of determining the specific bounding rectangle of the preset distribution area of the lead can also be used to represent the lead by the minimum bounding rectangle of each lead.
[0051] Any suitable method can be used to automatically determine the minimum bounding rectangle (MBR) of each lead. The MBR can be a minimum perimeter bounding rectangle (MPBR) or a minimum area bounding rectangle (MABR). Specifically, a trained, end-to-end neural network model can be used to directly determine the MBR of each lead within each pre-defined distribution area.
[0052] In step S142 , the position and direction of the lead are determined based on the minimum circumscribed rectangle.
[0053] It's easy to understand that, in the image to be detected, the lead line can be viewed as a long, narrow pixel region formed by multiple pixels. Therefore, the minimum bounding rectangle of the lead line determined in step S141 is the minimum bounding rectangle of the long, narrow pixel region, which also appears to be long and narrow. The geometric properties of this long, narrow minimum bounding rectangle can accurately reflect the position and direction of the lead line.
[0054] According to an embodiment of the present application, the position and direction of the lead can be determined based on any suitable geometric characteristics of the minimum circumscribed rectangle of each lead. For example, but not limitation, the direction of the lead can be determined based on the longer side of the minimum circumscribed rectangle. Figure 2 ,exist Figure 2 In the image to be detected shown in , the longer side of the minimum circumscribed rectangle 210 (shown in the black dotted box in the figure) of the second lead located in the lower left corner is consistent with the direction of the lead. Therefore, the direction of the lead can be determined based on any longer side of the minimum circumscribed rectangle. The position of the lead can be determined based on the position of the minimum circumscribed rectangle of the lead. Optionally, the position of the minimum circumscribed rectangle can be directly determined as the position of the lead, such as the enclosed area of the four sides of the minimum circumscribed rectangle as the position area of the lead. Alternatively, the minimum circumscribed rectangle can be used to fit the straight line or line segment where the lead is located, and the position of the fitted straight line or line segment is determined as the position of the lead. Of course, other geometric characteristics of the minimum circumscribed rectangle can also be used to determine the position of the lead, for example, the position coordinates of a point or several points in the minimum circumscribed rectangle can be determined as the position coordinates of the lead.
[0055] According to the above scheme, the position and orientation of the lead can be determined using its minimum enclosing rectangle. This scheme is computationally simple and easy to implement, with a low computational load, resulting in high detection efficiency. Furthermore, using the minimum enclosing rectangle can more accurately represent the lead shape, thereby improving the accuracy of lead position deviation detection.
[0056] In one example, step S120 of determining the predetermined distribution area of lead lines in the image to be inspected includes step S121 of inputting the image to be inspected into a trained first model to output the predetermined distribution area of each lead line. And / or step S141 of determining the minimum bounding rectangle of the lead lines includes step S141.1 of inputting the image to be inspected into a trained second model to output the minimum bounding rectangle of each lead line.
[0057] According to an embodiment of the present application, the preset distribution area of each lead and / or the minimum bounding rectangle of the lead can be determined by an end-to-end detection model. The first model can be any suitable trained neural network model, as long as it can accurately output the preset distribution area of the lead, and this application is not limited thereto. Similarly, the second model can also be any suitable trained neural network model, as long as it can accurately output the minimum bounding rectangle of the lead, and this application is not limited thereto.
[0058] In one example, the first model can be used to first output the preset distribution area of each lead, and then the position and direction of each lead can be determined by other means. Based on the direction of each lead, the specific bounding rectangle of the preset distribution area is obtained through post-processing. Then, based on the position of each lead in the corresponding specific bounding rectangle, it is determined whether the lead is offset. In another example, the second model can also be used to output the minimum bounding rectangle of each lead, and the position and direction of the lead can be determined based on the minimum bounding rectangle. Any suitable image processing method can be used to obtain the preset distribution area of the lead, and further obtain the specific bounding rectangle of the preset distribution area of the lead. In another example, the preset distribution area of each lead and the minimum bounding rectangle of the lead can be output by outputting the image to be detected to the first model and the second model respectively, and the specific bounding rectangle of the preset distribution area of the lead can be further determined.
[0059] In the above scheme, the detection model directly outputs the preset distribution area of the leads and / or the minimum bounding rectangle of the leads in the image to be detected, and then uses a simple post-processing method to determine the lead offset. In this scheme, the model structure is simpler, the training process is also relatively simple, the computational effort is small, and the detection speed is also faster. Moreover, compared with obtaining detection results using a classification model, the above scheme of the present application has higher detection efficiency and accuracy. It can also be widely applied to accurately determine the position offset of various lead shapes, thus the scheme is also more versatile.
[0060] By way of example and not limitation, the first model includes a segmentation model, and the second model includes a rotation object detection model.
[0061] The first model can be any suitable segmentation model, including but not limited to a semantic segmentation model and an instance segmentation model. A suitable segmentation model can be selected based on the features of the image to be detected, the detection speed requirements, and the detection accuracy requirements. In one example, the first model can include an instance segmentation model. That is, the image to be detected can be input into the input layer of a trained instance segmentation model, and a mask map of the preset distribution area of the leads in the image to be detected can be obtained at the output layer of the model, and the pixel values of the preset distribution areas of different leads are different. For some images to be detected, the preset distribution areas of the leads output by the instance segmentation model are more accurate. For example, the image to be detected is an image to be detected of a disk coil, and the disk includes a plurality of pad areas of leads spaced apart. In this case, the instance segmentation model can output the position information of the plurality of pad areas while effectively distinguishing different pads. This solution has higher detection efficiency and detection accuracy.
[0062] The second model can be various open source rotating target detection models, including but not limited to the YOLOv5 rotating target detection model, the rotating target detection model based on adaptive point (Oriented RepPoints) learning, etc. For example, the image to be detected can be input into the rotating target detection model of YOLOv5, etc., and the position coordinates of the minimum bounding rectangle of each lead and the probability of belonging to the lead can be obtained at its output layer. Among the various schemes for obtaining the minimum bounding rectangle of the lead, the scheme of directly obtaining the minimum bounding rectangle of the lead using an end-to-end rotating target detection model is more convenient, accurate, simpler and more effective, and occupies less video memory, thereby significantly improving the efficiency and accuracy of lead position offset detection.
[0063] Figure 3 A schematic diagram showing the minimum circumscribed rectangle of the lead in the image to be detected and the preset distribution area of the lead according to one embodiment of the present application is shown. Figure 2 The disk coil image to be detected shown in FIG is input into the instance segmentation model and the rotation target detection model respectively. Based on the output results of the two models, the following can be obtained: Figure 3 The minimum bounding rectangle of each lead (shown in the black short dashed box in the figure) and the preset distribution area of the lead (the pad area in the figure) are shown in FIG. A specific bounding rectangle of the preset distribution area of each lead can be determined (shown in the black long dashed box in the figure), and any side of the specific bounding rectangle can be parallel to the long side of the minimum bounding rectangle of the lead.
[0064] According to the above solution, the instance segmentation model and the rotation object detection model can be used to directly obtain the preset distribution area and minimum bounding rectangle of the lead in the image to be detected. This solution is simpler, has higher detection efficiency and accuracy, and is more versatile.
[0065] Exemplarily, step S180 determines whether each lead is offset according to the position of the lead in the corresponding specific circumscribed rectangle, and includes step S181 and step S182.
[0066] In step S181, a lead is fitted based on the minimum circumscribed rectangle of each lead. The fitted lead is parallel to the longer side of the minimum circumscribed rectangle. A variety of suitable methods can be used to fit the lead.
[0067] It is easy to understand that the direction of the longer side of the minimum circumscribed rectangle of the lead is usually consistent with the direction of the lead. The lead can be fitted based on the longer side of the minimum circumscribed rectangle of the lead so that the direction of the fitted lead is parallel to the longer side.
[0068] In one example, if the lead wire in the object to be inspected is thin, the shorter side of the minimum bounding rectangle is small (e.g., less than 1 / 20 of the longer side). In this case, any longer side of the minimum bounding rectangle can be directly fitted to the lead wire. For example, the position coordinates of the fitted lead wire can be represented by the position coordinates of the pixels corresponding to the two endpoints of any longer side.
[0069] In another example, the lead lines in the object to be detected are relatively thick. In this case, the shorter side of the obtained minimum circumscribed rectangle corresponds to a slightly larger number of pixels in the image to be detected. In this case, for accuracy, the lead lines can also be fitted based on the center of the shorter side of the minimum circumscribed rectangle, so that the fitted lead lines are not only parallel to the longer side but also located at the center of the shorter side. For example, the lead lines can be fitted using the center line segment of the shorter side of the minimum circumscribed rectangle of each lead line, and the two endpoints of the center line segment are respectively on the two shorter sides of the minimum circumscribed rectangle.
[0070] In other examples, other geometric properties of the minimum bounding rectangle of each lead can be used to fit the lead. For example, the lead can be directly fitted using the area within the minimum bounding rectangle or the center point of the minimum bounding rectangle. The fitted lead can be a region, a line, a line segment, or one or more points. Furthermore, different lead fitting methods can be used for different images to be inspected, thereby more accurately detecting lead position offsets.
[0071] In step S182, it is determined whether the lead is offset based on at least the relative positional relationship between the fitted lead and the specific circumscribed rectangle. As mentioned above, the judgment criteria for the lead position offset can be set according to the actual detection requirements. The relative positional relationship between the fitted lead and the specific circumscribed rectangle can be any positional relationship. By way of example and not limitation, the positional relationship can include the relative positional relationship between the fitted lead and the preset center area of the specific circumscribed rectangle. The judgment criteria can include that if the fitted lead exceeds the preset center area of the specific circumscribed rectangle, it can be determined that the lead position is offset. For example, in the aforementioned example where the fitted lead is the center line segment of the shorter side of the minimum circumscribed rectangle, a variety of suitable methods can be used to determine whether the center line segment is in the preset center area of the corresponding specific circumscribed rectangle, and then it can be determined whether the lead is offset.
[0072] Specifically, the relative positional relationship between the fitting lead and the corresponding specific circumscribed rectangle may include the relative positional relationship between the fitting lead and the specific circumscribed rectangle in the direction of the lead. For example, if the fitting lead is a line segment, the relative positional relationship between the two endpoints of the line segment and the specific circumscribed rectangle in the direction of the lead can be first determined, and then whether the lead is offset according to the relative positional relationship in this direction. Alternatively, the relative positional relationship between the fitting lead and the corresponding specific circumscribed rectangle may include the relative positional relationship between the fitting lead and the specific circumscribed rectangle in a direction perpendicular to the lead. By way of example and not limitation, if the fitting lead is a line segment, whether the lead is offset can be determined based on the relative distance between the line segment and the two parallel sides of the corresponding specific circumscribed rectangle.
[0073] According to the above scheme, each lead is fitted using its minimum bounding rectangle (MBR), and the relative positional relationship between the fitted lead and the corresponding specific BR is used to determine whether the lead is offset. This scheme is relatively easy to implement, requires less computation, and is also highly versatile. Furthermore, since the minimum bounding rectangle output by methods such as the rotating target detection model may not closely align with the lead under non-ideal conditions, fitting the lead is more accurate in characterizing the lead, thereby improving detection accuracy.
[0074] For example, step S180 determines whether each lead is offset based on its position within a corresponding specific bounding rectangle, and includes steps S183 and S184. Prior to step S183, the leads can be fitted using any suitable method. For example, the method of step S181 can be used to fit the leads based on their minimum bounding rectangles, or other suitable methods such as etching can be used to fit the leads.
[0075] After obtaining the fitted lead line, in step S183, a first distance between the lead line and a parallel side of a specific circumscribed rectangle parallel to the lead line's direction can be determined. The parallel side of the specific circumscribed rectangle can be either of two parallel sides. This parallel side is parallel to the lead line's direction. After determining the fitted lead line for each lead line through the aforementioned steps, the first distance between each fitted lead line and the parallel side of the corresponding specific circumscribed rectangle can be further calculated.
[0076] The following description uses the example of a fitted lead line as the centerline segment of the shorter side of the minimum circumscribed rectangle of the lead line. For example, in step S181, the two endpoints A1 and A2 of the centerline segment can be obtained. Based on the coordinates of any endpoint, such as A1, and the position of any parallel side of a specific circumscribed rectangle, the first distance between point A1 and that parallel side can be calculated. Alternatively, two first distances between A1 and two parallel sides of the specific circumscribed rectangle can be calculated. Of course, any other suitable method can also be used to determine the first distance.
[0077] In step S184, whether the lead is offset is determined based on the first distance. According to an embodiment of the present application, the first distance can be the distance between the fitted lead and any parallel side of a specific circumscribed rectangle, or the distance between the fitted lead and a predetermined parallel side of the specific circumscribed rectangle, or the first distance between the fitted lead and two parallel sides of the specific circumscribed rectangle. The following example uses the example where the first distance can be the distance between the fitted lead and any parallel side of the specific circumscribed rectangle. Any suitable method can be used to determine whether the lead is offset based on the first distance.
[0078] Alternatively, the determination of lead offset can be made directly based on the first distance and the first distance threshold. The first distance threshold can be any value set as needed. For example, the first distance threshold can be a relatively small value such as 5px. If the first distance is greater than the first distance threshold, it can be determined that the lead is offset; otherwise, it can be determined that the lead is not offset.
[0079] Alternatively, whether the lead is offset can be determined based on the first distance and the length of a vertical side of a specific circumscribed rectangle, where the vertical side is perpendicular to the parallel sides. By way of example and not limitation, the ratio of the first distance to the length of the vertical side of the specific circumscribed rectangle can be first calculated. This ratio can then be compared with a preset first ratio threshold range. If the ratio exceeds the first ratio threshold range, whether the lead is offset can be determined.
[0080] Figure 4A schematic diagram showing a post-processing image of a to-be-detected image according to one embodiment of the present application. As shown in the diagram, the first distance of the fitting lead of each of the four leads from any one of the parallel sides of the corresponding specific circumscribed rectangle can be calculated, and then the ratio of the first distance of each lead to the length of the vertical side of the corresponding specific circumscribed rectangle can be calculated. Then, it can be determined whether the ratio is within a first ratio threshold interval. The preset first ratio threshold interval is, for example, [0.2, 0.8], and the lead position within the range can be considered as a central region of the specific circumscribed rectangle (as shown by the gray filled region in the diagram). Figure 4 In the case where the ratio of the calculated first distance to the length of the vertical side of the specific circumscribed rectangle is less than 0.2 or greater than 0.8, it is determined that the lead is offset. It is easy to understand that in this scheme, within the central region of the specific circumscribed rectangle, the lead moves up and down by more than 40% along the center line of the vertical side of the specific circumscribed rectangle to be determined as offset. The preset first ratio threshold interval can be set according to actual needs, for example, the lead position within the interval can not affect the magnetism of the to-be-detected magnet. The detection of the lead offset beyond the range can improve the yield of the product.
[0081] In another example, the offset distance of the lead from the center of the specific circumscribed rectangle can be determined by the first distance and the length of the vertical side of the specific circumscribed rectangle. Then, the offset distance can be compared with a preset offset distance threshold, which can be equal to the first distance threshold in the foregoing example or not. The lead can be determined to be offset in the case where the offset distance exceeds the preset offset distance threshold. For example, the vertical side of the specific circumscribed rectangle is 5, the first distance is, for example, 2, and the preset offset distance threshold can be 1. The absolute value of the difference between the first distance and half of the length of the vertical side can be calculated first. Then, the offset distance of the lead from the center of the specific circumscribed rectangle is 0.5. Since 0.5 < 1, it is determined that the lead is not offset. In the case where the size of the to-be-detected object is relatively uniform, this scheme can be used to determine whether the lead is offset.
[0082] According to the above scheme, whether the lead is offset can be determined according to the first distance of the lead from the parallel side of the specific circumscribed rectangle. This scheme can effectively detect the offset of the lead in the vertical direction thereof, and the detection scheme is relatively simple and the calculation amount is relatively small. At the same time, the detection accuracy of this scheme is relatively high, and the universality of the scheme is also relatively good.
[0083] According to an embodiment of the present application, whether a lead is offset can also be determined based on the position of the lead's endpoint within a preset distribution area. Whether a lead is offset can be determined based on the position of one of the lead's endpoints within a corresponding specific circumscribed rectangle, or based on the positions of both of the lead's endpoints within a corresponding specific circumscribed rectangle. Step S180 determines whether a lead is offset based on the position of each lead within the corresponding specific circumscribed rectangle, and also includes steps S185 and S186.
[0084] In step S185 , a second distance between the lead head and / or the lead tail of the lead and a vertical side of a specific circumscribed rectangle is determined, wherein the vertical side is perpendicular to the direction of the lead.
[0085] It is easy to understand that the vertical side of a specific circumscribed rectangle is the side of the specific circumscribed rectangle that is perpendicular to the parallel side. The number of its parallel sides and vertical sides is two. Optionally, the second distance between the endpoint of the lead and the vertical side can be the distance between the endpoint and any one of the two vertical sides. Alternatively, the second distance between the endpoint of the lead and the vertical side can also be the distance between the endpoint and a specific vertical side of the two vertical sides. Among them, the specific vertical side can be defined as needed. Exemplarily and non-limitingly, the specific vertical side can be the vertical side on the same side as the endpoint. That is, the second distance can be the distance between each endpoint and the vertical side on the same side as the endpoint. For example, if the two endpoints of the lead are respectively located on the left and right sides of the lead direction, the second distance can be the distance between the left endpoint and the left vertical side of the specific circumscribed rectangle and / or the distance between the right endpoint and the right vertical side of the specific circumscribed rectangle.
[0086] The left and right endpoints of the lead can correspond to the lead tip and lead tail of the lead. It should be understood that the correspondence between the two endpoints of the lead and the lead tip and lead tail of the lead is not fixed and needs to be determined based on actual conditions. This will be explained below and will not be repeated here. Therefore, the second distance can include the distance between the lead tip and the vertical side of the specific circumscribed rectangle corresponding to the lead tip; and / or the second distance also includes the distance between the lead tail and the vertical side of the specific circumscribed rectangle corresponding to the lead tail. By way of example and not limitation, the vertical side corresponding to the lead tip can be the vertical side on the same side as the lead tip. The second distance can be calculated using any suitable method. For example, the method in step S181 can be used to fit the lead, and the lead tip and / or lead tail of the lead can be determined based on the fitted lead. For example, if the fitted lead is a line segment, the lead tip and lead tail of the lead can be the two endpoints of the line segment. For another example, if the fitted lead is a minimum circumscribed rectangle, the lead head and lead tail of the lead may be two shorter sides of the minimum circumscribed rectangle.
[0087] In step S186, it is determined whether the lead line is offset according to the second distance. Any suitable method can be used to determine whether the lead line is offset.
[0088] Alternatively, the lead offset can be determined directly based on the second distance and the second distance threshold. The second distance threshold can be arbitrarily set based on actual needs. This approach is similar to the method for determining lead offset based on the first distance and the first distance threshold in step S184. A person skilled in the art will understand various implementations of this approach by reading the approach in step S184, and will not be further described here.
[0089] Alternatively, in step S186, whether the lead is offset can also be determined based on the second distance and the length of the parallel sides of the specific circumscribed rectangle. By way of example and not limitation, the ratio of the second distance to the length of the parallel sides of the specific circumscribed rectangle can be first determined. This ratio can then be compared with a preset second ratio threshold. The preset second ratio threshold can be arbitrarily set according to actual detection requirements. Each second distance can correspond to a preset second ratio threshold. In the case where there are multiple second distances, the number of second ratio thresholds can be one or more.
[0090] In one example, the number of the second preset ratio threshold value can be one, such as 1 / 2. As mentioned above, the second distance between the endpoint of the lead and the vertical side can be the distance between each endpoint and a specific vertical side. For example, the second distance includes the distance between the two endpoints of the lead and the vertical side of a specific circumscribed rectangle on the same side of the endpoint. The ratio of each second distance to the length of the parallel side of the specific circumscribed rectangle can be calculated. The two ratios obtained are compared with 1 / 2, and it is determined whether the lead is offset based on the comparison result. For example, if any one of the two ratios is greater than 1 / 2, it can be determined that the lead has a position offset. Refer again Figure 4 In the figure, the centerline of the parallel sides of the specific circumscribed rectangle of the lead is the 1 / 2 dividing line of the parallel sides. Whether the position of the lead tip exceeds the 1 / 2 dividing line can be determined based on the second distance, and the lead can be determined to be offset if the lead tip is located to the left of the 1 / 2 dividing line. Of course, other suitable methods can also be used to determine whether the lead is offset based on the second distance and the length of the parallel sides of the specific circumscribed rectangle.
[0091] According to the above solution, the position of the lead's endpoint within a specific circumscribed rectangle of the lead's pre-set distribution area can be used to determine whether the lead is offset. This solution can effectively detect the proportional impact of improper lead end position on the performance of the test object, effectively improving the accuracy of the test.
[0092] For example, the number of leads in the image to be detected is at least 2, and the at least 2 leads are spaced and arranged around the preset object. The preset object can be any suitable object, such as an object connected with leads, such as a coil, etc. Figure 2As shown in the image to be detected, the disk coil is connected with four leads, and each lead is spacedly distributed around the four corners of the coil. The method 100 further comprises step S170. In step S170, the lead head and the lead tail of each lead can be determined based on the relative positional relationship between the lead and the preset object. Again referring to Figure 2 The lead head and the lead tail of each lead can be determined based on the relative positional relationship between the lead and the coil. In the aforementioned example in which the fitting lead is the center line segment of the shorter side of the minimum circumscribed rectangle of the lead, the distance between the two end points of the center line segment of each lead and the coil can be calculated, for example, the center of the coil region can be detected first. Then, the distance between the two end points of the center line segment of each lead and the center of the coil can be calculated, and the end point with a larger distance from the center of the coil is determined as the lead tail, and the other end point is determined as the lead head. Other suitable methods can also be used to determine the distance between the two ends of the lead and the preset object, and thus the lead head and the lead tail of each lead can be determined. And in step S183, whether the lead is offset can be determined based on the second distance between the lead head and / or the lead tail of the determined lead and the vertical side of the specific circumscribed rectangle and the length of the parallel side of the specific circumscribed rectangle. This scheme is simple and has a smaller amount of calculation.
[0093] Exemplarily, the number of leads is multiple, and at least two leads are spacedly arranged around the preset object. The method 100 further comprises step S171, step S172 and step S173.
[0094] In step S171, the center point of each lead is determined. Exemplarily but not limitatively, the center point of the minimum circumscribed rectangle of the lead can be determined as the center point of the lead based on the determination of the minimum circumscribed rectangle of the lead.
[0095] In step S172, the center points of the multiple leads are connected to obtain a closed figure. As Figure 3 As shown, the center points of the four leads can be connected to obtain a closed figure 310 (shown by the gray filled area in the figure). Any suitable method can be used to determine the closed figure.
[0096] In step S173, the lead end of each lead located within the closed figure is determined as the lead head of the lead, and the lead end of each lead located outside the closed figure is determined as the lead tail of the lead. For example, the end point of the two end points of the center line segment of the shorter side of each minimum circumscribed rectangle which is not within the closed figure can be taken as the lead tail of the lead, and the other end point can be taken as the lead head. And in step S183, whether the lead is offset can be determined based on the second distance between the lead head and / or the lead tail of the determined lead and the vertical side of the specific circumscribed rectangle and the length of the parallel side of the specific circumscribed rectangle. This scheme is simple and has a smaller amount of calculation.
[0097] Exemplarily, the method 100 further includes step S174, step S175 and step S176.
[0098] In step S174, the center point of the image to be detected can be first determined. For example, the position coordinates of the pixel located at the center of the image to be detected can be determined based on the image to be detected. In step S175, the distances between the two endpoints of each lead and the center point are calculated. The two endpoints of each lead can be determined based on the minimum bounding rectangle of each lead. For example, the two endpoints of the center line segment of the shorter side of the minimum bounding rectangle can be determined as the two endpoints of the lead, and the distances between the two endpoints of the center line segment and the position coordinates of the center point can be calculated. For another example, the two shorter sides of the minimum bounding rectangle can be determined as the two endpoints of the lead, and the distances between each shorter side and the position coordinates of the center point can be calculated. In step S176, the lead end of each lead with the largest distance from the center point can be determined as the lead tail of the lead. This solution is easily understood by those skilled in the art and will not be described in detail here. This solution for determining the lead tail of a lead is relatively simple and requires less computation.
[0099] For example, whether the leads are offset can be determined by detecting the number of preset distribution areas of the leads and / or the number of leads. Furthermore, if the number of leads in the image to be detected is not equal to the preset number and / or the preset distribution areas of the leads in the image to be detected are not equal to the preset number, lead offset can be determined.
[0100] Figure 5A flowchart of a method for detecting lead offset according to another embodiment of the present application is shown. As shown in the figure, the image to be detected is an image of a coil disk. The image to be detected can be input into a pre-trained lead rotation target detection network and a pre-trained solder segmentation network, respectively, to output the minimum bounding rectangle (MBR) and solder area of the lead. The lead can then be fitted using the centerline segment of the shorter side of the MBR. Based on the orientation of the fitted lead, a specific BR of the solder area of the fitted lead can be obtained, such that one side of the BR is parallel to the fitted lead. Next, based on the relative positional relationship between the fitted lead and the specific BR of the solder area, the offset distance of the lead from the center of the solder area can be calculated. This offset distance can be compared with a preset distance threshold. If the offset distance is greater than the distance threshold, the lead can be determined to be offset; if the offset distance is greater than or equal to the distance threshold, the lead can be determined to be offset. Furthermore, the tail of each lead can be determined based on the center coordinates of the image to be detected and the distances between the two endpoints of the fitted lead and the center coordinates. A second distance between each lead tail and a corresponding vertical side of a specific circumscribed rectangle of the corresponding solder area is determined. A ratio of the second distance to the length of a parallel side of the specific circumscribed rectangle is calculated. Based on this ratio and a preset ratio threshold, a determination can be made as to whether the lead is offset. For example, if this ratio is greater than 1 / 2, the lead is determined to be offset.
[0101] According to a second aspect of the present application, a lead position deviation detection system 600 is also provided. Figure 6 A schematic block diagram of a lead position deviation detection system 600 according to an embodiment of the present application is shown. As shown in the figure, the system 600 includes: a first determination module 610, a second determination module 620, a third determination module 630 and a judgment module 640.
[0102] A first determining module 610 is configured to determine a preset distribution area of leads in an image to be detected;
[0103] A second determining module 620 is used to determine the position and direction of the lead in each preset distribution area;
[0104] A third determining module 640 is configured to determine a specific circumscribed rectangle of each preset distribution area, wherein two sides of the specific circumscribed rectangle are parallel to the direction of the corresponding lead line; and
[0105] The judgment module 650 is used to judge whether each lead line is offset according to the position of the lead line in the corresponding specific circumscribed rectangle.
[0106] According to a third aspect of the present application, an electronic device is also provided. Figure 7A schematic block diagram of an electronic device 700 according to an embodiment of the present application is shown. As shown in the figure, the electronic device 700 includes a processor 710 and a memory 720, wherein the memory 720 stores computer program instructions, which are used by the processor 710 to execute the lead position offset detection method 100 described above when the computer program instructions are executed.
[0107] According to a fourth aspect of the present application, a storage medium is further provided, on which program instructions are stored. When the program instructions are executed, the program instructions are used to execute the lead position offset detection method 100 described above. The storage medium may include, for example, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a compact disc read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. The computer-readable storage medium may be any combination of one or more computer-readable storage media.
[0108] A person skilled in the art can understand the specific implementation scheme of the lead position deviation detection system, electronic device and storage medium by reading the above description of the lead position deviation detection method, which will not be described here for the sake of brevity.
[0109] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely illustrative and are not intended to limit the scope of the present application. Various changes and modifications may be made therein by those skilled in the art without departing from the scope and spirit of the present application. All such changes and modifications are intended to be included within the scope of the present application as required by the appended claims.
[0110] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0111] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is merely a logical function division. In actual implementation, other division methods may be used. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not performed.
[0112] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.
[0113] Similarly, it should be understood that in order to streamline the present application and aid in understanding one or more of the various inventive aspects, in the description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, this approach of the present application should not be interpreted as reflecting the intention that the application claimed for protection requires more features than those explicitly recited in each claim. More precisely, as reflected in the corresponding claims, the inventive point is that the corresponding technical problem can be solved with fewer features than all the features of a single disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim itself serving as a separate embodiment of the present application.
[0114] It will be understood by those skilled in the art that, except where mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or apparatus disclosed herein may be combined in any combination. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature providing the same, equivalent, or similar purpose.
[0115] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, combinations of features from different embodiments are intended to be within the scope of this application and to form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
[0116] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some modules in the lead position offset detection system according to the embodiment of the present application. The present application can also be implemented as a device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0117] It should be noted that the above embodiments illustrate rather than limit the present application, and that a person skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbols placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0118] The above description is merely a specific embodiment or illustration of a specific embodiment of the present application, and the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. The scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A method for detecting lead position deviation, characterized in that: include: Determining a preset distribution area of leads in an image to be detected; Determine the position and direction of the lead in each preset distribution area; Determining a specific circumscribed rectangle of each preset distribution area, wherein two sides of the specific circumscribed rectangle are parallel to the direction of the corresponding lead line; and Determine whether each lead is offset according to the position of the lead in the corresponding specific circumscribed rectangle; Wherein, determining the position and direction of the lead in each preset distribution area includes: determining a minimum circumscribed rectangle of the lead; and Determining the position and direction of the lead based on the minimum circumscribed rectangle; The step of determining whether each lead is offset according to a position of the lead in a corresponding specific circumscribed rectangle includes: Fitting the lead line according to the minimum circumscribed rectangle, wherein the lead line is parallel to the longer side of the minimum circumscribed rectangle; Whether the lead line is offset is determined based at least on a relative positional relationship between the lead line and the specific circumscribed rectangle.
2. The lead position deviation detection method according to claim 1, wherein: The step of determining whether each lead is offset according to a position of the lead in a corresponding specific circumscribed rectangle includes: determining a first distance between the lead line and a parallel side of the specific circumscribed rectangle that is parallel to the lead line direction; and Whether the lead is offset is determined according to the first distance.
3. The lead position deviation detection method according to claim 1, wherein: The step of determining whether each lead is offset according to a position of the lead in a corresponding specific circumscribed rectangle includes: determining a second distance between a lead tip and / or a lead tail of the lead and a vertical side of the specific circumscribed rectangle; and Whether the lead is offset is determined according to the second distance, wherein the vertical side is perpendicular to the direction of the lead.
4. The lead position deviation detection method according to claim 3, wherein: The number of the lead lines in the image to be detected is at least 2, and the at least 2 lead lines are spaced and distributed around a preset object. The method further includes: Based on the relative position relationship between the lead and the preset object, a lead head and a lead tail of the lead are determined; The lead end that is at a greater distance from the preset object is the lead tail, and the lead end that is at a smaller distance from the preset object is the lead head.
5. The lead position deviation detection method according to claim 3, wherein: There are multiple leads, and at least two leads are spaced and distributed around a preset object. The method further includes: Determine the center point of each lead; Connecting the center points of multiple leads to form a closed figure; and The lead end of each lead located within the closed figure is determined as the lead head of the lead, and the lead end of each lead located outside the closed figure is determined as the lead tail of the lead.
6. The lead position deviation detection method according to claim 3, wherein: The method further comprises: Determine the center point of the image to be detected; Calculating the distances between the two endpoints of each lead and the center point respectively; and The lead end of each lead that is farther away from the center point is determined as the lead tail of the lead.
7. The lead position deviation detection method according to claim 1, wherein: The step of determining a preset distribution area of leads in the image to be detected includes: Inputting the image to be detected into a trained first model to output a preset distribution area of each lead; and / or Determining the minimum circumscribed rectangle of the lead includes: The image to be detected is input into the trained second model to output the minimum circumscribed rectangle of each lead.
8. The lead position deviation detection method according to claim 7, wherein: The first model includes a segmentation model, and the second model includes a rotation object detection model.
9. A lead position deviation detection system, characterized in that: include: A first determining module is used to determine a preset distribution area of the lead in the image to be detected; A second determining module is configured to determine the position and direction of the lead in each preset distribution area, wherein the position and direction of the lead are determined based on a minimum circumscribed rectangle of the lead; A third determining module is configured to determine a specific circumscribed rectangle of each preset distribution area, wherein two sides of the specific circumscribed rectangle are parallel to the direction of the corresponding lead line; and A judgment module is used to judge whether the lead is offset based on the position of each lead in the corresponding specific circumscribed rectangle, wherein the position of the lead in the corresponding specific circumscribed rectangle includes the relative position relationship between the lead fitted based on the minimum circumscribed rectangle and the specific circumscribed rectangle, and the lead is parallel to the longer side of the minimum circumscribed rectangle.
10. An electronic device comprising a processor and a memory, wherein: The memory stores computer program instructions, which are used by the processor to execute the lead position deviation detection method according to any one of claims 1 to 8 when the processor runs the computer program instructions.
11. A storage medium having program instructions stored thereon, wherein the program instructions are used to execute the lead position deviation detection method according to any one of claims 1 to 8 when running.
Citation Information
Patent Citations
Pseudo soldering detection method and device
CN109727229A