HK1249245B - Qr code positioning method and device - Google Patents
Qr code positioning method and device Download PDFInfo
- Publication number
- HK1249245B HK1249245B HK18108715.7A HK18108715A HK1249245B HK 1249245 B HK1249245 B HK 1249245B HK 18108715 A HK18108715 A HK 18108715A HK 1249245 B HK1249245 B HK 1249245B
- Authority
- HK
- Hong Kong
- Prior art keywords
- type pixels
- pixel
- location detection
- pixels
- suspected location
- Prior art date
Links
Description
技术领域Technical Field
本申请涉及图像处理领域,尤其涉及一种二维码定位方法及装置。The present application relates to the field of image processing, and in particular to a two-dimensional code positioning method and device.
背景技术Background Art
二维码又称为二维条形码,它通过某种特定的几何图形按一定规律在平面(二维方向)上分布形成的图形记录数据符号信息。与传统的条码比较,二维码具有信息容量高、纠错能力强、译码可靠性高等特点,同时,还具有成本低、易制作等优势。因此,二维码已经在多个领域内得到了广泛应用,例如,支付领域、身份认证领域等。A QR code, also known as a two-dimensional barcode, records data and symbolic information using a pattern of geometric shapes distributed in a two-dimensional plane. Compared to traditional barcodes, QR codes offer high information capacity, strong error correction capabilities, and high decoding reliability. They also offer advantages such as low cost and ease of production. Consequently, QR codes have found widespread application in various fields, such as payment and identity authentication.
在使用二维码时,扫描二维码后,需要对二维码进行识别,以获取存储在二维码内的数据符号信息。当扫描到二维码图形后,通过对二维码进行定位、解码,来识别该二维码。相关技术中,是先识别出二维码图像中的位置探测图形,再通过位置探测图形来对二维码进行定位。When using a QR code, after scanning it, it needs to be identified to obtain the data symbol information stored within it. After scanning the QR code image, the QR code is identified by locating and decoding it. In related technologies, a position detection pattern in the QR code image is first identified, and then the QR code is located using the position detection pattern.
在二维码的日常使用中,在某些环境下经常会出现识别性差的问题,比如当二维码的位置探测图形出现少量污损或者亮度较弱时,经常无法准确识别出二维码的位置探测图形,导致无法对二维码进行定位,从而使二维码识别失败。因此,业内亟需一种在不同环境下均具有较高准确性和有效性的二维码定位的方法。In the daily use of QR codes, poor recognition often occurs in certain environments. For example, when the QR code's position detection pattern is slightly damaged or the brightness is low, the QR code's position detection pattern is often not accurately recognized, resulting in the inability to locate the QR code and thus failing to recognize the QR code. Therefore, the industry urgently needs a QR code positioning method that is highly accurate and effective in various environments.
发明内容Summary of the Invention
本申请实施例的目的是提供一种二维码定位方法及装置,二维码定位的准确性和有效性较高,进而提高了二维码的识别效率。The purpose of the embodiments of the present application is to provide a method and device for locating a two-dimensional code, which has high accuracy and effectiveness in locating the two-dimensional code, thereby improving the recognition efficiency of the two-dimensional code.
为解决上述技术问题,本申请实施例是这样实现的:To solve the above technical problems, the embodiments of the present application are implemented as follows:
本申请实施例提供了一种二维码定位方法,包括:The present invention provides a method for locating a QR code, including:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,所述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a second preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位方法,包括:The present application also provides a method for locating a QR code, including:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:连续排布的所述第一类像素或所述第二类像素的个数达到第一预设阈值,所述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;In a two-dimensional code image containing first-class pixels and second-class pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a first preset threshold, and the column pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a second preset threshold;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位方法,包括:The present application also provides a method for locating a QR code, including:
在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, determining the center position of a suspected position detection pattern in the two-dimensional code image using a preset pixel detection rule; wherein the pixel detection rule includes that a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位装置,包括:The present application also provides a two-dimensional code positioning device, including:
位置确定模块,用于在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,所述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;A position determination module is configured to determine, in a two-dimensional code image containing first-category pixels and second-category pixels, a center position of a suspected position detection pattern in the two-dimensional code image using a preset row pixel detection rule and a preset column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a second preset ratio;
识别模块,用于根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;an identification module, configured to identify a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
图形确定模块,用于从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。The pattern determination module is used to determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位装置,包括:The present application also provides a two-dimensional code positioning device, including:
位置确定模块,用于在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:连续排布的所述第一类像素或所述第二类像素的个数达到第一预设阈值,所述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;A position determination module is configured to determine, in a two-dimensional code image containing pixels of the first and second categories, a center position of a suspected position detection pattern in the two-dimensional code image using a preset row pixel detection rule and a preset column pixel detection rule; wherein the row pixel detection rule includes: the number of consecutively arranged pixels of the first or second category reaches a first preset threshold; and the column pixel detection rule includes: the number of consecutively arranged pixels of the first or second category reaches a second preset threshold.
识别模块,用于根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;an identification module, configured to identify a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
图形确定模块,用于从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。The pattern determination module is used to determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位装置,包括:The present application also provides a two-dimensional code positioning device, including:
位置确定模块,用于在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;a position determination module for determining, in a two-dimensional code image containing first-category pixels and second-category pixels, a center position of a suspected position detection pattern in the two-dimensional code image using a preset pixel detection rule; wherein the pixel detection rule includes that a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio;
识别模块,用于根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;an identification module, configured to identify a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
图形确定模块,用于从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。The pattern determination module is used to determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位设备,包括:The present application also provides a two-dimensional code positioning device, including:
处理器;以及processor; and
被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器:a memory arranged to store computer-executable instructions which, when executed, cause the processor to:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,所述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a second preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位设备,包括:The present application also provides a two-dimensional code positioning device, including:
处理器;以及processor; and
被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器:a memory arranged to store computer-executable instructions which, when executed, cause the processor to:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:连续排布的所述第一类像素或所述第二类像素的个数达到第一预设阈值,所述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;In a two-dimensional code image containing first-class pixels and second-class pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a first preset threshold, and the column pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a second preset threshold;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种二维码定位设备,包括:The present application also provides a two-dimensional code positioning device, including:
处理器;以及processor; and
被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器:a memory arranged to store computer-executable instructions which, when executed, cause the processor to:
在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, determining the center position of a suspected position detection pattern in the two-dimensional code image using a preset pixel detection rule; wherein the pixel detection rule includes that a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,其特征在于,所述可执行指令在被执行时实现以下流程:The present application also provides a storage medium for storing computer-executable instructions, wherein the computer-executable instructions implement the following process when executed:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,所述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a second preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,其特征在于,所述可执行指令在被执行时实现以下流程:The present application also provides a storage medium for storing computer-executable instructions, wherein the computer-executable instructions implement the following process when executed:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述行像素探测规则包括:连续排布的所述第一类像素或所述第二类像素的个数达到第一预设阈值,所述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;In a two-dimensional code image containing first-class pixels and second-class pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a first preset threshold, and the column pixel detection rule includes: the number of consecutively arranged first-class pixels or second-class pixels reaches a second preset threshold;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,其特征在于,所述可执行指令在被执行时实现以下流程:The present application also provides a storage medium for storing computer-executable instructions, wherein the computer-executable instructions implement the following process when executed:
在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定所述二维码图像中的疑似位置探测图形的中心位置;其中,所述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;In a two-dimensional code image containing first-category pixels and second-category pixels, determining the center position of a suspected position detection pattern in the two-dimensional code image using a preset pixel detection rule; wherein the pixel detection rule includes that a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio;
根据确定的所述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的所述疑似位置探测图形中,确定符合所述二维码图像的定位规则的图形,作为所述二维码图像的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
本申请实施例中的二维码定位方法及装置,根据第一类像素、第二类像素、第一类像素的排布比例或者连续排布的第一类像素的个数或者连续排布的第二类像素的个数确定二维码图像中的疑似位置探测图形的中心位置,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。The QR code positioning method and device in the embodiments of the present application determine the center position of the suspected position detection pattern in the QR code image based on the first-category pixels, the second-category pixels, the arrangement ratio of the first-category pixels, or the number of continuously arranged first-category pixels or the number of continuously arranged second-category pixels, and have a certain degree of fault tolerance. In this way, even if the position detection pattern of the QR code is damaged or has low brightness, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified in the above manner, the position detection pattern of the QR code is determined from the identified suspected position detection pattern, with high accuracy.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1为本申请实施例提供的二维码定位方法的第一种流程示意图;FIG1 is a schematic diagram of a first flow chart of a QR code positioning method provided in an embodiment of the present application;
图2为本申请实施例提供的二维码的位置探测图形的示意图;FIG2 is a schematic diagram of a position detection pattern of a QR code provided in an embodiment of the present application;
图3为本申请实施例提供的在二维码上建立的坐标系的示意图;FIG3 is a schematic diagram of a coordinate system established on a QR code according to an embodiment of the present application;
图4为本申请实施例提供的在二维码的位置探测图形上确定的第一像素排布和第二像素排布的示意图;FIG4 is a schematic diagram of a first pixel arrangement and a second pixel arrangement determined on a position detection pattern of a two-dimensional code according to an embodiment of the present application;
图5为本申请实施例提供的二维码定位方法的第二种流程示意图;FIG5 is a schematic diagram of a second flow chart of a QR code positioning method provided in an embodiment of the present application;
图6为本申请实施例提供的二维码定位方法的第三种流程示意图;FIG6 is a schematic diagram of a third flow chart of the QR code positioning method provided in an embodiment of the present application;
图7为本申请实施例提供的二维码定位方法的第四种流程示意图;FIG7 is a schematic diagram of a fourth flow chart of the QR code positioning method provided in an embodiment of the present application;
图8为本申请实施例提供的二维码定位方法的第五种流程示意图;FIG8 is a schematic diagram of a fifth flow chart of the QR code positioning method provided in an embodiment of the present application;
图9为本申请实施例提供的二维码定位装置的模块组成示意图;FIG9 is a schematic diagram of the module composition of a QR code positioning device provided in an embodiment of the present application;
图10为本申请实施例提供的二维码定位设备的结构示意图。FIG10 is a schematic diagram of the structure of a QR code positioning device provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
本申请实施例提供了一种二维码定位方法及装置,该方法可以应用在通过二维码进行支付或身份认证等场景中。该二维码可以是任何应用程序所使用的二维码,比如,支付宝或者微信等应用程序。The present invention provides a method and apparatus for locating a QR code, which can be applied to scenarios such as payment or identity authentication using a QR code. The QR code can be a QR code used by any application, such as Alipay or WeChat.
一般,在应用二维码时,需要对二维码进行识别,以获取二维码内存储的信息,在对二维码进行识别时至少包括二维码定位和二维码解码这两个步骤,即二维码定位是二维码识别的其中一个步骤。Generally, when using a QR code, it is necessary to identify the QR code to obtain the information stored in the QR code. When identifying a QR code, it includes at least two steps: QR code positioning and QR code decoding. That is, QR code positioning is one of the steps in QR code recognition.
本申请实施例提供的方法的执行主体可以是终端,比如说,手机、计算机、平板电脑或者二维码扫描设备等。在该种情况下,当终端获取到二维码图像后,则由终端直接在获取到的二维码图像上执行本申请实施例提供的方法。当然,本申请实施例提供的方法的执行主体还可以是服务器,在该种情况下,则是先通过终端扫描获取二维码图像,之后由服务器从终端处获取该二维码图像,再由服务器在获取到的二维码图像上执行本申请实施例提供的方法。The execution subject of the method provided in the embodiment of the present application can be a terminal, for example, a mobile phone, a computer, a tablet computer or a QR code scanning device. In this case, after the terminal obtains the QR code image, the terminal directly executes the method provided in the embodiment of the present application on the obtained QR code image. Of course, the execution subject of the method provided in the embodiment of the present application can also be a server. In this case, the QR code image is first obtained by scanning the terminal, and then the server obtains the QR code image from the terminal, and then the server executes the method provided in the embodiment of the present application on the obtained QR code image.
图1为本申请实施例提供的二维码定位方法的第一种流程示意图,如图1所示,该方法至少包括以下步骤:FIG1 is a schematic diagram of a first flow chart of a QR code positioning method provided in an embodiment of the present application. As shown in FIG1 , the method includes at least the following steps:
步骤S102,在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定该二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,上述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例。Step S102: In a two-dimensional code image containing first-category pixels and second-category pixels, the center position of a suspected position detection pattern in the two-dimensional code image is determined using preset row pixel detection rules and column pixel detection rules; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a second preset ratio.
其中,上述第一类像素和第二类像素为颜色不同的像素,比如,当上述二维码为黑白二维码时,可以是,上述第一类像素为黑色像素,上述第二类像素为白色像素。当上述二维码为蓝白二维码时,可以是,上述第一类像素为蓝色像素,第二类像素为白色像素。The first type of pixels and the second type of pixels are pixels of different colors. For example, when the QR code is a black and white QR code, the first type of pixels may be black pixels and the second type of pixels may be white pixels. When the QR code is a blue and white QR code, the first type of pixels may be blue pixels and the second type of pixels may be white pixels.
另外,在一种具体实施方式中,为了方便后续处理,在获取到原始的二维码图像后,对原始的二维码图像进行二值化处理,得到该二维码图像的二值化图像。在该种情况下,二维码图像上的像素只有黑色和白色两种颜色,因此,可以是第一类像素为黑色像素,第二类像素为白色像素。In addition, in one specific embodiment, to facilitate subsequent processing, after obtaining the original QR code image, the original QR code image is binarized to obtain a binary image of the QR code image. In this case, the pixels on the QR code image have only two colors: black and white. Therefore, the first type of pixels can be black pixels, and the second type of pixels can be white pixels.
一般的,在每个二维码中均设置有三个位置探测图形,且三个位置探测图形分别位于二维码的四个角中的任意三个角上。位置探测图形一般为矩形图形,可以是四边均相等的正方形,也可以是长方形。每个位置探测图形可以看作是由三个中心重叠的同心矩形组成。图2示出了本申请实施例中一种可能的二维码的位置探测图形的示意图,图2中的位置探测图形由三个中心重叠的同心正方形组成,这三个正方形分别为7*7个黑色模块、5*5个白色模块、3*3个黑色模块,即第一类像素为黑色像素、第二类像素为白色像素,该位置探测图形的模块宽度比为1:1:3:1:1。在图2中,将位置探测图形的最外面的黑色矩形区域记为第一区域,位置探测图形的中间的黑色矩形区域记为第三区域,第一区域和第二区域中间的白色区域记为第二区域。Generally, three position detection graphics are provided in each QR code, and the three position detection graphics are respectively located at any three corners of the four corners of the QR code. The position detection graphic is generally a rectangular graphic, which can be a square with equal sides or a rectangle. Each position detection graphic can be regarded as consisting of three concentric rectangles with overlapping centers. Figure 2 shows a schematic diagram of a possible position detection graphic of a QR code in an embodiment of the present application. The position detection graphic in Figure 2 is composed of three concentric squares with overlapping centers. These three squares are 7*7 black modules, 5*5 white modules, and 3*3 black modules, that is, the first type of pixels are black pixels and the second type of pixels are white pixels. The module width ratio of the position detection graphic is 1:1:3:1:1. In Figure 2, the outermost black rectangular area of the position detection graphic is recorded as the first area, the middle black rectangular area of the position detection graphic is recorded as the third area, and the white area between the first area and the second area is recorded as the second area.
其中,上述第一预设比例为1:n:1,且n大于1;上述第二预设比例为1:m:1,且m大于1;其中,m和n的取值可以相同,也可以不同,m和n的具体取值可以根据实际应用场景确定,比如说,针对现有的1:1:3:1:1模式的位置探测图形,上述m和n的取值均可以为5,即第一预设比例可以是1:5:1,第二预设比例可以是1:5:1。Among them, the above-mentioned first preset ratio is 1:n:1, and n is greater than 1; the above-mentioned second preset ratio is 1:m:1, and m is greater than 1; among them, the values of m and n can be the same or different, and the specific values of m and n can be determined according to the actual application scenario. For example, for the existing 1:1:3:1:1 mode position detection pattern, the above-mentioned m and n values can both be 5, that is, the first preset ratio can be 1:5:1, and the second preset ratio can be 1:5:1.
在本申请实施例中,确定二维码图像中的疑似位置探测图形的中心位置,包括以下步骤(a1)和(a2):In an embodiment of the present application, determining the center position of a suspected position detection pattern in a two-dimensional code image includes the following steps (a 1 ) and (a 2 ):
(a1)确定行像素中的第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例的第一像素排布;及确定列像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例的第二像素排布;( a1 ) determining a first pixel arrangement in which a first type of pixel, a second type of pixel, and a first type of pixel are sequentially arranged in a row of pixels at a ratio that satisfies a first predetermined ratio; and determining a second pixel arrangement in which a first type of pixel, a second type of pixel, and a first type of pixel are sequentially arranged in a column of pixels at a ratio that satisfies a second predetermined ratio;
(a2)根据所述第一像素排布的中心点及第二像素排布的中心点,确定疑似位置探测图形的中心位置。( a2 ) Determining a center position of a suspected position detection pattern based on the center point of the first pixel arrangement and the center point of the second pixel arrangement.
其中,上述第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例指的是第一类像素:第二类像素:第一类像素=1:n:1;上述第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例指的是第一类像素:第二类像素:第一类像素=1:m:1。具体的,此处像素的排布比例可以是像素个数的排布比例。Wherein, the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels satisfying the first preset ratio refers to the first type of pixels: the second type of pixels: the first type of pixels = 1:n:1; and the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels satisfying the second preset ratio refers to the first type of pixels: the second type of pixels: the first type of pixels = 1:m:1. Specifically, the pixel arrangement ratio here may be the arrangement ratio of the number of pixels.
在本申请实施例中,满足第一预设比例的第一像素排布为只穿过图2中的第一区域和第二区域的行像素,满足第二预设比例的第二像素排布为只穿过图2中的第一区域和第二区域的列像素。In the embodiment of the present application, the first pixel arrangement that meets the first preset ratio is row pixels that only pass through the first area and the second area in Figure 2, and the second pixel arrangement that meets the second preset ratio is column pixels that only pass through the first area and the second area in Figure 2.
在实际应用时,由于扫描到的二维码图形可能存在变形、残缺或污损等问题,从而导致二维码图像中的位置探测图形中的第一像素排布中的第一类像素、第二类像素、第一类像素的顺序排布比例无法严格满足第一预设比例,第二像素排布中的第一类像素、第二类像素、第一类像素的顺序排布比例无法严格满足第二预设比例,因此,在上述步骤(a1)中,只要第一类像素、第二类像素、第一类像素的顺序排布比例在第一预设比例或者第二预设比例的误差范围内,则可以认为第一类像素、第二类像素、第一类像素的顺序排布满足第一预设比例或者第二预设比例。In actual application, since the scanned QR code graphic may be deformed, incomplete or damaged, the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the first pixel arrangement in the position detection graphic in the QR code image cannot strictly meet the first preset ratio, and the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the second pixel arrangement cannot strictly meet the second preset ratio. Therefore, in the above step ( a1 ), as long as the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels is within the error range of the first preset ratio or the second preset ratio, it can be considered that the sequential arrangement of the first type of pixels, the second type of pixels, and the first type of pixels meets the first preset ratio or the second preset ratio.
在上述步骤(a2)中,可以根据第一像素排布的中心点及第二像素排布的中心点,确定出疑似位置探测图形的中心位置坐标,进而确定出疑似位置探测图形的中心位置。In the above step (a 2 ), the center position coordinates of the suspected position detection pattern may be determined based on the center point of the first pixel arrangement and the center point of the second pixel arrangement, thereby determining the center position of the suspected position detection pattern.
在一种具体实施方式中,以二维码的左上角作为坐标原点O,以过坐标原点的水平线作为横轴(X轴),以过坐标原点的竖直线作为纵轴(Y轴),建立OXY坐标系,如图3所示。具体的,疑似位置探测图形的中心位置坐标至少可以通过(b1)、(b1)和(b3)三种方式实现:In a specific embodiment, an OXY coordinate system is established with the upper left corner of the QR code as the coordinate origin O, a horizontal line passing through the coordinate origin as the horizontal axis (X axis), and a vertical line passing through the coordinate origin as the vertical axis (Y axis), as shown in FIG3 . Specifically, the center position coordinates of the suspected position detection pattern can be achieved in at least three ways: (b 1 ), (b 1 ), and (b 3 ):
(b1)在二维码图像上沿着X方向画一条扫描线,使用该扫描线沿着Y方向对二维码图像进行扫描,在第一预设位置处确定一个第一像素排布,之后在二维码图像上沿着Y方向画一条扫描线,使用该扫描线沿着X方向对二维码图像进行扫描,在每个疑似位置探测图形上的第二预设位置处和第三预设位置处分别确定一个第二像素排布,将第一预设位置处的第一像素排布记为P1,将第二预设位置处的第二像素排布记为P2,将第三预设位置处的第二像素排布记为P3,如图4所示,将第二像素排布P2距离该疑似位置探测图形的左边缘的距离记为第一距离,将第二像素排布P3距离该疑似位置探测图形的右边缘的距离记为第二距离,在一种具体实施方式中,为了便于计算,使得第二像素排布P2和第二像素排布P3的位置刚好满足第一距离和第二距离相等,计算第二像素排布P2和第二像素排布P3在水平方向上的位置的平均值,该平均值则是第一像素排布P1的中心点,将该中心点记为疑似位置探测图形的中心位置的横坐标;( b1 ) Draw a scan line along the X direction on the two-dimensional code image, use the scan line to scan the two-dimensional code image along the Y direction, determine a first pixel arrangement at the first preset position, then draw a scan line along the Y direction on the two-dimensional code image, use the scan line to scan the two-dimensional code image along the X direction, and determine a second pixel arrangement at the second preset position and the third preset position on each suspected position detection pattern, respectively. The first pixel arrangement at the first preset position is recorded as P1 , the second pixel arrangement at the second preset position is recorded as P2 , and the second pixel arrangement at the third preset position is recorded as P3 . As shown in Figure 4, the distance between the second pixel arrangement P2 and the left edge of the suspected position detection pattern is recorded as the first distance, and the distance between the second pixel arrangement P3 and the right edge of the suspected position detection pattern is recorded as the second distance. In a specific embodiment, for the convenience of calculation, the positions of the second pixel arrangement P2 and the second pixel arrangement P3 just satisfy the equality of the first distance and the second distance. The second pixel arrangement P2 and the second pixel arrangement P3 are calculated. 3 in the horizontal direction, the average value is the center point of the first pixel arrangement P1 , and the center point is recorded as the abscissa of the center position of the suspected position detection pattern;
另外,在本申请实施例中,二维码上的位置探测图形被平均划分为多个矩形模块,该矩形模块可以是正方形模块,也可以是长方形模块,该矩形模块的长宽比例可以根据实际应用场景进行设置。In addition, in an embodiment of the present application, the position detection pattern on the QR code is evenly divided into multiple rectangular modules, which can be square modules or rectangular modules. The length-to-width ratio of the rectangular modules can be set according to the actual application scenario.
通过计算疑似位置探测图形的宽度与该方向上的矩形模块的个数的比值,可以计算出每个矩形模块的宽度。之后,根据第一像素排布P1在竖直方向上的位置,以及第一像素排布P1在竖直方向上距离中心位置的矩形模块的个数,确定出第二像素排布的中心点,该第二像素排布的中心点则是疑似位置探测图形的中心位置的纵坐标。The width of each rectangular module can be calculated by calculating the ratio of the width of the suspected position detection pattern to the number of rectangular modules in that direction. The center point of the second pixel arrangement is then determined based on the vertical position of the first pixel arrangement P1 and the number of rectangular modules vertically spaced from the center position of the first pixel arrangement P1 . This center point serves as the vertical coordinate of the center position of the suspected position detection pattern.
其中,上述第一预设位置可以是使得第一像素排布满足第一预设比例的任意位置,第二预设位置和第三预设位置也为使第二像素排布满足第二预设比例的任意位置。优选的,为了便于计算,上述第一预设位置、第二预设位置和第三预设位置均可以设置在整个矩形模块处。The first preset position can be any position where the first pixel arrangement satisfies the first preset ratio, and the second and third preset positions can also be any positions where the second pixel arrangement satisfies the second preset ratio. Preferably, for ease of calculation, the first, second, and third preset positions can all be set throughout the entire rectangular module.
(b2)在该种情况下,疑似位置探测图形的中心位置的横坐标的确定方法与上述(b1)中横坐标的确定方法相同,此处不再赘述。(b 2 ) In this case, the method for determining the abscissa of the center position of the suspected position detection pattern is the same as the method for determining the abscissa in (b 1 ) above, and will not be repeated here.
另外,在该种情况下,采用与确定横坐标的方法相同的方法确定疑似位置探测图形的中心位置的纵坐标。具体过程则为:在二维码图像上沿着X方向画一条扫描线,使用该扫描线沿着Y方向对二维码图像进行扫描,在第一预设位置处确定第一像素分布P1,在第四预设位置处确定第一像素排布p4。根据第一像素排布p1和第一像素排布p4确定疑似位置探测图形的中心位置的纵坐标,具体过程和上述横坐标的确定过程相似,此处不再赘述。In this case, the ordinate of the center position of the suspected position detection pattern is determined using the same method as that used to determine the abscissa. The specific process is as follows: a scan line is drawn along the X direction on the QR code image, and the QR code image is scanned along the Y direction using this scan line. A first pixel arrangement P1 is determined at a first preset position, and a first pixel arrangement P4 is determined at a fourth preset position. The ordinate of the center position of the suspected position detection pattern is determined based on the first pixel arrangement P1 and the first pixel arrangement P4 . The specific process is similar to the process for determining the abscissa, and will not be repeated here.
(b3)在二维码图像上沿着X方向画一条扫描线,使用该扫描线沿着Y方向对二维码图像进行扫描,在第一预设位置处确定第一像素排布p1,在二维码图像上沿着Y方向画一条扫描线,使用该扫描线沿着X方向对二维码图像进行扫描,在第二预设位置处确定第二像素排布p2,根据第一像素排布P1的第一个像素与最后一个像素之间的距离,确定第一像素排布P1的中心点,采用同样的方法确定出第二像素排布p2的中心点,根据第一像素排布p1的中心点确定疑似位置探测图形的中心位置的横坐标,根据第二像素排布p2的中心点确定疑似位置探测图形的中心位置的纵坐标。( b3 ) Draw a scan line along the X direction on the two-dimensional code image, use the scan line to scan the two-dimensional code image along the Y direction, determine a first pixel arrangement p1 at a first preset position, draw a scan line along the Y direction on the two-dimensional code image, use the scan line to scan the two-dimensional code image along the X direction, determine a second pixel arrangement p2 at a second preset position, determine the center point of the first pixel arrangement P1 based on the distance between the first pixel and the last pixel of the first pixel arrangement P1 , and use the same method to determine the center point of the second pixel arrangement p2. Determine the abscissa of the center position of the suspected position detection pattern based on the center point of the first pixel arrangement p1 , and determine the ordinate of the center position of the suspected position detection pattern based on the center point of the second pixel arrangement p2 .
其中,在本申请实施例中,第一像素排布为疑似位置探测图形的其中一行像素,第二像素排布为疑似位置探测图形的其中一列像素。In the embodiment of the present application, the first pixels are arranged as a row of pixels of the suspected position detection pattern, and the second pixels are arranged as a column of pixels of the suspected position detection pattern.
在本申请实施例中,仅通过第一类像素、第二类像素、第一类像素的顺序排布比例,确定二维码图像中的疑似位置探测图形的中心位置,提高了二维码的识别的有效性。In the embodiment of the present application, the center position of the suspected position detection pattern in the QR code image is determined only by the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels, thereby improving the effectiveness of QR code recognition.
步骤S104,根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形。Step S104 : identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern.
在本申请实施例中,在确定出疑似位置探测图形的中心位置后,则将该中心位置所在的图形确定为该二维码的疑似位置探测图形。In the embodiment of the present application, after the center position of the suspected position detection pattern is determined, the pattern at the center position is determined as the suspected position detection pattern of the QR code.
步骤S106,从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,作为二维码图像的位置探测图形。Step S106 : Determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, and use it as the position detection pattern of the two-dimensional code image.
在本申请实施例中,通过上述步骤S102和步骤S104可以识别出二维码图像中的疑似位置探测图形,但是,仅仅通过上述两个步骤识别出的疑似位置探测图形中可能存在其它图形,因此,为了提高位置探测图形识别的准确性,需要对识别出的疑似位置探测图形进行进一步筛选,并从筛选后的疑似位置探测图形中,确定出符合二维码图像的定位规则的图形,具体是通过如下步骤(1)和(2)实现的:In the embodiment of the present application, the suspected position detection pattern in the two-dimensional code image can be identified through the above steps S102 and S104. However, other patterns may exist in the suspected position detection pattern identified by the above two steps alone. Therefore, in order to improve the accuracy of position detection pattern recognition, it is necessary to further screen the identified suspected position detection patterns and determine the patterns that meet the positioning rules of the two-dimensional code image from the screened suspected position detection patterns. This is specifically achieved through the following steps (1) and (2):
(1)从识别出的疑似位置探测图形中,确定符合第一筛选条件和/或第二筛选条件的疑似位置探测图形;其中,上述第一筛选条件包括在中心位置相邻的预设区域内,第一类像素和/或第二类像素的个数符合预设的阈值范围;上述第二筛选条件包括穿过中心位置的第三像素排布中的第一类像素、第二类像素、第一类像素、第二类像素、第一类像素的顺序排布比例满足第三预设比例;(1) determining, from the identified suspected position detection patterns, suspected position detection patterns that meet a first screening condition and/or a second screening condition; wherein the first screening condition includes that the number of first-category pixels and/or second-category pixels within a preset area adjacent to a central position meets a preset threshold range; and the second screening condition includes that a sequential arrangement ratio of the first-category pixels, the second-category pixels, the first-category pixels, the second-category pixels, and the first-category pixels in a third pixel arrangement passing through the central position meets a third preset ratio;
(2)从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。(2) Determine a pattern that meets the positioning rule of the QR code from the suspected position detection patterns that meet the first screening condition and/or the second screening condition.
具体的,上述从识别出的疑似位置探测图形中,确定符合二维码图形的定位规则的图形包括如下三种情况:Specifically, the above-mentioned patterns that meet the positioning rules of the QR code pattern from the identified suspected position detection patterns include the following three situations:
第一种情况,In the first case,
从识别出的疑似位置探测图形中,确定符合第一筛选条件的疑似位置探测图形;从符合第一筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形;Determine, from the identified suspected position detection patterns, suspected position detection patterns that meet the first screening condition; determine, from the suspected position detection patterns that meet the first screening condition, patterns that meet the positioning rules of the QR code;
第二种情况,The second case,
从识别出的疑似位置探测图形中,确定符合第二筛选条件的疑似位置探测图形;从符合第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形;Determine, from the identified suspected position detection patterns, suspected position detection patterns that meet the second screening condition; determine, from the suspected position detection patterns that meet the second screening condition, patterns that meet the positioning rules of the QR code;
第三种情况,The third case,
从识别出的疑似位置探测图形中,确定符合第一筛选条件和第二筛选条件的疑似位置探测图形;从符合第一筛选条件和第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。From the identified suspected position detection patterns, the suspected position detection patterns that meet the first screening condition and the second screening condition are determined; from the suspected position detection patterns that meet the first screening condition and the second screening condition, the patterns that meet the positioning rules of the QR code are determined.
在上述第三种情况中,一种具体的实施方式可以是:先从识别出的疑似位置探测图形中,确定符合第一筛选条件的疑似位置探测图像;再从符合第一筛选条件的疑似位置探测图形中,筛选符合第二筛选条件的疑似位置探测图形;从符合第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。In the third case mentioned above, a specific implementation method may be: first, determine the suspected position detection image that meets the first filtering condition from the identified suspected position detection graphics; then, filter the suspected position detection graphics that meet the second filtering condition from the suspected position detection graphics that meet the first filtering condition; and determine the graphics that meet the positioning rules of the QR code from the suspected position detection graphics that meet the second filtering condition.
当然,还可以是先筛选出符合第二筛选条件的疑似位置探测图形,再从符合第二筛选条件的疑似位置探测图形中筛选符合第一筛选条件的疑似位置探测图形。Of course, it is also possible to first filter out the suspected position detection patterns that meet the second filtering condition, and then filter out the suspected position detection patterns that meet the first filtering condition from the suspected position detection patterns that meet the second filtering condition.
具体的,在本申请实施例中,使用第一筛选条件进行筛选的过程如下:以疑似位置探测图形的中心位置处的像素点为中心,在中心位置处的像素点周围选取预设数量个像素,比如,选取包括中心位置处的像素点在内的9个像素点、或者5个像素点等,确定选取的预设数量个像素点中第一类像素和第二类像素的个数,根据第一类像素或第二类像素的个数,进行筛选。例如,中心位置所在的第三区域为黑色像素区域,则第一类像素为黑色像素,第二类像素为白色像素,正常情况下,第三区域内的像素均为第一类像素,或者,由于椒盐噪声的影响,可能会有几个白色像素,因此,确定选取的预设数量个像素点中第二类像素点的个数,当第二类像素点的个数与预设数量的比值大于预设比值时,则将该疑似位置探测图形过滤掉。Specifically, in an embodiment of the present application, the process of screening using the first screening condition is as follows: taking the pixel at the center position of the suspected position detection pattern as the center, a preset number of pixels are selected around the pixel at the center position, for example, 9 pixels including the pixel at the center position, or 5 pixels, etc. are selected, and the number of first-category pixels and second-category pixels in the selected preset number of pixels is determined, and screening is performed based on the number of first-category pixels or second-category pixels. For example, if the third area where the center position is located is a black pixel area, then the first-category pixels are black pixels and the second-category pixels are white pixels. Under normal circumstances, all pixels in the third area are first-category pixels, or there may be a few white pixels due to the influence of salt and pepper noise. Therefore, the number of second-category pixels in the selected preset number of pixels is determined. When the ratio of the number of second-category pixels to the preset number is greater than the preset ratio, the suspected position detection pattern is filtered out.
具体的,上述第三像素排布可以是包含中心位置处的像素点在内的任意一条像素排布,比如说,可以是疑似位置探测图形的对角线、还可以是包含中心位置处的像素点且与水平线之间夹角值为30°的斜线等等。Specifically, the above-mentioned third pixel arrangement can be any pixel arrangement including the pixel point at the center position. For example, it can be the diagonal line of the suspected position detection pattern, or it can be a slanted line including the pixel point at the center position and with an angle of 30° with the horizontal line, etc.
在1:1:3:1:1模式的位置探测图形中,则上述第三预设比例为1:1:3:1:1。In the position detection pattern of the 1:1:3:1:1 mode, the third preset ratio is 1:1:3:1:1.
图5示出了本申请实施例提供的二维码定位方法的第二种流程示意图,如图5所示,该方法包括以下步骤:FIG5 shows a second flow chart of the QR code positioning method provided in an embodiment of the present application. As shown in FIG5 , the method includes the following steps:
步骤S202,在含有第一类像素和第二类像素的二维码图像中,确定行像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例的第一像素排布;及确定列像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例的第二像素排布;Step S202: In a two-dimensional code image containing pixels of the first category and pixels of the second category, determining a first pixel arrangement in which a ratio of the first category pixels, the second category pixels, and the first category pixels in a row of pixels satisfies a first preset ratio; and determining a second pixel arrangement in which a ratio of the first category pixels, the second category pixels, and the first category pixels in a column of pixels satisfies a second preset ratio;
步骤S204,根据第一像素排布的中心点及第二像素排布的中心点,确定疑似位置探测图形的中心位置;Step S204, determining the center position of the suspected position detection pattern according to the center point of the first pixel arrangement and the center point of the second pixel arrangement;
步骤S206,根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;Step S206, identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
步骤S208,从识别出的疑似位置探测图形中,确定符合第一筛选条件的疑似位置探测图形;Step S208, determining a suspected position detection pattern that meets a first screening condition from among the identified suspected position detection patterns;
步骤S210,从符合第一筛选条件的疑似位置探测图形中,确定符合第二筛选条件的疑似位置探测图形;Step S210, determining a suspected position detection pattern that meets a second screening condition from the suspected position detection patterns that meet the first screening condition;
步骤S212,从符合第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。Step S212: Determine a pattern that meets the positioning rule of the QR code from the suspected position detection patterns that meet the second screening condition.
二维码中的三个位置探测图形位于二维码的四个角中的任意三个角上,因此,上述定位规则可以包括:三个位置探测图形的中心点的连线中,长度最短的两条连线垂直且长度相等;The three position detection patterns in the QR code are located at any three of the four corners of the QR code. Therefore, the positioning rule may include: among the lines connecting the center points of the three position detection patterns, the two shortest lines are perpendicular and of equal length;
上述位置探测图形的中心点指的是位置探测图形的中心位置。The center point of the position detection pattern mentioned above refers to the center position of the position detection pattern.
因此,从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形,包括:从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;分别判断每组疑似位置探测图形是否满足上述定位规则;将满足上述定位规则的至少一组疑似位置探测图形作为二维码图像的位置探测图形。Therefore, from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, the graphics that meet the positioning rules of the QR code are determined, including: from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, multiple groups of suspected position detection graphics are formed in groups of three; each group of suspected position detection graphics is judged whether it meets the above-mentioned positioning rules; at least one group of suspected position detection graphics that meets the above-mentioned positioning rules is used as the position detection graphic of the QR code image.
其中,上述筛选出的符合第一筛选条件和/或第二筛选条件的疑似位置探测图形至少为3个。在本申请实施例中,将筛选出的符合第一筛选条件和/或第二筛选条件的疑似位置探测图形的个数记为N,N个疑似位置探测图形按照每三个一组的方式可以形成组疑似位置探测图形,比如,上述筛选出的符合第一筛选条件和/或第二筛选条件的疑似位置探测图形为4个,分别记为A1、A2、A3和A4,按照每三个一组的形式可以形成组疑似位置探测图形,分别记为{A1,A2,A3}、{A1,A3,A4}、{A1,A2,A4}和{A2、A3、A4}。Among them, the number of suspected position detection patterns that meet the first screening condition and/or the second screening condition is at least 3. In the embodiment of the present application, the number of suspected position detection patterns that meet the first screening condition and/or the second screening condition is recorded as N, and the N suspected position detection patterns can form a group of suspected position detection patterns in a group of three. For example, the number of suspected position detection patterns that meet the first screening condition and/or the second screening condition is 4, which are recorded as A1 , A2 , A3 and A4 respectively. The suspected position detection patterns can form a group of three suspected position detection patterns, which are recorded as { A1 , A2 , A3 }, { A1 , A3 , A4 }, { A1 , A2 , A4 } and { A2 , A3 , A4 } respectively.
具体的,每组疑似位置探测图形的中心点的连线可以构成一个三角形,在判断每组疑似位置探测图形是否满足上述定位规则时,可以通过判断上述三角形中长度最短的两条边的夹角值是否是90°,以及长度最短的两条边是否相等来判断每组疑似位置探测图形是否满足定位规则。由于获取到的二维码图像可能存在变形等情况,因此由三个位置探测图形的中心点构成的三角形中两个短边的夹角值不一定是90°,因此,在实际应用中,在判断每组疑似位置探测图形是否满足定位规则时,只要每组疑似位置探测图形的中心点构成的三角形的两个短边的夹角值与90°之间的差值在预设范围内,且两个短边之间的长度差也在预设误差范围内,则确定该组疑似位置探测图形满足定位规则。Specifically, the lines connecting the center points of each group of suspected position detection patterns can form a triangle. When judging whether each group of suspected position detection patterns satisfies the above-mentioned positioning rules, the method can be used to judge whether the angle between the two shortest sides of the triangle is 90°, and whether the two shortest sides are equal. Since the acquired QR code image may be deformed, the angle between the two short sides of the triangle formed by the center points of the three position detection patterns is not necessarily 90°. Therefore, in actual applications, when judging whether each group of suspected position detection patterns satisfies the positioning rules, as long as the difference between the angle between the two short sides of the triangle formed by the center points of each group of suspected position detection patterns and 90° is within the preset range, and the length difference between the two short sides is also within the preset error range, it is determined that the group of suspected position detection patterns satisfies the positioning rules.
除了上述确定符合二维码的定位规则的图形外,本申请实施例还提供了如下方法,具体包括:In addition to the above-mentioned method of determining a graphic that meets the positioning rules of a QR code, the embodiment of the present application also provides the following method, specifically including:
从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;确定每组疑似位置探测图形中的三个疑似位置探测图形的中心点的连线构成的三角形的几何参数和三个疑似位置探测图形的面积的均差,其中,上述几何参数包括三角形中长度最短的两条连线的夹角值和长度最短的两条连线的长度差值;From the suspected position detection patterns that meet the first screening condition and/or the second screening condition, forming a plurality of groups of three suspected position detection patterns; determining geometric parameters of a triangle formed by lines connecting the center points of the three suspected position detection patterns in each group of suspected position detection patterns and a mean difference between the areas of the three suspected position detection patterns, wherein the geometric parameters include an angle between the two shortest connecting lines in the triangle and a length difference between the two shortest connecting lines;
根据上述夹角值、上述长度差值和上述均差,确定符合上述二维码的定位规则的图形。According to the angle value, the length difference and the mean difference, a graphic that meets the positioning rule of the two-dimensional code is determined.
其中,上述确定三个疑似位置探测图形的面积的均差的具体过程如下:根据每个疑似位置探测图形的长度和宽度,以及每个疑似位置探测图形上的模块的个数,确定出每个模块的长和宽,计算出每个模块的面积。之后,根据每个模块的面积和模块的个数,计算每个疑似位置探测图形的面积。最后,根据三个疑似位置探测图形的面积,及均差公式,计算出三个疑似位置探测图形的面积的均差。The specific process for determining the mean difference in the areas of the three suspected position detection patterns is as follows: Based on the length and width of each suspected position detection pattern and the number of modules within each suspected position detection pattern, the length and width of each module are determined, and the area of each module is calculated. Next, based on the area of each module and the number of modules, the area of each suspected position detection pattern is calculated. Finally, based on the areas of the three suspected position detection patterns and the mean difference formula, the mean difference in the areas of the three suspected position detection patterns is calculated.
具体的,在本申请实施例中,上述根据夹角值、长度差值和均差,确定符合上述二维码的定位规则的图像,具体包括如下步骤:Specifically, in the embodiment of the present application, determining an image that meets the positioning rule of the above-mentioned two-dimensional code based on the angle value, length difference and mean difference specifically includes the following steps:
根据上述夹角值、上述长度差值和均差,通过公式(1)计算每组疑似位置探测图形的得分;According to the above angle value, the above length difference and the mean difference, the score of each group of suspected position detection patterns is calculated by formula (1);
分别将每组疑似位置探测图形的得分与预设分值进行比较,根据比较结果确定符合二维码的定位规则的图形;Compare the scores of each group of suspected location detection patterns with the preset scores, and determine the patterns that meet the positioning rules of the QR code based on the comparison results;
其中,在公式(1)中,a、b、c、d均为常量,xi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的夹角值,yi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的长度差值,zi表示的是第i组疑似位置探测图形中的三个疑似位置探测图形的面积的均差,fi表示的是第i组疑似位置探测图形的得分。Wherein, in formula (1), a, b, c, and d are all constants, x i represents the angle between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection patterns, y i represents the length difference between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection patterns, z i represents the average difference in the areas of the three suspected position detection patterns in the i-th group of suspected position detection patterns, and fi represents the score of the i-th group of suspected position detection patterns.
当确定出每组疑似位置探测图形的得分后,将该得分与预设分值进行比较,在一种具体实施方式中,当该得分大于或等于预设分值时,则确定该组疑似位置探测图形符合二维码的定位规则。After determining the score of each group of suspected location detection patterns, the score is compared with the preset score. In a specific embodiment, when the score is greater than or equal to the preset score, it is determined that the group of suspected location detection patterns meets the positioning rules of the QR code.
在本申请实施例中,确地出的符合二维码定位规则的位置探测图形的组数可以是一组或者多组。In the embodiment of the present application, the number of groups of position detection patterns that meet the two-dimensional code positioning rules can be one group or multiple groups.
基于上述图1至图5中的方法,本申请实施例还提供了一种二维码定位方法,图6为本申请实施例提供的二维码定位方法的第三种流程示意图,该方法的执行主体可以是终端,也可以是服务器,针对图6所示的方法,这里重点介绍与上述图1至图5中的方法的不同之处,相同之处可以参考前述图1至图5的描述,这里不再赘述,如图6所示,该方法包括以下步骤:Based on the methods in Figures 1 to 5 above, the present application also provides a QR code positioning method. Figure 6 is a schematic diagram of a third flow chart of the QR code positioning method provided in the present application. The execution subject of this method can be a terminal or a server. With respect to the method shown in Figure 6, the differences from the methods in Figures 1 to 5 above are mainly described here. For the similarities, please refer to the description of Figures 1 to 5 above, which will not be repeated here. As shown in Figure 6, the method includes the following steps:
步骤S602,在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第一预设阈值,列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值。Step S602: In a two-dimensional code image containing first-category pixels and second-category pixels, the center position of a suspected position detection pattern in the two-dimensional code image is determined using preset row pixel detection rules and column pixel detection rules; wherein the row pixel detection rule includes: the number of continuously arranged first-category pixels or second-category pixels reaches a first preset threshold, and the column pixel detection rule includes: the number of continuously arranged first-category pixels or second-category pixels reaches a second preset threshold.
具体的,上述行像素探测规则可以是连续排布的第一类像素的个数达到第一预设阈值,相应的,列像素探测规则为连续排布的第一类像素的个数达到第二预设阈值;或者,上述行像素探测规则为连续排布的第二类像素的个数达到第一预设阈值,相应的,列像素探测规则为连续排布的第二类像素的个数达到第二预设阈值。Specifically, the above-mentioned row pixel detection rule can be that the number of continuously arranged first-type pixels reaches a first preset threshold, and correspondingly, the column pixel detection rule is that the number of continuously arranged first-type pixels reaches a second preset threshold; or, the above-mentioned row pixel detection rule is that the number of continuously arranged second-type pixels reaches a first preset threshold, and correspondingly, the column pixel detection rule is that the number of continuously arranged second-type pixels reaches a second preset threshold.
上述第一预设阈值与第二预设阈值的大小可以相等,在一种具体应用场景中,支付宝所使用的二维码中,位置探测图形为正方形,即长和宽相等,这时,第一预设阈值和第二预设阈值则相等。The first preset threshold and the second preset threshold may be equal in size. In a specific application scenario, in the QR code used by Alipay, the location detection graphic is a square, that is, the length and width are equal. In this case, the first preset threshold and the second preset threshold are equal.
其中,满足上述行像素探测规则和列像素探测规则的像素排布一般位于二值探测图形的第一区域(如图2所示)。The pixel arrangement that meets the above-mentioned row pixel detection rule and column pixel detection rule is generally located in the first area of the binary detection pattern (as shown in FIG. 2 ).
步骤S604,根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形。Step S604: identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern.
步骤S606,从识别出的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,作为上述二维码图像的位置探测图形。Step S606: Determine a pattern that meets the positioning rule of the two-dimensional code from the identified suspected position detection patterns, and use it as the position detection pattern of the two-dimensional code image.
在一种具体实施方式中,比如支付宝所使用的黑白二维码,其位置探测图形为1:1:3:1:1模式,三个中心重叠的同心正方形,分别为7*7个黑色模块、5*5个白色模块、3*3个黑色模块,上述行像素探测规则可以是连续排布的黑色像素的个数达到7*7个黑色模块处的黑色像素的个数,上述列像素探测规则为连续排布的黑色像素的个数达到7*7个黑色模块处的黑色像素的个数。满足上述行像素探测规则的第一像素排布位于位置探测图形的第一区域,满足上述列像素探测规则的第二像素排布位于位置探测图形的第一区域,这样可以快速识别出二维码中的疑似位置探测图形。In a specific embodiment, for example, the black and white QR code used by Alipay has a position detection pattern in a 1:1:3:1:1 pattern, with three concentric squares with overlapping centers, namely 7*7 black modules, 5*5 white modules, and 3*3 black modules. The row pixel detection rule can be that the number of continuously arranged black pixels reaches the number of black pixels at 7*7 black modules, and the column pixel detection rule can be that the number of continuously arranged black pixels reaches the number of black pixels at 7*7 black modules. The first pixel arrangement that meets the row pixel detection rule is located in the first area of the position detection pattern, and the second pixel arrangement that meets the column pixel detection rule is located in the first area of the position detection pattern. This allows for rapid identification of suspected position detection patterns in the QR code.
在本申请实施例中,根据第一类像素、第二类像素、第一类像素的排布比例或者连续排布的第一类像素的个数或者连续排布的第二类像素的个数确定二维码图像中的疑似位置探测图形的中心位置,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。In an embodiment of the present application, the center position of the suspected position detection pattern in the QR code image is determined based on the first-category pixels, the second-category pixels, the arrangement ratio of the first-category pixels, or the number of continuously arranged first-category pixels or the number of continuously arranged second-category pixels, which has a certain fault tolerance. In this way, even if the position detection pattern of the QR code is damaged or the brightness is weak, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified in the above manner, the position detection pattern of the QR code is determined from the identified suspected position detection pattern, with high accuracy.
基于上述图1至图5中的方法,本申请实施例还提供了一种二维码定位方法,图7为本申请实施例提供的二维码定位方法的第四种流程示意图,该方法的执行主体可以是终端,也可以是服务器,针对图7所示的方法,这里重点介绍与上述图1至图5中的方法的不同之处,相同之处可以参考前述图1至图5的描述,这里不再赘述,如图7所示,该方法包括以下步骤:Based on the methods in Figures 1 to 5 above, the present application also provides a QR code positioning method. Figure 7 is a fourth flow chart of the QR code positioning method provided in the present application. The execution subject of this method can be a terminal or a server. With respect to the method shown in Figure 7, the differences from the methods in Figures 1 to 5 above are mainly described here. For the similarities, please refer to the description of Figures 1 to 5 above, which will not be repeated here. As shown in Figure 7, the method includes the following steps:
步骤S702,在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例。Step S702: In a two-dimensional code image containing first-category pixels and second-category pixels, a preset pixel detection rule is used to determine the center position of a suspected position detection pattern in the two-dimensional code image; wherein the pixel detection rule includes that the sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio.
针对现阶段支付宝所使用的二维码,上述预设比例可以是1:5:1。For the QR code currently used by Alipay, the above preset ratio can be 1:5:1.
在本申请实施例中,上述第一类像素为前景色像素,第二类像素为背景色像素,具体的,上述第一类像素为黑色像素或蓝色像素,第二类像素为与所述第一类像素的色差值超过设定阈值的像素,比说,第二类像素可以是白色。In an embodiment of the present application, the first type of pixels are foreground color pixels, and the second type of pixels are background color pixels. Specifically, the first type of pixels are black pixels or blue pixels, and the second type of pixels are pixels whose color difference value with the first type of pixels exceeds a set threshold. For example, the second type of pixels can be white.
当然,除了黑色像素和蓝色像素外,上述第一类像素还可以是其它颜色的像素。Of course, in addition to black pixels and blue pixels, the first type of pixels may also be pixels of other colors.
目前,支付宝在使用的二维码包括黑白二维码、蓝白二维码等,因此,在一种具体实施方式中,第一类像素为黑色像素,第二类像素为白色像素。在另外一种实施方式中,第一类像素为蓝色像素,第二类像素为白色像素。Currently, the QR codes used by Alipay include black and white QR codes, blue and white QR codes, etc. Therefore, in one embodiment, the first type of pixels are black pixels and the second type of pixels are white pixels. In another embodiment, the first type of pixels are blue pixels and the second type of pixels are white pixels.
步骤S704,根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形。Step S704: identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern.
步骤S706,从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,作为二维码图像的位置探测图形。Step S706 : Determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, and use it as the position detection pattern of the two-dimensional code image.
以支付宝所使用的黑白二维码为例,现在结合具体应用场景,介绍一种具体的二维码的定位装置,图8为本申请实施例提供的二维码定位方法的第四种流程示意图,该方法的执行主体可以是终端,也可以是服务器,如图8所示,该方法包括以下步骤:Taking the black and white QR code used by Alipay as an example, a specific QR code positioning device is now introduced in combination with specific application scenarios. FIG8 is a schematic flow chart of the fourth QR code positioning method provided in an embodiment of the present application. The execution subject of this method can be a terminal or a server. As shown in FIG8, the method includes the following steps:
步骤S802,获取通过支付宝扫描到的原始二维码图像;Step S802: Obtain the original QR code image scanned by Alipay;
步骤S804,对原始二维码图像进行处理,得到包含有黑色像素和白色像素的二维码图像;Step S804: Process the original two-dimensional code image to obtain a two-dimensional code image containing black pixels and white pixels;
其中,上述对原始二维码图形进行处理,可以包括去噪、二值化处理等过程。The above processing of the original two-dimensional code graphic may include processes such as denoising and binarization.
步骤S806,在含有黑色像素和白色像素的二维码图像中,以预设的像素探测规则,确定行像素中黑色像素、白色像素、黑色像素的顺序排布比例满足1:5:1的行像素排布及列像素排布;Step S806, in the two-dimensional code image containing black pixels and white pixels, using a preset pixel detection rule, determining a row pixel arrangement and a column pixel arrangement in which the sequential arrangement ratio of black pixels, white pixels, and black pixels in a row of pixels satisfies a 1:5:1 ratio;
步骤S808,根据上述行像素排布的中心点和列像素排布的中心点,确定疑似位置探测图形的中心位置;Step S808, determining the center position of the suspected position detection pattern according to the center point of the row pixel arrangement and the center point of the column pixel arrangement;
步骤S810,根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;Step S810, identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
步骤S812,从识别出的疑似位置探测图形中,确定符合第一筛选条件的疑似位置探测图形;Step S812, determining a suspected position detection pattern that meets a first screening condition from among the identified suspected position detection patterns;
步骤S814,从符合第一筛选条件的疑似位置探测图形中筛选出符合第二筛选条件的疑似位置探测图形;Step S814, filtering out suspected position detection patterns that meet the second screening condition from the suspected position detection patterns that meet the first screening condition;
步骤S816,从符合第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;Step S816, forming a plurality of groups of suspected position detection patterns in groups of three from the suspected position detection patterns that meet the second screening condition;
步骤S818,判断每组疑似位置探测图形是否满足二维码的定位规则;如果是,执行步骤S820;Step S818, determining whether each group of suspected position detection patterns meets the positioning rules of the QR code; if so, executing step S820;
步骤S820,将该组疑似位置探测图形作为二维码图像的位置探测图形。Step S820: Using the group of suspected position detection patterns as position detection patterns of the two-dimensional code image.
通过上述介绍的二维码定位方法,根据第一类像素、第二类像素、第一类像素的排布比例,确定二维码图像中的疑似位置探测图形的中心位置,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。Through the QR code positioning method introduced above, the center position of the suspected position detection pattern in the QR code image is determined according to the arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels, which has a certain fault tolerance. In this way, even if the position detection pattern of the QR code is damaged or the brightness is weak, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified by the above method, the position detection pattern of the QR code is determined from the identified suspected position detection pattern, with high accuracy.
对应上述的二维码定位方法,基于相同的思路,本申请实施例还提供了一种二维码定位装置,可以应用在终端侧,也可以应用在服务器侧,图9为本申请实施例提供的二维码定位装置的模块组成示意图,如图9所示,该装置包括:Corresponding to the above-mentioned QR code positioning method, based on the same idea, the embodiment of the present application also provides a QR code positioning device, which can be applied on the terminal side or on the server side. FIG9 is a schematic diagram of the module composition of the QR code positioning device provided in the embodiment of the present application. As shown in FIG9, the device includes:
位置确定模块91,用于在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,上述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;A position determination module 91 is configured to determine, in a two-dimensional code image containing pixels of the first and second categories, a center position of a suspected position detection pattern in the two-dimensional code image using a preset row pixel detection rule and a preset column pixel detection rule; wherein the row pixel detection rule includes: a first preset ratio of sequential arrangement of pixels of the first category, pixels of the second category, and pixels of the first category; and the column pixel detection rule includes: a second preset ratio of sequential arrangement of pixels of the first category, pixels of the second category, and pixels of the first category.
识别模块92,用于根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;an identification module 92 for identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
图形确定模块93,用于从识别出的疑似位置探测图形中,确定符合二维码图形的定位规则的图形,作为二维码图像的位置探测图形。The pattern determination module 93 is used to determine a pattern that meets the positioning rule of the two-dimensional code pattern from the identified suspected position detection patterns, and use it as the position detection pattern of the two-dimensional code image.
可选地,上述第一预设比例为1:n:1,且n大于1;上述第二预设比例为1:m:1,且m大于1。Optionally, the first preset ratio is 1:n:1, and n is greater than 1; the second preset ratio is 1:m:1, and m is greater than 1.
可选的,上述位置确定模块91包括像素确定单元和位置确定单元,具体包括像素确定单元和位置确定单元;Optionally, the position determination module 91 includes a pixel determination unit and a position determination unit, specifically including a pixel determination unit and a position determination unit;
上述像素确定单元,用于确定行像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例的第一像素排布;及确定列像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例的第二像素排布;上述位置确定单元,用于根据上述第一像素排布的中心点及第二像素排布的中心点,确定上述疑似位置探测图形的中心位置。The above-mentioned pixel determination unit is used to determine a first pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the row pixels meets a first preset ratio; and to determine a second pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the column pixels meets a second preset ratio; the above-mentioned position determination unit is used to determine the center position of the above-mentioned suspected position detection pattern based on the center point of the above-mentioned first pixel arrangement and the center point of the second pixel arrangement.
可选地,上述图形确定模块93包括第一图形确定单元和第二图形确定单元,具体包括:Optionally, the graphic determination module 93 includes a first graphic determination unit and a second graphic determination unit, specifically including:
上述第一图形确定单元,用于从识别出的疑似位置探测图形中,确定符合第一筛选条件和/或第二筛选条件的疑似位置探测图形;其中,上述第一筛选条件包括在上述中心位置相邻的预设区域内,第一类像素和/或第二类像素的个数符合预设的阈值范围;第二筛选条件包括穿过上述中心位置的第三像素排布中的第一类像素、第二类像素、第一类像素、第二类像素、第一类像素的顺序排布比例满足第三预设比例;上述第二确定单元,用于从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合上述二维码的定位规则的图形。The above-mentioned first graphic determination unit is used to determine the suspected position detection graphic that meets the first filtering condition and/or the second filtering condition from the identified suspected position detection graphic; wherein the above-mentioned first filtering condition includes that the number of first-class pixels and/or second-class pixels in the preset area adjacent to the above-mentioned center position meets the preset threshold range; the second filtering condition includes that the sequential arrangement ratio of the first-class pixels, the second-class pixels, the first-class pixels, the second-class pixels, and the first-class pixels in the third pixel arrangement passing through the above-mentioned center position meets the third preset ratio; the above-mentioned second determination unit is used to determine the graphic that meets the positioning rules of the above-mentioned QR code from the suspected position detection graphic that meets the first filtering condition and/or the second filtering condition.
可选地,上述定位规则包括:三个位置探测图形的中心点的连线中,长度最短的两条连线垂直且长度相等,上述第二图形确定单元,具体用于:Optionally, the positioning rule includes: among the lines connecting the center points of the three position detection figures, the two shortest lines are perpendicular and equal in length, and the second figure determination unit is specifically configured to:
从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照没三个一组的方式形成多组疑似位置探测图形;分别判断每组疑似位置探测图形是否满足上述定位规则;将满足上述定位规则的至少一组疑似位置探测图形作为上述二维码图像的位置探测图形。From the suspected position detection patterns that meet the first filtering condition and/or the second filtering condition, multiple groups of suspected position detection patterns are formed in groups of three; each group of suspected position detection patterns is judged separately whether it meets the above-mentioned positioning rules; at least one group of suspected position detection patterns that meets the above-mentioned positioning rules is used as the position detection pattern of the above-mentioned QR code image.
可选地,上述第二图形确定单元,还具体用于:Optionally, the second graphic determination unit is further configured to:
从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;确定每组疑似位置探测图形中的三个疑似位置探测图形的中线点的连线构成的三角形的几何参数和三个疑似位置探测图形的面积的均差,其中,上述几何参数包括上述三角形中长度最短的两条连线的夹角值和长度最短的两条连线的长度差值;根据上述夹角值、上述长度差值和上述均差,确定符合上述二维码的定位规则的图形。From the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, multiple groups of suspected position detection graphics are formed in groups of three; the geometric parameters of the triangle formed by the lines connecting the midline points of the three suspected position detection graphics in each group of suspected position detection graphics and the average difference of the areas of the three suspected position detection graphics are determined, wherein the above-mentioned geometric parameters include the angle value of the two shortest lines in the above-mentioned triangle and the length difference of the two shortest lines; based on the above-mentioned angle value, the above-mentioned length difference and the above-mentioned average difference, the graphics that meet the positioning rules of the above-mentioned QR code are determined.
可选地,上述第二图形确定单元,具体通过以下过程确定符合二维码的定位规则的图形:Optionally, the second graphic determining unit determines a graphic that meets the positioning rule of the QR code through the following process:
根据上述夹角值、上述长度差值和均差,通过如下公式计算每组疑似位置探测图形的得分;分别将每组疑似位置探测图形的得分与预设分值进行比较,根据比较结果确定符合上述二维码的定位规则的图形;Based on the angle value, the length difference, and the mean difference, the score of each group of suspected position detection patterns is calculated using the following formula; the score of each group of suspected position detection patterns is compared with the preset score, and the pattern that meets the positioning rules of the QR code is determined based on the comparison results;
其中,在上述公式中,a、b、c、d均为常量,xi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的夹角值,yi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的长度差值,zi表示的是第i组疑似位置探测图形中的三个疑似位置探测图形的面积的均差,fi表示的是第i组疑似位置探测图形的得分。Wherein, in the above formula, a, b, c, and d are all constants, x i represents the angle between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection figures, y i represents the difference in length between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection figures, zi represents the average difference in the areas of the three suspected position detection figures in the i-th group of suspected position detection figures, and fi represents the score of the i-th group of suspected position detection figures.
对应上述的二维码定位方法,基于相同的思路,上述图9所示的二维码定位装置中的各个模块,还具体如下功能:Corresponding to the above-mentioned two-dimensional code positioning method, based on the same idea, each module in the two-dimensional code positioning device shown in FIG9 also has the following specific functions:
上述位置确定模块91,还用于在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第一预设阈值,列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;The position determination module 91 is further configured to determine the center position of the suspected position detection pattern in the two-dimensional code image containing the first and second type pixels using a preset row pixel detection rule and a preset column pixel detection rule. The row pixel detection rule includes the following: the number of consecutively arranged first type pixels or second type pixels reaches a first preset threshold value; the column pixel detection rule includes the following: the number of consecutively arranged first type pixels or second type pixels reaches a second preset threshold value.
上述识别模块92,还用于根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;The identification module 92 is further configured to identify a corresponding suspected position detection pattern based on the determined center position of the suspected position detection pattern;
上述图形确定模块93,还用于从识别出的疑似位置探测图形中,确定符合上述二维码图像的定位规则的图形,作为二维码图像的位置探测图形。The pattern determination module 93 is further configured to determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, as the position detection pattern of the two-dimensional code image.
可选地,上述第一预设阈值与第二预设阈值相等。Optionally, the first preset threshold is equal to the second preset threshold.
对应上述的二维码定位方法,基于相同的思路,上述图9所示的二维码定位装置中的各个模块,还具体如下功能:Corresponding to the above-mentioned two-dimensional code positioning method, based on the same idea, each module in the two-dimensional code positioning device shown in FIG9 also has the following specific functions:
上述位置确定模块91,还用于在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;The position determination module 91 is further configured to determine the center position of the suspected position detection pattern in the two-dimensional code image containing the first-category pixels and the second-category pixels using a preset pixel detection rule; wherein the pixel detection rule includes that the sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio;
上述识别模块92,还用于根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;The identification module 92 is further configured to identify a corresponding suspected position detection pattern based on the determined center position of the suspected position detection pattern;
上述图形确定模块93,还用于从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,作为二维码图像的位置探测图形。The pattern determination module 93 is further configured to determine a pattern that meets the positioning rule of the two-dimensional code image from the identified suspected position detection patterns, as the position detection pattern of the two-dimensional code image.
可选地,上述预设比例为1:5:1。Optionally, the preset ratio is 1:5:1.
可选地,上述第一类像素为黑色像素或蓝色像素,第二类像素为与所述第一类像素的色差值超过设定阈值的像素。Optionally, the first type of pixels are black pixels or blue pixels, and the second type of pixels are pixels whose color difference value with the first type of pixels exceeds a set threshold.
通过本申请实施例中的二维码定位装置,首先根据第一类像素、第二类像素、第一类像素的排布比例或者连续排布的第一类像素的个数或者连续排布的第二类像素的个数,确定二维码的疑似位置探测图形,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。Through the two-dimensional code positioning device in the embodiment of the present application, the suspected position detection pattern of the two-dimensional code is first determined based on the first-category pixels, the second-category pixels, the arrangement ratio of the first-category pixels, or the number of continuously arranged first-category pixels or the number of continuously arranged second-category pixels, which has a certain fault tolerance. In this way, even if the position detection pattern of the two-dimensional code is damaged or the brightness is weak, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified in the above manner, the position detection pattern of the two-dimensional code is determined from the identified suspected position detection pattern, with high accuracy.
进一步地,基于上述图1至图8所示的方法,本申请实施例还提供了一种二维码定位设备,如图10所示。Furthermore, based on the methods shown in FIG. 1 to FIG. 8 above, an embodiment of the present application also provides a QR code positioning device, as shown in FIG. 10 .
二维码定位设备可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上的处理器901和存储器902,存储器902中可以存储有一个或一个以上存储应用程序或数据。其中,存储器902可以是短暂存储或持久存储。存储在存储器902的应用程序可以包括一个或一个以上模块(图示未示出),每个模块可以包括对二维码定位设备中的一系列计算机可执行指令。更进一步地,处理器901可以设置为与存储器902通信,在二维码定位设备上执行存储器902中的一系列计算机可执行指令。二维码定位设备还可以包括一个或一个以上电源903,一个或一个以上有线或无线网络接口904,一个或一个以上输入输出接口905,一个或一个以上键盘906等。The two-dimensional code positioning device may have relatively large differences due to different configurations or performances, and may include one or more processors 901 and memory 902, and the memory 902 may store one or more storage applications or data. Among them, the memory 902 can be a temporary storage or a persistent storage. The application stored in the memory 902 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the two-dimensional code positioning device. Furthermore, the processor 901 can be configured to communicate with the memory 902 and execute a series of computer executable instructions in the memory 902 on the two-dimensional code positioning device. The two-dimensional code positioning device may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input and output interfaces 905, one or more keyboards 906, etc.
在一个具体的实施例中,二维码定位设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对二维码定位设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:In a specific embodiment, the two-dimensional code positioning device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the two-dimensional code positioning device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,上述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;In a two-dimensional code image containing first-class pixels and second-class pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-class pixels, the second-class pixels, and the first-class pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-class pixels, the second-class pixels, and the first-class pixels satisfies a second preset ratio;
根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;Identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,作为二维码的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code is determined as the position detection pattern of the two-dimensional code.
可选地,计算机可执行指令在被执行时,第一预设比例为1:n:1,且n大于1;第二预设比例为1:m:1,且m大于1。Optionally, when the computer executable instruction is executed, the first preset ratio is 1:n:1, and n is greater than 1; the second preset ratio is 1:m:1, and m is greater than 1.
可选地,计算机可执行指令在被执行时,确定二维码图像中疑似位置探测图形的中心位置,包括:确定行像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例的第一像素排布;及确定列像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例的第二像素排布;根据第一像素排布的中心点及第二像素排布的中心点,确定疑似位置探测图形的中心位置。Optionally, when the computer executable instructions are executed, they determine the center position of the suspected position detection pattern in the two-dimensional code image, including: determining a first pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the row pixels meets a first preset ratio; and determining a second pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the column pixels meets a second preset ratio; and determining the center position of the suspected position detection pattern based on the center point of the first pixel arrangement and the center point of the second pixel arrangement.
可选地,计算机可执行指令在被执行时,从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,包括:从识别出的疑似位置探测图形中,确定符合第一筛选条件和/或第二筛选条件的疑似位置探测图形;其中,第一筛选条件包括在上述中心位置相邻的预设区域内,第一类像素和/或第二类像素的个数符合预设的阈值范围;第二筛选条件包括穿过中心位置的第三像素排布中的第一类像素、第二类像素、第一类像素、第二类像素、第一类像素的顺序排布比例满足第三预设比例;从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。Optionally, when the computer executable instructions are executed, a graphic that meets the positioning rules of the two-dimensional code image is determined from the identified suspected position detection graphics, including: determining a suspected position detection graphic that meets the first filtering condition and/or the second filtering condition from the identified suspected position detection graphics; wherein the first filtering condition includes that the number of first-class pixels and/or second-class pixels in a preset area adjacent to the above-mentioned center position meets a preset threshold range; the second filtering condition includes that the sequential arrangement ratio of first-class pixels, second-class pixels, first-class pixels, second-class pixels, and first-class pixels in the third pixel arrangement passing through the center position meets a third preset ratio; and determining a graphic that meets the positioning rules of the two-dimensional code from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition.
可选地,上述定位规则包括:三个位置探测图形的中心点的连线中,长度最短的两条连线垂直且长度相等,计算机可执行指令在被执行时,从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,包括:从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;分别判断每组疑似位置探测图形是否满足上述定位规则;将满足上述定位规则的至少一组疑似位置探测图形作为二维码图像的位置探测图形。Optionally, the above-mentioned positioning rules include: among the lines connecting the center points of the three position detection graphics, the two shortest lines are perpendicular and of equal length. When the computer executable instructions are executed, the graphics that meet the positioning rules of the above-mentioned QR code are determined from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, including: from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, multiple groups of suspected position detection graphics are formed in groups of three; each group of suspected position detection graphics is judged to determine whether it meets the above-mentioned positioning rules; and at least one group of suspected position detection graphics that meets the above-mentioned positioning rules is used as the position detection graphic of the QR code image.
可选地,计算机可执行指令在被执行时,上述从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,包括:从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;确定每组疑似位置探测图形中的三个疑似位置探测图形的中心点的连线构成的三角形的几何参数和三个疑似位置探测图形的面积的均差,其中,上述几何参数包括三角形中长度最短的两条连线的夹角值和长度最短的两条连线的长度差值;根据夹角值、长度差值和均差,确定符合二维码的定位规则的图形。Optionally, when the computer executable instructions are executed, the above-mentioned graphics that meet the positioning rules of the above-mentioned QR code are determined from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, including: forming multiple groups of suspected position detection graphics in groups of three from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition; determining the geometric parameters of the triangle formed by the lines connecting the center points of the three suspected position detection graphics in each group of suspected position detection graphics and the average difference of the areas of the three suspected position detection graphics, wherein the above-mentioned geometric parameters include the angle value of the two shortest lines in the triangle and the length difference of the two shortest lines; determining the graphics that meet the positioning rules of the QR code based on the angle value, the length difference and the average difference.
可选地,计算机可执行指令在被执行时,上述根据夹角值、长度差值和均差,确定符合上述二维码的定位规则的图形,包括:根据夹角值、长度差值和均差,通过如下公式计算每组疑似位置探测图形的得分;分别将每组疑似位置探测图形的得分与预设分值进行比较,根据比较结果确定符合二维码的定位规则的图形;Optionally, when the computer executable instructions are executed, the above-mentioned determining the graphics that meet the positioning rules of the above-mentioned QR code based on the angle value, length difference and average difference includes: calculating the score of each group of suspected position detection graphics according to the angle value, length difference and average difference using the following formula; comparing the score of each group of suspected position detection graphics with a preset score, and determining the graphics that meet the positioning rules of the QR code based on the comparison results;
其中,在上述公式中,a、b、c、d均为常量,xi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的夹角值,yi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的长度差值,zi表示的是第i组疑似位置探测图形中的三个疑似位置探测图形的面积的均差,fi表示的是第i组疑似位置探测图形的得分。Wherein, in the above formula, a, b, c, and d are all constants, x i represents the angle between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection figures, y i represents the difference in length between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection figures, zi represents the average difference in the areas of the three suspected position detection figures in the i-th group of suspected position detection figures, and fi represents the score of the i-th group of suspected position detection figures.
在一个具体的实施例中,二维码定位设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对二维码定位设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:In a specific embodiment, the two-dimensional code positioning device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the two-dimensional code positioning device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第一预设阈值,上述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;根据确定的上述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;从识别出的疑似位置探测图形中,确定符合上述二维码图像的定位规则的图形,作为上述二维码图像的位置探测图形。In a two-dimensional code image containing first-category pixels and second-category pixels, the center position of the suspected position detection pattern in the above-mentioned two-dimensional code image is determined using preset row pixel detection rules and column pixel detection rules; wherein the above-mentioned row pixel detection rules include: the number of continuously arranged first-category pixels or second-category pixels reaches a first preset threshold, and the above-mentioned column pixel detection rules include: the number of continuously arranged first-category pixels or second-category pixels reaches a second preset threshold; according to the determined center position of the above-mentioned suspected position detection pattern, the corresponding suspected position detection pattern is identified; from the identified suspected position detection patterns, a pattern that meets the positioning rule of the above-mentioned two-dimensional code image is determined as the position detection pattern of the above-mentioned two-dimensional code image.
可选地,计算机可执行指令在被执行时,上述第一预设阈值与第二预设阈值相等。Optionally, when the computer-executable instruction is executed, the first preset threshold is equal to the second preset threshold.
在一个具体的实施例中,二维码定位设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对二维码定位设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:In a specific embodiment, the two-dimensional code positioning device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the two-dimensional code positioning device, and the one or more programs are configured to be executed by one or more processors, including computer-executable instructions for performing the following:
在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,作为二维码图像的位置探测图形。In a two-dimensional code image containing first-category pixels and second-category pixels, a preset pixel detection rule is used to determine the center position of a suspected position detection pattern in the above-mentioned two-dimensional code image; wherein the above-mentioned pixel detection rule includes that the sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio; according to the determined center position of the suspected position detection pattern, a corresponding suspected position detection pattern is identified; from the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
可选地,计算机可执行指令在被执行时,上述预设比例为1:5:1。Optionally, when the computer executable instructions are executed, the preset ratio is 1:5:1.
可选地,计算机可执行指令在被执行时,上述第一类像素为黑色像素或蓝色像素,第二类像素为与所述第一类像素的色差值超过设定阈值的像素。Optionally, when the computer executable instructions are executed, the first type of pixels are black pixels or blue pixels, and the second type of pixels are pixels whose color difference value with the first type of pixels exceeds a set threshold.
本申请实施例中的存储介质存储的计算机指令在被执行后,首先根据第一类像素、第二类像素、第一类像素的排布比例或者连续排布的第一类像素的个数或者连续排布的第二类像素的个数,确定二维码的疑似位置探测图形,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。After the computer instructions stored in the storage medium in the embodiment of the present application are executed, the suspected position detection pattern of the QR code is first determined based on the first-category pixels, the second-category pixels, the arrangement ratio of the first-category pixels, or the number of continuously arranged first-category pixels or the number of continuously arranged second-category pixels. It has a certain fault tolerance, so even if the position detection pattern of the QR code is damaged or the brightness is weak, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified in the above manner, the position detection pattern of the QR code is determined from the identified suspected position detection pattern, with high accuracy.
进一步地,本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,一种具体的实施例中,该存储介质可以为U盘、光盘、硬盘等,该存储介质存储的计算机可执行指令在被处理器执行时,能实现以下流程:Furthermore, an embodiment of the present application further provides a storage medium for storing computer-executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例,上述列像素探测规则包括:第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例;In a two-dimensional code image containing first-class pixels and second-class pixels, a center position of a suspected position detection pattern in the two-dimensional code image is determined using a preset row pixel detection rule and a column pixel detection rule; wherein the row pixel detection rule includes: a sequential arrangement ratio of the first-class pixels, the second-class pixels, and the first-class pixels satisfies a first preset ratio; and the column pixel detection rule includes: a sequential arrangement ratio of the first-class pixels, the second-class pixels, and the first-class pixels satisfies a second preset ratio;
根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;Identifying a corresponding suspected position detection pattern according to the determined center position of the suspected position detection pattern;
从识别出的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,作为二维码的位置探测图形。From the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code is determined as the position detection pattern of the two-dimensional code.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,第一预设比例为1:n:1,且n大于1;第二预设比例为1:m:1,且m大于1。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the first preset ratio is 1:n:1, and n is greater than 1; the second preset ratio is 1:m:1, and m is greater than 1.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,确定二维码图像中疑似位置探测图形的中心位置,包括:确定行像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第一预设比例的第一像素排布;及确定列像素中第一类像素、第二类像素、第一类像素的顺序排布比例满足第二预设比例的第二像素排布;根据第一像素排布的中心点及第二像素排布的中心点,确定疑似位置探测图形的中心位置。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the center position of the suspected position detection pattern in the two-dimensional code image is determined, including: determining a first pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the row pixels meets a first preset ratio; and determining a second pixel arrangement in which the sequential arrangement ratio of the first type of pixels, the second type of pixels, and the first type of pixels in the column pixels meets a second preset ratio; and determining the center position of the suspected position detection pattern based on the center point of the first pixel arrangement and the center point of the second pixel arrangement.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,包括:从识别出的疑似位置探测图形中,确定符合第一筛选条件和/或第二筛选条件的疑似位置探测图形;其中,第一筛选条件包括在上述中心位置相邻的预设区域内,第一类像素和/或第二类像素的个数符合预设的阈值范围;第二筛选条件包括穿过中心位置的第三像素排布中的第一类像素、第二类像素、第一类像素、第二类像素、第一类像素的顺序排布比例满足第三预设比例;从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合二维码的定位规则的图形。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the computer executable instructions determine a graphic that meets the positioning rules of the two-dimensional code image from the identified suspected position detection graphics, including: determining a suspected position detection graphic that meets the first filtering condition and/or the second filtering condition from the identified suspected position detection graphics; wherein the first filtering condition includes that the number of first-class pixels and/or second-class pixels in a preset area adjacent to the above-mentioned center position meets a preset threshold range; the second filtering condition includes that the sequential arrangement ratio of first-class pixels, second-class pixels, first-class pixels, second-class pixels, and first-class pixels in the third pixel arrangement passing through the center position meets a third preset ratio; and determining a graphic that meets the positioning rules of the two-dimensional code from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition.
可选地,上述定位规则包括:三个位置探测图形的中心点的连线中,长度最短的两条连线垂直且长度相等,该存储介质存储的计算机可执行指令在被处理器执行时,从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,包括:从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;分别判断每组疑似位置探测图形是否满足上述定位规则;将满足上述定位规则的至少一组疑似位置探测图形作为二维码图像的位置探测图形。Optionally, the above-mentioned positioning rules include: among the lines connecting the center points of the three position detection graphics, the two shortest lines are perpendicular and of equal length. When the computer executable instructions stored in the storage medium are executed by the processor, the graphics that meet the positioning rules of the above-mentioned QR code are determined from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, including: from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition, multiple groups of suspected position detection graphics are formed in groups of three; each group of suspected position detection graphics is judged to determine whether it meets the above-mentioned positioning rules; and at least one group of suspected position detection graphics that meets the above-mentioned positioning rules is used as the position detection graphics of the QR code image.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,上述从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,确定符合上述二维码的定位规则的图形,包括:从符合第一筛选条件和/或第二筛选条件的疑似位置探测图形中,按照每三个一组的方式形成多组疑似位置探测图形;确定每组疑似位置探测图形中的三个疑似位置探测图形的中心点的连线构成的三角形的几何参数和三个疑似位置探测图形的面积的均差,其中,上述几何参数包括三角形中长度最短的两条连线的夹角值和长度最短的两条连线的长度差值;根据夹角值、长度差值和均差,确定符合二维码的定位规则的图形。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the above-mentioned determining of the graphics that meet the positioning rules of the above-mentioned QR code from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition includes: forming multiple groups of suspected position detection graphics in groups of three from the suspected position detection graphics that meet the first filtering condition and/or the second filtering condition; determining the geometric parameters of the triangle formed by the lines connecting the center points of the three suspected position detection graphics in each group of suspected position detection graphics and the average difference of the areas of the three suspected position detection graphics, wherein the above-mentioned geometric parameters include the angle value of the two shortest lines in the triangle and the length difference of the two shortest lines; determining the graphics that meet the positioning rules of the QR code based on the angle value, the length difference and the average difference.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,上述根据夹角值、长度差值和均差,确定符合上述二维码的定位规则的图形,包括:根据夹角值、长度差值和均差,通过如下公式计算每组疑似位置探测图形的得分;分别将每组疑似位置探测图形的得分与预设分值进行比较,根据比较结果确定符合二维码的定位规则的图形;Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the above-mentioned determining the graphics that meet the positioning rules of the above-mentioned two-dimensional code based on the angle value, length difference and average difference includes: calculating the score of each group of suspected position detection graphics according to the angle value, length difference and average difference by the following formula; comparing the score of each group of suspected position detection graphics with a preset score, and determining the graphics that meet the positioning rules of the two-dimensional code based on the comparison results;
其中,在上述公式中,a、b、c、d均为常量,xi表示的是第i组疑似位置探测图形的中心点的连线构成的三角形中长度最短的两条连线的夹角值,yi表示的是第i组疑似位置探测图形构成的三角形中长度最短的两条连线的长度差值,zi表示的是第i组疑似位置探测图形中的三个疑似位置探测图形的面积的均差,fi表示的是第i组疑似位置探测图形的得分。Wherein, in the above formula, a, b, c, and d are all constants, x i represents the angle between the two shortest lines in the triangle formed by the lines connecting the center points of the i-th group of suspected position detection figures, y i represents the difference in length between the two shortest lines in the triangle formed by the i-th group of suspected position detection figures, zi represents the average difference in the areas of the three suspected position detection figures in the i-th group of suspected position detection figures, and fi represents the score of the i-th group of suspected position detection figures.
进一步地,本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,一种具体的实施例中,该存储介质可以为U盘、光盘、硬盘等,该存储介质存储的计算机可执行指令在被处理器执行时,能实现以下流程:Furthermore, an embodiment of the present application further provides a storage medium for storing computer-executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
在含有第一类像素和第二类像素的二维码图像中,以预设的行像素探测规则及列像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述行像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第一预设阈值,上述列像素探测规则包括:连续排布的第一类像素或第二类像素的个数达到第二预设阈值;根据确定的上述疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;从识别出的疑似位置探测图形中,确定符合上述二维码图像的定位规则的图形,作为上述二维码图像的位置探测图形。In a two-dimensional code image containing first-category pixels and second-category pixels, the center position of the suspected position detection pattern in the above-mentioned two-dimensional code image is determined using preset row pixel detection rules and column pixel detection rules; wherein the above-mentioned row pixel detection rules include: the number of continuously arranged first-category pixels or second-category pixels reaches a first preset threshold, and the above-mentioned column pixel detection rules include: the number of continuously arranged first-category pixels or second-category pixels reaches a second preset threshold; according to the determined center position of the above-mentioned suspected position detection pattern, the corresponding suspected position detection pattern is identified; from the identified suspected position detection patterns, a pattern that meets the positioning rule of the above-mentioned two-dimensional code image is determined as the position detection pattern of the above-mentioned two-dimensional code image.
可选的,该存储介质存储的计算机可执行指令在被处理器执行时,上述第一预设阈值与第二预设阈值相等。Optionally, when the computer-executable instructions stored in the storage medium are executed by the processor, the first preset threshold is equal to the second preset threshold.
进一步地,本申请实施例还提供了一种存储介质,用于存储计算机可执行指令,一种具体的实施例中,该存储介质可以为U盘、光盘、硬盘等,该存储介质存储的计算机可执行指令在被处理器执行时,能实现以下流程:Furthermore, an embodiment of the present application further provides a storage medium for storing computer-executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
在含有第一类像素和第二类像素的二维码图像中,以预设的像素探测规则,确定上述二维码图像中的疑似位置探测图形的中心位置;其中,上述像素探测规则包括第一类像素、第二类像素、第一类像素的顺序排布比例满足预设比例;根据确定的疑似位置探测图形的中心位置识别出相应的疑似位置探测图形;从识别出的疑似位置探测图形中,确定符合二维码图像的定位规则的图形,作为二维码图像的位置探测图形。In a two-dimensional code image containing first-category pixels and second-category pixels, a preset pixel detection rule is used to determine the center position of a suspected position detection pattern in the above-mentioned two-dimensional code image; wherein the above-mentioned pixel detection rule includes that the sequential arrangement ratio of the first-category pixels, the second-category pixels, and the first-category pixels satisfies a preset ratio; according to the determined center position of the suspected position detection pattern, a corresponding suspected position detection pattern is identified; from the identified suspected position detection patterns, a pattern that meets the positioning rule of the two-dimensional code image is determined as the position detection pattern of the two-dimensional code image.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,上述预设比例为1:5:1。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the above preset ratio is 1:5:1.
可选地,该存储介质存储的计算机可执行指令在被处理器执行时,上述第一类像素为黑色像素或蓝色像素,第二类像素为与所述第一类像素的色差值超过设定阈值的像素。Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, the first type of pixels are black pixels or blue pixels, and the second type of pixels are pixels whose color difference value with the first type of pixels exceeds a set threshold.
本申请实施例中的存储介质存储的计算机指令在被执行后,首先根据第一类像素、第二类像素、第一类像素的排布比例或者连续排布的第一类像素的个数或者连续排布的第二类像素的个数,确定二维码的疑似位置探测图形,具有一定的容错性,这样即使在二维码的位置探测图形存在污损或者亮度较弱的情况下,也能识别出疑似位置探测图形,提高了疑似位置探测图形识别的有效性;另外,当通过上述方式识别出疑似位置探测图形后,再从识别出的疑似位置探测图形中确定出二维码的位置探测图形,准确性较高。After the computer instructions stored in the storage medium in the embodiment of the present application are executed, the suspected position detection pattern of the QR code is first determined based on the first-category pixels, the second-category pixels, the arrangement ratio of the first-category pixels, or the number of continuously arranged first-category pixels or the number of continuously arranged second-category pixels. It has a certain fault tolerance, so even if the position detection pattern of the QR code is damaged or the brightness is weak, the suspected position detection pattern can be identified, thereby improving the effectiveness of the suspected position detection pattern recognition; in addition, after the suspected position detection pattern is identified in the above manner, the position detection pattern of the QR code is determined from the identified suspected position detection pattern, with high accuracy.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures such as diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compilers used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There are not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and/or hardware.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt 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.) that contain computer-usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to the flow chart and/or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and/or box in the flow chart and/or block diagram and the combination of the flow process and/or box in the flow chart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and/or one box or multiple boxes of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(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.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。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. The 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 technology, 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 transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。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 a complete hardware embodiment, a complete 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.
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
Claims (23)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| HK18108715.7A HK1249245B (en) | 2018-07-05 | Qr code positioning method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| HK18108715.7A HK1249245B (en) | 2018-07-05 | Qr code positioning method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| HK1249245A1 HK1249245A1 (en) | 2018-10-26 |
| HK1249245B true HK1249245B (en) | 2021-04-16 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11194982B2 (en) | QR code positioning method and apparatus | |
| TWI716008B (en) | Face recognition method and device | |
| US7813553B2 (en) | Image region detection method, recording medium, and device therefor | |
| US10748023B2 (en) | Region-of-interest detection apparatus, region-of-interest detection method, and recording medium | |
| US11562551B1 (en) | Image analysis for decoding angled optical patterns | |
| TWI738026B (en) | Method and device for selecting target face from multiple faces and face recognition and comparison | |
| US12505556B2 (en) | Corner point detection method and apparatus | |
| JP6398335B2 (en) | Filtering method and filtering apparatus in image processing | |
| CN118015029A (en) | Method, device and storage medium for detecting corner points of tabs | |
| JP6106808B2 (en) | Specify barcode placement in document | |
| US11836218B2 (en) | System and method for object detection and dimensioning | |
| HK1249245B (en) | Qr code positioning method and device | |
| CN113496134A (en) | Two-dimensional code positioning method, device, equipment and storage medium | |
| AU2014277851A1 (en) | Detecting a gap between text columns from text line fragments | |
| HK1249245A1 (en) | Qr code positioning method and device | |
| CN115329795A (en) | Method and device for identifying two-dimensional code | |
| US11816878B1 (en) | Object detection in an image based on one or more oriented projection spaces | |
| CN112132141A (en) | Character merging method and device, electronic equipment and storage medium | |
| AU2015201663A1 (en) | Dewarping from multiple text columns | |
| CN115578606B (en) | Two-dimensional code identification method and device, computer equipment and readable storage medium | |
| CN110929708A (en) | Method, equipment and storage medium for identifying national flag in Thai identity card | |
| CN116820458A (en) | Interactive interface modeling method and device | |
| CN120411979A (en) | Image processing method, device and equipment | |
| CN118711107A (en) | Method, device and related products for detecting problematic elements of an object | |
| HK1247698B (en) | Image processing method and image processing device |