[go: up one dir, main page]

CN105184778A - Detection method and device - Google Patents

Detection method and device Download PDF

Info

Publication number
CN105184778A
CN105184778A CN201510527486.9A CN201510527486A CN105184778A CN 105184778 A CN105184778 A CN 105184778A CN 201510527486 A CN201510527486 A CN 201510527486A CN 105184778 A CN105184778 A CN 105184778A
Authority
CN
China
Prior art keywords
image
template image
component
sample set
similarity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201510527486.9A
Other languages
Chinese (zh)
Other versions
CN105184778B (en
Inventor
杨铭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Original Assignee
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Shiyuan Electronics Thecnology Co Ltd filed Critical Guangzhou Shiyuan Electronics Thecnology Co Ltd
Priority to CN201510527486.9A priority Critical patent/CN105184778B/en
Publication of CN105184778A publication Critical patent/CN105184778A/en
Priority to PCT/CN2016/096551 priority patent/WO2017032311A1/en
Application granted granted Critical
Publication of CN105184778B publication Critical patent/CN105184778B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T7/001Industrial image inspection using an image reference approach
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30141Printed circuit board [PCB]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Quality & Reliability (AREA)

Abstract

本发明实施例公开了一种检测方法及装置,所述方法,包括:将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;计算所述模板图像与所述测试图像的特征向量的相似度;根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,本发明实施例通过将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。

The embodiment of the present invention discloses a detection method and device. The method includes: inputting a template image and a test image into a trained Siamese network, and performing forward calculations respectively to obtain the results of the template image and the test image. feature vector; calculating the similarity between the template image and the feature vector of the test image; determining whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, the embodiment of the present invention can accurately judge whether the template image matches the test image by inputting the image into the trained Siamese network, and the judgment accuracy is high.

Description

一种检测方法及装置A detection method and device

技术领域technical field

本发明涉及AOI领域,具体涉及一种检测方法及装置。The invention relates to the field of AOI, in particular to a detection method and device.

背景技术Background technique

图像匹配是指利用图像特征判断两幅图像是否相似的技术,目前已应用于各种领域,如可利用图像匹配技术进行元件检测、人脸识别等,但是目前由于用于进行图像匹配的图像特征的鲁棒性低,容易受光照等环境的影响而导致匹配出现误差,匹配准确率低。Image matching refers to the technology of judging whether two images are similar by using image features. It has been used in various fields, such as component detection and face recognition, etc. by using image matching technology. The robustness is low, and it is easy to be affected by the environment such as lighting, which may cause matching errors, and the matching accuracy is low.

以元件检测领域的图像匹配为例:印刷线路板(Printedcircuitboard,简称PCB板)是指为各种电子元器件提供连接的电路板,随着电子设备越来越复杂,需要的零件自然越来越多,PCB上头的线路与连接也越来越密集,从而在焊接/手插电子元件的时候难免出现漏件现象,那么需要在PCB板焊接完毕后对PCB板是否出现漏件进行检测。Take image matching in the field of component detection as an example: Printed circuit board (PCB board for short) refers to a circuit board that provides connections for various electronic components. As electronic equipment becomes more and more complex, the required parts are naturally more and more Many, the lines and connections on the PCB are becoming more and more dense, so it is inevitable that there will be missing parts when soldering/hand-inserting electronic components, so it is necessary to check whether there are missing parts on the PCB board after the PCB board is soldered.

目前,对PCB板电子元件的漏件检测有些是通过人工检测来进行,此种方案耗时多、成本高以及效率低,所以现在一般采用自动检测方法来进行,最普遍的自动检测方法是基于模板匹配的漏件检测方法,但是该方案容易受光照等环境的影响而导致检测失误,也有些是基于颜色直方图或一些低层特征的来实现,但是这些方案由于电子元件的颜色信息不可靠或电子元件的低层特征不明显而导致检测失误。At present, the detection of missing parts of electronic components on PCB boards is carried out by manual detection. This kind of scheme is time-consuming, high in cost and low in efficiency. Template matching missing parts detection method, but this scheme is susceptible to detection errors due to the influence of lighting and other environments, and some are implemented based on color histograms or some low-level features, but these schemes are due to unreliable color information of electronic components or The low-level features of electronic components are not obvious and lead to detection errors.

发明内容Contents of the invention

本发明实施例提供了一种检测方法及装置,以期可以提高图像的相似检测准确率,可靠性高。The embodiment of the present invention provides a detection method and device, in order to improve the accuracy of image similarity detection and to have high reliability.

本发明实施例第一方面提供一种检测方法,包括:The first aspect of the embodiments of the present invention provides a detection method, including:

将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;The template image and the test image are input into the Siamese network after training, and the feature vectors of the template image and the test image are obtained by forward calculation respectively;

计算所述模板图像与所述测试图像的特征向量的相似度;Calculating the similarity between the template image and the feature vector of the test image;

根据所述相似度确定所述测试图像与所述模板图像是否匹配。Determine whether the test image matches the template image according to the similarity.

本发明实施例第二方面提供一种检测装置,包括:The second aspect of the embodiment of the present invention provides a detection device, including:

图像输入模块,用于将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;Image input module, for template image and test image input Siamese network after training, and do forward calculation respectively to obtain the feature vector of described template image and described test image;

计算模块,用于计算所述模块图像与所述测试图像的特征向量的相似度;Calculation module, for calculating the similarity between the feature vector of the module image and the test image;

确定模块,用于根据所述相似度确定所述测试图像与所述模板图像是否匹配。A determining module, configured to determine whether the test image matches the template image according to the similarity.

可以看出,在本发明实施例提供的技术方案中,将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;计算所述模板图像与所述测试图像的特征向量的相似度;根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。It can be seen that in the technical solution provided by the embodiments of the present invention, the template image and the test image are input into the trained Siamese network, and forward calculations are performed respectively to obtain the feature vectors of the template image and the test image; The similarity between the feature vector of the template image and the test image; determining whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately judge whether the template image matches the test image, and the judgment accuracy is high.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1-a是本发明实施例提供的Siamese网络的网络结构图;Fig. 1-a is the network structural diagram of the Siamese network that the embodiment of the present invention provides;

图1-b是本发明第一实施例提供的一种检测方法的流程示意图;Fig. 1-b is a schematic flow chart of a detection method provided by the first embodiment of the present invention;

图2是本发明第二实施例提供的一种检测方法的流程示意图;Fig. 2 is a schematic flow chart of a detection method provided by the second embodiment of the present invention;

图3是本发明第三实施例提供的一种检测装置的结构示意图;Fig. 3 is a schematic structural diagram of a detection device provided by a third embodiment of the present invention;

图4是本发明第四实施例提供的一种检测装置的结构示意图;Fig. 4 is a schematic structural diagram of a detection device provided by a fourth embodiment of the present invention;

图5是本发明第五实施例提供的一种检测装置的结构示意图。Fig. 5 is a schematic structural diagram of a detection device provided by a fifth embodiment of the present invention.

具体实施方式Detailed ways

本发明实施例提供了本发明实施例提供了一种检测方法及装置,以期可以提高图像的相似检测准确率,可靠性高。The embodiment of the present invention provides a detection method and device in the embodiment of the present invention, in order to improve the accuracy of image similarity detection and to have high reliability.

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only It is an embodiment of a part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.

本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”和“第三”等是用于区别不同对象,而非用于描述特定顺序。此外,术语“包括”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second" and "third" in the specification and claims of the present invention and the above drawings are used to distinguish different objects, rather than to describe a specific order. Furthermore, the term "comprise", as well as any variations thereof, is intended to cover a non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally further includes For other steps or units inherent in these processes, methods, products or apparatuses.

本发明实施例的一种检测方法,一种检测方法包括:A kind of detection method of the embodiment of the present invention, a kind of detection method comprises:

将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;计算所述模板图像与所述测试图像的特征向量的相似度;根据所述相似度确定所述测试图像与所述模板图像是否匹配。Input the template image and the test image into the Siamese network after training, and perform forward calculations respectively to obtain the feature vector of the template image and the test image; calculate the similarity between the template image and the feature vector of the test image ; Determine whether the test image matches the template image according to the similarity.

首先参见图1,图1-a是本发明实施例提供的Siamese网络的网络结构图;图1-b是本发明第一实施例提供的一种检测方法的流程示意图。其中,如图1-b所示,本发明第一实施例提供的一种检测方法可以包括:Referring first to Fig. 1, Fig. 1-a is a network structure diagram of a Siamese network provided by an embodiment of the present invention; Fig. 1-b is a schematic flowchart of a detection method provided by the first embodiment of the present invention. Among them, as shown in Figure 1-b, a detection method provided by the first embodiment of the present invention may include:

S101、将所述模板图像与所述测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量。其中,参见图1-a,Siamese网络是一种深度神经网络,根据Siamese网络的特点,可计算出来图像各个层次的特征,包括低层特征和高层特征,从而根据图像的高层特征对图像进行分析时将得到更为精确的结果。为了进行图像匹配,设计Siamese网络包含两个结构一样并共享参数的卷积神经网络,在利用Siamese网络进行图像匹配时,分别输入图像的模板图像和测试图像,从而可分别计算出来两个输入图像的特征向量,再计算两个特征向量的相似度,从而根据相似度的值判断两幅图像的相似程度即判断两幅图像是否匹配。S101. Input the template image and the test image into the trained Siamese network, and perform forward calculation respectively to obtain feature vectors of the template image and the test image. Among them, see Figure 1-a, the Siamese network is a deep neural network. According to the characteristics of the Siamese network, the features of each level of the image can be calculated, including low-level features and high-level features, so that the image can be analyzed according to the high-level features of the image. will get more accurate results. In order to perform image matching, the Siamese network is designed to include two convolutional neural networks with the same structure and shared parameters. When using the Siamese network for image matching, the template image and the test image of the image are input respectively, so that two input images can be calculated separately. The eigenvectors, and then calculate the similarity of the two eigenvectors, so as to judge the similarity of the two images according to the value of the similarity, that is, to judge whether the two images match.

其中,经过训练后的Siamese网络由于经过大量的样本图像的训练学习,具有了准确地对模板图像与测试图像进行图像匹配的能力。Among them, the trained Siamese network has the ability to accurately match the template image and the test image due to the training and learning of a large number of sample images.

其中,模板图像是用于对照的标准的图片,测试图像是通过与模板图像进行对照从而判断与模板图像是否匹配。Wherein, the template image is a standard picture for comparison, and the test image is compared with the template image to determine whether it matches the template image.

S102、计算所述模板图像与所述测试图像的特征向量的相似度。S102. Calculate the similarity between the feature vectors of the template image and the test image.

其中,相似度是用于判断模板图像与测试图像相似程序的参数。Wherein, the similarity is a parameter for judging the similarity between the template image and the test image.

可选地,在本发明的一些可能的实施方式中,可在计算模块图像与测试图像的特征向量后,再计算特征向量的欧氏距离得到模板图像与测试图像的特征向量的相似度。Optionally, in some possible implementations of the present invention, after calculating the feature vectors of the module image and the test image, the Euclidean distance of the feature vectors can be calculated to obtain the similarity between the feature vectors of the template image and the test image.

S103、根据所述相似度确定所述测试图像与所述模板图像是否匹配。S103. Determine whether the test image matches the template image according to the similarity.

其中,由于相似度是对Siamese网络输入的两个图像的特征的相似情况的度量,所以可通过相似度来判断模板图像与测试图像是否相似,也即判断模板图像与测试图像是否匹配。Among them, since the similarity is a measure of the similarity of the features of the two images input by the Siamese network, it can be used to judge whether the template image is similar to the test image, that is, to judge whether the template image matches the test image.

可以看出,本实施例的方案中,将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;计算所述模板图像与所述测试图像的特征向量的相似度;根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。It can be seen that in the solution of this embodiment, the template image and the test image are input into the Siamese network after training, and the feature vectors of the template image and the test image are obtained by forward calculation respectively; the template image is calculated A similarity with the feature vector of the test image; determining whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately judge whether the template image matches the test image, and the judgment accuracy is high.

可选地,在本发明的一些可能的实施方式中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像,所述根据所述相似度确定所述测试图像与所述模板图像是否匹配,包括:Optionally, in some possible implementations of the present invention, the template image is the corresponding component image when the component exists and is in a standard position, the test image is the component image that needs to be tested, and the Determine whether the test image matches the template image, including:

根据所述相似度确定所述测试图像对应的元件是否存在。Determine whether the component corresponding to the test image exists according to the similarity.

其中,该模板图像可以为PCB模板图,从而与其对应输入的元件图像或测试图像也为PCB图像,该模板图也可以为从PCB图像上截取到的分别包含各个独立元件的图像,从而与其对应输入的测试图像也为包含各个独立元件的图像。Wherein, the template image can be a PCB template image, so that the input component image or test image corresponding to it is also a PCB image, and the template image can also be an image containing each independent component intercepted from the PCB image, so as to correspond to it The input test image is also an image containing individual components.

可选地,在本发明的一些可能的实施方式中,由于是对每个元件进行漏件检测,所以一般在Siamese网络中输入的模板图像为包含一个独立元件的图像,那么在训练阶段输入的元件图像也为从PCB图像上截取到的该位置的元件图像,在测试阶段输入的图像也为不同情况下从PCB图像上截取到的该位置的元件图像。Optionally, in some possible implementations of the present invention, since the missing part detection is performed on each component, generally the template image input in the Siamese network is an image containing an independent component, then the input in the training phase The component image is also the component image of the position intercepted from the PCB image, and the image input in the test stage is also the component image of the position intercepted from the PCB image in different situations.

可选地,在本发明的一些可能的实施方式中,当模板图像为元件的模板图像时,可以理解,模板图像为元件存在并且元件的位置处于一个正确位置的元件图像,测试图像则根据模板图像判断是否漏件。Optionally, in some possible implementations of the present invention, when the template image is a template image of a component, it can be understood that the template image is a component image in which the component exists and the position of the component is in a correct position, and the test image is based on the template The image judges whether there is a missing part.

可以理解,由于Siamese网络可以判断测试图像与模板图像是否匹配,所以当模板图像与测试图像为元件图像时,可以根据相似度确定元件图像的测试图像是否与模板图像是否匹配,也即确定测试图像对应的元件是否存在。It can be understood that since the Siamese network can judge whether the test image matches the template image, when the template image and the test image are component images, it can be determined according to the similarity whether the test image of the component image matches the template image, that is, determine the test image Whether the corresponding element exists.

可选地,在本发明的一些可能的实施方式中,所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络之前,所述方法还包括:Optionally, in some possible implementation manners of the present invention, before inputting the template image and the test image into the trained Siamese network, the method further includes:

利用模板匹配得到所述模板图像与所述测试图像中元件的位置并对所述模板图像与所述测试图像进行对齐;Obtaining the position of the template image and the element in the test image by template matching and aligning the template image and the test image;

对所述模板图像与所述测试图像进行归一化,以触发执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。The template image and the test image are normalized to trigger the execution of the step of inputting the template image and the test image into the trained Siamese network.

可以理解,由于元件图像是从模板图像上截取下来的一块图像,为了使检测结果更为准确,需要使截取到的元件图像中的元件位于图像的中心位置,并同时对图像的大小进行归一化,这样以保证后续处理的准确性。该过程称为预处理过程。It can be understood that since the component image is an image intercepted from the template image, in order to make the detection result more accurate, it is necessary to locate the component in the intercepted component image at the center of the image, and at the same time normalize the size of the image to ensure the accuracy of subsequent processing. This process is called preprocessing.

可选地,在本发明的一些可能的实施方式中,也可以不对图像进行预处理。Optionally, in some possible implementation manners of the present invention, the image may not be preprocessed.

可选地,在本发明的一些可能的实施方式中,所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络之前,所述方法还包括:Optionally, in some possible implementation manners of the present invention, before inputting the template image and the test image into the trained Siamese network, the method further includes:

创建所述元件图像对正样本集合以及负样本集合,其中,所述正样本集合包括所述模板图像与所述元件存在时的所述元件图像构成的元件图像对,所述负样本集合包括所述模板图像与所述元件不存在时的所述元件图像构成的元件图像对,所述负样本集合还包括所述模板图像与其它元件存在时的元件图像构成的元件图像对;Create a positive sample set and a negative sample set for the component image pair, wherein the positive sample set includes a component image pair formed by the template image and the component image when the component exists, and the negative sample set includes the The component image pair formed by the template image and the component image when the component does not exist, the negative sample set also includes the component image pair formed by the template image and component images when other components exist;

利用所述正样本集合以及所述负样本集合训练所述Siamese网络,以触发执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。Using the positive sample set and the negative sample set to train the Siamese network, so as to trigger the execution of the step of inputting the template image and the test image into the trained Siamese network.

需要说明,可选地,在本发明的一些可能的实施方式中,当模板图像与测试图像为PCB图像时,则样本集合中的正样本集合包括模板图像与模板图像上各元件位置上均包含的是正确的元件时的元件图像构成的元件图像对,负样本集合包括模板图像与各元件位置上可能不存在元件时的元件图像构成的元件图像对,负样本集合还包括模板图像与各元件位置上的元件均存在、但是可能插入了错误的元件时的元件图像构成的元件图像对。It should be noted that, optionally, in some possible implementations of the present invention, when the template image and the test image are PCB images, the positive sample set in the sample set includes the template image and the position of each component on the template image. The component image pair composed of the component image when the component is correct, the negative sample set includes the component image pair composed of the template image and the component image when there may be no component in each component position, the negative sample set also includes the template image and each component A component image pair composed of component images when all components exist at the position, but a wrong component may be inserted.

可选地,在本发明的另一些可能的实施方式中,当模板图像与测试图像均为从PCB图像上截取到的分别包含各个独立元件的图像,从而样本集合中的正样本集合包括模板图像与包含该模板图像中的元件的图像构成的元件图像对,负样本集合包括模板图像与不包含元件的图像构成的元件图像对,负样本集合还包括模板图像与包含了不是模板图像中的元件、但是包含了其它的错误元件的元件图像构成的元件图像对。Optionally, in other possible implementations of the present invention, when both the template image and the test image are images containing individual components that are intercepted from the PCB image, the positive sample set in the sample set includes the template image The component image pair composed of the image containing the component in the template image, the negative sample set includes the component image pair composed of the template image and the image that does not contain the component, and the negative sample set also includes the template image and the component that is not in the template image , but contains component images of other wrong components.

可选地,在本发明的一些可能的实施方式中,所述正样本集合包括所述模板图像,以及元件存在并且在各个场景下拍摄的样本,如在光线不好的情况下拍摄的正样本图像,以及从不同的位置或角度拍摄的正样本图像,或者其它复杂场景下拍摄的正样本图像,利用各个场景下拍摄的正样本图像对Siamese网络进行训练,从而使Siamese网络具有更强的识别能力,能够在后续测试阶段对不同场景下拍摄的非漏件的元件图像进行正确的检测,提高识别率。Optionally, in some possible implementation manners of the present invention, the set of positive samples includes the template image, and samples in which components exist and are taken in various scenes, such as positive samples taken in bad light images, and positive sample images taken from different positions or angles, or positive sample images taken in other complex scenes, the Siamese network is trained using the positive sample images taken in each scene, so that the Siamese network has a stronger recognition Ability to correctly detect non-missing component images taken in different scenarios in the subsequent test stage, and improve the recognition rate.

可以理解,在利用Siamese网络对图像进行漏件检测时,首先需要对Siamese网络利用样本进行训练学习,得到Siamese网络的参数,从而再利用训练后的Siamese网络对元件图像准确地进行漏件检测。而在对Siamese网络进行训练时,需要分别利用各种场景下的正样本集合以及负样本集合进行训练,这样才能使Siamese网络充分学习到元件不是漏件时的图片情况,以及使Siamese网络充分学习到元件漏件时的图片情况,后续才能正确地进行漏件检测。It can be understood that when using the Siamese network to detect missing parts in images, it is first necessary to train and learn the Siamese network using samples to obtain the parameters of the Siamese network, and then use the trained Siamese network to accurately detect missing parts in component images. When training the Siamese network, it is necessary to use positive sample sets and negative sample sets in various scenarios for training, so that the Siamese network can fully learn the picture when the component is not a missing part, and the Siamese network can fully learn Only by seeing the pictures of missing components, can the missing parts detection be carried out correctly in the future.

可选地,在本发明的一些可能的实施方式中,所述负样本集合包括所述模板图像,以及元件不存在时的图像,或者元件存在,但焊接位置明显有误时候的情况,或者不是正确的元件的时候的图像等。Optionally, in some possible implementations of the present invention, the negative sample set includes the template image, and an image when the component does not exist, or when the component exists but the welding position is obviously wrong, or not Images etc. when the components are correct.

可以理解,取不同情景下的尽可能多的正样本集合以及负样本集合对Siamese网络进行训练,可使得Siamese网络的学习效果更好,从而后续漏件检测识别准确率高。It can be understood that taking as many positive sample sets and negative sample sets as possible in different scenarios to train the Siamese network can make the learning effect of the Siamese network better, so that the accuracy of subsequent missing parts detection and recognition is high.

可选地,在本发明的一些可能的实施方式中,所述元件图像的正样本集合和负样本集合包括训练样本和测试样本。Optionally, in some possible implementation manners of the present invention, the positive sample set and the negative sample set of the component image include training samples and testing samples.

其中,训练样本是指对Siamese网络进行训练,测试样本是指测试经过训练后的Siamese网络的效果,两者一起构成对Siamese网络的训练阶段的样本。Wherein, the training sample refers to training the Siamese network, and the test sample refers to testing the effect of the trained Siamese network, and the two together constitute a sample in the training phase of the Siamese network.

可选地,在本发明的一些可能的实施方式中,所述创建所述元件图像对正样本集合以及负样本集合,包括:Optionally, in some possible implementation manners of the present invention, the creating the component image alignment positive sample set and negative sample set includes:

采集印刷电路板图像;Capture printed circuit board images;

以印刷电路板模板图像为参考,在所述印刷电路板图像上截取元件图像;Taking the printed circuit board template image as a reference, intercepting the component image on the printed circuit board image;

采集所述元件图像对正样本集合以及负样本集合。The image of the component is collected to align a positive sample set and a negative sample set.

可选地,在本发明的些可能的实施方式中,在印刷电路板图标上截取元件图像后可对所述元件图像进行标注。Optionally, in some possible implementation manners of the present invention, the component image may be marked after the component image is captured on the printed circuit board icon.

可以理解,由于是需要对每个元件进行漏件检测,所以在对Siamese网络进行训练时,需要截取印刷电路板图像上面每个元件的图像的样本集合进行训练。并且,为了在训练的时候对各个元件图像进行区分,所以在训练之前需要对各个元件图像进行标注以区分不同元件。It can be understood that since it is necessary to detect missing parts for each component, when training the Siamese network, it is necessary to intercept a sample set of images of each component on the printed circuit board image for training. Moreover, in order to distinguish each component image during training, it is necessary to mark each component image to distinguish different components before training.

可选地,在本发明的一些可能的实施方式中,可以在生产线上架设摄像头,批量采集不同型号的PCB板卡图像,并以板卡跟踪技术避免重复拍摄某一PCB板卡。这样每个型号的PCB板卡均包含多个图像样本,每个图像样本对应某一型号的某张PCB板卡,从而这样在获取到的PCB板卡上的元件图像也来自不同板卡上,保证样本具备多样性。Optionally, in some possible implementations of the present invention, a camera can be set up on the production line to collect images of different types of PCB boards in batches, and use board tracking technology to avoid repeatedly photographing a certain PCB board. In this way, each type of PCB board contains multiple image samples, and each image sample corresponds to a certain type of PCB board, so that the obtained component images on the PCB board also come from different boards. Ensure sample diversity.

可选地,在本发明的一些可能的实施方式中,所述在所述印刷板电路上截取元件图像,包括:Optionally, in some possible implementation manners of the present invention, the intercepting component images on the printed circuit board includes:

利用印刷板图像上面的元件的位置信息自动截取元件图像。The component image is automatically captured using the position information of the component on the printed board image.

可以理解,当知道元件的位置信息后,则可以根据该位置信息自动截取元件图像。It can be understood that when the position information of the component is known, the component image can be automatically intercepted according to the position information.

可选地,在本发明的一些可能的实施方式中,所述获取元件图像的位置信息可以通过板式文件中所记录的元件的位置信息,或者通过人工标注的位置信息来获取。Optionally, in some possible implementations of the present invention, the position information of the obtained component image may be obtained through the component position information recorded in the template file, or through the manually marked position information.

可选地,在本发明的一些可能的实施方式中,所述对元件图像进行标注包括:Optionally, in some possible implementation manners of the present invention, the marking the component image includes:

根据元件类别信息进行标注。Label according to component category information.

可以理解,需要对元件的类别进行区分,从而在训练的时候记录元件的类别才能准确地对元件进行漏件检测。It can be understood that it is necessary to distinguish the types of components, so that the types of components can be recorded during training to accurately detect missing parts of components.

可选地,在本发明的另一些可能的实施方式中,也可以通过其它能对元件进行区分的方式对元件进行标注。Optionally, in some other possible implementation manners of the present invention, the components may also be marked in other ways that can distinguish the components.

可选地,在本发明的一些可能的实施方式中,所述采集所述元件图像对正样本集合以及负样本集合之前,所述方法还包括:Optionally, in some possible implementation manners of the present invention, before collecting the component image alignment positive sample set and negative sample set, the method further includes:

利用模板匹配得到所述元件图像中元件的位置并对所述元件图像进行对齐;Obtaining the position of the component in the component image by template matching and aligning the component image;

对所述元件图像进行归一化,以触发执行所述采集所述元件图像对正样本集合以及负样本集合的步骤。The component image is normalized to trigger the execution of the step of acquiring the positive sample set and the negative sample set of the component image pair.

可以理解,与对Siamese网络进行测试的过程类似,在采集Siamese网络的样本图像时对图像进行对齐以使元件位于图像的中心位置,并对图像进行归一化,该过程称为对图像的预处理过程,对图像进行预处理将会使Siamese网络训练效果更好。It can be understood that, similar to the process of testing the Siamese network, when the sample image of the Siamese network is collected, the image is aligned so that the component is located in the center of the image, and the image is normalized. This process is called image pre-processing. During the processing process, preprocessing the image will make the Siamese network training effect better.

可选地,在本发明的一些可能的实施方式中,如果对Siamese网络进行训练的时候对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时,也需要对元件图像进行预处理,如果对Siamese网络进行训练的时候不对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时也不对元件图像进行预处理。Optionally, in some possible implementations of the present invention, if the component image is preprocessed when the Siamese network is trained, then when the trained Siamese network is used to detect missing parts, the component image also needs to be preprocessed. Preprocessing, if the component image is not preprocessed when the Siamese network is trained, then the component image is not preprocessed when the trained Siamese network is used for missing parts detection.

可选地,在本发明的一些可能的实施方式中,所述根据所述相似度确定所述测试图像对应的元件是否存在,包括:Optionally, in some possible implementation manners of the present invention, the determining whether the element corresponding to the test image exists according to the similarity includes:

判断所述相似度是否在预设范围内;judging whether the similarity is within a preset range;

若所述相似度在预设范围内,则判定为所述元件存在;If the similarity is within a preset range, it is determined that the element exists;

若所述相似度不在预设范围内,则判定为所述元件不存在。If the similarity is not within the preset range, it is determined that the element does not exist.

可以理解,由于所述相似度是用于表征模板图像与测试图像的相似程度,所以当相似度在预设范围内时,说明模板图像与测试图像相似,那么元件图像则存在,也就是元件不漏件,否则,元件漏件。It can be understood that since the similarity is used to characterize the degree of similarity between the template image and the test image, when the similarity is within a preset range, it means that the template image is similar to the test image, then the component image exists, that is, the component does not Missing parts, otherwise, components missing parts.

可选地,在本发明的一些可能的实施方式中,当所述相似度大于或等于预设值时,则元件存在,也就是元件不漏件;当所述相似度小于预设值时,则元件不存在。Optionally, in some possible implementations of the present invention, when the similarity is greater than or equal to a preset value, the component exists, that is, there are no missing parts in the component; when the similarity is smaller than the preset value, then the element does not exist.

为了便于更好理解和实施本发明实施例的上述方案,下面结合一些具体的应用场景进行举例说明。In order to facilitate a better understanding and implementation of the above-mentioned solutions of the embodiments of the present invention, some specific application scenarios are used for illustration below.

请参见图2,图2是本发明第二实施例提供的一种检测方法的流程示意图,其中,如图2所示,本发明第二实施例提供的一种检测方法可以包括:Please refer to Fig. 2, Fig. 2 is a schematic flow chart of a detection method provided by the second embodiment of the present invention, wherein, as shown in Fig. 2, a detection method provided by the second embodiment of the present invention may include:

S201、采集印刷电路板图像。S201. Collect images of printed circuit boards.

可以理解,由于是需要利用Siamese网络进行漏件检测,所以首先需要采集样本图像。It can be understood that since it is necessary to use the Siamese network for missing parts detection, it is first necessary to collect sample images.

其中,Siamese网络是指一种深度神经网络,根据Siamese网络的特点,可计算出来元件各个层次的特征,包括低层特征和高层特征,从而根据图像的高层特征对图像进行分析时将得到更为精确的结果。为了对元件进行漏件检测,设计Siamese网络包含两个结构一样并共享参数的卷积神经网络,在利用Siamese网络进行漏件检测时,分别输入图像的模板图像和元件图像,从而可分别计算出来两个输入图像的特征向量,再计算两个特征向量的相似度,从而根据相似度的值判断是否为一类元件从而判断是否漏件。首先需要对Siamese网络进行训练,得到Siamese网络的参数,在训练的过程中利用各种情况下采集到的图像的样本,从而可以训练不同情况下图像漏件以及图像存在的情况。然后再根据训练后的Siamese网络对元件进行漏件检测,这两个卷积神经网络在训练阶段和测试阶段所输入的图像都不一样,在训练阶段时,其中一个输入模板图,另外一个输入元件图像,在测试阶段时,其中一个输入模板图,另外一个输入测试图像。并且,在训练阶段时,通过分别作前向计算得到两个图像的特征向量,再计算两个特征向量的欧氏距离得到相似度。Among them, the Siamese network refers to a deep neural network. According to the characteristics of the Siamese network, the features of each level of the component can be calculated, including low-level features and high-level features, so that it will be more accurate when analyzing the image according to the high-level features of the image. the result of. In order to detect missing parts for components, the Siamese network is designed to include two convolutional neural networks with the same structure and shared parameters. When using the Siamese network for missing parts detection, the template image and component image of the image are input respectively, so that they can be calculated separately. The eigenvectors of the two input images, and then calculate the similarity of the two eigenvectors, so as to judge whether it is a type of component according to the value of the similarity, so as to determine whether it is a missing part. Firstly, it is necessary to train the Siamese network to obtain the parameters of the Siamese network. During the training process, the samples of images collected in various situations are used to train the missing and existing images in different situations. Then, according to the trained Siamese network, the components are detected for missing parts. The images input by the two convolutional neural networks are different in the training phase and the testing phase. In the training phase, one of them inputs the template image, and the other inputs Component images, during the test phase, one of them is input as a template image, and the other is input as a test image. Moreover, in the training phase, the feature vectors of the two images are obtained by performing forward calculations respectively, and then the Euclidean distance of the two feature vectors is calculated to obtain the similarity.

其中,模板图为用于对照的标准的图片。该模板图可以为PCB模板图,从而与其对应输入的元件图像或测试图像也为PCB图像,该模板图也可以为从PCB图像上截取到的分别包含各个独立元件的图像,从而与其对应输入的图像也为包含各个独立元件的图像。Wherein, the template picture is a standard picture for comparison. The template image can be a PCB template image, so that the input component image or test image corresponding to it is also a PCB image, and the template image can also be an image intercepted from the PCB image that contains each independent component, so that the corresponding input image An image is also an image comprising individual elements.

可选地,在本发明的一些可能的实施方式中,由于是对每个元件进行漏件检测,所以一般在Siamese网络中输入的模板图像为包含一个独立元件的图像,那么在训练阶段输入的元件图像也为从PCB图像上截取到的该位置的元件图像,在测试阶段输入的图像也为不同情况下从PCB图像上截取到的该位置的元件图像。Optionally, in some possible implementations of the present invention, since the missing part detection is performed on each component, generally the template image input in the Siamese network is an image containing an independent component, then the input in the training phase The component image is also the component image of the position intercepted from the PCB image, and the image input in the test stage is also the component image of the position intercepted from the PCB image in different situations.

可以理解,首先需要采集PCB图像,才能截取元件图像样本。It can be understood that the PCB image needs to be collected first before the component image sample can be intercepted.

可选地,在本发明的一些可能的实施方式中,可以在生产线上架设摄像头,批量采集不同型号的PCB板卡图像,并以板卡跟踪技术避免重复拍摄某一PCB板卡。这样每个型号的PCB板卡均包含多个图像样本,每个图像样本对应某一型号的某张PCB板卡,从而这样在获取到的PCB板卡上的元件图像也来自不同板卡上,保证样本具备多样性。Optionally, in some possible implementations of the present invention, a camera can be set up on the production line to collect images of different types of PCB boards in batches, and use board tracking technology to avoid repeatedly photographing a certain PCB board. In this way, each type of PCB board contains multiple image samples, and each image sample corresponds to a certain type of PCB board, so that the obtained component images on the PCB board also come from different boards. Ensure sample diversity.

S202、以印刷电路板模板图像为参考,在印刷电路板图像上截取元件图像并对元件图像进行标注。S202. Using the printed circuit board template image as a reference, intercept the component image on the printed circuit board image and mark the component image.

可以理解,由于是需要对每个元件进行漏件检测,所以在对Siamese网络进行训练时,需要截取印刷电路板图像上面每个元件的图像的样本集合进行训练。并且,为了在训练的时候对各个元件图像进行区分,所以在训练之前需要对各个元件图像进行标注以区分不同元件。It can be understood that since it is necessary to detect missing parts for each component, when training the Siamese network, it is necessary to intercept a sample set of images of each component on the printed circuit board image for training. Moreover, in order to distinguish each component image during training, it is necessary to mark each component image to distinguish different components before training.

可选地,在本发明的一些可能的实施方式中,所述在所述印刷板电路上截取元件图像,包括:Optionally, in some possible implementation manners of the present invention, the intercepting component images on the printed circuit board includes:

利用印刷板图像上面的元件的位置信息自动截取元件图像。The component image is automatically captured using the position information of the component on the printed board image.

可以理解,当知道元件的位置信息后,则可以根据该位置信息自动截取元件图像。It can be understood that when the position information of the component is known, the component image can be automatically intercepted according to the position information.

可选地,在本发明的一些可能的实施方式中,所述获取元件图像的位置信息可以通过板式文件中所记录的元件的位置信息,或者通过人工标注的位置信息来获取。Optionally, in some possible implementations of the present invention, the position information of the obtained component image may be obtained through the component position information recorded in the template file, or through the manually marked position information.

可选地,在本发明的一些可能的实施方式中,所述对元件图像进行标注包括:Optionally, in some possible implementation manners of the present invention, the marking the component image includes:

根据元件类别信息进行标注。Label according to component category information.

可以理解,需要对元件的类别进行区分,从而在训练的时候记录元件的类别才能准确地对元件进行漏件检测。It can be understood that it is necessary to distinguish the types of components, so that the types of components can be recorded during training to accurately detect missing parts of components.

可选地,在本发明的另一些可能的实施方式中,也可以通过其它能对元件进行区分的方式对元件进行标注。Optionally, in some other possible implementation manners of the present invention, the components may also be marked in other ways that can distinguish the components.

S203、采集元件图像对正样本集合以及负样本集合。S203. Align the positive sample set and the negative sample set with the image of the acquisition component.

其中,所述正样本集合包括所述模板图像与所述元件存在时的所述元件图像构成的元件图像对,所述负样本集合包括所述模板图像与所述元件不存在时的所述元件图像构成的元件图像对,所述负样本集合还包括所述模板图像与其它元件存在时的元件图像构成的元件图像对。Wherein, the positive sample set includes the component image pair formed by the template image and the component image when the component exists, and the negative sample set includes the template image and the component when the component does not exist The component image pair formed by the image, the negative sample set also includes the component image pair formed by the template image and component images when other components exist.

需要说明,可选地,在本发明的一些可能的实施方式中,当模板图像与测试图像为PCB图像时,则样本集合中的正样本集合包括模板图像与模板图像上各元件位置上均包含的是正确的元件时的元件图像构成的元件图像对,负样本集合包括模板图像与各元件位置上可能不存在元件时的元件图像构成的元件图像对,负样本集合还包括模板图像与各元件位置上的元件均存在、但是可能插入了错误的元件时的元件图像构成的元件图像对。It should be noted that, optionally, in some possible implementations of the present invention, when the template image and the test image are PCB images, the positive sample set in the sample set includes the template image and the position of each component on the template image. The component image pair composed of the component image when the component is correct, the negative sample set includes the component image pair composed of the template image and the component image when there may be no component in each component position, the negative sample set also includes the template image and each component A component image pair composed of component images when all components exist at the position, but a wrong component may be inserted.

可选地,在本发明的另一些可能的实施方式中,当模板图像与测试图像均为从PCB图像上截取到的分别包含各个独立元件的图像,从而样本集合中的正样本集合包括模板图像与包含该模板图像中的元件的图像构成的元件图像对,负样本集合包括模板图像与不包含元件的图像构成的元件图像对,负样本集合还包括模板图像与包含了不是模板图像中的元件、但是包含了其它的错误元件的元件图像构成的元件图像对。Optionally, in other possible implementations of the present invention, when both the template image and the test image are images containing individual components that are intercepted from the PCB image, the positive sample set in the sample set includes the template image The component image pair composed of the image containing the component in the template image, the negative sample set includes the component image pair composed of the template image and the image that does not contain the component, and the negative sample set also includes the template image and the component that is not in the template image , but contains component images of other wrong components.

可选地,在本发明的一些可能的实施方式中,所述正样本集合包括所述模板图像,以及元件存在并且在各个场景下拍摄的样本,如在光线不好的情况下拍摄的正样本图像,以及从不同的位置或角度拍摄的正样本图像,或者其它复杂场景下拍摄的正样本图像,利用各个场景下拍摄的正样本图像对Siamese网络进行训练,从而使Siamese网络具有更强的识别能力,能够在后续测试阶段对不同场景下拍摄的非漏件的元件图像进行正确的检测,提高识别率。Optionally, in some possible implementation manners of the present invention, the set of positive samples includes the template image, and samples in which components exist and are taken in various scenes, such as positive samples taken in bad light images, and positive sample images taken from different positions or angles, or positive sample images taken in other complex scenes, the Siamese network is trained using the positive sample images taken in each scene, so that the Siamese network has a stronger recognition Ability to correctly detect non-missing component images taken in different scenarios in the subsequent test stage, and improve the recognition rate.

可以理解,在利用Siamese网络对图像进行漏件检测时,首先需要对Siamese网络利用样本进行训练学习,得到Siamese网络的参数,从而再利用训练后的Siamese网络对元件图像准确地进行漏件检测。而在对Siamese网络进行训练时,需要分别利用各种场景下的正样本集合以及负样本集合进行训练,这样才能使Siamese网络充分学习到元件不是漏件时的图片情况,以及使Siamese网络充分学习到元件漏件时的图片情况,后续才能正确地进行漏件检测。It can be understood that when using the Siamese network to detect missing parts in images, it is first necessary to train and learn the Siamese network using samples to obtain the parameters of the Siamese network, and then use the trained Siamese network to accurately detect missing parts in component images. When training the Siamese network, it is necessary to use positive sample sets and negative sample sets in various scenarios for training, so that the Siamese network can fully learn the picture when the component is not a missing part, and the Siamese network can fully learn Only by seeing the pictures of missing components can the subsequent detection of missing parts be carried out correctly.

可选地,在本发明的一些可能的实施方式中,所述负样本集合包括所述模板图像,以及元件不存在时的图像,或者元件存在,但焊接位置明显有误时候的情况,或者不是正确的元件的时候的图像等。Optionally, in some possible implementations of the present invention, the negative sample set includes the template image, and an image when the component does not exist, or when the component exists but the welding position is obviously wrong, or not Images etc. when the components are correct.

可以理解,取不同情景下的尽可能多的正样本集合以及负样本集合对Siamese网络进行训练,可使得Siamese网络的学习效果更好,从而后续漏件检测识别准确率高。It can be understood that taking as many positive sample sets and negative sample sets as possible in different scenarios to train the Siamese network can make the learning effect of the Siamese network better, so that the accuracy of subsequent missing parts detection and recognition is high.

可选地,在本发明的一些可能的实施方式中,所述元件图像的正样本集合和负样本集合包括训练样本和测试样本。Optionally, in some possible implementation manners of the present invention, the positive sample set and the negative sample set of the component image include training samples and test samples.

其中,训练样本是指对Siamese网络进行训练,测试样本是指测试经过训练后的Siamese网络的效果,两者一起构成对Siamese网络的训练阶段的样本。Wherein, the training sample refers to training the Siamese network, and the test sample refers to testing the effect of the trained Siamese network, and the two together constitute a sample in the training phase of the Siamese network.

可选地,在本发明的一些可能的实施方式中,所述采集所述元件图像对正样本集合以及负样本集合之前,所述方法还包括:Optionally, in some possible implementation manners of the present invention, before collecting the component image alignment positive sample set and negative sample set, the method further includes:

利用模板匹配得到所述元件图像中元件的位置并对所述元件图像进行对齐;Obtaining the position of the component in the component image by template matching and aligning the component image;

对所述元件图像进行归一化。The component image is normalized.

可以理解,由于元件图像是从模板图像上截取下来的一块图像,为了使检测结果更为准确,需要使截取到的元件图像中的元件位于图像的中心位置,并同时对图像的大小进行归一化,这样以保证后续处理的准确性。该过程称为预处理过程。It can be understood that since the component image is an image intercepted from the template image, in order to make the detection result more accurate, it is necessary to locate the component in the intercepted component image at the center of the image, and at the same time normalize the size of the image to ensure the accuracy of subsequent processing. This process is called preprocessing.

可选地,在本发明的一些可能的实施方式中,也可以不对图像进行预处理。Optionally, in some possible implementation manners of the present invention, the image may not be preprocessed.

S204、利用正样本集合以及负样本集合训练Siamese网络。S204, using the positive sample set and the negative sample set to train the Siamese network.

可以理解,需要利用正样本集合以及负样本集合对Siamese网络进行训练,从而使Siamese网络具有漏件检测能力。It can be understood that the Siamese network needs to be trained with positive sample sets and negative sample sets, so that the Siamese network has the ability to detect missing parts.

S205、将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到模板图像与测试图像的特征向量。S205 , input the template image and the test image into the trained Siamese network, and perform forward calculation respectively to obtain feature vectors of the template image and the test image.

S206、计算模块图像与测试图像的特征向量的相似度。S206. Calculate the similarity between the feature vectors of the module image and the test image.

其中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像Wherein, the template image is the corresponding component image when the component exists and is in the standard position, and the test image is the component image that needs to be tested

其中,所述相似度为对Siamese网络输入的模板图像与测试图像的特征的相似情况的度量,相似度是利用Siamese网络学习到的模板图像与测试图像高级特征来判断模板图像与测试图像是否相似的程度的值。Wherein, the similarity is a measure of the similarity between the template image input by the Siamese network and the characteristics of the test image, and the similarity is to use the advanced features of the template image and the test image learned by the Siamese network to judge whether the template image and the test image are similar value of degree.

可选地,在本发明的一些可能的实施方式中,所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络之前,所述方法还包括:Optionally, in some possible implementation manners of the present invention, before inputting the template image and the test image into the trained Siamese network, the method further includes:

利用模板匹配得到所述模板图像与所述测试图像中元件的位置并对所述模板图像与所述测试图像进行对齐;Obtaining the position of the template image and the element in the test image by template matching and aligning the template image and the test image;

对所述模板图像与所述测试图像进行归一化。The template image and the test image are normalized.

可以理解,由于元件图像是从模板图像上截取下来的一块图像,为了使检测结果更为准确,需要使截取到的元件图像中的元件位于图像的中心位置,并同时对图像的大小进行归一化,这样以保证后续处理的准确性。该过程称为预处理过程。It can be understood that since the component image is an image intercepted from the template image, in order to make the detection result more accurate, it is necessary to locate the component in the intercepted component image at the center of the image, and at the same time normalize the size of the image to ensure the accuracy of subsequent processing. This process is called preprocessing.

可选地,在本发明的一些可能的实施方式中,也可以不对图像进行预处理。Optionally, in some possible implementation manners of the present invention, the image may not be preprocessed.

可选地,在本发明的一些可能的实施方式中,如果对Siamese网络进行训练的时候对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时,也需要对元件图像进行预处理,如果对Siamese网络进行训练的时候不对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时也不对元件图像进行预处理。Optionally, in some possible implementations of the present invention, if the component image is preprocessed when the Siamese network is trained, then when the trained Siamese network is used to detect missing parts, the component image also needs to be preprocessed. Preprocessing, if the component image is not preprocessed when the Siamese network is trained, then the component image is not preprocessed when the trained Siamese network is used for missing parts detection.

S207、根据相似度确定测试图像对应的元件是否存在。S207. Determine whether the component corresponding to the test image exists according to the similarity.

可以理解,由于相似度是利用Siamese网络学习到的模板图像与测试图像高级特征来判断模板图像与测试图像是否相似的程度的值,从而可以用相似度来确定元件是否模板图像与测试图像是否相似,也即确定所述测试图像对应的元件是否存在,即判断元件是否漏件。It can be understood that since the similarity is the value of the degree of similarity between the template image and the test image by using the advanced features of the template image and the test image learned by the Siamese network, the similarity can be used to determine whether the component is similar to the template image and the test image , that is, to determine whether the component corresponding to the test image exists, that is, to determine whether the component is missing.

可选地,在本发明的一些可能的实施方式中,所述根据所述相似度确定所述测试图像对应的元件是否存在,包括:Optionally, in some possible implementation manners of the present invention, the determining whether the element corresponding to the test image exists according to the similarity includes:

判断所述相似度是否在预设范围内;judging whether the similarity is within a preset range;

若所述相似度在预设范围内,则所述元件存在;If the similarity is within a preset range, the element exists;

若所述相似度不在预设范围内,则所述元件不存在。If the similarity is not within the preset range, the element does not exist.

可以理解,由于所述相似度是用于表征模板图像与测试图像的相似程度,所以当相似度在预设范围内时,说明模板图像与测试图像相似,那么元件图像则存在,也就是元件不漏件,否则,元件漏件。It can be understood that since the similarity is used to characterize the degree of similarity between the template image and the test image, when the similarity is within a preset range, it means that the template image is similar to the test image, then the component image exists, that is, the component does not Missing parts, otherwise, components missing parts.

可选地,在本发明的一些可能的实施方式中,当所述相似度大于或等于预设值时,则元件存在,也就是元件不漏件;当所述相似度小于预设值时,则元件不存在。Optionally, in some possible implementations of the present invention, when the similarity is greater than or equal to a preset value, the component exists, that is, there are no missing parts in the component; when the similarity is smaller than the preset value, then the element does not exist.

可以看出,本实施例的方案中,将所述模板图像与所述测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量,最后计算两个特征向量的相似度,其中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像;根据所述相似度确定所述测试图像对应的元件是否存在。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断元件图像是否漏件,识别准确率高。It can be seen that in the solution of this embodiment, the template image and the test image are input into the trained Siamese network, and forward calculations are performed respectively to obtain the feature vectors of the template image and the test image, and finally Calculating the similarity of two feature vectors, wherein the template image is the corresponding component image when the component exists and is in a standard position, and the test image is the component image that needs to be tested; determine the test image according to the similarity Whether the corresponding element exists. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately determine whether the component image is missing, and the recognition accuracy is high.

本发明实施例还提供一种元件检测装置,该装置包括:The embodiment of the present invention also provides a component detection device, which includes:

图像输入模块,用于将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量,其中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像;The image input module is used to input the template image and the test image into the trained Siamese network, and perform forward calculations respectively to obtain the feature vectors of the template image and the test image, wherein the template image is that the element exists and The corresponding component image at the standard position, the test image is the component image that needs to be tested;

计算模块,用于计算所述模块图像与所述测试图像的特征向量的相似度;Calculation module, for calculating the similarity between the feature vector of the module image and the test image;

确定模块,用于根据所述相似度确定所述测试图像对应的元件是否存在。A determining module, configured to determine whether the element corresponding to the test image exists according to the similarity.

具体的,请参见图3,图3是本发明第三实施例提供的一种检测装置的结构示意图,其中,如图3所示,本发明第三实施例提供的一种检测装置300可以包括:Specifically, please refer to FIG. 3 . FIG. 3 is a schematic structural diagram of a detection device provided by a third embodiment of the present invention, wherein, as shown in FIG. 3 , a detection device 300 provided by a third embodiment of the present invention may include :

图像输入模块310、计算模块320和确定模块330。An image input module 310 , a calculation module 320 and a determination module 330 .

其中,图像输入模块310,用于将所述模板图像与所述测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量。Wherein, the image input module 310 is configured to input the template image and the test image into the trained Siamese network, and perform forward calculation to obtain feature vectors of the template image and the test image respectively.

其中,参见图1-a,Siamese网络是一种深度神经网络,根据Siamese网络的特点,可计算出来图像各个层次的特征,包括低层特征和高层特征,从而根据图像的高层特征对图像进行分析时将得到更为精确的结果。为了进行图像匹配,设计Siamese网络包含两个结构一样并共享参数的卷积神经网络,在利用Siamese网络进行图像匹配时,分别输入图像的模板图像和测试图像,从而可分别计算出来两个输入图像的特征向量,再计算两个特征向量的相似度,从而根据相似度的值判断两幅图像的相似程度即判断两幅图像是否匹配。Among them, see Figure 1-a, the Siamese network is a deep neural network. According to the characteristics of the Siamese network, the features of each level of the image can be calculated, including low-level features and high-level features, so that the image can be analyzed according to the high-level features of the image. will get more accurate results. In order to perform image matching, the Siamese network is designed to include two convolutional neural networks with the same structure and shared parameters. When using the Siamese network for image matching, the template image and the test image of the image are input respectively, so that two input images can be calculated separately. The eigenvectors, and then calculate the similarity of the two eigenvectors, so as to judge the similarity of the two images according to the value of the similarity, that is, to judge whether the two images match.

其中,经过训练后的Siamese网络由于经过大量的样本图像的训练学习,具有了准确地对模板图像与测试图像进行图像匹配的能力。Among them, the trained Siamese network has the ability to accurately match the template image and the test image due to the training and learning of a large number of sample images.

其中,模板图像是用于对照的标准的图片,测试图像是通过与模板图像进行对照从而判断与模板图像是否匹配。Wherein, the template image is a standard picture for comparison, and the test image is compared with the template image to determine whether it matches the template image.

计算模块320,用于计算所述模板图像与所述测试图像的特征向量的相似度。Calculation module 320, configured to calculate the similarity between the feature vectors of the template image and the test image.

其中,相似度是用于判断模板图像与测试图像相似程序的参数。Wherein, the similarity is a parameter for judging the similarity between the template image and the test image.

可选地,在本发明的一些可能的实施方式中,可在计算模块图像与测试图像的特征向量后,再计算特征向量的欧氏距离得到模板图像与测试图像的特征向量的相似度。Optionally, in some possible implementations of the present invention, after calculating the feature vectors of the module image and the test image, the Euclidean distance of the feature vectors can be calculated to obtain the similarity between the feature vectors of the template image and the test image.

确定模块330,用于根据所述相似度确定所述测试图像与所述模板图像是否匹配。A determining module 330, configured to determine whether the test image matches the template image according to the similarity.

其中,由于相似度是对Siamese网络输入的两个图像的特征的相似情况的度量,所以可通过相似度来判断模板图像与测试图像是否相似,也即判断模板图像与测试图像是否匹配。可以理解的是,本实施例的检测装置300的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。Among them, since the similarity is a measure of the similarity of the features of the two images input by the Siamese network, it can be used to judge whether the template image is similar to the test image, that is, to judge whether the template image matches the test image. It can be understood that the functions of each functional module of the detection device 300 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

可以看出,本实施例的方案中,检测装置300将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;检测装置300计算所述模板图像与所述测试图像的特征向量的相似度;检测装置300根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。It can be seen that in the solution of this embodiment, the detection device 300 inputs the template image and the test image into the trained Siamese network, and performs forward calculations respectively to obtain the feature vectors of the template image and the test image; the detection device 300 calculates the similarity between the feature vectors of the template image and the test image; the detecting device 300 determines whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately judge whether the template image matches the test image, and the judgment accuracy is high.

请参见图4,图4是本发明第四实施例提供的一种检测装置的结构示意图,其中,如图4所示,本发明第四实施例提供的一种检测装置400可以包括:Please refer to FIG. 4. FIG. 4 is a schematic structural diagram of a detection device provided by a fourth embodiment of the present invention, wherein, as shown in FIG. 4, a detection device 400 provided by the fourth embodiment of the present invention may include:

图像输入模块410、计算模块420和确定模块430。An image input module 410 , a calculation module 420 and a determination module 430 .

其中,图像输入模块410,用于将所述模板图像与所述测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量。Wherein, the image input module 410 is configured to input the template image and the test image into the trained Siamese network, and perform forward calculation to obtain feature vectors of the template image and the test image respectively.

其中,参见图1-a,Siamese网络是一种深度神经网络,根据Siamese网络的特点,可计算出来图像各个层次的特征,包括低层特征和高层特征,从而根据图像的高层特征对图像进行分析时将得到更为精确的结果。为了进行图像匹配,设计Siamese网络包含两个结构一样并共享参数的卷积神经网络,在利用Siamese网络进行图像匹配时,分别输入图像的模板图像和测试图像,从而可分别计算出来两个输入图像的特征向量,再计算两个特征向量的相似度,从而根据相似度的值判断两幅图像的相似程度即判断两幅图像是否匹配。Among them, see Figure 1-a, the Siamese network is a deep neural network. According to the characteristics of the Siamese network, the features of each level of the image can be calculated, including low-level features and high-level features, so that the image can be analyzed according to the high-level features of the image. will get more accurate results. In order to perform image matching, the Siamese network is designed to include two convolutional neural networks with the same structure and shared parameters. When using the Siamese network for image matching, the template image and the test image of the image are input respectively, so that two input images can be calculated separately. The eigenvectors, and then calculate the similarity of the two eigenvectors, so as to judge the similarity of the two images according to the value of the similarity, that is, to judge whether the two images match.

其中,经过训练后的Siamese网络由于经过大量的样本图像的训练学习,具有了准确地对模板图像与测试图像进行图像匹配的能力。Among them, the trained Siamese network has the ability to accurately match the template image and the test image due to the training and learning of a large number of sample images.

其中,模板图像是用于对照的标准的图片,测试图像是通过与模板图像进行对照从而判断与模板图像是否匹配。Wherein, the template image is a standard picture for comparison, and the test image is compared with the template image to determine whether it matches the template image.

计算模块420,用于计算所述模板图像与所述测试图像的特征向量的相似度。Calculation module 420, configured to calculate the similarity between the feature vectors of the template image and the test image.

其中,相似度是用于判断模板图像与测试图像相似程序的参数。Wherein, the similarity is a parameter for judging the similarity between the template image and the test image.

可选地,在本发明的一些可能的实施方式中,可在计算模块图像与测试图像的特征向量后,再计算特征向量的欧氏距离得到模板图像与测试图像的特征向量的相似度。Optionally, in some possible implementations of the present invention, after calculating the feature vectors of the module image and the test image, the Euclidean distance of the feature vectors can be calculated to obtain the similarity between the feature vectors of the template image and the test image.

确定模块430,用于根据所述相似度确定所述测试图像与所述模板图像是否匹配。A determining module 430, configured to determine whether the test image matches the template image according to the similarity.

其中,由于相似度是对Siamese网络输入的两个图像的特征的相似情况的度量,所以可通过相似度来判断模板图像与测试图像是否相似,也即判断模板图像与测试图像是否匹配。Among them, since the similarity is a measure of the similarity of the features of the two images input by the Siamese network, it can be used to judge whether the template image is similar to the test image, that is, to judge whether the template image matches the test image.

可选地,在本发明的一些可能的实施方式中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像,所述确定模块430具体用于:Optionally, in some possible implementations of the present invention, the template image is the corresponding component image when the component exists and is in a standard position, the test image is the component image that needs to be tested, and the determination module 430 specifically Used for:

根据所述相似度确定所述测试图像对应的元件是否存在。Determine whether the component corresponding to the test image exists according to the similarity.

其中,该模板图像可以为PCB模板图,从而与其对应输入的元件图像或测试图像也为PCB图像,该模板图也可以为从PCB图像上截取到的分别包含各个独立元件的图像,从而与其对应输入的测试图像也为包含各个独立元件的图像。Wherein, the template image can be a PCB template image, so that the input component image or test image corresponding to it is also a PCB image, and the template image can also be an image containing each independent component intercepted from the PCB image, so as to correspond to it The input test image is also an image containing individual components.

可选地,在本发明的一些可能的实施方式中,由于是对每个元件进行漏件检测,所以一般在Siamese网络中输入的模板图像为包含一个独立元件的图像,那么在训练阶段输入的元件图像也为从PCB图像上截取到的该位置的元件图像,在测试阶段输入的图像也为不同情况下从PCB图像上截取到的该位置的元件图像。Optionally, in some possible implementations of the present invention, since the missing part detection is performed on each component, generally the template image input in the Siamese network is an image containing an independent component, then the input in the training phase The component image is also the component image of the position intercepted from the PCB image, and the image input in the test stage is also the component image of the position intercepted from the PCB image in different situations.

可选地,在本发明的一些可能的实施方式中,当模板图像为元件的模板图像时,可以理解,模板图像为元件存在并且元件的位置处于一个正确位置的元件图像,测试图像则根据模板图像判断是否漏件。Optionally, in some possible implementations of the present invention, when the template image is a template image of a component, it can be understood that the template image is a component image in which the component exists and the position of the component is in a correct position, and the test image is based on the template The image judges whether there is a missing part.

可以理解,由于Siamese网络可以判断测试图像与模板图像是否匹配,所以当模板图像与测试图像为元件图像时,可以根据相似度确定元件图像的测试图像是否与模板图像是否匹配,也即确定测试图像对应的元件是否存在。It can be understood that since the Siamese network can judge whether the test image matches the template image, when the template image and the test image are component images, it can be determined according to the similarity whether the test image of the component image matches the template image, that is, determine the test image Whether the corresponding element exists.

可选地,在本发明的一些可能的实施方式中,所述元件检测装置400还包括:Optionally, in some possible implementation manners of the present invention, the component detection device 400 further includes:

预处理模块440,用于利用模板匹配得到所述模板图像与所述测试图像中元件的位置并对所述模板图像与所述测试图像进行对齐;A preprocessing module 440, configured to use template matching to obtain the positions of elements in the template image and the test image and align the template image and the test image;

对所述模板图像与所述测试图像进行归一化,以触发所述图像输入模块执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。The template image and the test image are normalized to trigger the image input module to execute the step of inputting the template image and the test image into the trained Siamese network.

可以理解,由于元件图像是从模板图像上截取下来的一块图像,为了使检测结果更为准确,需要使截取到的元件图像中的元件位于图像的中心位置,并同时对图像的大小进行归一化,这样以保证后续处理的准确性。该过程称为预处理过程。It can be understood that since the component image is an image intercepted from the template image, in order to make the detection result more accurate, it is necessary to locate the component in the intercepted component image at the center of the image, and at the same time normalize the size of the image to ensure the accuracy of subsequent processing. This process is called preprocessing.

可选地,在本发明的一些可能的实施方式中,也可以不对图像进行预处理。Optionally, in some possible implementation manners of the present invention, the image may not be preprocessed.

可选地,在本发明的一些可能的实施方式中,所述元件检测装置400还包括:Optionally, in some possible implementation manners of the present invention, the component detection device 400 further includes:

样本创建模块450,用于创建所述元件图像对正样本集合以及负样本集合,其中,所述正样本集合包括所述模板图像与所述元件存在时的所述元件图像构成的元件图像对,所述负样本集合包括所述模板图像与所述元件不存在时的所述元件图像构成的元件图像对,所述负样本集合还包括所述模板图像与其它元件存在时的元件图像构成的元件图像对;A sample creation module 450, configured to create a positive sample set and a negative sample set for the component image alignment, wherein the positive sample set includes a component image pair composed of the template image and the component image when the component exists, The negative sample set includes a component image pair formed by the template image and the component image when the component does not exist, and the negative sample set also includes components formed by the template image and component images when other components exist image pair;

训练模块460,用于利用所述正样本集合以及所述负样本集合训练所述Siamese网络,以触发所述图像输入模块执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。A training module 460, configured to use the positive sample set and the negative sample set to train the Siamese network, so as to trigger the image input module to execute the step of inputting the template image and the test image into the trained Siamese network. Network steps.

需要说明,可选地,在本发明的一些可能的实施方式中,当模板图像与测试图像为PCB图像时,则样本集合中的正样本集合包括模板图像与模板图像上各元件位置上均包含的是正确的元件时的元件图像构成的元件图像对,负样本集合包括模板图像与各元件位置上可能不存在元件时的元件图像构成的元件图像对,负样本集合还包括模板图像与各元件位置上的元件均存在、但是可能插入了错误的元件时的元件图像构成的元件图像对。It should be noted that, optionally, in some possible implementations of the present invention, when the template image and the test image are PCB images, the positive sample set in the sample set includes the template image and the position of each component on the template image. The component image pair composed of the component image when the component is correct, the negative sample set includes the component image pair composed of the template image and the component image when there may be no component in each component position, the negative sample set also includes the template image and each component A component image pair composed of component images when all components exist at the position, but a wrong component may be inserted.

可选地,在本发明的另一些可能的实施方式中,当模板图像与测试图像均为从PCB图像上截取到的分别包含各个独立元件的图像,从而样本集合中的正样本集合包括模板图像与包含该模板图像中的元件的图像构成的元件图像对,负样本集合包括模板图像与不包含元件的图像构成的元件图像对,负样本集合还包括模板图像与包含了不是模板图像中的元件、但是包含了其它的错误元件的元件图像构成的元件图像对。Optionally, in other possible implementations of the present invention, when both the template image and the test image are images containing individual components that are intercepted from the PCB image, the positive sample set in the sample set includes the template image The component image pair composed of the image containing the component in the template image, the negative sample set includes the component image pair composed of the template image and the image that does not contain the component, and the negative sample set also includes the template image and the component that is not in the template image , but contains component images of other wrong components.

可选地,在本发明的一些可能的实施方式中,所述正样本集合包括所述模板图像,以及元件存在并且在各个场景下拍摄的样本,如在光线不好的情况下拍摄的正样本图像,以及从不同的位置或角度拍摄的正样本图像,或者其它复杂场景下拍摄的正样本图像,利用各个场景下拍摄的正样本图像对Siamese网络进行训练,从而使Siamese网络具有更强的识别能力,能够在后续测试阶段对不同场景下拍摄的非漏件的元件图像进行正确的检测,提高识别率。Optionally, in some possible implementation manners of the present invention, the set of positive samples includes the template image, and samples in which components exist and are taken in various scenes, such as positive samples taken in bad light images, and positive sample images taken from different positions or angles, or positive sample images taken in other complex scenes, the Siamese network is trained using the positive sample images taken in each scene, so that the Siamese network has a stronger recognition Ability to correctly detect non-missing component images taken in different scenarios in the subsequent test stage, and improve the recognition rate.

可以理解,在利用Siamese网络对图像进行漏件检测时,首先需要对Siamese网络利用样本进行训练学习,得到Siamese网络的参数,从而再利用训练后的Siamese网络对元件图像准确地进行漏件检测。而在对Siamese网络进行训练时,需要分别利用各种场景下的正样本集合以及负样本集合进行训练,这样才能使Siamese网络充分学习到元件不是漏件时的图片情况,以及使Siamese网络充分学习到元件漏件时的图片情况,后续才能正确地进行漏件检测。It can be understood that when using the Siamese network to detect missing parts in images, it is first necessary to train and learn the Siamese network using samples to obtain the parameters of the Siamese network, and then use the trained Siamese network to accurately detect missing parts in component images. When training the Siamese network, it is necessary to use positive sample sets and negative sample sets in various scenarios for training, so that the Siamese network can fully learn the picture when the component is not a missing part, and the Siamese network can fully learn Only by seeing the pictures of missing components, can the missing parts detection be carried out correctly in the future.

可选地,在本发明的一些可能的实施方式中,所述负样本集合包括所述模板图像,以及元件不存在时的图像,或者元件存在,但焊接位置明显有误时候的情况,或者不是正确的元件的时候的图像等。Optionally, in some possible implementations of the present invention, the negative sample set includes the template image, and an image when the component does not exist, or when the component exists but the welding position is obviously wrong, or not Images etc. when the components are correct.

可以理解,取不同情景下的尽可能多的正样本集合以及负样本集合对Siamese网络进行训练,可使得Siamese网络的学习效果更好,从而后续漏件检测识别准确率高。It can be understood that taking as many positive sample sets and negative sample sets as possible in different scenarios to train the Siamese network can make the learning effect of the Siamese network better, so that the accuracy of subsequent missing parts detection and recognition is high.

可选地,在本发明的一些可能的实施方式中,所述元件图像的正样本集合和负样本集合包括训练样本和测试样本。Optionally, in some possible implementation manners of the present invention, the positive sample set and the negative sample set of the component image include training samples and testing samples.

其中,训练样本是指对Siamese网络进行训练,测试样本是指测试经过训练后的Siamese网络的效果,两者一起构成对Siamese网络的训练阶段的样本。Wherein, the training sample refers to training the Siamese network, and the test sample refers to testing the effect of the trained Siamese network, and the two together constitute a sample in the training phase of the Siamese network.

可选地,在本发明的一些可能的实施方式中,所述样本创建模块450包括:Optionally, in some possible implementations of the present invention, the sample creation module 450 includes:

图像采集单元451,采集印刷电路板图像;An image acquisition unit 451, which acquires an image of a printed circuit board;

截取单元452,用于以印刷电路板模板图像为参考,在所述印刷电路板图像上截取元件图像;The intercepting unit 452 is configured to use the printed circuit board template image as a reference to intercept the component image on the printed circuit board image;

样本采集单元453,用于采集所述元件图像对正样本集合以及负样本集合。The sample collection unit 453 is configured to collect the component image alignment positive sample set and negative sample set.

可选地,在本发明的些可能的实施方式中,在印刷电路板图标上截取元件图像后可对所述元件图像进行标注。Optionally, in some possible implementation manners of the present invention, the component image may be marked after the component image is captured on the printed circuit board icon.

可以理解,由于是需要对每个元件进行漏件检测,所以在对Siamese网络进行训练时,需要截取印刷电路板图像上面每个元件的图像的样本集合进行训练。并且,为了在训练的时候对各个元件图像进行区分,所以在训练之前需要对各个元件图像进行标注以区分不同元件。It can be understood that since it is necessary to detect missing parts for each component, when training the Siamese network, it is necessary to intercept a sample set of images of each component on the printed circuit board image for training. Moreover, in order to distinguish each component image during training, it is necessary to mark each component image to distinguish different components before training.

可选地,在本发明的一些可能的实施方式中,可以在生产线上架设摄像头,批量采集不同型号的PCB板卡图像,并以板卡跟踪技术避免重复拍摄某一PCB板卡。这样每个型号的PCB板卡均包含多个图像样本,每个图像样本对应某一型号的某张PCB板卡,从而这样在获取到的PCB板卡上的元件图像也来自不同板卡上,保证样本具备多样性。Optionally, in some possible implementations of the present invention, a camera can be set up on the production line to collect images of different types of PCB boards in batches, and use board tracking technology to avoid repeatedly photographing a certain PCB board. In this way, each type of PCB board contains multiple image samples, and each image sample corresponds to a certain type of PCB board, so that the obtained component images on the PCB board also come from different boards. Ensure sample diversity.

可选地,在本发明的一些可能的实施方式中,所述截取单元452在所述印刷板电路上截取元件图像具体为:Optionally, in some possible implementation manners of the present invention, the intercepting unit 452 intercepts the component image on the printed circuit board specifically as follows:

利用印刷板图像上面的元件的位置信息自动截取元件图像。The component image is automatically captured using the position information of the component on the printed board image.

可以理解,当知道元件的位置信息后,则可以根据该位置信息自动截取元件图像。It can be understood that when the position information of the component is known, the component image can be automatically intercepted according to the position information.

可选地,在本发明的一些可能的实施方式中,所述获取元件图像的位置信息可以通过板式文件中所记录的元件的位置信息,或者通过人工标注的位置信息来获取。Optionally, in some possible implementations of the present invention, the position information of the obtained component image may be obtained through the component position information recorded in the template file, or through the manually marked position information.

可选地,在本发明的一些可能的实施方式中,所述截取单元452对元件图像进行标注具体为:Optionally, in some possible implementation manners of the present invention, the intercepting unit 452 marks the component image specifically as follows:

根据元件类别信息进行标注。Label according to component category information.

可以理解,需要对元件的类别进行区分,从而在训练的时候记录元件的类别才能准确地对元件进行漏件检测。It can be understood that it is necessary to distinguish the types of components, so that the types of components can be recorded during training to accurately detect missing parts of components.

可选地,在本发明的另一些可能的实施方式中,也可以通过其它能对元件进行区分的方式对元件进行标注。Optionally, in some other possible implementation manners of the present invention, the components may also be marked in other ways that can distinguish the components.

可选地,在本发明的一些可能的实施方式中,所述样本创建模块450还包括:Optionally, in some possible implementations of the present invention, the sample creation module 450 also includes:

预处理单元454,用于利用模板匹配得到所述元件图像中元件的位置并对所述元件图像进行对齐;A preprocessing unit 454, configured to use template matching to obtain the position of the component in the component image and align the component image;

对所述元件图像进行归一化,以触发所述样本采集单元执行所述采集所述元件图像对正样本集合以及负样本集合的步骤。The component image is normalized to trigger the sample acquisition unit to execute the step of acquiring a positive sample set and a negative sample set for the component image pair.

可以理解,与对Siamese网络进行测试的过程类似,在采集Siamese网络的样本图像时对图像进行对齐以使元件位于图像的中心位置,并对图像进行归一化,该过程称为对图像的预处理过程,对图像进行预处理将会使Siamese网络训练效果更好。It can be understood that, similar to the process of testing the Siamese network, when the sample image of the Siamese network is collected, the image is aligned so that the component is located in the center of the image, and the image is normalized. This process is called image pre-processing. During the processing process, preprocessing the image will make the Siamese network training effect better.

可选地,在本发明的一些可能的实施方式中,如果对Siamese网络进行训练的时候对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时,也需要对元件图像进行预处理,如果对Siamese网络进行训练的时候不对元件图像进行预处理,那么在利用训练后的Siamese网络进行漏件检测时也不对元件图像进行预处理。Optionally, in some possible implementations of the present invention, if the component image is preprocessed when the Siamese network is trained, then when the trained Siamese network is used to detect missing parts, the component image also needs to be preprocessed. Preprocessing, if the component image is not preprocessed when the Siamese network is trained, then the component image is not preprocessed when the trained Siamese network is used for missing parts detection.

可选地,在本发明的一些可能的实施方式中,所述确定模块430具体用于:Optionally, in some possible implementation manners of the present invention, the determining module 430 is specifically configured to:

判断所述相似度是否在预设范围内;judging whether the similarity is within a preset range;

若所述相似度在预设范围内,则判定为所述元件存在;If the similarity is within a preset range, it is determined that the element exists;

若所述相似度不在预设范围内,则判定为所述元件不存在。If the similarity is not within the preset range, it is determined that the element does not exist.

可以理解,由于所述相似度是用于表征模板图像与测试图像的相似程度,所以当相似度在预设范围内时,说明模板图像与测试图像相似,那么元件图像则存在,也就是元件不漏件,否则,元件漏件。It can be understood that since the similarity is used to characterize the degree of similarity between the template image and the test image, when the similarity is within a preset range, it means that the template image is similar to the test image, then the component image exists, that is, the component does not Missing parts, otherwise, components missing parts.

可选地,在本发明的一些可能的实施方式中,当所述相似度大于或等于预设值时,则元件存在,也就是元件不漏件;当所述相似度小于预设值时,则元件不存在。Optionally, in some possible implementations of the present invention, when the similarity is greater than or equal to a preset value, the component exists, that is, there are no missing parts in the component; when the similarity is smaller than the preset value, then the element does not exist.

可以理解的是,本实施例的检测装置400的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional module of the detection device 400 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

可以看出,本实施例的方案中,检测装置400将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;检测装置400计算所述模板图像与所述测试图像的特征向量的相似度;检测装置400根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。It can be seen that in the solution of this embodiment, the detection device 400 inputs the template image and the test image into the trained Siamese network, and performs forward calculations respectively to obtain the feature vectors of the template image and the test image; the detection device 400 calculates the similarity between the template image and the feature vector of the test image; the detecting device 400 determines whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately judge whether the template image matches the test image, and the judgment accuracy is high.

参见图5,图5是本发明第五实施例提供的一种检测装置的结构示意图。如图5所示,本发明第五实施例提供一种检测装置500可以包括:至少一个总线501、与总线相连的至少一个处理器502以及与总线相连的至少一个存储器503。其中,处理器502通过总线501,调用存储器503中存储的代码以用于将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;计算所述模板图像与所述测试图像的特征向量的相似度;根据所述相似度确定所述测试图像与所述模板图像是否匹配。Referring to FIG. 5 , FIG. 5 is a schematic structural diagram of a detection device provided by a fifth embodiment of the present invention. As shown in FIG. 5 , a detection device 500 provided by a fifth embodiment of the present invention may include: at least one bus 501 , at least one processor 502 connected to the bus, and at least one memory 503 connected to the bus. Wherein, the processor 502 calls the code stored in the memory 503 through the bus 501 to input the template image and the test image into the trained Siamese network, and performs forward calculations respectively to obtain the values of the template image and the test image. A feature vector; calculating a similarity between the template image and the feature vector of the test image; determining whether the test image matches the template image according to the similarity.

其中,经过训练后的Siamese网络由于经过大量的样本图像的训练学习,具有了准确地对模板图像与测试图像进行图像匹配的能力。Among them, the trained Siamese network has the ability to accurately match the template image and the test image due to the training and learning of a large number of sample images.

其中,模板图像是用于对照的标准的图片,测试图像是通过与模板图像进行对照从而判断与模板图像是否匹配。Wherein, the template image is a standard picture for comparison, and the test image is compared with the template image to determine whether it matches the template image.

其中,相似度是用于判断模板图像与测试图像相似程序的参数。Wherein, the similarity is a parameter for judging the similarity between the template image and the test image.

可选地,在本发明的一些可能的实施方式中,所述模板图像为元件存在且处于标准位置时对应的元件图像,所述测试图像为需要进行测试的元件图像,所述处理器502根据所述相似度确定所述测试图像与所述模板图像是否匹配时,还用于:Optionally, in some possible implementations of the present invention, the template image is a corresponding component image when the component exists and is in a standard position, the test image is a component image that needs to be tested, and the processor 502 according to When the similarity determines whether the test image matches the template image, it is also used for:

根据所述相似度确定所述测试图像对应的元件是否存在。Determine whether the component corresponding to the test image exists according to the similarity.

其中,该模板图像可以为PCB模板图,从而与其对应输入的元件图像或测试图像也为PCB图像,该模板图也可以为从PCB图像上截取到的分别包含各个独立元件的图像,从而与其对应输入的测试图像也为包含各个独立元件的图像。Wherein, the template image can be a PCB template image, so that the input component image or test image corresponding to it is also a PCB image, and the template image can also be an image containing each independent component intercepted from the PCB image, so as to correspond to it The input test image is also an image containing individual components.

可选地,在本发明的一些可能的实施方式中,由于是对每个元件进行漏件检测,所以一般在Siamese网络中输入的模板图像为包含一个独立元件的图像,那么在训练阶段输入的元件图像也为从PCB图像上截取到的该位置的元件图像,在测试阶段输入的图像也为不同情况下从PCB图像上截取到的该位置的元件图像。Optionally, in some possible implementations of the present invention, since the missing part detection is performed on each component, generally the template image input in the Siamese network is an image containing an independent component, then the input in the training phase The component image is also the component image of the position intercepted from the PCB image, and the image input in the test stage is also the component image of the position intercepted from the PCB image in different situations.

其中,所述相似度为对Siamese网络输入的两个图像的特征的相似情况的度量,并且由于经过训练后的Siamese网络能准备地识别不同场景下拍摄的元件图像是否漏件情况,所以可根据该相似度值判断元件是否漏件。Wherein, the similarity is a measure of the similarity of the features of the two images input by the Siamese network, and because the Siamese network after training can be prepared to identify whether the component images taken in different scenes are missing parts, so it can be based on The similarity value judges whether the component is missing or not.

可选地,在本发明的一些可能的实施方式中,所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络之前,所述处理器502还用于:Optionally, in some possible implementation manners of the present invention, before inputting the template image and the test image into the trained Siamese network, the processor 502 is further configured to:

利用模板匹配得到所述模板图像与所述测试图像中元件的位置并对所述模板图像与所述测试图像进行对齐;Obtaining the position of the template image and the element in the test image by template matching and aligning the template image and the test image;

对所述模板图像与所述测试图像进行归一化,以触发执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。The template image and the test image are normalized to trigger the execution of the step of inputting the template image and the test image into the trained Siamese network.

可选地,在本发明的一些可能的实施方式中,所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络之前,所述处理器502还用于:Optionally, in some possible implementation manners of the present invention, before inputting the template image and the test image into the trained Siamese network, the processor 502 is further configured to:

创建所述元件图像对正样本集合以及负样本集合,其中,所述正样本集合包括所述模板图像与所述元件存在时的所述元件图像构成的元件图像对,所述负样本集合包括所述模板图像与所述元件不存在时的所述元件图像构成的元件图像对,所述负样本集合还包括所述模板图像与其它元件存在时的元件图像构成的元件图像对;Create a positive sample set and a negative sample set for the component image pair, wherein the positive sample set includes a component image pair formed by the template image and the component image when the component exists, and the negative sample set includes the A component image pair composed of the template image and the component image when the component does not exist, the negative sample set also includes a component image pair formed by the template image and component images when other components exist;

利用所述正样本集合以及所述负样本集合训练所述Siamese网络,以触发执行所述将所述模板图像与所述测试图像输入经过训练后的Siamese网络的步骤。Using the positive sample set and the negative sample set to train the Siamese network, so as to trigger the execution of the step of inputting the template image and the test image into the trained Siamese network.

可选地,在本发明的一些可能的实施方式中,所述元件图像的正样本集合和负样本集合包括训练样本和测试样本。Optionally, in some possible implementation manners of the present invention, the positive sample set and the negative sample set of the component image include training samples and test samples.

其中,训练样本是指对Siamese网络进行训练,测试样本是指测试经过训练后的Siamese网络的效果,两者一起构成对Siamese网络的训练阶段的样本。Wherein, the training sample refers to training the Siamese network, and the test sample refers to testing the effect of the trained Siamese network, and the two together constitute a sample in the training phase of the Siamese network.

可选地,在本发明的一些可能的实施方式中,所述创建所述元件图像对正样本集合以及负样本集合时,所述处理器502具体用于:Optionally, in some possible implementation manners of the present invention, when creating the component image alignment positive sample set and negative sample set, the processor 502 is specifically configured to:

采集印刷电路板图像;Capture printed circuit board images;

以印刷电路板模板图像为参考,在所述印刷电路板图像上截取元件图像;Taking the printed circuit board template image as a reference, intercepting the component image on the printed circuit board image;

采集所述元件图像对正样本集合以及负样本集合。The image of the component is collected to align a positive sample set and a negative sample set.

可选地,在本发明的一些可能的实施方式中,可以在生产线上架设摄像头,批量采集不同型号的PCB板卡图像,并以板卡跟踪技术避免重复拍摄某一PCB板卡。这样每个型号的PCB板卡均包含多个图像样本,每个图像样本对应某一型号的某张PCB板卡,从而这样在获取到的PCB板卡上的元件图像也来自不同板卡上,保证样本不重复并且数量充分。Optionally, in some possible implementations of the present invention, a camera can be set up on the production line to collect images of different types of PCB boards in batches, and use board tracking technology to avoid repeatedly photographing a certain PCB board. In this way, each type of PCB board contains multiple image samples, and each image sample corresponds to a certain type of PCB board, so that the obtained component images on the PCB board also come from different boards. Ensure that the samples are not repeated and the number is sufficient.

可选地,在本发明的一些可能的实施方式中,所述在所述印刷板电路上截取元件图像,所述处理器502具体用于:Optionally, in some possible implementation manners of the present invention, the intercepting the component image on the printed circuit board, the processor 502 is specifically configured to:

利用印刷板图像上面的元件的位置信息自动截取元件图像。The component image is automatically captured using the position information of the component on the printed board image.

可以理解,当知道元件的位置信息后,则可以根据该位置信息自动截取元件图像。It can be understood that when the position information of the component is known, the component image can be automatically intercepted according to the position information.

可选地,在本发明的一些可能的实施方式中,所述对元件图像进行标注,所述处理器502具体用于:Optionally, in some possible implementation manners of the present invention, in annotating the component image, the processor 502 is specifically configured to:

根据元件类别信息进行标注。Label according to component category information.

可选地,在本发明的另一些可能的实施方式中,也可以通过其它能对元件进行区分的方式对元件进行标注。Optionally, in some other possible implementation manners of the present invention, the components may also be marked in other ways that can distinguish the components.

可选地,在本发明的一些可能的实施方式中,所述采集所述元件图像对正样本集合以及负样本集合之前,所述处理器502还用于:Optionally, in some possible implementation manners of the present invention, before collecting the component image alignment positive sample set and negative sample set, the processor 502 is further configured to:

利用模板匹配得到所述元件图像中元件的位置并对所述元件图像进行对齐;Obtaining the position of the component in the component image by template matching and aligning the component image;

对所述元件图像进行归一化,以触发执行所述采集所述元件图像对正样本集合以及负样本集合的步骤。The component image is normalized to trigger the execution of the step of acquiring the positive sample set and the negative sample set of the component image pair.

可选地,在本发明的一些可能的实施方式中,所述处理器502根据所述相似度确定所述测试图像对应的元件是否存在,所述处理器502具体用于:Optionally, in some possible implementations of the present invention, the processor 502 determines whether the element corresponding to the test image exists according to the similarity, and the processor 502 is specifically configured to:

判断所述相似度是否在预设范围内;judging whether the similarity is within a preset range;

若所述相似度在预设范围内,则判定为所述元件存在;If the similarity is within a preset range, it is determined that the element exists;

若所述相似度不在预设范围内,则判定为所述元件不存在。If the similarity is not within the preset range, it is determined that the element does not exist.

可以理解的是,本实施例的元件检测装置500的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional module of the component detection device 500 in this embodiment can be specifically realized according to the method in the above-mentioned method embodiment, and the specific implementation process can refer to the relevant description of the above-mentioned method embodiment, and will not be repeated here. .

可以理解的是,本实施例的检测装置500的各功能模块的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相关描述,此处不再赘述。It can be understood that the functions of each functional module of the detection device 500 in this embodiment can be specifically implemented according to the method in the above method embodiment, and the specific implementation process can refer to the relevant description of the above method embodiment, and will not be repeated here.

可以看出,本实施例的方案中,检测装置500将模板图像与测试图像输入经过训练后的Siamese网络,并分别作前向计算得到所述模板图像与所述测试图像的特征向量;检测装置500计算所述模板图像与所述测试图像的特征向量的相似度;检测装置500根据所述相似度确定所述测试图像与所述模板图像是否匹配。由于Siamese网络可以提取到图像的高级特征,将图像输入经过训练后的Siamese网络可以准确地判断模板图像与测试图像是否匹配,判断准确率高。It can be seen that in the solution of this embodiment, the detection device 500 inputs the template image and the test image into the trained Siamese network, and performs forward calculations respectively to obtain the feature vectors of the template image and the test image; the detection device 500 calculates the similarity between the template image and the feature vector of the test image; the detecting device 500 determines whether the test image matches the template image according to the similarity. Since the Siamese network can extract the advanced features of the image, inputting the image into the trained Siamese network can accurately judge whether the template image matches the test image, and the judgment accuracy is high.

本发明实施例还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时包括上述方法实施例中记载的任何检测方法的部分或全部步骤。An embodiment of the present invention also provides a computer storage medium, wherein the computer storage medium can store a program, and the program includes some or all steps of any detection method described in the above method embodiments when executed.

需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. Because of the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the foregoing embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本发明的各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为嵌入式设备、个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,RandomAccessMemory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to make a computer device (which may be an embedded device, a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media capable of storing program codes such as U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk.

以上所述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still understand the foregoing The technical solutions recorded in each embodiment are modified, or some of the technical features are replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (12)

1. a detection method, is characterized in that, described method comprises:
Template image and test pattern are inputted the Siamese network after training, and obtains the proper vector of described template image and described test pattern respectively as forward calculation;
Calculate the similarity of the proper vector of described template image and described test pattern;
Determine whether described test pattern mates with described template image according to described similarity.
2. method according to claim 1, it is characterized in that, the part drawing picture that described template image is corresponding when being element existence and being in normal place, described test pattern is the part drawing picture needing to carry out testing, describedly determine whether described test pattern mates with described template image, comprising according to described similarity:
Determine whether the element that described test pattern is corresponding exists according to described similarity.
3. method according to claim 2, is characterized in that, described described template image and described test pattern are inputted the Siamese network after training before, described method also comprises:
Template matches is utilized to obtain the position of described template image and element in described test pattern and align with described test pattern to described template image;
Described template image and described test pattern are normalized, perform the described step described template image and described test pattern being inputted the Siamese network after training to trigger.
4. according to the method in claim 2 or 3, it is characterized in that, described described template image and described test pattern are inputted the Siamese network after training before, described method also comprises:
Create described part drawing picture and align sample set and negative sample set, wherein, described positive sample set comprises the part drawing picture pair of described element image construction when described template image and described element exist, described negative sample set comprises the part drawing picture pair of described element image construction when described template image and described element do not exist, and described negative sample set also comprises the part drawing picture pair of element image construction when described template image and other element exist;
Utilize described positive sample set and described negative sample set to train described Siamese network, perform the described step described template image and described test pattern being inputted the Siamese network after training to trigger.
5. method according to claim 4, is characterized in that, the described part drawing picture of described establishment aligns sample set and negative sample set, comprising:
Gather printed circuit board image;
With printed circuit board (PCB) template image for reference, described printed circuit board image intercepts part drawing picture;
Gather described part drawing picture and align sample set and negative sample set.
6. method according to claim 5, before the described part drawing picture of described collection aligns sample set and negative sample set, described method also comprises:
Template matches is utilized to obtain the position of element in described part drawing picture and align to described part drawing picture;
Described part drawing picture is normalized, performs to trigger the step that the described part drawing picture of described collection aligns sample set and negative sample set.
7. method according to claim 6, is characterized in that, describedly determines whether the element that described test pattern is corresponding exists, and comprising according to described similarity:
Judge described similarity whether in preset range;
If described similarity is in preset range, be then judged to be that described element exists;
If described similarity is not in preset range, be then judged to be that described element does not exist.
8. a pick-up unit, is characterized in that, described device comprises:
Image input module, for template image and test pattern are inputted the Siamese network after training, and obtains the proper vector of described template image and described test pattern respectively as forward calculation;
Computing module, for calculating the similarity of the proper vector of described module map picture and described test pattern;
According to described similarity, determination module, for determining whether described test pattern mates with described template image.
9. device according to claim 8, is characterized in that, described template image is element corresponding part drawing picture when existing and be in normal place, and described test pattern is the part drawing picture needing to carry out testing, described determination module specifically for:
Determine whether the element that described test pattern is corresponding exists according to described similarity.
10. device according to claim 9, is characterized in that, described device also comprises:
Pretreatment module, obtains the position of described template image and element in described test pattern for utilizing template matches and aligns with described test pattern to described template image;
Described template image and described test pattern are normalized, perform the described step described template image and described test pattern being inputted the Siamese network after training to trigger described image input module.
11. devices according to claim 9 or 10, it is characterized in that, described device also comprises:
Sample creation module, sample set and negative sample set is aligned for creating described part drawing picture, wherein, described positive sample set comprises the part drawing picture pair of described element image construction when described template image and described element exist, described negative sample set comprises the part drawing picture pair of described element image construction when described template image and described element do not exist, and described negative sample set also comprises the part drawing picture pair of element image construction when described template image and other element exist;
Training module, for utilizing described positive sample set and described negative sample set to train described Siamese network, perform the described step described template image and described test pattern being inputted the Siamese network after training to trigger described image input module.
12. devices according to claim 11, is characterized in that, described sample creation module comprises:
Image acquisition units, for gathering printed circuit board image;
Interception unit, for printed circuit board (PCB) template image for reference, described printed circuit board image intercepts part drawing picture;
Sample collection unit, aligns sample set and negative sample set for gathering described part drawing picture.
CN201510527486.9A 2015-08-25 2015-08-25 Detection method and device Active CN105184778B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201510527486.9A CN105184778B (en) 2015-08-25 2015-08-25 Detection method and device
PCT/CN2016/096551 WO2017032311A1 (en) 2015-08-25 2016-08-24 Detection method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510527486.9A CN105184778B (en) 2015-08-25 2015-08-25 Detection method and device

Publications (2)

Publication Number Publication Date
CN105184778A true CN105184778A (en) 2015-12-23
CN105184778B CN105184778B (en) 2018-04-24

Family

ID=54906831

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510527486.9A Active CN105184778B (en) 2015-08-25 2015-08-25 Detection method and device

Country Status (2)

Country Link
CN (1) CN105184778B (en)
WO (1) WO2017032311A1 (en)

Cited By (34)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105957065A (en) * 2016-04-21 2016-09-21 广州视源电子科技股份有限公司 Element missing detection method and system
CN106204602A (en) * 2016-07-13 2016-12-07 广州视源电子科技股份有限公司 Element reverse detection method and system
CN106251333A (en) * 2016-07-13 2016-12-21 广州视源电子科技股份有限公司 Element reverse detection method and system
WO2017032311A1 (en) * 2015-08-25 2017-03-02 广州视源电子科技股份有限公司 Detection method and apparatus
CN106650630A (en) * 2016-11-11 2017-05-10 纳恩博(北京)科技有限公司 Target tracking method and electronic equipment
CN106909625A (en) * 2017-01-20 2017-06-30 清华大学 A kind of image search method and system based on Siamese networks
CN107220277A (en) * 2017-04-14 2017-09-29 西北大学 Image retrieval algorithm based on cartographical sketching
WO2018072326A1 (en) * 2016-10-21 2018-04-26 广州视源电子科技股份有限公司 Image identification-based solder joint type detection and apparatus
CN107967255A (en) * 2017-11-08 2018-04-27 北京广利核系统工程有限公司 A kind of method and system for judging text similarity
CN108171714A (en) * 2017-11-13 2018-06-15 合肥阿巴赛信息科技有限公司 It is a kind of based on the fracture area recognition methods compared in pairs and system
CN108171184A (en) * 2018-01-03 2018-06-15 南京理工大学 Method for distinguishing is known based on Siamese networks again for pedestrian
CN108399382A (en) * 2018-02-13 2018-08-14 阿里巴巴集团控股有限公司 Vehicle insurance image processing method and device
CN108665485A (en) * 2018-04-16 2018-10-16 华中科技大学 A kind of method for tracking target merged with twin convolutional network based on correlation filtering
CN108830850A (en) * 2018-06-28 2018-11-16 信利(惠州)智能显示有限公司 Automatic optics inspection picture analyzing method and apparatus
CN108846358A (en) * 2018-06-13 2018-11-20 浙江工业大学 Target tracking method for feature fusion based on twin network
CN108918536A (en) * 2018-07-13 2018-11-30 广东工业大学 Tire-mold face character defect inspection method, device, equipment and storage medium
CN108960258A (en) * 2018-07-06 2018-12-07 江苏迪伦智能科技有限公司 A kind of template matching method based on self study depth characteristic
CN109002784A (en) * 2018-06-29 2018-12-14 国信优易数据有限公司 The training method and system of streetscape identification model, streetscape recognition methods and system
CN109344661A (en) * 2018-09-06 2019-02-15 南京聚铭网络科技有限公司 A kind of webpage integrity assurance of the micro code based on machine learning
CN109543057A (en) * 2018-11-20 2019-03-29 广州逗号智能零售有限公司 Commodity recognition method, device, equipment and storage medium based on intelligent cashier platform
CN109670073A (en) * 2018-12-20 2019-04-23 科大讯飞股份有限公司 A kind of information conversion method and device, interaction auxiliary system
CN109767456A (en) * 2019-01-09 2019-05-17 上海大学 A target tracking method based on SiameseFC framework and PFP neural network
CN110782480A (en) * 2019-10-15 2020-02-11 哈尔滨工程大学 An infrared pedestrian tracking method based on online template prediction
CN110967851A (en) * 2019-12-26 2020-04-07 成都数之联科技有限公司 Circuit extraction method and system for array image of liquid crystal panel
CN111524162A (en) * 2020-04-15 2020-08-11 上海摩象网络科技有限公司 A method, device and hand-held camera for retrieving a tracking target
CN111914508A (en) * 2020-08-19 2020-11-10 创新奇智(南京)科技有限公司 Component detection method and device, electronic equipment and readable storage medium
CN113012088A (en) * 2019-12-03 2021-06-22 浙江大搜车软件技术有限公司 Circuit board fault detection and twin network training method, device and equipment
CN114619591A (en) * 2022-05-16 2022-06-14 河南源宏高分子新材料有限公司 Sorting process in high polymer material regeneration process
TWI772181B (en) * 2021-09-14 2022-07-21 台達電子工業股份有限公司 Automatic recognizing system and automatic recognizing method for a pick-up position of a printed circuit board
CN114882257A (en) * 2022-05-09 2022-08-09 安徽文香科技有限公司 Wire detection method and device for experimental operation
CN115546219A (en) * 2022-12-05 2022-12-30 广州镭晨智能装备科技有限公司 Detection board type generation method, board card defect detection method, device and product
CN115731455A (en) * 2022-10-28 2023-03-03 河南凯瑞电气设备有限公司 Looped network metering cabinet
CN116026859A (en) * 2023-01-30 2023-04-28 讯芸电子科技(中山)有限公司 Method, device, equipment and storage medium for detecting installation of optoelectronic module
WO2024044915A1 (en) * 2022-08-29 2024-03-07 西门子股份公司 Image comparison method and apparatus for error detection, and computer device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110443777B (en) * 2018-10-09 2023-03-10 广东仙童智能机器人科技有限公司 PCB image alignment method and device and computer storage medium
CN112559342A (en) * 2020-12-09 2021-03-26 上海米哈游天命科技有限公司 Method, device and equipment for acquiring picture test image and storage medium
CN112816474B (en) * 2021-01-07 2022-02-01 武汉大学 Target perception-based depth twin network hyperspectral video target tracking method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020102018A1 (en) * 1999-08-17 2002-08-01 Siming Lin System and method for color characterization using fuzzy pixel classification with application in color matching and color match location
CN101464946A (en) * 2009-01-08 2009-06-24 上海交通大学 Detection method based on head identification and tracking characteristics
CN103065135A (en) * 2013-01-25 2013-04-24 上海理工大学 License number matching algorithm based on digital image processing
CN103310453A (en) * 2013-06-17 2013-09-18 北京理工大学 Rapid image registration method based on sub-image corner features
CN103679158A (en) * 2013-12-31 2014-03-26 北京天诚盛业科技有限公司 Face authentication method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105184778B (en) * 2015-08-25 2018-04-24 广州视源电子科技股份有限公司 Detection method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020102018A1 (en) * 1999-08-17 2002-08-01 Siming Lin System and method for color characterization using fuzzy pixel classification with application in color matching and color match location
CN101464946A (en) * 2009-01-08 2009-06-24 上海交通大学 Detection method based on head identification and tracking characteristics
CN103065135A (en) * 2013-01-25 2013-04-24 上海理工大学 License number matching algorithm based on digital image processing
CN103310453A (en) * 2013-06-17 2013-09-18 北京理工大学 Rapid image registration method based on sub-image corner features
CN103679158A (en) * 2013-12-31 2014-03-26 北京天诚盛业科技有限公司 Face authentication method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王添翼: "基于卷积的三维模型特征提取", 《中国优秀硕博士学位论文全文数据库(硕士) 信息科技辑》 *

Cited By (55)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017032311A1 (en) * 2015-08-25 2017-03-02 广州视源电子科技股份有限公司 Detection method and apparatus
CN105957065A (en) * 2016-04-21 2016-09-21 广州视源电子科技股份有限公司 Element missing detection method and system
CN106204602A (en) * 2016-07-13 2016-12-07 广州视源电子科技股份有限公司 Element reverse detection method and system
CN106251333A (en) * 2016-07-13 2016-12-21 广州视源电子科技股份有限公司 Element reverse detection method and system
CN106204602B (en) * 2016-07-13 2019-02-01 广州视源电子科技股份有限公司 Element reverse detection method and system
CN106251333B (en) * 2016-07-13 2019-02-26 广州视源电子科技股份有限公司 Element reverse detection method and system
WO2018072326A1 (en) * 2016-10-21 2018-04-26 广州视源电子科技股份有限公司 Image identification-based solder joint type detection and apparatus
WO2018086607A1 (en) * 2016-11-11 2018-05-17 纳恩博(北京)科技有限公司 Target tracking method, electronic device, and storage medium
CN106650630A (en) * 2016-11-11 2017-05-10 纳恩博(北京)科技有限公司 Target tracking method and electronic equipment
CN106650630B (en) * 2016-11-11 2019-08-23 纳恩博(北京)科技有限公司 A kind of method for tracking target and electronic equipment
CN106909625A (en) * 2017-01-20 2017-06-30 清华大学 A kind of image search method and system based on Siamese networks
CN107220277A (en) * 2017-04-14 2017-09-29 西北大学 Image retrieval algorithm based on cartographical sketching
CN107967255A (en) * 2017-11-08 2018-04-27 北京广利核系统工程有限公司 A kind of method and system for judging text similarity
CN108171714A (en) * 2017-11-13 2018-06-15 合肥阿巴赛信息科技有限公司 It is a kind of based on the fracture area recognition methods compared in pairs and system
CN108171714B (en) * 2017-11-13 2021-09-21 广东三维家信息科技有限公司 Fracture area identification method and system based on pair-wise comparison
CN108171184B (en) * 2018-01-03 2020-04-10 南京理工大学 Method for re-identifying pedestrians based on Simese network
CN108171184A (en) * 2018-01-03 2018-06-15 南京理工大学 Method for distinguishing is known based on Siamese networks again for pedestrian
US10891515B2 (en) 2018-02-13 2021-01-12 Advanced New Technologies Co., Ltd. Vehicle accident image processing method and apparatus
US10891517B2 (en) 2018-02-13 2021-01-12 Advanced New Technologies Co., Ltd. Vehicle accident image processing method and apparatus
CN108399382A (en) * 2018-02-13 2018-08-14 阿里巴巴集团控股有限公司 Vehicle insurance image processing method and device
CN108665485B (en) * 2018-04-16 2021-07-02 华中科技大学 A Target Tracking Method Based on Fusion of Correlation Filter and Siamese Convolutional Network
CN108665485A (en) * 2018-04-16 2018-10-16 华中科技大学 A kind of method for tracking target merged with twin convolutional network based on correlation filtering
CN108846358B (en) * 2018-06-13 2021-10-26 浙江工业大学 Target tracking method for feature fusion based on twin network
CN108846358A (en) * 2018-06-13 2018-11-20 浙江工业大学 Target tracking method for feature fusion based on twin network
CN108830850B (en) * 2018-06-28 2020-10-23 信利(惠州)智能显示有限公司 Automatic optical detection picture analysis method and equipment
CN108830850A (en) * 2018-06-28 2018-11-16 信利(惠州)智能显示有限公司 Automatic optics inspection picture analyzing method and apparatus
CN109002784A (en) * 2018-06-29 2018-12-14 国信优易数据有限公司 The training method and system of streetscape identification model, streetscape recognition methods and system
CN109002784B (en) * 2018-06-29 2021-04-13 国信优易数据股份有限公司 Street view identification method and system
CN108960258A (en) * 2018-07-06 2018-12-07 江苏迪伦智能科技有限公司 A kind of template matching method based on self study depth characteristic
CN108918536A (en) * 2018-07-13 2018-11-30 广东工业大学 Tire-mold face character defect inspection method, device, equipment and storage medium
CN108918536B (en) * 2018-07-13 2021-01-26 广东工业大学 Tire mold surface character defect detection method, device, equipment and storage medium
CN109344661A (en) * 2018-09-06 2019-02-15 南京聚铭网络科技有限公司 A kind of webpage integrity assurance of the micro code based on machine learning
CN109543057A (en) * 2018-11-20 2019-03-29 广州逗号智能零售有限公司 Commodity recognition method, device, equipment and storage medium based on intelligent cashier platform
CN109670073A (en) * 2018-12-20 2019-04-23 科大讯飞股份有限公司 A kind of information conversion method and device, interaction auxiliary system
CN109670073B (en) * 2018-12-20 2021-03-23 科大讯飞股份有限公司 Information conversion method and device and interactive auxiliary system
CN109767456A (en) * 2019-01-09 2019-05-17 上海大学 A target tracking method based on SiameseFC framework and PFP neural network
CN110782480A (en) * 2019-10-15 2020-02-11 哈尔滨工程大学 An infrared pedestrian tracking method based on online template prediction
CN110782480B (en) * 2019-10-15 2023-08-04 哈尔滨工程大学 Infrared pedestrian tracking method based on online template prediction
CN113012088A (en) * 2019-12-03 2021-06-22 浙江大搜车软件技术有限公司 Circuit board fault detection and twin network training method, device and equipment
CN110967851A (en) * 2019-12-26 2020-04-07 成都数之联科技有限公司 Circuit extraction method and system for array image of liquid crystal panel
CN110967851B (en) * 2019-12-26 2022-06-21 成都数之联科技股份有限公司 Line extraction method and system for array image of liquid crystal panel
CN111524162A (en) * 2020-04-15 2020-08-11 上海摩象网络科技有限公司 A method, device and hand-held camera for retrieving a tracking target
CN111524162B (en) * 2020-04-15 2022-04-01 上海摩象网络科技有限公司 Method and device for retrieving tracking target and handheld camera
WO2021208261A1 (en) * 2020-04-15 2021-10-21 上海摩象网络科技有限公司 Tracking target retrieving method and device, and handheld camera
CN111914508A (en) * 2020-08-19 2020-11-10 创新奇智(南京)科技有限公司 Component detection method and device, electronic equipment and readable storage medium
TWI772181B (en) * 2021-09-14 2022-07-21 台達電子工業股份有限公司 Automatic recognizing system and automatic recognizing method for a pick-up position of a printed circuit board
CN114882257A (en) * 2022-05-09 2022-08-09 安徽文香科技有限公司 Wire detection method and device for experimental operation
CN114619591B (en) * 2022-05-16 2022-08-26 河南源宏高分子新材料有限公司 Sorting process in high polymer material regeneration process
CN114619591A (en) * 2022-05-16 2022-06-14 河南源宏高分子新材料有限公司 Sorting process in high polymer material regeneration process
WO2024044915A1 (en) * 2022-08-29 2024-03-07 西门子股份公司 Image comparison method and apparatus for error detection, and computer device
CN115731455A (en) * 2022-10-28 2023-03-03 河南凯瑞电气设备有限公司 Looped network metering cabinet
CN115546219A (en) * 2022-12-05 2022-12-30 广州镭晨智能装备科技有限公司 Detection board type generation method, board card defect detection method, device and product
CN115546219B (en) * 2022-12-05 2023-10-20 广州镭晨智能装备科技有限公司 Detection plate type generation method, plate card defect detection method, device and product
CN116026859A (en) * 2023-01-30 2023-04-28 讯芸电子科技(中山)有限公司 Method, device, equipment and storage medium for detecting installation of optoelectronic module
CN116026859B (en) * 2023-01-30 2023-12-12 讯芸电子科技(中山)有限公司 Method, device, equipment and storage medium for detecting installation of optoelectronic module

Also Published As

Publication number Publication date
WO2017032311A1 (en) 2017-03-02
CN105184778B (en) 2018-04-24

Similar Documents

Publication Publication Date Title
CN105184778B (en) Detection method and device
CN110443110B (en) Face recognition method, device, terminal and storage medium based on multipath camera shooting
CN105426917A (en) Element classification method and device
CN106127746A (en) Circuit board element missing part detection method and system
CN109990662B (en) Automatic target scoring method, device, equipment and computer readable storage medium
WO2017088553A1 (en) Method and system for rapidly identifying and marking electronic component polarity direction
CN110222791A (en) Sample labeling information auditing method and device
CN108229480A (en) A kind of recognition methods, device and the equipment of number meter reading
CN110443224A (en) Page turning detection method and device, electronic equipment and storage medium
WO2017088552A1 (en) Method and system for identifying electronic component polarity, and method and system for marking electronic component polarity
CN106529369A (en) Component mounting state detection method and system
CN108663382A (en) The method and device of the paper surface defects detection of view-based access control model conspicuousness
CN115239683A (en) Circuit board detection method, model training method, device and electronic equipment
CN112001200A (en) Identification code identification method, device, equipment, storage medium and system
CN108596829A (en) A kind of PCB bare boards picture method for registering and device
CN110046085A (en) The method and device of the application program control shown on identification terminal equipment
CN113536868B (en) Circuit board fault identification method and related equipment
CN110517260A (en) The detection method and device of circuit board, storage medium, electronic equipment
CN110346704B (en) Method, device and equipment for determining test file in board test and storage medium
CN112631896A (en) Equipment performance testing method and device, storage medium and electronic equipment
WO2021159736A1 (en) Application compatibility test method and apparatus, and computer device
CN110888812A (en) System and method for testing response time of terminal page
CN115496894A (en) Detection method and detection terminal for PCBA
CN114885156A (en) Identification method, device, equipment, storage medium and program product
CN112529883A (en) Patch detection method and device based on image edge recognition

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant