Device detection method and device, storage medium and electronic equipment
By identifying the target image area in the device image to indirectly infer the position identification position, the problem of low accuracy of component installation position recognition in the prior art is solved, and the normal use capability of the circuit board is improved.
Patent Information
- Application Number
- CN202311208289.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2025-03-21
AI Technical Summary
In the prior art, the accuracy of the installation position identification of components on the circuit board is low, resulting in the circuit board failure, such as short circuit, circuit breaker, overheating and other problems.
通过获取待检测器件的器件图像,识别出与位置标识具有关联关系的目标图像区域,并根据目标图像区域的位置推测出位置标识的位置,从而判断待检测器件在电路板上的安装位置是否准确。
It improves the accuracy of the installation position identification of components on the circuit board, reduces circuit board failures caused by installation errors, and enhances the normal use ability of the circuit board.
Smart Images

Figure CN119671924A_ABST
Abstract
Description
Technical Field
[0001] The technical solution disclosed herein relates to the field of intelligent manufacturing technology, and in particular to a device detection method, device, storage medium and electronic device. Background Art
[0002] When designing a circuit, many components will be soldered on the circuit board. Common components include chips, resistors, capacitors, amplifiers, etc. In the automated soldering process, multiple components are usually mounted on a certain position on the circuit board first, and then the circuit board with components is placed in a reflow furnace for soldering to obtain a circuit board that can realize the circuit function.
[0003] If there is a problem with the installation position of a component in the circuit board, such as the component is in the opposite direction, it will cause the circuit board to malfunction, such as short circuit, open circuit, overheating and other problems, affecting the normal use of the circuit board.
[0004] In the prior art, a mark is usually printed at a designated position of a component, which can assist a worker or a recognition model to identify the position and direction of the component and determine whether the component is installed correctly in the circuit board. In the prior art, whether it is manual recognition or model recognition, there is a problem of low recognition accuracy. Summary of the invention
[0005] In view of this, the present disclosure provides a device detection method, an apparatus, a storage medium and an electronic device to solve the problem of low accuracy in identifying the installation position of components.
[0006] According to a first aspect of an embodiment of the present disclosure, a device detection method is provided, the method comprising:
[0007] Acquire a device image of the device to be inspected;
[0008] Acquire a target image region from the device image, wherein the target image region is a region associated with a position mark in the device to be detected, wherein the position mark is located at a specified position of the device to be detected, and when the mounting position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image;
[0009] Determine the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker;
[0010] Based on the comparison result between the position of the position mark in the device image and the preset position, the position detection result of the device to be detected is determined, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
[0011] According to a second aspect of an embodiment of the present disclosure, a device detection apparatus is provided, the device comprising:
[0012] A first acquisition module, used to acquire a device image of a device to be detected;
[0013] A second acquisition module is used to acquire a target image area from the device image, wherein the target image area is an area associated with a position mark in the device to be detected, the position mark is located at a specified position of the device to be detected, and when the installation position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image;
[0014] A first determination module, configured to determine a position of the position marker in the device image based on the target image area and an association relationship between the target image area and the position marker;
[0015] The second determination module is used to determine the position detection result of the device to be detected based on the comparison result between the position of the position mark in the device image and the preset position, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
[0016] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0017] processor;
[0018] a memory for storing processor-executable instructions;
[0019] Wherein, the processor is configured to implement the steps of any device detection method described in the first aspect by running the executable instructions.
[0020] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the device detection method described in any one of the first aspects are implemented.
[0021] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0022] A device image of the device to be inspected is obtained, and a target image area is obtained from the device image. When the mounting position of the device to be inspected on the circuit board is accurate, the designated position is located at a preset position in the device image.
[0023] On the one hand, the target image area is an area associated with the position mark, and on the other hand, the position of the position mark on the device to be detected (specified position) is also fixed. Therefore, based on the association between the position mark and the device to be detected and the position of the target image area in the device image, the position of the position mark in the device image can be inferred, and then further by comparing the position of the position mark in the device image with the preset position, it can be determined whether the installation position of the device to be detected on the circuit board is accurate.
[0024] Through the above method, this solution does not need to directly identify the position marker, but instead identifies the area (target image area) that has an association with the position marker to indirectly deduce the position of the position marker, which helps to solve the problem of low position detection accuracy of the device to be detected in the prior art due to the difficulty in accurately capturing the position marker.
[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0027] Figure 1 is an application schematic diagram of a device detection method according to an exemplary embodiment of the present disclosure;
[0028] Figure 2 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0029] Figure 3 is a flow chart of a device detection method according to an exemplary embodiment of the present disclosure;
[0030] Figure 4 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0031] Figure 5 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0032] Figure 6a is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0033] Figure 6b is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0034] Figure 6c is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0035] Figure 7 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0036] Figure 8 is a flow chart of another device detection method according to an exemplary embodiment of the present disclosure;
[0037] Fig. 9 is a flow chart of another device detection method according to an exemplary embodiment of the present disclosure;
[0038] Fig.10 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0039] Fig.11 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure;
[0040] Fig.12 is a structural schematic diagram of a device detection apparatus according to an exemplary embodiment of the present disclosure;
[0041] Fig.13 It is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0043] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0044] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0045] Figure 1 FIG. 1 is a schematic diagram showing an application of a device detection method according to an exemplary embodiment of the present disclosure. Figure 1 As shown, multiple components need to be soldered in the circuit board 101, including component 102 (for example, a resistor) and component 103 (for example, a chip, and component 103 is exemplified as a device to be detected in the present disclosure). The pre-printed circuits in the circuit board 101 enable these components to be connected together in series, parallel, etc. to achieve specific circuit functions.
[0046] A mark 104 (called a position mark) is set on the component 103 (for example, on the surface), and this mark 104 is set adjacent to the first pin of the component 103 (the first pin of the component 103 is pin 105 in this case). In other words, the position mark is always set at the specified position of the device to be tested, and is used to indicate whether the installation position of the device to be tested in the circuit is accurate. Figure 1 An example explanation is given below:
[0047] In the circuit routing designed for the circuit board 101, it is required that the pin 105 of the component 103 must be installed at the installation position 106 (such as a pad, a solder joint) on the circuit board, and other pins are also installed at other positions of the circuit board accordingly (for example, pin 107 must be installed at position 108). In this case, the circuit of the circuit board can be used normally. If the pin 107 of the component is installed at position 106, the circuit board will have circuit problems such as short circuit, open circuit, abnormal signal, etc., making the circuit board unable to work normally.
[0048] Therefore, since the position marker 104 is located at the designated position of the device to be inspected (adjacent to the pin 105), it is possible to infer whether the installation position of the component 103 in the circuit board is correct based on the position of the designated position in the device image.
[0049] For example, suppose that when the device image of component 103 is Figure 1 When the directions of the components 103 and 104 are consistent (the mark 104 will be located in the upper left corner of the device image), it is considered that the installation position of the component 103 in the circuit board is correct.
[0050] on the contrary, Figure 2 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure, such as Figure 2 As shown, if the mark 104 is located at the lower right corner of the device image, since the position mark 104 is located at the specified position of the device to be detected (adjacent to the pin 105), Figure 2 The pin 105 located next to the position mark 104 in the device 103 is still the first pin, that is, the first pin 105 is installed at the installation position 108 of the circuit board, and the pin 107 is installed at the installation position 106. Therefore, the installation position of the component 103 in the circuit board is wrong. Figure 2 The circuit board shown may fail to realize the circuit function of the circuit board due to incorrect installation of the components 103 .
[0051] In the prior art, there may be situations where the mark 104 cannot be identified, or other contents on the surface of the component (such as potholes on the surface, or other marks) are mistakenly identified as the mark 104, which will lead to a low accuracy rate in identifying the installation position of the component due to the incorrect identification of the mark 104.
[0052] In order to solve the problem that the prior art easily identifies the wrong position mark and leads to the wrong judgment of the installation position of the components. In the present disclosure, the position mark on the device to be detected is not directly identified, but the target image area with specific characteristics is identified. Since the target image area is the area with the association relationship between the position mark, after identifying the target image area, the position of the position mark can be indirectly inferred, so that the indirectly inferred position can be used to determine whether the installation position of the device to be detected in the circuit board is correct.
[0053] The following is a detailed introduction:
[0054] Figure 3 is a flow chart of a device detection method according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the method comprises the following steps:
[0055] Step 301: Acquire a device image of a device to be inspected.
[0056] After mounting the device to be tested on the circuit board, it is necessary to check whether the installation position of the device to be tested on the circuit board is accurate. Only after the installation position is detected to be accurate can the subsequent welding process be entered, that is, the device to be tested is connected to the circuit board by welding. Alternatively, after welding, it is necessary to recheck whether the installation position of the device to be tested on the circuit board is correct.
[0057] Therefore, the device image is acquired after the device to be inspected is mounted on the circuit board and before the device to be inspected is soldered to the circuit board, or after the device to be inspected is soldered to the circuit board.
[0058] The device image may be obtained by photographing the device to be inspected on the circuit board at a preset angle.
[0059] by Figure 1 For example, suppose Figure 1 That is, the image of the circuit board 101 is taken after the device to be detected (component 103) is mounted on the circuit board 101 and before the device to be detected (component 103) is soldered to the circuit board 101. The device image can be obtained based on this image.
[0060] For example, the device image 401 of the device to be detected (device 103) can be directly obtained based on this image, such as Figure 4 As shown, the device image 401 includes the surface area of the device to be inspected, four pins connected to the surface area of the device to be inspected, and four pads in the circuit board respectively connected to the four pins.
[0061] Alternatively, when the position detection of the device to be detected is performed, if the pins of the device to be detected are not detected, the obtained device image can also be Figure 5 As shown, the device image 501 only includes the device surface area of the device to be inspected 103 (that is, excluding the area where the pins are located and the area where the pads in the circuit board are located).
[0062] Step 302: Acquire a target image area from the device image, wherein the target image area is an area associated with a position identifier in the device to be detected, wherein the position identifier is located at a specified position of the device to be detected, and when the installation position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image.
[0063] The target image region has specific features, and the difficulty of identifying the target image region based on the specific features is lower than the difficulty of identifying the position mark. In addition, the association relationship between the target image region and the position mark is obtained by analyzing the device to be detected in advance.
[0064] For example, when producing the device to be inspected, in order to ensure that the position mark can be seen by the user (or recognized by the model), no mark will be set in the area associated with the position mark. At this time, the target image area can be identified based on the feature that no mark is set in the target image area.
[0065] like Figure 6a As shown, Figure 6a 6 is an application diagram of another device detection method according to an exemplary embodiment of the present disclosure, wherein a position mark 104 is printed on the surface of a component 103 (that is, a device to be detected), and device information (such as model, production batch, production date, manufacturer, serial number, etc.) for indicating the component 103 (that is, the device to be detected) is printed in an area 602. Figure 6a The content displayed in area 602 is for reference only).
[0066] When identifying based on the feature that no mark is set in the target image area, since the elements in area 601 are the least, there will not be too many interference elements. Therefore, area 601 is easier to identify than other areas (area 602, or the area where the position mark 104 is located).
[0067] At this time, the area in the device image that meets the third preset condition can be determined as the target image area; the third preset condition includes: when the device image includes at least one area, the area whose total pixel value is less than or equal to a preset threshold; or, when there are at least two areas in the device image, the area with the smallest total pixel value; the total pixel value is positively correlated with the area marked in the area.
[0068] That is, the region with the smallest total pixel value in the device image (the region calculated under normal circumstances is region 601) can be used as the target image region. Alternatively, the region with the smallest area occupied by the logo in the device image (the region calculated under normal circumstances is region 601) can be used as the target image region. Based on the above method, region 601 can be identified and used as the target image region.
[0069] Among them, one or more regions in the device image can be divided according to a preset method, or can be automatically identified according to a preset model.
[0070] For example, you can follow Figure 6b The area 601 is divided in the manner shown (the same as the division method of the four quadrants), and the sum of the pixel values is calculated for each area (or the sum of the areas occupied by the logos, or the ratio of the logo area to the total area of the area), so that it can be determined that area 601 is the target image area.
[0071] For another example, Figure 7 is an application schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure, such as Figure 7 As shown, when designing component 701, no mark is set in the target image area associated with the position mark. Therefore, compared with mark 104, it is easier to identify area 701 (such as Figure 7The area 701 is determined as the target image area.
[0072] Step 303: Determine the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker.
[0073] After the target image region is determined according to step 302 , the location identifier may be determined according to the association relationship between the target image region and the location identifier.
[0074] When the component 103 is Figure 6a When placed in the orientation shown, after identifying that the target image area is area 601, it is assumed that the association relationship between the target image area (area 601) and the position marker is: the position marker is adjacent to the target image area and both are set on the short side of the device to be detected.
[0075] Then, according to the association relationship "the position marker is adjacent to the target image area and both are set on the short side of the device to be detected", Figure 6a The area directly below the area 601 (target image area) (that is, the area where the position marker 104 is located) is used as the area where the position marker is located, thereby determining the position of the position marker in the device image (for example Figure 6a lower left corner shown).
[0076] Or, Figure 6c is a schematic diagram of another device detection method according to an exemplary embodiment of the present disclosure. When the component 103 is Figure 6c When the position is placed as shown, after identifying that area 601 is the target image area, according to the association relationship "the position mark is adjacent to the target image area and both are set on the short side of the device to be detected", it can be Figure 6c The region 603 in the device image is identified as the region where the position marker is located, thereby determining the position of the position marker in the device image (eg Figure 6c upper right corner shown).
[0077] For another example, the association relationship between the target image area and the position mark 104 may be at least one of the following: being located on the same surface of the device to be inspected; being different in color, and the like.
[0078] For example, refer to Figure 7, when the component 103 is used as the device to be detected for position detection, it is assumed that the association relationship between the position marker and the target image area is: the position marker and the target image area are set to be on the same surface of the device to be detected (component 103), and the area where the position marker is located is different from the target image area. Then, after determining that area 701 is the target image area, the remaining area of the surface of the component 103 except area 701 can be used as the area where the position marker 104 is located according to the association relationship, thereby determining the position of the position marker 104 in the device image (such as Figure 7 lower left corner shown).
[0079] Step 304, based on the comparison result between the position of the position mark in the device image and the preset position, determine the position detection result of the device to be detected, wherein the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
[0080] When the device image is Figure 6a The direction shown is the position of the device to be detected (component 103) when it is correctly installed in the circuit board. Assume that the preset position is: the position (specified position) where the position mark 104 is located is located at the lower left corner of the device to be detected.
[0081] At this time, according to step 303, it is determined that the position of the position mark in the device image is Figure 6a If the position of the lower left corner is shown, then according to step 303, the position of the position mark in the device image is the same as the preset position. Therefore, an accurate position detection result of the mounting position of the device to be detected on the circuit board can be obtained.
[0082] In the case where the preset position remains unchanged, assuming that the device image obtained is as follows Figure 6c As shown, when the position mark 104 is located at the upper right corner of the device image according to step 303, the position of the position mark in the device image (the upper right corner of the device image) and the preset position (the lower left corner of the device image) obtained according to step 303 are different. Therefore, a position detection result indicating that the mounting position of the device to be detected on the circuit board is inaccurate can be obtained.
[0083] The device image of the device to be inspected is obtained by the above method, and the target image area is obtained from the device image. When the mounting position of the device to be inspected on the circuit board is accurate, the designated position is located at a preset position in the device image.
[0084] On the one hand, the target image area is an area associated with the position mark, and on the other hand, the position of the position mark on the device to be detected (specified position) is also fixed. Therefore, based on the association between the position mark and the device to be detected and the position of the target image area in the device image, the position of the position mark in the device image can be inferred, and then further by comparing the position of the position mark in the device image with the preset position, it can be determined whether the installation position of the device to be detected on the circuit board is accurate.
[0085] Through the above method, this solution does not need to directly identify the position marker, but instead identifies the area (target image area) that has an association with the position marker to indirectly deduce the position of the position marker, which helps to solve the problem of low position detection accuracy of the device to be detected in the prior art due to the difficulty in accurately capturing the position marker.
[0086] Optionally, the size of the device to be detected is less than or equal to a preset size threshold; and / or the difference between the size of the position marker and the size of the device marker on the device image is less than or equal to a preset size difference; the device marker is used to represent the device information of the device to be detected.
[0087] In the present disclosure, the surface of the device to be detected is printed with: device identification and position identification. And / or the size of the device to be detected is small. The preset size threshold can be 5 mm (illustrative), for example. Common components are: radio frequency amplifiers, discrete low noise amplifiers, etc.
[0088] When the device to be detected meets the above conditions, the position mark printed on the surface of the device to be detected is difficult to identify. For example, because the size of the device mark and the position mark are close, the device mark is easily mistakenly identified as the position mark. Or because the size of the device to be detected is small, it is not easy to identify the position mark, etc. In this case, the target image area is easier to identify. Therefore, the use of the present disclosure can more accurately determine the position of the position mark, thereby judging whether the installation position of the device to be detected in the circuit board is accurate.
[0089] Optional, Figure 8 FIG. 1 is a flow chart of another device detection method according to an exemplary embodiment of the present disclosure. When executing step 301 to obtain a device image of a device to be detected, the method includes the following steps:
[0090] Step 801: Acquire a first image obtained by photographing a component to be inspected on a circuit board at a preset angle.
[0091] The first image may be taken by a device used to detect the installation position of components on a circuit board. For example, an image obtained by an automatic optical inspection device (AOI) directly taking a picture of the component to be inspected on the circuit board to be inspected, for example Figure 4 The image 401 in FIG. 4 can be regarded as a first image directly obtained by photographing the device to be inspected on the circuit board.
[0092] Step 802: Process the first image to obtain a second image; the processing is used to remove the area where other circuit elements except the device to be detected are located in the first image.
[0093] Still Figure 4 Take this as an example to illustrate:
[0094] exist Figure 4 In the image 401, in addition to the component 103 to be detected, there are other circuit elements: pads, pins of the device to be detected (since the pins do not participate in position detection, they are also considered as interference elements). Figure 4 When the image 401 (first image) in FIG. 4 is used as a device image for recognition, these circuit elements will become interference elements. Therefore, in order to improve the recognition accuracy, the first image can be processed to obtain a second image (such as FIG. 4 ) in which the interference elements are filtered out. Figure 5 At this time, the circuit elements in the image 501 only include the device to be detected.
[0095] The following is an example of one of the processing methods:
[0096] Based on a pre-trained classification model, pixel points in the first image used to represent different circuit elements are classified to obtain a plurality of circuit element regions; circuit element regions that do not meet a first preset condition are removed to obtain the second image; the circuit elements in the second image are the devices to be detected.
[0097] A pre-trained classification model can be, for example, a visual segmentation model (Segment Anything Model, SAM). During the model training process, the model needs to learn the characteristics of different elements in the circuit board, such as electronic components, wires, solder joints, etc., and usually uses pixel-level annotation data to guide model learning. This means that each pixel has a corresponding semantic label, such as electronic components, wires, background, etc. These elements may have different shapes, sizes, and textures in the image. The model gradually improves the segmentation accuracy of the circuit board image by comparing the differences between the predicted results and the true annotations and optimizing the parameters according to the loss function.
[0098] Through the classification model, the image 401 (first image) can be segmented into several circuit element regions. When the device takes a picture of the device to be detected to obtain the first image (image 401), it is usually performed with the mounting coordinates as the origin and a field of view slightly larger than the mounting area. Therefore, in the segmented image, the device to be detected (component 103) should have the following characteristics: the centroid is roughly in the center of the image and the area occupies most of the overall area of the image.
[0099] Therefore, the first preset condition can be set according to the above characteristics, that is, the first preset condition includes:
[0100] The deviation between the centroid coordinates of the circuit element region and the centroid coordinates of the first image is less than or equal to a preset deviation; and / or the ratio between the area of the circuit element region and the area of the first image is greater than or equal to a preset ratio.
[0101] Exemplarily, the preset deviation may be set to 10%, and the preset ratio may be set to 50%. In this way, after the device image 401 is processed as the first image, the second image (image 501) can be obtained.
[0102] Step 803: Obtain the device image based on the second image.
[0103] After the second image is obtained according to step 803, the second image can be directly used as a device image for detection, which can ensure that there are no interfering elements in the device image, thereby avoiding the problem of inaccurate detection results caused by erroneous identification of other circuit elements as position markers.
[0104] Optional, Fig. 9 FIG. 1 is a flow chart of another device detection method according to an exemplary embodiment of the present disclosure. When executing step 301 to obtain a device image of a device to be detected, the method includes the following steps:
[0105] Step 801: Acquire a first image obtained by photographing a component to be inspected on a circuit board at a preset angle.
[0106] Step 901: Perform noise processing on the first image to obtain a third image.
[0107] Noise processing is used to filter out noise points other than the logo in the device image. The following is an example of one of the processing methods:
[0108] First, filter out the noise caused by color:
[0109] Pixels in the first image that do not satisfy preset color parameters are deleted to obtain a fourth image; the preset color parameters are set according to color parameters satisfied by the identifier under preset lighting parameters, and the identifier at least includes the position identifier; the fourth image is converted into a binary image; and noise processing is performed on the binary image to obtain the third image.
[0110] Among them, the mark on the surface of the device to be detected (device mark and / or position mark) has a specific color under the preset lighting parameters. For example, the mark is gray and appears white under the preset lighting parameters. Alternatively, the surface of the device to be detected is provided with a groove, and the groove is regarded as a position mark. When the surface of the device to be detected is illuminated, the groove will present a different color from other areas (areas without grooves). The pixels of the area without marks are usually black.
[0111] Therefore, by calculating the proportion of the three channel components of R, G, and B in the device area image, the preset color parameters are set as the color parameters satisfied by the logo under the preset lighting parameters. In this way, the pixels that do not satisfy the preset color parameters in the first image can be deleted to obtain a fourth image that only displays the pixels where the logo is located.
[0112] Deletion here means setting the color or grayscale value of the pixel points that do not meet the preset color parameters to a specific value. At this time, the fourth image includes: the pixel points whose color or grayscale value is set to a specific value (for example, 0) (i.e., the pixel points deleted after not meeting the preset color parameters) and the pixel points that meet the preset color parameters (the pixel points where the logo is located).
[0113] In this way, the problem of misidentification caused by abnormal grayscale value of a pixel point in the non-marked area can be avoided during the detection process.
[0114] Secondly, after obtaining the processed fourth image, the pixels in the non-marked area are deleted, and it is assumed that the grayscale value has been set to 0. However, the grayscale values of the pixels in the area where the logo is located are various values that meet the preset color parameters (for example: all parameters where the red channel accounts for more than 40% and the blue channel accounts for less than 30%), which is not conducive to subsequent calculations. Therefore, the fourth image is binarized, and then the fourth image after binarization is subjected to the following noise processing:
[0115] Performing an image closing operation on the binary image; the image closing operation is used to delete noise points in the binary image; and / or, based on the interquartile range criterion, deleting connected regions whose areas are less than or equal to the third quartile among the connected regions of the binary image.
[0116] Image Closing is a basic morphological image processing operation that combines the two steps of dilation and erosion. The basic principle of the closing operation is to dilate the image first, and then erode the dilated result. This can fill small holes, smooth edges, and remove small noise while maintaining the overall shape of the image.
[0117] For larger noise, the interquartile range criterion can be used to delete it:
[0118] The Interquartile Range Rule is a statistical outlier detection method used to determine whether there are outliers in a data set. It is based on the quartiles of the data and determines potential outliers by comparing the distance between the data point and the quartile. The device image has several connected regions consisting of 1 pixel, and the area of each connected region is used as a data in the data set.
[0119] The area values of several connected regions are divided by the interquartile range criterion. For example, the device image includes: connected region 1, connected region 2, connected region 3 and connected region 4. The areas of the connected regions are 1, 5, 3 and 2 respectively.
[0120] According to the area of the connected regions, we can divide them according to the interquartile range criterion. First, we need to calculate the third quartile (Q3) and the first quartile (Q1) of these connected regions, and then use the interquartile range (IQR) to determine the inner limit range.
[0121] Assume that the areas of the connected regions are 1, 5, 3, and 2, respectively. We sort these areas and get 1, 2, 3, and 5. Since the data set contains 4 values, the position of the third quartile Q3 falls between the third and fourth values. According to the calculation, Q3 = (3 + 5) / 2 = 4.
[0122] Therefore, deleting the connected areas whose area is less than or equal to the third quartile among the connected areas is to delete: connected area 1, connected area 3 and connected area 4. That is, to delete the connected areas whose area is less than 75% in the data set whose area is less than the interquartile range criterion (consider them as noise points), and the connected area 2 (considered as a mark) is left.
[0123] Step 902: Obtain the device image based on the third image.
[0124] The third image is used as the device image, so that when identifying the installation position of the device to be detected in the device image, there will be no interference from noise points, which helps to improve accuracy.
[0125] Alternatively, step 802, step 901 and step 902 may be processed together to obtain a final device image.
[0126] For example, a first image is acquired by photographing the component to be inspected on the circuit board at a preset angle.
[0127] Processing the first image to obtain a second image; the processing is used to remove the area where other circuit elements except the device to be detected are located in the first image;
[0128] The second image is subjected to noise processing to obtain a third image.
[0129] Pixels in the second image that do not meet preset color parameters are deleted to obtain a fourth image; the preset color parameters are set according to color parameters met by the identifier under preset lighting parameters, and the identifier at least includes the position identifier; the fourth image is converted into a binary image; and noise processing is performed on the binary image to obtain the third image.
[0130] A device image is obtained based on the third image.
[0131] The contents involved in the above steps have been explained in the above embodiments and will not be repeated here.
[0132] Optionally, the binarization process may be, for example, setting the value of the pixel points that meet the second preset condition to 1 (the pixel points in the identification area), and setting the value of the pixel points that do not meet the second preset condition to 0. This facilitates the subsequent direct processing of the pixel points whose pixel value is 1. The second preset condition may be: satisfying the preset color parameter, or the second preset condition may also be: the value of the pixel point is greater than or equal to a specified value (which may be set according to actual conditions, and the specified value is the pixel value satisfied by the identified pixel points and the pixel value not satisfied by the non-identified pixel points).
[0133] Alternatively, when the binarization processing is: binarizing the fourth image; the binarization processing includes: setting the values of the pixels in the fourth image that meet the second preset condition to 0, and setting the values of the pixels in the fourth image that do not meet the second preset condition to 1; performing color inversion processing on the image after the binarization processing; the color inversion processing is used to switch the value of each pixel in the binary image; and using the image after the color inversion processing as the binary image.
[0134] If the binarization process is used, the values of the pixels that meet the second preset condition are set to 0 (pixels in the identification area), and the values of the pixels that do not meet the second preset condition are set to 1. Then, the points with a value of 1 actually need to be processed later, so the image after the binarization process can be inverted: the values of the pixels with a value of 0 in the previous step are switched to 1, and the values of the pixels with a value of 1 in the previous step are switched to 0. In other words, the values of the pixels that meet the second preset condition are switched to 1 (pixels in the identification area), and the values of the pixels that do not meet the second preset condition are switched to 0.
[0135] Optionally, the target image area is the first area or the second area; and determining the area in the device image that meets the third preset condition as the target image area includes:
[0136] The region in the device image that meets the third preset condition is determined as the first region; the device image is rotated by a preset angle in a preset direction to obtain a rotated image; and the region in the rotated image that meets the third preset condition is determined as the second region.
[0137] When the device image is Figure 6a When the image shown in FIG. 1 is shown in FIG. 1 , the first area is area 601. Assume that the preset angle is rotated by 180° clockwise. Figure 6a The device image shown is rotated 180° clockwise to obtain the rotated image shown in Fig.10 As shown: The second area is Fig.10 Area 1001 in.
[0138] The determining the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker includes:
[0139] Based on the first area and the association relationship between the first area and the position marker, the first position of the position marker in the device image is determined; based on the second area and the association relationship between the second area and the position marker, the second position of the position marker in the rotated image is determined.
[0140] like Figure 6a As shown, according to the association relationship between the first area 601 and the position mark, it is determined that the position mark is located at the lower left corner (first position) of the device image.
[0141] like Fig.10 As shown, according to the association relationship between the second area 1001, the first area 1001 and the position mark, it is determined that the position mark is located at the upper right corner (second position) of the device image.
[0142] The preset position includes: when the installation position of the device to be detected on the circuit board is accurate, the designated position is located at a first preset position in the device image, or the designated position is located at a second preset position in the rotation image.
[0143] Assuming that the installation position of the device to be detected on the circuit board is accurate, the first preset position of the designated position in the device image is the lower left corner. Then the designated position of the rotated image obtained by rotating the device image 180° clockwise is located at the second preset position (upper right corner) in the rotated image.
[0144] At this time, the position detection result of the device to be detected can be determined according to the comparison result between the position of the position mark in the device image and the preset position.
[0145] For example, it can be determined as follows:
[0146] If each condition in the target conditions is met, a position detection result indicating that the position of the device to be detected is correct is generated, and the target conditions include: the first position is the same as the first preset position, and the second position is the same as the second preset position; and / or, if at least one condition in the target conditions is met, and the first position and the second position are located at the same position of the device to be detected, a position detection result indicating that the position of the device to be detected is correct is generated.
[0147] That is: when Figure 6a When the position mark in is located at the lower left corner (first position) of the device image, since the first position is the same as the first preset position and the second position is the same as the second preset position, it is determined that the installation position of the device to be detected is correct.
[0148] Or, when Figure 6a The position mark in the lower left corner of the device image (the first position) is in the same area as the second position in the rotated image. At this time, if the first position is the same as the first preset position, it can be determined that the installation position of the device to be detected is correct. Or, when Figure 6a The position marker in the device image is located at the lower left corner (first position) and Fig.10 The second position in the rotation image in the same area, if the second position is the same as the second preset position, it can be determined that the installation position of the device to be detected is correct. Figure 6a The position mark in the lower left corner of the device image (the first position) is in the same area as the second position in the rotated image. At this time, if the first position is the same as the first preset position and the second position is the same as the second preset position, it can be determined that the installation position of the device to be inspected is correct.
[0149] If the first position is different from the first preset position, and / or the second position is different from the second preset position, a position detection result indicating that the position of the component to be detected is wrong is generated.
[0150] Illustratively, if the first position is different from the first preset position, the device image may not be rotated, thereby reducing the amount of calculation.
[0151] Optionally, when the device to be inspected includes a device identifier and a position identifier, and the target image area is determined according to a third preset condition, the device image is a minimum circumscribed rectangular image of a contour boundary of the position identifier and a contour boundary of the device identifier on the device image, and the device identifier is used to represent the device information of the device to be inspected.
[0152] like Fig.11 As shown, if the device image is 1101, when the target image area is determined by the third preset condition, if the bounding rectangle (for example, the minimum bounding rectangle) is not set, it is easy to determine the area in the upper right corner of the image area 1101 as the target image area. At this time, the minimum bounding rectangle image can be determined by the device identification and position identification to improve the accuracy of the determined target image area.
[0153] For the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described order of actions, because according to the present disclosure, certain steps can be performed in other orders or simultaneously.
[0154] Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0155] Corresponding to the aforementioned application function realization method embodiment, the present disclosure also provides an embodiment of a device detection apparatus and a corresponding terminal.
[0156] Fig.12 is a schematic structural diagram of a device detection apparatus according to an exemplary embodiment of the present disclosure. Fig.12 As shown, the device comprises:
[0157] The first acquisition module 1201 is used to acquire a device image of the device to be inspected.
[0158] The second acquisition module 1202 is used to acquire a target image area from the device image, where the target image area is an area associated with a position identifier in the device to be detected, and the position identifier is located at a specified position of the device to be detected. When the installation position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image.
[0159] The first determination module 1203 is used to determine the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker.
[0160] The second determination module 1204 is used to determine the position detection result of the device to be detected based on the comparison result between the position of the position mark in the device image and the preset position, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
[0161] Optionally, the size of the device to be detected is less than or equal to a preset size threshold; and / or the difference between the size of the position marker and the size of the device marker on the device image is less than or equal to a preset size difference; the device marker is used to represent the device information of the device to be detected.
[0162] Optionally, when the first acquisition module 1201 is used to acquire the device image of the device to be inspected, it is used to:
[0163] A first image is acquired by photographing the component to be inspected on the circuit board at a preset angle.
[0164] The first image is processed to obtain a second image; the processing is used to remove the area where other circuit elements except the device to be detected are located in the first image.
[0165] Based on the second image, the device image is obtained.
[0166] Optionally, when the first acquisition module 1201 is used to process the first image to obtain the second image, it is used to:
[0167] Based on a pre-trained classification model, pixel points in the first image used to represent different circuit elements are classified to obtain a plurality of circuit element regions.
[0168] The circuit element regions that do not meet the first preset condition are removed to obtain the second image; the circuit elements in the second image are the devices to be detected.
[0169] Optionally, the first preset condition includes:
[0170] The deviation between the centroid coordinates of the circuit element region and the centroid coordinates of the first image is less than or equal to a preset deviation; and / or the ratio between the area of the circuit element region and the area of the first image is greater than or equal to a preset ratio.
[0171] Optionally, when the first acquisition module 1201 is used to acquire the device image of the device to be inspected, it is used to:
[0172] A first image is acquired by photographing the component to be inspected on the circuit board at a preset angle.
[0173] Noise processing is performed on the first image to obtain a third image.
[0174] Based on the third image, the device image is obtained.
[0175] Optionally, when the first acquisition module 1201 is used to perform noise processing on the first image to obtain the third image, it is used to:
[0176] Pixels in the first image that do not satisfy preset color parameters are deleted to obtain a fourth image; the preset color parameters are set according to color parameters satisfied by the identifier under preset lighting parameters, and the identifier at least includes the position identifier.
[0177] The fourth image is converted into a binary image.
[0178] Noise processing is performed on the binarized image to obtain the third image.
[0179] Optionally, when the first acquisition module 1201 is used to convert the fourth image into a binary image, it is used to:
[0180] The fourth image is binarized; the binarization includes: setting the values of the pixels in the fourth image that meet the second preset condition to 0, and setting the values of the pixels in the fourth image that do not meet the second preset condition to 1.
[0181] The image after the binarization process is subjected to a color inversion process; the color inversion process is used to switch the value of each pixel in the binarization image.
[0182] The image after the color inversion process is used as the binary image.
[0183] Optionally, when the first acquisition module 1201 is used to perform noise processing on the binary image, it is used to:
[0184] Performing an image closing operation on the binary image; the image closing operation is used to delete noise points in the binary image; and / or, based on the interquartile range criterion, deleting connected regions whose areas are less than or equal to the third quartile among the connected regions of the binary image.
[0185] Optionally, the device image includes the position identifier and a device identifier on the device image, and the device identifier is used to indicate device information of the device to be detected.
[0186] When the second acquisition module 1202 is used to acquire the target image area from the device image, it is used to:
[0187] An area in the device image that meets a third preset condition is determined as the target image area.
[0188] The third preset condition includes: when the device image includes at least one area, an area whose total pixel value is less than or equal to a preset threshold; or, when there are at least two areas in the device image, an area with the smallest total pixel value; the total pixel value is positively correlated with the area marked in the area.
[0189] Optionally, the target image area is the first area or the second area.
[0190] When the second acquisition module 1202 is used to determine the area in the device image that meets the third preset condition as the target image area, it is used to:
[0191] An area in the device image that meets a third preset condition is determined as the first area.
[0192] The device image is rotated in a preset direction by a preset angle to obtain a rotated image.
[0193] An area in the rotated image that meets a third preset condition is determined as the second area.
[0194] When the first determining module 1203 is used to determine the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker, it is used to:
[0195] Based on the first region and an association relationship between the first region and the position marker, a first position of the position marker in the device image is determined.
[0196] Based on the second area and the association relationship between the second area and the position marker, a second position of the position marker in the rotated image is determined.
[0197] The preset position includes: when the installation position of the device to be detected on the circuit board is accurate, the designated position is located at a first preset position in the device image, or the designated position is located at a second preset position in the rotation image.
[0198] Optionally, when the second determining module 1204 is used to determine the position detection result of the device to be detected based on the comparison result between the position of the position identifier in the device image and the preset position, it is used to:
[0199] If each of the target conditions is met, a position detection result indicating that the position of the device to be detected is correct is generated, wherein the target conditions include: the first position is the same as the first preset position, and the second position is the same as the second preset position;
[0200] And / or, if at least one of the target conditions is satisfied and the first position and the second position are located at the same position of the device to be detected, a position detection result indicating that the position of the device to be detected is correct is generated.
[0201] And / or, if the first position is different from the first preset position, and / or the second position is different from the second preset position, a position detection result indicating that the position of the component to be detected is wrong is generated.
[0202] Optionally, the device image is a minimum circumscribed rectangular image of a contour boundary of the position marker and a contour boundary of a device marker on the device image, and the device marker is used to represent device information of the device to be detected.
[0203] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art may understand and implement it without creative work.
[0204] Accordingly, an embodiment of the present disclosure provides an electronic device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to implement the steps of any of the above-mentioned device detection methods by running the executable instructions. In the present disclosure, the electronic device may be, for example, an automatic optical inspection device (AOI) for inspecting a device to be inspected.
[0205] Fig.131 is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present disclosure. For example, the electronic device 1300 may be a user device, which may specifically be a mobile phone, a computer, a digital broadcast terminal, a message transceiver device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, a wearable device such as a smart watch, a smart glasses, a smart bracelet, a smart running shoe, etc.
[0206] Reference Fig.13 , the electronic device 1300 may include one or more of the following components: a processing component 1302 , a memory 1304 , a power component 1306 , a multimedia component 1308 , an audio component 1310 , an input / output (I / O) interface 1312 , a sensor component 1314 , and a communication component 1316 .
[0207] The processing component 1302 generally controls the overall operation of the electronic device 1300, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1302 may include one or more processors 1320 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1302 may include one or more modules to facilitate the interaction between the processing component 1302 and other components. For example, the processing component 1302 may include a multimedia module to facilitate the interaction between the multimedia component 1308 and the processing component 1302.
[0208] The memory 1304 is configured to store various types of data to support operations on the device 1300. Examples of such data include instructions for any application or method operating on the electronic device 1300, contact data, phone book data, messages, pictures, videos, etc. The memory 1304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0209] The power supply component 1306 provides power to the various components of the electronic device 1300. The power supply component 1306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1300.
[0210] The multimedia component 1308 includes a screen that provides an output interface between the electronic device 1300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1308 includes a front camera and / or a rear camera. When the electronic device 1300 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0211] The audio component 1310 is configured to output and / or input audio signals. For example, the audio component 1310 includes a microphone (MIC), and when the electronic device 1300 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1304 or sent via the communication component 1316. In some embodiments, the audio component 1310 also includes a speaker for outputting audio signals.
[0212] I / O interface 1312 provides an interface between processing component 1302 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0213] The sensor assembly 1314 includes one or more sensors for providing various aspects of status assessment for the electronic device 1300. For example, the sensor assembly 1314 can detect the open / closed state of the electronic device 1300, the relative positioning of the components, such as the display and keypad of the electronic device 1300, and the sensor assembly 1314 can also detect the position change of the electronic device 1300 or a component of the electronic device 1300, the presence or absence of user contact with the electronic device 1300, the position or acceleration / deceleration of the electronic device 1300, and the temperature change of the electronic device 1300. The sensor assembly 1314 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1314 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1314 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0214] The communication component 1316 is configured to facilitate wired or wireless communication between the electronic device 1300 and other devices. The electronic device 1300 can access a wireless network based on a communication standard, such as WiFi, 4G or 5G, 4G LTE, 5G NR or a combination thereof. In an exemplary embodiment, the communication component 1316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0215] In an exemplary embodiment, the electronic device 1300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0216] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory 1304 including instructions, which, when executed by a processor 1320 of an electronic device 1300, enables the electronic device 1300 to perform a device detection method, the method comprising:
[0217] Acquire a device image of the device to be inspected.
[0218] A target image area is obtained from the device image, wherein the target image area is an area associated with a position identifier in the device to be detected, the position identifier is located at a specified position of the device to be detected, and when the installation position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image.
[0219] Based on the target image area and the association relationship between the target image area and the position marker, the position of the position marker in the device image is determined.
[0220] Based on the comparison result between the position of the position mark in the device image and the preset position, the position detection result of the device to be detected is determined, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
[0221] The non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0222] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0223] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A device detection method, characterized in that: The method comprises: Acquire a device image of the device to be inspected; Acquire a target image region from the device image, wherein the target image region is a region associated with a position mark in the device to be detected, wherein the position mark is located at a specified position of the device to be detected, and when the mounting position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image; Determine the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker; Based on the comparison result between the position of the position mark in the device image and the preset position, the position detection result of the device to be detected is determined, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
2. The method according to claim 1, characterized in that The size of the device to be detected is less than or equal to a preset size threshold; And / or, the difference between the size of the position mark and the size of the device mark on the device image is less than or equal to a preset size difference; the device mark is used to represent the device information of the device to be detected.
3. The method according to claim 1, characterized in that The step of obtaining a device image of the device to be detected comprises: Acquire a first image obtained by photographing the device to be inspected on the circuit board at a preset angle; Processing the first image to obtain a second image; the processing is used to remove the area where other circuit elements except the device to be detected are located in the first image; Based on the second image, the device image is obtained.
4. The method according to claim 3, characterized in that The processing of the first image to obtain a second image includes: Classifying the pixels representing different circuit elements in the first image based on a pre-trained classification model to obtain a plurality of circuit element regions; The circuit element regions that do not meet the first preset condition are removed to obtain the second image; the circuit elements in the second image are the devices to be detected.
5. The method according to claim 4, characterized in that The first preset condition includes: The deviation between the centroid coordinates of the circuit element region and the centroid coordinates of the first image is less than or equal to a preset deviation; And / or, a ratio between an area of the circuit element region and an area of the first image is greater than or equal to a preset ratio.
6. The method according to claim 1, characterized in that The step of obtaining a device image of the device to be detected comprises: Acquire a first image obtained by photographing the device to be inspected on the circuit board at a preset angle; performing noise processing on the first image to obtain a third image; Based on the third image, the device image is obtained.
7. The method according to claim 6, characterized in that The performing noise processing on the first image to obtain a third image includes: Delete the pixels in the first image that do not meet the preset color parameters to obtain a fourth image; the preset color parameters are set according to the color parameters met by the identifier under the preset lighting parameters, and the identifier at least includes the position identifier; Converting the fourth image into a binary image; Noise processing is performed on the binarized image to obtain the third image.
8. The method according to claim 7, characterized in that The converting the fourth image into a binary image comprises: Binarization is performed on the fourth image; the binarization includes: setting the values of the pixels in the fourth image that meet the second preset condition to 0, and setting the values of the pixels in the fourth image that do not meet the second preset condition to 1; Performing color inversion processing on the image after the binarization processing; the color inversion processing is used to switch the value of each pixel in the binarization image; The image after the color inversion process is used as the binary image.
9. The method according to claim 7, characterized in that: The performing noise processing on the binary image comprises: Performing an image closing operation on the binary image; the image closing operation is used to delete noise points in the binary image; And / or, based on the interquartile range criterion, the connected regions whose areas are less than or equal to the third quartile among the connected regions of the binary image are deleted.
10. The method according to claim 1, characterized in that The device image includes the position mark and the device mark on the device image, and the device mark is used to represent the device information of the device to be detected; The step of acquiring a target image area from the device image comprises: Determining a region in the device image that meets a third preset condition as the target image region; The third preset condition includes: when the device image includes at least one area, an area whose total pixel value is less than or equal to a preset threshold; or, when there are at least two areas in the device image, an area with the smallest total pixel value; the total pixel value is positively correlated with the area marked in the area.
11. The method according to claim 10, characterized in that The target image area is the first area or the second area; The step of determining a region in the device image that meets a third preset condition as the target image region comprises: Determine an area in the device image that meets a third preset condition as the first area; Rotating the device image in a preset direction and by a preset angle to obtain a rotated image; Determining an area in the rotated image that meets a third preset condition as the second area; The determining the position of the position marker in the device image based on the target image area and the association relationship between the target image area and the position marker includes: Determine a first position of the position marker in the device image based on the first region and an association relationship between the first region and the position marker; Determine a second position of the position marker in the rotated image based on the second area and an association relationship between the second area and the position marker; The preset position includes: when the installation position of the device to be detected on the circuit board is accurate, the designated position is located at a first preset position in the device image, or the designated position is located at a second preset position in the rotation image.
12. The method according to claim 11, characterized in that The step of determining the position detection result of the device to be detected based on the comparison result between the position of the position marker in the device image and the preset position includes: If each of the target conditions is met, a position detection result indicating that the position of the device to be detected is correct is generated, wherein the target conditions include: the first position is the same as the first preset position, and the second position is the same as the second preset position; and / or, If at least one of the target conditions is satisfied, and the first position and the second position are located at the same position of the device to be detected, a position detection result indicating that the position of the device to be detected is correct is generated; and / or, If the first position is different from the first preset position, and / or the second position is different from the second preset position, a position detection result indicating that the position of the component to be detected is wrong is generated.
13. The method according to claim 1 or 10, characterized in that: The device image is a minimum circumscribed rectangular image of the contour boundary of the position mark and the contour boundary of the device mark on the device image, and the device mark is used to represent the device information of the device to be detected.
14. A device detection apparatus, characterized in that: The device comprises: A first acquisition module, used to acquire a device image of a device to be detected; A second acquisition module is used to acquire a target image area from the device image, wherein the target image area is an area associated with a position mark in the device to be detected, the position mark is located at a specified position of the device to be detected, and when the installation position of the device to be detected on the circuit board is accurate, the specified position is located at a preset position in the device image; A first determination module, configured to determine a position of the position marker in the device image based on the target image area and an association relationship between the target image area and the position marker; The second determination module is used to determine the position detection result of the device to be detected based on the comparison result between the position of the position mark in the device image and the preset position, and the position detection result is used to indicate whether the installation position of the device to be detected on the circuit board is accurate.
15. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the steps of any one of the methods of claims 1 to 13 by running the executable instructions.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of any method described in claims 1 to 13 are implemented.