CN111275697B - Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method - Google Patents
Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method Download PDFInfo
- Publication number
- CN111275697B CN111275697B CN202010085060.3A CN202010085060A CN111275697B CN 111275697 B CN111275697 B CN 111275697B CN 202010085060 A CN202010085060 A CN 202010085060A CN 111275697 B CN111275697 B CN 111275697B
- Authority
- CN
- China
- Prior art keywords
- image
- tested
- template
- optical flow
- battery
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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
- G06T7/0008—Industrial image inspection checking presence/absence
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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 OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/80—Geometric correction
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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 OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/194—Segmentation; Edge detection involving foreground-background segmentation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/20—Analysis of motion
- G06T7/269—Analysis of motion using gradient-based methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/74—Image or video pattern matching; Proximity measures in feature spaces
- G06V10/75—Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
- G06V10/757—Matching configurations of points or features
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10016—Video; Image sequence
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Multimedia (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Medical Informatics (AREA)
- Software Systems (AREA)
- Evolutionary Computation (AREA)
- Databases & Information Systems (AREA)
- Artificial Intelligence (AREA)
- Health & Medical Sciences (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
Abstract
Description
技术领域technical field
本发明属于机器视觉自动化表面检测技术领域,具体涉及一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法。The invention belongs to the technical field of machine vision automatic surface detection, in particular to a battery silk screen quality detection method based on ORB feature matching and LK optical flow method.
背景技术Background technique
检测电池的丝印/条码是电池组装加工过程中的重要步骤,不同型号的电池具有字符类型(汉字、韩文、英文及数字等)、字符格式、插图内容、条码格式等差异。目前电池丝印/条码受夹具、设备、人员等相关因素影响导致印刷缺陷,丝印/条码缺陷类型主要分为:条码缺损/扭曲/歪斜/模糊/重影/脏污/色差、丝印缺损/歪斜/模糊/重影/脏污/色差、丝印与条码信息不匹配、条码尺寸及条码/丝印位置不符合规格要求等。Screen printing/barcode detection of batteries is an important step in the battery assembly process. Different types of batteries have differences in character type (Chinese characters, Korean, English and numbers, etc.), character format, illustration content, and barcode format. At present, battery screen printing/barcode is affected by fixtures, equipment, personnel and other related factors, resulting in printing defects. The types of screen printing/barcode defects are mainly divided into: barcode defect/distortion/skew/blur/ghost/dirty/color difference, silkscreen defect/skew/ Fuzzy/ghosting/dirty/color difference, silk screen and barcode information do not match, barcode size and barcode/screen printing position do not meet specifications, etc.
传统的电池丝印外观检测主要依靠肉眼、放大镜和CCD摄像头等进行人工检测,由于不可避免地受人类情绪、周边环境噪声、工作专注度等因素影响,难以保证检测结果的准确性和实时性。人工检测的方法操作简单,但检测速度慢,容易引入误判,检测缺乏客观标准。The traditional appearance inspection of battery screen printing mainly relies on the naked eye, magnifying glass and CCD camera for manual inspection. Due to the inevitable influence of human emotions, surrounding environmental noise, work concentration and other factors, it is difficult to ensure the accuracy and real-time performance of the inspection results. The manual detection method is simple to operate, but the detection speed is slow, it is easy to introduce misjudgment, and the detection lacks objective standards.
为了实现对电池丝印质量的自动化检测,国内外学者进行了大量研究,涌现出了许多经典方法,如全局模板匹配法、基于逐像素分层检测法、神经网络算法,小波变换检测方法、Gabor变换算法、特征提取法等。但以上方法主要存在两个问题:In order to realize the automatic detection of battery screen printing quality, scholars at home and abroad have conducted a lot of research, and many classic methods have emerged, such as global template matching method, pixel-based hierarchical detection method, neural network algorithm, wavelet transform detection method, Gabor transform algorithms, feature extraction, etc. But there are two main problems with the above method:
1)算法过于复杂,检测耗时长,不适合工厂应用于生产线上检测;1) The algorithm is too complex, and the detection takes a long time, which is not suitable for factories to be used in production line detection;
2)应用对象特点比较单一,方法的通用性和对复杂对象的检测能力有待加强。2) The characteristics of the application objects are relatively simple, and the versatility of the method and the detection ability of complex objects need to be strengthened.
本发明检测的电池丝印类型众多,每种图案或文字适用的方法也不同,需要更高的处理精度。运用以往经典方法均无法取得良好效果。There are many types of battery screen printing detected by the present invention, and the applicable methods for each pattern or text are also different, which requires higher processing precision. Using the previous classical methods can not achieve good results.
发明内容SUMMARY OF THE INVENTION
本发明所要解决的技术问题在于针对上述现有技术中的不足,提供一种基于ORB(Oriented FAST and Rotated BRIEF)特征匹配和L-K(Lukas-Kanade)光流法的电池丝印质量检测方法,可以对工厂流水线上的丝印外观质量进行实时检测,准确率高,在一定程度上提高国内电池制造行业就电池丝印质量检测方面的自动化水平。The technical problem to be solved by the present invention is to provide a battery screen printing quality detection method based on ORB (Oriented FAST and Rotated BRIEF) feature matching and L-K (Lukas-Kanade) optical flow method for the above-mentioned deficiencies in the prior art. The appearance quality of silk screen printing on the factory assembly line is tested in real time, with high accuracy, which to a certain extent improves the automation level of battery screen printing quality detection in the domestic battery manufacturing industry.
本发明采用以下技术方案:The present invention adopts following technical scheme:
一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法,包括以下步骤:A battery screen printing quality detection method based on ORB feature matching and LK optical flow method, comprising the following steps:
S1、采集电池丝印图像数据,进行预处理提取电池丝印区域;S1. Collect battery silkscreen image data, and perform preprocessing to extract battery silkscreen area;
S2、采用矩形分块的方式进行建模,包括插画部分模板和文字部分模板,基于ORB算法提取模板丝印和待测丝印的特征并匹配,实现对丝印内容的定位;S2. Use the rectangular block method to model, including the illustration part template and the text part template, based on the ORB algorithm to extract and match the characteristics of the template silk screen and the silk screen to be tested, so as to realize the positioning of the silk screen content;
S3、基于形态学的图像差影法进行检测,如果出现误报,使用基于L-K光流法的扭曲校正检测方法进行二次检测;如果没有出现误报,输出结果图像及检测数据,执行分拣操作。S3. Perform the detection based on the image aberration method based on morphology. If there is a false alarm, use the distortion correction detection method based on the L-K optical flow method for secondary detection; if there is no false alarm, output the result image and detection data, and perform sorting operate.
具体的,步骤S1具体为:Specifically, step S1 is specifically:
S101、根据原始图像尺寸创建十字交叉矩形窗,对原始图像进行裁剪,其目的为获取电芯丝印区域的边界信息;S101, creating a crossed rectangular window according to the size of the original image, and cropping the original image, the purpose of which is to obtain the boundary information of the screen printing area of the cell;
S102、利用Ostu算法计算二值化阈值,将丝印区域与其他背景初步分离,并结合图像灰度特征对该阈值进行适当偏移以准确分离电芯丝印区域和其他背景,通过形态学开运算去除边缘毛刺,消除边缘细小的分割误差;S102, use the Ostu algorithm to calculate the binarization threshold, initially separate the silk screen area from other backgrounds, and appropriately offset the threshold value in combination with the grayscale features of the image to accurately separate the cell silk screen area and other backgrounds, and remove them by morphological opening operation Edge burr to eliminate small edge segmentation errors;
S103、利用相关算法对步骤S102提取出来的区域进行最小外接矩形拟合,根据拟合结果对原始图像进行裁剪,获得准确的电池丝印区域;S103, using a relevant algorithm to perform minimum circumscribed rectangle fitting on the region extracted in step S102, and trimming the original image according to the fitting result to obtain an accurate battery silk screen area;
S104、对待测图像进行灰度校正,调整到与模板图像相同的灰度水平。S104, performing grayscale correction on the image to be tested, and adjusting it to the same grayscale level as the template image.
进一步的,步骤S104具体为:Further, step S104 is specifically:
S1041、将图像灰度化,将原始三通道图像转换为单通道灰度图像,采用心理学灰度公式:S1041. Grayscale the image, convert the original three-channel image into a single-channel grayscale image, and use the psychological grayscale formula:
gray=0.299*red+0.587*green+0.114*bluegray=0.299*red+0.587*green+0.114*blue
S1042、利用阈值分割方法划分前景区域R1和背景区域R2;分别计算前景区域和背景区域的灰度均值,对待测图像和模板图像分别执行上述操作,灰度均值计算如下:S1042, divide the foreground region R 1 and the background region R 2 by using a threshold segmentation method; calculate the gray mean value of the foreground region and the background region respectively, perform the above operations on the image to be tested and the template image respectively, and calculate the gray mean value as follows:
其中,Ri为阈值分割后提取的区域,p为区域内一像素点,g(p)为点p处的灰度值,F为Ri内像素点总数;Among them, R i is the region extracted after threshold segmentation, p is a pixel in the region, g(p) is the gray value at point p, and F is the total number of pixels in R i ;
S1043、对待测图像进行灰度变换,获得模板前景灰度均值M1、模板背景灰度均值M2、待测图像前景灰度均值T1、待测图像背景灰度均值T2,进行灰度变换,分别计算灰度放缩系数Mult和灰度平移系数Add,利用这两个系数对待测图像的原始灰度进行映射校正,具体如下:S1043. Perform grayscale transformation on the image to be tested to obtain the mean value M1 of the foreground grayscale of the template, the mean value M2 of the background grayscale of the template, the mean value T1 of the foreground grayscale of the image to be tested, and the mean value T2 of the background grayscale of the image to be tested, and perform grayscale Transform, calculate the gray scale scaling coefficient Mult and the gray scale translation coefficient Add respectively, and use these two coefficients to map and correct the original gray scale of the image to be tested, as follows:
Mult=(M1-M2)/(T1-T2)Mult=(M 1 -M 2 )/(T 1 -T 2 )
Add=M1-Mult*T1 Add=M 1 -Mult*T 1
g'=g*Mult+Addg'=g*Mult+Add
其中,Mult为灰度放缩系数,Add为灰度平移系数,g’为映射后的新灰度值。Among them, Mult is the gray scale scaling coefficient, Add is the gray scale translation coefficient, and g' is the new gray value after mapping.
具体的,步骤S2具体为:Specifically, step S2 is specifically:
S201、oFAST特征点提取;S201, oFAST feature point extraction;
S202、rBRIEF特征描述子构造;S202, rBRIEF feature descriptor structure;
S203、特征点匹配。S203, feature point matching.
进一步的,步骤S201中,将P点的灰度值和以P为中心半径为3的邻域内的16个像素点的灰度值进行比较,如果P点的像素值和圆圈上邻域内n个连续的像素点的像素值相减大于阈值t,点P是一个特征点。Further, in step S201, the gray value of point P is compared with the gray value of 16 pixel points in the neighborhood with P as the center and the radius of 3. If the pixel value of point P is the same as that of n pixels in the neighborhood on the circle The subtraction of the pixel values of consecutive pixel points is greater than the threshold t, and the point P is a feature point.
进一步的,步骤S202中,在关键点P的周围选取N个点对,把N个点对的比较结果组合起来作为描述子,所有的点对进行比较,生成长度为n的二进制串。Further, in step S202, N point pairs are selected around the key point P, the comparison results of the N point pairs are combined as descriptors, and all point pairs are compared to generate a binary string of length n.
进一步的,步骤S203中,采用描述子之间的汉明距离作为相似性测度,两个等长二进制串之间的汉明距离是两个字符串对应位置的不同字符的个数,通过设置相似度阈值进行匹配点对的筛选;获得匹配结果后,根据模板图像和待测图像中ORB特征点的对应关系,对模板和待测图像进行配准,将模板图像中的各个矩形子模板与待测图像中的各个部分完成匹配。Further, in step S203, the Hamming distance between the descriptors is used as the similarity measure, and the Hamming distance between the two binary strings of equal length is the number of different characters in the corresponding positions of the two strings. By setting the similarity According to the corresponding relationship between the ORB feature points in the template image and the image to be tested, the template and the image to be tested are registered, and each rectangular sub-template in the template image is matched with the image to be tested. Matching is done on each part of the measured image.
具体的,步骤S3中,插画部分检测具体为:Specifically, in step S3, the illustration part detection is specifically:
S3011、根据匹配结果得到对应点关系,计算刚体变换矩阵,将子模板图像与待测图像进行对准,利用阈值分割法将检测内容从背景分割出来;S3011, obtaining the corresponding point relationship according to the matching result, calculating the rigid body transformation matrix, aligning the sub-template image with the image to be tested, and using the threshold segmentation method to segment the detection content from the background;
S3012、对分割出来的丝印内容进行形态学腐蚀和膨胀处理,通过待测品和模板的正反作差可以获得多印类缺陷和漏印类缺陷,多印类缺陷为:T(腐蚀)-M(膨胀);漏印类缺陷为:M(腐蚀)-T(膨胀);S3012, perform morphological corrosion and expansion treatment on the divided screen printing content, and obtain multi-print defects and missing printing defects through the positive and negative difference between the product to be tested and the template. The multi-print defects are: T (corrosion) - M (expansion) ; missing printing defects are: M (corrosion) -T (expansion) ;
S3013、对步骤S3012作差后的差图像进行连通分析与阈值筛选,超出阈值的区域即为缺陷区域;S3013, perform connectivity analysis and threshold screening on the difference image after the difference in step S3012, and the area exceeding the threshold is the defect area;
S3014、以缺陷中心为圆心,利用缺陷的最小外接圆对缺陷进行标记。S3014 , taking the center of the defect as the center of the circle, and marking the defect by using the smallest circumcircle of the defect.
具体的,步骤S3中,文字部分缺陷检测流程如下:Specifically, in step S3, the text part defect detection process is as follows:
S3015、仿射变换配准;S3015, affine transformation registration;
S3016、对文字进行骨架提取处理,提取后文字线条统一为单像素宽度,只保留其拓扑结构;S3016, perform skeleton extraction processing on the text, after the extraction, the text lines are unified into a single-pixel width, and only the topology structure is retained;
S3017、对提取出来的文字进行米字型平移处理,即上、下、左、右、左上、右上、左下、右下8个方向,然后进行图像作差,获得8个差图像;S3017, performing a rice-shaped translation process on the extracted text, namely up, down, left, right, upper left, upper right, lower left, and lower right in 8 directions, and then performing image difference to obtain 8 difference images;
S3018、对步骤S3017获得的8个差图像进行交运算,最终保留的区域视为真实缺陷区域;S3018, performing an intersection operation on the 8 difference images obtained in step S3017, and the final reserved area is regarded as a real defect area;
S3019、连通分析阈值筛选及缺陷标记。S3019. Connectivity analysis threshold screening and defect marking.
具体的,步骤S3中,将模板图像和待测图像视为视频中的连续帧图像,将待测图像中出现的不规律微小扭曲变形视为局部微量运动,检测流程如下:Specifically, in step S3, the template image and the image to be tested are regarded as continuous frame images in the video, and the irregular and small distortions that appear in the image to be tested are regarded as local micro-motion, and the detection process is as follows:
S3021、利用L-K光流法就可以计算出两幅图像之间的光流场,光流场任意位置(i,j)上的光流矢量Vi,j构成如下:S3021. The optical flow field between the two images can be calculated by using the LK optical flow method. The optical flow vector V i,j at any position (i, j) of the optical flow field is composed as follows:
Vi,j=(x,y)V i,j =(x,y)
其中,x值代表了待测图像在(i,j)点的行偏移量,y值则代表了列偏移量;Among them, the x value represents the row offset of the image to be tested at point (i, j), and the y value represents the column offset;
S3022、分解光流矢量Vi,j获取其分量x和y,构成两个数据集{x}和{y};S3022, decompose the optical flow vector V i,j to obtain its components x and y to form two data sets {x} and {y};
S3023、对待测图像进行阈值分割,获取丝印前景区域T,统计区域T内所有点的坐标(i,j);S3023, perform threshold segmentation on the image to be tested, obtain the screen printing foreground area T, and count the coordinates (i, j) of all points in the area T;
S3024、计算对应点集,待测图像相比模板图像,在坐标(i,j)处的像素点由于扭曲变形移动到了坐标(i+x,j+y)处;S3024, calculate the corresponding point set, the image to be tested is compared with the template image, and the pixel at the coordinate (i, j) is moved to the coordinate (i+x, j+y) due to distortion;
S3025、以(i,j)和(i+x,j+y)作为对应点集,计算投影变换矩阵A,以此矩阵对待测丝印进行投影变换,实现对微小变形的校正;S3025, using (i, j) and (i+x, j+y) as the corresponding point sets, calculate the projection transformation matrix A, and perform projection transformation on the silk screen to be measured with this matrix, so as to realize the correction of small deformation;
S3026、对校正后的待测图像和模板图像再次进行差影处理,进行缺陷分离提取处理,并做最终的标记。S3026 , performing shadow difference processing on the corrected image to be tested and the template image again, performing defect separation and extraction processing, and making final marks.
与现有技术相比,本发明至少具有以下有益效果:Compared with the prior art, the present invention at least has the following beneficial effects:
本发明一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法,实时性好,检测率高于同类方法,并且通过引入光流法能够对无规律扭曲变形进行校正,大大增强了对丝印质量检测的适应性。The invention is a battery silk screen quality detection method based on ORB feature matching and LK optical flow method, which has good real-time performance and higher detection rate than similar methods, and can correct irregular distortion by introducing optical flow method, which greatly enhances the accuracy of The adaptability of screen printing quality inspection.
进一步的,对图像进行预处理后,消除了背景冗余,提高了图像质量,使得后续检测得以进行。Further, after the image is preprocessed, the background redundancy is eliminated, the image quality is improved, and the subsequent detection can be carried out.
进一步的,进行灰度校正后,可将待测丝印与模板丝印调整到基本相同的灰度水平,大大降低了光照变化对检测的影响。Further, after grayscale correction, the silkscreen to be tested and the template silkscreen can be adjusted to basically the same gray level, which greatly reduces the influence of illumination changes on detection.
进一步的,分块匹配后,可以提高每一子模板的定位精度,防止了丝印各版块内容间的位置及角度误差带来误报,同时基于ORB特征的匹配具有较高的准确率与实时性。Further, after block matching, the positioning accuracy of each sub-template can be improved, preventing false positives caused by the position and angle errors between the contents of the screen printing blocks, and the matching based on ORB features has high accuracy and real-time performance. .
进一步的,可以快速提取图像特征点,高效省时,为构建rBRIEF描述子提供前提条件。Further, image feature points can be quickly extracted, which is efficient and time-saving, and provides prerequisites for constructing rBRIEF descriptors.
进一步的,构建了二进制字符串形式的特征描述子,形式简单,大大节省了存储空间,降低了匹配耗时,同时该描述子对旋转具有不变性,提高了算法的适应性。Furthermore, a feature descriptor in the form of a binary string is constructed, which has a simple form, greatly saves storage space, and reduces the time-consuming of matching. At the same time, the descriptor is invariant to rotation, which improves the adaptability of the algorithm.
进一步的,通过计算汉明距离来度量二进制描述子的相似度,简单高效,筛选出了模板与待测图像的对应点从而完成匹配定位。Further, by calculating the Hamming distance to measure the similarity of the binary descriptors, it is simple and efficient, and the corresponding points between the template and the image to be tested are screened out to complete the matching and positioning.
进一步的,插画检测中通过图像作差和腐蚀膨胀处理,可以有效消除轮廓伪缺陷,准确分离插画真实缺陷。Further, through image aberration and corrosion expansion processing in the illustration detection, contour false defects can be effectively eliminated, and the real defects of the illustration can be accurately separated.
进一步的,文字检测中通过提取文字骨架可有效避免文字线条粗细不均带来的误报,通过“米”字型平移策略可以进一步降低文字位置一致性较差带来的误报干扰。Further, in the text detection, by extracting the text skeleton, the false positives caused by the uneven thickness of the text lines can be effectively avoided, and the false positive interference caused by the poor text position consistency can be further reduced by the "mi" font translation strategy.
进一步的,将模板与待测丝印视作连续帧图像,通过L-K光流计算和投影变换可以准确地校正丝印中发生的微量扭曲变形,消除了此类扭曲变形的误报干扰。Further, the template and the silk screen to be tested are regarded as continuous frame images, and the slight distortion in the silk screen can be accurately corrected through L-K optical flow calculation and projection transformation, eliminating the false alarm interference of such distortion.
综上所述,本发明实时性好、检测率高,通过改进传统差影法,并将光流法引入印刷缺陷检测领域内,大大提升了对非精确印刷的适应性与检测率。To sum up, the present invention has good real-time performance and high detection rate. By improving the traditional aberration method and introducing the optical flow method into the field of printing defect detection, the adaptability and detection rate of inaccurate printing are greatly improved.
下面通过附图和实施例,对本发明的技术方案做进一步的详细描述。The technical solutions of the present invention will be further described in detail below through the accompanying drawings and embodiments.
附图说明Description of drawings
图1为本发明流程图;Fig. 1 is the flow chart of the present invention;
图2为预处理图,其中,(a)为原始图,(b)为预处理图像;Figure 2 is a preprocessing image, wherein (a) is the original image, and (b) is the preprocessing image;
图3为预处理流程图;Fig. 3 is a preprocessing flow chart;
图4为十字分割流程图,其中,(a)为十字开窗,(b)为Ostu二值化,(c)为Ostu阈值偏移,(d)为形态学开运算;Fig. 4 is a flow chart of cross segmentation, wherein (a) is cross windowing, (b) is Ostu binarization, (c) is Ostu threshold shift, and (d) is morphological opening operation;
图5为灰度校正图,其中,(a)为模板图像,(b)为校正前待测图像,(c)为校正后待测图像;5 is a grayscale correction diagram, wherein (a) is a template image, (b) is an image to be tested before correction, and (c) is an image to be tested after correction;
图6为分块示意图;6 is a block diagram;
图7为基于ORB特征模板匹配流程图;Fig. 7 is a flowchart of template matching based on ORB feature;
图8为oFAST检测原理图;Figure 8 is a schematic diagram of oFAST detection;
图9为oFAST检测结果图;Fig. 9 is oFAST detection result graph;
图10为rBRIEF点对示意图;Figure 10 is a schematic diagram of rBRIEF point pair;
图11为ORB算法匹配结果图;Figure 11 is the ORB algorithm matching result diagram;
图12为缺陷分离提取流程图;12 is a flowchart of defect separation and extraction;
图13为插画检测流程图;Figure 13 is a flowchart of illustration detection;
图14为文字检测流程图;Figure 14 is a flow chart of text detection;
图15为平移策略示意图;15 is a schematic diagram of a translation strategy;
图16为扭曲丝印示意图,其中,(a)为重合度对比,(b)为差影检测结果;Figure 16 is a schematic diagram of twisted silk screen printing, wherein (a) is the comparison of the coincidence degree, and (b) is the difference shadow detection result;
图17为某光流场示意图;17 is a schematic diagram of an optical flow field;
图18为L-K光流法检测流程图;Fig. 18 is the L-K optical flow method detection flow chart;
图19为丝印校正示意图。FIG. 19 is a schematic diagram of screen printing calibration.
具体实施方式Detailed ways
本发明提供了一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法,首先进行预处理阶段:相机采集到的原始图像包含了较多背景干扰和噪声,并且倾斜程度各不相同,所以需要在本阶段对其进行裁切校正、仿射变换以及灰度校正等;然后模板匹配阶段:基于ORB算法提取模板丝印和待测丝印的特征并匹配,实现对丝印内容的定位;最后缺陷分离提取阶段:在本阶段首先采用基于形态学的差影法进行初步检测,对于出现不规律扭曲变形的丝印采用基于L-K光流法的扭曲校正检测方法,进行二次检测。The invention provides a battery silk screen quality detection method based on ORB feature matching and LK optical flow method. First, a preprocessing stage is performed: the original image collected by the camera contains a lot of background interference and noise, and the inclination degrees are different. Therefore, it is necessary to perform cropping correction, affine transformation and grayscale correction at this stage; then the template matching stage: based on the ORB algorithm, the characteristics of the template silkscreen and the silkscreen to be tested are extracted and matched to realize the positioning of the silkscreen content; the final defect Separation and extraction stage: In this stage, the difference shadow method based on morphology is used for preliminary detection, and the distortion correction detection method based on L-K optical flow method is used for the secondary detection of screen printing with irregular distortion.
请参阅图1,本发明一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法,包括以下步骤:Please refer to FIG. 1 , a battery silk screen quality detection method based on ORB feature matching and LK optical flow method of the present invention includes the following steps:
S1、图像预处理S1, image preprocessing
相机采集到的原始图像包含了较多背景干扰和噪声,并且倾斜程度各不相同,所以需要在本阶段对其进行裁切校正、仿射变换以及灰度校正等;如图2所示,(a)为原始图像,(b)为预处理后的图像。The original image collected by the camera contains a lot of background interference and noise, and the degree of inclination is different, so it is necessary to perform cropping correction, affine transformation, and grayscale correction at this stage; as shown in Figure 2, ( a) is the original image, (b) is the preprocessed image.
请参阅图3,原始图像视场内容包括背景载物台、夹具、金属电极片等干扰区域,影响了后续检测,因此,需要进行预处理以提取电芯丝印区域,提取步骤为:Please refer to Figure 3. The original image field of view includes interference areas such as the background stage, fixtures, and metal electrode sheets, which affect subsequent detection. Therefore, preprocessing is required to extract the cell silk screen area. The extraction steps are:
S101、根据原始图像尺寸创建十字交叉矩形窗,对原始图像进行裁剪,其目的为获取电芯丝印区域的边界信息;S101, creating a crossed rectangular window according to the size of the original image, and cropping the original image, the purpose of which is to obtain the boundary information of the screen printing area of the cell;
请参阅图4,通过上述处理,成功获取了电池丝印区域的上、下、左、右四个边界的信息,并且去掉了大量的与检测无关的背景冗余。Referring to FIG. 4 , through the above processing, the information of the upper, lower, left and right borders of the screen printing area of the battery is successfully obtained, and a large amount of background redundancy irrelevant to detection is removed.
S102、利用Ostu算法计算二值化阈值,将丝印区域与其他背景初步分离,并结合图像灰度特征对该阈值进行适当偏移以准确分离电芯丝印区域和其他背景,最后通过形态学开运算去除边缘毛刺,消除边缘细小的分割误差,处理效果如图4所示;S102, use the Ostu algorithm to calculate the binarization threshold, initially separate the silk screen area from other backgrounds, and appropriately offset the threshold value in combination with the grayscale features of the image to accurately separate the cell silk screen area and other backgrounds, and finally perform a morphological opening operation Remove edge burrs and eliminate small edge segmentation errors. The processing effect is shown in Figure 4;
S103、对上述提取出来的区域利用相关算法进行最小外接矩形拟合,根据拟合结果对原始图像进行裁剪,以获得准确的电池丝印区域;S103 , using a correlation algorithm to perform minimum circumscribed rectangle fitting on the extracted area, and crop the original image according to the fitting result to obtain an accurate battery silk screen area;
S104、对待测图像进行灰度校正,调整到与模板图像相同的灰度水平,以解决光照不稳定带来的影响,提高检测准确度,这对后续检测至关重要。S104, perform grayscale correction on the image to be tested, and adjust it to the same grayscale level as the template image, so as to solve the influence of unstable illumination and improve the detection accuracy, which is very important for subsequent detection.
本发明采用的灰度校正方法具体为:The grayscale correction method adopted by the present invention is specifically:
S1041、首先将图像灰度化,将原始三通道图像转换为单通道灰度图像,人眼对绿色敏感最高,对蓝色敏感最低,故采用心理学灰度公式:S1041. First, the image is grayscaled, and the original three-channel image is converted into a single-channel grayscale image. The human eye is most sensitive to green and the least sensitive to blue, so the psychological grayscale formula is adopted:
gray=0.299*red+0.587*green+0.114*blue (1)gray=0.299*red+0.587*green+0.114*blue (1)
S1042、利用阈值分割方法划分前景区域R1和背景区域R2;分别计算前景区域和背景区域的灰度均值,对待测图像和模板图像分别执行上述操作,灰度均值计算公式如公式2所示:S1042, divide the foreground area R 1 and the background area R 2 by using a threshold segmentation method; calculate the gray mean value of the foreground area and the background area, respectively, perform the above operations on the image to be tested and the template image, and the gray mean value calculation formula is shown in formula 2 :
其中,Ri为阈值分割后提取的区域(前景或者后景区域),p为区域内一像素点,g(p)为点p处的灰度值,F为Ri内像素点总数;Among them, R i is the region (foreground or background region) extracted after threshold segmentation, p is a pixel in the region, g(p) is the gray value at point p, and F is the total number of pixels in R i ;
S1043、对待测图像进行灰度变换,经过上述计算,获得了四个关键值:模板前景(丝印内容)灰度均值M1、模板背景灰度均值M2、待测图像前景(丝印内容)灰度均值T1、待测图像背景灰度均值T2,以此四个数据为基础,进行灰度变换,分别计算灰度放缩系数Mult和灰度平移系数Add,利用这两个系数对待测图像的原始灰度进行映射校正,各公式如下:S1043. Perform grayscale transformation on the image to be tested, and through the above calculation, four key values are obtained: the grayscale mean value M 1 of the template foreground (screen printing content), the template background gray mean value M 2 , the foreground (screen printing content) gray value of the image to be tested The gray scale mean T 1 and the background gray mean T 2 of the image to be tested are based on these four data, and the gray scale transformation is performed to calculate the gray scale scaling coefficient Mult and the gray scale translation coefficient Add respectively, and use these two coefficients to be tested. The original grayscale of the image is mapped and corrected, and the formulas are as follows:
Mult=(M1-M2)/(T1-T2) (3)Mult=(M 1 -M 2 )/(T 1 -T 2 ) (3)
Add=M1-Mult*T1 (4)Add=M 1 -Mult*T 1 (4)
g'=g*Mult+Add (5)g'=g*Mult+Add (5)
其中,Mult为灰度放缩系数,Add为灰度平移系数,g’为映射后的新灰度值,原始图像经过上述处理后的效果如图5所示,其中,(a)为模板图像,(b)为待测图像(校正前),(c)为待测图像(校正后);由图5可以看出,经过灰度变换后待测图像对比度、亮度等特征与模板图像已经非常接近,这为后续模板匹配算法的实施和缺陷分离提取提供了良好的条件。Among them, Mult is the gray scale scaling coefficient, Add is the gray scale translation coefficient, g' is the new gray value after mapping, and the effect of the original image after the above processing is shown in Figure 5, where (a) is the template image , (b) is the image to be tested (before correction), (c) is the image to be tested (after correction); it can be seen from Figure 5 that the contrast, brightness and other characteristics of the image to be tested after grayscale transformation are very different from the template image. close, which provides good conditions for the implementation of subsequent template matching algorithms and defect separation and extraction.
S2、模板匹配阶段S2, template matching stage
基于ORB算法提取模板丝印和待测丝印的特征并匹配,实现对丝印内容的定位;Based on the ORB algorithm, the characteristics of the template silkscreen and the silkscreen to be tested are extracted and matched to realize the positioning of the silkscreen content;
请参阅图6,预处理结束后,需要对待测图像上的各部分丝印内容进行识别定位,ORB特征检测运行时间远远优于SIFT算法和SURF算法,可应用于实时性特征检测,故本发明采用基于ORB特征的模板匹配算法,同时由于电池丝印图像尺寸较大,并且丝印内容一致性较差,不同丝印内容之间存在旋转和位置误差,故本发明采用矩形分块的方式进行建模。Please refer to Fig. 6. After the preprocessing, it is necessary to identify and locate each part of the silkscreen content on the image to be tested. The running time of ORB feature detection is much better than that of the SIFT algorithm and the SURF algorithm, and can be applied to real-time feature detection. Therefore, the present invention The template matching algorithm based on ORB features is adopted. At the same time, due to the large size of the screen printing image of the battery, the poor consistency of the screen printing content, and the rotation and position errors between different screen printing contents, the present invention adopts a rectangular block method for modeling.
包括插画部分模板和文字部分模板,各个子模板按照次序依次建立,每个子模板在当次建模完成后都会被灰度值为0的矩形掩膜覆盖,然后继续进行建模,所以图中各矩形框之间有交叠;接着利用ORB模板匹配算法进行匹配定位(Oriented FAST and RotatedBRIEF ORB),主要分为以下三个步骤:Including the illustration part template and the text part template, each sub-template is established in sequence, and each sub-template will be covered by a rectangular mask with a gray value of 0 after the current modeling is completed, and then continue modeling, so each sub-template in the figure will be covered. There is overlap between the rectangular boxes; then the ORB template matching algorithm is used for matching positioning (Oriented FAST and RotatedBRIEF ORB), which is mainly divided into the following three steps:
(1)oFAST特征点检测;(1) oFAST feature point detection;
(2)rBRIEF特征描述;(2) rBRIEF feature description;
(3)特征点的匹配。(3) Matching of feature points.
请参阅图7,检测流程及技术细节步骤如下:Please refer to Figure 7, the detection process and technical details are as follows:
S201、oFAST特征点提取;S201, oFAST feature point extraction;
请参阅图8,oFAST角点检测是一种快速角点特征检测算法,具体是对兴趣点及其周围区域的16个像素点灰度进行判断,通常该区域选择圆形区域,其判断方法如下:Please refer to Figure 8. oFAST corner detection is a fast corner feature detection algorithm. Specifically, it judges the grayscale of 16 pixels of the point of interest and its surrounding area. Usually, a circular area is selected for this area. The judgment method is as follows :
将P点的灰度值和以P为中心半径为3的邻域内的16个像素点的灰度值进行比较,如果P点的像素值和圆圈上邻域内n个连续的像素点的像素值相减大于阈值t,那么就认为点P是一个特征点。Compare the gray value of point P with the gray value of 16 pixels in the neighborhood with P as the center and a radius of 3. If the pixel value of point P and the pixel value of n consecutive pixels in the neighborhood on the circle The subtraction is greater than the threshold t, then the point P is considered to be a feature point.
oFAST算法具有良好的尺度不变性和旋转不变性,某块子图像经oFAST算法提取的特征点如图9所示。The oFAST algorithm has good scale invariance and rotation invariance. The feature points of a sub-image extracted by the oFAST algorithm are shown in Figure 9.
S202、rBRIEF特征描述子构造;S202, rBRIEF feature descriptor structure;
得到特征点后我们需要以某种方式描述这些特征点的属性,这种描述称为特征描述子,ORB算法采用rBRIEF算法来计算描述子。操作为在关键点P的周围以一定模式选取N个点对,把这N个点对的比较结果组合起来作为描述子。所有的点对都进行比较,则生成长度为n的二进制串,一般N取128、256或512。After obtaining the feature points, we need to describe the attributes of these feature points in a certain way. This description is called a feature descriptor. The ORB algorithm uses the rBRIEF algorithm to calculate the descriptor. The operation is to select N point pairs in a certain pattern around the key point P, and combine the comparison results of these N point pairs as a descriptor. All point pairs are compared, and a binary string of length n is generated. Generally, N takes 128, 256 or 512.
请参阅图10,以关键点P为圆心,以d为半径做圆O,在圆O内某一模式选取N个点对。假设当前选取的4个点对如图10所示,此时比较每个点对中Ai和Bi灰度值相对大小,可得长度为4的二进制描述子串,如1011。ORB在计算rBRIEF描述子时建立的坐标系是以关键点为原点,以关键点和取点区域的质心的连线为X轴建立2维坐标系,这样描述子就具有了旋转不变性。Please refer to Figure 10, take the key point P as the center of the circle, and take d as the radius to make a circle O, and select N point pairs in a certain pattern in the circle O. Assuming that the currently selected 4 point pairs are shown in Figure 10, at this time, compare the relative sizes of the gray values of A i and B i in each point pair, and obtain a binary description substring of length 4, such as 1011. The coordinate system established by ORB when calculating the rBRIEF descriptor takes the key point as the origin, and establishes a 2-dimensional coordinate system with the line connecting the key point and the centroid of the point region as the X-axis, so that the descriptor has rotation invariance.
S203、特征点匹配;S203, feature point matching;
ORB算法最大特点为计算速度快。本发明匹配时采用描述子之间的汉明距离作为相似性测度,两个等长二进制串之间的汉明距离是两个字符串对应位置的不同字符的个数,也代表了两个二进制串的相似程度,通过设置相似度阈值进行匹配点对的筛选。根据汉明距离得到的匹配结果如图11所示。The biggest feature of ORB algorithm is the fast calculation speed. The present invention uses the Hamming distance between descriptors as a similarity measure when matching, and the Hamming distance between two binary strings of equal length is the number of different characters in the corresponding positions of the two strings, and also represents the two binary strings. The similarity of the strings is selected by setting the similarity threshold to filter the matching point pairs. The matching results obtained according to the Hamming distance are shown in Figure 11.
获得上述匹配结果后,根据模板图像和待测图像中ORB特征点的对应关系,对模板和待测图像进行配准。至此,模板匹配阶段工作完成,将模板图像中的各个矩形子模板与待测图像中的各个部分完成了匹配。After the above matching results are obtained, the template and the image to be tested are registered according to the corresponding relationship between the ORB feature points in the template image and the image to be tested. So far, the template matching stage is completed, and each rectangular sub-template in the template image is matched with each part in the image to be tested.
S3、基于光流法和形态学图像差影法进行缺陷分离提取S3. Defect separation and extraction based on optical flow method and morphological image aberration method
首先对所有丝印统一使用基于形态学的差影法进行检测,检测结果若正常,则执行分拣操作;检测结果若出现大量误报,则使用基于L-K光流法的扭曲校正检测方法进行二次检测,以此消除误判。First, all silk screen prints are detected by the morphological-based difference shadow method. If the detection results are normal, the sorting operation is performed; if there are a large number of false positives in the detection results, the distortion correction detection method based on the L-K optical flow method is used for the second time. detection to eliminate false positives.
请参阅图12,缺陷分离提取阶段的流程图及技术细节具体为:Please refer to Figure 12. The flowchart and technical details of the defect separation and extraction stage are as follows:
S301、基于形态学的图像差影法缺陷分析算法;S301. An image aberration defect analysis algorithm based on morphology;
将丝印内容分为插画和文字部分两大类型,根据其各自特点分别设计子算法,以达到最好的检测效果。The screen printing content is divided into two types: illustration and text, and sub-algorithms are designed according to their respective characteristics to achieve the best detection effect.
请参阅图13,插画区域油墨集中,线条简单,根据这一特点设计如下检测流程:Please refer to Figure 13. The ink in the illustration area is concentrated and the lines are simple. According to this feature, the following detection process is designed:
S3011、根据匹配结果可以得到对应点关系,据此计算刚体变换矩阵,将子模板图像与待测图像进行对准,利用阈值分割法将检测内容从背景分割出来;S3011, the corresponding point relationship can be obtained according to the matching result, and the rigid body transformation matrix is calculated accordingly, the sub-template image is aligned with the image to be tested, and the detection content is segmented from the background by a threshold segmentation method;
S3012、对分割出来的丝印内容进行形态学腐蚀和膨胀处理,目的为防止图案边界不重合导致轮廓伪缺陷。通过待测品和模板的正反作差可以获得多印类缺陷和漏印类缺陷,如下所示:S3012 , performing morphological corrosion and expansion processing on the segmented silk-screen content, in order to prevent false contour defects caused by misalignment of pattern boundaries. Multi-print defects and missing-print defects can be obtained by the difference between the positive and negative of the product to be tested and the template, as shown below:
多印类缺陷:Multiprint Defects:
T(腐蚀)-M(膨胀) T (corrosion) -M (expansion)
漏印类缺陷:Missing printing defects:
M(腐蚀)-T(膨胀) M (corrosion) -T (expansion)
S3013、对作差后的差图像进行连通分析与阈值筛选,超出阈值的区域即为缺陷区域;S3013, performing connectivity analysis and threshold screening on the difference image after the difference, and the area exceeding the threshold is the defect area;
S3014、缺陷定位与标记:以缺陷中心为圆心,利用缺陷的最小外接圆对缺陷进行标记。S3014, defect location and marking: take the center of the defect as the center of the circle, and use the minimum circumcircle of the defect to mark the defect.
以上是对插画部分检测方法的介绍,而文字部分线条精细复杂,缺陷更加细小。The above is an introduction to the detection method of the illustration part, while the lines of the text part are fine and complex, and the defects are more subtle.
请参阅图14,文字部分缺陷检测方法流程如下:Please refer to Figure 14, the process of the text part defect detection method is as follows:
S3015、仿射变换配准:同插画检测;S3015, affine transformation registration: same as illustration detection;
S3016、骨架提取:采用骨架提取的原因在于文字线条比较精细复杂,且线条粗细不均匀。若采用膨胀腐蚀处理会破坏文字拓扑结构,并且参数难以调节,故本发明对文字进行骨架提取处理。提取后文字线条统一为单像素宽度,只保留其拓扑结构,而不受粗细影响;S3016, skeleton extraction: the reason for using skeleton extraction is that the text lines are relatively fine and complex, and the thickness of the lines is uneven. If the expansion corrosion treatment is used, the topological structure of the text will be destroyed, and the parameters are difficult to adjust, so the present invention performs skeleton extraction processing on the text. After extraction, the text lines are unified to a single-pixel width, and only their topology is retained without being affected by the thickness;
S3017、图像平移作差:对提取出来的文字进行“米”字型平移处理,即上、下、左、右、左上、右上、左下、右下8个方向,然后进行图像作差,获得8个差图像。平移作差原因在于丝印内容位置一致性较差,会有微量的位置偏差,单次直接作差会带来大量误报,如图15所示;S3017, image translation difference: perform "m" font translation processing on the extracted text, namely up, down, left, right, upper left, upper right, lower left, and lower right 8 directions, and then perform image difference to obtain 8 poor image. The reason for the translation error is that the position consistency of the silk screen content is poor, and there will be a small amount of position deviation. A single direct error will bring a large number of false alarms, as shown in Figure 15;
S3018、差影交运算:对上步获得的8个差图像进行交运算,最终保留的区域视为真实缺陷区域;S3018, difference shadow intersection operation: perform the intersection operation on the 8 difference images obtained in the previous step, and the final reserved area is regarded as the real defect area;
S3019、连通分析阈值筛选及缺陷标记:同插画检测;S3019. Connectivity analysis threshold screening and defect marking: same as illustration detection;
S302、基于L-K光流法的扭曲校正检测算法S302. Distortion correction detection algorithm based on L-K optical flow method
经过检测,大部分缺陷均可正常检测,但对于极少一部分丝印产品,由于印刷工艺其印刷内容会发生微量扭曲变形,而且无法引起人类视觉异常,此类属于印刷良品范畴,但此类产品在3.1检测方法即差影法检测下会判定为不良品,属于本次检测中的难点,如图16所示为微量扭曲变形的示意图,观察可知,在(a)图中,模板丝印和待测丝印重合度较低,且为不规律扭曲变形,但待测丝印属于良品范畴,经直接检测后,产生了大量误报,如右侧(b)图所示。故本发明提出基于L-K光流法的扭曲校正检测算法,创造性地将光流法引入表面缺陷检测领域,可对发生微量扭曲变形的产品进行准确检测,防止误报产生。After testing, most of the defects can be detected normally, but for a very small part of screen printing products, due to the printing process, the printed content will be slightly distorted and deformed, and it cannot cause abnormal human vision. This category belongs to the category of good printing products, but such products are in the 3.1 The detection method, that is, the differential shadow method, will be judged as a defective product, which is a difficult point in this detection. Figure 16 shows a schematic diagram of a small amount of distortion. It can be seen from the observation that in the picture (a), the template silk screen and the under test The screen printing has a low degree of coincidence and is irregularly distorted, but the screen printing to be tested belongs to the category of good products. After direct detection, a large number of false positives have been generated, as shown in the figure (b) on the right. Therefore, the present invention proposes a distortion correction detection algorithm based on the L-K optical flow method, and creatively introduces the optical flow method into the field of surface defect detection, which can accurately detect products with slight distortion and prevent false alarms.
其检测流程及技术细节如下:The testing process and technical details are as follows:
光流是空间运动物体在观察成像平面上的像素运动的瞬时速度,光流法是利用图像序列中像素在时间域上的变化以及相邻帧之间的相关性来找到上一帧跟当前帧之间存在的对应关系,从而计算出相邻帧之间物体的运动信息的一种方法。通常将二维图像平面特定坐标点上的灰度瞬时变化率定义为光流矢量,在时间间隔很小(比如视频的连续前后两帧之间)时,也等同于目标点的位移,某处丝印图像计算得出的光流场示意图如图17所示。Optical flow is the instantaneous speed of pixel motion of space moving objects on the observation imaging plane. The optical flow method uses the changes of pixels in the image sequence in the time domain and the correlation between adjacent frames to find the previous frame and the current frame. A method for calculating the motion information of objects between adjacent frames. Usually, the instantaneous rate of change of gray level on a specific coordinate point of the two-dimensional image plane is defined as the optical flow vector. When the time interval is small (such as between two consecutive frames of the video), it is also equivalent to the displacement of the target point. The schematic diagram of the optical flow field calculated from the silk screen image is shown in Figure 17.
由于应用于输入图像的一组点上时比较方便,因此本发明选用L-K光流法,该算法基于以下三个假设:Because it is more convenient to apply to a set of points in the input image, the present invention selects the L-K optical flow method, which is based on the following three assumptions:
(1)相邻帧之间的亮度恒定;(1) The brightness between adjacent frames is constant;
(2)相邻视频帧的取帧时间连续,或者相邻帧之间物体的运动比较“微小”;(2) The frame-taking time of adjacent video frames is continuous, or the movement of objects between adjacent frames is relatively "small";
(3)保持空间一致性;即同一子图像的像素点具有相同的运动。(3) Maintaining spatial consistency; that is, the pixels of the same sub-image have the same motion.
其基本思路为:The basic idea is:
设I(x,y,t)在t时刻图像上点P(x,y)处的亮度,I(x+dx,y+dy,t+dt)为t+dt时刻图像上点(x,y)的对应点P’处的亮度,根据亮度一致性假设,得到:Let I(x,y,t) be the brightness at point P(x,y) on the image at time t, I(x+dx,y+dy,t+dt) is the point (x, t+dt) on the image at time t+dt The brightness at the corresponding point P' of y), according to the assumption of brightness consistency, we get:
I(x,y,t)=I(x+dx,y+dy,t+dt) (9)I(x,y,t)=I(x+dx,y+dy,t+dt) (9)
根据光流的定义(u,v)=(dx/dt,dy/dt),利用泰勒展开可得:According to the definition of optical flow (u, v) = (dx/dt, dy/dt), Taylor expansion can be used to obtain:
Ixu+Iyv+It=0 (10)I x u+I y v+I t =0 (10)
上式为基本光流约束方程,一个方程无法求解两个未知量,此时需要引入另外的约束条件才能对两个速度矢量进行求解,根据假设(3)可得n个方程,再结合最小二乘法求解可得L-K光流:The above formula is the basic optical flow constraint equation. One equation cannot solve two unknowns. At this time, another constraint needs to be introduced to solve the two velocity vectors. According to assumption (3), n equations can be obtained, and then combined with the least squares Multiplication solution can get L-K optical flow:
其中,即为所求,也就是计算得到的L-K光流。in, That is, what is required, that is, the calculated LK optical flow.
请参阅图18,将模板图像和待测图像视为视频中的连续帧图像,将待测图像中出现的不规律微小扭曲变形视为局部微量运动,其检测流程如下:Referring to Figure 18, the template image and the image to be tested are regarded as continuous frame images in the video, and the irregular and small distortions in the image to be tested are regarded as local micro-motion. The detection process is as follows:
S3021、利用L-K光流法就可以计算出两幅图像之间的光流场,如图17所示,该光流场任意位置(i,j)上的光流矢量Vi,j构成为:S3021. The optical flow field between the two images can be calculated by using the LK optical flow method. As shown in Figure 17, the optical flow vector V i,j at any position (i, j) of the optical flow field is composed of:
Vi,j=(x,y) (12)Vi ,j = (x,y) (12)
其中,x值代表了待测图像在(i,j)点的行偏移量,y值则代表了列偏移量;Among them, the x value represents the row offset of the image to be tested at point (i, j), and the y value represents the column offset;
S3022、分解光流矢量Vi,j获取其分量x和y,构成两个数据集{x}和{y};S3022, decompose the optical flow vector V i,j to obtain its components x and y to form two data sets {x} and {y};
S3023、对待测图像进行阈值分割,获取丝印前景区域T,统计区域T内所有点的坐标(i,j);S3023, perform threshold segmentation on the image to be tested, obtain the screen printing foreground area T, and count the coordinates (i, j) of all points in the area T;
S3024、计算对应点集,待测图像相比模板图像,在坐标(i,j)处的像素点由于扭曲变形移动到了坐标(i+x,j+y)处;S3024, calculate the corresponding point set, the image to be tested is compared with the template image, and the pixel at the coordinate (i, j) is moved to the coordinate (i+x, j+y) due to distortion;
S3025、以(i,j)和(i+x,j+y)作为对应点集,计算投影变换矩阵A,以此矩阵对待测丝印进行投影变换,实现对微小变形的校正,校正后的图像如图19所示。由图19可以看到,待测丝印和模板丝印的重合度已经比较高,扭曲变形现象已经基本消除,便于后续检测;S3025, using (i, j) and (i+x, j+y) as the corresponding point sets, calculate the projection transformation matrix A, and perform projection transformation on the silk screen to be measured with this matrix, so as to realize the correction of the slight deformation, and the corrected image As shown in Figure 19. As can be seen from Figure 19, the degree of coincidence between the silk screen to be tested and the template silk screen has been relatively high, and the distortion phenomenon has been basically eliminated, which is convenient for subsequent detection;
S3026、对校正后的待测图像和模板图像再次进行差影处理,进行类似步骤S301中提出的缺陷分离提取处理,并做最终的标记。S3026 , perform aberration processing on the corrected image to be tested and the template image again, perform defect separation and extraction processing similar to that proposed in step S301 , and make a final mark.
经过上述方法的处理后,可以实现对微量扭曲变形丝印的正常检测,不产生误报,极大得提高了方法的实用性,可以满足企业流水线的实时性检测,并能保证较高的检测准确率。After the processing of the above method, the normal detection of micro-distorted silk screen printing can be realized without false alarms, which greatly improves the practicability of the method, can meet the real-time detection of enterprise pipelines, and can ensure high detection accuracy. Rate.
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。通常在此处附图中的描述和所示的本发明实施例的组件可以通过各种不同的配置来布置和设计。因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. The components of the embodiments of the invention generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations. Thus, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
采用本发明一种基于ORB特征匹配和LK光流法的电池丝印质量检测方法进行在线测试,通过对1000块待检丝印进行在线测试,981块丝印可正确检出,检测率为98.1%,其中,11块良品丝印被判断为不良品,8块不良品丝印被判断为良品。By adopting the battery screen printing quality detection method based on ORB feature matching and LK optical flow method of the present invention for online testing, 981 screen printings can be correctly detected by online testing of 1000 screen printings to be inspected, and the detection rate is 98.1%, of which , 11 pieces of good screen printing were judged as defective products, and 8 pieces of bad screen printing were judged as good products.
而传统的全局模板匹配法对相同样本的检测率仅为49%,完全无法适应对此类非精确型印刷品的检测。However, the detection rate of the traditional global template matching method for the same sample is only 49%, which is completely unsuitable for the detection of such inaccurate prints.
综上所述,本发明所述检测方法相比传统检测方法检测率高,实时性好,对于非精确型印刷品如扭曲变形、位置角度误差等等具有强大的适应性,可以准确分离出真实缺陷而不产生误报。To sum up, the detection method of the present invention has high detection rate and good real-time performance compared with the traditional detection method, and has strong adaptability to inaccurate printed matter such as distortion, position angle error, etc., and can accurately separate real defects. without generating false positives.
以上内容仅为说明本发明的技术思想,不能以此限定本发明的保护范围,凡是按照本发明提出的技术思想,在技术方案基础上所做的任何改动,均落入本发明权利要求书的保护范围之内。The above content is only to illustrate the technical idea of the present invention, and cannot limit the protection scope of the present invention. Any modification made on the basis of the technical solution proposed in accordance with the technical idea of the present invention falls within the scope of the claims of the present invention. within the scope of protection.
Claims (7)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010085060.3A CN111275697B (en) | 2020-02-10 | 2020-02-10 | Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010085060.3A CN111275697B (en) | 2020-02-10 | 2020-02-10 | Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111275697A CN111275697A (en) | 2020-06-12 |
| CN111275697B true CN111275697B (en) | 2022-04-22 |
Family
ID=71002140
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010085060.3A Active CN111275697B (en) | 2020-02-10 | 2020-02-10 | Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111275697B (en) |
Families Citing this family (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112560858B (en) * | 2020-10-13 | 2023-04-07 | 国家计算机网络与信息安全管理中心 | Character and picture detection and rapid matching method combining lightweight network and personalized feature extraction |
| CN112164058B (en) * | 2020-10-13 | 2024-09-17 | 东莞市瑞图新智科技有限公司 | Silk screen region coarse positioning method and device for optical filter and storage medium |
| CN113063731B (en) * | 2021-03-24 | 2023-01-20 | 上海晨兴希姆通电子科技有限公司 | Detection system and detection method for rotary disc type glass cover plate silk screen printing |
| CN113191348B (en) * | 2021-05-31 | 2023-02-03 | 山东新一代信息产业技术研究院有限公司 | Template-based text structured extraction method and tool |
| CN113516584B (en) * | 2021-09-14 | 2021-11-30 | 风脉能源(武汉)股份有限公司 | Image gray processing method and system and computer storage medium |
| CN114120197B (en) * | 2021-11-27 | 2024-03-29 | 中国传媒大学 | Ultra-high definition video abnormal signal detection method for 2SI mode transmission |
| CN114612469B (en) * | 2022-05-09 | 2022-08-12 | 武汉中导光电设备有限公司 | Product defect detection method, device and equipment and readable storage medium |
| CN115775263A (en) * | 2022-12-16 | 2023-03-10 | 京东方科技集团股份有限公司 | Moving target tracking method, device, equipment and storage medium |
| CN116228746B (en) * | 2022-12-29 | 2024-08-23 | 摩尔线程智能科技(北京)有限责任公司 | Defect detection method, device, electronic apparatus, storage medium, and program product |
| CN116310289B (en) * | 2023-05-12 | 2023-08-08 | 苏州优备精密智能装备股份有限公司 | System and method for on-line measurement of ink-jet printing and real-time adjustment of printing position angle |
| CN117237331A (en) * | 2023-10-19 | 2023-12-15 | 武汉华中天经通视科技有限公司 | Patterned wafer defect detection method |
| CN117495852B (en) * | 2023-12-29 | 2024-05-28 | 天津中荣印刷科技有限公司 | A digital printing quality detection method based on image analysis |
| CN117963458B (en) * | 2024-03-27 | 2024-10-15 | 泰山学院 | A conveyor belt deviation detection method, system and inspection robot |
| CN120451139B (en) * | 2025-07-02 | 2025-09-19 | 征图新视(江苏)科技股份有限公司 | Defect detection method and defect detection equipment for circular printed matter |
Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104751465A (en) * | 2015-03-31 | 2015-07-01 | 中国科学技术大学 | ORB (oriented brief) image feature registration method based on LK (Lucas-Kanade) optical flow constraint |
| CN107389701A (en) * | 2017-08-22 | 2017-11-24 | 西北工业大学 | A kind of PCB visual defects automatic checkout system and method based on image |
| CN107680095A (en) * | 2017-10-25 | 2018-02-09 | 哈尔滨理工大学 | The electric line foreign matter detection of unmanned plane image based on template matches and optical flow method |
| CN108122256A (en) * | 2017-12-25 | 2018-06-05 | 北京航空航天大学 | It is a kind of to approach under state the method for rotating object pose measurement |
| CN108355987A (en) * | 2018-01-08 | 2018-08-03 | 西安交通大学 | A kind of screen printing of battery quality determining method based on piecemeal template matches |
| CN108986093A (en) * | 2018-07-19 | 2018-12-11 | 常州宏大智能装备产业发展研究院有限公司 | Cylinder or flat screen printing machine network blocking defect detection method based on machine vision |
| CN110264445A (en) * | 2019-05-30 | 2019-09-20 | 西安交通大学 | Quality detection method of battery screen printing based on block template matching combined with morphological processing |
| CN110503633A (en) * | 2019-07-29 | 2019-11-26 | 西安理工大学 | A method for surface defect detection of applique ceramic discs based on image difference |
| WO2019245320A1 (en) * | 2018-06-22 | 2019-12-26 | 삼성전자주식회사 | Mobile robot device for correcting position by fusing image sensor and plurality of geomagnetic sensors, and control method |
| CN110672617A (en) * | 2019-09-14 | 2020-01-10 | 华南理工大学 | Defect detection method in screen printing area of smartphone glass cover plate based on machine vision |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107662872B (en) * | 2016-07-29 | 2021-03-12 | 奥的斯电梯公司 | Monitoring system and monitoring method for passenger conveyor |
-
2020
- 2020-02-10 CN CN202010085060.3A patent/CN111275697B/en active Active
Patent Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104751465A (en) * | 2015-03-31 | 2015-07-01 | 中国科学技术大学 | ORB (oriented brief) image feature registration method based on LK (Lucas-Kanade) optical flow constraint |
| CN107389701A (en) * | 2017-08-22 | 2017-11-24 | 西北工业大学 | A kind of PCB visual defects automatic checkout system and method based on image |
| CN107680095A (en) * | 2017-10-25 | 2018-02-09 | 哈尔滨理工大学 | The electric line foreign matter detection of unmanned plane image based on template matches and optical flow method |
| CN108122256A (en) * | 2017-12-25 | 2018-06-05 | 北京航空航天大学 | It is a kind of to approach under state the method for rotating object pose measurement |
| CN108355987A (en) * | 2018-01-08 | 2018-08-03 | 西安交通大学 | A kind of screen printing of battery quality determining method based on piecemeal template matches |
| WO2019245320A1 (en) * | 2018-06-22 | 2019-12-26 | 삼성전자주식회사 | Mobile robot device for correcting position by fusing image sensor and plurality of geomagnetic sensors, and control method |
| CN108986093A (en) * | 2018-07-19 | 2018-12-11 | 常州宏大智能装备产业发展研究院有限公司 | Cylinder or flat screen printing machine network blocking defect detection method based on machine vision |
| CN110264445A (en) * | 2019-05-30 | 2019-09-20 | 西安交通大学 | Quality detection method of battery screen printing based on block template matching combined with morphological processing |
| CN110503633A (en) * | 2019-07-29 | 2019-11-26 | 西安理工大学 | A method for surface defect detection of applique ceramic discs based on image difference |
| CN110672617A (en) * | 2019-09-14 | 2020-01-10 | 华南理工大学 | Defect detection method in screen printing area of smartphone glass cover plate based on machine vision |
Non-Patent Citations (6)
| Title |
|---|
| "A Hybrid 3D Registration Method of Augmented Reality for Intelligent Manufacturing";Xian Yang等;《IEEE Access》;20191216;第181867-181883页 * |
| "AR Based on ORB Feature and KLT Tracking";Jie Ren等;《Applied Mechanics and Materials》;20130731;第333-340页 * |
| "一种改进光流法的运动目标检测及跟踪算法";李成美等;《仪器仪表学报》;20180531;第249-256页 * |
| "基于LK光流约束的ORB特征配准算法";刘嘉威等;《第三十四届中国控制会议论文集(C卷)》;20150731;第3914-3919页 * |
| "基于光流跟踪和特征匹配的视觉里程计研究";贾哲;《中国优秀硕士学位论文全文数据库 信息科技辑》;20190815;I138-952 * |
| "基于机器视觉的标签缺陷检测算法研究";殷红杰;《中国优秀硕士学位论文全文数据库 工程科技Ⅰ辑》;20190615;B024-274 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111275697A (en) | 2020-06-12 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111275697B (en) | Battery silk-screen quality detection method based on ORB feature matching and LK optical flow method | |
| CN105067638B (en) | Tire fetal membrane face character defect inspection method based on machine vision | |
| CN115546795B (en) | A method for automatic reading of circular pointer instruments based on deep learning | |
| CN112508826A (en) | Printed matter defect detection method based on feature registration and gradient shape matching fusion | |
| CN104568986A (en) | Method for automatically detecting printing defects of remote controller panel based on SURF (Speed-Up Robust Feature) algorithm | |
| CN109886954B (en) | A method for detecting defects in printed matter | |
| CN111242896A (en) | Color printing label defect detection and quality rating method | |
| CN105957082A (en) | Printing quality on-line monitoring method based on area-array camera | |
| CN111965197B (en) | Defect classification method based on multi-feature fusion | |
| CN114897881B (en) | A grain defect detection method based on edge features | |
| CN113705564B (en) | A method for identifying and reading pointer instruments | |
| CN110533660B (en) | Method for detecting silk-screen defect of electronic product shell | |
| CN114549446A (en) | A detection method for cylinder liner defect marks based on deep learning | |
| WO2021109011A1 (en) | Intelligent capacitor internal defect detection method based on ultrasound image | |
| CN114757913A (en) | A kind of display screen defect detection method | |
| CN106097368A (en) | A kind of recognition methods in veneer crack | |
| CN114596242A (en) | Defect detection method, apparatus, electronic device, and computer-readable storage medium | |
| CN116642907A (en) | Method, equipment and storage medium for detecting appearance defects of cell screen printing | |
| CN117830287A (en) | A circuit board online detection re-judgment algorithm | |
| CN114187247A (en) | Ampoule bottle printing character defect detection method based on image registration | |
| CN111798429A (en) | A visual inspection method for printed matter defects | |
| CN108629762A (en) | A kind of stone age evaluation and test model reduces the image pre-processing method and system of interference characteristic | |
| CN108764230A (en) | A kind of bank's card number automatic identifying method based on convolutional neural networks | |
| CN120125586B (en) | Industrial detection method, system and device based on multi-frame image registration | |
| CN116433978A (en) | Automatic generation and automatic labeling method and device for high-quality flaw image |
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 |





