[go: up one dir, main page]

HK1218582B - Method and device for detecting specific identification image in predetermined area - Google Patents

Method and device for detecting specific identification image in predetermined area Download PDF

Info

Publication number
HK1218582B
HK1218582B HK16106568.1A HK16106568A HK1218582B HK 1218582 B HK1218582 B HK 1218582B HK 16106568 A HK16106568 A HK 16106568A HK 1218582 B HK1218582 B HK 1218582B
Authority
HK
Hong Kong
Prior art keywords
image
predetermined area
specific identification
connected domain
area
Prior art date
Application number
HK16106568.1A
Other languages
Chinese (zh)
Other versions
HK1218582A1 (en
Inventor
程刚
楚汝峰
张伦
Original Assignee
斑马智行网络(香港)有限公司
Filing date
Publication date
Priority claimed from CN201410367807.9A external-priority patent/CN105303189B/en
Application filed by 斑马智行网络(香港)有限公司 filed Critical 斑马智行网络(香港)有限公司
Publication of HK1218582A1 publication Critical patent/HK1218582A1/en
Publication of HK1218582B publication Critical patent/HK1218582B/en

Links

Description

一种用于检测预定区域中特定标识图像的方法及装置A method and device for detecting a specific identification image in a predetermined area

技术领域Technical Field

本申请涉及计算机应用领域,具体涉及一种获取标准卡片中特定标识的方法和装置。The present application relates to the field of computer applications, and in particular to a method and device for obtaining a specific identifier in a standard card.

背景技术Background Art

特定标识的识别属于物体检测范畴,特定标识一般用于表明物体的某种特征,对于观察者来说,标识可以用来作为识别物体的参考依据。特定标识物通常具有明显的外形和显著的空间位置,能够更容易的被识别。对于银行卡来说,标识物一般包括发卡组织的图形标识,文字标识等,识别这些标识具有如下重要意义:The recognition of specific identifiers falls under the category of object detection. Specific identifiers are generally used to indicate certain characteristics of an object. For observers, identifiers can serve as a reference for identifying the object. Specific identifiers typically have a distinct appearance and a prominent spatial location, making them easier to identify. For bank cards, identifiers generally include the issuing organization's graphic logo and text logo. Recognizing these identifiers has the following important implications:

(1)标识物的识别可以作为鉴别银行卡真伪的重要参考依据。(1) The identification of identifiers can serve as an important reference for identifying the authenticity of bank cards.

标识物一般都具有明确的尺寸规格和相对位置标识,合法的银行卡都会按照标准对标识物进行印刷,而仿冒的银行卡由于做工低廉,成本较低,一般对标识物的印刷控制不严,通过对标志物的识别,得到标识物的尺寸比例和相对位置,进一步通过与真实标准的银行卡比对,可以为鉴别银行卡的真伪提供有效的参考。Markers generally have clear size specifications and relative position markings. Legitimate bank cards will have markers printed in accordance with the standards. However, counterfeit bank cards are generally not strictly controlled in the printing of markers due to their low workmanship and low cost. By identifying the markers, the size ratio and relative position of the markers can be obtained, and further compared with the real standard bank cards, it can provide an effective reference for identifying the authenticity of bank cards.

(2)标识物的识别可以为银行卡的检测和校正提供参考标识。(2) The identification of the identifier can provide a reference identifier for the detection and correction of bank cards.

相对于整个银行卡而言,标识物会有统一的样式规定,因此一般也就有明确的边缘标识,识别得到标识物的边缘,可以根据此边缘得到当前拍摄图像的仿射变换标识,因此可以对图像进行校正以利于后续的银行卡精确检测和定位。这里描述为边框标识不是特别准确,准确的描述是边缘标识。Compared to the entire bank card, the marker has a uniform design and therefore generally has a clear edge marker. By identifying the marker's edge, we can derive the affine transformation of the current image based on this edge. This allows for image correction to facilitate subsequent accurate bank card detection and location. The term "border marker" here is not entirely accurate; the more accurate term is "edge marker."

(3)标识物的识别可以让服务提供商根据特定的标识物进行精准广告推送服务。(3) Identification of identifiers allows service providers to provide precise advertising push services based on specific identifiers.

标识物往往表明了银行卡的特定标识,例如发卡组织和使用范围,因此标识物的识别可以让商家针对该银行卡进行精确地广告推送,提高服务的质量,除此之外,获取标识物标识后,结合增强现实等技术,可以实现多媒体的广告展示。Identifiers often indicate the specific identification of bank cards, such as the issuing organization and scope of use. Therefore, the identification of identifiers allows merchants to accurately push advertisements for the bank cards and improve the quality of service. In addition, after obtaining the identifier, combined with technologies such as augmented reality, multimedia advertising display can be achieved.

物体检测是指,在给出的一幅图像或一段视频中,找出特定标识或感兴趣物体在图像或视频中的位置,根据具体的使用场景,物体检测系统通常最后输出物体的外接矩形框或者精确的轮廓。Object detection refers to finding the location of a specific identifier or object of interest in a given image or video. Depending on the specific usage scenario, the object detection system usually outputs the object's circumscribed rectangular box or precise outline.

物体检测大致可分为滑动窗口和广义霍夫变换两类方法。其中,滑动窗口法为目前主流的物体检测方法,滑动窗口法是通过使用训练好的模板在输入图像的多个尺度和多视角进行滑动扫描,通过确定最大相应位置找到目标物体的外接窗口。Object detection can be broadly categorized into two methods: sliding window and generalized Hough transform. The sliding window method, currently the mainstream object detection method, uses a trained template to perform sliding scans across multiple scales and perspectives of the input image, then locates the window surrounding the target object by determining the maximum corresponding position.

现有技术的物体检测方法中所采用的滑动窗口法,在对数据进行分析扫描时,运算量较大,计算复杂度也相对较高,进而使得检测时间较长,其适用于物体结构较为复杂的检测。而对于识别结构较为固定的标识时,显然滑动窗口法并不适用。The sliding window method used in existing object detection methods requires a large amount of computation and has relatively high computational complexity when analyzing and scanning data, resulting in a long detection time. This method is suitable for detecting objects with complex structures. However, it is clearly not suitable for identifying signs with relatively fixed structures.

因此,迫切需要本领域技术人员解决的技术问题就在于,如何提供一种能够快速、准确的识别出标准卡片上的特定标识的方法。Therefore, a technical problem that urgently needs to be solved by those skilled in the art is how to provide a method that can quickly and accurately identify a specific mark on a standard card.

发明内容Summary of the Invention

本申请提供一种用于检测预定区域中特定标识图像的方法,以解决现有现有检测过程中计算复杂度高,运算量大的问题。The present application provides a method for detecting a specific identification image in a predetermined area, so as to solve the problems of high computational complexity and large amount of calculation in the existing detection process.

本申请提供一种用于检测预定区域中特定标识图像的方法,包括:The present application provides a method for detecting a specific identification image in a predetermined area, comprising:

获取预定区域的图像,作为待检目标图像;Acquire an image of a predetermined area as an image of a target to be inspected;

对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,二者均称为待检目标二值图像;Binarizing the target image to be inspected to obtain a binary image and an inverse image of the binary image, both of which are referred to as the target binary image to be inspected;

标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域所在区域作为候选连通域区域;Calibrate the connected domain of the binary image of the target to be detected, and take the area where the number of pixels in the calibrated connected domain meets the set threshold range as the candidate connected domain area;

逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与标准特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域区域视为特定标识图像所在位置。The image features of the candidate connected domain regions are obtained one by one, and the image features of the candidate connected domain regions are compared with the corresponding image features of the standard specific identification image, and the candidate connected domain regions with the same or closest comparison results are regarded as the locations of the specific identification images.

优选地,所述获取所述预定区域或包含该预定区域的图像,作为待检目标图像,包括:Preferably, acquiring the predetermined area or an image containing the predetermined area as the target image to be inspected includes:

获取所述预定区域或包含该预定区域的图像的预览图像;Acquiring a preview image of the predetermined area or an image containing the predetermined area;

计算所述预览图像的区域范围;Calculating the area range of the preview image;

将所述预览图像框定在所述区域范围内,获取所述预定区域或包含预定区域的图像,将该框定的区域范围内的图像作为待检目标图像。The preview image is framed within the region, the predetermined region or an image containing the predetermined region is acquired, and the image within the framed region is used as a target image to be inspected.

优选地,所述计算预览图像的区域范围是指:根据所述预定区域的实际尺寸参数及预览图像的分辨率参数,获得框定所述预览图像的虚拟边框参数,具体为:Preferably, calculating the area range of the preview image refers to obtaining virtual frame parameters for framing the preview image based on actual size parameters of the predetermined area and resolution parameters of the preview image, specifically:

根据所述预定区域或包含该预定区域图像的实际尺寸,判断所述预览图像高度乘以所述预定区域或包含该预定区域图像的实际宽度的值是否大于预览图像宽度乘以所述预定区域或包含该预定区域图像实际高度的值;Determining, based on the actual size of the predetermined area or the image containing the predetermined area, whether a value obtained by multiplying the height of the preview image by the actual width of the predetermined area or the image containing the predetermined area is greater than a value obtained by multiplying the width of the preview image by the actual height of the predetermined area or the image containing the predetermined area;

若是,则所述虚拟边框的宽度为:If so, the width of the virtual border is:

ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;

其中,CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;PreviewHeight为预览图像高度;CardHeightGdt为预定区域或包含该预定区域的图像实际高度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; PreviewHeight is the height of the preview image; CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio;

其中,PreviewHeight为预览图像高度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewHeight is the height of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

若否,则虚拟边框的宽度为:If not, the width of the virtual border is:

ScaledWidth=PreviewWidth×DisplayRatio;ScaledWidth=PreviewWidth×DisplayRatio;

其中,PreviewWidth为预览图像宽度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewWidth is the width of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;

其中,CardHeightGdt为预定区域或包含该预定区域图像的实际高度;PreviewWidth为预览图像宽度;CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; PreviewWidth is the width of the preview image; CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框上边界为显示屏幕高度与虚拟边框高度差的二分之一;所述虚拟边框下边界为显示屏幕高度与虚拟边框高度和的二分之一;所述虚拟边框的左边界为显示屏幕宽度与虚拟边框宽度差的二分之一;所述虚拟边框的右边界为显示屏幕宽度与虚拟边框宽度和的二分之一。The upper boundary of the virtual border is half of the difference between the display screen height and the virtual border height; the lower boundary of the virtual border is half of the sum of the display screen height and the virtual border height; the left boundary of the virtual border is half of the difference between the display screen width and the virtual border width; and the right boundary of the virtual border is half of the sum of the display screen width and the virtual border width.

优选地,所述获取所述预定区域或包含该预定区域的图像,作为待检目标图像,包括:根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像。Preferably, the obtaining of the predetermined area or the image containing the predetermined area as the target image to be inspected includes: based on the specific position information of the specific identification image in the predetermined area or the image of the predetermined area, intercepting the area range containing the specific identification image as the target image to be inspected.

优选地,所述特定位置信息为事先设定的特定标识图像所位于预定区域或包含预定区域图像上的位置。Preferably, the specific position information is the position of a pre-set specific identification image located in a predetermined area or on an image including a predetermined area.

优选地,所述特定位置是位于所述预定区域或包含预定区域的图像的右上角或右下角或左上角或左下角。Preferably, the specific position is the upper right corner or lower right corner or the upper left corner or lower left corner of the predetermined area or the image including the predetermined area.

优选地,根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像,包括:Preferably, based on the specific position information of the specific identification image in the predetermined area or the predetermined area image, intercepting the area range containing the specific identification image as the target image to be inspected includes:

建立预定区域或包含预定区域的标准图像模板;Establishing a predetermined area or a standard image template containing a predetermined area;

根据所述预定区域或包含预定区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述预定区域或包含预定区域的图像的对应关系,获取特定标识图像在预定区域或包含预定区域的图像中的位置信息;Traversing the standard image template according to the predetermined area or the image containing the predetermined area, and obtaining position information of the specific identification image in the predetermined area or the image containing the predetermined area through a correspondence between the standard image template and the predetermined area or the image containing the predetermined area;

根据该位置信息截取所述预定区域或包含预定区域的图像中包含特定标识的图像区域,作为待检目标图像。The predetermined area or the image area containing the specific mark in the image containing the predetermined area is intercepted according to the position information as the target image to be inspected.

优选地,所述阈值区间的上限值为所述获取的预定区域图像或包含预定区域图像的宽度、高度和上限系数的乘积;下限值为所述获取的预定区域图像或包含预定区域图像的宽度、高度和下限系数的乘积。Preferably, the upper limit value of the threshold interval is the product of the width, height and upper limit coefficient of the acquired predetermined area image or the image containing the predetermined area; the lower limit value is the product of the width, height and lower limit coefficient of the acquired predetermined area image or the image containing the predetermined area.

优选地,所述将该候选连通域区域的图像特征与所述特定标识图像的相应图像特征进行比对,包括:采用单独图像特征比对或者组合图像特征比对;其中,所述图像特征包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比。Preferably, the comparing the image features of the candidate connected domain area with the corresponding image features of the specific identification image includes: using a single image feature comparison or a combined image feature comparison; wherein the image features include the volume ratio of the connected domain, the major axis direction of the ellipse circumscribed by the connected domain, the outer contour shape of the connected domain and/or the aspect ratio of the rectangle circumscribed by the connected domain.

优选地,逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与所述特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域区域视为所述特定标识图像所在区域,包括:Preferably, the image features of the candidate connected domain regions are obtained one by one, and the image features of the candidate connected domain regions are compared with the corresponding image features of the specific identification image, and the candidate connected domain regions with the same or closest comparison results are regarded as the regions where the specific identification image is located, including:

以所述连通域的体积比和连通域外接椭圆长轴方向作为组合图像特征对候选连通域区域进行筛选,具体是:The candidate connected domain regions are screened using the volume ratio of the connected domain and the major axis direction of the connected domain circumscribed ellipse as combined image features, specifically:

获取候选连通域区域的外接边框;Get the bounding box of the candidate connected region;

计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;Calculating a volume ratio of pixels of the foreground color in the candidate connected domain within the bounding box to the area of the bounding box;

判断该体积比是否大于预先设定的特定标识图像的阈值范围,若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;Determine whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, discard the candidate connected domain area; if so, fill the candidate connected domain area;

计算填充后的所述候选连通域区域外接椭圆长轴的方向,并获得该方向与设定的参考轴的夹角;Calculating the direction of the major axis of the ellipse circumscribed in the filled candidate connected region, and obtaining the angle between the major axis and the set reference axis;

判断该夹角是否在预定的阈值范围内,若是,则将该候选连通域区域视为所述特定标识图像所在区域;若否,则舍弃该候选连通域区域。It is determined whether the angle is within a predetermined threshold range. If so, the candidate connected domain area is regarded as the area where the specific identification image is located; if not, the candidate connected domain area is discarded.

优选地,包括:判断所述方向与所述参考轴的夹角在预定的阈值范围内后,以所述连通域外轮廓形状作为单独条件对所述候选连通域区域再次进行筛选,具体为:Preferably, the method includes: after determining that the angle between the direction and the reference axis is within a predetermined threshold range, screening the candidate connected domain regions again based on the outer contour shape of the connected domain as a separate condition, specifically:

填充所述候选连通域区域,获得填充图像;Filling the candidate connected component area to obtain a filled image;

检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;Detecting the edge of the filled image to obtain an edge contour image of the filled image;

分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;Respectively obtaining sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image, and selecting the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

拟合所述选取的采样像素点,获得所述边缘轮廓图像的线段组合信息;Fitting the selected sampling pixel points to obtain line segment combination information of the edge contour image;

判断所述线段组合信息及交点位置信息与标准特定标识图像的线段组合信息及交点位置信息是否相同;若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。Determine whether the line segment combination information and intersection position information are the same as the line segment combination information and intersection position information of the standard specific identification image; if so, regard the candidate connected domain area as the specific identification image area; if not, output the undetected specific identification image area.

优选地,所述获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点包括:Preferably, obtaining sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image includes:

以与所述填充图像有两个交点为条件,进行扫描,将该些交点作为采样像素点;Scanning is performed on the condition that there are two intersection points with the filling image, and the intersection points are used as sampling pixel points;

所述选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点包括:The selecting of the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range includes:

判断获取的所述采样像素点的上下边缘之间的距离和左右边缘之间的距离是否在设定的阈值范围内,若是,则选取;若否,则舍弃。Determine whether the distances between the upper and lower edges and the distances between the left and right edges of the obtained sampling pixel points are within a set threshold range. If so, select them; if not, discard them.

优选地,所述阈值范围为maxDist±maxDist×5%。Preferably, the threshold range is maxDist±maxDist×5%.

优选地,包括:Preferably, it includes:

根据预定区域或包含预定区域图像中特定标识的位置信息和各个交点位置信息,计算仿射变换矩阵;Calculating an affine transformation matrix based on the position information of a specific marker in a predetermined area or an image containing the predetermined area and the position information of each intersection point;

根据所述仿射变换矩阵获取所述预定区域内的相关信息。Relevant information within the predetermined area is acquired according to the affine transformation matrix.

优选地,所述特定标识图像为银行卡联合组织或银行卡发卡组织的标志图形。Preferably, the specific identification image is a logo graphic of a bank card association or a bank card issuing organization.

本申请另外提供一种用于检测预定区域中特定标识图像的装置,包括:The present application further provides a device for detecting a specific identification image in a predetermined area, comprising:

获取单元,用于获取所述预定区域或包含该预定区域的图像,作为待检目标图像;an acquisition unit, configured to acquire the predetermined area or an image containing the predetermined area as an image of a target to be inspected;

二值化处理单元,用于对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,二者均称为待检目标二值图像;A binarization processing unit, configured to perform binarization processing on the target image to be detected to obtain a binarized image and an inverse image of the binarized image, both of which are referred to as the target binary image to be detected;

连通域标定单元,用于标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域作为候选连通域;A connected domain calibration unit is used to calibrate the connected domain of the binary image of the target to be detected, and to select the connected domain whose number of pixels in the calibrated connected domain meets the set threshold range as a candidate connected domain;

图像特征比对单元,用于逐一获取所述候选连通域的图像特征,并将该候选连通域的图像特征与标准特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域视为特定标识图像所在位置。The image feature comparison unit is used to obtain the image features of the candidate connected domain one by one, and compare the image features of the candidate connected domain with the corresponding image features of the standard specific identification image, and regard the candidate connected domain with the same or closest comparison results as the location of the specific identification image.

优选地,所述获取单元包括:Preferably, the acquiring unit includes:

预览图像获取单元,用于获取所述预定区域或包含该预定区域的图像的预览图像;a preview image acquiring unit, configured to acquire a preview image of the predetermined area or an image containing the predetermined area;

计算单元,用于计算所述预览图像的区域范围;A calculation unit, configured to calculate the area range of the preview image;

框定单元,用于将所述预览图像框定在所述区域范围内,获取所述预定区域或包含预定区域的图像,将该框定的区域范围内的图像作为待检目标图像。The framing unit is used to frame the preview image within the area, obtain the predetermined area or an image containing the predetermined area, and use the image within the framed area as the target image to be inspected.

优选地,所述计算单元是指:根据所述预定区域的实际尺寸参数及预览图像的分辨率参数,获得框定所述预览图像的虚拟边框参数,具体为:Preferably, the calculation unit is configured to obtain virtual frame parameters for framing the preview image according to the actual size parameters of the predetermined area and the resolution parameters of the preview image, specifically:

根据所述预定区域或包含该预定区域图像的实际尺寸,判断所述预览图像高度乘以所述预定区域或包含该预定区域图像的实际宽度的值是否大于预览图像宽度乘以所述预定区域或包含该预定区域图像实际高度的值;Determining, based on the actual size of the predetermined area or the image containing the predetermined area, whether a value obtained by multiplying the height of the preview image by the actual width of the predetermined area or the image containing the predetermined area is greater than a value obtained by multiplying the width of the preview image by the actual height of the predetermined area or the image containing the predetermined area;

若是,则所述虚拟边框的宽度为:If so, the width of the virtual border is:

ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;

其中,CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;PreviewHeight为预览图像高度;CardHeightGdt为预定区域或包含该预定区域的图像实际高度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; PreviewHeight is the height of the preview image; CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio;

其中,PreviewHeight为预览图像高度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewHeight is the height of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

若否,则虚拟边框的宽度为:If not, the width of the virtual border is:

ScaledWidth=PreviewWidth×DisplayRatio;ScaledWidth=PreviewWidth×DisplayRatio;

其中,PreviewWidth为预览图像宽度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewWidth is the width of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;

其中,CardHeightGdt为预定区域或包含该预定区域图像的实际高度;PreviewWidth为预览图像宽度;CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; PreviewWidth is the width of the preview image; CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框上边界为显示屏幕高度与虚拟边框高度差的二分之一;所述虚拟边框下边界为显示屏幕高度与虚拟边框高度和的二分之一;所述虚拟边框的左边界为显示屏幕宽度与虚拟边框宽度差的二分之一;所述虚拟边框的右边界为显示屏幕宽度与虚拟边框宽度和的二分之一。The upper boundary of the virtual border is half of the difference between the display screen height and the virtual border height; the lower boundary of the virtual border is half of the sum of the display screen height and the virtual border height; the left boundary of the virtual border is half of the difference between the display screen width and the virtual border width; and the right boundary of the virtual border is half of the sum of the display screen width and the virtual border width.

优选地,所述获取单元包括:Preferably, the acquiring unit includes:

截取单元,用于根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像。The interception unit is used to intercept the area range containing the specific identification image as the target image to be inspected according to the specific position information of the specific identification image in the predetermined area or the predetermined area image.

优选地,所述特定位置信息为事先设定的特定标识图像所位于预定区域或包含预定区域图像上的位置。Preferably, the specific position information is the position of a pre-set specific identification image located in a predetermined area or on an image including a predetermined area.

优选地,所述特定位置是位于所述预定区域或包含预定区域的图像的右上角或右下角或左上角或左下角。Preferably, the specific position is the upper right corner or lower right corner or the upper left corner or lower left corner of the predetermined area or the image including the predetermined area.

优选地,所述截取单元包括:Preferably, the interception unit comprises:

建立单元,用于建立预定区域或包含预定区域的标准图像模板;An establishing unit, configured to establish a predetermined area or a standard image template containing the predetermined area;

遍历单元,用于根据所述预定区域或包含预定区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述预定区域或包含预定区域的图像的对应关系,获取特定标识图像在预定区域或包含预定区域的图像中的位置信息;a traversal unit, configured to traverse the standard image template according to the predetermined area or the image containing the predetermined area, and obtain position information of the specific identification image in the predetermined area or the image containing the predetermined area through a correspondence between the standard image template and the predetermined area or the image containing the predetermined area;

待检目标图像确定单元,用于根据该位置信息截取所述预定区域或包含预定区域的图像中包含特定标识的图像区域,作为待检目标图像。The target image to be inspected determining unit is configured to intercept the predetermined area or an image area containing a specific mark in the image containing the predetermined area according to the position information as the target image to be inspected.

优选地,所述阈值区间的上限值为所述预定区域或包含预定区域的图像宽度、高度和上限系数的乘积;下限值为所述预定区域或包含预定区域的图像宽度、高度和下限系数的乘积。Preferably, the upper limit value of the threshold interval is the product of the width, height and upper limit coefficient of the predetermined area or the image containing the predetermined area; the lower limit value is the product of the width, height and lower limit coefficient of the predetermined area or the image containing the predetermined area.

优选地,所述将该候选连通域区域的图像特征与所述特定标识图像的相应图像特征进行比对,包括:采用单独图像特征比对或者组合图像特征比对;其中,所述图像特征包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比。Preferably, the comparing the image features of the candidate connected domain area with the corresponding image features of the specific identification image includes: using a single image feature comparison or a combined image feature comparison; wherein the image features include the volume ratio of the connected domain, the major axis direction of the ellipse circumscribed by the connected domain, the outer contour shape of the connected domain and/or the aspect ratio of the rectangle circumscribed by the connected domain.

优选地,包括:组合图像特征筛选单元,具体是:Preferably, it includes: a combined image feature screening unit, specifically:

外接边框获取单元,用于获取候选连通域区域的外接边框;An outer bounding box obtaining unit, used to obtain the outer bounding box of the candidate connected region;

体积比计算单元,用于计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;a volume ratio calculation unit, configured to calculate a volume ratio of pixels of the foreground color in the candidate connected domain within the circumscribed frame to the area of the circumscribed frame;

体积比阈值判断单元,用于判断该体积比是否大于预先设定的特定标识图像的阈值范围;若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;A volume ratio threshold judgment unit is used to judge whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, the candidate connected domain area is discarded; if so, the candidate connected domain area is filled;

填充计算单元,用于计算填充后的所述候选连通域区域外接椭圆长轴的方向,并获得该方向与设定的参考轴的夹角;A filling calculation unit, used to calculate the direction of the major axis of the ellipse circumscribed in the candidate connected region after filling, and obtain the angle between the direction and the set reference axis;

夹角阈值判断单元,用于判断该夹角是否在预定的阈值范围内,若是,则将该候选连通域区域视为所述特定标识图像所在区域;若否,则舍弃该候选连通域区域。The angle threshold judgment unit is used to judge whether the angle is within a predetermined threshold range. If so, the candidate connected domain area is regarded as the area where the specific identification image is located; if not, the candidate connected domain area is discarded.

优选地,单独图像特征筛选单元,包括:Preferably, the individual image feature screening unit includes:

填充单元,用于填充所述候选连通域区域,获得填充图像;A filling unit, configured to fill the candidate connected component region to obtain a filled image;

边缘轮廓获取单元,用于根据检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;an edge contour acquiring unit, configured to acquire an edge contour image of the filled image by detecting the edge of the filled image;

采样单元,用于分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;a sampling unit, configured to respectively obtain sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image, and select the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

采样像素点拟合单元,用于分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;A sampling pixel point fitting unit is used to obtain sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image respectively, and select the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

线段组合判断单元,用于判断所述线段组合信息及交点位置信息与标准特定标识图像的线段组合信息和交点位置信息是否相同;若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。The line segment combination judgment unit is used to judge whether the line segment combination information and intersection position information are the same as the line segment combination information and intersection position information of the standard specific identification image; if so, the candidate connected domain area is regarded as the specific identification image area; if not, the undetected specific identification image area is output.

优选地,所述采样单元包括:Preferably, the sampling unit comprises:

扫描单元,以与所述填充图像有两个交点为条件,进行扫描,将该些交点作为采样像素点;a scanning unit, performing scanning based on the condition that there are two intersection points with the filling image, and using the intersection points as sampling pixel points;

距离阈值判断单元,用于判断获取的所述采样像素点的上下边缘之间的距离和左右边缘之间的距离是否在设定的阈值范围内,若是,则选取;若否,则舍弃。The distance threshold judgment unit is used to judge whether the distance between the upper and lower edges and the distance between the left and right edges of the obtained sampling pixel points are within a set threshold range. If so, they are selected; if not, they are discarded.

优选地,所述阈值范围为maxDist±maxDist×5%。Preferably, the threshold range is maxDist±maxDist×5%.

优选地,包括:Preferably, it includes:

仿射变换单元,用于根据预定区域或包含预定区域图像中特定标识的位置信息和各个交点位置信息,计算仿射变换矩阵;An affine transformation unit, configured to calculate an affine transformation matrix based on position information of a specific marker in a predetermined area or an image containing the predetermined area and position information of each intersection point;

相关信息获取单元,用于根据所述仿射变换矩阵获取相关信息。The relevant information acquisition unit is used to acquire relevant information according to the affine transformation matrix.

优选地,所述特定标识图像为银行卡联合组织或银行卡发卡组织的标志图形。Preferably, the specific identification image is a logo graphic of a bank card association or a bank card issuing organization.

与现有技术相比,本申请具有以下优点:Compared with the prior art, this application has the following advantages:

本申请通过获取预定区域的图像,作为待检目标图像,对该待检目标图像进行二值化处理,并标定二值化图像中的连通域作为候选连通域图像,在该些候选连通域图像中筛选出符合特定标识图像特征的连通域,进而确定检测到特定标识信息。The present application obtains an image of a predetermined area as the target image to be inspected, binarizes the target image to be inspected, and calibrates the connected domains in the binarized image as candidate connected domain images. The connected domains that meet the characteristics of the specific identification image are screened out from these candidate connected domain images, and then it is determined that the specific identification information is detected.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是本申请提供的一种用于检测预定区域中特定标识图像的方法流程图;FIG1 is a flow chart of a method for detecting a specific identification image in a predetermined area provided by the present application;

图2是本申请提供的一种用于检测预定区域中特定标识图像的方法中虚拟边框计算示意图;FIG2 is a schematic diagram of virtual border calculation in a method for detecting a specific identification image in a predetermined area provided by the present application;

图3是本申请提供的一种用于检测预定区域中特定标识图像的方法中虚拟边缘的示意图;FIG3 is a schematic diagram of a virtual edge in a method for detecting a specific identification image in a predetermined area provided by the present application;

图4是本申请提供的一种用于检测预定区域中特定标识图像的方法中截取包含特定标识图像的区域范围的第一实施例示意图;FIG4 is a schematic diagram of a first embodiment of a method for detecting a specific identification image in a predetermined area provided by the present application for intercepting an area containing a specific identification image;

图5是本申请提供的一种用于检测预定区域中特定标识图像的方法中截取包含特定标识图像的区域范围的第二实施例流程图;FIG5 is a flowchart of a second embodiment of a method for detecting a specific identification image in a predetermined area provided by the present application for intercepting an area containing a specific identification image;

图6是本申请提供的一种用于检测预定区域中特定标识图像的方法中对待检目标图像进行二值化处理后的二值化图像示意图;FIG6 is a schematic diagram of a binary image after a target image to be detected is binarized in a method for detecting a specific identification image in a predetermined area provided by the present application;

图7是本申请提供的一种用于检测预定区域中特定标识图像的方法中,对候选连通域区域进行第一次筛选的流程图;FIG7 is a flowchart of a method for detecting a specific identification image in a predetermined area provided by the present application, for performing a first screening of candidate connected domain regions;

图8是本申请提供的一种用于检测预定区域中特定标识图像的方法中,对候选联通区域进行第二次筛选的流程图;FIG8 is a flowchart of a second screening of candidate connected areas in a method for detecting a specific identification image in a predetermined area provided by the present application;

图9是本申请提供的一种用于检测预定区域中特定标识图像的方法中,对银联标识上置和下置的检测示意图;FIG9 is a schematic diagram of detecting the upper and lower placement of the UnionPay logo in a method for detecting a specific logo image in a predetermined area provided by the present application;

图10是本申请提供的一种用于检测预定区域中特定标识图像的装置结构框图。FIG10 is a block diagram of the structure of a device for detecting a specific identification image in a predetermined area provided by the present application.

具体实施方式DETAILED DESCRIPTION

在下面的描述中阐述了很多具体细节以便于充分理解本申请。但是本申请能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本申请内涵的情况下做类似推广,因此本申请不受下面公开的具体实施的限制。The following description sets forth many specific details to facilitate a thorough understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present application. Therefore, the present application is not limited to the specific implementations disclosed below.

本申请以银行卡卡面所在区域为预定区域,银行卡上的银联标识为特定标识,说明本申请的具体实现过程,但是应当说明,本申请的方法并不局限于对银行卡上的银联标识的识别,本申请的方法可以用于所有具有预定区域中特定已知标识的识别场景,特定已知标识可以是产品标识,企业logo等等,产品标识的预定区域可以是产品本身;企业logo的预定区域可以是包含有该logo的任何载体本身。This application takes the area where the bank card surface is located as the predetermined area and the UnionPay logo on the bank card as the specific logo to illustrate the specific implementation process of this application. However, it should be noted that the method of this application is not limited to the recognition of the UnionPay logo on the bank card. The method of this application can be used for all recognition scenarios with specific known logos in the predetermined area. The specific known logo can be a product logo, a corporate logo, etc. The predetermined area of the product logo can be the product itself; the predetermined area of the corporate logo can be any carrier itself containing the logo.

请参考图1所示,图1是本申请提供一种用于检测预定区域中特定标识图像方法的第一实施例流程图,在该实施例中,包括如下步骤:Please refer to FIG1 , which is a flow chart of a first embodiment of a method for detecting a specific identification image in a predetermined area provided by the present application. In this embodiment, the method includes the following steps:

步骤S100:获取预定区域的图像,作为待检目标图像;Step S100: Acquire an image of a predetermined area as an image of a target to be inspected;

步骤S200:对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,二者均称为待检目标二值图像;Step S200: performing binarization processing on the target image to be inspected to obtain a binarized image and an inverse image of the binarized image, both of which are referred to as the target binary image to be inspected;

步骤S300:标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域所在区域作为候选连通域区域;Step S300: calibrating the connected domain of the binary image of the target to be detected, and taking the connected domain area where the number of pixels in the calibrated connected domain meets the set threshold range as the candidate connected domain area;

步骤S400:逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与标准特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域区域视为特定标识图像所在位置。Step S400: Acquire the image features of the candidate connected domain regions one by one, and compare the image features of the candidate connected domain regions with the corresponding image features of the standard specific identification image, and regard the candidate connected domain regions with the same or closest comparison results as the locations of the specific identification images.

通过上述步骤,在对数据进行扫描分析时,是在较小的区域内进行,所以上述检测方法能够减小检测过程中的运算量,并且降低计算复杂度,能够根据特征比较快速完成检测。Through the above steps, when scanning and analyzing the data, it is performed in a smaller area, so the above detection method can reduce the amount of calculation in the detection process, reduce the calculation complexity, and can quickly complete the detection based on feature comparison.

下面对上述步骤的具体实现过程进行说明:The following describes the specific implementation process of the above steps:

所述步骤S100:获取预定区域的图像,作为待检目标图像。The step S100: obtaining an image of a predetermined area as an image of a target to be inspected.

该步骤中的预定区域可以是银行卡卡面区域,也就是说获取银行卡卡面图像或者包含有银行卡卡面区域的图像,获取方式可以通过采用移动终端人为获取或者自动获取,例如:通过移动终端的摄像功能获取预定区域或包含该预定区域的图像。通过预定区域的选取可以减小检测扫描范围,提高检测速度的同时,降低运算量。The predetermined area in this step can be the bank card surface area. In other words, an image of the bank card surface or an image containing the bank card surface area can be obtained. This can be obtained manually or automatically using a mobile terminal, for example, by using a mobile terminal's camera to capture the predetermined area or an image containing the predetermined area. Selecting the predetermined area can reduce the detection scanning range, thereby increasing detection speed and reducing computational complexity.

为更进一步提高检测效率,减少对非银联标识区域的检测,本申请可以在获取所述银行卡图像或者包含有银行卡区域的图像时,先通过获取的银行卡图像或者包含银行卡卡面区域图像的预览图像,并根据标准银行卡的实际尺寸及预览图像的分辨率,获得框定所述预览图像的虚拟边框的长和宽;再根据该虚拟边框的长宽计算出虚拟边框的上下左右边界,具体如下:To further improve detection efficiency and reduce detection of non-UnionPay logo areas, the present application can, when acquiring the bank card image or the image containing the bank card area, first obtain the bank card image or the preview image containing the bank card face area image, and based on the actual size of the standard bank card and the resolution of the preview image, obtain the length and width of the virtual frame that frames the preview image; then calculate the upper, lower, left, and right boundaries of the virtual frame based on the length and width of the virtual frame, as follows:

参考图2所示,图2是本申请提供的一种用于检测预定区域中特定标识图像的方法中虚拟边框计算示意图。根据《银联卡业务运作规章》第三卷《卡片BIN号及标识规则》,可以获知银行卡卡片的标准尺寸参数,卡片宽度是85.60mm±0.30mm,卡片高度是53.98mm±0.30mm,本申请中忽略卡片误差范围0.30mm,即:卡片宽度CardWidthGdt=85.6,卡片高度CardHeightGdt=53.98;假定移动终端屏幕分辨率为长×高,即:ScreenWidth×PreviewHeight;预览图像的分辨率参数为宽×高,即:PreviewWidth×PreviewHeight;虚拟边框与预览图像的比值参数为DisplayRatio;在计算虚拟边框时,首先判断PreviewHeight(预览图像高度)×CardWidthGdt(卡片宽度)是否大于(不包含等于)PreviewWidth(预览图像宽度)×CardHeightGdt(卡片高度),若是,则:Refer to FIG2 , which is a schematic diagram of virtual bounding box calculation in a method for detecting a specific identification image in a predetermined area provided by the present application. According to the "Card BIN Number and Identification Rules" in Volume 3 of the "UnionPay Card Business Operation Regulations", the standard size parameters of bank cards can be obtained. The card width is 85.60mm±0.30mm, and the card height is 53.98mm±0.30mm. In this application, the card error range of 0.30mm is ignored, that is, the card width CardWidthGdt = 85.6, and the card height CardHeightGdt = 53.98; assuming that the screen resolution of the mobile terminal is length × height, that is, ScreenWidth × PreviewHeight; the resolution parameter of the preview image is width × height, that is, PreviewWidth × PreviewHeight; the ratio parameter of the virtual border to the preview image is DisplayRatio; when calculating the virtual border, first determine whether PreviewHeight (preview image height) × CardWidthGdt (card width) is greater than (not equal to) PreviewWidth (preview image width) × CardHeightGdt (card height). If so, then:

ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;

ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio;

若否,则:If not, then:

ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;

ScaledWidth=PreviewWidth×DisplayRatio;ScaledWidth=PreviewWidth×DisplayRatio;

当计算得到虚拟边框的宽与高之后,可以根据移动终端屏幕的分辨率参数确定所述虚拟边框的上下左右边界,具体如下:After the width and height of the virtual frame are calculated, the upper, lower, left, and right boundaries of the virtual frame can be determined according to the resolution parameters of the mobile terminal screen, as follows:

上边界Top=ScreenHeight/2-ScaledHeight/2;Top = ScreenHeight / 2 - ScaledHeight / 2;

下边界Bottom=ScreenHeight/2+ScaledHeight/2;Bottom border = ScreenHeight/2 + ScaledHeight/2;

左边界Left=ScreenWidth/2-ScaledWidth/2;Left border Left = ScreenWidth/2 - ScaledWidth/2;

右边界Right=ScreenWidth/2+ScaledWidth/2。Right border Right = ScreenWidth/2 + ScaledWidth/2.

参考图3,图是3本申请提供的一种用于检测预定区域中特定标识图像的方法中虚拟边缘的示意图。Refer to FIG3 , which is a schematic diagram of a virtual edge in a method for detecting a specific identification image in a predetermined area provided by the present application.

所述虚拟边框覆盖在所述银行卡图像或者包含银行卡图像区域中银行卡的上方,将虚拟边框所覆盖的范围内区域作为待检目标图像,从而达到检测范围减小化。也可以在虚拟边框的覆盖范围内根据标准银行中银联标识的特定位置信息,截取包含银联标识图像的区域范围,将该区域范围作为待检目标图像,从而进一步达到检测范围的更小化,以提高检测速度,减少运算量。The virtual border covers the bank card image or the area containing the bank card image, and the area within the virtual border is used as the target image to be inspected, thereby reducing the detection range. Alternatively, within the coverage of the virtual border, the area containing the UnionPay logo image can be intercepted based on the specific position information of the UnionPay logo in a standard bank, and this area is used as the target image to be inspected, thereby further minimizing the detection range, improving detection speed, and reducing computational complexity.

截取包含银联标识图像的区域范围,本申请通过两种实现方式进行说明。This application describes two implementation methods for capturing the area containing the UnionPay logo image.

实现方式一:Implementation method 1:

参考图4所示,图4是本申请提供的一种用于检测预定区域中特定标识图像的方法中截取包含特定标识图像的区域范围的第一实施例示意图。根据《银联卡业务运作规章》第三卷《卡片BIN号及标识规则》可获知,银行卡上银联标识的位置信息是事先设定的位置,银联标识区位于卡片正面右侧,分为下置格式和上置格式两种。Referring to Figure 4, which is a schematic diagram illustrating a first embodiment of a method for detecting a specific logo image in a predetermined area provided by this application, for intercepting an area containing a specific logo image, it is known that the location of the UnionPay logo on a bank card is predetermined. The UnionPay logo area is located on the right side of the front of the card and is available in either a bottom-mounted or top-mounted format.

当银联标识采用下置格式时,须位于卡片的右下角,具体要求是:银联标识的宽度22mm,高度15mm,银联标识右边沿到卡的右边沿的距离是2mm,银联标识下边沿到卡的下边沿的距离是2mm。When the UnionPay logo is placed in the bottom format, it must be located in the lower right corner of the card. The specific requirements are: the width of the UnionPay logo is 22mm, the height is 15mm, the distance from the right edge of the UnionPay logo to the right edge of the card is 2mm, and the distance from the bottom edge of the UnionPay logo to the bottom edge of the card is 2mm.

当银联标识采用上置格式时,须位于卡片的右上角,具体要求是:银联标识的宽度22mm,高度15mm,银联标识右边沿到卡的右边沿的距离是2mm,银联标识上边沿到卡的上边沿的距离是2mm。When the UnionPay logo is placed in the top format, it must be located in the upper right corner of the card. The specific requirements are: the width of the UnionPay logo is 22mm, the height is 15mm, the distance from the right edge of the UnionPay logo to the right edge of the card is 2mm, and the distance from the top edge of the UnionPay logo to the top edge of the card is 2mm.

根据上述对银联标识的位置,在截取银行卡图像时,可以仅对银行卡图像或者包含银行卡区域的图像的右上角和右下角进行处理,例如:假定银行卡图像或者包含银行卡区域的图像的分辨率(宽×高)为:Width×Height,则需要截取的图像分别为[Width/2,Width]×[0,Height]和[Width/2,Width]×[Height/2,Height]。According to the above position of the UnionPay logo, when capturing a bank card image, only the upper right corner and lower right corner of the bank card image or the image containing the bank card area can be processed. For example, assuming that the resolution (width × height) of the bank card image or the image containing the bank card area is: Width × Height, the images that need to be captured are [Width/2, Width] × [0, Height] and [Width/2, Width] × [Height/2, Height] respectively.

实现方式二:Implementation method 2:

请参考图5所示,图5提供的一种用于检测预定区域中特定标识图像的方法中截取包含特定标识图像的区域范围的第二实施例流程图;包括:Please refer to FIG. 5 , which provides a flow chart of a second embodiment of a method for detecting a specific identification image in a predetermined area and capturing an area containing a specific identification image; the method includes:

步骤S101:建立银行卡图像的标准图像模板;Step S101: creating a standard image template for a bank card image;

步骤S102:根据所述银行卡图像或包含银行卡区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述银行卡图像或包含银行卡区域的图像的对应关系,获取银联标识图像在所述银行卡图像或包含银行卡区域图像中的位置信息;Step S102: Traversing the standard image template according to the bank card image or the image containing the bank card area, and obtaining position information of the UnionPay logo image in the bank card image or the image containing the bank card area based on the correspondence between the standard image template and the bank card image or the image containing the bank card area;

步骤S103:根据该位置信息截取包含有银联标识图像的区域范围,将该截取的银联标识图像的区域范围作为待检目标图像。Step S103: intercepting the region containing the UnionPay logo image according to the position information, and using the intercepted region containing the UnionPay logo image as the target image to be inspected.

可以理解的是,本申请也可以在该银行卡图像或包含有银行卡区域的图像的基础上,根据银联标识的特定位置信息或者根据银行卡标准图像模板,直接截取包含银联标识的图像区域,将该图像区域作为待检目标图像;也可以在虚拟边框的基础上仅截取所述虚拟边框范围内包含银联标识图像区域的部分,舍弃虚拟边框以外的图像信息,进而达到提高检测的效率。It is understandable that the present application can also directly intercept the image area containing the UnionPay logo based on the bank card image or the image containing the bank card area, according to the specific position information of the UnionPay logo or the standard image template of the bank card, and use the image area as the target image to be inspected; it can also intercept only the part of the image area containing the UnionPay logo within the virtual border based on the virtual border, and discard the image information outside the virtual border, thereby improving the efficiency of detection.

所述步骤S200:对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,二者均称为待检目标二值图像。The step S200: performing binarization processing on the target image to be detected to obtain a binarized image and an inverse image of the binarized image, both of which are referred to as the target binary image to be detected.

参考图6所示,图6是本申请提供的一种用于检测预定区域中特定标识图像的方法中对待检目标图像进行二值化处理后的二值化图像示意图;Referring to FIG6 , FIG6 is a schematic diagram of a binary image after a target image to be detected is binarized in a method for detecting a specific identification image in a predetermined area provided by the present application;

在该步骤中,将待检目标图像,也就是对截取的包含有银联标识图像的区域范围的图像进行二值化处理。图像二值化处理,是指将图像上的像素点的灰度值设置为0或255,也就是将整个图像呈现出明显的只有黑和白的视觉效果;即将256个亮度等级的灰度图像通过适当的阈值选取而获得仍然可以反映图像整体和局部特征的二值化图像。要进行二值图像的处理与分析,首先要把原图像灰度化,之后对灰度图像进行二值化,得到二值化图像,进而有利于再对图像做进一步处理时,图像的集合性质只与像素值为0或255的点的位置有关,不再涉及像素的多级值,使处理变得简单,而且数据的处理和压缩量减小。In this step, the target image to be inspected, that is, the image of the area containing the UnionPay logo image, is binarized. Image binarization refers to setting the grayscale value of the pixels on the image to 0 or 255, that is, making the entire image appear to be only black and white; that is, the grayscale image with 256 brightness levels is selected through an appropriate threshold to obtain a binary image that can still reflect the overall and local features of the image. To process and analyze binary images, the original image must first be grayscaled, and then the grayscale image is binarized to obtain a binary image. This is beneficial for further processing of the image. The collective properties of the image are only related to the positions of the points with pixel values of 0 or 255, and no longer involve the multi-level values of the pixels, making the processing simpler and reducing the amount of data processing and compression.

在该步骤中二值化处理过程中阈值的选取可以采用Otsu方法,将灰度图像分割成背景和目标(前景)两部分。所述Otsu方法又称为最大类间方差法,是一种自适应的阈值确定的方法,其按照图像的灰度特定,将图像分割成背景与目标两部分,背景和目标之间的类间方差越大,说明构成图像背景和目标差别越大。通过前景像素点数占图像的比例和平均灰度值;背景像素点数占图像的比例和平均灰度值,计算出前景和背景图像的方差,选取方差最大时所对应的灰度值即为全局阈值,根据该全局阈值对图像进行二值化变换。In this step, the threshold selection during the binarization process can use the Otsu method to segment the grayscale image into two parts: background and target (foreground). The Otsu method, also known as the maximum inter-class variance method, is an adaptive threshold determination method that divides the image into two parts, background and target, according to the grayscale characteristics of the image. The larger the inter-class variance between the background and target, the greater the difference between the background and target in the image. The variance of the foreground and background images is calculated by the proportion of foreground pixels in the image and the average grayscale value; the proportion of background pixels in the image and the average grayscale value. The grayscale value corresponding to the maximum variance is selected as the global threshold, and the image is binarized according to this global threshold.

由于在对二值化图像分析过程中,是要对二值化图像中白色像素(目标像素)进行标记,而包含有银联标识的图像作为待检测目标图像被二值化处理之后,银联标识可能会被二值化为前景(1)或背景(0),因此,在得到二值化图像后,还可以再对该二值化图像进行取反,将二值化图像和取反图像都作为待检目标二值图像。Since the white pixels (target pixels) in the binary image are to be marked during the analysis of the binary image, and the image containing the UnionPay logo is binarized as the target image to be detected, the UnionPay logo may be binarized as foreground (1) or background (0), therefore, after obtaining the binary image, the binary image can be inverted, and both the binary image and the inverted image are used as the target binary image to be detected.

二值图像分析最重要的方法就是连通区域标记,它是所有二值图像分析的基础,它通过对二值图像中白色像素(目标)的标记,让每个单独的连通区域形成一个被标识的块,进一步的我们就可以获取这些块的轮廓、外接矩形、质心、不变矩等几何参数。The most important method of binary image analysis is connected region labeling, which is the basis of all binary image analysis. It marks the white pixels (targets) in the binary image so that each individual connected region forms a marked block. Further, we can obtain the geometric parameters of these blocks, such as the outline, circumscribed rectangle, center of mass, invariant moment, etc.

二值图像的连通域标记处理操作就是从白色像素(通常二值图像用“1”)和黑色像素(通常用“0”来表示)组合的一幅点阵图像中,将互相邻接(4邻接或8邻接)的具有像素值“1”的像素集合提取出来。二值图像中包含黑(像素值为0)白(像素值为1或255)两种颜色,分别作为目标颜色和背景颜色,标记算法只对目标像素进行标记。The connected component labeling process for binary images involves extracting adjacent (4- or 8-adjacent) sets of pixels with a value of "1" from a dot matrix composed of white pixels (typically represented by "1" in binary images) and black pixels (typically represented by "0"). Binary images contain two colors: black (pixel value 0) and white (pixel value 1 or 255), which serve as the target color and background color, respectively. The labeling algorithm only labels the target pixels.

所述步骤S300:标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域作为候选连通域。The step S300 is: calibrating the connected domain of the binary image of the target to be detected, and taking the connected domain in which the number of pixels in the calibrated connected domain meets a set threshold range as a candidate connected domain.

连通域标定是所有二值图像分析的基础,二值图像的连通域标记处理操作就是从白色像素(通常二值图像用“1”)和黑色像素(通常用“0”来表示)组合的一幅点阵图像中,将互相邻接的具有像素值“1”的像素集合提取出来,也就是说,二值图像中包含黑(像素值为0)白(像素值为1或255)两种颜色,分别作为目标颜色和背景颜色,在连通域标定时,标定算法只对目标像素(白色像素)进行标定。Connected domain calibration is the basis of all binary image analysis. The connected domain marking processing operation of a binary image is to extract the adjacent pixel sets with pixel value "1" from a raster image composed of white pixels (usually represented by "1" in binary images) and black pixels (usually represented by "0"). In other words, the binary image contains two colors, black (pixel value 0) and white (pixel value 1 or 255), which serve as the target color and background color respectively. When calibrating the connected domain, the calibration algorithm only calibrates the target pixels (white pixels).

连通域标定算法中,常见的邻接关系有两种:4邻接与8邻接。4邻接一共4个点,即上、下、左和右;8邻接的点一共有8个,包括了对角线位置的点,即:上、下、左、右、左上和右上。将上、下、左、右或者上、下、左、右、左上、右上中彼此连通的点所构成集合标定为连通域。In the connected component demarcation algorithm, there are two common adjacency relationships: 4-adjacency and 8-adjacency. 4-adjacency consists of four points: up, down, left, and right. 8-adjacency consists of eight points, including diagonal points: up, down, left, right, upper-left, and upper-right. A connected component is defined as a set of points that are connected to each other in the order of up, down, left, and right, or up, down, left, right, upper-left, and upper-right.

该步骤将截取的包含有银联标识图像的区域范围经过二值化后,对二值化图像采用上述连通域标定方式,标定二值化图像中的连通域,也就是说,标定像素值为1的所有连通域。对所标定的每个独立的连通域进行阈值判断,若该连通域的像素个数在给定的阈值区间内,则保留该连通域,否则对待检目标二值图像中的取反图像进行连通域标定,并对取反图像中所标定的连通域像素个数进行阈值判断,若连通域像素个数在阈值区间内,则保留该连通域,若否则舍弃该连通域。In this step, the captured area containing the UnionPay logo image is binarized, and the connected domain calibration method described above is used on the binary image to calibrate the connected domains in the binary image. In other words, all connected domains with a pixel value of 1 are calibrated. A threshold value is determined for each independently calibrated connected domain. If the number of pixels in the connected domain is within a given threshold range, the connected domain is retained. Otherwise, a connected domain calibration is performed on the inverted image of the target binary image to be inspected, and a threshold value is determined for the number of pixels in the calibrated connected domain in the inverted image. If the number of pixels in the connected domain is within the threshold range, the connected domain is retained; otherwise, the connected domain is discarded.

需要说明的是,对于银联标识图像所形成的连通域,其连通域的像素个数会在一个合理范围内,该合理范围可以设定属于该银联标识图像连通域的阈值区间。It should be noted that, for the connected domain formed by the UnionPay logo image, the number of pixels in the connected domain will be within a reasonable range, and the reasonable range can be used to set the threshold interval of the connected domain of the UnionPay logo image.

上述银联标识连通域的阈值区间具体计算可以参考如下:The specific calculation of the threshold interval of the above UnionPay logo connectivity domain can be referred to as follows:

阈值下限LowThreshhold=Width×Height×下限系数;LowThreshhold = Width × Height × lower limit coefficient;

阈值上限HighThreshhold=Width×Height×上限系数;HighThreshhold = Width × Height × upper limit coefficient;

其中,Width和Height分别为所获取的预定区域图像或包含预定区域的图像的宽和高,也就是说,Width和Height可以是待检目标图像的宽和高,下限系数和上限取值可以为经验值,分别为0.011和0.043。Among them, Width and Height are the width and height of the acquired predetermined area image or the image containing the predetermined area, that is, Width and Height can be the width and height of the target image to be inspected, and the lower limit coefficient and upper limit values can be empirical values, which are 0.011 and 0.043 respectively.

当检测的特定标识信息非银联标识时,也可以根据该特定标识连通域的像素个数所处于的合理范围,来设定一个阈值区间。When the detected specific identification information is not the UnionPay logo, a threshold interval may also be set according to a reasonable range of the number of pixels in the connected domain of the specific logo.

所述步骤S400:逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与标准特定标识图像的相应图像特征进行比对,将比对结构相同或者接近的候选连通域区域视为特定标识图像所在位置。The step S400: obtaining the image features of the candidate connected domain regions one by one, and comparing the image features of the candidate connected domain regions with the corresponding image features of the standard specific identification image, and considering the candidate connected domain regions with the same or similar comparison structures as the locations of the specific identification image.

该步骤的具体实现过程是,对于候选的银联标识连通域区域的图像特征和标准银联标识图像,将二者的相应的图像特征进行比对,具体可以采用单独图像特征比对或者组合图像特征比对;其中,所述图像特征包括:包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比等,也可以理解的是上述特征属于图像的形状特征,而形状特征还可以包括距离特征、图像凹凸特征、长短特征等等。The specific implementation process of this step is to compare the corresponding image features of the candidate UnionPay logo connected domain area and the standard UnionPay logo image. Specifically, a single image feature comparison or a combined image feature comparison can be used; wherein, the image features include: the volume ratio of the connected domain, the major axis direction of the ellipse circumscribed in the connected domain, the outer contour shape of the connected domain and/or the aspect ratio of the rectangle circumscribed in the connected domain, etc. It can also be understood that the above features belong to the shape features of the image, and the shape features can also include distance features, image convexity features, length features, etc.

该步骤中,可以以所述连通域的体积比和连通域外接椭圆长轴方向作为第一组合图像特征,对候选银联标识图像的连通域区域进行筛选。In this step, the volume ratio of the connected domain and the major axis direction of the ellipse circumscribed by the connected domain may be used as the first combined image feature to screen the connected domain area of the candidate UnionPay logo image.

请参考图7所示,图7是本申请提供一种用于检测预定区域中特定标识图像的方法中对候选连通域区域进行第一次筛选的流程图。Please refer to FIG. 7 , which is a flowchart of performing a first screening of candidate connected domain regions in a method for detecting a specific identification image in a predetermined region provided by the present application.

具体步骤包括:The specific steps include:

步骤S701:获取候选连通域区域的外接边框;Step S701: Obtain the bounding box of the candidate connected region;

在该步骤中可以通过扫描的方式,从候选银联标识连通域图像的最外侧边缘向内扫描,检测到前景色(白色像素)后,停止扫描,获得外接边框,该外接边框为矩形。In this step, the image of the connected domain of the candidate UnionPay logo can be scanned inward from the outermost edge. After the foreground color (white pixel) is detected, the scanning is stopped to obtain an outer bounding box, which is a rectangle.

步骤S702:计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;Step S702: Calculating the volume ratio of the pixels of the foreground color in the candidate connected domain within the bounding box to the area of the bounding box;

该步骤可以通过统计矩形外接边框内前景色(白色)的像素个数,用白色像素个数除以矩形外接边框的面积,得到连通域体积比。In this step, the volume ratio of the connected domain can be obtained by counting the number of foreground color (white) pixels within the rectangular outer frame and dividing the number of white pixels by the area of the rectangular outer frame.

步骤S703:判断该体积比是否大于预先设定的特定标识图像的阈值范围,若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;Step S703: determining whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, discarding the candidate connected domain area; if so, filling the candidate connected domain area;

在该步骤中,可以根据事先设定标准银联标识连通域体积比的阈值Tsolid,判断候选银联标识连通域体积比是否与标准的银联标识连通域体积比的图像特征相符。其中阈值Tsolid可以通过标准银联标识图像的信息获得,例如:从各个角度获取标准银联标识图像,并计算其与外接矩阵的体积比,从而选取阈值Tsolid,通过候选银联标识连通域体积比与Tsolid的比较,确定候选连通域是否为银联标识图像。In this step, a predetermined threshold value Tsolid for the volume ratio of the connected domain of the standard UnionPay logo can be used to determine whether the volume ratio of the connected domain of the candidate UnionPay logo matches the image characteristics of the standard connected domain of the UnionPay logo. The threshold value Tsolid can be obtained using information about the standard UnionPay logo image. For example, the standard UnionPay logo image can be obtained from various angles and its volume ratio to the external matrix can be calculated to select the threshold value Tsolid. The volume ratio of the connected domain of the candidate UnionPay logo can then be compared with Tsolid to determine whether the candidate connected domain is a UnionPay logo image.

当候选银联标识连通域体积比大于阈值Tsolid,该候选银联标识连通域为银联标识连通域,因为,在候选银联标识连通域中可能存在与标准银联标识连通域体积比图像特征相同的非银联标识连通域,所以,本申请在此基础上还要结合另一图像特征,即:连通域椭圆长轴方向的图像特征,进一步确定该候选银联标识。当确定候选银联标识连通域体积比大于阈值Tsolid之后,进入连通域椭圆长轴方向的图像特征判断,如下述步骤S704。When the volume ratio of the candidate UnionPay logo connected domain is greater than the threshold value Tsolid, the candidate UnionPay logo connected domain is considered a UnionPay logo connected domain. Because the candidate UnionPay logo connected domain may contain non-UnionPay logo connected domains with the same image characteristics as the standard UnionPay logo connected domain volume ratio, the present application further determines the candidate UnionPay logo by combining another image feature, namely, the image feature along the major axis of the connected domain ellipse. After determining that the volume ratio of the candidate UnionPay logo connected domain is greater than the threshold value Tsolid, the process proceeds to determining the image feature along the major axis of the connected domain ellipse, as described in step S704.

步骤S704:对所述候选连通域区域进行填充;Step S704: filling the candidate connected domain area;

该步骤中,对银联标识候选连通域区域以前景色(白色)进行填充。In this step, the UnionPay logo candidate connected domain area is filled with the foreground color (white).

步骤S705:计算填充后的所述银联标识候选连通域区域的方向;Step S705: Calculate the direction of the filled UnionPay logo candidate connected domain area;

在该步骤中,可以通过采用椭圆拟合的方式,计算出连通域的方向。在该实施例中,连通域的方向以在所述连通域上获得的外接椭圆的长轴方向为连通域方向。所述椭圆拟合,是通过对候选连通域进行边缘检测,记录边缘上的点,对该些点进行椭圆拟合。In this step, the direction of the connected component can be calculated by using ellipse fitting. In this embodiment, the direction of the connected component is the direction of the major axis of the circumscribed ellipse obtained on the connected component. The ellipse fitting is performed by performing edge detection on the candidate connected component, recording the points on the edge, and performing ellipse fitting on these points.

当计算出椭圆拟合长轴方向之后,以连通域的左下角为原点建立坐标轴,该坐标轴的X轴定义为参考轴,进而椭圆长轴与X轴之间形成夹角。同样地,对于标准银联标识图像,也可以计算出椭圆长轴与X轴之间形成的夹角。After calculating the direction of the major axis of the ellipse fit, a coordinate axis is established with the lower left corner of the connected domain as the origin. The X-axis of this coordinate axis is defined as the reference axis, and the angle formed between the major axis of the ellipse and the X-axis is then calculated. Similarly, for the standard UnionPay logo image, the angle formed between the major axis of the ellipse and the X-axis can also be calculated.

步骤S706:判断该夹角是否在预定的阈值范围内,若是,则将该银联标识的候选连通域区域视为所述银联标识图像所在区域;若否,则舍弃该银联标识的候选连通域区域;Step S706: determining whether the angle is within a predetermined threshold range; if so, considering the candidate connected domain area of the UnionPay logo as the area where the UnionPay logo image is located; if not, discarding the candidate connected domain area of the UnionPay logo;

该步骤中,夹角的阈值范围可以根据上述对标准银联标识图像进行椭圆拟合,并计算该椭圆长轴方向与参考轴之间的夹角,因为,在获取银联标识待检目标图像,可能存在获取角度等因素的影响,使得候选连通域图像角度也会受到影响,所以本申请基于标准银联标识中椭圆长轴与参考轴之间的夹角,设定夹角的阈值范围,以避免由于获取角度的问题而影响判断,此处的参考轴也为X轴。上述的参考轴的设定可以根据实际判断需要设定,即:也可以为Y轴,能够满足连通域外接椭圆长轴方向特征判断需求即可。In this step, the threshold range of the angle can be based on the above-mentioned ellipse fitting of the standard UnionPay logo image and the calculation of the angle between the major axis of the ellipse and the reference axis. Because, when obtaining the target image of the UnionPay logo to be inspected, there may be factors such as the acquisition angle, which will also affect the angle of the candidate connected domain image. Therefore, this application sets the threshold range of the angle based on the angle between the major axis of the ellipse in the standard UnionPay logo and the reference axis to avoid affecting the judgment due to the problem of the acquisition angle. The reference axis here is also the X-axis. The setting of the above-mentioned reference axis can be set according to the actual judgment needs, that is, it can also be the Y-axis, which can meet the requirements for judging the major axis direction characteristics of the ellipse circumscribed in the connected domain.

需要说明的是,当特定标识为存在两个明显的外接边缘,即:内层边缘和外层边缘连通域时;还可以在上述基础上再次对银联标识候选连通域图像进行二次体积比判断,但该二次体积比判断时,其阈值采用的并非上述Tsolid,而是针对此次判断设定的另一阈值Tsolid’,检测判断过程如上述步骤S701-步骤S706。需要说明的是,内层连通域的像素值与外层连通域的像素值是不同的,所以采用阈值也不同。It should be noted that when a specific logo has two distinct circumscribed edges, namely, an inner edge and an outer edge connected domain, a secondary volume ratio determination can be performed on the UnionPay logo candidate connected domain image based on the above. However, the threshold used in this secondary volume ratio determination is not the aforementioned Tsolid, but a different threshold Tsolid' set specifically for this determination. The detection and determination process is the same as steps S701-S706 above. It should be noted that the pixel values of the inner connected domain are different from those of the outer connected domain, so different thresholds are used.

经过上述步骤已经可以确定银联标识候选连通域图像为银联标识图像,为更进一步确定,本申请在上述步骤基础上判断所述椭圆长轴与所述参考轴的夹角在预定的阈值范围内的基础上,以所述连通域外轮廓形状作为单独条件对所述候选连通域区域进行第二次筛选。After the above steps, it can be determined that the UnionPay logo candidate connected domain image is the UnionPay logo image. To further confirm, this application judges that the angle between the major axis of the ellipse and the reference axis is within a predetermined threshold range based on the above steps, and then uses the outer contour shape of the connected domain as a separate condition to perform a second screening of the candidate connected domain area.

具体参考图8所示,图8是本申请提供的一种用于检测预定区域中特定标识图像的方法中,以连通域外轮廓形状作为单独条件对所述候选连通域区域进行第二次筛选的流程图。8 , which is a flowchart of a method provided by the present application for detecting a specific identification image in a predetermined area, in which the outer contour shape of the connected domain is used as a separate condition for performing a second screening on the candidate connected domain area.

具体包括如下步骤:The specific steps include:

步骤S801:填充所述候选连通域区域,获得填充图像;Step S801: Filling the candidate connected component area to obtain a filled image;

该步骤可以采用步骤S704中的填充方式,对候选连通域区域进行填充。This step may use the filling method in step S704 to fill the candidate connected component area.

步骤S802:检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;Step S802: detecting the edge of the filled image to obtain an edge contour image of the filled image;

该步骤具体实现,当候选连通域区域以白色进行填充后,白色区域为候选连通域区域,通过采用边缘检测方法,获得填充图像的边缘轮廓图像。所述边缘检测方法是图像处理中常用的一种技术,其可以捕获图像中物体的重要特征,常用的边缘检测方法有:查分边缘检测、梯度边缘检测、Roberts边缘检测算子、Sobel边缘检测算子、Prewitt边缘检测算子和Laplace边缘检测算子等等。本申请中采用Sobel边缘检测算子检测所述填充图像的边缘,所述Sobel边缘检测算子主要是根据像素点上下、左右邻点灰度加权差,在边缘处达到极值现象检测边缘,其对噪声具有平滑作用,能够提供较为精确的边缘方向信息。Sobel算子有两个,一个是检测水平边缘的;另一个是检测垂直边缘的。与Prewitt算子相比,Sobel算子对于象素的位置的影响做了加权,可以降低边缘模糊程度,因此效果更好。当然,也可以根据不同的需求采用其他边缘检测算子来检测填充图像的边缘。In this step, after the candidate connected domain area is filled with white, the white area becomes the candidate connected domain area. Edge detection methods are then used to obtain an edge contour image of the filled image. Edge detection methods are commonly used in image processing and can capture important features of objects in an image. Common edge detection methods include: edge detection, gradient edge detection, Roberts edge detection operator, Sobel edge detection operator, Prewitt edge detection operator, and Laplace edge detection operator. In this application, the Sobel edge detection operator is used to detect the edges of the filled image. The Sobel edge detection operator primarily detects edges based on the weighted grayscale difference between the upper and lower and left and right neighboring pixels of a pixel, reaching an extreme value at the edge. It has a noise-smoothing effect and can provide relatively accurate edge direction information. There are two Sobel operators: one for detecting horizontal edges and the other for detecting vertical edges. Compared to the Prewitt operator, the Sobel operator weights the influence of pixel position, which can reduce edge blur, resulting in better results. Of course, other edge detection operators can also be used to detect the edges of the filled image according to different needs.

步骤S803:分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;Step S803: acquiring sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image respectively, and selecting the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

在该步骤中,采用扫描的方式采样边缘轮廓图像中的上下边缘和左右边缘的采样像素点。在以银联标识为实施例的情况下,填充图像的边缘轮廓为矩形图像,分别对矩形图像的上下边缘和左右边缘分别进行扫面,对上下边缘和左右边缘的扫描方式可以采用相同方式,下面以上下边缘举例说明。In this step, a scanning method is used to sample pixel points at the upper and lower edges and the left and right edges of the edge contour image. In the case of the UnionPay logo as an example, the edge contour of the fill image is a rectangular image. The upper and lower edges and the left and right edges of the rectangular image are scanned separately. The scanning method for the upper and lower edges and the left and right edges can be used in the same way. The upper and lower edges are used as an example below.

对矩形图像的边缘进行逐列扫描,选取扫描线与所述边缘图像有两个交点的像素点,并对该些像素点之间的距离进行计算,统计所有像素点之间的最大值maxDist的像素点作为采样像素点。由于矩形图像的边缘可能存在锯齿,因此,设定最大距离的阈值范围对采样像素点进行选取,阈值范围可以设定在maxDist±maxDist×5%,选取在该阈值范围内的像素点作为采样像素点,该阈值范围以外的像素点则舍弃。从而得到矩形图像上下边缘的采样像素点,同理,可以获得左右边缘的采样像素点。Scan the edges of the rectangular image column by column, select pixels where the scan line intersects the edge image, calculate the distances between these pixels, and count the pixels with the maximum value (maxDist) between all pixels as sampling pixels. Because the edges of rectangular images may have jagged edges, a threshold range of the maximum distance is set to select sampling pixels. The threshold range can be set to maxDist±maxDist×5%. Pixels within this threshold range are selected as sampling pixels, and pixels outside this threshold range are discarded. This results in sampling pixels for the upper and lower edges of the rectangular image. Similarly, sampling pixels for the left and right edges can be obtained.

步骤S804:拟合所述选取的采样像素点,获得所述边缘轮廓图像的线段组合信息。Step S804: fitting the selected sampling pixel points to obtain line segment combination information of the edge contour image.

通过步骤S803选取的候选连通域矩形图像四条边的采样像素点,步骤S804可以采用多项式曲线拟合方法,对所选取的采样像素点进行拟合,从而得到四条线段,并通过该四条线段组合可以获得四个顶点;步骤S804的具体实现方式是针对银行卡银联标识进行举例说明,可以理解的是,如果其他标识可以采用不同的拟合方式或者计算方法,进行采样像素点的拟合。In step S804, a polynomial curve fitting method can be used to fit the sampled pixel points of the four sides of the candidate connected domain rectangular image selected in step S803, thereby obtaining four line segments, and four vertices can be obtained by combining the four line segments. The specific implementation method of step S804 is illustrated by taking the UnionPay logo of a bank card as an example. It can be understood that if other logos can use different fitting methods or calculation methods to fit the sampled pixel points.

步骤S805:判断所述线段组合信息与标准特定标识图像的线段组合信息是否相同,若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。Step S805: determining whether the line segment combination information is the same as the line segment combination information of the standard specific identification image; if so, treating the candidate connected domain area as the specific identification image area; if not, outputting an undetected specific identification image area.

该步骤中,对于在步骤S804中获得的线段组合,即:四条线段以及根据该四条线段的组合获得四个顶点,将该四条线段与四个顶点与标准银行卡银联标识的图像进行比较,相同则该银联标识候选连通域区域即为银联标识图像。In this step, for the line segment combination obtained in step S804, that is, four line segments and four vertices obtained based on the combination of the four line segments, the four line segments and four vertices are compared with the image of the standard bank card UnionPay logo. If they are the same, the UnionPay logo candidate connected domain area is the UnionPay logo image.

需要说明的是,经过以上步骤,候选银联标识被检测到,系统可以输出银联标识的四个角点(参考图9)。同时,若检测得到的组合信息,例如:顶点信息多于或少于4个,则可以判断该候选区域非银联图标。若检测到的银联标识候选区域为空,则提示用户未检测到银联标识,若检测到的银联标识候选区域个数多于一个,则将所有候选区域提供给用户,用于用户自主选择。It should be noted that after the above steps, the candidate UnionPay logo is detected, and the system can output the four corner points of the UnionPay logo (see Figure 9). At the same time, if the combination of information detected, for example: more or less than 4 vertex information, it can be determined that the candidate area is not a UnionPay icon. If the detected UnionPay logo candidate area is empty, the user is prompted that no UnionPay logo is detected. If the number of detected UnionPay logo candidate areas is more than one, all candidate areas are provided to the user for self-selection.

上述是以银联标识为例对检测特定标识进行的说明,对于银联标识而言,其具有的图像特征是形状特征,包括有平行四边形、四个顶点等属性;当特定标识为文字或产品标识或企业logo等时,可以通过其本申请具有的图像特征进行检测,例如:各个发卡银行的logo,以招商银行的logo为例进行说明,请参考图3,招商银行的logo图像的图像特征可以是圆形、字母M以及字母M的各个顶点、三角形或者是凹凸属性等等,可以通过该些特征属性采用上述检测方法,对该logo进行检测。The above is an explanation of detecting specific logos using the UnionPay logo as an example. For the UnionPay logo, its image features are shape features, including attributes such as a parallelogram and four vertices; when the specific logo is text or a product logo or a corporate logo, etc., it can be detected by the image features of this application, for example: the logos of various issuing banks. Taking the logo of China Merchants Bank as an example, please refer to Figure 3. The image features of the China Merchants Bank logo image can be a circle, the letter M and the vertices of the letter M, a triangle or a concave and convex attribute, etc. The above detection method can be used to detect the logo through these feature attributes.

由此可见,本申请提供的检测特定标识的方法并不限于上述银联标识。It can be seen that the method for detecting a specific logo provided in this application is not limited to the above-mentioned UnionPay logo.

当检测到银联标识后可以根据检测到的银联标识的四个顶点信息以及标准银联信息的顶点信息,计算银联标识图像的仿射变换矩阵;根据该矩阵可以计算获得银行卡上其他信息。仿射变换矩阵可以采用如下方式获得:After the UnionPay logo is detected, the affine transformation matrix of the UnionPay logo image can be calculated based on the four vertex information of the detected UnionPay logo and the vertex information of the standard UnionPay information; based on this matrix, other information on the bank card can be calculated. The affine transformation matrix can be obtained as follows:

假定标准的银联标识的四个顶点坐标为[x1,y1],[x2,y2],[x3,y3]和[x4,y4],而在检测到候选连通域图像中的4个顶点的坐标为[X1,Y1],[X2,Y2],[X3,Y3]和[X4,Y4],根据4个点的对应关系就可以计算仿射变换(projective)矩阵M,对于检测图像的每个像素点可以计算射影变换后的图像,此图像所在的视觉就是正视角图像。根据银行卡中的规定,可以获知银行卡上任何信息,例如:需要获知银行卡上的卡号信息时,将卡号的像素点乘以矩阵M即可以获得卡号的正是正视角图像,从而的准确的卡号信息。Assuming the coordinates of the four vertices of the standard UnionPay logo are [x1, y1], [x2, y2], [x3, y3], and [x4, y4], and the coordinates of the four vertices in the detected candidate connected domain image are [X1, Y1], [X2, Y2], [X3, Y3], and [X4, Y4], the affine transformation (projective) matrix M can be calculated based on the correspondence between the four points. For each pixel in the detected image, the image after the projective transformation can be calculated. The visual field of this image is the orthographic image. According to the regulations on the bank card, any information on the bank card can be obtained. For example, if the card number on the bank card is needed, the pixel of the card number is multiplied by the matrix M to obtain the orthographic image of the card number, thereby accurately obtaining the card number information.

以上公开了本申请一种用于检测预定区域中特定标识图像的方法实施例,与所述方法实施例相对应,本申请还公开了一种用于检测预定区域中特定标识图像装置实施例,请参看图10,其为本申请一种用于检测预定区域中特定标识图像的装置的实施例结构示意图。由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。下述描述的装置实施例仅仅是示意性的。The above discloses a method embodiment of the present application for detecting a specific identification image in a predetermined area. Corresponding to the method embodiment, the present application also discloses an apparatus embodiment for detecting a specific identification image in a predetermined area. Please refer to Figure 10, which is a schematic diagram of the structure of an embodiment of the apparatus for detecting a specific identification image in a predetermined area. Because the apparatus embodiment is substantially similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the description of the method embodiment. The apparatus embodiment described below is merely illustrative.

如图10所示,本申请提供的一种用于检测预定区域中特定标识图像的装置,包括:As shown in FIG10 , the present application provides a device for detecting a specific identification image in a predetermined area, comprising:

获取单元A100,用于获取所述预定区域或包含该预定区域的图像,作为待检目标图像;An acquisition unit A100 is configured to acquire the predetermined area or an image containing the predetermined area as an image of an object to be inspected;

二值化处理单元A200,用于对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,二者均称为待检目标二值图像;A binarization processing unit A200 is used to perform binarization processing on the target image to obtain a binarized image and an inverse image of the binarized image, both of which are referred to as the target binary image;

连通域标定单元A300,用于标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域作为候选连通域;The connected domain calibration unit A300 is used to calibrate the connected domain of the binary image of the target to be detected, and select the connected domain whose number of pixels in the calibrated connected domain meets the set threshold range as the candidate connected domain;

图像特征比对单元A400,用于逐一获取所述候选连通域的图像特征,并将该候选连通域的图像特征与标准特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域视为特定标识图像所在位置。The image feature comparison unit A400 is used to obtain the image features of the candidate connected domain one by one, and compare the image features of the candidate connected domain with the corresponding image features of the standard specific identification image, and regard the candidate connected domain with the same or closest comparison results as the location of the specific identification image.

其中,该获取单元A100包括:The acquisition unit A100 includes:

预览图像获取单元,用于获取所述预定区域或包含该预定区域的图像的预览图像;a preview image acquiring unit, configured to acquire a preview image of the predetermined area or an image containing the predetermined area;

计算单元,用于计算所述预览图像的区域范围;该计算单元是指,根据所述预定区域的实际尺寸参数及预览图像的分辨率参数,获得框定所述预览图像的虚拟边框参数,具体为:A calculation unit is used to calculate the area range of the preview image; the calculation unit is to obtain virtual frame parameters for framing the preview image based on the actual size parameters of the predetermined area and the resolution parameters of the preview image, specifically:

根据所述预定区域或包含该预定区域图像的实际尺寸,判断所述预览图像高度乘以所述预定区域或包含该预定区域图像的实际宽度的值是否大于预览图像宽度乘以所述预定区域或包含该预定区域图像实际高度的值;Determining, based on the actual size of the predetermined area or the image containing the predetermined area, whether a value obtained by multiplying the height of the preview image by the actual width of the predetermined area or the image containing the predetermined area is greater than a value obtained by multiplying the width of the preview image by the actual height of the predetermined area or the image containing the predetermined area;

若是,则所述虚拟边框的宽度为:If so, the width of the virtual border is:

ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;

其中,CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;PreviewHeight为预览图像高度;CardHeightGdt为预定区域或包含该预定区域的图像实际高度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; PreviewHeight is the height of the preview image; CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio;

其中,PreviewHeight为预览图像高度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewHeight is the height of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

若否,则虚拟边框的宽度为:If not, the width of the virtual border is:

ScaledWidth=PreviewWidth×DisplayRatio;ScaledWidth=PreviewWidth×DisplayRatio;

其中,PreviewWidth为预览图像宽度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewWidth is the width of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框的高度为:The height of the virtual border is:

ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;

其中,CardHeightGdt为预定区域或包含该预定区域图像的实际高度;PreviewWidth为预览图像宽度;CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; PreviewWidth is the width of the preview image; CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image;

所述虚拟边框上边界为显示屏幕高度与虚拟边框高度差的二分之一;所述虚拟边框下边界为显示屏幕高度与虚拟边框高度和的二分之一;所述虚拟边框的左边界为显示屏幕宽度与虚拟边框宽度差的二分之一;所述虚拟边框的右边界为显示屏幕宽度与虚拟边框宽度和的二分之一。The upper boundary of the virtual border is half of the difference between the display screen height and the virtual border height; the lower boundary of the virtual border is half of the sum of the display screen height and the virtual border height; the left boundary of the virtual border is half of the difference between the display screen width and the virtual border width; and the right boundary of the virtual border is half of the sum of the display screen width and the virtual border width.

框定单元,用于将所述预览图像框定在所述区域范围内,获取所述预定区域或包含预定区域的图像,将该框定的区域范围内的图像作为待检目标图像。The framing unit is used to frame the preview image within the area, obtain the predetermined area or an image containing the predetermined area, and use the image within the framed area as the target image to be inspected.

所述获取单元A100还包括:The acquisition unit A100 further includes:

截取单元,用于根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像。其中,截取单元中的特定位置信息为事先设定的特定标识图像所位于预定区域或包含预定区域图像上的位置。在以银行卡的银联标识为特定标识的情况下,所述特定位置可以根据《银联卡业务运作规章》第三卷《卡片BIN号及标识规则》中的记载可以获知,银联标识的特定位置位于银行卡卡面区域的右上角或者右下角。可以理解的是,当特定标识信息非银联标识,还有可以位于左上角或左下角等。The interception unit is used to intercept the area range containing the specific identification image according to the specific position information of the specific identification image in the predetermined area or the predetermined area image, as the target image to be inspected. The specific position information in the interception unit is the pre-set position of the specific identification image in the predetermined area or the image containing the predetermined area. In the case where the UnionPay logo of the bank card is used as the specific identification, the specific position can be known according to the records in the "Card BIN Number and Identification Rules" in Volume 3 of the "UnionPay Card Business Operation Regulations". The specific position of the UnionPay logo is located in the upper right corner or lower right corner of the bank card surface area. It is understandable that when the specific identification information is not the UnionPay logo, it can also be located in the upper left corner or lower left corner, etc.

截取单元还可以通过下述方式实现:The interception unit can also be implemented in the following ways:

建立单元,用于建立预定区域或包含预定区域的标准图像模板;An establishing unit, configured to establish a predetermined area or a standard image template containing the predetermined area;

遍历单元,用于根据所述预定区域或包含预定区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述预定区域或包含预定区域的图像的对应关系,获取特定标识图像在预定区域或包含预定区域的图像中的位置信息;a traversal unit, configured to traverse the standard image template according to the predetermined area or the image containing the predetermined area, and obtain position information of the specific identification image in the predetermined area or the image containing the predetermined area through a correspondence between the standard image template and the predetermined area or the image containing the predetermined area;

待检目标图像确定单元,用于根据该位置信息截取所述预定区域或包含预定区域的图像中包含特定标识的图像区域,作为待检目标图像。The target image to be inspected determining unit is configured to intercept the predetermined area or an image area containing a specific mark in the image containing the predetermined area according to the position information as the target image to be inspected.

连通域标定单元A300中的阈值区间的上限值为所述预定区域或包含预定区域的图像宽度、高度和上限系数的乘积;下限值为所述预定区域或包含预定区域的图像宽度、高度和下限系数的乘积。The upper limit value of the threshold interval in the connected domain calibration unit A300 is the product of the width, height and upper limit coefficient of the predetermined area or the image containing the predetermined area; the lower limit value is the product of the width, height and lower limit coefficient of the predetermined area or the image containing the predetermined area.

图像特征比对单元A400,包括组合图像特征筛选单元或单独图像特征筛选单元,通过采用单独图像特征比对或者组合图像特征比对;其中,所述图像特征包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比。The image feature comparison unit A400 includes a combined image feature screening unit or a separate image feature screening unit, by adopting separate image feature comparison or combined image feature comparison; wherein, the image features include the volume ratio of the connected domain, the major axis direction of the ellipse circumscribed in the connected domain, the outer contour shape of the connected domain and/or the aspect ratio of the rectangle circumscribed in the connected domain.

组合图像特征筛选单元,具体是:Combined image feature screening unit, specifically:

外接边框获取单元,用于获取候选连通域区域的外接边框;An outer bounding box obtaining unit, used to obtain the outer bounding box of the candidate connected domain area;

体积比计算单元,用于计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;a volume ratio calculation unit, configured to calculate a volume ratio of pixels of the foreground color in the candidate connected domain within the circumscribed frame to the area of the circumscribed frame;

体积比阈值判断单元,用于判断该体积比是否大于预先设定的特定标识图像的阈值范围;若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;A volume ratio threshold judgment unit is used to judge whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, the candidate connected domain area is discarded; if so, the candidate connected domain area is filled;

填充计算单元,用于计算填充后的所述候选连通域区域外接椭圆长轴的方向,并获得该方向与设定的参考轴的夹角;A filling calculation unit, used to calculate the direction of the major axis of the ellipse circumscribed in the candidate connected region after filling, and obtain the angle between the direction and the set reference axis;

夹角阈值判断单元,用于判断该夹角是否在预定的阈值范围内,若是,则将该候选连通域区域视为所述特定标识图像所在区域;若否,则舍弃该候选连通域区域。The angle threshold judgment unit is used to judge whether the angle is within a predetermined threshold range. If so, the candidate connected domain area is regarded as the area where the specific identification image is located; if not, the candidate connected domain area is discarded.

单独图像特征筛选单元,包括:Separate image feature screening unit, including:

填充单元,用于填充所述候选连通域区域,获得填充图像;A filling unit, configured to fill the candidate connected component region to obtain a filled image;

边缘轮廓获取单元,用于根据检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;an edge contour acquiring unit, configured to acquire an edge contour image of the filled image by detecting the edge of the filled image;

采样单元,用于分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;a sampling unit, configured to respectively obtain sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image, and select the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

采样像素点拟合单元,用于分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;A sampling pixel point fitting unit is used to obtain sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image respectively, and select the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range;

线段组合判断单元,用于判断所述线段组合信息及交点位置信息与标准特定标识图像的线段组合信息和交点位置信息是否相同;若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。The line segment combination judgment unit is used to judge whether the line segment combination information and intersection position information are the same as the line segment combination information and intersection position information of the standard specific identification image; if so, the candidate connected domain area is regarded as the specific identification image area; if not, the undetected specific identification image area is output.

所述采样单元包括:The sampling unit comprises:

扫描单元,以与所述填充图像有两个交点为条件,进行扫描,将该些交点作为采样像素点;a scanning unit, performing scanning based on the condition that there are two intersection points with the filling image, and using the intersection points as sampling pixel points;

距离阈值判断单元,用于判断获取的所述采样像素点的上下边缘之间的距离和左右边缘之间的距离是否在设定的阈值范围内,若是,则选取;若否,则舍弃。在该距离阈值判断单元中,阈值范围可以是maxDist±maxDist×5%,其中maxDist为两个采样像素点的最大距离。A distance threshold determination unit is configured to determine whether the distances between the upper and lower edges and the distances between the left and right edges of the sampled pixels are within a set threshold range. If so, the sampled pixels are selected; otherwise, the sampled pixels are discarded. In this distance threshold determination unit, the threshold range may be maxDist ± maxDist × 5%, where maxDist is the maximum distance between two sampled pixels.

本申请还包括仿射变换单元,用于根据预定区域或包含预定区域图像中特定标识的位置信息和各个交点位置信息,计算仿射变换矩阵;以及相关信息获取单元,用于根据所述仿射变换矩阵获取相关信息。The present application also includes an affine transformation unit for calculating an affine transformation matrix based on the position information of specific identifiers in a predetermined area or an image containing a predetermined area and the position information of each intersection; and a related information acquisition unit for acquiring related information based on the affine transformation matrix.

本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。Although the present application is disclosed as above with the preferred embodiments, it is not intended to limit the present application. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

1、计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

2、本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。2. Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

Claims (30)

1.一种用于检测预定区域中特定标识图像的方法,其特征在于,包括:1. A method for detecting a specific identification image in a predetermined area, comprising: 获取预定区域的图像,作为待检目标图像;Acquire an image of a predetermined area as an image of a target to be inspected; 对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,将所述二值化图像和所述取反图像均称为待检目标二值图像;Binarizing the target image to be inspected to obtain a binary image and a negated image of the binary image, wherein both the binary image and the negated image are referred to as the binary image of the target image to be inspected; 标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域所在区域作为候选连通域区域;Calibrate the connected domain of the binary image of the target to be detected, and take the area where the number of pixels in the calibrated connected domain meets the set threshold range as the candidate connected domain area; 逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与标准特定标识图像的相应图像特征采用单独图像特征比对或者组合图像特征比对,将比对结果相同或最接近的候选连通域区域视为特定标识图像所在位置。The image features of the candidate connected domain areas are obtained one by one, and the image features of the candidate connected domain areas are compared with the corresponding image features of the standard specific identification image using a single image feature comparison or a combined image feature comparison, and the candidate connected domain areas with the same or closest comparison results are regarded as the locations of the specific identification images. 2.根据权利要求1所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述获取所述预定区域图像,作为待检目标图像,包括:2. The method for detecting a specific identification image in a predetermined area according to claim 1, wherein obtaining the image of the predetermined area as the target image to be detected comprises: 获取所述预定区域或包含该预定区域的图像的预览图像;Acquiring a preview image of the predetermined area or an image containing the predetermined area; 计算所述预览图像的区域范围;Calculating the area range of the preview image; 将所述预览图像框定在所述区域范围内,获取所述预定区域或包含预定区域的图像,将该框定的区域范围内的图像作为待检目标图像。The preview image is framed within the region, the predetermined region or an image containing the predetermined region is acquired, and the image within the framed region is used as a target image to be inspected. 3.根据权利要求2所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述计算预览图像的区域范围是指:根据所述预定区域的实际尺寸参数及预览图像的分辨率参数,获得框定所述预览图像的虚拟边框参数,具体为:3. The method for detecting a specific identification image in a predetermined area according to claim 2, wherein calculating the area range of the preview image comprises obtaining virtual frame parameters for framing the preview image based on actual size parameters of the predetermined area and resolution parameters of the preview image, specifically: 根据所述预定区域或包含该预定区域图像的实际尺寸,判断所述预览图像高度乘以所述预定区域或包含该预定区域图像的实际宽度的值是否大于预览图像宽度乘以所述预定区域或包含该预定区域图像实际高度的值;determining, based on the actual size of the predetermined area or the image containing the predetermined area, whether a value obtained by multiplying the height of the preview image by the actual width of the predetermined area or the image containing the predetermined area is greater than a value obtained by multiplying the width of the preview image by the actual height of the predetermined area or the image containing the predetermined area; 若是,则所述虚拟边框的宽度为:If so, the width of the virtual border is: ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio; 其中,CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;PreviewHeight为预览图像高度;CardHeightGdt为预定区域或包含该预定区域的图像实际高度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; PreviewHeight is the height of the preview image; CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image; 所述虚拟边框的高度为:The height of the virtual border is: ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio; 其中,PreviewHeight为预览图像高度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewHeight is the height of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image; 若否,则虚拟边框的宽度为:If not, the width of the virtual border is: ScaledWidth=PreviewWidth×DisplayRatio;ScaledWidth=PreviewWidth×DisplayRatio; 其中,PreviewWidth为预览图像宽度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewWidth is the width of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image; 所述虚拟边框的高度为:The height of the virtual border is: ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio; 其中,CardHeightGdt为预定区域或包含该预定区域图像的实际高度;PreviewWidth为预览图像宽度;CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; PreviewWidth is the width of the preview image; CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image; 所述虚拟边框上边界为显示屏幕高度与虚拟边框高度差的二分之一;所述虚拟边框下边界为显示屏幕高度与虚拟边框高度和的二分之一;所述虚拟边框的左边界为显示屏幕宽度与虚拟边框宽度差的二分之一;所述虚拟边框的右边界为显示屏幕宽度与虚拟边框宽度和的二分之一。The upper boundary of the virtual border is half of the difference between the display screen height and the virtual border height; the lower boundary of the virtual border is half of the sum of the display screen height and the virtual border height; the left boundary of the virtual border is half of the difference between the display screen width and the virtual border width; and the right boundary of the virtual border is half of the sum of the display screen width and the virtual border width. 4.根据权利要求1-3任意一项所述的用于检测预定区域中特定标识图像的方法,其特征在于,获取所述预定区域或包含该预定区域的图像,作为待检目标图像,包括:4. The method for detecting a specific identification image in a predetermined area according to any one of claims 1 to 3, wherein acquiring the predetermined area or an image containing the predetermined area as the target image to be detected comprises: 根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像。According to the specific position information of the specific identification image in the predetermined area or the predetermined area image, the area range including the specific identification image is intercepted as the target image to be inspected. 5.根据权利要求4所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述特定位置信息为事先设定的特定标识图像所位于预定区域或包含预定区域图像上的位置。5 . The method for detecting a specific identification image in a predetermined area according to claim 4 , wherein the specific position information is a pre-set position of the specific identification image in the predetermined area or in an image including the predetermined area. 6.根据权利要求5所述的用于检测预定区域中特定标识图像的方法,其特征在于:所述特定位置是位于所述预定区域或包含预定区域的图像的右上角或右下角或左上角或左下角。6. The method for detecting a specific identification image in a predetermined area according to claim 5, wherein the specific position is the upper right corner, lower right corner, upper left corner, or lower left corner of the predetermined area or the image containing the predetermined area. 7.根据权利要求4所述的用于检测预定区域中特定标识图像的方法,其特征在于,根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像,包括:7. The method for detecting a specific identification image in a predetermined area according to claim 4, wherein, based on specific position information of the specific identification image in the predetermined area or the predetermined area image, the region containing the specific identification image is intercepted as the target image to be detected, comprising: 建立预定区域或包含预定区域的标准图像模板;Establishing a predetermined area or a standard image template containing a predetermined area; 根据所述预定区域或包含预定区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述预定区域或包含预定区域的图像的对应关系,获取特定标识图像在预定区域或包含预定区域的图像中的位置信息;Traversing the standard image template according to the predetermined area or the image containing the predetermined area, and obtaining position information of the specific identification image in the predetermined area or the image containing the predetermined area through a correspondence between the standard image template and the predetermined area or the image containing the predetermined area; 根据该位置信息截取所述预定区域或包含预定区域的图像中包含特定标识的图像区域,作为待检目标图像。The predetermined area or the image area containing the specific mark in the image containing the predetermined area is intercepted according to the position information as the target image to be inspected. 8.根据权利要求1所述的用于检测预定区域中特定标识图像的方法,其特征在于:8. The method for detecting a specific identification image in a predetermined area according to claim 1, wherein: 所述阈值区间的上限值为所述获取的预定区域图像或包含预定区域图像的宽度、高度和上限系数的乘积;下限值为所述获取的预定区域图像或包含预定区域图像的宽度、高度和下限系数的乘积。The upper limit value of the threshold interval is the product of the width, height and upper limit coefficient of the acquired predetermined area image or the image containing the predetermined area; the lower limit value is the product of the width, height and lower limit coefficient of the acquired predetermined area image or the image containing the predetermined area. 9.根据权利要求1所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述图像特征包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比。9. The method for detecting a specific identification image in a predetermined area according to claim 1 is characterized in that the image features include the volume ratio of the connected domain, the major axis direction of the ellipse circumscribing the connected domain, the outer contour shape of the connected domain and/or the aspect ratio of the rectangle circumscribing the connected domain. 10.根据权利要求9所述的用于检测预定区域中特定标识图像的方法,其特征在于,逐一获取所述候选连通域区域的图像特征,并将该候选连通域区域的图像特征与所述特定标识图像的相应图像特征进行比对,将比对结果相同或最接近的候选连通域区域视为所述特定标识图像所在区域,包括:10. The method for detecting a specific identification image in a predetermined area according to claim 9, characterized in that the steps of acquiring image features of each candidate connected domain region one by one, comparing the image features of the candidate connected domain region with corresponding image features of the specific identification image, and considering the candidate connected domain region with the same or closest comparison results as the region where the specific identification image is located, comprise: 以所述连通域的体积比和连通域外接椭圆长轴方向作为组合图像特征对候选连通域区域进行筛选,具体是:The candidate connected domain regions are screened using the volume ratio of the connected domain and the major axis direction of the connected domain circumscribed ellipse as combined image features, specifically: 获取候选连通域区域的外接边框;Get the bounding box of the candidate connected region; 计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;Calculating a volume ratio of pixels of the foreground color in the candidate connected domain within the bounding box to the area of the bounding box; 判断该体积比是否大于预先设定的特定标识图像的阈值范围,若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;Determine whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, discard the candidate connected domain area; if so, fill the candidate connected domain area; 计算填充后的所述候选连通域区域外接椭圆长轴的方向,并获得该方向与设定的参考轴的夹角;Calculating the direction of the major axis of the ellipse circumscribed in the filled candidate connected region, and obtaining the angle between the major axis and the set reference axis; 判断该夹角是否在预定的阈值范围内,若是,则将该候选连通域区域视为所述特定标识图像所在区域;若否,则舍弃该候选连通域区域。It is determined whether the angle is within a predetermined threshold range. If so, the candidate connected domain area is regarded as the area where the specific identification image is located; if not, the candidate connected domain area is discarded. 11.根据权利要求10所述的用于检测预定区域中特定标识图像的方法,其特征在于,包括:判断所述方向与所述参考轴的夹角在预定的阈值范围内后,以所述连通域外轮廓形状作为单独条件对所述候选连通域区域再次进行筛选,具体为:11. The method for detecting a specific identification image in a predetermined area according to claim 10, further comprising: after determining that the angle between the direction and the reference axis is within a predetermined threshold range, further screening the candidate connected domain regions using the outer contour shape of the connected domain as a separate condition, specifically: 填充所述候选连通域区域,获得填充图像;Filling the candidate connected component area to obtain a filled image; 检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;Detecting the edge of the filled image to obtain an edge contour image of the filled image; 分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;Respectively obtaining sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image, and selecting the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range; 拟合所述选取的采样像素点,获得所述边缘轮廓图像的线段组合信息;Fitting the selected sampling pixel points to obtain line segment combination information of the edge contour image; 判断所述线段组合信息及交点位置信息与标准特定标识图像的线段组合信息及交点位置信息是否相同;若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。Determine whether the line segment combination information and intersection position information are the same as the line segment combination information and intersection position information of the standard specific identification image; if so, regard the candidate connected domain area as the specific identification image area; if not, output the undetected specific identification image area. 12.根据权利要求11所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点包括:12. The method for detecting a specific identification image in a predetermined area according to claim 11, wherein obtaining sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image comprises: 以与所述填充图像有两个交点为条件,进行扫描,将该些交点作为采样像素点;Scanning is performed on the condition that there are two intersection points with the filling image, and the intersection points are used as sampling pixel points; 所述选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点包括:The selecting of the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range includes: 判断获取的所述采样像素点的上下边缘之间的距离和左右边缘之间的距离是否在设定的阈值范围内,若是,则选取;若否,则舍弃。Determine whether the distances between the upper and lower edges and the distances between the left and right edges of the obtained sampling pixel points are within a set threshold range. If so, select them; if not, discard them. 13.根据权利要求12所述的用于检测预定区域中特定标识图像的方法,其特征在于,所述阈值范围为maxDist±maxDist×5%。13 . The method for detecting a specific identification image in a predetermined area according to claim 12 , wherein the threshold range is maxDist±maxDist×5%. 14.根据权利要求11所述的检测预定区域中特定标识图像的方法,其特征在于,包括:14. The method for detecting a specific identification image in a predetermined area according to claim 11, characterized by comprising: 根据预定区域或包含预定区域图像中特定标识的位置信息和各个交点位置信息,计算仿射变换矩阵;Calculating an affine transformation matrix based on the position information of a specific marker in a predetermined area or an image containing the predetermined area and the position information of each intersection point; 根据所述仿射变换矩阵获取所述预定区域内的相关信息。Relevant information within the predetermined area is acquired according to the affine transformation matrix. 15.根据权利要求1-3、5-14中任意一项所述的用于检测预定区域中特定标识图像方法,其特征在于:所述特定标识图像为银行卡联合组织或银行卡发卡组织的标志图形。15. The method for detecting a specific identification image in a predetermined area according to any one of claims 1-3 and 5-14, wherein the specific identification image is a logo graphic of a bank card association or a bank card issuing organization. 16.一种用于检测预定区域中特定标识图像的装置,其特征在于,包括:16. A device for detecting a specific identification image in a predetermined area, comprising: 获取单元,用于获取所述预定区域的图像,作为待检目标图像;an acquisition unit, configured to acquire an image of the predetermined area as an image of the target to be inspected; 二值化处理单元,用于对所述待检目标图像进行二值化处理,获得二值化图像,及所述二值化图像的取反图像,将所述二值化图像和所述取反图像均称为待检目标二值图像;a binarization processing unit, configured to perform binarization processing on the target image to be detected to obtain a binarized image and a negated image of the binarized image, wherein both the binarized image and the negated image are referred to as the target binary image to be detected; 连通域标定单元,用于标定所述待检目标二值图像的连通域,并将标定的连通域中像素个数满足设定阈值区间的连通域作为候选连通域;A connected domain calibration unit is used to calibrate the connected domain of the binary image of the target to be detected, and to select the connected domain whose number of pixels in the calibrated connected domain meets the set threshold range as a candidate connected domain; 图像特征比对单元,用于逐一获取所述候选连通域的图像特征,并将该候选连通域的图像特征与标准特定标识图像的相应图像特征采用单独图像特征比对或者组合图像特征比对,将比对结果相同或最接近的候选连通域视为特定标识图像所在位置。An image feature comparison unit is used to obtain the image features of the candidate connected domain one by one, and compare the image features of the candidate connected domain with the corresponding image features of the standard specific identification image using a single image feature comparison or a combined image feature comparison, and regard the candidate connected domain with the same or closest comparison results as the location of the specific identification image. 17.根据权利要求16所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述获取单元包括:17. The device for detecting a specific identification image in a predetermined area according to claim 16, wherein the acquiring unit comprises: 预览图像获取单元,用于获取所述预定区域或包含该预定区域的图像的预览图像;a preview image acquiring unit, configured to acquire a preview image of the predetermined area or an image containing the predetermined area; 计算单元,用于计算所述预览图像的区域范围;A calculation unit, configured to calculate the area range of the preview image; 框定单元,用于将所述预览图像框定在所述区域范围内,获取所述预定区域或包含预定区域的图像,将该框定的区域范围内的图像作为待检目标图像。The framing unit is used to frame the preview image within the area, obtain the predetermined area or an image containing the predetermined area, and use the image within the framed area as the target image to be inspected. 18.根据权利要求17所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述计算单元是指:根据所述预定区域的实际尺寸参数及预览图像的分辨率参数,获得框定所述预览图像的虚拟边框参数,具体为:18. The device for detecting a specific identification image in a predetermined area according to claim 17, wherein the calculating unit is configured to obtain virtual frame parameters for framing the preview image based on actual size parameters of the predetermined area and resolution parameters of the preview image, specifically: 根据所述预定区域或包含该预定区域图像的实际尺寸,判断所述预览图像高度乘以所述预定区域或包含该预定区域图像的实际宽度的值是否大于预览图像宽度乘以所述预定区域或包含该预定区域图像实际高度的值;determining, based on the actual size of the predetermined area or the image containing the predetermined area, whether a value obtained by multiplying the height of the preview image by the actual width of the predetermined area or the image containing the predetermined area is greater than a value obtained by multiplying the width of the preview image by the actual height of the predetermined area or the image containing the predetermined area; 若是,则所述虚拟边框的宽度为:If so, the width of the virtual border is: ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio;ScaledWidth=CardWidthGdt×PreviewHeight/CardHeightGdt×DisplayRatio; 其中,CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;PreviewHeight为预览图像高度;CardHeightGdt为预定区域或包含该预定区域的图像实际高度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; PreviewHeight is the height of the preview image; CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image; 所述虚拟边框的高度为:The height of the virtual border is: ScaledHeight=PreviewHeight×DisplayRatio;ScaledHeight=PreviewHeight×DisplayRatio; 其中,PreviewHeight为预览图像高度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewHeight is the height of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image; 若否,则虚拟边框的宽度为:ScaledWidth=PreviewWidth×DisplayRatio;If not, the width of the virtual border is: ScaledWidth = PreviewWidth × DisplayRatio; 其中,PreviewWidth为预览图像宽度,DisplayRatio为虚拟边框与预览图像的比值;Where PreviewWidth is the width of the preview image, and DisplayRatio is the ratio of the virtual border to the preview image; 虚拟边框的高度为:The height of the virtual border is: ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio;ScaledHeight=CardHeightGdt×PreviewWidth/CardWidthGdt×DisplayRatio; 其中,CardHeightGdt为预定区域或包含该预定区域图像的实际高度;PreviewWidth为预览图像宽度;CardWidthGdt为预定区域或包含该预定区域图像的实际宽度;DisplayRatio为虚拟边框与预览图像的比值;Wherein, CardHeightGdt is the actual height of the predetermined area or the image containing the predetermined area; PreviewWidth is the width of the preview image; CardWidthGdt is the actual width of the predetermined area or the image containing the predetermined area; DisplayRatio is the ratio of the virtual border to the preview image; 所述虚拟边框上边界为显示屏幕高度与虚拟边框高度差的二分之一;所述虚拟边框下边界为显示屏幕高度与虚拟边框高度和的二分之一;所述虚拟边框的左边界为显示屏幕宽度与虚拟边框宽度差的二分之一;所述虚拟边框的右边界为显示屏幕宽度与虚拟边框宽度和的二分之一。The upper boundary of the virtual border is half of the difference between the display screen height and the virtual border height; the lower boundary of the virtual border is half of the sum of the display screen height and the virtual border height; the left boundary of the virtual border is half of the difference between the display screen width and the virtual border width; and the right boundary of the virtual border is half of the sum of the display screen width and the virtual border width. 19.根据权利要求16-18任意一项所述的用于检测预定区域中特定标识图像的装置,其特征在于,获取单元包括:19. The device for detecting a specific identification image in a predetermined area according to any one of claims 16 to 18, wherein the acquiring unit comprises: 截取单元,用于根据特定标识图像在所述预定区域或预定区域图像中的特定位置信息,截取包含特定标识图像的区域范围,作为待检目标图像。The interception unit is used to intercept the area range containing the specific identification image as the target image to be inspected according to the specific position information of the specific identification image in the predetermined area or the predetermined area image. 20.根据权利要求19所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述特定位置信息为事先设定的特定标识图像所位于预定区域或包含预定区域图像上的位置。20. The device for detecting a specific identification image in a predetermined area according to claim 19, wherein the specific position information is a pre-set position of the specific identification image in the predetermined area or in an image including the predetermined area. 21.根据权利要求20所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述特定位置是位于所述预定区域或包含预定区域的图像的右上角或右下角或左上角或左下角。21. The device for detecting a specific identification image in a predetermined area according to claim 20, wherein the specific position is the upper right corner or lower right corner or the upper left corner or lower left corner of the predetermined area or the image containing the predetermined area. 22.根据权利要求19所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述截取单元包括:22. The device for detecting a specific identification image in a predetermined area according to claim 19, wherein the interception unit comprises: 建立单元,用于建立预定区域或包含预定区域的标准图像模板;An establishing unit, configured to establish a predetermined area or a standard image template containing the predetermined area; 遍历单元,用于根据所述预定区域或包含预定区域的图像遍历所述标准图像模板,通过所述标准图像模板与所述预定区域或包含预定区域的图像的对应关系,获取特定标识图像在预定区域或包含预定区域的图像中的位置信息;a traversal unit, configured to traverse the standard image template according to the predetermined area or the image containing the predetermined area, and obtain position information of the specific identification image in the predetermined area or the image containing the predetermined area through a correspondence between the standard image template and the predetermined area or the image containing the predetermined area; 待检目标图像确定单元,用于根据该位置信息截取所述预定区域或包含预定区域的图像中包含特定标识的图像区域,作为待检目标图像。The target image to be inspected determining unit is configured to intercept the predetermined area or an image area containing a specific mark in the image containing the predetermined area according to the position information as the target image to be inspected. 23.根据权利要求16所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述阈值区间的上限值为所述预定区域或包含预定区域的图像宽度、高度和上限系数的乘积;下限值为所述预定区域或包含预定区域的图像宽度、高度和下限系数的乘积。23. The device for detecting a specific identification image in a predetermined area according to claim 16 is characterized in that the upper limit value of the threshold range is the product of the width, height and upper limit coefficient of the predetermined area or the image containing the predetermined area; the lower limit value is the product of the width, height and lower limit coefficient of the predetermined area or the image containing the predetermined area. 24.根据权利要求16所述的用于检测预定区域中特定标识图像的装置,其特征在于:所述图像特征包括连通域的体积比、连通域外接椭圆长轴方向、连通域外轮廓形状和/或连通域外接矩形长宽比。24. The device for detecting a specific identification image in a predetermined area according to claim 16, wherein the image features include the volume ratio of the connected domain, the direction of the major axis of the ellipse circumscribed by the connected domain, the shape of the outer contour of the connected domain and/or the aspect ratio of the rectangle circumscribed by the connected domain. 25.根据权利要求24所述的用于检测预定区域中特定标识图像的装置,其特征在于,包括:组合图像特征筛选单元,具体是:25. The device for detecting a specific identification image in a predetermined area according to claim 24, characterized in that it comprises: a combined image feature screening unit, specifically: 外接边框获取单元,用于获取候选连通域区域的外接边框;An outer bounding box obtaining unit, used to obtain the outer bounding box of the candidate connected domain area; 体积比计算单元,用于计算所述外接边框内所述候选连通域中前景色的像素与该外接边框面积的体积比;a volume ratio calculation unit, configured to calculate a volume ratio of pixels of the foreground color in the candidate connected domain within the circumscribed frame to the area of the circumscribed frame; 体积比阈值判断单元,用于判断该体积比是否大于预先设定的特定标识图像的阈值范围;若否,则舍弃该候选连通域区域;若是,对所述候选连通域区域进行填充;A volume ratio threshold judgment unit is used to judge whether the volume ratio is greater than a preset threshold range of a specific identification image; if not, the candidate connected domain area is discarded; if so, the candidate connected domain area is filled; 填充计算单元,用于计算填充后的所述候选连通域区域外接椭圆长轴的方向,并获得该方向与设定的参考轴的夹角;A filling calculation unit, used to calculate the direction of the major axis of the ellipse circumscribed in the candidate connected region after filling, and obtain the angle between the direction and the set reference axis; 夹角阈值判断单元,用于判断该夹角是否在预定的阈值范围内,若是,则将该候选连通域区域视为所述特定标识图像所在区域;若否,则舍弃该候选连通域区域。The angle threshold judgment unit is used to judge whether the angle is within a predetermined threshold range. If so, the candidate connected domain area is regarded as the area where the specific identification image is located; if not, the candidate connected domain area is discarded. 26.根据权利要求25所述的用于检测预定区域中特定标识图像的装置,其特征在于,单独图像特征筛选单元,包括:26. The device for detecting a specific identification image in a predetermined area according to claim 25, wherein the individual image feature screening unit comprises: 填充单元,用于填充所述候选连通域区域,获得填充图像;A filling unit, configured to fill the candidate connected component region to obtain a filled image; 边缘轮廓获取单元,用于根据检测所述填充图像的边缘,获得所述填充图像的边缘轮廓图像;an edge contour acquiring unit, configured to acquire an edge contour image of the filled image by detecting the edge of the filled image; 采样单元,用于分别获取所述边缘轮廓图像的上下边缘和左右边缘的采样像素点,并选取在设定阈值范围内的所述上下边缘采样像素点和左右边缘采样像素点;a sampling unit, configured to respectively obtain sampling pixel points of the upper and lower edges and the left and right edges of the edge contour image, and select the upper and lower edge sampling pixel points and the left and right edge sampling pixel points within a set threshold range; 采样像素点拟合单元,用于拟合所述选取的采样像素点,获得所述边缘轮廓图像的线段组合信息;A sampling pixel point fitting unit, used for fitting the selected sampling pixel points to obtain line segment combination information of the edge contour image; 线段组合判断单元,用于判断所述线段组合信息及交点位置信息与标准特定标识图像的线段组合信息和交点位置信息是否相同;若是,则将候选连通域区域视为特定标识图像区域;若否,则输出未检测特定标识图像区域。The line segment combination judgment unit is used to judge whether the line segment combination information and intersection position information are the same as the line segment combination information and intersection position information of the standard specific identification image; if so, the candidate connected domain area is regarded as the specific identification image area; if not, the undetected specific identification image area is output. 27.根据权利要求26所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述采样单元包括:27. The device for detecting a specific identification image in a predetermined area according to claim 26, wherein the sampling unit comprises: 扫描单元,以与所述填充图像有两个交点为条件,进行扫描,将该些交点作为采样像素点;a scanning unit, performing scanning based on the condition that there are two intersection points with the filling image, and using the intersection points as sampling pixel points; 距离阈值判断单元,用于判断获取的所述采样像素点的上下边缘之间的距离和左右边缘之间的距离是否在设定的阈值范围内,若是,则选取;若否,则舍弃。The distance threshold judgment unit is used to judge whether the distance between the upper and lower edges and the distance between the left and right edges of the obtained sampling pixel points are within a set threshold range. If so, they are selected; if not, they are discarded. 28.根据权利要求27所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述阈值范围为maxDist±maxDist×5%。28. The device for detecting a specific identification image in a predetermined area according to claim 27, wherein the threshold range is maxDist±maxDist×5%. 29.根据权利要求26所述的用于检测预定区域中特定标识图像的装置,其特征在于,包括:29. The device for detecting a specific identification image in a predetermined area according to claim 26, characterized in that it comprises: 仿射变换单元,用于根据预定区域或包含预定区域图像中特定标识的位置信息和各个交点位置信息,计算仿射变换矩阵;An affine transformation unit, configured to calculate an affine transformation matrix based on position information of a specific marker in a predetermined area or an image containing the predetermined area and position information of each intersection point; 相关信息获取单元,用于根据所述仿射变换矩阵获取相关信息。The relevant information acquisition unit is used to acquire relevant information according to the affine transformation matrix. 30.根据权利要求16-18、20-29中任意一项所述的用于检测预定区域中特定标识图像的装置,其特征在于,所述特定标识图像为银行卡联合组织或银行卡发卡组织的标志图形。30. The device for detecting a specific identification image in a predetermined area according to any one of claims 16-18 and 20-29, wherein the specific identification image is a logo graphic of a bank card association or a bank card issuing organization.
HK16106568.1A 2016-06-08 Method and device for detecting specific identification image in predetermined area HK1218582B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410367807.9A CN105303189B (en) 2014-07-29 2014-07-29 It is a kind of for detecting the method and device of specific identifier image in presumptive area

Publications (2)

Publication Number Publication Date
HK1218582A1 HK1218582A1 (en) 2017-02-24
HK1218582B true HK1218582B (en) 2020-09-04

Family

ID=

Similar Documents

Publication Publication Date Title
TWI655586B (en) Method and device for detecting specific identification image in predetermined area
CN111612781B (en) A screen defect detection method, device and head-mounted display device
Toh et al. Automated fish counting using image processing
US10586321B2 (en) Automatic detection, counting, and measurement of lumber boards using a handheld device
EP1091320A2 (en) Processing multiple digital images
US8811751B1 (en) Method and system for correcting projective distortions with elimination steps on multiple levels
US8897600B1 (en) Method and system for determining vanishing point candidates for projective correction
CN115908269A (en) Visual defect detection method and device, storage medium and computer equipment
CN110136069B (en) Text image correction method and device and electronic equipment
CN109948521B (en) Image deviation rectifying method and device, equipment and storage medium
US9785850B2 (en) Real time object measurement
EP1081648B1 (en) Method for processing a digital image
WO2021195873A1 (en) Method and device for identifying region of interest in sfr test chart image, and medium
US8913836B1 (en) Method and system for correcting projective distortions using eigenpoints
CN113569859B (en) Image processing method and device, electronic equipment and storage medium
US20200193561A1 (en) Automatic Detection, Counting, and Measurement of Lumber Boards Using a Handheld Device
CN117152088B (en) Method, device, equipment and storage medium for detecting seal of medicine package
CN110263778A (en) A kind of meter register method and device based on image recognition
CN105678737A (en) Digital image corner point detection method based on Radon transform
CN112733829B (en) Feature block identification method, electronic equipment and computer readable storage medium
CN112052859B (en) License plate accurate positioning method and device in free scene
US20170352170A1 (en) Nearsighted camera object detection
HK1218582B (en) Method and device for detecting specific identification image in predetermined area
CN120404730A (en) Foreign body detection method, device, equipment and storage medium
CN120198927A (en) Method, device, equipment and storage medium for identifying marker information