WO2017032308A1 - Pcb board detection method and apparatus - Google Patents

Pcb board detection method and apparatus Download PDF

Info

Publication number
WO2017032308A1
WO2017032308A1 PCT/CN2016/096546 CN2016096546W WO2017032308A1 WO 2017032308 A1 WO2017032308 A1 WO 2017032308A1 CN 2016096546 W CN2016096546 W CN 2016096546W WO 2017032308 A1 WO2017032308 A1 WO 2017032308A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
threshold
pcb board
edge image
zero pixels
Prior art date
Application number
PCT/CN2016/096546
Other languages
French (fr)
Chinese (zh)
Inventor
杨铭
Original Assignee
广州视源电子科技股份有限公司
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 广州视源电子科技股份有限公司 filed Critical 广州视源电子科技股份有限公司
Publication of WO2017032308A1 publication Critical patent/WO2017032308A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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]

Definitions

  • the invention relates to the field of automatic optical inspection of PCBs, in particular to a device for detecting PCB boards.
  • AOI Automatic Optical Inspection
  • the technology mainly includes four steps: image acquisition, image processing, feature extraction and decision-making.
  • image processing it is often necessary to perform preliminary analysis on the collected original image to determine whether the original image contains complete PCB boards, which play a vital role in improving the efficiency and quality of PCB inspection.
  • the existing image processing schemes often have problems such as low robustness, slow calculation speed, and complicated operation, which cannot meet the requirements for use.
  • an object of the present invention is to provide a PCB board detecting method and device, which realizes fast and accurate PCB board testing and satisfies the use requirements.
  • Embodiments of the present invention provide a PCB board detecting method, including the following steps:
  • the image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptively generated according to pixel information of the image;
  • the method further includes:
  • the size of the image is normalized.
  • the image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the
  • the pixel information of the image is adaptively generated, and specifically includes:
  • the high threshold takes the smaller of I max and (1 + ⁇ ) * m; the low threshold takes I min and (1 - ⁇ ) * m The larger of them, ⁇ is an empirical parameter;
  • the image is processed using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
  • the empirical parameter ⁇ takes a value of 0.33.
  • the counting the number of non-zero pixels in the edge image includes:
  • the pixels in the edge image are traversed, the pixels whose pixel values are not zero are marked as non-zero pixels, and the number of non-zero pixels is counted.
  • the detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
  • the designated area includes a boundary area, wherein the boundary area is a point in the specified area that a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt is less than or equal to a predetermined length The area formed;
  • the detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
  • the designated area further includes an inner area, the inner area being an area other than the boundary area in the designated area;
  • the detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
  • the invention also provides a PCB board detecting device, comprising:
  • An acquisition unit for collecting an image of a designated area on a conveying surface of the conveyor belt
  • An image processing unit configured to process the image by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the image Pixel information adaptive generation;
  • a statistical unit configured to count the number of non-zero pixels in the edge image
  • a detecting unit configured to detect, according to a magnitude relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
  • the PCB board detecting device further includes:
  • a normalization unit for normalizing the size of the image is
  • the image processing unit specifically includes:
  • a pixel acquisition unit configured to acquire a pixel value range of the image, where the pixel value range is [I min , I max ];
  • a calculating unit configured to calculate a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size;
  • a threshold generating unit configured to generate the high threshold and a low threshold, wherein the high threshold takes a smaller one of I max and (1+ ⁇ )*m; the low threshold takes I min and (1) The larger of - ⁇ )*m, ⁇ is an empirical parameter;
  • a processing unit configured to process the image by using the high threshold and the low threshold as a threshold parameter of the Canny operator to obtain an edge image.
  • the designated area includes a boundary area, wherein the boundary area is a point in the specified area that a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt is less than or equal to a predetermined length The area formed;
  • the statistic unit is specifically configured to: count the number of non-zero pixels in the edge image corresponding to the boundary area;
  • the detecting unit is configured to determine that the PCB board portion enters the designated area when determining that the number of non-zero pixels in the edge image corresponding to the boundary area is greater than a preset second threshold.
  • the designated area further includes an inner area, wherein the inner area is an area other than the boundary area in the designated area;
  • the statistic unit is specifically configured to separately count the number of non-zero pixels of the edge image corresponding to the inner region and the edge image corresponding to the boundary region;
  • the detecting unit is configured to: determine that the number of non-zero pixels in the edge image corresponding to the inner region is greater than a preset third threshold, and the non-zero pixels in the edge image corresponding to the boundary region When the number is less than the preset fourth threshold, it is determined that the PCB board completely enters the designated area.
  • the method and device for detecting a PCB board use an adaptive Canny operator to analyze an image of a specified area on a transmission surface of a conveyor belt, and detect the extent to which the PCB board enters a designated area, and determine that the PCB board completely enters.
  • the image of the designated area thereby filtering out unnecessary invalid images for subsequent processing, improving the speed and accuracy of PCB detection. Since the edge detection parameter of the adaptive Canny operator is adaptively generated according to the pixel information of the image, no manual basis is needed.
  • the body condition adjustment parameters are highly robust and achieve a high degree of automation of PCB inspection.
  • FIG. 1 is a schematic flow chart of a PCB board detecting method according to a first embodiment of the present invention.
  • FIG. 2 is a schematic view of a portion of a PCB board provided in a first embodiment of the present invention entering a designated area.
  • FIG. 3 is a schematic diagram of the PCB board provided in the first embodiment of the present invention completely entering a designated area.
  • FIG. 4 is a schematic diagram of a PCB board according to a first embodiment of the present invention that has not entered or has left a designated area.
  • FIG. 5 is a schematic flow chart of a PCB board detecting method according to a second embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a PCB board detecting apparatus according to a third embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of the image processing unit shown in FIG. 6.
  • FIG. 8 is a schematic structural diagram of a PCB board detecting apparatus according to a fourth embodiment of the present invention.
  • Embodiments of the present invention provide a PCB board detecting method and apparatus for detecting the extent to which a PCB board enters an image acquisition field of view, and improving the efficiency and quality of automatic optical inspection of the PCB. A detailed description will be given below.
  • a first embodiment of the present invention provides a PCB board detecting method.
  • the PCB board detecting method is implemented by a PCB board detecting device, and includes at least the following steps:
  • the conveyor belt can continuously transport the PCB board along a certain transmission direction
  • the PCB board detecting device collects the image of the PCB board in the transportation.
  • the PCB board detecting device includes a camera.
  • the camera is mounted above the conveyor belt and acquires an image of a designated area on the conveying surface in real time, wherein the image may be a color image or a black and white image. Since the PCB board is constantly moving relative to the camera, a PCB board portion may enter the designated area in the image of the designated area collected by the camera, and the PCB board completely enters the designated area. Or, the PCB board does not enter or has left the designated area and the like.
  • the image is processed by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptive according to pixel information of the image. generate.
  • the Canny operator is generally used for detecting edge of an image.
  • the high threshold and the low threshold of the traditional Canny operator are preset, and cannot be customized according to the current situation of the image. Adapt to the adjustment.
  • the PCB board detecting apparatus adopts an adaptive edge detection strategy, and automatically generates appropriate high thresholds and low thresholds according to pixel information of the image, thereby providing a preferred threshold for the Canny operator.
  • Parameter specifically,
  • the PCB board detecting device acquires a gray value of each pixel of the image, and reads a maximum value I max and a minimum value I min from the gray values.
  • the pixel value range is labeled as [I min , I max ].
  • a pixel median value m of the image is calculated, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size.
  • the high threshold t high and the low threshold t low are generated, wherein the high threshold t high takes the smaller of I max and (1+ ⁇ )*m, and the low threshold t low takes I The larger of min and (1- ⁇ )*m.
  • the high threshold t high takes the smaller of I max and (1+ ⁇ )*m
  • the low threshold t low takes I min and (1- ⁇ )*m
  • t high min(I max ,(1+ ⁇ )*m)
  • t low max(I min ,(1- ⁇ )*m)
  • is an empirical parameter.
  • the empirical parameter ⁇ takes a value of 0.33. It is to be understood that the empirical parameter ⁇ may also have a value of 0.2, 0.3, 0.4 or any other suitable value, which may be set according to actual needs, and is not specifically limited in the present invention.
  • the image is processed using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
  • the PCB board detecting apparatus processes the image by using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
  • the process of processing the edge image by the canny operator can refer to the calculation principle of the Canny operator, and the present invention is not described herein.
  • the PCB board detecting device traverses all the pixels in the edge image, and marks the pixels whose pixel values are not zero as non-zero pixels, and counts the number of the non-zero pixels.
  • the relationship between the PCB board and the designated area may include not entering or leaving, partially entering, and fully entering.
  • the following embodiments of the present invention will be described one by one.
  • the PCB board detecting device counts the number of non-zero pixels in the edge image corresponding to the designated area 10, and respectively compares the number of non-zero pixels in the edge image with The first threshold is compared, and when the number of non-zero pixels in the edge image is less than the first threshold, it is determined that the PCB board 20 has not entered or has left the designated area 10, wherein Narrative A threshold can be zero, or a value close to zero.
  • the designated area 10 includes a boundary area 11, wherein the boundary area 11 is within the designated area 10.
  • the PCB board detecting device counts the number of non-zero pixels in the edge image corresponding to the boundary region 11
  • the number of non-zero pixels in the edge image corresponding to the boundary region 11 is preset with The two thresholds are compared. When the number of non-zero pixels in the edge image corresponding to the boundary region 11 is greater than the second threshold, it is determined that the PCB board 20 partially enters the designated area 10.
  • the designated area 10 may further include an inner area 12, wherein the inner area 12 is an area other than the boundary area 11 in the designated area 10.
  • the PCB board detecting device separately counts the number of non-zero pixels in the edge image corresponding to the inner region 12 and the edge image corresponding to the boundary region 11, and respectively respectively outputs the edge image corresponding to the inner region 12
  • the number of non-zero pixels in the comparison is compared with a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is compared with a preset fourth threshold.
  • the method for detecting a PCB board uses an adaptive Canny operator to analyze an image of a specified area on a transmission surface of the conveyor belt, and detects the extent to which the PCB board enters the designated area, and determines that the PCB board completely enters the Specify an image of the area to filter out unnecessary invalid images for subsequent processing, improving the speed and accuracy of PCB inspection. Since the edge detection parameter of the adaptive Canny operator is adaptively generated according to the pixel information of the image, it is not necessary to manually adjust parameters according to specific conditions, and has strong robustness, and achieves high automation of PCB detection.
  • FIG. 5 is a schematic flowchart diagram of a PCB detecting method according to a second embodiment of the present invention.
  • the PCB board detection method includes:
  • the PCB board detecting device may first downsample the image and reduce the image resolution to a predetermined size, wherein the predetermined size may be to keep the height pixel value of the image unchanged. , reducing the width pixel value to a preset threshold, or maintaining the width pixel value of the image unchanged, reducing the height pixel value to a preset threshold, or simultaneously reducing the width and height pixel values of the image to a preset threshold, which may be The actual needs are set, and the present invention is not specifically limited.
  • the image is processed by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptive according to pixel information of the image. generate.
  • the PCB board detecting method provided by the embodiment of the invention reduces the image normalized processing by downsampling the collected image, thereby improving the detection efficiency.
  • FIG. 6 is a schematic structural diagram of a PCB board detecting apparatus according to a third embodiment of the present invention.
  • the PCB board detecting device 300 includes an acquiring unit 310, an image processing unit 320, a statistic unit 330, and a detecting unit 340, wherein:
  • the collecting unit 310 is configured to collect an image of a designated area on a conveying surface of the conveyor belt.
  • the image processing unit 320 is configured to process the image by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the The pixel information of the image is adaptively generated.
  • the image processing unit 320 includes:
  • the pixel obtaining unit 321 is configured to acquire a pixel value range of the image, where the pixel value ranges from [I min , I max ].
  • the calculating unit 322 is configured to calculate a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size.
  • the threshold generating unit 323 is configured to generate the high threshold and the low threshold, wherein the high threshold takes a smaller one of I max and (1+ ⁇ )*m; the low threshold takes I min and ( The larger of the two 1- ⁇ )*m, ⁇ is the empirical parameter.
  • the processing unit 324 is configured to process the image by using the high threshold and the low threshold as a threshold parameter of the Canny operator to obtain an edge image, where the edge image includes a first edge image and a second edge image
  • the high threshold is applied to the image to obtain the first edge image
  • the low threshold is applied to the image to obtain the second edge image.
  • the statistic unit 330 is configured to count the number of non-zero pixels in the edge image.
  • the detecting unit 340 is configured to detect, according to the size relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
  • the relationship between the PCB board and the designated area may include not entering or leaving, partially entering, and fully entering, and the following description will be made one by one in the embodiment of the present invention.
  • the detecting unit 340 selects the non-zero pixels in the edge image corresponding to the designated area 10. The number of zero pixels is compared with a preset first threshold. When the number of non-zero pixels in the edge image corresponding to the designated area 10 is less than the first threshold, the detecting unit 340 determines the The PCB board 20 has not entered or has left the designated area 10, wherein the first threshold may be zero, or a value close to zero.
  • the designated area 10 includes a boundary area 11 , wherein the boundary area 11 is composed of points in the designated area 10 that have a minimum distance to two sides perpendicular to the traveling direction of the conveyor belt that is less than or equal to a predetermined length.
  • the area may set the preset length to one tenth or one-twentieth of the width of the designated area, and the like.
  • the designated area 10 may further include an inner area 12, wherein the inner area 12 is an area other than the boundary area 11 in the designated area 10.
  • the statistic unit 330 separately counts the edge image corresponding to the inner region 12 and the number of non-zero pixels of the edge image corresponding to the boundary region 11, the detecting unit 340 respectively respectively the edge corresponding to the inner region 12
  • the number of non-zero pixels in the image is compared with a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is compared with a preset fourth threshold.
  • the detecting unit 340 determines that the PCB board 20 completely enters the designated area 10.
  • the PCB board detecting apparatus 300 processes the image collected by the collecting unit 310 by the image processing unit 320 to obtain an edge image, and then uses the statistical unit 330 to count the image processing unit 320.
  • the number of non-zero pixels of the edge image is detected by the detecting unit 340 to the extent that the PCB board enters the image capturing field of view, and the image of the PCB board completely enters the image capturing field of view is determined, thereby filtering unnecessary portions for subsequent processing. Invalid images improve the speed and accuracy of PCB inspection. Since the edge detection parameter of the adaptive Canny operator adopted by the image processing unit 320 is adaptively generated according to the pixel information of the image, it is not necessary to manually adjust parameters according to specific conditions, and has strong robustness and realizes PCB. The detection is highly automated.
  • FIG. 8 is a schematic structural diagram of a PCB board detecting apparatus according to a fourth embodiment of the present invention.
  • the PCB board detecting apparatus 400 includes an acquiring unit 410, a normalization unit 420, an image processing unit 430, a statistics unit 440, and a detecting unit 450, wherein:
  • the collecting unit 410 is configured to collect an image of a designated area on a conveying surface of the conveyor belt.
  • the normalization unit 420 is configured to normalize the size of the image.
  • the normalization unit 420 may first downsample the image of the collection unit 410 and reduce the image resolution to a predetermined size, wherein the predetermined size may be the height of the image.
  • the pixel value is unchanged, the width pixel value is lowered to a preset threshold, or the width pixel value of the image is kept unchanged, the height pixel value is lowered to a preset threshold, or the image width and height pixel values are simultaneously lowered to a preset threshold.
  • the image processing unit 430 is configured to process the image by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the The pixel information of the image is adaptively generated.
  • the statistics unit 440 is configured to count the number of non-zero pixels in the edge image.
  • the detecting unit 450 is configured to detect, according to the relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
  • the PCB board detecting apparatus 400 provided by the embodiment of the present invention performs down-sampling on the image collected by the collecting unit 410 by the normalization unit 420, thereby realizing normalization processing of the image, and improving the detection efficiency.
  • first and second are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated.
  • features defining “first” or “second” may include at least one of the features, either explicitly or implicitly.
  • the meaning of "a plurality” is at least two, such as two, three, etc., unless specifically defined otherwise.
  • a "computer-readable medium” can be any apparatus that can contain, store, communicate, propagate, or transport the software for use by the instruction execution system, apparatus, or apparatus, or in conjunction with the instruction execution system, apparatus, or apparatus.
  • computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM).
  • the computer readable medium may even be a paper or other suitable medium on which the software may be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method proceeds to obtain the software electronically and then store it in computer memory.
  • a plurality of steps or methods may be stored in a memory and understood by appropriate instructions, and portions of the invention may be implemented in hardware, software, firmware or a combination thereof.
  • the software or firmware executed by the system is implemented.
  • a discrete logic circuit having logic gates for implementing logic functions on data signals, dedicated to suitable combinational logic gates Integrated circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
  • each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
  • the integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
  • the above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

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

Abstract

A PCB board detection method comprises the following steps: acquiring an image of a specified region (10) on a conveyance surface of a conveyor belt (S201); processing the image by using a Canny operator to obtain an edge image, the Canny operator comprising two parameters: a high threshold and a low threshold, and the high threshold and the low threshold being adaptively generated according to pixel information of the image (S203); counting the number of non-zero pixels in the edge image (S204); and detecting, according to a magnitude relationship between the number of non-zero pixels and at least one of the preset thresholds, a degree of entrance of the PCB board (20) into the specified region (10) (S205). The technical solutions also comprise a PCB board detection apparatus. The PCB board detection method and apparatus have strong robustness, improve efficiency and quality of PCB detection, and realize high automation of PCB detection.

Description

一种PCB板检测方法及装置PCB board detecting method and device 技术领域Technical field
本发明涉及PCB自动光学检测领域,具体是一种PCB板检测方法装置。The invention relates to the field of automatic optical inspection of PCBs, in particular to a device for detecting PCB boards.
背景技术Background technique
采用自动光学检测技术(Automatic Optical Inspection,AOI)作为PCB检测手段已是大势所趋。该技术主要包括:图像采集、图像处理、特征提取和决策判断四个步骤,其中,在图像处理这一步骤中往往需要对采集到的原始图像进行初步分析,以判断原始图像中是否包含完整的PCB板,这对提高PCB检测的效率和质量起着至关重要的作用。然而现有的图像处理方案往往存在鲁棒性低、计算速度慢、操作复杂等问题,无法满足使用要求。The use of Automatic Optical Inspection (AOI) as a means of PCB detection has become a trend. The technology mainly includes four steps: image acquisition, image processing, feature extraction and decision-making. In the step of image processing, it is often necessary to perform preliminary analysis on the collected original image to determine whether the original image contains complete PCB boards, which play a vital role in improving the efficiency and quality of PCB inspection. However, the existing image processing schemes often have problems such as low robustness, slow calculation speed, and complicated operation, which cannot meet the requirements for use.
发明内容Summary of the invention
针对上述问题,本发明的目的在于提供一种PCB板检测方法及装置,实现了快速、准确的PCB板检测,满足了使用要求。In view of the above problems, an object of the present invention is to provide a PCB board detecting method and device, which realizes fast and accurate PCB board testing and satisfies the use requirements.
本发明实施例提供一种PCB板检测方法,包括如下步骤:Embodiments of the present invention provide a PCB board detecting method, including the following steps:
采集传送带的传送面上指定区域的图像;Acquiring an image of a designated area on the conveying surface of the conveyor belt;
利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成;The image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptively generated according to pixel information of the image;
统计所述边缘图像内的非零像素的个数;Counting the number of non-zero pixels in the edge image;
根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。 And detecting, by the relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
作为上述方案的改进,在所述采集传送带的传送面上指定区域的图像之后,在所述利用Canny算子对所述图像进行处理得到边缘图像之前,还包括:As an improvement of the foregoing solution, after the image of the area is specified on the transmission surface of the collection conveyor, before the image is processed by the Canny operator to obtain the edge image, the method further includes:
对所述图像的尺寸进行归一化处理。The size of the image is normalized.
作为上述方案的改进,所述利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成,具体包括:As a modification of the above solution, the image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the The pixel information of the image is adaptively generated, and specifically includes:
获取所述图像的像素取值范围,其中,所述像素取值范围为[Imin,Imax];Obtaining a pixel value range of the image, wherein the pixel takes a value range of [I min , I max ];
计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值;Calculating a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the pixel values of the image are sorted by size;
生成所述高阈值和低阈值,其中,所述高阈值取Imax和(1+σ)*m二者中的较小者;所述低阈值取Imin和(1-σ)*m二者中的较大者,σ为经验参数;Generating the high threshold and the low threshold, wherein the high threshold takes the smaller of I max and (1 + σ) * m; the low threshold takes I min and (1 - σ) * m The larger of them, σ is an empirical parameter;
利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。The image is processed using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
作为上述方案的改进,所述经验参数σ取值为0.33。As a modification of the above scheme, the empirical parameter σ takes a value of 0.33.
作为上述方案的改进,所述统计所述边缘图像内的非零像素的个数,具体包括:As an improvement of the foregoing solution, the counting the number of non-zero pixels in the edge image includes:
遍历所述边缘图像内的所有像素,将像素值不为零的像素标记为非零像素,并统计获取非零像素的个数。The pixels in the edge image are traversed, the pixels whose pixel values are not zero are marked as non-zero pixels, and the number of non-zero pixels is counted.
作为上述方案的改进,所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:As a modification of the foregoing solution, the detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
当判断所述边缘图像内的非零像素的个数少于第一阈值时,确定所述PCB板位于所述指定区域外。When it is determined that the number of non-zero pixels in the edge image is less than the first threshold, it is determined that the PCB board is located outside the designated area.
作为上述方案的改进,所述指定区域包括边界区域,其中,所述边界区域为所述指定区域内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域;As a modification of the above aspect, the designated area includes a boundary area, wherein the boundary area is a point in the specified area that a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt is less than or equal to a predetermined length The area formed;
则所述统计所述边缘图像内的非零像素的个数,为:Then counting the number of non-zero pixels in the edge image is:
统计所述边界区域对应的边缘图像内的非零像素的个数; Counting the number of non-zero pixels in the edge image corresponding to the boundary region;
所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:The detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
当判断所述边界区域对应的边缘图像内的非零像素的个数大于预设的第二阈值时,确定所述PCB板部分进入所述指定区域。When it is determined that the number of non-zero pixels in the edge image corresponding to the boundary region is greater than a preset second threshold, determining that the PCB board portion enters the designated region.
作为上述方案的改进,所述指定区域还包括内部区域,所述内部区域为所述指定区域内除所述边界区域之外的区域;As a modification of the above aspect, the designated area further includes an inner area, the inner area being an area other than the boundary area in the designated area;
则所述统计所述边缘图像内的非零像素的个数,为:Then counting the number of non-zero pixels in the edge image is:
分别统计所述边界区域对应的边缘图像内的非零像素的个数和所述内部区域对应的边缘图像内的非零像素的个数;Statistically counting the number of non-zero pixels in the edge image corresponding to the boundary region and the number of non-zero pixels in the edge image corresponding to the internal region;
所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:The detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
当判断所述内部区域对应的边缘图像内的非零像素的个数大于预设的第三阈值,且所述边界区域对应的边缘图像内的非零像素的个数少于预设的第四阈值时,确定所述PCB板完全进入所述指定区域。When it is determined that the number of non-zero pixels in the edge image corresponding to the inner region is greater than a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region is less than a preset fourth At the threshold, it is determined that the PCB board completely enters the designated area.
本发明还提供一种PCB板检测装置,包括:The invention also provides a PCB board detecting device, comprising:
采集单元,用于采集传送带的传送面上指定区域的图像;An acquisition unit for collecting an image of a designated area on a conveying surface of the conveyor belt;
图像处理单元,用于利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成;An image processing unit, configured to process the image by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the image Pixel information adaptive generation;
统计单元,用于统计所述边缘图像内的非零像素的个数;a statistical unit, configured to count the number of non-zero pixels in the edge image;
检测单元,用于根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。And a detecting unit, configured to detect, according to a magnitude relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
作为上述方案的改进,所述PCB板检测装置还包括:As an improvement of the above solution, the PCB board detecting device further includes:
归一化单元,用于对所述图像的尺寸进行归一化处理。A normalization unit for normalizing the size of the image.
作为上述方案的改进,所述图像处理单元具体包括:As an improvement of the foregoing solution, the image processing unit specifically includes:
像素获取单元,用于获取所述图像的像素取值范围,其中,所述像素取值范围为[Imin,Imax]; a pixel acquisition unit, configured to acquire a pixel value range of the image, where the pixel value range is [I min , I max ];
计算单元,用于计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值;a calculating unit, configured to calculate a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size;
阈值生成单元,用于生成所述高阈值和低阈值,其中,所述高阈值取Imax和(1+σ)*m二者中的较小者;所述低阈值取Imin和(1-σ)*m二者中的较大者,σ为经验参数;a threshold generating unit, configured to generate the high threshold and a low threshold, wherein the high threshold takes a smaller one of I max and (1+σ)*m; the low threshold takes I min and (1) The larger of -σ)*m, σ is an empirical parameter;
处理单元,用于利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。And a processing unit, configured to process the image by using the high threshold and the low threshold as a threshold parameter of the Canny operator to obtain an edge image.
作为上述方案的改进,所述指定区域包括边界区域,其中,所述边界区域为所述指定区域内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域;As a modification of the above aspect, the designated area includes a boundary area, wherein the boundary area is a point in the specified area that a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt is less than or equal to a predetermined length The area formed;
所述统计单元具体用于,统计所述边界区域对应的边缘图像内的非零像素的个数;The statistic unit is specifically configured to: count the number of non-zero pixels in the edge image corresponding to the boundary area;
所述检测单元具体用于,在判断所述边界区域对应的边缘图像内的非零像素的个数大于预设的第二阈值时,确定所述PCB板部分进入所述指定区域。The detecting unit is configured to determine that the PCB board portion enters the designated area when determining that the number of non-zero pixels in the edge image corresponding to the boundary area is greater than a preset second threshold.
作为上述方案的改进,所述指定区域还包括内部区域,其中,所述内部区域为所述指定区域内除所述边界区域之外的区域;As a modification of the above aspect, the designated area further includes an inner area, wherein the inner area is an area other than the boundary area in the designated area;
所述统计单元具体用于,分别统计所述内部区域对应的边缘图像和边界区域对应的边缘图像的非零像素的个数;The statistic unit is specifically configured to separately count the number of non-zero pixels of the edge image corresponding to the inner region and the edge image corresponding to the boundary region;
所述检测单元具体用于,在判断所述内部区域对应的边缘图像内的非零像素的个数大于预设的第三阈值,且所述边界区域对应的边缘图像内的非零像素的个数少于预设的第四阈值时,确定所述PCB板完全进入所述指定区域。The detecting unit is configured to: determine that the number of non-zero pixels in the edge image corresponding to the inner region is greater than a preset third threshold, and the non-zero pixels in the edge image corresponding to the boundary region When the number is less than the preset fourth threshold, it is determined that the PCB board completely enters the designated area.
本发明实施例提供的PCB板检测方法及装置,采用自适应Canny算子对采集到传送带的传送面上指定区域的图像进行分析,检测PCB板进入指定区域的程度,确定所述PCB板完全进入所述指定区域的图像,从而为后续处理过滤掉不必要的无效图像,提高PCB检测的速度和准确度。由于所述自适应Canny算子的边缘检测参数是根据所述图像的像素信息自适应生成,不需要人工根据具 体情况调整参数,具有很强的鲁棒性,实现了PCB检测的高度自动化。The method and device for detecting a PCB board according to an embodiment of the present invention use an adaptive Canny operator to analyze an image of a specified area on a transmission surface of a conveyor belt, and detect the extent to which the PCB board enters a designated area, and determine that the PCB board completely enters. The image of the designated area, thereby filtering out unnecessary invalid images for subsequent processing, improving the speed and accuracy of PCB detection. Since the edge detection parameter of the adaptive Canny operator is adaptively generated according to the pixel information of the image, no manual basis is needed. The body condition adjustment parameters are highly robust and achieve a high degree of automation of PCB inspection.
附图说明DRAWINGS
为了更清楚地说明本发明的技术方案,下面将对实施方式中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the present invention, the drawings used in the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention, which are common in the art. For the skilled person, other drawings can be obtained from these drawings without any creative work.
图1是本发明第一实施例提供的PCB板检测方法的流程示意图。FIG. 1 is a schematic flow chart of a PCB board detecting method according to a first embodiment of the present invention.
图2是本发明第一实施例提供的PCB板部分进入指定区域的示意图。2 is a schematic view of a portion of a PCB board provided in a first embodiment of the present invention entering a designated area.
图3是本发明第一实施例提供的PCB板完全进入指定区域的示意图。FIG. 3 is a schematic diagram of the PCB board provided in the first embodiment of the present invention completely entering a designated area.
图4是本发明第一实施例提供的PCB板未进入或已经离开指定区域的示意图。4 is a schematic diagram of a PCB board according to a first embodiment of the present invention that has not entered or has left a designated area.
图5是本发明第二实施例提供的PCB板检测方法的流程示意图。FIG. 5 is a schematic flow chart of a PCB board detecting method according to a second embodiment of the present invention.
图6是本发明第三实施例提供的PCB板检测装置的结构示意图。FIG. 6 is a schematic structural diagram of a PCB board detecting apparatus according to a third embodiment of the present invention.
图7是图6所示的图像处理单元的结构示意图。FIG. 7 is a schematic structural diagram of the image processing unit shown in FIG. 6.
图8是本发明第四实施例提供的PCB板检测装置的结构示意图。FIG. 8 is a schematic structural diagram of a PCB board detecting apparatus according to a fourth embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例提供一种PCB板检测方法及装置,用于检测PCB板进入图像采集视野的程度,提高PCB自动光学检测的效率和质量。下面分别进行详细的描述。Embodiments of the present invention provide a PCB board detecting method and apparatus for detecting the extent to which a PCB board enters an image acquisition field of view, and improving the efficiency and quality of automatic optical inspection of the PCB. A detailed description will be given below.
请参阅图1,本发明第一实施例提供一种PCB板检测方法,所述PCB板检测方法由PCB板检测装置来实施,至少包括如下步骤: Referring to FIG. 1 , a first embodiment of the present invention provides a PCB board detecting method. The PCB board detecting method is implemented by a PCB board detecting device, and includes at least the following steps:
S101,采集传送带的传送面上指定区域的图像。S101. Acquire an image of a designated area on a conveying surface of the conveyor belt.
在本发明实施例中,所述传送带可沿一定的传送方向连续不断地输送PCB板,所述PCB板检测装置采集输送中的PCB板图像,具体为,所述PCB板检测装置包括摄像头,所述摄像头架设于传送带上方,并实时采集所述传送面上指定区域的图像,其中,所述图像可为彩色图像,也可以是黑白图像。由于相对所述摄像头而言,所述PCB板在不断运动,因此,所述摄像头采集到的所述指定区域的图像中可能存在PCB板部分进入所述指定区域,PCB板完全进入所述指定区域,或者PCB板未进入或已经离开所述指定区域等各种情况。In the embodiment of the present invention, the conveyor belt can continuously transport the PCB board along a certain transmission direction, and the PCB board detecting device collects the image of the PCB board in the transportation. Specifically, the PCB board detecting device includes a camera. The camera is mounted above the conveyor belt and acquires an image of a designated area on the conveying surface in real time, wherein the image may be a color image or a black and white image. Since the PCB board is constantly moving relative to the camera, a PCB board portion may enter the designated area in the image of the designated area collected by the camera, and the PCB board completely enters the designated area. Or, the PCB board does not enter or has left the designated area and the like.
S102,利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成。S102. The image is processed by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptive according to pixel information of the image. generate.
在本发明实施例中,所述Canny算子被普遍用于图像边缘的检测,然而,传统的Canny算子的高阈值和低阈值是预先设定的,无法根据当前的图像的具体情况做自适应调整。In the embodiment of the present invention, the Canny operator is generally used for detecting edge of an image. However, the high threshold and the low threshold of the traditional Canny operator are preset, and cannot be customized according to the current situation of the image. Adapt to the adjustment.
在本发明实施例中,所述PCB板检测装置采用自适应边缘检测的策略,根据所述图像的像素信息自动生成合适的高阈值和低阈值,从而为所述Canny算子提供较优的阈值参数,具体为,In the embodiment of the present invention, the PCB board detecting apparatus adopts an adaptive edge detection strategy, and automatically generates appropriate high thresholds and low thresholds according to pixel information of the image, thereby providing a preferred threshold for the Canny operator. Parameter, specifically,
首先,获取所述图像的像素取值范围。First, the pixel value range of the image is obtained.
在本发明实施例中,所述PCB板检测装置获取所述图像的每个像素点的灰度值,并从这些灰度值中读取出最大值Imax和最小值Imin,此时,所述像素取值范围标记为[Imin,Imax]。In the embodiment of the present invention, the PCB board detecting device acquires a gray value of each pixel of the image, and reads a maximum value I max and a minimum value I min from the gray values. The pixel value range is labeled as [I min , I max ].
然后,计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值。Then, a pixel median value m of the image is calculated, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size.
接着,生成所述高阈值thigh和低阈值tlow,其中,所述高阈值thigh取Imax和(1+σ)*m二者中的较小者,所述低阈值tlow取Imin和(1-σ)*m二者中的较大者。 Next, the high threshold t high and the low threshold t low are generated, wherein the high threshold t high takes the smaller of I max and (1+σ)*m, and the low threshold t low takes I The larger of min and (1-σ)*m.
在本发明实施例中,所述高阈值thigh取Imax和(1+σ)*m二者中的较小者,所述低阈值tlow取Imin和(1-σ)*m二者中的较大者,即thigh=min(Imax,(1+σ)*m),tlow=max(Imin,(1-σ)*m),σ为经验参数。In the embodiment of the present invention, the high threshold t high takes the smaller of I max and (1+σ)*m, and the low threshold t low takes I min and (1-σ)*m The larger of them is t high =min(I max ,(1+σ)*m), t low =max(I min ,(1-σ)*m), and σ is an empirical parameter.
在本发明实施例中,优选地,所述经验参数σ取值为0.33。可以理解的是,所述经验参数σ还可取值为0.2、0.3、0.4或其它任意合适的数值,这些可根据实际的需要进行设置,本发明不做具体的限定。In the embodiment of the present invention, preferably, the empirical parameter σ takes a value of 0.33. It is to be understood that the empirical parameter σ may also have a value of 0.2, 0.3, 0.4 or any other suitable value, which may be set according to actual needs, and is not specifically limited in the present invention.
最后,利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。Finally, the image is processed using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
具体为,在本发明实施例中,所述PCB板检测装置利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。其中,所述canny算子对所述图像处理得到边缘图像的过程可参考Canny算子的计算原理,本发明在此不做说明。Specifically, in the embodiment of the present invention, the PCB board detecting apparatus processes the image by using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image. The process of processing the edge image by the canny operator can refer to the calculation principle of the Canny operator, and the present invention is not described herein.
S103,统计所述边缘图像内的非零像素的个数。S103. Count the number of non-zero pixels in the edge image.
在本发明实施例中,所述PCB板检测装置遍历所述边缘图像内的所有像素,并将像素值不为零的像素标记为非零像素后,统计所述非零像素的个数。In the embodiment of the present invention, the PCB board detecting device traverses all the pixels in the edge image, and marks the pixels whose pixel values are not zero as non-zero pixels, and counts the number of the non-zero pixels.
S104,根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。S104. Detect the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold.
在本发明实施例中,所述PCB板与所述指定区域的关系可包括未进入或者已经离开、部分进入、完全进入,下面本发明实施例将对上述情况逐一进行描述。In the embodiment of the present invention, the relationship between the PCB board and the designated area may include not entering or leaving, partially entering, and fully entering. The following embodiments of the present invention will be described one by one.
请一并参阅图2,对于所述PCB板20未进入或已经离开所述指定区域10情况的判断:Please refer to FIG. 2 together for the judgment that the PCB board 20 has not entered or has left the designated area 10:
在本发明实施例中,所述PCB板检测装置统计所述指定区域10对应的边缘图像内的非零像素的个数后,并分别将所述边缘图像内的非零像素的个数与预设的第一阈值进行比较,当所述边缘图像内的非零像素的个数少于所述第一阈值,则确定所述PCB板20未进入或已经离开所述指定区域10,其中,所述第 一阈值可为零,或接近于零的数值。In the embodiment of the present invention, the PCB board detecting device counts the number of non-zero pixels in the edge image corresponding to the designated area 10, and respectively compares the number of non-zero pixels in the edge image with The first threshold is compared, and when the number of non-zero pixels in the edge image is less than the first threshold, it is determined that the PCB board 20 has not entered or has left the designated area 10, wherein Narrative A threshold can be zero, or a value close to zero.
请一并参阅图3,对于所述PCB板20部分进入所述指定区域10情况的判断:所述指定区域10包括边界区域11,其中,所述边界区域11为所述指定区域10内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域,例如,可将所述预设的长度设置为所述指定区域的宽度的十分之一或二十分之一等。所述PCB板检测装置统计所述边界区域11对应的边缘图像内的非零像素的个数后,将所述边界区域11对应的边缘图像内内的非零像素的个数与预设的第二阈值进行比较。当所述边界区域11对应的边缘图像内的非零像素的个数大于所述第二阈值时,则确定所述PCB板20部分进入所述指定区域10。Please refer to FIG. 3 together for the determination that the PCB board 20 partially enters the designated area 10: the designated area 10 includes a boundary area 11, wherein the boundary area 11 is within the designated area 10. An area composed of points having a minimum distance of two sides perpendicular to the advancing direction of the conveyor belt being less than or equal to a predetermined length, for example, the preset length may be set to one tenth of the width of the designated area Or one in twenty. After the PCB board detecting device counts the number of non-zero pixels in the edge image corresponding to the boundary region 11, the number of non-zero pixels in the edge image corresponding to the boundary region 11 is preset with The two thresholds are compared. When the number of non-zero pixels in the edge image corresponding to the boundary region 11 is greater than the second threshold, it is determined that the PCB board 20 partially enters the designated area 10.
请一并参阅图4,对于所述PCB板20完全进入所述指定区域10情况的判断:Please refer to FIG. 4 together for the judgment that the PCB board 20 completely enters the designated area 10:
在本发明实施例中,所述指定区域10还可包括内部区域12,其中,所述内部区域12为所述指定区域10内除所述边界区域11之外的区域。所述PCB板检测装置分别统计所述内部区域12对应的边缘图像内和所述边界区域11对应的边缘图像内的非零像素的个数后,并分别将所述内部区域12对应的边缘图像内的非零像素的个数与预设的第三阈值进行比较,及将所述边界区域11对应的边缘图像内内的非零像素的个数与预设的第四阈值进行比较。当所述内部区域12对应的边缘图像内的非零像素的个数大于所述第三阈值,且所述边界区域11对应的边缘图像内的非零像素的个数少于所述第四阈值时,则确定所述PCB板20完全进入所述指定区域10。In the embodiment of the present invention, the designated area 10 may further include an inner area 12, wherein the inner area 12 is an area other than the boundary area 11 in the designated area 10. The PCB board detecting device separately counts the number of non-zero pixels in the edge image corresponding to the inner region 12 and the edge image corresponding to the boundary region 11, and respectively respectively outputs the edge image corresponding to the inner region 12 The number of non-zero pixels in the comparison is compared with a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is compared with a preset fourth threshold. When the number of non-zero pixels in the edge image corresponding to the inner region 12 is greater than the third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is less than the fourth threshold At this time, it is determined that the PCB board 20 completely enters the designated area 10.
本发明实施例提供的PCB板检测方法,采用自适应Canny算子对采集到传送带的传送面上指定区域的图像进行分析,检测PCB板进入指定区域的程度,确定所述PCB板完全进入所述指定区域的图像,从而为后续处理过滤掉不必要的无效图像,提高PCB检测的速度和准确度。由于所述自适应Canny算子的边缘检测参数是根据所述图像的像素信息自适应生成,不需要人工根据具体情况调整参数,具有很强的鲁棒性,实现了PCB检测的高度自动化。 The method for detecting a PCB board according to an embodiment of the present invention uses an adaptive Canny operator to analyze an image of a specified area on a transmission surface of the conveyor belt, and detects the extent to which the PCB board enters the designated area, and determines that the PCB board completely enters the Specify an image of the area to filter out unnecessary invalid images for subsequent processing, improving the speed and accuracy of PCB inspection. Since the edge detection parameter of the adaptive Canny operator is adaptively generated according to the pixel information of the image, it is not necessary to manually adjust parameters according to specific conditions, and has strong robustness, and achieves high automation of PCB detection.
请参阅图5,图5是本发明第二实施例提供的PCB检测方法的流程示意图。所述PCB板检测方法包括:Please refer to FIG. 5. FIG. 5 is a schematic flowchart diagram of a PCB detecting method according to a second embodiment of the present invention. The PCB board detection method includes:
S201,采集传送带的传送面上指定区域的图像。S201. Acquire an image of a designated area on a conveying surface of the conveyor belt.
S202,对所述图像的尺寸进行归一化处理。S202: normalize the size of the image.
在本发明实施例中,所述PCB板检测装置可先对所述图像进行下采样,并降低图像分辨率至预定的大小,其中,所述预定的大小可为保持图像的高度像素值不变,降低宽度像素值至预设的阈值、或保持图像的宽度像素值不变,降低高度像素值至预设的阈值,或者同时降低图像的宽度和高度像素值至预设的阈值,这些可根据实际的需要进行设置,本发明不做具体的限定。In the embodiment of the present invention, the PCB board detecting device may first downsample the image and reduce the image resolution to a predetermined size, wherein the predetermined size may be to keep the height pixel value of the image unchanged. , reducing the width pixel value to a preset threshold, or maintaining the width pixel value of the image unchanged, reducing the height pixel value to a preset threshold, or simultaneously reducing the width and height pixel values of the image to a preset threshold, which may be The actual needs are set, and the present invention is not specifically limited.
S203,利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成。S203. The image is processed by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptive according to pixel information of the image. generate.
S204,统计所述边缘图像内的非零像素的个数。S204. Count the number of non-zero pixels in the edge image.
S205,根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。S205. Detect a degree of entering the PCB into the designated area according to a size relationship between the number of the non-zero pixels and the at least one preset threshold.
本发明实施例提供的PCB板检测方法,通过对采集的图像进行下采样,从而实现图像的归一化处理,提高了检测的效率。The PCB board detecting method provided by the embodiment of the invention reduces the image normalized processing by downsampling the collected image, thereby improving the detection efficiency.
请一并参阅图6,图6是本发明第三实施例提供的PCB板检测装置的结构示意图。所述PCB板检测装置300包括采集单元310、图像处理单元320、统计单元330及检测单元340,其中:Please refer to FIG. 6. FIG. 6 is a schematic structural diagram of a PCB board detecting apparatus according to a third embodiment of the present invention. The PCB board detecting device 300 includes an acquiring unit 310, an image processing unit 320, a statistic unit 330, and a detecting unit 340, wherein:
所述采集单元310,用于采集传送带的传送面上指定区域的图像。The collecting unit 310 is configured to collect an image of a designated area on a conveying surface of the conveyor belt.
所述图像处理单元320,用于利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成。The image processing unit 320 is configured to process the image by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the The pixel information of the image is adaptively generated.
请一并参阅图6,在本发明实施例中,所述图像处理单元320包括: Referring to FIG. 6, in the embodiment of the present invention, the image processing unit 320 includes:
像素获取单元321,用于获取所述图像的像素取值范围,其中,所述像素取值范围为[Imin,Imax]。The pixel obtaining unit 321 is configured to acquire a pixel value range of the image, where the pixel value ranges from [I min , I max ].
计算单元322,用于计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值。The calculating unit 322 is configured to calculate a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size.
阈值生成单元323,用于生成所述高阈值和低阈值,其中,所述高阈值取Imax和(1+σ)*m二者中的较小者;所述低阈值取Imin和(1-σ)*m二者中的较大者,σ为经验参数。The threshold generating unit 323 is configured to generate the high threshold and the low threshold, wherein the high threshold takes a smaller one of I max and (1+σ)*m; the low threshold takes I min and ( The larger of the two 1-σ)*m, σ is the empirical parameter.
处理单元324,用于利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像,其中,所述边缘图像包括第一边缘图像和第二边缘图像,所述高阈值作用于所述图像得到所述第一边缘图像,所述低阈值作用于所述图像得到所述第二边缘图像。The processing unit 324 is configured to process the image by using the high threshold and the low threshold as a threshold parameter of the Canny operator to obtain an edge image, where the edge image includes a first edge image and a second edge image The high threshold is applied to the image to obtain the first edge image, and the low threshold is applied to the image to obtain the second edge image.
所述统计单元330,用于统计所述边缘图像内的非零像素的个数。The statistic unit 330 is configured to count the number of non-zero pixels in the edge image.
所述检测单元340,用于根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。The detecting unit 340 is configured to detect, according to the size relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
在本发明实施例中,所述PCB板与所述指定区域的关系可包括未进入或者已经离开、部分进入、完全进入、,下面本发明实施例将对上述情况逐一进行描述。In the embodiment of the present invention, the relationship between the PCB board and the designated area may include not entering or leaving, partially entering, and fully entering, and the following description will be made one by one in the embodiment of the present invention.
请一并参阅图2,对于所述PCB板20未进入或已经离开所述指定区域10情况的判断:Please refer to FIG. 2 together for the judgment that the PCB board 20 has not entered or has left the designated area 10:
在本发明实施例中,所述统计单元330统计所述指定区域10对应的边缘图像内的非零像素的个数后,所述检测单元340将所述指定区域10对应的边缘图像内的非零像素的个数与预设的第一阈值进行比较,当所述指定区域10对应的边缘图像内的非零像素的个数少于所述第一阈值,则所述检测单元340确定所述PCB板20未进入或已经离开所述指定区域10,其中,所述第一阈值可为零,或接近于零的数值。In the embodiment of the present invention, after the statistics unit 330 counts the number of non-zero pixels in the edge image corresponding to the designated area 10, the detecting unit 340 selects the non-zero pixels in the edge image corresponding to the designated area 10. The number of zero pixels is compared with a preset first threshold. When the number of non-zero pixels in the edge image corresponding to the designated area 10 is less than the first threshold, the detecting unit 340 determines the The PCB board 20 has not entered or has left the designated area 10, wherein the first threshold may be zero, or a value close to zero.
请一并参阅图3,对于所述PCB板20部分进入所述指定区域10情况的判断: Please refer to FIG. 3 together for the judgment that the PCB board 20 partially enters the designated area 10:
所述指定区域10包括边界区域11,其中,所述边界区域11为所述指定区域10内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域,例如,可将所述预设的长度设置为所述指定区域的宽度的十分之一或二十分之一等。所述统计单元330统计所述边界区域11对应的边缘图像内的非零像素的个数后,所述检测单元340将所述边界区域11对应的边缘图像内的非零像素的个数与预设的第二阈值进行比较。当所述边界区域11对应的边缘图像内的非零像素的个数大于所述第二阈值时,则所述检测单元340确定所述PCB板20部分进入所述指定区域10。The designated area 10 includes a boundary area 11 , wherein the boundary area 11 is composed of points in the designated area 10 that have a minimum distance to two sides perpendicular to the traveling direction of the conveyor belt that is less than or equal to a predetermined length. The area, for example, may set the preset length to one tenth or one-twentieth of the width of the designated area, and the like. After the statistic unit 330 counts the number of non-zero pixels in the edge image corresponding to the boundary region 11, the detecting unit 340 compares the number of non-zero pixels in the edge image corresponding to the boundary region 11 with The second threshold is set for comparison. When the number of non-zero pixels in the edge image corresponding to the boundary region 11 is greater than the second threshold, the detecting unit 340 determines that the PCB board 20 partially enters the designated region 10.
请一并参阅图4,对于所述PCB板20完全进入所述指定区域10情况的判断:Please refer to FIG. 4 together for the judgment that the PCB board 20 completely enters the designated area 10:
在本发明实施例中,所述指定区域10还可包括内部区域12,其中,所述内部区域12为所述指定区域10内除所述边界区域11之外的区域。所述统计单元330分别统计所述内部区域12对应的边缘图像和所述边界区域11对应的边缘图像的非零像素的个数后,所述检测单元340分别将所述内部区域12对应的边缘图像内的非零像素的个数与预设的第三阈值进行比较,及将所述边界区域11对应的边缘图像内的非零像素的个数与预设的第四阈值进行比较。当所述内部区域12对应的边缘图像内的非零像素的个数大于所述第三阈值,且所述边界区域11对应的边缘图像内的非零像素的个数少于所述第四阈值时,则所述检测单元340确定所述PCB板20完全进入所述指定区域10。In the embodiment of the present invention, the designated area 10 may further include an inner area 12, wherein the inner area 12 is an area other than the boundary area 11 in the designated area 10. After the statistic unit 330 separately counts the edge image corresponding to the inner region 12 and the number of non-zero pixels of the edge image corresponding to the boundary region 11, the detecting unit 340 respectively respectively the edge corresponding to the inner region 12 The number of non-zero pixels in the image is compared with a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is compared with a preset fourth threshold. When the number of non-zero pixels in the edge image corresponding to the inner region 12 is greater than the third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region 11 is less than the fourth threshold The detecting unit 340 determines that the PCB board 20 completely enters the designated area 10.
本发明实施例提供的PCB板检测装置300,通过所述图像处理单元320对所述采集单元310采集的图像进行处理得到边缘图像,再利用所述统计单元330统计所述图像处理单元320得到的边缘图像的非零像素的个数,通过所述检测单元340检测PCB板进入图像采集视野的程度,确定所述PCB板完全进入所述图像采集视野的图像,从而为后续处理过滤掉不必要的无效图像,提高PCB检测的速度和准确度。由于所述图像处理单元320采用的自适应Canny算子的边缘检测参数是根据所述图像的像素信息自适应生成,不需要人工根据具体情况调整参数,具有很强的鲁棒性,实现了PCB检测的高度自动化。 The PCB board detecting apparatus 300 provided by the embodiment of the present invention processes the image collected by the collecting unit 310 by the image processing unit 320 to obtain an edge image, and then uses the statistical unit 330 to count the image processing unit 320. The number of non-zero pixels of the edge image is detected by the detecting unit 340 to the extent that the PCB board enters the image capturing field of view, and the image of the PCB board completely enters the image capturing field of view is determined, thereby filtering unnecessary portions for subsequent processing. Invalid images improve the speed and accuracy of PCB inspection. Since the edge detection parameter of the adaptive Canny operator adopted by the image processing unit 320 is adaptively generated according to the pixel information of the image, it is not necessary to manually adjust parameters according to specific conditions, and has strong robustness and realizes PCB. The detection is highly automated.
请一并参阅图8,图8是本发明第四实施例提供的PCB板检测装置的结构示意图。所述PCB板检测装置400包括采集单元410、归一化单元420、图像处理单元430、统计单元440及检测单元450,其中:Please refer to FIG. 8. FIG. 8 is a schematic structural diagram of a PCB board detecting apparatus according to a fourth embodiment of the present invention. The PCB board detecting apparatus 400 includes an acquiring unit 410, a normalization unit 420, an image processing unit 430, a statistics unit 440, and a detecting unit 450, wherein:
所述采集单元410,用于采集传送带的传送面上指定区域的图像。The collecting unit 410 is configured to collect an image of a designated area on a conveying surface of the conveyor belt.
所述归一化单元420,用于对所述图像的尺寸进行归一化处理。The normalization unit 420 is configured to normalize the size of the image.
在本发明实施例中,所述归一化单元420可先对所述采集单元410图像进行下采样,并降低图像分辨率至预定的大小,其中,所述预定的大小可为保持图像的高度像素值不变,降低宽度像素值至预设的阈值、或保持图像的宽度像素值不变,降低高度像素值至预设的阈值,或者同时降低图像的宽度和高度像素值至预设的阈值,这些可根据实际的需要进行设置,本发明不做具体的限定。In the embodiment of the present invention, the normalization unit 420 may first downsample the image of the collection unit 410 and reduce the image resolution to a predetermined size, wherein the predetermined size may be the height of the image. The pixel value is unchanged, the width pixel value is lowered to a preset threshold, or the width pixel value of the image is kept unchanged, the height pixel value is lowered to a preset threshold, or the image width and height pixel values are simultaneously lowered to a preset threshold. These can be set according to actual needs, and the invention is not specifically limited.
所述图像处理单元430,用于利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成。The image processing unit 430 is configured to process the image by using a Canny operator to obtain an edge image, where the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the The pixel information of the image is adaptively generated.
所述统计单元440,用于统计所述边缘图像内的非零像素的个数。The statistics unit 440 is configured to count the number of non-zero pixels in the edge image.
所述检测单元450,用于根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。The detecting unit 450 is configured to detect, according to the relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
本发明实施例提供的PCB板检测装置400,通过所述归一化单元420对所述采集单元410采集的图像进行下采样,从而实现图像的归一化处理,提高了检测的效率。The PCB board detecting apparatus 400 provided by the embodiment of the present invention performs down-sampling on the image collected by the collecting unit 410 by the normalization unit 420, thereby realizing normalization processing of the image, and improving the detection efficiency.
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。 In the description of the present specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" and the like means a specific feature described in connection with the embodiment or example. A structure, material or feature is included in at least one embodiment or example of the invention. In the present specification, the schematic representation of the above terms is not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. In addition, various embodiments or examples described in the specification, as well as features of various embodiments or examples, may be combined and combined.
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本发明的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。Moreover, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, features defining "first" or "second" may include at least one of the features, either explicitly or implicitly. In the description of the present invention, the meaning of "a plurality" is at least two, such as two, three, etc., unless specifically defined otherwise.
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。Any process or method description in the flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a particular logical function or process. And the scope of the preferred embodiments of the invention includes additional implementations, in which the functions may be performed in a substantially simultaneous manner or in an opposite order depending on the functions involved, in the order shown or discussed. It will be understood by those skilled in the art to which the embodiments of the present invention pertain.
在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输软件以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述软件的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述软件,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer readable medium, Used in conjunction with, or in conjunction with, an instruction execution system, apparatus, or device (eg, a computer-based system, a system including a processor, or other system that can fetch instructions and execute instructions from an instruction execution system, apparatus, or device) Or use with equipment. For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the software for use by the instruction execution system, apparatus, or apparatus, or in conjunction with the instruction execution system, apparatus, or apparatus. More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM). In addition, the computer readable medium may even be a paper or other suitable medium on which the software may be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method proceeds to obtain the software electronically and then store it in computer memory.
在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方 式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。In the above-described embodiments, a plurality of steps or methods may be stored in a memory and understood by appropriate instructions, and portions of the invention may be implemented in hardware, software, firmware or a combination thereof. The software or firmware executed by the system is implemented. For example, if implemented in hardware, and in another implementation As in the formula, it can be implemented by any one of the following techniques known in the art or a combination thereof: a discrete logic circuit having logic gates for implementing logic functions on data signals, dedicated to suitable combinational logic gates Integrated circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过软件来指令相关的硬件完成,所述的软件可以存储于一种计算机可读存储介质中,该软件在执行时,包括方法实施例的步骤之一或其组合。One of ordinary skill in the art can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by software to instruct related hardware, and the software can be stored in a computer readable storage medium. When executed, one or a combination of the steps of the method embodiments is included.
此外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. The integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。 The above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like. Although the embodiments of the present invention have been shown and described, it is understood that the above-described embodiments are illustrative and are not to be construed as limiting the scope of the invention. The embodiments are subject to variations, modifications, substitutions and variations.

Claims (13)

  1. 一种PCB板检测方法,其特征在于,包括如下步骤:A method for detecting a PCB board, comprising the steps of:
    采集传送带的传送面上指定区域的图像;Acquiring an image of a designated area on the conveying surface of the conveyor belt;
    利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成;The image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are adaptively generated according to pixel information of the image;
    统计所述边缘图像内的非零像素的个数;Counting the number of non-zero pixels in the edge image;
    根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。And detecting, by the relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
  2. 根据权利要求1所述的PCB板检测方法,其特征在于,在所述采集传送带的传送面上指定区域的图像之后,在所述利用Canny算子对所述图像进行处理得到边缘图像之前,还包括:The PCB board detecting method according to claim 1, wherein after the image of the area is specified on the conveying surface of the collecting conveyor, before the image is processed by the Canny operator to obtain an edge image, include:
    对所述图像的尺寸进行归一化处理。The size of the image is normalized.
  3. 根据权利要求1所述的PCB板检测方法,其特征在于,所述利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成,具体包括:The PCB board detecting method according to claim 1, wherein the image is processed by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and The high threshold and the low threshold are adaptively generated according to the pixel information of the image, and specifically include:
    获取所述图像的像素取值范围,其中,所述像素取值范围为[Imin,Imax];Obtaining a pixel value range of the image, wherein the pixel takes a value range of [I min , I max ];
    计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值;Calculating a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the pixel values of the image are sorted by size;
    生成所述高阈值和低阈值,其中,所述高阈值取Imax和(1+σ)*m二者中的较小者;所述低阈值取Imin和(1-σ)*m二者中的较大者,σ为经验参数;Generating the high threshold and the low threshold, wherein the high threshold takes the smaller of I max and (1 + σ) * m; the low threshold takes I min and (1 - σ) * m The larger of them, σ is an empirical parameter;
    利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。 The image is processed using the high threshold and the low threshold as threshold parameters of the Canny operator to obtain an edge image.
  4. 根据权利要求3所述的PCB板检测方法,其特征在于,所述经验参数σ取值为0.33。The PCB board detecting method according to claim 3, wherein the empirical parameter σ has a value of 0.33.
  5. 根据权利要求1所述的PCB板检测方法,其特征在于,所述统计所述边缘图像内的非零像素的个数,具体包括:The method for detecting a PCB according to claim 1, wherein the counting the number of non-zero pixels in the edge image comprises:
    遍历所述边缘图像内的所有像素,将像素值不为零的像素标记为非零像素,并统计获取非零像素的个数。The pixels in the edge image are traversed, the pixels whose pixel values are not zero are marked as non-zero pixels, and the number of non-zero pixels is counted.
  6. 根据权利要求1所述的PCB板检测方法,其特征在于,所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:The PCB board detecting method according to claim 1, wherein the detecting the extent to which the PCB board enters the designated area according to the magnitude relationship of the number of the non-zero pixels and the at least one preset threshold ,for:
    当判断所述边缘图像内的非零像素的个数少于第一阈值时,确定所述PCB板位于所述指定区域外。When it is determined that the number of non-zero pixels in the edge image is less than the first threshold, it is determined that the PCB board is located outside the designated area.
  7. 根据权利要求1所述的PCB板检测方法,其特征在于,所述指定区域包括边界区域,其中,所述边界区域为所述指定区域内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域;The PCB board detecting method according to claim 1, wherein the designated area includes a boundary area, wherein the boundary area is a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt in the designated area An area consisting of points that are less than or equal to a predetermined length;
    则所述统计所述边缘图像内的非零像素的个数,为:Then counting the number of non-zero pixels in the edge image is:
    统计所述边界区域对应的边缘图像内的非零像素的个数;Counting the number of non-zero pixels in the edge image corresponding to the boundary region;
    所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:The detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
    当判断所述边界区域对应的边缘图像内的非零像素的个数大于预设的第二阈值时,确定所述PCB板部分进入所述指定区域。When it is determined that the number of non-zero pixels in the edge image corresponding to the boundary region is greater than a preset second threshold, determining that the PCB board portion enters the designated region.
  8. 根据权利要求7所述的PCB板检测方法,其特征在于,所述指定区域还包括内部区域,所述内部区域为所述指定区域内除所述边界区域之外的区域;The PCB board detecting method according to claim 7, wherein the designated area further includes an inner area, wherein the inner area is an area other than the boundary area in the designated area;
    则所述统计所述边缘图像内的非零像素的个数,为: Then counting the number of non-zero pixels in the edge image is:
    分别统计所述边界区域对应的边缘图像内的非零像素的个数和所述内部区域对应的边缘图像内的非零像素的个数;Statistically counting the number of non-zero pixels in the edge image corresponding to the boundary region and the number of non-zero pixels in the edge image corresponding to the internal region;
    所述根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度,为:The detecting the extent to which the PCB board enters the designated area according to the relationship between the number of the non-zero pixels and the at least one preset threshold is:
    当判断所述内部区域对应的边缘图像内的非零像素的个数大于预设的第三阈值,且所述边界区域对应的边缘图像内的非零像素的个数少于预设的第四阈值时,确定所述PCB板完全进入所述指定区域。When it is determined that the number of non-zero pixels in the edge image corresponding to the inner region is greater than a preset third threshold, and the number of non-zero pixels in the edge image corresponding to the boundary region is less than a preset fourth At the threshold, it is determined that the PCB board completely enters the designated area.
  9. 一种PCB板检测装置,其特征在于,包括:A PCB board detecting device, comprising:
    采集单元,用于采集传送带的传送面上指定区域的图像;An acquisition unit for collecting an image of a designated area on a conveying surface of the conveyor belt;
    图像处理单元,用于利用Canny算子对所述图像进行处理得到边缘图像,其中,所述Canny算子包括高阈值和低阈值两个参数,且所述高阈值和低阈值根据所述图像的像素信息自适应生成;An image processing unit, configured to process the image by using a Canny operator to obtain an edge image, wherein the Canny operator includes two parameters of a high threshold and a low threshold, and the high threshold and the low threshold are according to the image Pixel information adaptive generation;
    统计单元,用于统计所述边缘图像内的非零像素的个数;a statistical unit, configured to count the number of non-zero pixels in the edge image;
    检测单元,用于根据所述非零像素的个数与至少一个预设的阈值的大小关系,检测所述PCB板进入所述指定区域的程度。And a detecting unit, configured to detect, according to a magnitude relationship between the number of the non-zero pixels and the at least one preset threshold, the extent to which the PCB board enters the designated area.
  10. 根据权利要求9所述的PCB板检测装置,其特征在于,所述PCB板检测装置还包括:The PCB board detecting device according to claim 9, wherein the PCB board detecting device further comprises:
    归一化单元,用于对所述图像的尺寸进行归一化处理。A normalization unit for normalizing the size of the image.
  11. 根据权利要求9所述的PCB板检测装置,其特征在于,所述图像处理单元具体包括:The PCB board detecting device according to claim 9, wherein the image processing unit specifically comprises:
    像素获取单元,用于获取所述图像的像素取值范围,其中,所述像素取值范围为[Imin,Imax];a pixel acquisition unit, configured to acquire a pixel value range of the image, where the pixel value range is [I min , I max ];
    计算单元,用于计算所述图像的像素中值m,其中,所述像素中值m为将所述图像的各个像素值按大小进行排序后,序号位于中间的像素值; a calculating unit, configured to calculate a pixel median value m of the image, wherein the pixel median value m is a pixel value in which the serial number is in the middle after the respective pixel values of the image are sorted by size;
    阈值生成单元,用于生成所述高阈值和低阈值,其中,所述高阈值取Imax和(1+σ)*m二者中的较小者;所述低阈值取Imin和(1-σ)*m二者中的较大者,σ为经验参数;a threshold generating unit, configured to generate the high threshold and a low threshold, wherein the high threshold takes a smaller one of I max and (1+σ)*m; the low threshold takes I min and (1) The larger of -σ)*m, σ is an empirical parameter;
    处理单元,用于利用所述高阈值和低阈值作为所述Canny算子的阈值参数对所述图像进行处理,得到边缘图像。And a processing unit, configured to process the image by using the high threshold and the low threshold as a threshold parameter of the Canny operator to obtain an edge image.
  12. 根据权利要求9所述的PCB板检测装置,其特征在于,所述指定区域包括边界区域,其中,所述边界区域为所述指定区域内的到与传送带前进方向垂直的两条边的最小距离小于或者等于一预设的长度的点所组成的区域;The PCB board detecting device according to claim 9, wherein the designated area includes a boundary area, wherein the boundary area is a minimum distance to two sides perpendicular to a traveling direction of the conveyor belt in the designated area An area consisting of points that are less than or equal to a predetermined length;
    所述统计单元具体用于,统计所述边界区域对应的边缘图像内的非零像素的个数;The statistic unit is specifically configured to: count the number of non-zero pixels in the edge image corresponding to the boundary area;
    所述检测单元具体用于,在判断所述边界区域对应的边缘图像内的非零像素的个数大于预设的第二阈值时,确定所述PCB板部分进入所述指定区域。The detecting unit is configured to determine that the PCB board portion enters the designated area when determining that the number of non-zero pixels in the edge image corresponding to the boundary area is greater than a preset second threshold.
  13. 根据权利要求12所述的PCB板检测装置,其特征在于,所述指定区域还包括内部区域,其中,所述内部区域为所述指定区域内除所述边界区域之外的区域;The PCB board detecting device according to claim 12, wherein the designated area further includes an inner area, wherein the inner area is an area other than the boundary area in the designated area;
    所述统计单元具体用于,分别统计所述内部区域对应的边缘图像和所述边界区域对应的边缘图像内的非零像素的个数;The statistic unit is configured to separately count the edge image corresponding to the inner region and the number of non-zero pixels in the edge image corresponding to the boundary region;
    所述检测单元具体用于,在判断所述内部区域对应的边缘图像内的非零像素的个数大于预设的第三阈值,且所述边界区域对应的边缘图像内的非零像素的个数少于预设的第四阈值时,确定所述PCB板完全进入所述指定区域。 The detecting unit is configured to: determine that the number of non-zero pixels in the edge image corresponding to the inner region is greater than a preset third threshold, and the non-zero pixels in the edge image corresponding to the boundary region When the number is less than the preset fourth threshold, it is determined that the PCB board completely enters the designated area.
PCT/CN2016/096546 2015-08-25 2016-08-24 Pcb board detection method and apparatus WO2017032308A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510527487.3A CN105139397B (en) 2015-08-25 2015-08-25 A kind of pcb board detection method and device
CN201510527487.3 2015-08-25

Publications (1)

Publication Number Publication Date
WO2017032308A1 true WO2017032308A1 (en) 2017-03-02

Family

ID=54724729

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/096546 WO2017032308A1 (en) 2015-08-25 2016-08-24 Pcb board detection method and apparatus

Country Status (2)

Country Link
CN (1) CN105139397B (en)
WO (1) WO2017032308A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109035236A (en) * 2018-07-27 2018-12-18 深圳市闿思科技有限公司 Casting fin detection method and device
CN112215827A (en) * 2020-10-20 2021-01-12 中广核核电运营有限公司 Electromigration region detection method and device, computer equipment and storage medium
CN113252625A (en) * 2021-04-27 2021-08-13 歌尔光学科技有限公司 Glue path detection method for glue with fluorescence effect
CN115131287A (en) * 2022-05-16 2022-09-30 奥蒂玛光学科技(深圳)有限公司 Image processing method, area detection method, detection device and storage medium
CN115601364A (en) * 2022-12-14 2023-01-13 惠州威尔高电子有限公司(Cn) Golden finger circuit board detection method based on image analysis
CN116703889A (en) * 2023-07-31 2023-09-05 深圳市普能达电子有限公司 Flexible circuit board patch abnormality detection method
CN116758077A (en) * 2023-08-18 2023-09-15 山东航宇游艇发展有限公司 Online detection method and system for surface flatness of surfboard

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105139397B (en) * 2015-08-25 2017-12-19 广州视源电子科技股份有限公司 A kind of pcb board detection method and device
CN106469482A (en) * 2016-09-05 2017-03-01 深圳怡化电脑股份有限公司 Bank note crosses the border detection method, device and Banknote deposting/drawing out equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060023934A1 (en) * 2004-07-30 2006-02-02 Fujitsu Limited Component edge detecting method, component edge detecting program and component inspection apparatus
CN102034101A (en) * 2010-10-22 2011-04-27 广东工业大学 Method for quickly positioning circular mark in PCB visual detection
CN102496161A (en) * 2011-12-13 2012-06-13 浙江欧威科技有限公司 Method for extracting contour of image of printed circuit board (PCB)
CN104268857A (en) * 2014-09-16 2015-01-07 湖南大学 Rapid sub pixel edge detection and locating method based on machine vision
CN105139397A (en) * 2015-08-25 2015-12-09 广州视源电子科技股份有限公司 PCB board detection method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102456131A (en) * 2010-11-02 2012-05-16 屏东科技大学 Obstacle sensing method
CN102436656A (en) * 2011-09-05 2012-05-02 同济大学 Animal-diversity monitoring method based on computer vision
CN103600707B (en) * 2013-11-06 2016-08-17 同济大学 A kind of parking position detection device and method of Intelligent parking system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060023934A1 (en) * 2004-07-30 2006-02-02 Fujitsu Limited Component edge detecting method, component edge detecting program and component inspection apparatus
CN102034101A (en) * 2010-10-22 2011-04-27 广东工业大学 Method for quickly positioning circular mark in PCB visual detection
CN102496161A (en) * 2011-12-13 2012-06-13 浙江欧威科技有限公司 Method for extracting contour of image of printed circuit board (PCB)
CN104268857A (en) * 2014-09-16 2015-01-07 湖南大学 Rapid sub pixel edge detection and locating method based on machine vision
CN105139397A (en) * 2015-08-25 2015-12-09 广州视源电子科技股份有限公司 PCB board detection method and device

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109035236A (en) * 2018-07-27 2018-12-18 深圳市闿思科技有限公司 Casting fin detection method and device
CN109035236B (en) * 2018-07-27 2024-02-23 深圳市闿思科技有限公司 Casting burr detection method and device
CN112215827A (en) * 2020-10-20 2021-01-12 中广核核电运营有限公司 Electromigration region detection method and device, computer equipment and storage medium
CN113252625A (en) * 2021-04-27 2021-08-13 歌尔光学科技有限公司 Glue path detection method for glue with fluorescence effect
CN115131287A (en) * 2022-05-16 2022-09-30 奥蒂玛光学科技(深圳)有限公司 Image processing method, area detection method, detection device and storage medium
CN115601364A (en) * 2022-12-14 2023-01-13 惠州威尔高电子有限公司(Cn) Golden finger circuit board detection method based on image analysis
CN115601364B (en) * 2022-12-14 2023-04-07 惠州威尔高电子有限公司 Golden finger circuit board detection method based on image analysis
CN116703889A (en) * 2023-07-31 2023-09-05 深圳市普能达电子有限公司 Flexible circuit board patch abnormality detection method
CN116703889B (en) * 2023-07-31 2023-10-03 深圳市普能达电子有限公司 Flexible circuit board patch abnormality detection method
CN116758077A (en) * 2023-08-18 2023-09-15 山东航宇游艇发展有限公司 Online detection method and system for surface flatness of surfboard
CN116758077B (en) * 2023-08-18 2023-10-20 山东航宇游艇发展有限公司 Online detection method and system for surface flatness of surfboard

Also Published As

Publication number Publication date
CN105139397B (en) 2017-12-19
CN105139397A (en) 2015-12-09

Similar Documents

Publication Publication Date Title
WO2017032308A1 (en) Pcb board detection method and apparatus
US8755589B2 (en) Measurement of belt wear through edge detection of a raster image
CN110930390B (en) Chip pin missing detection method based on semi-supervised deep learning
US8774514B2 (en) Method of and apparatus for classifying image using histogram analysis, and method of and apparatus for recognizing text image using the histogram analysis
CN110866903B (en) Ping-pong ball identification method based on Hough circle transformation technology
CN115239704B (en) Accurate detection and repair method for wood surface defects
CN101464418B (en) Flaw detection method and apparatus
KR20190088089A (en) Apparatus and method for detecting defects on welding surface
CN113340909B (en) Glue line defect detection method based on machine vision
CN113781415B (en) Defect detection method, device, equipment and medium for X-ray image
CN110738644A (en) automobile coating surface defect detection method and system based on deep learning
CN114127784A (en) Method, computer program product and computer readable medium for generating a mask for a camera stream
CN111476804A (en) Method, device and equipment for efficiently segmenting carrier roller image and storage medium
US20170103536A1 (en) Counting apparatus and method for moving objects
JP2014020926A (en) Surface defect inspection device and surface defect inspection method
CN117635620B (en) Circuit board defect detection method and system based on image processing
CN109784145B (en) Target detection method based on depth map and storage medium
CN115861315A (en) Defect detection method and device
CN108982544B (en) Method for detecting defective parts of printed circuit board
JP2004062519A (en) Lane mark detector
TWI549097B (en) A method of detecting images of appearance of electronic components and computer readable media thereof
KR101646838B1 (en) Counting method for track images
CN117593302B (en) Defective part tracing method and system
Eom et al. Automated X-ray Defect Inspection on Occluded BGA Balls Using Hybrid Algorithm.
Wu et al. Automatic optical inspection for chip components based on local principal wave probability

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16838566

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16838566

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16838566

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 29.01.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16838566

Country of ref document: EP

Kind code of ref document: A1