CN110490192A - A kind of commodity production date tag detection method and system - Google Patents
A kind of commodity production date tag detection method and system Download PDFInfo
- Publication number
- CN110490192A CN110490192A CN201910642410.9A CN201910642410A CN110490192A CN 110490192 A CN110490192 A CN 110490192A CN 201910642410 A CN201910642410 A CN 201910642410A CN 110490192 A CN110490192 A CN 110490192A
- Authority
- CN
- China
- Prior art keywords
- image
- connected domain
- production date
- industrial camera
- target
- 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.)
- Pending
Links
- 238000004519 manufacturing process Methods 0.000 title claims abstract description 53
- 238000001514 detection method Methods 0.000 title claims abstract description 32
- 230000011218 segmentation Effects 0.000 claims abstract description 28
- 238000000034 method Methods 0.000 claims description 21
- 238000002474 experimental method Methods 0.000 claims description 19
- 239000000047 product Substances 0.000 claims description 18
- 238000012545 processing Methods 0.000 claims description 6
- 238000012216 screening Methods 0.000 claims description 5
- 230000000877 morphologic effect Effects 0.000 claims description 4
- 230000002950 deficient Effects 0.000 claims description 3
- 238000007781 pre-processing Methods 0.000 claims description 3
- 239000013589 supplement Substances 0.000 claims description 3
- 230000004438 eyesight Effects 0.000 description 4
- 230000007547 defect Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000010191 image analysis Methods 0.000 description 1
- 238000003709 image segmentation Methods 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/26—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
- G06V10/267—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/56—Extraction of image or video features relating to colour
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V20/00—Scenes; Scene-specific elements
- G06V20/60—Type of objects
- G06V20/62—Text, e.g. of license plates, overlay texts or captions on TV images
- G06V20/63—Scene text, e.g. street names
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/10—Character recognition
- G06V30/14—Image acquisition
- G06V30/148—Segmentation of character regions
- G06V30/153—Segmentation of character regions using recognition of characters or words
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
Abstract
本发明涉及一种商品生产日期标签检测方法及系统,所述系统包括处理器、支架、工业相机、环形光源、传送带和台架;支架和传送带设于台架上,工业相机通过支架设于传送带上方,当待检测商品经传送带通过工业相机镜头下方时,处理器控制工业相机捕获图像并启动软件系统识别算法,首先采用HSV空间和灰度空间对目标图像进行阈值分割,依据灰度特征和形态学特征筛选出可疑的字符连通域;提出一种带旋转的生产日期标签快速分割检测方案,对商品上表面的生产日期标签进行检测。本发明能有效排除与目标字符图像尺寸相当、形态相当的干扰特征,能快速地分割和检测字符目标。
The invention relates to a product production date label detection method and system. The system includes a processor, a bracket, an industrial camera, a ring light source, a conveyor belt and a stage; the bracket and the conveyor belt are arranged on the stage, and the industrial camera is arranged on the conveyor belt through the bracket Above, when the commodity to be detected passes under the lens of the industrial camera via the conveyor belt, the processor controls the industrial camera to capture the image and starts the software system identification algorithm. First, the target image is thresholded using HSV space and grayscale space. The suspicious character connected domain is screened out by the scientific features; a rapid segmentation and detection scheme of the production date label with rotation is proposed to detect the production date label on the upper surface of the commodity. The invention can effectively eliminate the interference features with the same size and shape as the target character image, and can quickly segment and detect the character target.
Description
技术领域technical field
本发明涉及非接触智能测控技术领域,更具体地,涉及一种商品生产日期标签检测方法及系统。The invention relates to the technical field of non-contact intelligent measurement and control, and more particularly, to a method and system for detecting the production date label of commodities.
背景技术Background technique
生产日期标签缺损检测技术属于计算机视觉技术,是一项通过相机拍摄物体,获取图像信息,再进行图像分析,从而获取物体的位姿和形态等信息的工程学科。相比于传统的人工查看检测,计算机视觉不受人工因素,具有快速、准确、非接触和成本低廉等优势,极大地降低人工成本,提高生产效率。Production date label defect detection technology belongs to computer vision technology. It is an engineering discipline that captures objects with cameras, obtains image information, and then performs image analysis to obtain information such as the pose and shape of objects. Compared with traditional manual inspection and detection, computer vision is free from artificial factors, and has the advantages of fast, accurate, non-contact and low cost, which greatly reduces labor costs and improves production efficiency.
计算机视觉中检测目标常需要对图像进行分割处理,其目的在于将待测目标与背景、噪声等其他信号分割开来。分割过程中可采用固定阈值分割法、边缘分割法或最大类间方差等自动阈值分割方法。而无论使用哪种分割方法,都不能保证完全把目标与干扰信号分割开来,这就要求检测方案必须是针对有干扰信号的情况。The detection of objects in computer vision often requires image segmentation, the purpose of which is to separate the object to be detected from other signals such as background and noise. In the segmentation process, automatic threshold segmentation methods such as fixed threshold segmentation method, edge segmentation method or maximum inter-class variance can be used. No matter which segmentation method is used, it cannot guarantee that the target and the interference signal are completely separated, which requires that the detection scheme must be aimed at the situation of the interference signal.
另外,生产日期标签印在产品表面时,其旋转方向具有随机性,同时,图像中有尺寸和灰度与字符目标接近的干扰特征的存在,这些对生产日期标签的分割和检测提出了较高的要求。In addition, when the production date label is printed on the surface of the product, its rotation direction is random, and at the same time, there are interference features in the image whose size and grayscale are close to the character target, which are highly recommended for the segmentation and detection of production date labels. requirements.
本发明给出一种带旋转的商品生产日期标签检测系统及其方法,有效排除干扰特征,实现对带旋转的商品生产日期标签的快速分割检测。The invention provides a detection system and a method for a product production date label with a rotation, which can effectively eliminate the interference feature and realize the rapid segmentation and detection of the production date label of the product with a rotation.
发明内容SUMMARY OF THE INVENTION
本发明为克服上述现有技术所述的标签检测不能排除干扰特征的缺陷,提供一种商品生产日期标签检测方法及系统。In order to overcome the defect of the above-mentioned prior art that label detection cannot exclude interference features, the present invention provides a product production date label detection method and system.
所述方法包括:The method includes:
S1:获取商品表面RGB图像,并对RGB图像进行预处理,获得二值图像;其中,RGB为代表红、绿、蓝三个通道的颜色,这个标准几乎包括了人类视力所能感知的所有颜色,是目前运用最广的颜色系统之一。S1: Obtain the RGB image of the product surface, and preprocess the RGB image to obtain a binary image; among them, RGB is the color representing the three channels of red, green, and blue, and this standard includes almost all colors that can be perceived by human eyesight. , is one of the most widely used color systems.
S2:对S1获得的二值图像进行连通域筛选;获得筛选过后的可疑目标的连通域集合。S2: Perform connected domain screening on the binary image obtained by S1; obtain the connected domain set of the filtered suspicious targets.
S3:对可疑目标的连通域集合进行带旋转的生产日期标签快速分割处理,得到生产日期字符组合的图像Tout。S3: Perform fast segmentation processing of the production date label with rotation on the connected domain set of the suspicious target, and obtain an image T out of the production date character combination.
S4:建立字符对比库;通过实验获取生产日期标签上的字符的图像,组成图像集合CH={CHi},i=1,2,3,......,n;所述的字符包括0~9、a~z、A~Z、“.”、“/”、“\”和“-”。S4: establish a character comparison library; obtain the images of the characters on the production date label through experiments, and form an image set CH={CH i }, i=1, 2, 3, ..., n; the characters Including 0~9, a~z, A~Z, ".", "/", "\" and "-".
S5:将图像Tout中每个连通域切割出来,依次进行knn预测识别;并得到预测结果。S5: Cut out each connected domain in the image T out , and perform knn prediction and recognition in turn; and obtain the prediction result.
优选地,S1包括以下步骤:Preferably, S1 includes the following steps:
S1.1:获取商品表面RGB图像O,及其灰度图像G;将图像O转换至HSV空间(Hue,Saturation,Value),得到图像H;对图像G进行固定阈值分割,由于目标物体及检测环境固定,其分割阈值可由多次实验获得,获得二值图像B,目标像素设为255,背景像素设为0;S1.1: Obtain the RGB image O of the product surface and its grayscale image G; convert the image O to the HSV space (Hue, Saturation, Value) to obtain the image H; perform a fixed threshold segmentation on the image G, due to the target object and detection The environment is fixed, and its segmentation threshold can be obtained by multiple experiments to obtain a binary image B, the target pixel is set to 255, and the background pixel is set to 0;
其中HSV(Hue,Saturation,Value)是根据颜色的直观特性由A.R.Smith在1978年创建的一种颜色空间,也称六角锥体模型(Hexcone Model),这个模型中颜色的参数分别是:色调(H),饱和度(S),明度(V)。Among them, HSV (Hue, Saturation, Value) is a color space created by A.R. Smith in 1978 according to the intuitive characteristics of color, also known as the Hexcone Model. The parameters of the color in this model are: Hue ( H), saturation (S), lightness (V).
S1.2:设图像H的任一像素为Hi,其HSV分量为{h,s,v};设图像B中与Hi像素位置相同的像素为Bi;若Hi和Bi满足条件Con,则将Bi置0,其中条件Con为:S1.2: Let any pixel of the image H be Hi, and its HSV component is {h, s , v } ; let the pixel in the image B with the same pixel position as Hi be Bi ; if Hi and Bi satisfy Condition Con, set B i to 0, where Condition Con is:
其中Rh、Rs、Rv表示目标像素H、S、V分量数值的范围;由于目标物体及检测环境固定,Rh、Rs、Rv区间范围由多次实验获得;遍历图像H和图像B,获得新的获得二值图像B。Among them, R h , R s , and R v represent the range of H, S, and V component values of the target pixel; because the target object and the detection environment are fixed, the interval range of R h , R s , and R v is obtained by multiple experiments; traverse the images H and Image B, obtain a new obtained binary image B.
优选地,S2包括以下步骤:Preferably, S2 includes the following steps:
S2.1:检测预处理完成后的二值图像B中的全部连通域,获得连通域集合Re={Rei},i=1,2,3,......,n;S2.1: Detect all connected domains in the binary image B after preprocessing, and obtain a connected domain set Re={Re i },i=1,2,3,...,n;
S2.2:设可疑目标的连通域子集合为Rc,检测连通域Rei的最小外接矩形,其长边长度为a,短边长度为b,若a∈Ra且b∈Rb,则将Rei保存于Rc,其中Ra和Rb分别表示连通域最小外接矩形的长边长度的区间范围和短边长度的区间范围,Ra和Rb可以通过多次实验获得;S2.2: Set the connected domain subset of the suspicious target as Rc, and detect the smallest circumscribed rectangle of the connected domain Re i , whose long side length is a and the short side length is b. If a∈R a and b∈R b , then Save Re i in Rc, where R a and R b represent the interval range of the length of the long side and the length of the short side of the minimum circumscribed rectangle of the connected domain, respectively, and R a and R b can be obtained through multiple experiments;
S2.3:遍历连通域集合Re,获得筛选过后的可疑目标的连通域子集合Rc,筛选过后的连通域包含了生产日期字符和部分与生产日期字符形态相近的干扰连通域;S2.3: Traverse the connected domain set Re to obtain the filtered connected domain subset Rc of the suspicious target, and the filtered connected domain includes production date characters and some interference connected domains with similar shapes to the production date characters;
优选地,S3包括以下步骤:Preferably, S3 includes the following steps:
S3.1:计算连通域子集合Rc中的每个连通域的最小外接矩形的中心坐标,得到中心坐标集合C={Ci},i=1,2,3,......,n,并以该坐标集合表征Rc中对应元素的位置;S3.1: Calculate the center coordinates of the smallest circumscribed rectangle of each connected domain in the connected domain subset Rc, and obtain the center coordinate set C={C i }, i=1, 2, 3,..., n, and represent the position of the corresponding element in Rc with the coordinate set;
S3.2:定义集合N={Ni},i=1,2,3,......,n;令i=0,j=0;S3.2: Define the set N={N i }, i=1, 2, 3, ......, n; let i=0, j=0;
S3.3:以元素Ci为中心,选取一个宽和高都为w(生产日期字符串的像素长度,通过多次实验获得)的矩形区域Rect_w,并统计Rect_w区域包含集合C中元素的个数n,如果n>t(其中t为预设阈值,可由多次实验获得),则令Nj=Ci,j=j+1,否则启动下一步;S3.3: Take the element C i as the center, select a rectangular area Rect_w whose width and height are w (the pixel length of the production date string, obtained through multiple experiments), and count the number of elements in the set C that the Rect_w area contains Number n, if n>t (where t is a preset threshold, which can be obtained by multiple experiments), then let N j =C i , j=j+1, otherwise start the next step;
S3.4:执行i=i+1;并判断Ci∈C是否成立,若成立,则回到步骤S3.3,否则启动下一步;S3.4: Execute i=i+1; and judge whether C i ∈ C is established, if so, go back to step S3.3, otherwise start the next step;
S3.5:根据排列组合建立从集合N中选取j个元素的方案池:S3.5: Establish a solution pool for selecting j elements from the set N according to the permutation and combination:
P={Pk},k=1,2,3,......,nP={P k },k=1,2,3,...,n
即集合P中包含了从集合N中选取j个元素的全部情况,集合P中的每个元素Pk代表一种从集合N中选取j个元素的情况,且集合P的每个元素互异;令k=0;That is, the set P contains all the cases where j elements are selected from the set N, and each element P k in the set P represents a situation where j elements are selected from the set N, and each element of the set P is different from each other. ; let k = 0;
S3.6:采用方案Pk从集合N中选取j个元素,将这j个元素构成一个整体T,并计算T的最小外接矩形Rect_T的短边与长边的长度之比f;S3.6: adopt the scheme P k to select j elements from the set N, form the j elements into a whole T, and calculate the ratio f of the length of the short side to the long side of the minimum circumscribed rectangle Rect_T of T;
S3.7:设比例区间阈值范围为ratio,即连通域最小外接矩形的短边与长边之比的范围,比例区间根据字符尺寸定,由于检测目标固定,其值可由多次实验获得,若f∈ratio,则获取Rect_T的旋转角度然后启动步骤S3.10,否则令k=k+1,再启动下一步;S3.7: Set the threshold range of the ratio interval to ratio, that is, the range of the ratio of the short side to the long side of the minimum circumscribed rectangle of the connected domain. The ratio interval is determined according to the character size. Since the detection target is fixed, its value can be obtained by multiple experiments. f∈ratio, then get the rotation angle of Rect_T Then start step S3.10, otherwise let k=k+1, and then start the next step;
S3.8:若Pk∈P则回到步骤S3.6,否则令j=j-1,再启动下一步;S3.8: If P k ∈ P, go back to step S3.6, otherwise set j=j-1, and then start the next step;
S3.9:若j>nt,则回到步骤S3.5,其中nt由目标字符个数确定,否则输出分割失败信息,并结束分割处理;S3.9: If j>n t , go back to step S3.5, where n t is determined by the number of target characters, otherwise output segmentation failure information, and end the segmentation process;
S3.10:将连通域集合Rc中在Rect_T区域的元素整体图像切割出来,并依据旋转角度将其旋转至图像长边与水平方向重合,得到生产日期字符组合的图像Tout。S3.10: Cut out the overall image of the elements in the Rect_T area in the connected domain set Rc, and according to the rotation angle Rotate it until the long side of the image coincides with the horizontal direction to obtain the image T out of the combination of production date characters.
优选地,S5具体为:将图像Tout中每个连通域切割出来,依次进行KNN(k-NearestNeighbor,K邻近算法)预测,再将预测结果与概率阈值pn进行对比,概率阈值pn由多次实验获得,若其预测概率大于pn,则预测结果作为该连通域的字符值,否则判定该连通域字符有缺损。Preferably, S5 is specifically: cutting out each connected domain in the image T out , performing KNN (k-Nearest Neighbor, K adjacent algorithm) prediction in turn, and then comparing the prediction result with the probability threshold pn, the probability threshold pn is determined by multiple times According to the experiment, if the predicted probability is greater than pn, the predicted result is used as the character value of the connected domain, otherwise it is determined that the connected domain character is defective.
其中,KNN预测即计算测试数据与库数据之间的距离,对距离从小到大排序,选取距离最小的k个库数据,将其作为预测结果;Among them, KNN prediction is to calculate the distance between the test data and the database data, sort the distance from small to large, select the k database data with the smallest distance, and use it as the prediction result;
本发明还提供一种应用商品生产日期标签检测方法的检测系统,所述系统包括台架、传送带、支架、工业相机、光源、处理器;The invention also provides a detection system applying the method for detecting the production date label of a commodity, the system comprising a stand, a conveyor belt, a bracket, an industrial camera, a light source, and a processor;
传送带设于台架上;用来传送待检测商品;The conveyor belt is set on the stand; it is used to convey the goods to be tested;
支架的一端固定于台架侧面,另一端用来固定工业相机,使得工业相机位于传送带上方,工业相机镜头朝下,用来捕获传送带上传送的待检测商品的生产日期标签的图像,并将捕获的图像信息传输给处理器;One end of the bracket is fixed on the side of the stand, and the other end is used to fix the industrial camera, so that the industrial camera is located above the conveyor belt, and the industrial camera lens is facing down, which is used to capture the image of the production date label of the goods to be inspected conveyed on the conveyor belt, and will capture The image information is transmitted to the processor;
光源设于工业相机下方,用来为工业相机补充光源;The light source is arranged under the industrial camera to supplement the light source for the industrial camera;
处理器控制工业相机进行图像捕获,以及对工业相机捕获的图像进行数据处理,包括采用HSV空间和灰度空间对目标图像进行阈值分割,依据灰度特征和形态学特征筛选出可疑的字符连通域。The processor controls the industrial camera to capture images, and performs data processing on the images captured by the industrial cameras, including using HSV space and grayscale space to perform threshold segmentation on the target image, and filtering out suspicious character connected domains based on grayscale features and morphological features .
优选地,所述的光源为环形光源。Preferably, the light source is a ring light source.
与现有技术相比,本发明技术方案的有益效果是:商品生产日期标签的自动检测相比于传统的人工检测,具有快速、准确、非接触和成本低廉等优势,极大地降低人工成本,提高生产效率。Compared with the prior art, the beneficial effects of the technical solution of the present invention are: compared with the traditional manual detection, the automatic detection of the product production date label has the advantages of rapidity, accuracy, non-contact and low cost, and greatly reduces the labor cost. Increase productivity.
本发明提出的带旋转的生产日期标签快速分割算法,有效地解决了生产日期标签印在产品表面时,其旋转方向具有随机性所带来的检测困难。The rapid segmentation algorithm of the production date label with rotation proposed by the invention effectively solves the detection difficulty caused by the randomness of the rotation direction of the production date label when the production date label is printed on the surface of the product.
本发明提出的带旋转的生产日期标签快速分割算法,能有效排除尺寸和灰度与字符目标接近的干扰特征,能快速地分割和检测字符目标。The rapid segmentation algorithm of the production date label with rotation proposed by the invention can effectively eliminate the interference features whose size and gray scale are close to the character target, and can quickly segment and detect the character target.
附图说明Description of drawings
图1为一种商品生产日期标签检测方法流程图。FIG. 1 is a flow chart of a method for detecting a production date label of a commodity.
图2为形态学筛选过后的可疑目标的连通域集合的图像。Figure 2 is an image of the connected domain set of suspicious objects after morphological screening.
图3为图2中对应连通域的中心坐标示意图;Fig. 3 is a schematic diagram of the center coordinates of the corresponding connected domain in Fig. 2;
图4为快速分割算法流程图;Fig. 4 is the flow chart of fast segmentation algorithm;
图5为旋转后的目标字符集合图像;Fig. 5 is the target character set image after rotation;
图6为一种商品生产日期标签检测系统结构示意图。FIG. 6 is a schematic structural diagram of a product production date label detection system.
图中,1-处理器,2-支架,3工业相机,4-镜头,5-光源,6-传送带,7-待检测商品,8-台架。In the figure, 1-processor, 2-stand, 3-industrial camera, 4-lens, 5-light source, 6-conveyor, 7-product to be inspected, 8-stand.
具体实施方式Detailed ways
附图仅用于示例性说明,不能理解为对本专利的限制;The accompanying drawings are for illustrative purposes only, and should not be construed as limitations on this patent;
为了更好说明本实施例,附图某些部件会有省略、放大或缩小,并不代表实际产品的尺寸;In order to better illustrate this embodiment, some parts of the drawings are omitted, enlarged or reduced, which do not represent the size of the actual product;
对于本领域技术人员来说,附图中某些公知结构及其说明可能省略是可以理解的。It will be understood by those skilled in the art that some well-known structures and their descriptions may be omitted from the drawings.
下面结合附图和实施例对本发明的技术方案做进一步的说明。The technical solutions of the present invention will be further described below with reference to the accompanying drawings and embodiments.
实施例1:Example 1:
本实施例提供一种商品生产日期标签检测方法,如图1所示,所述方法包括:The present embodiment provides a method for detecting the production date label of a commodity, as shown in FIG. 1 , the method includes:
S1:获取商品表面RGB图像,并对RGB图像进行预处理,获得二值图像;S1: Obtain the RGB image of the product surface, and preprocess the RGB image to obtain a binary image;
S2:对S1获得的二值图像进行连通域筛选;获得筛选过后的可疑目标的连通域集合;S2: Perform connected domain screening on the binary image obtained by S1; obtain the connected domain set of the filtered suspicious targets;
S3:对可疑目标的连通域集合进行带旋转的生产日期标签快速分割处理,得到生产日期字符组合的图像Tout;S3: perform rapid segmentation processing of the production date label with rotation on the connected domain set of the suspicious target, and obtain the image T out of the production date character combination;
S4:建立字符对比库;通过实验获取生产日期标签上0~9、a~z、A~Z、“.”、“/”、“\”和“-”等特殊字符的字符图像,组成图像集合CH={CHi},i=1,2,3,......,n;S4: Establish a character comparison library; obtain character images of special characters such as 0-9, a-z, A-Z, ".", "/", "\" and "-" on the production date label through experiments, and form an image Set CH={CH i },i=1,2,3,...,n;
S5:将图像Tout中每个连通域切割出来,依次进行KNN预测识别;并得到预测结果。S5: Cut out each connected domain in the image T out , and perform KNN prediction and recognition in turn; and obtain the prediction result.
S1包括以下步骤:S1 includes the following steps:
S1.1:获取商品表面RGB图像O,及其灰度图像G;将图像O转换至HSV空间(Hue,Saturation,Value),得到图像H;对图像G进行固定阈值分割(由于目标物体及检测环境固定,其分割阈值可由多次实验获得),获得二值图像B,目标像素设为255,背景像素设为0;S1.1: Obtain the RGB image O of the product surface and its grayscale image G; convert the image O to the HSV space (Hue, Saturation, Value) to obtain the image H; perform a fixed threshold segmentation on the image G (due to the target object and detection The environment is fixed, and its segmentation threshold can be obtained by multiple experiments), and a binary image B is obtained, the target pixel is set to 255, and the background pixel is set to 0;
S1.2:设图像H的任一像素为Hi,其HSV分量为{h,s,v};设图像B中与Hi像素位置相同的像素为Bi;若Hi和Bi满足条件Con,则将Bi置0,其中条件Con为:S1.2: Let any pixel of the image H be Hi, and its HSV component is {h, s , v } ; let the pixel in the image B with the same pixel position as Hi be Bi ; if Hi and Bi satisfy Condition Con, set B i to 0, where Condition Con is:
其中Rh、Rs、Rv表示目标像素H、S、V分量数值的范围;由于目标物体及检测环境固定,Rh、Rs、Rv区间范围由多次实验获得;遍历图像H和图像B,获得新的获得二值图像B。Among them, R h , R s , and R v represent the range of H, S, and V component values of the target pixel; because the target object and the detection environment are fixed, the interval range of R h , R s , and R v is obtained by multiple experiments; traverse the images H and Image B, obtain a new obtained binary image B.
S2包括以下步骤:S2 includes the following steps:
S2.1:检测预处理完成后的二值图像B中的全部连通域,获得连通域集合Re={Rei},i=1,2,3,......,n;S2.1: Detect all connected domains in the binary image B after preprocessing, and obtain a connected domain set Re={Re i },i=1,2,3,...,n;
S2.2:设可疑目标的连通域子集合为Rc,检测连通域Rei的最小外接矩形,其长边长度为a,短边长度为b,若a∈Ra且b∈Rb,则将Rei保存于连通域集合Rc,其中Ra和Rb分别表示连通域最小外接矩形的长边长度的区间范围和短边长度的区间范围,Ra和Rb可以通过多次实验获得;S2.2: Set the connected domain subset of the suspicious target as Rc, and detect the smallest circumscribed rectangle of the connected domain Re i , whose long side length is a and the short side length is b. If a∈R a and b∈R b , then Save Re i in the connected domain set Rc, where R a and R b represent the interval range of the length of the long side and the length of the short side of the minimum circumscribed rectangle of the connected domain, respectively, and R a and R b can be obtained through multiple experiments;
S2.3:遍历连通域集合Re,获得筛选过后的可疑目标的连通域子集合Rc,如图2所示,筛选过后的连通域包含了生产日期字符和部分与生产日期字符形态相近的干扰连通域;S2.3: Traverse the connected domain set Re, and obtain the connected domain subset Rc of the filtered suspicious targets. As shown in Figure 2, the filtered connected domain includes the production date characters and some interference connections with similar shapes to the production date characters. area;
如图4所示,S3包括以下步骤:As shown in Figure 4, S3 includes the following steps:
S3.1:计算连通域子集合Rc中的每个连通域的最小外接矩形的中心坐标,得到中心坐标集合C={Ci},i=1,2,3,......,n,在图像中显示如图3所示,并以该坐标集合表征Rc中对应元素的位置;S3.1: Calculate the center coordinates of the smallest circumscribed rectangle of each connected domain in the connected domain subset Rc, and obtain the center coordinate set C={C i }, i=1, 2, 3,..., n, display in the image as shown in Figure 3, and use this coordinate set to represent the position of the corresponding element in Rc;
S3.2:定义集合N={Ni},i=1,2,3,......,n;令i=0,j=0;S3.2: Define the set N={N i }, i=1, 2, 3, ......, n; let i=0, j=0;
S3.3:以元素Ci为中心,选取一个宽和高都为w(生产日期字符串的像素长度,通过多次实验获得)的矩形区域Rect_w,并统计Rect_w区域包含集合C中元素的个数n,如果n>t(其中t为预设阈值,可由多次实验获得),则令Nj=Ci,j=j+1,否则启动下一步;S3.3: Take the element C i as the center, select a rectangular area Rect_w whose width and height are w (the pixel length of the production date string, obtained through multiple experiments), and count the number of elements in the set C that the Rect_w area contains Number n, if n>t (where t is a preset threshold, which can be obtained by multiple experiments), then let N j =C i , j=j+1, otherwise start the next step;
S3.4:执行i=i+1;并判断Ci∈C是否成立,若成立,则回到步骤S3.3,否则启动下一步;S3.4: Execute i=i+1; and judge whether C i ∈ C is established, if so, go back to step S3.3, otherwise start the next step;
S3.5:根据排列组合建立从集合N中选取j个元素的方案池:S3.5: Establish a solution pool for selecting j elements from the set N according to the permutation and combination:
P={Pk},k=1,2,3,......,nP={P k },k=1,2,3,...,n
即集合P中包含了从集合N中选取j个元素的全部情况,集合P中的每个元素Pk代表一种从集合N中选取j个元素的情况,且集合P的每个元素互异;令k=0;That is, the set P contains all the cases where j elements are selected from the set N, and each element P k in the set P represents a situation where j elements are selected from the set N, and each element of the set P is different from each other. ; let k = 0;
S3.6:采用方案Pk从集合N中选取j个元素,将这j个元素构成一个整体T,并计算T的最小外接矩形Rect_T的短边与长边的长度之比f;S3.6: adopt the scheme P k to select j elements from the set N, form the j elements into a whole T, and calculate the ratio f of the length of the short side to the long side of the minimum circumscribed rectangle Rect_T of T;
S3.7:设比例区间阈值范围为ratio,即连通域最小外接矩形的短边与长边之比的范围,比例区间根据字符尺寸定,由于检测目标固定,其值可由多次实验获得,若f∈ratio,则获取Rect_T的旋转角度然后启动步骤S3.10,否则令k=k+1,再启动下一步;S3.7: Set the threshold range of the ratio interval to ratio, that is, the range of the ratio of the short side to the long side of the minimum circumscribed rectangle of the connected domain. The ratio interval is determined according to the character size. Since the detection target is fixed, its value can be obtained by multiple experiments. f∈ratio, then get the rotation angle of Rect_T Then start step S3.10, otherwise let k=k+1, and then start the next step;
S3.8:若Pk∈P则回到步骤S3.6,否则令j=j-1,再启动下一步;S3.8: If P k ∈ P, go back to step S3.6, otherwise set j=j-1, and then start the next step;
S3.9:若j>nt,则回到步骤S3.5,其中nt由目标字符个数确定,否则输出分割失败信息,并结束分割处理;S3.9: If j>n t , go back to step S3.5, where n t is determined by the number of target characters, otherwise output segmentation failure information, and end the segmentation process;
S3.10:将连通域集合Rc中在Rect_T区域的元素整体图像切割出来,并依据旋转角度将其旋转至图像长边与水平方向重合,如图5所示,得到生产日期字符组合的图像Tout。S3.10: Cut out the overall image of the elements in the Rect_T area in the connected domain set Rc, and according to the rotation angle Rotate it until the long side of the image coincides with the horizontal direction, as shown in Figure 5, to obtain the image T out of the combination of production date characters.
S5具体为:将图像Tout中每个连通域切割出来,依次进行KNN预测再将预测结果与概率阈值pn进行对比,概率阈值pn由多次实验获得,若其预测概率大于pn,则预测结果作为该连通域的字符值,否则判定该连通域字符有缺损。S5 is specifically: cut out each connected domain in the image T out , perform KNN prediction in turn, and then compare the prediction result with the probability threshold pn, the probability threshold pn is obtained by multiple experiments, if the prediction probability is greater than pn, then the prediction result As the character value of the connected domain, otherwise it is determined that the connected domain character is defective.
其中,KNN预测即计算测试数据与库数据之间的距离,对距离从小到大排序,选取距离最小的k个库数据,本实施例取k=1,将其作为预测结果;Among them, KNN prediction is to calculate the distance between the test data and the database data, sort the distances from small to large, and select the k database data with the smallest distance. In this embodiment, k=1 is taken as the prediction result;
实施例2:Example 2:
本实施例一种应用实施例1所述商品生产日期标签检测方法的检测系统,如图6所示,所述系统包括台架8、传送带6、支架2、工业相机3、光源5、处理器1;This embodiment is a detection system applying the method for detecting the production date label of a commodity described in Embodiment 1. As shown in FIG. 6 , the system includes a stand 8 , a conveyor belt 6 , a bracket 2 , an industrial camera 3 , a light source 5 , and a processor 1;
传送带设于台架8上;用来传送待检测商品7;The conveyor belt is arranged on the stand 8; it is used to convey the commodity 7 to be tested;
支架2的一端固定于台架8侧面,另一端用来固定工业相机3,使得工业相机位于传送带6上方,工业相机3镜头4朝下,用来捕获传送带上传送待检测商品7的生产日期标签的图像,并将捕获的图像信息传输给处理器;One end of the bracket 2 is fixed to the side of the stand 8, and the other end is used to fix the industrial camera 3, so that the industrial camera is located above the conveyor belt 6, and the lens 4 of the industrial camera 3 faces downwards, which is used to capture the production date label of the goods 7 to be tested on the conveyor belt. image, and transmit the captured image information to the processor;
光源5设于工业相机3下方,用来为工业相机3补充光源;The light source 5 is arranged below the industrial camera 3 to supplement the light source for the industrial camera 3;
处理器1控制工业相机3进行图像捕获,以及对工业相机3捕获的图像进行数据处理,包括采用HSV空间和灰度空间对目标图像进行阈值分割,依据灰度特征和形态学特征筛选出可疑的字符连通域。The processor 1 controls the industrial camera 3 to capture images, and performs data processing on the images captured by the industrial camera 3, including using HSV space and grayscale space to perform threshold segmentation on the target image, and filter out suspicious objects based on grayscale features and morphological features. Character connected domain.
所述的光源5为环形光源。The light source 5 is a ring light source.
相同或相似的标号对应相同或相似的部件;The same or similar reference numbers correspond to the same or similar parts;
附图中描述位置关系的用语仅用于示例性说明,不能理解为对本专利的限制;The terms describing the positional relationship in the accompanying drawings are only used for exemplary illustration, and should not be construed as a limitation on this patent;
显然,本发明的上述实施例仅仅是为清楚地说明本发明所作的举例,而并非是对本发明的实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其它不同形式的变化或变动。这里无需也无法对所有的实施方式予以穷举。凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明权利要求的保护范围之内。Obviously, the above-mentioned embodiments of the present invention are only examples for clearly illustrating the present invention, rather than limiting the embodiments of the present invention. For those of ordinary skill in the art, changes or modifications in other different forms can also be made on the basis of the above description. There is no need and cannot be exhaustive of all implementations here. Any modification, equivalent replacement and improvement made within the spirit and principle of the present invention shall be included within the protection scope of the claims of the present invention.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910642410.9A CN110490192A (en) | 2019-07-16 | 2019-07-16 | A kind of commodity production date tag detection method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910642410.9A CN110490192A (en) | 2019-07-16 | 2019-07-16 | A kind of commodity production date tag detection method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110490192A true CN110490192A (en) | 2019-11-22 |
Family
ID=68547386
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910642410.9A Pending CN110490192A (en) | 2019-07-16 | 2019-07-16 | A kind of commodity production date tag detection method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110490192A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112183305A (en) * | 2020-09-24 | 2021-01-05 | 江苏池丰科技有限公司 | System for identifying production date and batch number of product |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH08190610A (en) * | 1995-01-12 | 1996-07-23 | Oki Electric Ind Co Ltd | Optical character reader |
US20070201757A1 (en) * | 2006-02-24 | 2007-08-30 | Dariusz Madej | System and method for optical character recognition in an image |
CN103049743A (en) * | 2012-12-27 | 2013-04-17 | 天津普达软件技术有限公司 | Detection system and detection method for characters at bottom of bowl |
CN105431866A (en) * | 2013-07-16 | 2016-03-23 | 株式会社汤山制作所 | Optical character recognition device |
US20160371557A1 (en) * | 2015-06-18 | 2016-12-22 | Pfu Limited | Image-processing apparatus, date identification apparatus, image-processing method, and computer program product |
CN108364010A (en) * | 2018-03-08 | 2018-08-03 | 广东工业大学 | A kind of licence plate recognition method, device, equipment and computer readable storage medium |
-
2019
- 2019-07-16 CN CN201910642410.9A patent/CN110490192A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH08190610A (en) * | 1995-01-12 | 1996-07-23 | Oki Electric Ind Co Ltd | Optical character reader |
US20070201757A1 (en) * | 2006-02-24 | 2007-08-30 | Dariusz Madej | System and method for optical character recognition in an image |
CN103049743A (en) * | 2012-12-27 | 2013-04-17 | 天津普达软件技术有限公司 | Detection system and detection method for characters at bottom of bowl |
CN105431866A (en) * | 2013-07-16 | 2016-03-23 | 株式会社汤山制作所 | Optical character recognition device |
US20160371557A1 (en) * | 2015-06-18 | 2016-12-22 | Pfu Limited | Image-processing apparatus, date identification apparatus, image-processing method, and computer program product |
CN108364010A (en) * | 2018-03-08 | 2018-08-03 | 广东工业大学 | A kind of licence plate recognition method, device, equipment and computer readable storage medium |
Non-Patent Citations (1)
Title |
---|
施成燕: "基于智能机器人的仪表示数识别技术与系统研制", 《中国优秀硕士学位论文全文数据库信息科技辑》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112183305A (en) * | 2020-09-24 | 2021-01-05 | 江苏池丰科技有限公司 | System for identifying production date and batch number of product |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI787296B (en) | Optical inspection method, optical inspection device and optical inspection system | |
CN109816644B (en) | An automatic detection system for bearing defects based on multi-angle light source images | |
CN106570511B (en) | Computer vision-based keyboard character defect online detection system and method | |
Rahaman et al. | Automatic defect detection and classification technique from image: a special case using ceramic tiles | |
CN109550712A (en) | A kind of chemical fiber wire tailfiber open defect detection system and method | |
CN104298996B (en) | A kind of underwater active visual tracking method applied to bionic machine fish | |
CN107123114A (en) | A kind of cloth defect inspection method and device based on machine learning | |
CN109255787A (en) | Silk ingot scratch detection system and method based on deep learning and image processing techniques | |
CN111179250B (en) | Industrial product defect detection system based on multitask learning | |
CN109308447A (en) | Method for Automatically Extracting Equipment Operating Parameters and Operating Status in Electric Power Remote Monitoring | |
CN111833303A (en) | Product detection method and device, electronic equipment and storage medium | |
CN102879404B (en) | System for automatically detecting medical capsule defects in industrial structure scene | |
Usami et al. | Defect detection and classification of electronic circuit boards using keypoint extraction and CNN features | |
CN111667475A (en) | Machine vision-based Chinese date grading detection method | |
CN113192061B (en) | Extraction method and device of LED package appearance detection image, electronic equipment and storage medium | |
CN114119591A (en) | A kind of display screen picture quality detection method | |
CN113971681A (en) | A method for edge detection of belt conveyor in complex environment | |
Myori | Object detection with a webcam using the Python programming language | |
CN117542301A (en) | Display screen detection method and system | |
KR20220101373A (en) | Apparatus and method for detecting defects in pcb based on video | |
CN114577805A (en) | MiniLED backlight panel defect detection method and device | |
CN110490192A (en) | A kind of commodity production date tag detection method and system | |
Popayorm et al. | Seven segment display detection and recognition using predefined HSV color slicing technique | |
Mukhopadhyay et al. | Comparing shape descriptor methods for different color space and lighting conditions | |
KR102139932B1 (en) | A Method of Detecting Character Data through a Adaboost Learning Method |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191122 |
|
RJ01 | Rejection of invention patent application after publication |