WO2022021687A1 - 快速响应码区域定位方法、电子设备及存储介质 - Google Patents

快速响应码区域定位方法、电子设备及存储介质 Download PDF

Info

Publication number
WO2022021687A1
WO2022021687A1 PCT/CN2020/130538 CN2020130538W WO2022021687A1 WO 2022021687 A1 WO2022021687 A1 WO 2022021687A1 CN 2020130538 W CN2020130538 W CN 2020130538W WO 2022021687 A1 WO2022021687 A1 WO 2022021687A1
Authority
WO
WIPO (PCT)
Prior art keywords
position detection
detection pattern
candidate
area
dark
Prior art date
Application number
PCT/CN2020/130538
Other languages
English (en)
French (fr)
Inventor
王亚楠
汪雪林
顾庆毅
Original Assignee
苏州中科全象智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏州中科全象智能科技有限公司 filed Critical 苏州中科全象智能科技有限公司
Publication of WO2022021687A1 publication Critical patent/WO2022021687A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K17/00Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations
    • G06K17/0022Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations arrangements or provisious for transferring data to distant stations, e.g. from a sensing device
    • G06K17/0025Methods or arrangements for effecting co-operative working between equipments covered by two or more of main groups G06K1/00 - G06K15/00, e.g. automatic card files incorporating conveying and reading operations arrangements or provisious for transferring data to distant stations, e.g. from a sensing device the arrangement consisting of a wireless interrogation device in combination with a device for optically marking the record carrier
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes

Definitions

  • the present application relates to the field of two-dimensional code image processing, for example, to a method for locating a region of a quick response code, an electronic device and a storage medium.
  • QR code is the abbreviation of Quick Response Code, and quick identification is the most prominent feature of QR code.
  • This matrix two-dimensional code not only has the advantages of long service life, easy printing and portability, but also has the advantages of high information density, small footprint, strong error correction ability, and can be arbitrarily Direction reading, good anti-counterfeiting, can include pictures, fingerprints, signatures, sounds and Chinese characters. Since its inception, QR codes have received close attention in various fields. Among related technologies, QR codes have been widely used in identity certification, media industry, electronic ticketing, logistics industry, manufacturing industry, etc.
  • Two-dimensional code reading methods are mainly divided into two categories, one is laser reading type, and the other is image reading type. Because the laser reading type is limited by the barcode format, its development space is becoming smaller and smaller. The image reading type has a lot of room for development because of its advantages of two-dimensional signal acquisition and the characteristics that it can be separated from the special reader.
  • the mainstream process of QR code image reading is: area positioning, area mapping to a standard QR structure, and decoding.
  • the location of the area is the basis and premise of QR code reading. Only when the QR area is accurately located can the code be read correctly. Therefore, the location of the area is a key step in QR code reading.
  • the symbol structure of the QR code includes three position detection patterns, which are specially designed for QR code area positioning.
  • the ratio of black and white width of the position detection pattern conforms to the characteristics of 1:1:3:1:1, that is, the width ratio of "black and white, black and white” is 1:1:3:1:1, and this feature It has the characteristic of not being deformed by rotation, as shown in Figure 3.
  • the positioning and correction method of the QR barcode is generally based on the contour image, and the four vertices of the QR code are first obtained through Hough transform. The image is then corrected by inverse perspective transformation.
  • QR code area localization algorithms firstly locate the QR area by first searching the position detection pattern through the whole image, and determining the corner points of the area.
  • the location of the location detection pattern is a key step in QR area localization. How to locate the location detection pattern quickly and efficiently is the focus of QR code area location research.
  • a method for quickly locating a QR code based on texture characteristics includes: determining the imaging quality of an image; dividing the image into blocks according to the imaging quality to obtain several sub-images; A candidate area is screened out from the sub-image; a growth area is obtained by using the candidate area; an affine rectangle is obtained according to the growth area; and a QR code is located according to the affine rectangle.
  • QR codes have strong edge gradient amplitudes and two approximately orthogonal principal directions. Using this property, QR code areas can be distinguished from non-QR code areas.
  • a method for quickly responding to QR code area positioning is disclosed.
  • the pixel points in the target image are filtered.
  • a QR code image positioning method based on the least squares method is disclosed.
  • the steps of the method are: binarizing the QR code image to obtain the binary image of the QR code image; performing mathematical morphological closure operations on the binary image of the QR code image to obtain the closure image of the QR code, Obtain the QR code area image; obtain the QR code outline; establish a rectangular coordinate system; calculate the minimum external moment of the QR code; determine the initial straight line;
  • the related technologies have at least the following deficiencies:
  • the present application provides a fast response code area positioning method, electronic equipment and storage medium, which can solve the geometric distortion of images caused by factors such as light existing in the related art, which in turn leads to poor stability of the results of the image binarization method and slow boundary changes.
  • the gradient calculation is easy to miss the edge, which leads to the technical problem of incomplete statistics of the light and dark width flow.
  • the present application provides a method for locating a quick response code area, including:
  • Step S001 determining the candidate area set of the first position detection pattern
  • Step S002 binarizing the input quick response code image to obtain a binarized image of the quick response code image
  • Step S003 determining the candidate area set of the second position detection pattern
  • Step S004 merging and optimizing the candidate area
  • Step S005 the candidate area is deduplicated
  • Step S006 filter and sort the position detection graph groupings.
  • Step S007 quick response code area correction and decoding
  • step S001 includes:
  • step S003 includes:
  • the set of candidate regions of the pattern includes a plurality of candidate regions of the position detection pattern
  • step S004 includes:
  • the candidate area set of the first position detection pattern obtained in step S001 is merged with the candidate area set of the second position detection pattern obtained in step S003 to obtain the candidate area set of the third position detection pattern.
  • the set of candidate regions includes candidate regions of a plurality of position detection patterns;
  • the candidate regions of the position detection patterns whose aspect ratios do not meet the conditions are filtered out from the candidate region set of the third position detection pattern to obtain the candidate region set of the fourth position detection pattern.
  • the candidate regions of the fourth position detection pattern the set includes candidate regions of a plurality of position detection patterns;
  • step S005 includes:
  • the repeated position detection pattern candidate regions For the repeated position detection pattern candidate regions, keep qualified position detection pattern candidate regions, and obtain a fifth position detection pattern candidate region set, where the fifth position detection pattern candidate region set includes a plurality of position detection pattern candidate regions. candidate area;
  • step S006 includes:
  • step S005 If the number of candidate position detection patterns in the candidate area set of the fifth position detection pattern obtained in step S005 is less than 3, it is considered that the positioning fails, and the process ends;
  • step S005 If the number of candidate position detection patterns in the candidate region set of the fifth position detection pattern obtained in step S005 is greater than or equal to 3, then perform group screening on the candidate regions of the position detection pattern in the candidate region set of the fifth position detection pattern to obtain the final The position detection pattern group, the final position detection pattern group includes 3 position detection patterns; And
  • step S007 includes:
  • the application also provides an electronic device, comprising:
  • the processor When the program is executed by the processor, the processor implements the method for locating the quick response code area as described above.
  • the present application also provides a computer-readable storage medium storing computer-executable instructions, where the computer-executable instructions are used to execute the method for locating a quick response code area as described above.
  • Fig. 1 is the symbol structure of QR code
  • Figure 2 is a QR code position detection graph
  • Fig. 3 is the rotated QR code position detection graph
  • Fig. 4 is the flow chart of the present application.
  • FIG. 5 is a schematic structural diagram of an electronic device provided by the present application.
  • 1-blank area 2-position detection pattern, 3-position detection pattern separator, 4-positioning image, 5-correction pattern, 6-format information, 7-version information, 8-data and error correction code word, 110-processor, 120-memory, 130-input device, 140-output device.
  • the present application provides a QR code area positioning method.
  • the image is scanned and calculated in the horizontal and vertical directions respectively, and the candidate regions of the position detection patterns obtained by the two are merged.
  • the candidate area of the position detection pattern is grouped, filtered and deduplicated, and a suitable position detection pattern is selected as the final available position detection pattern group, and is sorted, mapped and decoded.
  • the present application can solve images with uneven illumination that cannot be processed by binarization, and can also deal with relatively blurry situations that cannot be located by gradient calculation, and can achieve a more efficient and stable effect.
  • the present application provides a QR code area positioning method, including:
  • Step S001 the step of determining the candidate area set of the first position detection pattern:
  • the step of determining the candidate area set of the first position detection pattern includes:
  • Step S002 the input QR code image is binarized to obtain the binarized image of the QR code image
  • Step S003 the step of determining the candidate area set of the second position detection pattern:
  • the step of determining the candidate area set of the second position detection pattern includes:
  • Step S004 candidate area merge optimization:
  • the candidate area set of the first position detection pattern obtained in step S001 is merged with the candidate area set of the second position detection pattern obtained in step S003 to obtain the candidate area set of the third position detection pattern.
  • the candidate area set includes a plurality of candidate areas of the position detection pattern;
  • the candidate regions of the position detection patterns whose aspect ratios do not meet the conditions are filtered out from the candidate region set of the third position detection pattern, and the candidate region set of the fourth position detection pattern is obtained, and the candidate region set of the fourth position detection pattern includes: Candidate areas for multiple position detection patterns;
  • Step S005 the candidate area is deduplicated, including:
  • the repeated position detection pattern candidate area is determined
  • the repeated position detection pattern candidate regions For the repeated position detection pattern candidate regions, keep qualified position detection pattern candidate regions, and obtain a fifth position detection pattern candidate region set, where the fifth position detection pattern candidate region set includes multiple position detection pattern candidate regions ;
  • Step S006 the location detection graph grouping screening and sorting, including:
  • step S005 If the number of candidate position detection patterns in the candidate area set of the fifth position detection pattern obtained in step S005 is less than 3, it is considered that the positioning fails, and the process ends;
  • step S005 If the number of candidate position detection patterns in the candidate area set of the fifth position detection pattern obtained in step S005 is greater than or equal to 3, then:
  • the candidate regions of the position detection patterns in the candidate region set of the fifth position detection pattern are grouped and screened to obtain the final position detection pattern group, and the final position detection pattern group includes 3 position detection patterns;
  • Step S007 QR code area correction and decoding, including:
  • step S001 may include:
  • S010 Scan the input image row by row and column by column to obtain the grayscale values at each light and dark alternation of the image, and the grayscale values in each row and column respectively form a grayscale sequence of each row and each column;
  • x i is the gray value of the i-th pixel in each row or column
  • Diff2 i is the second-order difference of the ith pixel
  • S012 Determine that the positive side of the zero-cross point of the second-order difference is the dark area, and the negative side is the bright area, and record the jump position of the dark area in the bright area and the width of the dark area and the bright area as the light-dark width flow information ;
  • S013 Take five light and dark widths as a group for the light and dark width flows in the horizontal and vertical directions, respectively, and judge whether the five light and dark widths of each group in the horizontal and vertical directions satisfy the conditions.
  • the candidate area of the pattern is detected, and the candidate area set of the first position detection pattern and the center of the candidate area of each position detection pattern in the first location detection pattern candidate area set are determined accordingly.
  • step S003 may include:
  • S030 Scan the binarized image in the horizontal and vertical directions
  • S031 record the position of the black and white transition in the horizontal and vertical directions and the transition interval, and obtain the light and dark width flows in the horizontal and vertical directions of the binarized image respectively;
  • S032 Take five light and dark widths as a group for the light and dark width flows in the horizontal and vertical directions, respectively, and judge whether the five light and dark widths of each group in the horizontal and vertical directions meet the conditions. If both the horizontal and vertical directions meet the conditions, they are used as positions The candidate area of the detection pattern;
  • S033 The intersection of the horizontal and vertical directions satisfying the condition is used as the center of the candidate area of the position detection pattern
  • S034 According to the above-determined candidate area of the location detection pattern and the center of the candidate area of the location detection pattern, determine the candidate area set of the second location detection pattern and the candidate area of each location detection pattern in the second location detection pattern candidate area set. center.
  • judging whether the horizontal and vertical directions meet the conditions includes:
  • the light-dark width flow in the horizontal and vertical directions is divided into a group of 5 light-dark widths.
  • delta ⁇ deltaT the group of light-dark width flows is considered to meet the conditions
  • a1, a2, a3, a4 and a5 are the widths of each of the five light and dark widths
  • sum is the sum of 5 light and dark widths
  • delta is the deviation value of the light and dark width of the group
  • deltaT is the light-dark width deviation threshold.
  • the candidate region merging optimization described in step S004 includes:
  • the merging includes combining all position detection patterns. All light and dark widths in the horizontal and vertical directions of the candidate area of the graphic and the center position information of all the candidate areas of the position detection graphic form the candidate area information set of the position detection graphic;
  • the candidate regions of the position detection pattern whose aspect ratio is smaller than the lower threshold or greater than the upper threshold are filtered out from the candidate region set of the third position detection pattern to obtain the candidate region set of the fourth position detection pattern.
  • the candidate area deduplication in step S005 may include:
  • the candidate regions of the two position detection patterns are considered to be duplicate regions, and the candidate region of the position detection pattern with the smallest sum of deviations in the horizontal direction and the vertical direction is reserved, and a fifth position detection pattern is obtained. set of candidate regions.
  • the location detection pattern group screening in step S006 includes:
  • the candidate position detection patterns in the candidate area set of the fifth position detection pattern are arranged and combined every 3 as a group to obtain a plurality of available position detection pattern groups;
  • Each available position detection pattern group is judged as follows, and the available position detection pattern group that satisfies the following conditions is regarded as the final position detection pattern group:
  • W 1 , W 2 and W 3 are the widths of the three candidate position detection patterns respectively;
  • W avg is the average width of the three candidate position detection patterns
  • T1 is the width threshold.
  • step S006 includes:
  • the two-dimensional code area of the QR code is determined by point A, point B, and point C.
  • the binarization adopts the following method: an adaptive threshold method or a global threshold method.
  • step S001 may also be performed after S002 and S003. That is, in the present application, the input image may be binarized first, or gradient scanning may be performed first, and the two are in no particular order.
  • the present application provides a QR code area positioning method, including:
  • Step S001 the step of determining the candidate area set of the first position detection pattern:
  • the step of determining the candidate area set of the first position detection pattern includes:
  • Step S001 may include:
  • S010 Scan the input image row by row and column by column to obtain the grayscale value at each light and dark alternation of the image, and each grayscale value in each row and each column constitutes a grayscale sequence of each row and each column respectively;
  • x i is the gray value of the i-th pixel in each row or column
  • Diff2 i is the second-order difference of the ith pixel
  • S012 Determine that the positive side of the zero-cross point of the second-order difference is the dark area, and the negative side is the bright area, and record the jump position of the dark area in the bright area and the width of the dark area and the bright area as the light-dark width flow information ;
  • S013 Take five light and dark widths as a group for the light and dark width flows in the horizontal and vertical directions, respectively, and judge whether the five light and dark widths of each group in the horizontal and vertical directions meet the conditions.
  • the candidate area of the pattern is detected, and the candidate area set of the first position detection pattern and the center of the candidate area of each position detection pattern in the first location detection pattern candidate area set are determined accordingly.
  • the above-mentioned judging whether the horizontal and vertical directions satisfy the condition includes:
  • the light-dark width flow in the horizontal and vertical directions is divided into a group of 5 light-dark widths.
  • delta ⁇ deltaT the group of light-dark width flows is considered to meet the conditions
  • a1, a2, a3, a4 and a5 are the widths of each of the five light and dark widths
  • sum is the sum of 5 light and dark widths
  • delta is the deviation value of the light and dark width of the group
  • deltaT is the light-dark width deviation threshold.
  • Step S002 binarize the input QR code image to obtain a binarized image of the QR code image; the binarization adopts the following methods: an adaptive threshold method or a global threshold method.
  • Step S003 the step of determining the candidate area set of the second position detection pattern:
  • the step of determining the candidate area set of the second position detection pattern includes:
  • Step S003 may include:
  • S030 Scan the binarized image in the horizontal and vertical directions
  • S031 record the position of the black and white transition in the horizontal and vertical directions and the transition interval, and obtain the light and dark width flows in the horizontal and vertical directions of the binarized image respectively;
  • S032 Take five light and dark widths as a group for the light and dark width flows in the horizontal and vertical directions, respectively, and judge whether the five light and dark widths of each group in the horizontal and vertical directions meet the conditions. If both the horizontal and vertical directions meet the conditions, they are used as positions The candidate area of the detection pattern;
  • S033 The intersection of the horizontal and vertical directions satisfying the condition is used as the center of the candidate area of the position detection pattern
  • S034 According to the above-determined candidate area of the location detection pattern and the center of the candidate area of the location detection pattern, determine the candidate area set of the second location detection pattern and the candidate area of each location detection pattern in the second location detection pattern candidate area set. center.
  • the above-mentioned judging whether the horizontal and vertical directions satisfy the condition includes:
  • the light-dark width flow in the horizontal and vertical directions is divided into a group of 5 light-dark widths.
  • delta ⁇ deltaT the group of light-dark width flows is considered to meet the conditions
  • a1, a2, a3, a4 and a5 are the widths of each of the five light and dark widths
  • sum is the sum of 5 light and dark widths
  • delta is the deviation value of the light and dark width of the group
  • deltaT is the light-dark width deviation threshold.
  • step S001 can also be performed after S002 and S003, that is, in this application, the input image can be binarized first, or gradient scanning can be performed first, and the two are in no particular order.
  • Step S004 merging and optimizing the candidate area, including:
  • the candidate area set of the first position detection pattern obtained in step S001 is merged with the candidate area set of the second position detection pattern obtained in step S003 to obtain the candidate area set of the third position detection pattern.
  • the candidate area set includes a plurality of candidate areas of the position detection pattern;
  • the candidate regions of the position detection patterns whose aspect ratios do not meet the conditions are filtered out from the candidate region set of the third position detection pattern, and the candidate region set of the fourth position detection pattern is obtained, and the candidate region set of the fourth position detection pattern includes: Candidate areas for multiple position detection patterns;
  • Step S004 may include:
  • the merging includes combining all position detection patterns. All light and dark widths in the horizontal and vertical directions of the candidate area of the graphic and the center position information of all the candidate areas of the position detection graphic form the candidate area information set of the position detection graphic;
  • the candidate regions of the position detection pattern whose aspect ratio is smaller than the lower threshold or greater than the upper threshold are filtered out from the candidate region set of the third position detection pattern to obtain the candidate region set of the fourth position detection pattern.
  • Step S005 the candidate area is deduplicated, including:
  • the repeated position detection pattern candidate area is determined
  • the repeated position detection pattern candidate regions For the repeated position detection pattern candidate regions, keep qualified position detection pattern candidate regions, and obtain a fifth position detection pattern candidate region set, where the fifth position detection pattern candidate region set includes multiple position detection pattern candidate regions ;
  • Step S005 may include:
  • the candidate regions of the two position detection patterns are considered to be repeated regions, and the candidate region of the position detection pattern with the smallest sum of deviations in the horizontal direction and the vertical direction is reserved, and a fifth position detection pattern is obtained. set of candidate regions.
  • Step S006 the location detection graph grouping screening and sorting, including:
  • step S005 If the number of candidate position detection patterns in the candidate area set of the fifth position detection pattern obtained in step S005 is less than 3, it is considered that the positioning fails, and the process ends;
  • step S005 If the number of candidate position detection patterns in the candidate area set of the fifth position detection pattern obtained in step S005 is greater than or equal to 3, then:
  • the location detection pattern grouping screening includes:
  • the candidate position detection patterns in the candidate area set of the fifth position detection pattern are arranged and combined every 3 as a group to obtain a plurality of available position detection pattern groups;
  • Each available position detection pattern group is judged as follows, and the available position detection pattern group that satisfies the following conditions is regarded as the final position detection pattern group:
  • W 1 , W 2 and W 3 are the widths of the three candidate position detection patterns respectively;
  • W avg is the average width of the three candidate position detection patterns
  • T1 is the width threshold.
  • the position detection pattern sorting includes:
  • the two-dimensional code area of the QR code is determined by point A, point B, and point C.
  • Step S007 QR code area correction and decoding, including:
  • FIG. 5 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment. As shown in FIG. 5 , the electronic device includes: one or more processors 110 and a memory 120 . A processor 110 is taken as an example in FIG. 5 .
  • the electronic device may further include: an input device 130 and an output device 140 .
  • the processor 110 , the memory 120 , the input device 130 and the output device 140 in the electronic device may be connected by a bus or in other ways, and the connection by a bus is taken as an example in FIG. 5 .
  • the memory 120 can be configured to store software programs, computer-executable programs, and modules.
  • the processor 110 executes various functional applications and data processing by running the software programs, instructions and modules stored in the memory 120 to implement any one of the methods in the above embodiments.
  • the memory 120 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the electronic device, and the like.
  • the memory may include volatile memory such as random access memory (Random Access Memory, RAM), and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices.
  • RAM random access memory
  • non-volatile memory such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices.
  • Memory 120 may be a non-transitory computer storage medium or a transitory computer storage medium.
  • the non-transitory computer storage medium such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • memory 120 may optionally include memory located remotely from processor 110, which may be connected to the electronic device via a network. Examples of such networks may include the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the input device 130 may be configured to receive input numerical or character information, and to generate key signal input related to user settings and function control of the electronic device.
  • the output device 140 may include a display device such as a display screen.
  • This embodiment further provides a computer-readable storage medium storing computer-executable instructions, where the computer-executable instructions are used to execute the above method.
  • non-transitory computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a RAM, or the like.
  • the proportional condition is judged for the selected 5 light and dark width flows, and the position detection pattern is determined only when the deviation sum of each group is less than the preset value. candidate area, thereby reducing the impact of edge blur and image unevenness on positioning.
  • the present application merges the position detection pattern candidate regions obtained by binarization and gradient calculation, and retains the position detection pattern candidate region with the smallest deviation in the horizontal and vertical directions for the repeated regions, so that the determined position detection pattern candidate region is more Close to reality, it solves the problem of inaccurate positioning of images with uneven illumination by binarization and gradient calculation for relatively blurred situations.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Geometry (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • General Engineering & Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

本申请提供了一种快速响应码区域定位方法、电子设备及存储介质。所述方法包括:确定第一位置探测图形的候选区集合;对输入的快速响应码图像进行二值化,得到所述快速响应码图像的二值化图像;确定第二位置探测图形的候选区集合;候选区合并优化;候选区去重;位置探测图形分组筛选和排序;快速响应码区域矫正及解码。

Description

快速响应码区域定位方法、电子设备及存储介质
本公开要求在2020年07月29日提交中国专利局、申请号为202010742826.0的中国专利申请的优先权,以上申请的全部内容通过引用结合在本公开中。
技术领域
本申请涉及二维码图像处理领域,例如涉及一种快速响应码区域定位方法、电子设备及存储介质。
背景技术
QR码是快速响应码Quick Response Code的简称,快速识别是QR码最显著的特点。这种矩阵式二维码不仅具有使用寿命长、印制和携带方便等优点,而且还具有一维条码及其他二维条码无法实现的信息密度大、占用空间小、纠错能力强、可以任意方向读取、防伪性好、能包含图片、指纹、签字、声音和汉字等特点。自产生以来,QR码就受到各个领域的密切关注,相关技术中,QR码已广泛应用于身份证明、传媒行业、电子票务、物流行业、制造业等。
二维码的识读方式主要分为两类,一类是激光读取式,一类是图像读取式。激光读取式因为受限于条码的制式,其发展空间变得越来越小。图像读取式因其二维信号的获取优势和可脱离专用识读器的特点,具有很大的发展空间。
相关技术中,QR码图像读码的主流流程为:区域定位、区域映射到标准的QR结构、解码。其中区域的定位是QR码读码的基础和前提,只有准确定位到QR区域才有可能正确读码。因此区域的定位是QR码读码的关键步骤。
如附图1所示,QR码的符号结构中包括3个位置探测图形,此3个位置探测图形专为QR码区域定位设计。如附图2所示,位置探测图形的黑白宽度比例符合1:1:3:1:1的特点,即“黑白黑白黑”的宽度比例为1:1:3:1:1,并且该特征具有旋转不变形的特点,如附图3所示。
QR条码的定位与校正方法一般是在轮廓图像的基础上,先通过Hough变换获取QR码的四个顶点。然后通过反透视变换进行图像的校正。
相关技术中,主流的QR码区域定位算法大多是先通过全图搜索位置探测图形,确定区域的角点来定位QR区域。位置探测图形的定位是QR区域定位的关键步骤,如何快速高效的定位到位置探测图形是QR码区域定位研究的重点。
在中国专利申请文献CN109409163A中,公开了一种基于纹理特性的QR码快速定位方法,方法包括:确定图像的成像质量;根据所述成像质量,将图像分块,得到数个子图像;从数个所述子图像中筛选出候选区域;利用候选区域,得到生长区域;根据生长区域,得到仿射矩形;根据仿射矩形,定位QR码。QR码有较强的边缘梯度幅值和近似正交的两个主方向,利用这一性质,可区分QR码区域与非QR码区域。
在中国专利申请文献CN107025455B中,公开了一种快速反应QR码区域的定位方法,根据包含QR码区域的目标图像中每个像素点的像素值,对所述目标图像中的像素点进行过滤处理;对满足过滤处理条件的像素点进行聚类操作,确定多个聚类区域;其中,所述聚类区域中每两个像素点之间的距离不大于第一阈值;根据每个聚类区域的矩形度和旋转角度,从所述多个聚类区域中确定出备选的QR码定位符对应的聚类区域;根据所述QR码区域中每个QR码定位符之间的相对位置信息,从所述备选的QR码定位符对应的聚类区域中选取出QR码定位符对应的聚类区域;根据选取出的QR码定位符对应的聚类区域定位所述目标图像中的QR码区域。
在中国专利文献CN103177416B中,公开了一种基于最小二乘法的QR码图像定位方法。该方法的步骤为:对QR码图像进行二值化,得到QR码图像的二值图像;对QR码图像的二值图像进行数学形态学上的闭包运算,获取QR码的闭包图像,得到QR码区域图像;QR码轮廓获取;建立直角坐标系;计算QR码的最小外接矩;初始直线确定;直线平移;直线平移终止判断以及下边界 获取和左右边界获取。
相关技术至少存在以下不足:
1.采用图像二值化并进行扫描的方法,因为使用通用设备采集的条码图像,很容易受到光照不均和采集装置位置的影响,导致几何失真,因此二值化方法的处理结果无法保证稳定性。
2.梯度计算的方法,因为梯度在边界变化缓慢的地方,很容易漏掉相应的边缘,导致明暗宽度流统计的不完整。
发明内容
本申请提供一种快速响应码区域定位方法、电子设备及存储介质,可以解决相关技术中存在的光线等因素导致的图像几何失真,进而导致图像二值化方法结果稳定性差,以及边界变化缓慢使梯度计算易漏掉边缘,从而导致明暗宽度流统计不完整的技术问题。
本申请提供了一种快速响应码区域定位方法,包括:
步骤S001,确定第一位置探测图形的候选区集合;
步骤S002,对输入的快速响应码图像进行二值化,得到所述快速响应码图像的二值化图像;
步骤S003,确定第二位置探测图形的候选区集合;
步骤S004,候选区合并优化;
步骤S005,候选区去重;
步骤S006,位置探测图形分组筛选和排序;以及
步骤S007,快速响应码区域矫正及解码;
其中,步骤S001包括:
对输入的快速响应码图像进行逐行和逐列扫描,得到每个明暗交替处的灰 度值;
根据得到的每个明暗交替处的灰度值计算所述输入的快速响应码图像的梯度;以及
根据计算所得的梯度确定第一位置探测图形的候选区集合及所述第一位置探测图形候选区集合中每个位置探测图形的候选区的中心,所述第一位置探测图形的候选区集合包括多个位置探测图形的候选区;
其中,步骤S003包括:
在水平方向和垂直方向扫描步骤S002得到的二值化图像,得到水平方向和垂直方向的灰度值;
根据得到的水平方向和垂直方向的灰度值,确定所述二值化图像的明暗流宽度;以及
根据所述二值化图像的明暗流宽度确定第二位置探测图形的候选区集合及所述第二位置探测图形候选区集合中每个位置探测图形的候选区的中心,所述第二位置探测图形的候选区集合包括多个位置探测图形的候选区;
其中,步骤S004包括:
将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述第三位置探测图形的候选区集合包括多个位置探测图形的候选区;以及
从所述第三位置探测图形的候选区集合中过滤掉宽高比不符合条件的位置探测图形的候选区,得到第四位置探测图形的候选区集合,所述第四位置探测图形的候选区集合包括多个位置探测图形的候选区;
其中,步骤S005包括:
根据所述第四位置探测图形的候选区集合中每两个位置探测图形候选中心 距离,确定重复的位置探测图形候选区;以及
对于所述重复的位置探测图形候选区,保留符合条件的位置探测图形候选区,得到第五位置探测图形的候选区集合,所述第五位置探测图形的候选区集合包括多个位置探测图形的候选区;
其中,步骤S006包括:
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量小于3,则认为定位失败,结束流程;
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量大于等于3,则对所述第五位置探测图形的候选区集合中位置探测图形的候选区进行分组筛选,得到最终的位置探测图形组,所述最终的位置探测图形组包括3个位置探测图形;以及
对所述最终的位置探测图形组内的位置探测图形进行排序,确定快速响应码二维码区域;
其中,步骤S007包括:
将确定的快速响应码二维码区域矫正为标准快速响应码结构;以及
对矫正后的快速响应码进行解码。
本申请还提供了一种电子设备,包括:
处理器;
存储器,设置为存储程序,
当所述程序被所述处理器执行,使得所述处理器实现如上所述的快速响应码区域定位方法。
本申请还提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行如上所述的快速响应码区域定位方法。
附图说明
图1是QR码的符号结构;
图2是QR码位置探测图形;
图3是旋转后的QR码位置探测图形;
图4是本申请的流程图;
图5为本申请提供的一种电子设备的结构示意图。
其中,1-空白区,2-位置探测图形,3-位置探测图形分隔符,4-定位图像,5-矫正图形,6-格式信息,7-版本信息,8-数据和纠错码字,110-处理器,120-存储器,130-输入装置,140-输出装置。
具体实施方式
下面结合附图1-4,对本申请的具体实施方式作详细的说明。
本申请提供了一种QR码区域定位方法,通过结合二值化法和梯度算法对分别对图像进行水平和垂直方向的扫描和计算,将二者获取的位置探测图形候选区进行合并,对合并的位置探测图形候选区进行分组筛选、去重,并选取合适的位置探测图形作为最终的可用的位置探测图形组,并进行排序、映射和解码。本申请可以解决二值化处理不了的光照不均的图像,也可以处理梯度计算无法定位的相对模糊的情况,能够达到更加高效稳定的效果。
本申请提供了一种QR码区域定位方法,包括:
步骤S001,第一位置探测图形的候选区集合确定步骤:
所述第一位置探测图形的候选区集合的确定步骤包括:
对输入的QR码图像进行逐行和逐列扫描,得到每个明暗交替处的灰度值;
根据得到的每个明暗交替处的灰度值计算所述输入的QR码图像的梯度;
根据计算所得的梯度确定第一位置探测图形的候选区集合及第一位置探测图形候选区集合中各位置探测图形的候选区的中心,所述第一位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S002,对输入的QR码图像进行二值化,得到QR码图像的二值化图像;
步骤S003,第二位置探测图形的候选区集合确定步骤:
所述第二位置探测图形的候选区集合的确定步骤包括:
在水平方向和垂直方向扫描步骤S002得到的二值化图像,得到水平方向和垂直方向的灰度值;
根据得到的水平方向和垂直方向的灰度值,确定二值化图像的明暗流宽度;
根据二值化图像的明暗流宽度确定第二位置探测图形的候选区集合及第二位置探测图形候选区集合中各位置探测图形的候选区的中心,所述第二位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S004,候选区合并优化:
将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述第三位置探测图形的候选区集合包括多个位置探测图形的候选区;
从第三位置探测图形的候选区集合中过滤掉宽高比不符合条件的位置探测图形的候选区,得到第四位置探测图形的候选区集合,所述第四位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S005,候选区去重,包括:
根据第四位置探测图形的候选区集合中每两个位置探测图形候选中心距离,确定重复的位置探测图形候选区;
对于重复的位置探测图形候选区,保留符合条件的位置探测图形候选区,得到第五位置探测图形的候选区集合,所述第五位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S006,位置探测图形分组筛选和排序,包括:
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量小于3,则认为定位失败,结束流程;
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量大于等于3,则:
对第五位置探测图形的候选区集合中位置探测图形的候选区进行分组筛选,得到最终的位置探测图形组,所述最终的位置探测图形组包括3个位置探测图形;
对最终的位置探测图形组内的位置探测图形进行排序,确定QR码二维码区域;
步骤S007,QR码区域矫正及解码,包括:
将确定的QR码二维码区域矫正为标准QR码结构;
对矫正后的QR码进行解码。
作为可选实施方式,步骤S001可以包括:
S010:对输入图像进行逐行和逐列扫描,获得图像每个明暗交替处的灰度值,每行及每列中的各个灰度值分别组成每行和每列的灰度序列;
S011:分别计算每行之间及每列之间的灰度序列的二阶差分,公式如下:
Diff2 i=x i+1+x i-1-2*x i,     (1)
其中:
x i为每行或每列第i个像素的灰度值;
Diff2 i为第i个像素的二阶差分;
S012:确定二阶差分的零交叉点为正的一侧为暗区域,为负的一侧为明区域,记录明区域暗区域的跳变位置及暗区域和明区域的宽度作为明暗宽度流信息;
S013:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区,并以此确定第一位置探测图形的候选区集合及第一位置探测图形候选区集合中各位置探测图形的候选区的中心。
作为可选实施方式,步骤S003可以包括:
S030:在水平方向和垂直方向扫描二值化图像;
S031:记录水平和垂直方向黑白跳变的位置以及跳变的间隔,分别得到二值化图像的水平和垂直方向的明暗宽度流;
S032:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区;
S033:满足条件的水平和垂直方向的交叉点,作为位置探测图形的候选区的中心;
S034:根据上述确定的位置探测图形的候选区和位置探测图形的候选区的中心,确定第二位置探测图形的候选区集合及第二位置探测图形候选区集合中各位置探测图形的候选区的中心。
作为可选实施方式,判断水平和垂直方向是否满足条件包括:
对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,当delta<deltaT时,则认为该组明暗宽度流满足条件;
sum=a1+a2+a3+a4+a5;       (2)
Figure PCTCN2020130538-appb-000001
其中:
a1、a2、a3、a4和a5分别为5个明暗宽度中每个明暗宽度的宽度;
sum为5个明暗宽度的和;
delta为该组明暗宽度的偏差值;
deltaT为明暗宽度偏差阈值。
作为可选实施方式,步骤S004中所述候选区合并优化包括:
将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述合并包括将所有位置探测图形的候选区在水平和垂直方向的所有明暗宽度和所有位置探测图形的候选区的中心位置信息组成位置探测图形的候选区信息集合;
计算每个位置探测图形的候选区的宽高比;
设置宽高比的上限阈值和下限阈值;
从第三位置探测图形的候选区集合中过滤掉宽高比小于下限阈值或者大于上限阈值的位置探测图形的候选区,得到第四位置探测图形的候选区集合。
作为可选实施方式,步骤S005中所述候选区去重可以包括:
计算第四位置探测图形的候选区集合中每两个位置探测图形的候选区中心的距离;
如果所述距离比预设距离阈值小,则认为这两个位置探测图形的候选区是重复区域,并保留水平方向和垂直方向偏差之和最小的位置探测图形候选区, 得到第五位置探测图形的候选区集合。
作为可选实施方式,步骤S006中所述位置探测图形分组筛选包括:
计算第五位置探测图形的候选区集合中的每个候选位置探测图形的宽度,所述宽度为每个候选位置探测图形水平方向宽度和垂直方向宽度的平均值;
将第五位置探测图形的候选区集合中的候选位置探测图形每3个为一组排列组合,得到多个可用位置探测图形组;
分别对每个可用位置探测图形组进行如下判断,满足下面条件的可用位置探测图形组即作为最终的位置探测图形组:
W avg=(W 1+W 2+W 3)/3;     (4)
|W 1-W avg|+|W 2-W avg|+|W 3-W avg|<T 1;       (5)
其中:
W 1、W 2、W 3分别为三个候选位置探测图形的宽度;
W avg为三个候选位置探测图形的宽度平均值;
T 1为宽度阈值。
作为可选实施方式,步骤S006中所述排序包括:
计算最终的位置探测图形组内3个位置探测图形中两两中心位置的距离;
选择距离最大者作为QR码3个位置探测图形中构成斜边的两个点B和C,另一个点作为点A;
定义点A的顺时针方向的点为点C,逆时针方向的点为点B;
由点A、点B和点C确定QR码的二维码区域。
作为可选实施方式,所述二值化采用如下方法:自适应阈值法或全局阈值法。
作为可选实施方式,步骤S001还可以在S002和S003之后执行。即本申请中对输入的图像可以先进行二值化处理,也可以先进行梯度扫描,二者顺序不分先后。
实施例1
本申请提供了一种QR码区域定位方法,包括:
步骤S001,第一位置探测图形的候选区集合确定步骤:
所述第一位置探测图形的候选区集合的确定步骤包括:
对输入的QR码图像进行逐行和逐列扫描,得到每个明暗交替处的灰度值;
根据得到的每个明暗交替处的灰度值计算所述输入的QR码图像的梯度;
根据计算所得的梯度确定第一位置探测图形的候选区集合及第一位置探测图形候选区集合中各位置探测图形的候选区的中心,所述第一位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S001可以包括:
S010:对输入图像进行逐行和逐列扫描,获得图像每个明暗交替处的灰度值,每行及每列中的各个灰度值分别组成每行和每列的灰度序列;
S011:分别计算每行之间及每列之间的灰度序列的二阶差分,公式如下:
Diff2 i=x i+1+x i-1-2*x i,       (1)
其中:
x i为每行或每列第i个像素的灰度值;
Diff2 i为第i个像素的二阶差分;
S012:确定二阶差分的零交叉点为正的一侧为暗区域,为负的一侧为明区域,记录明区域暗区域的跳变位置及暗区域和明区域的宽度作为明暗宽度流信息;
S013:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区,并以此确定第一位置探测图形的候选区集合及第一位置探测图形候选区集合中各位置探测图形的候选区的中心。
在一实施例中,上述判断水平和垂直方向是否满足条件包括:
对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,当delta<deltaT时,则认为该组明暗宽度流满足条件;
sum=a1+a2+a3+a4+a5;       (2)
Figure PCTCN2020130538-appb-000002
其中:
a1、a2、a3、a4和a5分别为5个明暗宽度中每个明暗宽度的宽度;
sum为5个明暗宽度的和;
delta为该组明暗宽度的偏差值;
deltaT为明暗宽度偏差阈值。
步骤S002,对输入的QR码图像进行二值化,得到QR码图像的二值化图像;所述二值化采用如下方法:自适应阈值法或全局阈值法。
步骤S003,第二位置探测图形的候选区集合确定步骤:
所述第二位置探测图形的候选区集合的确定步骤包括:
在水平方向和垂直方向扫描步骤S002得到的二值化图像,得到水平方向和垂直方向的灰度值;
根据得到的水平方向和垂直方向的灰度值,确定二值化图像的明暗流宽度;
根据二值化图像的明暗流宽度确定第二位置探测图形的候选区集合及第二 位置探测图形候选区集合中各位置探测图形的候选区的中心,所述第二位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S003可以包括:
S030:在水平方向和垂直方向扫描二值化图像;
S031:记录水平和垂直方向黑白跳变的位置以及跳变的间隔,分别得到二值化图像的水平和垂直方向的明暗宽度流;
S032:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区;
S033:满足条件的水平和垂直方向的交叉点,作为位置探测图形的候选区的中心;
S034:根据上述确定的位置探测图形的候选区和位置探测图形的候选区的中心,确定第二位置探测图形的候选区集合及第二位置探测图形候选区集合中各位置探测图形的候选区的中心。
在一实施例中,上述判断水平和垂直方向是否满足条件包括:
对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,当delta<deltaT时,则认为该组明暗宽度流满足条件;
sum=a1+a2+a3+a4+a5;       (2)
Figure PCTCN2020130538-appb-000003
其中:
a1、a2、a3、a4和a5分别为5个明暗宽度中每个明暗宽度的宽度;
sum为5个明暗宽度的和;
delta为该组明暗宽度的偏差值;
deltaT为明暗宽度偏差阈值。
在本申请中,步骤S001还可以在S002和S003之后执行,即本申请中对输入的图像可以先进行二值化处理,也可以先进行梯度扫描,二者顺序不分先后
步骤S004,候选区合并优化,包括:
将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述第三位置探测图形的候选区集合包括多个位置探测图形的候选区;
从第三位置探测图形的候选区集合中过滤掉宽高比不符合条件的位置探测图形的候选区,得到第四位置探测图形的候选区集合,所述第四位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S004可以包括:
将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述合并包括将所有位置探测图形的候选区在水平和垂直方向的所有明暗宽度和所有位置探测图形的候选区的中心位置信息组成位置探测图形的候选区信息集合;
计算每个位置探测图形的候选区的宽高比;
设置宽高比的上限阈值和下限阈值;
从第三位置探测图形的候选区集合中过滤掉宽高比小于下限阈值或者大于上限阈值的位置探测图形的候选区,得到第四位置探测图形的候选区集合。
步骤S005,候选区去重,包括:
根据第四位置探测图形的候选区集合中每两个位置探测图形候选中心距离, 确定重复的位置探测图形候选区;
对于重复的位置探测图形候选区,保留符合条件的位置探测图形候选区,得到第五位置探测图形的候选区集合,所述第五位置探测图形的候选区集合包括多个位置探测图形的候选区;
步骤S005可以包括:
计算第四位置探测图形的候选区集合中每两个位置探测图形的候选区中心的距离;
如果所述距离比预设距离阈值小,则认为这两个位置探测图形的候选区是重复区域,并保留水平方向和垂直方向偏差之和最小的位置探测图形候选区,得到第五位置探测图形的候选区集合。
步骤S006,位置探测图形分组筛选和排序,包括:
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量小于3,则认为定位失败,结束流程;
若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量大于等于3,则:
对第五位置探测图形的候选区集合中位置探测图形的候选区进行分组筛选,得到最终的位置探测图形组,所述最终的位置探测图形组包括3个位置探测图形的候选区;
对最终的位置探测图形组内的位置探测图形进行排序,确定QR码二维码区域;
所述位置探测图形分组筛选包括:
计算第五位置探测图形的候选区集合中的每个候选位置探测图形的宽度,所述宽度为每个候选位置探测图形水平方向宽度和垂直方向宽度的平均值;
将第五位置探测图形的候选区集合中的候选位置探测图形每3个为一组排列组合,得到多个可用位置探测图形组;
分别对每个可用位置探测图形组进行如下判断,满足下面条件的可用位置探测图形组即作为最终的位置探测图形组:
W avg=(W 1+W 2+W 3)/3;        (4)
|W 1-W avg|+|W 2-W avg|+|W 3-W avg|<T 1;         (5)
其中:
W 1、W 2、W 3分别为三个候选位置探测图形的宽度;
W avg为三个候选位置探测图形的宽度平均值;
T 1为宽度阈值。
所述位置探测图形排序包括:
计算最终的位置探测图形组内3个位置探测图形中两两中心位置的距离;
选择距离最大者作为QR码3个位置探测图形中构成斜边的两个点B和C,另一个点作为点A;
定义点A的顺时针方向的点为点C,逆时针方向的点为点B;
由点A、点B和点C确定QR码的二维码区域。
步骤S007,QR码区域矫正及解码,包括:
将确定的QR码二维码区域矫正为标准QR码结构;
对矫正后的QR码进行解码。
图5是一实施例提供的一种电子设备的硬件结构示意图,如图5所示,该电子设备包括:一个或多个处理器110和存储器120。图5中以一个处理器110为例。
所述电子设备还可以包括:输入装置130和输出装置140。
所述电子设备中的处理器110、存储器120、输入装置130和输出装置140可以通过总线或者其他方式连接,图5中以通过总线连接为例。
存储器120作为一种计算机可读存储介质,可设置为存储软件程序、计算机可执行程序以及模块。处理器110通过运行存储在存储器120中的软件程序、指令以及模块,从而执行多种功能应用以及数据处理,以实现上述实施例中的任意一种方法。
存储器120可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据电子设备的使用所创建的数据等。此外,存储器可以包括随机存取存储器(Random Access Memory,RAM)等易失性存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件或者其他非暂态固态存储器件。
存储器120可以是非暂态计算机存储介质或暂态计算机存储介质。该非暂态计算机存储介质,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施例中,存储器120可选包括相对于处理器110远程设置的存储器,这些远程存储器可以通过网络连接至电子设备。上述网络的实例可以包括互联网、企业内部网、局域网、移动通信网及其组合。
输入装置130可设置为接收输入的数字或字符信息,以及产生与电子设备的用户设置以及功能控制有关的键信号输入。输出装置140可包括显示屏等显示设备。
本实施例还提供一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行上述方法。
上述实施例方法中的全部或部分流程可以通过计算机程序来执行相关的硬件来完成的,该程序可存储于一个非暂态计算机可读存储介质中,该程序在执 行时,可包括如上述方法的实施例的流程,其中,该非暂态计算机可读存储介质可以为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或RAM等。
与相关技术相对比,本申请具有如下优点:
(1)本申请在通过二值化和梯度计算获取位置探测图形候选区时,对于选取的5个明暗宽度流进行比例条件判断,每组偏差和小于预设值时,才确定为位置探测图形候选区,从而减小了边缘模糊和图像不均对定位造成的影响。
(2)本申请通过将二值化和梯度计算获取的位置探测图形候选区进行合并,对于重复区域,保留水平和垂直方向偏差最小的位置探测图形候选区,使确定的位置探测图形候选区更贴近于实际,解决了二值化处理光照不均的图像以及梯度计算对相对模糊的情况进行定位不准确的问题。
(3)本申请在位置探测图形筛选时,任意选取宽度偏差小于预设值的3个位置探测图形作为最终用于定位的3个位置探测图形,实现了减少漏识别的效果。

Claims (12)

  1. 一种快速响应码区域定位方法,所述快速响应码区域定位方法包括:
    步骤S001,确定第一位置探测图形的候选区集合;
    步骤S002,对输入的快速响应码图像进行二值化,得到所述快速响应码图像的二值化图像;
    步骤S003,确定第二位置探测图形的候选区集合;
    步骤S004,候选区合并优化;
    步骤S005,候选区去重;
    步骤S006,位置探测图形分组筛选和排序;以及
    步骤S007,快速响应码区域矫正及解码;
    其中,步骤S001包括:
    对输入的快速响应码图像进行逐行和逐列扫描,得到每个明暗交替处的灰度值;
    根据得到的每个明暗交替处的灰度值计算所述输入的快速响应码图像的梯度;以及
    根据计算所得的梯度确定第一位置探测图形的候选区集合及所述第一位置探测图形候选区集合中每个位置探测图形的候选区的中心,所述第一位置探测图形的候选区集合包括多个位置探测图形的候选区;
    其中,步骤S003包括:
    在水平方向和垂直方向扫描步骤S002得到的二值化图像,得到水平方向和垂直方向的灰度值;
    根据得到的水平方向和垂直方向的灰度值,确定所述二值化图像的明暗流宽度;以及
    根据所述二值化图像的明暗流宽度确定第二位置探测图形的候选区集合及 所述第二位置探测图形候选区集合中每个位置探测图形的候选区的中心,所述第二位置探测图形的候选区集合包括多个位置探测图形的候选区;
    其中,步骤S004包括:
    将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述第三位置探测图形的候选区集合包括多个位置探测图形的候选区;以及
    从所述第三位置探测图形的候选区集合中过滤掉宽高比不符合条件的位置探测图形的候选区,得到第四位置探测图形的候选区集合,所述第四位置探测图形的候选区集合包括多个位置探测图形的候选区;
    其中,步骤S005包括:
    根据所述第四位置探测图形的候选区集合中每两个位置探测图形候选中心距离,确定重复的位置探测图形候选区;以及
    对于所述重复的位置探测图形候选区,保留符合条件的位置探测图形候选区,得到第五位置探测图形的候选区集合,所述第五位置探测图形的候选区集合包括多个位置探测图形的候选区;
    其中,步骤S006包括:
    若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量小于3,则认为定位失败,结束流程;
    若步骤S005得到的第五位置探测图形的候选区集合中候选位置探测图形数量大于等于3,则对所述第五位置探测图形的候选区集合中位置探测图形的候选区进行分组筛选,得到最终的位置探测图形组,所述最终的位置探测图形组包括3个位置探测图形;以及
    对所述最终的位置探测图形组内的位置探测图形进行排序,确定快速响应 码二维码区域;
    其中,步骤S007包括:
    将确定的快速响应码二维码区域矫正为标准快速响应码结构;以及
    对矫正后的快速响应码进行解码。
  2. 根据权利要求1所述的快速响应码区域定位方法,步骤S001包括:
    S010:对输入图像进行逐行和逐列扫描,获得所述输入图像每个明暗交替处的灰度值,每行及每列中的每个灰度值分别组成每行和每列的灰度序列;
    S011:分别计算每行之间及每列之间的灰度序列的二阶差分,公式如下:
    Diff2 i=x i+1+x i-1-2*x i,     (1)
    其中:
    x i为每行或每列第i个像素的灰度值;
    Diff2 i为第i个像素的二阶差分;
    S012:确定所述二阶差分的零交叉点为正的一侧为暗区域,为负的一侧为明区域,记录明区域和暗区域的跳变位置及暗区域和明区域的宽度作为明暗宽度流信息;以及
    S013:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区,并以此确定第一位置探测图形的候选区集合及所述第一位置探测图形候选区集合中每个位置探测图形的候选区的中心。
  3. 根据权利要求1所述的快速响应码区域定位方法,步骤S003包括:
    S030:在水平方向和垂直方向扫描二值化图像;
    S031:记录水平和垂直方向黑白跳变的位置以及跳变的间隔,分别得到所 述二值化图像的水平和垂直方向的明暗宽度流;
    S032:对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,分别判断水平和垂直方向每组的5个明暗宽度是否满足条件,若水平和垂直方向都满足条件,则作为位置探测图形的候选区;
    S033:满足条件的水平和垂直方向的交叉点,作为位置探测图形的候选区的中心;以及
    S034:根据上述确定的位置探测图形的候选区和位置探测图形的候选区的中心,确定第二位置探测图形的候选区集合及第二位置探测图形候选区集合中每个位置探测图形的候选区的中心。
  4. 根据权利要求2或3所述的快速响应码区域定位方法,其中,判断水平和垂直方向是否满足条件包括:
    对水平和垂直方向的明暗宽度流分别以5个明暗宽度为一组,当delta<deltaT时,则认为该组明暗宽度流满足条件;
    sum=a1+a2+a3+a4+a5;      (2)
    Figure PCTCN2020130538-appb-100001
    其中:
    a1、a2、a3、a4和a5分别为5个明暗宽度中每个明暗宽度的宽度;
    sum为5个明暗宽度的和;
    delta为该组明暗宽度的偏差值;
    deltaT为明暗宽度偏差阈值。
  5. 根据权利要求1所述的快速响应码区域定位方法,其中,步骤S004包括:
    将步骤S001得到的第一位置探测图形的候选区集合与步骤S003得到的第 二位置探测图形的候选区集合进行合并,得到第三位置探测图形的候选区集合,所述合并包括将所有位置探测图形的候选区在水平和垂直方向的所有明暗宽度和所有位置探测图形的候选区的中心位置信息组成位置探测图形的候选区信息集合;
    计算每个位置探测图形的候选区的宽高比;
    设置宽高比的上限阈值和下限阈值;以及
    从所述第三位置探测图形的候选区集合中过滤掉宽高比小于下限阈值或者大于上限阈值的位置探测图形的候选区,得到第四位置探测图形的候选区集合。
  6. 根据权利要求1所述的快速响应码区域定位方法,其中,步骤S005包括:
    计算所述第四位置探测图形的候选区集合中每两个位置探测图形的候选区中心的距离;以及
    如果所述距离比预设距离阈值小,则认为这两个位置探测图形的候选区是重复区域,并保留水平方向和垂直方向偏差之和最小的位置探测图形候选区,得到第五位置探测图形的候选区集合。
  7. 根据权利要求1所述的快速响应码区域定位方法,其中,步骤S006包括:
    计算第五位置探测图形的候选区集合中的每个候选位置探测图形的宽度,所述宽度为每个候选位置探测图形水平方向宽度和垂直方向宽度的平均值;
    将所述第五位置探测图形的候选区集合中的候选位置探测图形每3个为一组排列组合,得到多个可用位置探测图形组;以及
    分别对每个可用位置探测图形组进行如下判断,满足下面条件的可用位置探测图形组即作为最终的位置探测图形组:
    W avg=(W 1+W 2+W 3)/3;    (4)
    |W 1-W avg|+|W 2-W avg|+|W 3-W avg|<T 1;    (5)
    其中:
    W 1、W 2、W 3分别为三个候选位置探测图形的宽度;
    W avg为三个候选位置探测图形的宽度平均值;
    T 1为宽度阈值。
  8. 根据权利要求1所述的快速响应码区域定位方法,其中,步骤S006包括:
    计算最终的位置探测图形组内3个位置探测图形中两两中心位置的距离;
    选择距离最大者作为快速响应码3个位置探测图形中构成斜边的两个点B和C,另一个点作为点A;
    定义点A的顺时针方向的点为点C,逆时针方向的点为点B;以及
    由点A、点B和点C确定快速响应码的二维码区域。
  9. 根据权利要求1所述的快速响应码区域定位方法,其中,所述二值化采用自适应阈值法或全局阈值法。
  10. 根据权利要求1所述的快速响应码区域定位方法,其中,步骤S001在S002和S003之后执行。
  11. 一种电子设备,包括:
    处理器;
    存储器,设置为存储程序,
    当所述程序被所述处理器执行,使得所述处理器实现如权利要求1-10中任一所述的快速响应码区域定位方法。
  12. 一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行如权利要求1-10任一所述的快速响应码区域定位方法。
PCT/CN2020/130538 2020-07-29 2020-11-20 快速响应码区域定位方法、电子设备及存储介质 WO2022021687A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010742826.0 2020-07-29
CN202010742826.0A CN111815725B (zh) 2020-07-29 2020-07-29 一种qr码区域定位方法

Publications (1)

Publication Number Publication Date
WO2022021687A1 true WO2022021687A1 (zh) 2022-02-03

Family

ID=72864323

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/130538 WO2022021687A1 (zh) 2020-07-29 2020-11-20 快速响应码区域定位方法、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN111815725B (zh)
WO (1) WO2022021687A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111815725B (zh) * 2020-07-29 2024-03-08 苏州中科全象智能科技有限公司 一种qr码区域定位方法
CN114662519B (zh) * 2022-05-24 2022-09-27 武汉朗修科技有限公司 基于位置探测图形梯度和强度先验的qr码盲去模糊方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130153663A1 (en) * 2011-12-20 2013-06-20 Yang Yang Method and Apparatus for Locating Bar Codes Including QR Codes
CN104700062A (zh) * 2015-03-20 2015-06-10 中国联合网络通信集团有限公司 一种识别二维码的方法及设备
CN107025455A (zh) * 2017-04-01 2017-08-08 浙江华睿科技有限公司 一种快速反应qr码区域的定位方法及装置
CN111815725A (zh) * 2020-07-29 2020-10-23 苏州中科全象智能科技有限公司 一种qr码区域定位方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5507134B2 (ja) * 2009-07-03 2014-05-28 株式会社富士通コンピュータテクノロジーズ 2次元コード読取方法、2次元コード認識方法及び2次元コード読取装置
CN105069394B (zh) * 2015-07-23 2017-10-10 福建联迪商用设备有限公司 二维码加权平均灰度法解码方法及系统
CN106485183B (zh) * 2016-07-14 2018-05-08 深圳市华汉伟业科技有限公司 一种二维码定位方法及系统
CN107679436B (zh) * 2017-09-04 2020-04-28 华南理工大学 一种适用于弯曲形变二维码的图像修正方法
CN110414292A (zh) * 2018-04-27 2019-11-05 刘晓玲 一种二维码检测算法
CN109409163B (zh) * 2018-11-12 2022-04-01 凌云光技术股份有限公司 一种基于纹理特性的qr码快速定位方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130153663A1 (en) * 2011-12-20 2013-06-20 Yang Yang Method and Apparatus for Locating Bar Codes Including QR Codes
CN104700062A (zh) * 2015-03-20 2015-06-10 中国联合网络通信集团有限公司 一种识别二维码的方法及设备
CN107025455A (zh) * 2017-04-01 2017-08-08 浙江华睿科技有限公司 一种快速反应qr码区域的定位方法及装置
CN111815725A (zh) * 2020-07-29 2020-10-23 苏州中科全象智能科技有限公司 一种qr码区域定位方法

Also Published As

Publication number Publication date
CN111815725A (zh) 2020-10-23
CN111815725B (zh) 2024-03-08

Similar Documents

Publication Publication Date Title
CN110309687B (zh) 一种二维码图像的校正方法及校正装置
CN109086714B (zh) 表格识别方法、识别系统及计算机装置
US10095903B2 (en) Block decoding method and system for two-dimensional code
CN105989317B (zh) 一种二维码的识别方法及装置
CN107633192B (zh) 一种基于机器视觉的复杂背景下条形码分割与识读方法
RU2678485C1 (ru) Способ сегментации и распознавания символов
CN106960208B (zh) 一种仪表液晶数字自动切分和识别的方法及系统
CN112686812B (zh) 银行卡倾斜矫正检测方法、装置、可读存储介质和终端
Gu et al. QR code recognition based on image processing
US7636483B2 (en) Code type determining method and code boundary detecting method
TWI676936B (zh) 條碼偵測方法及條碼偵測系統
WO2022021687A1 (zh) 快速响应码区域定位方法、电子设备及存储介质
CN110647882A (zh) 图像校正方法、装置、设备及存储介质
CN105844277B (zh) 标签识别方法和装置
CN109190742B (zh) 一种基于灰度特征的编码特征点的解码方法
CN111353961A (zh) 一种文档曲面校正方法及装置
WO2022121025A1 (zh) 证件增减类别检测方法、装置、可读存储介质和终端
CN110598566A (zh) 图像处理方法、装置、终端和计算机可读存储介质
CN113903024A (zh) 一种手写票据数值信息识别方法、系统、介质及装置
CN110569845A (zh) 一种试卷图像的校正方法及相关装置
CN109784328B (zh) 定位条码的方法、终端及计算机可读存储介质
CN112699704B (zh) 一种条形码的检测方法、装置、设备、存储装置
CN111178111A (zh) 二维码检测方法、电子设备、存储介质及系统
CN115205562B (zh) 一种基于特征点的任意试卷配准方法
CN115880683A (zh) 一种基于深度学习的城市内涝积水智能水位检测方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20947157

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20947157

Country of ref document: EP

Kind code of ref document: A1