Character defect detection method

文档序号:613292 发布日期:2021-05-07 浏览:2次 中文

阅读说明:本技术 一种字符缺陷检测方法 (Character defect detection method ) 是由 邓承建 张会 谷宏亮 于 2021-01-26 设计创作,主要内容包括:本发明属于视觉检测的技术领域,具体涉及一种字符缺陷检测方法,包括采集标准字符图像,采用滤波算法对标准字符图像进行图像处理,提取到标准字符的轮廓,并将其记为模板轮廓,将待检测的字符记为当前字符,采集当前字符图像,采用滤波算法对当前字符图像进行图像处理,提取到当前字符的轮廓,并将其记为当前轮廓,通过计算模板轮廓和当前轮廓的最大距离,实现模板轮廓和当前轮廓的比对,获得是否存在笔画缺失或者笔画重叠的字符缺陷检测结果。本发明有效地提高了字符缺陷检测的操作灵活度,其通用性强,检测效率高,可广泛适用于工业化的大批量的字符缺陷检测。(The invention belongs to the technical field of visual detection, and particularly relates to a character defect detection method which comprises the steps of collecting a standard character image, carrying out image processing on the standard character image by adopting a filtering algorithm, extracting the outline of the standard character, recording the outline of the standard character as a template outline, recording a character to be detected as a current character, collecting the current character image, carrying out image processing on the current character image by adopting the filtering algorithm, extracting the outline of the current character, recording the outline of the current character as the current outline, and comparing the template outline with the current outline by calculating the maximum distance between the template outline and the current outline to obtain a character defect detection result of whether stroke missing or stroke overlapping exists. The invention effectively improves the operation flexibility of character defect detection, has strong universality and high detection efficiency, and can be widely applied to industrialized large-batch character defect detection.)

1. A character defect detection method is characterized by comprising the following steps:

s1, collecting a standard character image, carrying out image processing on the standard character image by adopting a filtering algorithm, extracting the outline of a standard character, and recording the outline as a template outline;

s2, recording the character to be detected as the current character, collecting the current character image, processing the current character image by adopting a filtering algorithm, extracting the outline of the current character, and recording the outline as the current outline;

s3, comparing the template contour with the current contour by calculating the maximum distance between the template contour and the current contour, and obtaining the character defect detection result of whether stroke missing or stroke overlapping exists.

2. The character defect detecting method as claimed in claim 1, wherein said S3 includes the steps of:

s3-1, placing the template contour and the current contour in the same horizontal rectangular coordinate system, matching and aligning the template contour and the current contour, calculating the minimum distance from all points in the template contour to the current contour, and selecting the maximum value from all the distances as the maximum distance from the template contour to the current contour;

s3-2, calculating the minimum distance between the point of the current contour and the template contour, comparing the maximum distance between the point of the current contour and the template contour with the maximum distance between the template contour and the current contour, realizing the comparison between the template contour and the current contour, and outputting the detection result.

3. The character defect detecting method as claimed in claim 2, wherein the process of calculating the maximum distance from the template contour to the current contour in S3-1 comprises:

let P be { P ═ Pi=(xi,yi)|i∈(0,M]Is the set of points of the template profile, Q ═ Qk=(xk,yk)|k∈(0,N]Is the set of points of the current contour, where xiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkM is the total number of points of the template profile, N is the total number of points of the current profile, and P is the length of the template profileiThe minimum distance of a point to the current contour is:

the maximum distance from the template contour to the current contour is:

Dmax_i=max(Di)。

4. the character defect detecting method as claimed in claim 3, wherein said S3-2 further comprises:

the minimum distance from the points of the current contour to the template contour is:

the maximum distance from the point of the current contour to the template contour is:

Dmax_k=max(Dk);

the Dmax _ i represents the maximum distance from the template outline to the current outline, the Dmax _ k represents the maximum distance from the point of the current outline to the template outline, the Dmax _ i and the Dmax _ k are compared, and if the Dmax _ i is larger than the Dmax _ k, a character defect detection result with character stroke missing is output; and if Dmax _ i is smaller than Dmax _ k, outputting a character defect detection result with character stroke overlapping.

5. The character defect detecting method as claimed in claim 4, wherein said S3 further comprises the steps of:

superposing the current contour on the template contour, if the template contour is not coincident with the current contour, extracting each contour point of the template contour which is not coincident with the current contour, and calculating a contour point P of the template contour in each non-coincident contour pointiAnd a contour point Q of said current contourkMaximum distance D of coordinates ofik

Setting the threshold value of the current outline when the character is normal as J, and comparing J and DikAnd outputting a detection result by combining the size relationship between the total number M of the contour points of the template contour and the total number N of the contour points of the current contour.

6. The character defect detection method of claim 5, wherein the contour point P of the template contour is calculatediAnd a contour point Q of said current contourkMaximum distance D ofikThe formula of (1) is:

wherein x isiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkThe ordinate of (c).

7. The character defect detection method of claim 6, wherein: if D isik>J, and M>And N, outputting a character defect detection result with character stroke missing.

8. The character defect detection method of claim 6, wherein: if D isik>J, and N>And M, outputting a character defect detection result with character stroke overlapping.

9. The character defect detecting method as claimed in claim 1, wherein said process of image-processing said standard character image in S1 further comprises: and adjusting the contrast of the standard character image, and carrying out binarization processing on the standard character image.

10. The character defect detecting method as claimed in claim 1, wherein said process of image-processing said current character image in S2 further comprises: and adjusting the contrast of the current character image, and carrying out binarization processing on the current character image.

Technical Field

The invention belongs to the technical field of visual inspection, and particularly relates to a character defect detection method.

Background

In industrial production, many products contain character information, and a large amount of automatic printing easily causes printing defects of characters, so that the qualification rate of the products is reduced, and the production efficiency is also influenced, therefore, the character defect detection is widely applied to industry.

However, the inventors have found that this method has at least the following disadvantages: 1) because the same character is on different products, the image effect (mainly referring to gray value) can not be completely the same, and the template needs to be trained by a plurality of images, the operation process is complex, and the method is not suitable for occasions with more characters; 2) the premise of comparing the current character with the template character is that the two characters are aligned, the requirement on the character positioning precision is high, the comparison result is possibly greatly different if the characters are slightly staggered, and even if the characters are qualified, the defects can be calculated; 3) the method has low detection accuracy in identifying defects such as character missing, misprint, double image, stroke deformation and the like.

Therefore, a new method for detecting character defects is needed to solve the above problems.

Disclosure of Invention

The invention aims to: aiming at the defects of the prior art, the character defect detection method is strong in universality and high in detection efficiency, not only effectively improves the operation flexibility of character defect detection, but also can be suitable for large-batch character defect detection.

In order to achieve the purpose, the invention adopts the following technical scheme:

a character defect detection method includes:

s1, collecting a standard character image, carrying out image processing on the standard character image by adopting a filtering algorithm, extracting the outline of a standard character, and recording the outline as a template outline;

s2, recording the character to be detected as the current character, collecting the current character image, processing the current character image by adopting a filtering algorithm, extracting the outline of the current character, and recording the outline as the current outline;

s3, comparing the template contour with the current contour by calculating the maximum distance between the template contour and the current contour, and obtaining the character defect detection result of whether stroke missing or stroke overlapping exists.

Further, the S3 includes the following steps:

s3-1, placing the template contour and the current contour in the same horizontal rectangular coordinate system, matching and aligning the template contour and the current contour, calculating the minimum distance from all points in the template contour to the current contour, and selecting the maximum value from all the distances as the maximum distance from the template contour to the current contour;

s3-2, calculating the minimum distance between the point of the current contour and the template contour, comparing the maximum distance between the point of the current contour and the template contour with the maximum distance between the template contour and the current contour, realizing the comparison between the template contour and the current contour, and outputting the detection result.

Further, the process of calculating the maximum distance from the template contour to the current contour in S3-1 includes: let P be { P ═ Pi=(xi,yi)|i∈(0,M]Is the set of points of the template profile, Q ═ Qk=(xk,yk)|k∈(0,N]Is the set of points of the current contour, where xiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkM is the total number of points of the template profile, N is the total number of points of the current profile, and P is the length of the template profileiThe set of minimum distances from a point to the current contour is:the maximum distance from the template contour to the current contour is: dmax _ i ═ max (D)i)。

Further, the S3-2 further includes: the minimum set of distances from the points of the current contour to the template contour is:the maximum distance from the points of the current contour to the template contour is: dmax _ k is max (D)k) (ii) a The Dmax _ i represents the maximum distance from the template outline to the current outline, the Dmax _ k represents the maximum distance from the point of the current outline to the template outline, the values of the Dmax _ i and the Dmax _ k are compared, and if the Dmax _ i is larger than the Dmax _ k, a character defect detection result with character stroke missing is output; and if Dmax _ i is smaller than Dmax _ k, outputting a character defect detection result with character stroke overlapping.

Further, the S3 further includes the following steps: superposing the current contour on the template contour, if the template contour is not coincident with the current contour, extracting each contour point of the template contour which is not coincident with the current contour, and calculating a contour point P of the template contour in each non-coincident contour pointiAnd a contour point Q of said current contourkMaximum distance D of coordinates ofik(ii) a Setting the threshold value of the current outline when the character is normal as J, and comparing J and DikAnd outputting a detection result by combining the size relationship between the total number M of the contour points of the template contour and the total number N of the contour points of the current contour.

Further, calculating a contour point P of the template contouriAnd a contour point Q of said current contourkMaximum distance D ofikThe formula of (1) is:

wherein x isiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkThe ordinate of (c).

Further, if Dik>J, and M>And N, outputting a character missing detection result with character stroke missing.

Further, if Dik>J, and N>And M, outputting a character defect detection result with character stroke overlapping.

Further, in S3-1, the ratio of the unit length of the template contour to the unit length of the current contour is equal to the ratio of the area of the template contour in the rectangular coordinate system to the area of the current contour in the rectangular coordinate system.

Further, the process of image processing the standard character image in S1 further includes: and adjusting the contrast of the standard character image, and carrying out binarization processing on the standard character image.

Further, the process of image processing the current character image in S2 further includes: and adjusting the contrast of the current character image, and carrying out binarization processing on the current character image.

The invention has the beneficial effects that: 1) the invention adopts contour comparison, has low sensitivity to the image effect of the character, and does not influence the extraction of the character contour even if the gray values of the character image are different; 2) the template profile of the invention only needs one picture to be prepared, thus greatly reducing the complexity of operation; 3) in the prior art, the comparison between images is similar to image subtraction, and if characters are slightly misplaced when aligned, the difference of comparison results is possibly very large, but when the invention adopts contour comparison, the difference of the comparison results only exists in a local part and cannot generate an accumulative condition, so that the false detection can be effectively reduced, and the accuracy of character defect detection is remarkably improved.

Drawings

FIG. 1 is a flow chart of the detection according to the present invention.

FIG. 2 is a schematic diagram of a template profile and a current profile in one embodiment of the invention.

FIG. 3 is a diagram illustrating the maximum distance from the template contour to the current contour in one embodiment of the present invention.

FIG. 4 is a schematic diagram of a template profile and a current profile in one embodiment of the invention.

FIG. 5 is a diagram illustrating the maximum distance of the template contour from the current contour in one embodiment of the present invention.

FIG. 6 is a schematic diagram of a template profile and a current profile in one embodiment of the invention.

FIG. 7 is a diagram illustrating the effect of overlaying a current contour on a template contour in one embodiment of the present invention.

FIG. 8 is a schematic diagram of a template profile and a current profile in one embodiment of the invention.

Detailed Description

As one skilled in the art will appreciate, manufacturers may refer to a component by different names, such as "on the fly" and "off the fly" as they use "the specification and claims. The present specification and claims do not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms "include" and "comprise" are used in an open-ended fashion, and thus should be interpreted to mean "include, but not limited to. "substantially" means within an acceptable error range, and a person skilled in the art can solve the technical problem within a certain error range to substantially achieve the technical effect.

In the description of the present invention, it is to be understood that the terms "upper", "lower", "front", "rear", "left", "right", horizontal ", and the like indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience of description and simplicity of description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and thus, should not be construed as limiting the present invention.

In the present invention, unless otherwise expressly specified or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art according to specific situations.

The present invention will be described in further detail with reference to the accompanying drawings 1 to 8 and specific examples, but the present invention is not limited thereto.

Example 1

A character defect detecting method, as shown in fig. 1, includes the following steps:

s1, collecting a standard character image, carrying out image processing on the standard character image by adopting a filtering algorithm, extracting the outline of the standard character, and recording the outline as a template outline;

s2, recording the character to be detected as the current character, collecting the current character image, processing the current character image by adopting a filtering algorithm, extracting the outline of the current character, and recording the outline as the current outline;

s3, comparing the template contour with the current contour by calculating the maximum distance between the template contour and the current contour, and obtaining the character defect detection result of whether stroke missing or stroke overlapping exists.

The filtering algorithm may adopt a mean filtering algorithm, a median filtering algorithm, a gaussian filtering algorithm, or a bilateral filtering algorithm.

And defining the distance from a certain point on the A contour to the B contour as the minimum value of the distances from the point to all points on the B contour.

The maximum distance between two contours is defined as the maximum of all the above distances.

In addition, before the two outlines are compared, the character pictures can be aligned through matching, and then the outlines are extracted, so that the angle difference between the two outlines is avoided.

Wherein, S3 includes the following steps:

s3-1, placing the template contour and the current contour in the same horizontal rectangular coordinate system, matching and aligning the template contour and the current contour, calculating the minimum distance from all points in the template contour to the current contour, and selecting the maximum value from all the distances as the maximum distance from the template contour to the current contour, specifically comprising:

let P be { P ═ Pi=(xi,yi)|i∈(0,M]Is the set of points for the template profile, Q ═ Qk=(xk,yk)| k∈(0,N]Is the set of points for the current contour, where xiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkM is the total number of points of the template profile, N is the total number of points of the current profile and P is the template profileiThe minimum distance of a point to the current contour is: the maximum distance from the template contour to the current contour is: dmax _ i ═ max (D)i) (ii) a And, each i may correspond to a plurality of k.

S3-2, calculating the minimum distance between the point of the current contour and the template contour, comparing the maximum distance between the point of the current contour and the template contour with the maximum distance between the template contour and the current contour, comparing the template contour and the current contour, and outputting a detection result; wherein, the minimum distance from the points of the current contour to the template contour is:the maximum distance from the points of the current contour to the template contour is: dmax _ k is max (D)k) (ii) a Moreover, each k can correspond to a plurality of i, Dmax _ i represents the maximum distance from the template outline to the current outline, Dmax _ k represents the maximum distance from the point of the current outline to the template outline, the values of Dmax _ i and Dmax _ k are compared, and if Dmax _ i is larger than Dmax _ k, a character defect detection result with character stroke missing is output; and if Dmax _ i is smaller than Dmax _ k, outputting a character defect detection result with character stroke overlapping.

In addition, in the step S3-1, the ratio of the unit length of the template contour to the unit length of the current contour may be equal to the ratio of the enclosed area of the template contour in the rectangular coordinate system to the enclosed area of the current contour in the rectangular coordinate system, so as to ensure that the coordinate extraction process of the template contour and the current contour in the step S3 has higher accuracy.

Preferably, the process of image-processing the standard character image in S1 further includes: and the contrast of the standard character image is adjusted, and the standard character image is subjected to binarization processing, so that the definition of the template contour is effectively improved, and the selection of contour points is facilitated.

Preferably, the process of image processing the current character image in S2 further includes: and the contrast of the current character image is adjusted, and the current character image is subjected to binarization processing, so that the definition of the current contour is effectively improved, and the selection of contour points is facilitated.

As shown in FIGS. 2-3, the left part of FIG. 2 is the template profile, the right part of FIG. 2 is the current profile, the current profile is overlapped on the template profile, P in FIG. 3iAnd Pi’Points, Q in FIG. 3, which are all template contourskFor the point of the current contour, it can be found that there is a character defect in the current contour in which the character stroke is missing because Dmax _ i is greater than Dmax _ k.

As shown in FIGS. 4-5, the left part of FIG. 4 is the template profile, the right part of FIG. 4 is the current profile, the current profile is overlaid on the template profile, P in FIG. 5iPoints of the template profile, Q in FIG. 5kAnd Qk’All are points of the current contour, and it can be found that since Dmax _ i is smaller than Dmax _ k, there is a character defect in the current contour in which character strokes overlap.

Example 2

The present embodiment is different from embodiment 1 in that the step S3 further includes: superposing the current contour on the template contour, if the template contour is not coincident with the current contour, extracting each contour point of the template contour which is not coincident with the current contour, and calculating the contour point P of the template contour in each non-coincident contour pointiAnd the contour point Q of the current contourkMaximum distance D of coordinates ofikWherein i ∈ (0, M)],k∈(0,N]Maximum distance DikMeter (2)The calculation formula is as follows:wherein x isiRepresenting a contour point PiAbscissa of (a), yiRepresenting a contour point PiOrdinate of (a), xkRepresents the contour point QkAbscissa of (a), ykRepresents the contour point QkThe ordinate of (a); setting the threshold value of the current outline when the character is normal as J, and comparing J and DikAnd (3) outputting a detection result by combining the size relationship between the total number M of the contour points of the template contour and the total number N of the contour points of the current contour.

Preferably, if Dik>J, and M>N, outputting a character defect detection result with character stroke missing, wherein a threshold value J when the character of the current contour is normal can be selected from the distance between adjacent contour points of the current contour, obviously, as shown in FIGS. 6-7, the left part of FIG. 6 is a template contour, the right part of FIG. 6 is a current contour, and in each non-coincident contour point, a contour point P of the template contouriAnd the contour point Q of the current contourkMaximum distance D of coordinates ofikAnd the total number M of the contour points of the template contour is greater than the total number N of the contour points of the current contour, namely the current contour has the defect of character stroke missing.

Preferably, if Dik>J, and N>And M, outputting a character defect detection result with character stroke overlapping, wherein as shown in FIG. 8, the total number M of contour points of the template contour is smaller than the total number N of contour points of the current contour, and the defect with character stroke overlapping in the current contour can be found by combining the distance condition of each misaligned contour point.

The threshold J when the character of the current outline is normal may be selected from 0.5 to 1.5 times of the unit length of the horizontal rectangular coordinate system, and the threshold J when the character of the current outline is normal may be one unit length of the horizontal rectangular coordinate system.

Other steps in this embodiment are the same as those in embodiment 1, and are not described herein again.

Obviously, the character defect detection method has strong universality and high detection efficiency, can be realized by Scissomat software programming, not only prevents the conditions that the matching is not accurate enough and the detection is not accurate due to the fine difference of different products, but also prevents the conditions that the character has a slender or large-area non-coincident region due to the difference caused by the difference even if the matching is accurate enough, and not only effectively improves the operation flexibility of character defect detection, but also is suitable for large-batch character defect detection, and can greatly reduce the operation complexity.

Variations and modifications to the above-described embodiments may become apparent to those skilled in the art from the disclosure and teachings of the above description. Therefore, the present invention is not limited to the above-mentioned embodiments, and any obvious improvement, replacement or modification made by those skilled in the art based on the present invention is within the protection scope of the present invention. Furthermore, although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:毫米波实时成像人员安检系统的收发天线模块及系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!