CN112070738A - Method and system for detecting nose bridge of mask - Google Patents
Method and system for detecting nose bridge of mask Download PDFInfo
- Publication number
- CN112070738A CN112070738A CN202010912532.8A CN202010912532A CN112070738A CN 112070738 A CN112070738 A CN 112070738A CN 202010912532 A CN202010912532 A CN 202010912532A CN 112070738 A CN112070738 A CN 112070738A
- Authority
- CN
- China
- Prior art keywords
- mask
- image
- detected
- nose bridge
- length
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 230000009466 transformation Effects 0.000 claims abstract description 41
- 238000001514 detection method Methods 0.000 claims abstract description 39
- PXFBZOLANLWPMH-UHFFFAOYSA-N 16-Epiaffinine Natural products C1C(C2=CC=CC=C2N2)=C2C(=O)CC2C(=CC)CN(C)C1C2CO PXFBZOLANLWPMH-UHFFFAOYSA-N 0.000 claims abstract description 27
- 230000003044 adaptive effect Effects 0.000 claims abstract description 24
- 238000001914 filtration Methods 0.000 claims abstract description 11
- 230000000877 morphologic effect Effects 0.000 claims description 22
- 239000011159 matrix material Substances 0.000 claims description 8
- 238000007781 pre-processing Methods 0.000 claims description 6
- 230000002950 deficient Effects 0.000 claims description 5
- 238000004458 analytical method Methods 0.000 claims description 3
- 238000004364 calculation method Methods 0.000 claims description 3
- 238000000605 extraction Methods 0.000 claims description 2
- 238000012790 confirmation Methods 0.000 abstract 1
- 238000004519 manufacturing process Methods 0.000 description 7
- 239000007787 solid Substances 0.000 description 6
- 230000008569 process Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 238000003915 air pollution Methods 0.000 description 2
- 230000003628 erosive effect Effects 0.000 description 2
- 238000002372 labelling Methods 0.000 description 2
- 238000003672 processing method Methods 0.000 description 2
- 239000002994 raw material Substances 0.000 description 2
- 208000003464 asthenopia Diseases 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000000916 dilatatory effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 208000015181 infectious disease Diseases 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 229910000679 solder Inorganic materials 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B07—SEPARATING SOLIDS FROM SOLIDS; SORTING
- B07C—POSTAL SORTING; SORTING INDIVIDUAL ARTICLES, OR BULK MATERIAL FIT TO BE SORTED PIECE-MEAL, e.g. BY PICKING
- B07C5/00—Sorting according to a characteristic or feature of the articles or material being sorted, e.g. by control effected by devices which detect or measure such characteristic or feature; Sorting by manually actuated devices, e.g. switches
- B07C5/04—Sorting according to size
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B07—SEPARATING SOLIDS FROM SOLIDS; SORTING
- B07C—POSTAL SORTING; SORTING INDIVIDUAL ARTICLES, OR BULK MATERIAL FIT TO BE SORTED PIECE-MEAL, e.g. BY PICKING
- B07C5/00—Sorting according to a characteristic or feature of the articles or material being sorted, e.g. by control effected by devices which detect or measure such characteristic or feature; Sorting by manually actuated devices, e.g. switches
- B07C5/36—Sorting apparatus characterised by the means used for distribution
- B07C5/361—Processing or control devices therefor, e.g. escort memory
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/02—Measuring arrangements characterised by the use of optical techniques for measuring length, width or thickness
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/24—Measuring arrangements characterised by the use of optical techniques for measuring contours or curvatures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/20—Image enhancement or restoration using local operators
- G06T5/30—Erosion or dilatation, e.g. thinning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/155—Segmentation; Edge detection involving morphological operators
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/187—Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
- G06T7/62—Analysis of geometric attributes of area, perimeter, diameter or volume
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30124—Fabrics; Textile; Paper
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30204—Marker
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Quality & Reliability (AREA)
- Geometry (AREA)
- Image Analysis (AREA)
Abstract
Description
技术领域technical field
本发明涉及一种口罩生产检测技术领域,尤其是涉及一种口罩鼻梁检测方法及系统。The invention relates to the technical field of production and detection of masks, in particular to a method and system for detecting the bridge of the nose of a mask.
背景技术Background technique
随着工业化和城市化进程,空气污染越来越加剧,口罩产品是人们抵抗空气污染的常用品,在北方雾霾和沙尘暴严重的区域,口罩已经成了必不可少的生活依赖品,口罩在大批量生产过程中,由于原材料、生产机器和人员操作等多种原因,会产生很多种缺陷的口罩产品,如鼻梁未安装等,这种缺陷品如果流到市场环节,会给使用者带来很多不便,更会给口罩生产商带来经济损失。With the process of industrialization and urbanization, air pollution has become more and more serious. Mask products are commonly used by people to resist air pollution. In the areas with severe haze and sandstorms in the north, masks have become an indispensable daily dependency. In the mass production process, due to various reasons such as raw materials, production machines and personnel operations, there will be many kinds of defective mask products, such as the bridge of the nose is not installed, etc. If such defective products flow to the market, it will bring users. Many inconveniences will bring economic losses to mask manufacturers.
由于口罩生产已经全面趋向于自动化,生产要求和质量要求越来越高,一般口罩生产商依靠人眼逐个分辨,效率极低,导致目前的口罩品质检测过程中,费时费力,且容易对检测人员造成视觉疲劳,使产品存在质量隐患,造成大量产品返工和原材料浪费。Since the production of masks has been fully automated, the production requirements and quality requirements are getting higher and higher. Generally, mask manufacturers rely on the human eye to distinguish them one by one, and the efficiency is extremely low. As a result, the current mask quality inspection process is time-consuming and laborious, and it is easy to detect personnel. Cause visual fatigue, make products have hidden quality risks, and cause a large number of product rework and raw material waste.
在口罩鼻梁的检测中,其中一种检测方法是采用固定阈值的方法,将整个图像进行二值化处理,然后在二值化的图像中或者限定的局部位置中,根据面积或者长度来选择鼻梁;这种方法的缺点是,由于拍照时的口罩位置不确定,且口罩生产时一致性问题,会出现面积或者长度在要求的范围内,实际上却不是鼻梁区域的情况,即容易产生误判,且由于鼻梁成像原因,鼻梁与周围的对比度差异不明显,也会导致鼻梁检测失败或者检测误差较大。In the detection of the nose bridge of the mask, one of the detection methods is to use a fixed threshold method to binarize the entire image, and then select the nose bridge according to the area or length in the binarized image or in a limited local position. The disadvantage of this method is that due to the uncertainty of the position of the mask when taking pictures and the consistency problem during the production of the mask, the area or length will be within the required range, but it is not actually the bridge of the nose, which is prone to misjudgment. , and due to the imaging of the nose bridge, the contrast difference between the nose bridge and the surrounding is not obvious, which will also lead to the failure of the nose bridge detection or the large detection error.
发明内容SUMMARY OF THE INVENTION
基于此,有必要针对现有技术的不足,提供一种口罩鼻梁检测方法及系统,自动对口罩进行检测,避免出现漏检与误检的现象,提高检测的效率与口罩质量,且降低口罩生产的成本。Based on this, it is necessary to provide a method and system for detecting the nose bridge of a mask in view of the shortcomings of the prior art, which can automatically detect the mask, avoid the phenomenon of missed detection and false detection, improve the efficiency of detection and the quality of the mask, and reduce the production of masks. the cost of.
为解决上述技术问题,本发明所采用的技术方案是:一种口罩鼻梁检测方法,其包括如下步骤:In order to solve the above-mentioned technical problems, the technical scheme adopted in the present invention is: a method for detecting the bridge of the nose of a mask, which comprises the following steps:
(1)、采集待检测口罩的初始图像Img1;(1), collect the initial image Img1 of the mask to be detected;
(2)、建立图像坐标系,根据固定阈值算法对初始图像Img1进行二值化处理,得到初始二值化图像Img2;(2), establish image coordinate system, carry out binarization processing to initial image Img1 according to fixed threshold algorithm, obtain initial binarization image Img2;
(3)、构建圆形结构元素,对初始二值化图像Img2进行形态学闭处理,得到闭运算的二值化图像Img3;(3), construct the circular structural element, carry out morphological closure processing to the initial binarized image Img2, obtain the binarized image Img3 of closed operation;
(4)、构建矩形结构元素,对闭运算的二值化图像Img3进行形态学开处理,得到开运算的二值化图像Img4;(4), construct rectangular structural element, carry out morphological opening processing to the binarized image Img3 of closing operation, obtain the binarized image Img4 of opening operation;
(5)、通过Two-Pass算法对开运算的二值化图像Img4进行连通域判断,获取开运算的二值化图像Img4中的所有连通域,并根据开运算的二值化图像Img4中的连通域找出二值化图像Img4中连通域对应的轮廓,得到初始口罩轮廓集合Contours;(5), carry out connected domain judgment on the binarized image Img4 of the opening operation by the Two-Pass algorithm, obtain all connected domains in the binarized image Img4 of the opening operation, and according to the binary image Img4 of the opening operation. The connected domain finds the contour corresponding to the connected domain in the binarized image Img4, and obtains the initial mask contour set Contour s ;
(6)、根据预设的口罩周长Lms,通过公式计算初始口罩轮廓集合Contours中符合要求的轮廓数量,获得口罩轮廓集合Contourm;其中,预设的口罩周长Lms为已转化成像素长度的标准口罩周长,CLm为初始口罩轮廓集合Contours中连通域对应的轮廓长度;(6), according to the preset mask circumference L ms , through the formula Calculate the number of contours that meet the requirements in the initial mask contour set Contour s , and obtain the mask contour set Contour m ; wherein, the preset mask perimeter L ms is the standard mask perimeter that has been converted into pixel length, and CL m is the initial mask contour set. Contour length corresponding to the connected domain in Contour s ;
(7)、判断口罩轮廓集合Contourm中的轮廓数量,若口罩轮廓集合Contourm中的轮廓数量为0或大于1,则转入步骤(22);若口罩轮廓集合Contourm中的轮廓数量为1,则转入步骤(8);(7), judge the contour quantity in the mask contour set Contour m , if the contour quantity in the mask contour set Contour m is 0 or greater than 1, then go to step (22); If the contour quantity in the mask contour set Contour m is 1, then go to step (8);
(8)、获取口罩轮廓集合Contourm的最小外接矩形,根据最小外接矩形的长度、宽度、在图像坐标系中的矩形中心坐标、在图像坐标系中的矩形角度得出待检测口罩的长度Ls、宽度Ws、在图像坐标系的中心坐标(Xs,Ys)、在图像坐标系的角度As参数信息,根据预设的口罩尺寸,来判定待检测口罩的尺寸是否符合要求,若待检测口罩的长度及宽度在预设的口罩尺寸范围内,则转入步骤(8);若待检测口罩的长度及宽度超出预设的口罩尺寸范围,则转入步骤(22);其中,在图像坐标系中的矩形角度是以最小外接矩形的长边和图像坐标系中X轴形成的角度;(8), obtain the minimum circumscribed rectangle of the mask contour set Contour m , obtain the length Ls of the mask to be detected according to the length and width of the minimum circumscribed rectangle, the rectangle center coordinates in the image coordinate system, and the rectangular angle in the image coordinate system , width Ws, the center coordinates (Xs, Ys) in the image coordinate system, the angle As parameter information in the image coordinate system, according to the preset mask size, to determine whether the size of the mask to be detected meets the requirements, if the size of the mask to be detected is If the length and width are within the preset mask size range, then go to step (8); if the length and width of the mask to be detected exceed the preset mask size range, then go to step (22); wherein, in the image coordinate system The rectangle angle in is the angle formed by the long side of the smallest circumscribed rectangle and the X axis in the image coordinate system;
(9)、在步骤(8)获取的待检测口罩的中心坐标(Xs,Ys)、角度As不变的条件下,以待检测口罩的四个顶点为基准点分别沿待检测口罩的长度方向减去预设长度Lr1、再沿待检测口罩的宽度方向减去预设宽度Wr1,生成鼻梁检测的外区域矩形Ro;(9), under the condition that the center coordinates (Xs, Ys) and the angle As of the mask to be detected obtained in step (8) remain unchanged, take the four vertices of the mask to be detected as the reference points respectively along the length direction of the mask to be detected Subtract the preset length Lr1, and then subtract the preset width Wr1 along the width direction of the mask to be detected to generate the outer area rectangle Ro for nose bridge detection;
(10)、在步骤(8)获取的待检测口罩的中心坐标(Xs,Ys)、角度As不变的条件下,以待检测口罩的四个顶点为基准点分别沿待检测口罩的长度方向减去预设长度Lr2、再沿待检测口罩的宽度方向减去预设宽度Wr2,生成鼻梁检测的内区域矩形Ri;(10), under the condition that the center coordinates (Xs, Ys) and the angle As of the mask to be detected obtained in step (8) remain unchanged, take the four vertices of the mask to be detected as the reference points respectively along the length direction of the mask to be detected Subtract the preset length Lr2, and then subtract the preset width Wr2 along the width direction of the mask to be detected to generate the inner area rectangle Ri for nose bridge detection;
(11)、对鼻梁检测的外区域矩形Ro和鼻梁检测的内区域矩形Ri进行区域相减,得到鼻梁的检测区域Rnose,然后将鼻梁的检测区域Rnose以外的图像区域的像素点的灰度值设定为0以获得鼻梁所在位置对应的图像Img5;(11), perform regional subtraction on the outer area rectangle Ro of nose bridge detection and the inner area rectangle Ri of nose bridge detection to obtain the detection area Rnose of the bridge of the nose, and then use the gray value of the pixel of the image area other than the detection area Rnose of the bridge of the nose. Set to 0 to obtain the image Img5 corresponding to the position of the bridge of the nose;
(12)、对鼻梁所在位置对应的图像Img5进行线性变换,得到增强图像Img6,并获得增强图像Img6中像素点对应的灰度值;(12), carry out linear transformation to the image Img5 corresponding to the position of the bridge of the nose, obtain the enhanced image Img6, and obtain the gray value corresponding to the pixel point in the enhanced image Img6;
(13)、对增强图像Img6进行均值滤波处理,根据公式得到均值滤波图像Img7,其中,src1(x,y)为图像Img6在(x,y)处像素点的灰度值,dst1(x,y)为图像Img7在(x,y)处像素点的灰度值,h(k,l)为滤波核,k,l表示滤波核的大小,k,l均为奇数;(13), carry out mean filter processing to the enhanced image Img6, according to the formula Obtain the mean filtered image Img7, where src1(x, y) is the gray value of the pixel point at (x, y) of the image Img6, and dst1(x, y) is the pixel point of the image Img7 at (x, y) The gray value of the point Gray value, h(k,l) is the filter kernel, k,l is the size of the filter kernel, k,l are odd numbers;
(14)、对均值滤波图像Img7进行自适应阈值处理,得到自适应二值化图像Img8;(14), carry out self-adaptive threshold value processing to mean filter image Img7, obtain self-adaptive binarization image Img8;
(15)、构建矩形结构元素,对自适应二值化图像Img8进行先腐蚀后膨胀的二值形态学预处理操作获得图像Img9;(15), constructing a rectangular structural element, and performing a binary morphological preprocessing operation of first eroding and then dilating the adaptive binarized image Img8 to obtain an image Img9;
(16)、通过Two-Pass算法对图像Img9进行连通域判断,获取图像Img9中的所有连通域,并根据图像Img9中的连通域找出图像Img9中连通域对应的轮廓,得到初始鼻梁轮廓集合Contourc;(16), carry out connected domain judgment on image Img9 by Two-Pass algorithm, obtain all connected domains in the image Img9, and find out the corresponding contour of the connected domain in the image Img9 according to the connected domain in the image Img9, obtain the initial nose bridge outline set Contour c ;
(17)、根据预设的鼻梁长度,通过公式计算初始鼻梁轮廓集合Contourc中符合要求的轮廓数量,获得鼻梁轮廓集合Contourn;(17), according to the preset length of the bridge of the nose, through the formula Calculate the number of contours that meet the requirements in the initial nose bridge contour set Contour c , and obtain the nose bridge contour set Contour n ;
其中,预设的鼻梁长度Lns为已转化成像素长度的标准鼻梁长度,CLs为初始鼻梁轮廓集合Contourc中连通域对应的轮廓长度;Wherein, the preset nose bridge length L ns is the standard nose bridge length that has been converted into pixel length, and CL s is the contour length corresponding to the connected domain in the initial nose bridge contour set Contour c ;
(18)、判断鼻梁轮廓集合Contourn中的轮廓数量,若鼻梁轮廓集合Contourn中的轮廓数量为0或大于1,则转入步骤(22);若鼻梁轮廓集合Contourm中的轮廓数量为1,则转入步骤(19);(18), judge the contour quantity in the nose bridge contour set Contour n , if the contour quantity in the nose bridge contour set Contour n is 0 or greater than 1, then go to step (22); If the contour quantity in the nose bridge contour set Contour m is 1, then go to step (19);
(19)、获取鼻梁轮廓集合Contourn的最小外接矩形,根据最小外接矩形的长度、在图像坐标系中的矩形中心坐标得出待检测鼻梁的长度及待检测鼻梁的中心坐标(Xns,Yns);(19), obtain the minimum circumscribed rectangle of the nose bridge contour set Contour n , obtain the length of the nose bridge to be detected and the center coordinates (Xns, Yns) of the nose bridge to be detected according to the length of the minimum circumscribed rectangle and the center coordinates of the rectangle in the image coordinate system ;
(20)、根据预设的鼻梁长度与步骤(18)中得出的待检测鼻梁的长度进行比较,判断待检测鼻梁的长度是否满足要求,当待检测鼻梁的长度减去鼻梁的标准长度的绝对值不大于预设的鼻梁长度公差时,则转入步骤(21);当待检测鼻梁的长度减去鼻梁的标准长度的绝对值大于预设的鼻梁长度公差时,则转入步骤(22);(20), compare the length of the bridge of nose to be detected according to the length of the bridge of the nose to be detected obtained in step (18), judge whether the length of the bridge of the nose to be detected meets the requirements, when the length of the bridge of the nose to be detected deducts the standard length of the bridge of the nose When the absolute value is not greater than the preset nose bridge length tolerance, then go to step (21); When the absolute value of the length of the nose bridge to be detected minus the standard length of the nose bridge is greater than the preset nose bridge length tolerance, then go to step (22) );
(21)、构建变换矩阵Mc,根据构建的变换矩阵Mc对口罩中心坐标(Xs,Ys)和待检测鼻梁中心坐标(Xns,Yns)进行仿射变换,得到经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc),获得绝对值Labs=|Ysc-Ysc|,如果绝对值Labs≤预设的鼻梁偏位值,则判定待检测口罩为良品,所述待检测口罩输送至产品合格区;如果Labs>预设的鼻梁偏位值,则转入步骤(22);(21), construct a transformation matrix M c , perform affine transformation on the mask center coordinates (Xs, Ys) and the center coordinates (Xns, Yns) of the bridge of the nose to be detected according to the constructed transformation matrix M c to obtain the mask after affine transformation The center coordinates (Xsc, Ysc) and the center coordinates (Xnsc, Ynsc) of the nose bridge after affine transformation, obtain the absolute value Labs=|Ysc-Ysc|, if the absolute value Labs ≤ the preset nose bridge deviation value, then judge The mask to be detected is a good product, and the mask to be detected is delivered to the product qualified area; if Labs > the preset nose bridge offset value, then go to step (22);
(22)、判定待检测口罩为瑕疵品,将待检测口罩送至产品不合格区内。(22) Determine that the mask to be tested is a defective product, and send the mask to be tested to the unqualified area of the product.
一种口罩鼻梁检测系统,其包括A mask nose bridge detection system, comprising
图像采集单元,用于采集待检测口罩的初始图像Img1;The image acquisition unit is used to collect the initial image Img1 of the mask to be detected;
图像处理单元,用于通过固定阈值算法获得初始二值化图像Img2、通过形态学闭处理得到闭运算的二值化图像Img3、通过形态学开处理得到开运算的二值化图像Img4、通过线性变换得到增强图像Img6、通过均值滤波处理得到均值滤波图像Img7、通过自适应阈值处理得到自适应二值化图像Img8及通过二值形态学预处理操作获得图像Img9;The image processing unit is used to obtain an initial binarized image Img2 through a fixed threshold algorithm, obtain a closed-operation binarized image Img3 through morphological closing processing, obtain an open-operation binarized image Img4 through morphological opening processing, and obtain an open-operation binarized image Img4 through morphological closing processing. Transform to obtain an enhanced image Img6, obtain a mean value filtered image Img7 through mean filtering, obtain an adaptive binarized image Img8 through adaptive threshold processing, and obtain an image Img9 through a binary morphological preprocessing operation;
图像标记单元,用于通过Two-Pass算法对开运算的二值化图像Img4进行连通域判断获取口罩轮廓集合Contourm及通过Two-Pass算法对图像Img9进行连通域判断得到初始鼻梁轮廓集合Contourc;The image labeling unit is used to judge the connected domain of the binarized image Img4 of the split operation by the Two-Pass algorithm to obtain the mask contour set Contour m and to judge the connected domain of the image Img9 by the Two-Pass algorithm to obtain the initial nose bridge contour set Contour c ;
分析计算单元,用于获得待检测口罩的长度Ls、宽度Ws、待检测口罩在图像坐标系的中心坐标(Xs,Ys)、待检测口罩在图像坐标系的角度As、待检测鼻梁的长度、待检测鼻梁的中心坐标(Xns,Yns);The analysis and calculation unit is used to obtain the length Ls, width Ws of the mask to be detected, the center coordinates (Xs, Ys) of the mask to be detected in the image coordinate system, the angle As of the mask to be detected in the image coordinate system, the length of the bridge of the nose to be detected, The center coordinates of the bridge of the nose to be detected (Xns, Yns);
图像判定单元,用于判定待检测口罩的尺寸是否符合要求、待检测鼻梁的长度是否满足要求、判定根据经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc)获得的绝对值Labs=|Ysc-Ysc|是否满足要求。The image determination unit is used to determine whether the size of the mask to be detected meets the requirements, whether the length of the bridge of the nose to be detected meets the requirements, and the determination is based on the center coordinates (Xsc, Ysc) of the mask after affine transformation and the bridge of the nose after affine transformation. Whether the absolute value Labs=|Ysc-Ysc| obtained by the center coordinates (Xnsc, Ynsc) meets the requirements.
综上所述,本发明一种口罩鼻梁检测方法及系统通过二值化处理方式对口罩的初始图像进行处理,后找出口罩轮廓集合Contourm的最小外接矩形,进而获得待检测口罩的长度Ls、宽度Ws、在图像坐标系的中心坐标(Xs,Ys)、在图像坐标系的角度As参数信息,再通过外区域矩形Ro及内区域矩形Ri得到鼻梁的检测区域Rnose,然后在判断的鼻梁的检测区域Rnose内,通过对图像进行滤波,并通过自适应阈值处理生成自适应二值化图像,对检测范围内的自适应二值化图像进行连通域确认,获得鼻梁轮廓集合Contourn,再通过最小外接矩形方法得到鼻梁的外形尺寸及中心坐标,然后对待检测鼻梁的长度与鼻梁的标准长度进行比较,以及对经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc)进行比较,从而有效对待检测口罩的鼻梁长度和鼻梁位置的质量进行判定。To sum up, a method and system for detecting the bridge of the nose of a mask of the present invention processes the initial image of the mask by means of binarization, and then finds the minimum circumscribed rectangle of the mask contour set Contour m , and then obtains the length Ls of the mask to be detected. , the width Ws, the center coordinates (Xs, Ys) in the image coordinate system, the angle As parameter information in the image coordinate system, and then obtain the detection area Rnose of the nose bridge through the outer area rectangle Ro and the inner area rectangle Ri, and then determine the nose bridge. In the detection area Rnose , the adaptive binarized image is generated by filtering the image, and the adaptive binarized image is generated by adaptive thresholding. The external dimensions and center coordinates of the bridge of the nose are obtained by the minimum circumscribed rectangle method, and then the length of the bridge to be detected is compared with the standard length of the bridge of the nose, and the center coordinates (Xsc, Ysc) of the mask after affine transformation and the affine transformation are compared. The center coordinates (Xnsc, Ynsc) of the posterior bridge of the nose are compared, so as to effectively determine the length of the bridge of the nose and the quality of the location of the bridge of the nose of the mask to be detected.
附图说明Description of drawings
图1为本发明一种口罩鼻梁检测系统的结构示意图。Fig. 1 is the structural representation of a kind of mask nose bridge detection system of the present invention.
具体实施方式Detailed ways
为能进一步了解本发明的特征、技术手段以及所达到的具体目的、功能,下面结合附图与具体实施方式对本发明作进一步详细描述。In order to further understand the features, technical means, and specific goals and functions of the present invention, the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.
本发明一种口罩鼻梁检测方法,包括以下步骤:A method for detecting the bridge of the nose of a mask of the present invention comprises the following steps:
(1)、对传送带上的待检测口罩进行拍照,采集待检测口罩的初始图像Img1;(1), the mask to be detected on the conveyor belt is photographed, and the initial image Img1 of the mask to be detected is collected;
(2)、建立图像坐标系,根据固定阈值算法对初始图像Img1进行二值化处理,得到初始二值化图像Img2,其中,固定阈值算法公式为:(2), establish the image coordinate system, carry out binarization processing to the initial image Img1 according to the fixed threshold algorithm, obtain the initial binarized image Img2, wherein, the fixed threshold algorithm formula is:
其中,src(x,y)为初始图像Img1在(x,y)处像素点的灰度值,dst(x,y)为初始二值化图像Img2在(x,y)处像素点的灰度值,thresh和maxval为预设的口罩提取灰度值,在本实施例中,thresh设定为210,maxval设定为255,即根据固定阈值算法对初始图像Img1进行二值化处理时,当src(x,y)>thresh时,初始二值化图像Img2中dst(x,y)=0,当src(x,y)≤thresh时,初始二值化图像Img2中dst(x,y)=maxval;其中,在初始二值化图像Img2中(x,y)处像素点的灰度值只有0或255两种。Among them, src(x, y) is the gray value of the pixel at (x, y) of the initial image Img1, and dst(x, y) is the gray value of the pixel at (x, y) of the initial binarized image Img2 degree value, thresh and maxval are the preset grayscale values of mask extraction, in this embodiment, thresh is set to 210, and maxval is set to 255, that is, when the initial image Img1 is binarized according to the fixed threshold algorithm, When src(x,y)>thresh, dst(x,y)=0 in the initial binarized image Img2, and when src(x,y)≤thresh, dst(x,y) in the initial binarized image Img2 )=maxval; wherein, in the initial binarized image Img2, the gray value of the pixel at (x, y) is only 0 or 255.
(3)、构建半径为9个像素长度的圆形结构元素,圆形结构元素中心位于圆形结构元素圆心处,对初始二值化图像Img2进行形态学闭处理,用于填充初始二值化图像Img2上焊点处的小孔及亮的干扰点,得到闭运算的二值化图像Img3;其中,形态学闭处理方法是对初始二值化图像Img2进行先膨胀,再腐蚀的运算方法,将膨胀的圆形结构元素及腐蚀的圆形结构元素对初始二值化图像Img2进行处理,腐蚀的圆形结构元素及膨胀的圆形结构元素均设定为实心圆形状,实心圆的半径设定为9个像素长度。(3), construct a circular structural element with a radius of 9 pixels in length, the center of the circular structural element is located at the center of the circular structural element, and perform morphological closing processing on the initial binarized image Img2 for filling the initial binarization The small holes and bright interference points at the solder joints on the image Img2 obtain a closed operation binarized image Img3; wherein, the morphological closed processing method is to first dilate and then corrode the initial binarized image Img2. The circular structuring elements and the corroded circular structuring elements are processed on the initial binarized image Img2, the corroded circular structuring elements and the dilated circular structuring elements are all set to the shape of a solid circle, and the radius of the solid circle is set to 9 pixels long.
(4)、构建25像素*25像素尺寸的矩形结构元素,矩形结构元素的中心位于矩形结构元素的中心,对闭运算的二值化图像Img3进行形态学开处理,得到开运算的二值化图像Img4,用于去掉闭运算的二值化图像Img3中耳带及背景皮带的感染效果;其中,形态学开处理方法是对闭运算的二值化图像Img3进行先腐蚀,再膨胀的运算方法,将腐蚀的矩形结构元素及膨胀的矩形结构元素对闭运算的二值化图像Img3进行处理,腐蚀的矩形结构元素和膨胀的矩形结构元素均设定为实心矩形形状,实心矩形形状的长、宽分别设定为25像素长度及25像素长度。(4), construct a rectangular structural element with a size of 25 pixels*25 pixels, the center of the rectangular structural element is located in the center of the rectangular structural element, perform morphological opening processing on the binarized image Img3 of the closing operation, and obtain the binarization of the opening operation. The image Img4 is used to remove the infection effect of the ear belt and the background belt in the binarized image Img3 of the closed operation; wherein, the morphological opening processing method is to first erode the closed operation of the binarized image Img3, and then dilate the operation method , the eroded rectangular structuring elements and the expanded rectangular structuring elements are processed on the closed-operation binarized image Img3, the eroded rectangular structuring elements and the expanded rectangular structuring elements are both set as solid rectangular shapes, and the length of the solid rectangular shape, The width is set to 25 pixels long and 25 pixels long, respectively.
(5)、通过Two-Pass算法对开运算的二值化图像Img4进行连通域判断,获取开运算的二值化图像Img4中的所有连通域,并根据开运算的二值化图像Img4中的连通域找出二值化图像Img4中连通域对应的轮廓,得到初始口罩轮廓集合Contours,开运算的二值化图像Img4中的连通域对应的轮廓是指由多个像素点组成的曲线,根据曲线上像素点的数量来获得连通域对应的轮廓长度,比如连通域对应的轮廓长度为100,即表示连通域对应的轮廓是由100个像素点组成。其中,Two-pass算法为已知技术,在此不必赘述。(5), carry out connected domain judgment on the binarized image Img4 of the opening operation by the Two-Pass algorithm, obtain all connected domains in the binarized image Img4 of the opening operation, and according to the binary image Img4 of the opening operation. The connected domain finds the contour corresponding to the connected domain in the binarized image Img4, obtains the initial mask contour set Contour s , and the contour corresponding to the connected domain in the binarized image Img4 of the opening operation refers to a curve composed of multiple pixel points, The length of the contour corresponding to the connected domain is obtained according to the number of pixels on the curve. For example, the length of the contour corresponding to the connected domain is 100, which means that the contour corresponding to the connected domain is composed of 100 pixels. Among them, the Two-pass algorithm is a known technology, and it is unnecessary to describe it here.
(6)、根据预设的口罩周长Lms,通过公式计算初始口罩轮廓集合Contours中符合要求的轮廓数量,获得口罩轮廓集合Contourm;其中,预设的口罩周长Lms为已转化成像素长度的标准口罩周长,CLm为初始口罩轮廓集合Contours中连通域对应的轮廓长度;在本实施例中,以毫米为单位,会先将预设的口罩周长转换成像素长度,即像素点数量,转化公式为:(6), according to the preset mask circumference L ms , through the formula Calculate the number of contours that meet the requirements in the initial mask contour set Contour s , and obtain the mask contour set Contour m ; wherein, the preset mask perimeter L ms is the standard mask perimeter that has been converted into pixel length, and CL m is the initial mask contour set. The contour length corresponding to the connected domain in the Contour s ; in this embodiment, in millimeters, the preset mask perimeter will first be converted into a pixel length, that is, the number of pixels, and the conversion formula is:
Lpixel=Lreal/RptrLpixel=Lreal/Rptr
其中,Lpixel表示像素点数量,Lreal表示以毫米为单位的预设的口罩周长,Rptr为像素实际比率,也就是一个像素代表以毫米为单位的实际长度,像素实际比率Rptr的值由相机标定得到,本实施例中像素实际比率Rptr的值由相机标定得到的方法是将打印有两个黑色圆点的标定板放在相机下拍照获得标定图像,其中,标定板上黑色圆点半径为6mm、两黑色圆点间距为80mm,根据标定图像算出像素实际比率Rptr。Among them, Lpixel represents the number of pixels, Lreal represents the preset mask perimeter in millimeters, Rptr is the actual ratio of pixels, that is, a pixel represents the actual length in millimeters, and the value of the actual pixel ratio Rptr is calibrated by the camera Obtained, in this embodiment, the value of the actual pixel ratio Rptr is obtained by calibrating the camera by placing the calibration plate printed with two black dots under the camera to take pictures to obtain a calibration image, wherein the radius of the black dots on the calibration plate is 6mm , The distance between the two black dots is 80mm, and the actual pixel ratio Rptr is calculated according to the calibration image.
(7)、判断口罩轮廓集合Contourm中的轮廓数量,若口罩轮廓集合Contourm中的轮廓数量为0或大于1,则转入步骤(22);若口罩轮廓集合Contourm中的轮廓数量为1,则转入步骤(8)。(7), judge the contour quantity in the mask contour set Contour m , if the contour quantity in the mask contour set Contour m is 0 or greater than 1, then go to step (22); If the contour quantity in the mask contour set Contour m is 1, then go to step (8).
(8)、根据最小外接矩形算法,获取口罩轮廓集合Contourm的最小外接矩形,根据最小外接矩形的长度、宽度、在图像坐标系中的矩形中心坐标、在图像坐标系中的矩形角度得出待检测口罩的长度Ls、宽度Ws、在图像坐标系的中心坐标(Xs,Ys)、在图像坐标系的角度As等参数信息,根据预设的口罩尺寸,来判定待检测口罩的尺寸是否符合要求,若待检测口罩的长度及宽度在预设的口罩尺寸范围内,则转入步骤(8);若待检测口罩的长度及宽度超出预设的口罩尺寸范围,则转入步骤(22);其中,在图像坐标系中的矩形角度是以最小外接矩形的长边和图像坐标系中X轴形成的角度,预设的口罩尺寸范围包括预设的口罩的长度及预设的口罩的宽度,预设的口罩的长度为标准口罩的长度±2mm,预设的口罩的宽度为标准口罩的宽度±2mm,标准的口罩的长度及宽度可通过市面上售卖的口罩长度及宽度进行确定或根据本领域口罩常用的长度及宽度进行确定,最小外接矩形算法为已知技术,在此不必赘述。(8) According to the minimum circumscribed rectangle algorithm, obtain the minimum circumscribed rectangle of the mask contour set Contour m , and obtain according to the length and width of the minimum circumscribed rectangle, the coordinates of the center of the rectangle in the image coordinate system, and the angle of the rectangle in the image coordinate system. Parameter information such as the length Ls, width Ws of the mask to be detected, the center coordinates (Xs, Ys) in the image coordinate system, and the angle As in the image coordinate system, according to the preset mask size, to determine whether the size of the mask to be detected conforms to Requirements, if the length and width of the mask to be detected are within the preset mask size range, then go to step (8); if the length and width of the mask to be detected exceed the preset mask size range, then go to step (22) Wherein, the rectangle angle in the image coordinate system is the angle formed by the long side of the minimum circumscribed rectangle and the X-axis in the image coordinate system, and the preset size range of the mask includes the preset length of the mask and the preset width of the mask , the preset length of the mask is ±2mm of the length of the standard mask, and the preset width of the mask is ±2mm of the width of the standard mask. The length and width of the standard mask can be determined by the length and width of the masks sold in the market or according to The length and width of masks commonly used in the art are determined, and the minimum circumscribed rectangle algorithm is a known technology, and it is unnecessary to repeat them here.
(9)、在步骤(8)获取的待检测口罩的中心坐标(Xs,Ys)、角度As不变的条件下,以待检测口罩的四个顶点为基准点分别沿待检测口罩的长度方向减去预设长度Lr1、再沿待检测口罩的宽度方向减去预设宽度Wr1,生成鼻梁检测的外区域矩形Ro。(9), under the condition that the center coordinates (Xs, Ys) and the angle As of the mask to be detected obtained in step (8) remain unchanged, take the four vertices of the mask to be detected as the reference points respectively along the length direction of the mask to be detected The preset length Lr1 is subtracted, and then the preset width Wr1 is subtracted along the width direction of the mask to be detected to generate the outer area rectangle Ro for nose bridge detection.
(10)、在步骤(8)获取的待检测口罩的中心坐标(Xs,Ys)、角度As不变的条件下,以待检测口罩的四个顶点为基准点分别沿待检测口罩的长度方向减去预设长度Lr2、再沿待检测口罩的宽度方向减去预设宽度Wr2,生成鼻梁检测的内区域矩形Ri,其中,Lr1>Lr2,Wr1<Wr2,通常Lr1取值范围为16-26mm,Lr2取值范围为15-25mm,Wr1取值范围为0-5mm,Wr2的范围取值为15-25mm。(10), under the condition that the center coordinates (Xs, Ys) and the angle As of the mask to be detected obtained in step (8) remain unchanged, take the four vertices of the mask to be detected as the reference points respectively along the length direction of the mask to be detected Subtract the preset length Lr2, and then subtract the preset width Wr2 along the width direction of the mask to be detected to generate the inner area rectangle Ri for nose bridge detection, where Lr1>Lr2, Wr1<Wr2, usually the value range of Lr1 is 16-26mm , the value range of Lr2 is 15-25mm, the value range of Wr1 is 0-5mm, and the value range of Wr2 is 15-25mm.
(11)、对鼻梁检测的外区域矩形Ro和鼻梁检测的内区域矩形Ri进行区域相减,得到鼻梁的检测区域Rnose,然后将鼻梁的检测区域Rnose以外的图像区域的像素点的灰度值设定为0以获得鼻梁所在位置对应的图像Img5;(11), perform regional subtraction on the outer area rectangle Ro of nose bridge detection and the inner area rectangle Ri of nose bridge detection to obtain the detection area Rnose of the bridge of the nose, and then use the gray value of the pixel of the image area other than the detection area Rnose of the bridge of the nose. Set to 0 to obtain the image Img5 corresponding to the position of the bridge of the nose;
(12)、对鼻梁所在位置对应的图像Img5进行线性变换,以增强对比度,得到增强图像Img6,并获得增强图像Img6中像素点对应的灰度值;本实施例中,对鼻梁所在位置对应的图像Img5进行线性变换得到增强图像Img6,并获得增强图像Img6中像素点对应的灰度值的方法,包括以下步骤:(12), linear transformation is carried out to the image Img5 corresponding to the position of the bridge of the nose, to enhance the contrast, obtain the enhanced image Img6, and obtain the gray value corresponding to the pixel point in the enhanced image Img6; The image Img5 is linearly transformed to obtain the enhanced image Img6, and the method for obtaining the gray value corresponding to the pixel point in the enhanced image Img6 includes the following steps:
通过线性变换公式Pixeln=1.5*Pixelo+30对Img5图像中的像素点进行遍历,其中,Pixelo为鼻梁所在位置对应的图像Img5中的像素点的灰度值,Pixeln为增强图像Img6中像素点对应的灰度值,30为偏移量;The pixels in the Img5 image are traversed by the linear transformation formula Pixel n =1.5*Pixel o +30, wherein Pixel o is the gray value of the pixel in the image Img5 corresponding to the position of the bridge of the nose, and Pixel n is the enhanced image Img6 The gray value corresponding to the middle pixel, 30 is the offset;
获得增强图像Img6中像素点对应的灰度值Pixeln,如果Pixeln大于255,则Pixeln=255;如果Pixeln小于0,则Pixeln=0;如果Pixeln介于0到255之间,则Pixeln等于1.5*Pixelo+30。Obtain the grayscale value Pixeln corresponding to the pixel in the enhanced image Img6 . If Pixeln is greater than 255, then Pixeln =255; if Pixeln is less than 0, then Pixeln =0; if Pixeln is between 0 and 255, Then Pixel n is equal to 1.5*Pixel o +30.
(13)、对增强图像Img6进行均值滤波处理,根据公式得到均值滤波图像Img7,其中,src1(x,y)为图像Img6在(x,y)处像素点的灰度值,dst1(x,y)为图像Img7在(x,y)处像素点的灰度值,h(k,l)为滤波核,k,l表示滤波核的大小,k,l均为奇数,本实施例中,k,l取值均为15。(13), carry out mean filter processing to the enhanced image Img6, according to the formula Obtain the mean filtered image Img7, where src1(x, y) is the gray value of the pixel point at (x, y) of the image Img6, and dst1(x, y) is the pixel point of the image Img7 at (x, y) The gray value of the point Gray value, h(k, l) is the filter kernel, k, l represent the size of the filter kernel, k, l are odd numbers, in this embodiment, k, l are both 15.
(14)、对均值滤波图像Img7进行自适应阈值处理,得到自适应二值化图像Img8,其中,自适应阈值处理为已知技术,在此不必赘述。(14) Perform adaptive threshold processing on the mean value filtered image Img7 to obtain an adaptive binarized image Img8, wherein the adaptive threshold processing is a known technology, and it is unnecessary to describe it here.
(15)、构建25像素*25像素尺寸的矩形结构元素,对自适应二值化图像Img8进行先腐蚀后膨胀的二值形态学预处理操作获得图像Img9,将腐蚀的矩形结构元素及膨胀的矩形结构元素对自适应二值化图像Img8进行处理,腐蚀的矩形结构元素和膨胀的矩形结构元素均设定为实心矩形形状,其中实心矩形形状的长、宽分别设定为25像素长度及25像素长度。(15), construct a rectangular structural element with a size of 25 pixels*25 pixels, perform a binary morphological preprocessing operation of first eroding and then expanding on the adaptive binarized image Img8 to obtain an image Img9, and combine the eroded rectangular structural element and the expanded image Img9. The rectangular structuring element processes the adaptive binarized image Img8, and the corroded rectangular structuring elements and the dilated rectangular structuring elements are both set as solid rectangle shapes, and the length and width of the solid rectangle shape are set to 25 pixels long and 25 pixels respectively. pixel length.
(16)、通过Two-Pass算法对图像Img9进行连通域判断,获取图像Img9中的所有连通域,并根据图像Img9中的连通域找出图像Img9中连通域对应的轮廓,得到初始鼻梁轮廓集合Contourc。(16), carry out connected domain judgment on image Img9 by Two-Pass algorithm, obtain all connected domains in the image Img9, and find out the corresponding contour of the connected domain in the image Img9 according to the connected domain in the image Img9, obtain the initial nose bridge outline set Contour c .
(17)、根据预设的鼻梁长度,通过公式计算初始鼻梁轮廓集合Contourc中符合要求的轮廓数量,获得鼻梁轮廓集合Contourn;(17), according to the preset length of the bridge of the nose, through the formula Calculate the number of contours that meet the requirements in the initial nose bridge contour set Contour c , and obtain the nose bridge contour set Contour n ;
其中,预设的鼻梁长度Lns为已转化成像素长度的标准鼻梁长度,CLs为初始鼻梁轮廓集合Contourc中连通域对应的轮廓长度;在本实施例中,以毫米为单位,会先将预设的鼻梁长度转换成像素长度。Wherein, the preset nose bridge length L ns is the standard nose bridge length that has been converted into pixel length, and CL s is the contour length corresponding to the connected domain in the initial nose bridge contour set Contour c ; Converts preset nose bridge lengths to pixel lengths.
(18)、判断鼻梁轮廓集合Contourn中的轮廓数量,若鼻梁轮廓集合Contourn中的轮廓数量为0或大于1,则转入步骤(22);若鼻梁轮廓集合Contourm中的轮廓数量为1,则转入步骤(19)。(18), judge the contour quantity in the nose bridge contour set Contour n , if the contour quantity in the nose bridge contour set Contour n is 0 or greater than 1, then go to step (22); If the contour quantity in the nose bridge contour set Contour m is 1, then go to step (19).
(19)、获取鼻梁轮廓集合Contourn的最小外接矩形,根据最小外接矩形的长度、在图像坐标系中的矩形中心坐标得出待检测鼻梁的长度及待检测鼻梁的中心坐标(Xns,Yns)。(19), obtain the minimum circumscribed rectangle of the nose bridge contour set Contour n , obtain the length of the nose bridge to be detected and the center coordinates (Xns, Yns) of the nose bridge to be detected according to the length of the minimum circumscribed rectangle and the center coordinates of the rectangle in the image coordinate system .
(20)、根据预设的鼻梁长度与步骤(18)中得出的待检测鼻梁的长度进行比较,判断待检测鼻梁的长度是否满足要求,当待检测鼻梁的长度减去鼻梁的标准长度的绝对值不大于预设的鼻梁长度公差时,则转入步骤(21);当待检测鼻梁的长度减去鼻梁的标准长度的绝对值大于预设的鼻梁长度公差时,则转入步骤(22),其中,鼻梁的标准长度可通过市面上售卖的口罩中的鼻梁的长度进行确定或根据本领域鼻梁常用的长度进行确定。(20), compare the length of the bridge of nose to be detected according to the length of the bridge of the nose to be detected obtained in step (18), judge whether the length of the bridge of the nose to be detected meets the requirements, when the length of the bridge of the nose to be detected deducts the standard length of the bridge of the nose When the absolute value is not greater than the preset nose bridge length tolerance, then go to step (21); When the absolute value of the length of the nose bridge to be detected minus the standard length of the nose bridge is greater than the preset nose bridge length tolerance, then go to step (22) ), wherein, the standard length of the bridge of the nose can be determined by the length of the bridge of the nose in the masks sold in the market or determined according to the commonly used length of the bridge of the nose in the art.
(21)、构建以坐标(Xs,Ys)为中心、以As为旋转角度的变换矩阵Mc,根据构建的变换矩阵Mc对步骤(8)中得出在图像坐标系中的口罩中心坐标(Xs,Ys)和步骤(19)中得出的在图像坐标系中的待检测鼻梁中心坐标(Xns,Yns)进行仿射变换,得到经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc),获得绝对值Labs=|Ysc-Ysc|,如果绝对值Labs≤预设的鼻梁偏位值,则判定待检测口罩为良品,所述待检测口罩输送至产品合格区;如果Labs>预设的鼻梁偏位值,则转入步骤(22)。(21), construct a transformation matrix M c with coordinates (Xs, Ys) as the center and As as the rotation angle, and obtain the mask center coordinates in the image coordinate system according to the constructed transformation matrix M c in step (8) (Xs, Ys) and the center coordinates (Xns, Yns) of the nose bridge to be detected in the image coordinate system obtained in step (19) are subjected to affine transformation to obtain the center coordinates (Xsc, Ysc) of the mask after affine transformation ) and the center coordinates (Xnsc, Ynsc) of the bridge of the nose after affine transformation, to obtain the absolute value Labs=|Ysc-Ysc|, if the absolute value Labs≤the preset nose bridge offset value, then the mask to be tested is judged to be a good product, so The mask to be tested is transported to the product qualified area; if Labs > the preset nose bridge offset value, then go to step (22).
其中,预设的鼻梁偏位值设定为5mm,构建变换矩阵和进行仿射变换为已知技术,在此不必赘述,仿射变换的通用矩阵Maf为 Among them, the preset nose bridge offset value is set to 5mm, and it is a known technology to construct a transformation matrix and perform affine transformation.
(tx,ty)表示平移量,a1、a2、a3、a4反映了图像旋转、缩放等变化,本实施例中,a1=cos(As),a2=-sin(As),a3=sin(As),a4=cos(As),tx=Xs,ty=Ys,即本实施例中仿射变换的矩阵Mc=仿射变换公式为(X,Y)为仿射变换前的图像像素坐标,(X′,Y′)为仿射变换后的图像像素坐标,本实施例中当(X,Y)=(Xs,Ys),则(X′,Y′)=(Xsc,Ysc);当(X,Y)=(Xns,Yns),则(X′,Y′)=(Xnsc,Ynsc)。(t x , ty ) represents the amount of translation, a 1 , a 2 , a 3 , and a 4 reflect changes such as image rotation, scaling, etc. In this embodiment, a 1 =cos(As), a 2 =-sin( As), a 3 =sin(As), a 4 =cos(As), t x =Xs, ty =Ys, that is, the affine transformation matrix M c = The affine transformation formula is (X, Y) are the pixel coordinates of the image before affine transformation, and (X', Y') are the pixel coordinates of the image after affine transformation. In this embodiment, when (X, Y)=(Xs, Ys), then (X', Y')=(Xsc, Ysc); when (X, Y)=(Xns, Yns), then (X', Y')=(Xnsc, Ynsc).
(22)、判定待检测口罩为瑕疵品,将待检测口罩送至产品不合格区内。(22) Determine that the mask to be tested is a defective product, and send the mask to be tested to the unqualified area of the product.
如图1所示,根据上述本发明一种口罩鼻梁检测方法,本发明提供了一种口罩鼻梁检测系统,先通过二值化处理方式对口罩的初始图像进行处理,后找出口罩轮廓集合Contourm的最小外接矩形,进而获得待检测口罩的长度Ls、宽度Ws、在图像坐标系的中心坐标(Xs,Ys)、在图像坐标系的角度As参数信息,再通过外区域矩形Ro及内区域矩形Ri得到鼻梁的检测区域Rnose,然后在判断的鼻梁的检测区域Rnose内,通过对图像进行滤波,并通过自适应阈值处理生成自适应二值化图像,对检测范围内的自适应二值化图像进行连通域确认,获得鼻梁轮廓集合Contourn,再通过最小外接矩形方法得到鼻梁的外形尺寸及中心坐标,然后对待检测鼻梁的长度与鼻梁的标准长度进行比较,以及对经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc)进行比较,从而有效对待检测口罩的鼻梁长度和鼻梁位置的质量进行判定。As shown in Figure 1, according to a kind of mask nose bridge detection method of the above-mentioned present invention, the invention provides a kind of mask nose bridge detection system, first through the binarization processing mode, the initial image of the mask is processed, and then find out the mask outline collection Contour The minimum circumscribed rectangle of m , and then obtain the length Ls, width Ws of the mask to be detected, the center coordinates (Xs, Ys) in the image coordinate system, and the angle As parameter information in the image coordinate system, and then pass the outer area rectangle Ro and inner area. The rectangle Ri obtains the detection area Rnose of the bridge of the nose, and then in the detection area Rnose of the bridge of the nose, the image is filtered, and the adaptive binarization image is generated through adaptive threshold processing, and the adaptive binarization within the detection range is The connected domain of the image is confirmed, and the contour set of the nose bridge Contour n is obtained, and then the outline size and center coordinates of the nose bridge are obtained by the minimum circumscribed rectangle method, and then the length of the nose bridge to be detected is compared with the standard length of the nose bridge, and the affine transformation is carried out. The center coordinates (Xsc, Ysc) of the mask are compared with the center coordinates (Xnsc, Ynsc) of the nose bridge after affine transformation, so as to effectively determine the length of the nose bridge and the quality of the nose bridge position of the mask to be detected.
本发明一种口罩鼻梁检测系统,包括:The present invention is a mask nose bridge detection system, comprising:
图像采集单元,用于采集待检测口罩的初始图像Img1;The image acquisition unit is used to collect the initial image Img1 of the mask to be detected;
图像处理单元,用于通过固定阈值算法获得初始二值化图像Img2、通过形态学闭处理得到闭运算的二值化图像Img3、通过形态学开处理得到开运算的二值化图像Img4、通过线性变换得到增强图像Img6、通过均值滤波处理得到均值滤波图像Img7、通过自适应阈值处理得到自适应二值化图像Img8及通过二值形态学预处理操作获得图像Img9;The image processing unit is used to obtain an initial binarized image Img2 through a fixed threshold algorithm, obtain a closed-operation binarized image Img3 through morphological closing processing, obtain an open-operation binarized image Img4 through morphological opening processing, and obtain an open-operation binarized image Img4 through morphological closing processing. Transform to obtain an enhanced image Img6, obtain a mean value filtered image Img7 through mean filtering, obtain an adaptive binarized image Img8 through adaptive threshold processing, and obtain an image Img9 through a binary morphological preprocessing operation;
图像标记单元,用于通过Two-Pass算法对开运算的二值化图像Img4进行连通域判断获取口罩轮廓集合Contourm及通过Two-Pass算法对图像Img9进行连通域判断得到初始鼻梁轮廓集合Contourc;The image labeling unit is used to judge the connected domain of the binarized image Img4 of the split operation by the Two-Pass algorithm to obtain the mask contour set Contour m and to judge the connected domain of the image Img9 by the Two-Pass algorithm to obtain the initial nose bridge contour set Contour c ;
分析计算单元,用于获得待检测口罩的长度Ls、宽度Ws、待检测口罩在图像坐标系的中心坐标(Xs,Ys)、待检测口罩在图像坐标系的角度As、待检测鼻梁的长度、待检测鼻梁的中心坐标(Xns,Yns);The analysis and calculation unit is used to obtain the length Ls, width Ws of the mask to be detected, the center coordinates (Xs, Ys) of the mask to be detected in the image coordinate system, the angle As of the mask to be detected in the image coordinate system, the length of the bridge of the nose to be detected, The center coordinates of the bridge of the nose to be detected (Xns, Yns);
图像判定单元,用于判定待检测口罩的尺寸是否符合要求、待检测鼻梁的长度是否满足要求、判定根据经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc)获得的绝对值Labs=|Ysc-Ysc|是否满足要求。The image determination unit is used to determine whether the size of the mask to be detected meets the requirements, whether the length of the bridge of the nose to be detected meets the requirements, and the determination is based on the center coordinates (Xsc, Ysc) of the mask after affine transformation and the bridge of the nose after affine transformation. Whether the absolute value Labs=|Ysc-Ysc| obtained by the center coordinates (Xnsc, Ynsc) meets the requirements.
综上所述,本发明一种口罩鼻梁检测方法及系统通过二值化处理方式对口罩的初始图像进行处理,后找出口罩轮廓集合Contourm的最小外接矩形,进而获得待检测口罩的长度Ls、宽度Ws、在图像坐标系的中心坐标(Xs,Ys)、在图像坐标系的角度As参数信息,再通过外区域矩形Ro及内区域矩形Ri得到鼻梁的检测区域Rnose,然后在判断的鼻梁的检测区域Rnose内,通过对图像进行滤波,并通过自适应阈值处理生成自适应二值化图像,对检测范围内的自适应二值化图像进行连通域确认,获得鼻梁轮廓集合Contourn,再通过最小外接矩形方法得到鼻梁的外形尺寸及中心坐标,然后对待检测鼻梁的长度与鼻梁的标准长度进行比较,以及对经仿射变换后的口罩的中心坐标(Xsc,Ysc)和经仿射变换后鼻梁的中心坐标(Xnsc,Ynsc)进行比较,从而有效对待检测口罩的鼻梁长度和鼻梁位置的质量进行判定。To sum up, a method and system for detecting the bridge of the nose of a mask of the present invention processes the initial image of the mask by means of binarization, and then finds the minimum circumscribed rectangle of the mask contour set Contour m , and then obtains the length Ls of the mask to be detected. , the width Ws, the center coordinates (Xs, Ys) in the image coordinate system, the angle As parameter information in the image coordinate system, and then obtain the detection area Rnose of the nose bridge through the outer area rectangle Ro and the inner area rectangle Ri, and then determine the nose bridge. In the detection area Rnose , the adaptive binarized image is generated by filtering the image, and the adaptive binarized image is generated by adaptive thresholding. The external dimensions and center coordinates of the bridge of the nose are obtained by the minimum circumscribed rectangle method, and then the length of the bridge to be detected is compared with the standard length of the bridge of the nose, and the center coordinates (Xsc, Ysc) of the mask after affine transformation and the affine transformation are compared. The center coordinates (Xnsc, Ynsc) of the posterior bridge of the nose are compared, so as to effectively determine the length of the bridge of the nose and the quality of the location of the bridge of the nose of the mask to be detected.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present invention, and the descriptions thereof are specific and detailed, but should not be construed as limiting the scope of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can also be made, which all belong to the protection scope of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010912532.8A CN112070738B (en) | 2020-09-03 | 2020-09-03 | A kind of mask nose bridge detection method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010912532.8A CN112070738B (en) | 2020-09-03 | 2020-09-03 | A kind of mask nose bridge detection method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112070738A true CN112070738A (en) | 2020-12-11 |
CN112070738B CN112070738B (en) | 2022-04-12 |
Family
ID=73665381
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010912532.8A Active CN112070738B (en) | 2020-09-03 | 2020-09-03 | A kind of mask nose bridge detection method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112070738B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113706652A (en) * | 2021-09-23 | 2021-11-26 | 明峰医疗系统股份有限公司 | Method for removing ring-shaped artifacts with morphological assistance |
CN114441499A (en) * | 2022-04-11 | 2022-05-06 | 天津美腾科技股份有限公司 | Grade detection method and device, identification equipment, ore pulp grade instrument and storage medium |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100189361A1 (en) * | 2009-01-28 | 2010-07-29 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate positions of characteristic portions of face |
US20100202696A1 (en) * | 2009-02-06 | 2010-08-12 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate position of characteristic portion of face |
US20100209000A1 (en) * | 2009-02-17 | 2010-08-19 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate position of characteristic portion of face |
CN103914827A (en) * | 2013-09-06 | 2014-07-09 | 贵州大学 | Method for visual inspection of shortages of automobile sealing strip profile |
CN206791733U (en) * | 2017-03-01 | 2017-12-26 | 南阳理工学院 | Mouth mask and the mouth mask external member using the mouth mask |
KR101853006B1 (en) * | 2016-12-19 | 2018-04-30 | 동의대학교 산학협력단 | Recognition of Face through Detecting Nose in Depth Image |
CN108230315A (en) * | 2018-01-04 | 2018-06-29 | 西安理工大学 | A kind of respirator belt missing detection method based on machine vision |
CN109374634A (en) * | 2018-11-20 | 2019-02-22 | 深圳市维图视技术有限公司 | A kind of mask on-line detecting system and method |
CN109507198A (en) * | 2018-12-14 | 2019-03-22 | 航天科工智能机器人有限责任公司 | Mask detection system and method based on Fast Fourier Transform (FFT) and linear Gauss |
CN109765238A (en) * | 2018-12-12 | 2019-05-17 | 弓立(厦门)医疗用品有限公司 | A kind of product quality detection method of mask fully-automatic production detection device |
CN110322395A (en) * | 2019-06-18 | 2019-10-11 | 电子科技大学中山学院 | Part outline shape detection method and device based on image processing and affine transformation |
US20200042769A1 (en) * | 2017-04-14 | 2020-02-06 | Shenzhen Sensetime Technology Co., Ltd. | Face image processing methods and apparatuses, and electronic devices |
-
2020
- 2020-09-03 CN CN202010912532.8A patent/CN112070738B/en active Active
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100189361A1 (en) * | 2009-01-28 | 2010-07-29 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate positions of characteristic portions of face |
US20100202696A1 (en) * | 2009-02-06 | 2010-08-12 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate position of characteristic portion of face |
US20100209000A1 (en) * | 2009-02-17 | 2010-08-19 | Seiko Epson Corporation | Image processing apparatus for detecting coordinate position of characteristic portion of face |
CN103914827A (en) * | 2013-09-06 | 2014-07-09 | 贵州大学 | Method for visual inspection of shortages of automobile sealing strip profile |
KR101853006B1 (en) * | 2016-12-19 | 2018-04-30 | 동의대학교 산학협력단 | Recognition of Face through Detecting Nose in Depth Image |
CN206791733U (en) * | 2017-03-01 | 2017-12-26 | 南阳理工学院 | Mouth mask and the mouth mask external member using the mouth mask |
US20200042769A1 (en) * | 2017-04-14 | 2020-02-06 | Shenzhen Sensetime Technology Co., Ltd. | Face image processing methods and apparatuses, and electronic devices |
CN108230315A (en) * | 2018-01-04 | 2018-06-29 | 西安理工大学 | A kind of respirator belt missing detection method based on machine vision |
CN109374634A (en) * | 2018-11-20 | 2019-02-22 | 深圳市维图视技术有限公司 | A kind of mask on-line detecting system and method |
CN109765238A (en) * | 2018-12-12 | 2019-05-17 | 弓立(厦门)医疗用品有限公司 | A kind of product quality detection method of mask fully-automatic production detection device |
CN109507198A (en) * | 2018-12-14 | 2019-03-22 | 航天科工智能机器人有限责任公司 | Mask detection system and method based on Fast Fourier Transform (FFT) and linear Gauss |
CN110322395A (en) * | 2019-06-18 | 2019-10-11 | 电子科技大学中山学院 | Part outline shape detection method and device based on image processing and affine transformation |
Non-Patent Citations (1)
Title |
---|
肖标: "无纺布口罩自动在线检测技术研究", 《万方数据知识服务平台》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113706652A (en) * | 2021-09-23 | 2021-11-26 | 明峰医疗系统股份有限公司 | Method for removing ring-shaped artifacts with morphological assistance |
CN113706652B (en) * | 2021-09-23 | 2023-12-19 | 明峰医疗系统股份有限公司 | Method for morphologically assisting removal of ring artifacts |
CN114441499A (en) * | 2022-04-11 | 2022-05-06 | 天津美腾科技股份有限公司 | Grade detection method and device, identification equipment, ore pulp grade instrument and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112070738B (en) | 2022-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112927189B (en) | Edge reflection light spot eliminating method in visual inspection of surface flaws of electroplated workpiece | |
CN109724990B (en) | A method for rapid positioning and detection of coding area in packaging box labels | |
CN105067638B (en) | Tire fetal membrane face character defect inspection method based on machine vision | |
CN111275697B (en) | Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method | |
CN112419297B (en) | Bolt loosening detection method, device, equipment and storage medium | |
CN106446894B (en) | A method of based on outline identification ball-type target object location | |
CN112949564A (en) | Pointer type instrument automatic reading method based on deep learning | |
CN111243032A (en) | An automatic detection method for checkerboard corner points | |
CN111126253A (en) | Detection method of knife switch state based on image recognition | |
CN106568783A (en) | Hardware part defect detecting system and method | |
CN104568986A (en) | Method for automatically detecting printing defects of remote controller panel based on SURF (Speed-Up Robust Feature) algorithm | |
CN107063458B (en) | Ceramic tile coloration piecemeal detection method based on machine vision | |
CN104574418A (en) | Pressure vessel weld defect identification method and device based on neural network | |
CN107798326A (en) | A kind of profile visual detection algorithm | |
CN101620060A (en) | Automatic detection method of particle size distribution | |
CN114820621B (en) | Bolt loss defect detection method, system and device | |
CN112070738B (en) | A kind of mask nose bridge detection method and system | |
CN109658391B (en) | Circle radius measuring method based on contour merging and convex hull fitting | |
CN109975196B (en) | A kind of reticulocyte detection method and system thereof | |
CN113077437B (en) | Workpiece quality detection method and system | |
CN107016394B (en) | Cross fiber feature point matching method | |
CN111539927B (en) | Detection method for lack of installation detection device for fastening buckles of automobile plastic assemblies | |
CN106651893A (en) | Edge detection-based wall body crack identification method | |
Rani et al. | Detection of edges using mathematical morphological operators | |
CN113516619B (en) | Product surface flaw identification method based on image processing technology |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |