WO2020119301A1 - Two-dimensional code identification method, apparatus, and device - Google Patents

Two-dimensional code identification method, apparatus, and device Download PDF

Info

Publication number
WO2020119301A1
WO2020119301A1 PCT/CN2019/114218 CN2019114218W WO2020119301A1 WO 2020119301 A1 WO2020119301 A1 WO 2020119301A1 CN 2019114218 W CN2019114218 W CN 2019114218W WO 2020119301 A1 WO2020119301 A1 WO 2020119301A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
dimensional code
recognized
unit
specified number
Prior art date
Application number
PCT/CN2019/114218
Other languages
French (fr)
Chinese (zh)
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 WO2020119301A1 publication Critical patent/WO2020119301A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image

Definitions

  • One or more embodiments of this specification relate to the field of image recognition, and in particular, to a two-dimensional code recognition method, device, and equipment.
  • a two-dimensional code (2-dimensional bar code) is a bar code that records information by graphs distributed in a two-dimensional direction on a plane according to certain rules.
  • QR two-dimensional code is the most common.
  • the QR two-dimensional code has three patterns resembling "back" characters for positioning (hereinafter referred to as backword features), which are located in the upper left corner, upper right corner, and lower left corner of the two-dimensional code, respectively.
  • the recognition method can be as follows: the image processing technology is used to search for the three linguistic features of the two-dimensional code in the image to be recognized. According to the number and location of the backtracking features, the normal image to be recognized is restored. Then through the binarization method, it is converted into a binarization lattice. Finally, the character content implied by the dot matrix is parsed according to the standard grammar of the QR code.
  • the to-be-recognized image is not perfect, for example, the lingering feature of the two-dimensional code in the to-be-recognized image is greatly deformed, blocked, or the to-be-recognized image is a large-angle image.
  • One or more embodiments of this specification describe a two-dimensional code identification method, device, and equipment, which can accurately identify two-dimensional codes in imperfect images.
  • a two-dimensional code recognition method including:
  • the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm
  • the image correction includes at least a perspective transformation
  • a two-dimensional code identification device including:
  • An obtaining unit used to obtain an image to be recognized
  • the detection unit is configured to detect a specified number of corner points of the two-dimensional code in the image to be recognized according to a deep learning detection algorithm when the image to be recognized acquired by the acquisition unit includes a two-dimensional code ;
  • a determining unit configured to determine a target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points detected by the detecting unit;
  • a correction unit configured to perform image correction on the target area determined by the determination unit to obtain a corrected image; the image correction includes at least perspective transformation;
  • the identification unit is used for performing two-dimensional code identification on the image corrected by the correction unit.
  • a two-dimensional code identification device including:
  • One or more processors are One or more processors.
  • One or more programs wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and when the programs are executed by the processors, the following steps are implemented:
  • the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm
  • the image correction includes at least perspective transformation
  • the two-dimensional code recognition method, device and equipment provided in one or more embodiments of this specification acquire images to be recognized.
  • the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm.
  • the target area where the two-dimensional code is located in the image to be identified is determined.
  • the image correction here may include at least perspective transformation.
  • Figure 1 is a schematic diagram of the two-dimensional code recognition system provided by this specification.
  • FIG. 2 is a flowchart of a two-dimensional code recognition method provided by an embodiment of the present specification
  • Figure 3 is a schematic diagram of the two-dimensional code provided by this specification.
  • FIG. 5 is a schematic diagram of corners of a two-dimensional code provided by this specification.
  • Figure 6a is a schematic diagram of the corrected image provided by this specification.
  • 6b is a schematic diagram of a contrast-enhanced image provided by this specification.
  • 6c is a schematic diagram of a binary image provided by the specification.
  • FIG. 7 is a schematic diagram of a two-dimensional code recognition device provided by an embodiment of the present specification.
  • FIG. 8 is a schematic diagram of a two-dimensional code identification device provided by an embodiment of the present specification.
  • the acquired image of the two-dimensional code to be recognized (referred to as the image to be recognized for short) is usually not a perfect image.
  • traditional methods usually design complex multi-feature fusion logic, that is, the complexity of traditional two-dimensional code recognition methods is usually relatively high.
  • the QR code here can refer to PDF417 QR code, Datamatrix QR code and QR QR code. In the following description of this specification, a QR two-dimensional code is used as an example for description.
  • the present application is based on a deep learning detection algorithm to determine the two-dimensional code area of the image to be recognized, and then correct and identify the two-dimensional code area.
  • the deep learning detection algorithm is a relatively computationally intensive algorithm, so it is necessary to minimize unnecessary input.
  • One implementation idea may be: first determine whether the image to be recognized contains a two-dimensional code, and then input the deep learning detection algorithm only when it is determined that the image contains a two-dimensional code.
  • the process of determining the confidence of the above-mentioned back word feature may be as follows: the center point of the back word feature is used as a starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the back word feature. The gray histogram statistics are performed on the regular rectangular area. If the statistical gray-scale histogram is a bimodal histogram, the confidence of the Huizi feature is relatively high, otherwise the confidence of the Huizi feature is relatively low.
  • an attempt can be made to detect 3 ideal linguistic features in the image to be recognized. If the 3 ideal linguistic features are detected, it can also be determined that the image to be recognized contains a two-dimensional code.
  • picture correction is usually a time-consuming process, and because we are ultimately trying to recognize the two-dimensional code in the recognized image, in order to speed up the correction efficiency of the image to be recognized, we can consider only the two Dimension code area for correction. So how to determine and recognize the two-dimensional code area from the image to be recognized?
  • One implementation idea may be that, according to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code are detected in the image to be recognized. According to the position coordinates of the specified number of corner points, the two-dimensional code area in the image to be recognized is determined. It should be noted that the above-mentioned deep learning detection algorithm may be obtained by training a plurality of images of a specified number of corner points of a pre-calibrated two-dimensional code.
  • Another implementation idea may be that the two-dimensional code area is determined according to the positions of the three ideal ligature features detected in the image to be recognized.
  • the specified number of corner points of the two-dimensional code can be detected. Therefore, based on the coordinates of the specified number of corner points, image correction processing such as perspective transformation and lens distortion correction can be simultaneously performed on the two-dimensional code area.
  • image correction processing such as perspective transformation and lens distortion correction
  • multiple writing of image data in the memory can be avoided, which can greatly improve the correction efficiency of the image, thereby further improving the recognition efficiency of the two-dimensional code.
  • FIG. 1 is a schematic diagram of a two-dimensional code recognition system provided by this specification.
  • the two-dimensional code recognition system 10 may include: a feature detection module 102, a corner detection module 104, an image correction module 106, and a recognition module 108.
  • the feature detection module 102 is used to detect a back word feature with relatively high confidence in the image to be recognized.
  • the hyphen feature here has the following characteristics: the length ratio of line segments composed of black and white pixels is 1:1:3:1:1. Using this feature, the Huizi feature can be recognized in the image to be recognized. The determination of the confidence level of the above-mentioned back word feature is as described above and will not be repeated here.
  • the corner detection module 104 is configured to detect a specified number of corners of the two-dimensional code in the image to be recognized including the two-dimensional code.
  • the to-be-recognized image containing the two-dimensional code here may refer to the to-be-recognized image that has detected a character with high confidence.
  • the corner detection module 104 can specifically detect the specified number of corners of the two-dimensional code through a deep learning detection algorithm.
  • the image correction module 106 is used to perform image correction on the area (that is, the two-dimensional code area) determined by the position coordinates of the specified number of corner points.
  • the image correction here may include but is not limited to perspective transformation and lens distortion correction. It should be noted that, due to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code can be detected. Therefore, based on the specified number of corner points, two-dimensional code regions can be simultaneously subjected to perspective transformation and lens distortion correction, which can greatly improve the efficiency of image correction.
  • the recognition module 108 is used to recognize the two-dimensional code area after image correction. For example, identify and output the content contained in the QR code.
  • the above two-dimensional code recognition system may further include a contrast enhancement module 110.
  • the contrast enhancement module 110 is used to enhance the contrast of the image-corrected two-dimensional code region by using a local histogram method, so that a better contrast can be obtained.
  • a binarization module 112 may also be included.
  • the binarization module 112 is used to perform binarization processing on the image-corrected two-dimensional code region or the contrast-enhanced two-dimensional code region, thereby making the two-dimensional code region easier to recognize.
  • the execution subject of the method may be a device with processing capabilities: a server or a system or an apparatus, for example, it may be a two-dimensional code recognition system in FIG. 1.
  • the method may specifically include:
  • Step 202 Acquire an image to be recognized.
  • the image to be recognized may be obtained through the camera of the terminal device, and the terminal device here may refer to a smartphone, tablet computer, digital camera, or other similar terminal device.
  • the image to be recognized may be processed in grayscale to obtain a grayscale image.
  • the value range of the gray value (referred to as the pixel value) of the pixels in the gray image may be: [0,255].
  • the following determination step of whether a two-dimensional code is included may be performed. This step may be specifically performed by the feature detection module 102, which may specifically include:
  • Step a Perform feature detection on the gray-scale image to detect whether the image to be recognized contains linguistic features.
  • the syllable feature in this specification has the characteristics of 1:1:3:1:1, so the aforementioned syllable feature can be detected based on this feature.
  • the image to be recognized is relatively perfect, it is usually possible to detect three back features.
  • the ideal three ligature features cannot be detected, but a single ligature feature can usually be detected.
  • the method for judging whether a two-dimensional code is included in the embodiment of the specification has high robustness. Taking the two-dimensional code shown in FIG. 3 as an example, the back word feature in the upper left corner can be detected.
  • step b if the lingering feature is detected, the center point of the lingering feature is used as a starting point, and a number of pixels are expanded to the surrounding area to obtain a regular rectangular area containing the lingering feature.
  • “surrounding” may refer to the four directions of the back character feature, so the above expansion operation is to extend several pixels in the four directions of the back character feature, respectively.
  • the number of pixels expanded in each direction is determined by the size of the back word feature.
  • the number of the extended pixels may be: 1*8, which is set to 8 here because the final rectangular area obtained needs to include a back word feature (that is, greater than 7 dot-matrix units),
  • the 1 here represents the aforementioned 1 pixel.
  • the 8 in the formula can also be replaced by any number greater than 8, which is not limited in this manual.
  • Step c Perform gray histogram statistics on the positive rectangular area.
  • the horizontal coordinate of the grayscale histogram here can be different pixel values contained in the regular rectangular area.
  • the value range of the pixel value here is: [0,255], and the vertical coordinate is the number of different pixel values .
  • Step d If the statistical grayscale histogram is a bimodal histogram, it is determined that the image to be recognized contains a two-dimensional code.
  • steps b-d may be performed when the ideal three syllable features cannot be detected. If three ideal linguistic features can be detected through step a, it can be directly judged that the image to be recognized contains a two-dimensional code without performing steps b-d, which is not limited in this specification.
  • a method for determining whether a two-dimensional code is included in an image to be recognized by detecting a single linguistic feature with high confidence can reduce the misrecognition rate of whether a two-dimensional code is included.
  • Step 204 When the image to be recognized contains a two-dimensional code, detect the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm.
  • the corner detection module 104 detects the specified number of corners of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm.
  • the deep learning detection algorithm can detect the specified number of corners of the two-dimensional code, before performing step 204 in this embodiment of the present specification, the following two may also be performed:
  • the judgment steps of the dimension code include:
  • Get the size of the back word feature Convert the size of the QR code according to the preset conversion rules and the size of the back word feature. If the size of the two-dimensional code does not satisfy the preset condition, the region to be recognized centered on the character back is extracted from the image to be recognized. Enlarge the area to be identified.
  • the above-mentioned preset conversion rule can also be set to other algorithms, for example, the size of the back word feature is enlarged by a preset multiple to determine the size of the two-dimensional code, which is not limited in this specification.
  • FIG. 4 shows a schematic diagram of an enlargement process of an area to be recognized.
  • the character-return feature can be extracted from the image to be recognized as
  • the size of the area to be recognized in the center may be 400*400, and then the 400*400 area to be recognized is enlarged.
  • step 204 may be replaced by: detecting the specified number of corner points of the two-dimensional code in the enlarged area to be recognized according to the deep learning detection algorithm.
  • the specified number of corner points in step 204, or in the step after the replacement may refer to 4 corner points of the two-dimensional code. Taking FIG. 3 as an example, the detected four corner points may be as shown in FIG. 5.
  • the deep learning detection algorithm in this specification may be obtained by training a plurality of images of a specified number of corner points of a pre-calibrated two-dimensional code.
  • the human eye's ability to perceive the corners of the two-dimensional code can be simulated, thereby obtaining higher robustness.
  • the algorithm can also be updated faster through deep learning fine tuning.
  • the single-word-return feature detected with high confidence in this specification can be used not only to determine whether the image to be recognized contains a two-dimensional code, but also to convert the size of the two-dimensional code.
  • the surrounding area of the back word feature can be enlarged, thereby improving the success rate of detecting the corner points of the two-dimensional code.
  • the enlarged area can also be understood as the coarse positioning of the two-dimensional code, and this coarse positioning method can reduce the search space of the deep learning detection algorithm.
  • the embodiment of this specification uses a deep learning detection algorithm to determine the two-dimensional code area compared with the traditional method (that is, based on three ideal ligature features to locate the two-dimensional code area), the method has better Greatness.
  • the deep learning detection algorithm provided by the embodiments of the present specification can accurately locate the two-dimensional code area even when the traverse feature of the two-dimensional code is deformed, blocked, or the image to be recognized is a large-angle image.
  • Step 206 Determine the target area where the two-dimensional code is located in the image to be recognized according to the position coordinates of the specified number of corner points.
  • the target area determined in this step may be a rectangular area composed of four corner points in the figure.
  • Step 208 Perform image correction on the target area to obtain a corrected image.
  • the image correction module 108 may perform the above steps 206 and 208.
  • the corrected image as shown in FIG. 6a can be obtained.
  • the above image correction may include at least perspective transformation.
  • lens distortion correction can also be included. It should be noted that, since step 4 can already determine the four corner points of the target area, this step can directly perform perspective transformation. There is no need to perform lens distortion correction on the target area to determine the four corner points of the target area, and then perform perspective transformation on it. In one implementation, when lens distortion correction is also performed on the target area, the lens distortion correction and perspective transformation can be performed simultaneously, that is, only image data needs to be written to the memory once, thereby greatly improving the efficiency of image correction .
  • the lens distortion correction is a non-linear change, it is very resource intensive. Therefore, in this step, only the image correction is performed on the target area, and the image correction is not performed on the entire image to be recognized, which can greatly reduce the amount of calculation.
  • Step 210 perform two-dimensional code recognition on the corrected image.
  • the recognition module 108 may perform two-dimensional code recognition on the corrected image.
  • the embodiments of the present specification may also perform image processing steps such as contrast enhancement and binarization on the corrected image.
  • image processing steps such as contrast enhancement and binarization
  • the local histogram method is first used to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image.
  • the enhanced image is binarized to obtain a binarized image.
  • two-dimensional code recognition is performed on the binary image.
  • FIG. 6a after performing contrast enhancement processing on it, a contrast enhanced image as shown in FIG. 6b can be obtained. After that, when the image shown in FIG. 6b is binarized, the binarized image shown in FIG. 6c can be obtained.
  • the two-dimensional code recognition method determines whether the two-dimensional code is included in the image to be recognized by detecting a single ligature feature with high confidence. Discard the to-be-recognized images that do not contain the two-dimensional code, so that all images can be prevented from going through a deep learning detection algorithm that is relatively computationally intensive. In addition, through the single-word-back feature with high confidence, coarse positioning of the two-dimensional code can also be achieved, so that when the size of the two-dimensional code does not meet the preset conditions, the back-characteristic feature is used as the center to determine the surrounding area. To zoom in.
  • an embodiment of this specification also provides a two-dimensional code recognition device.
  • the device may include:
  • the obtaining unit 702 is used to obtain an image to be recognized.
  • the detection unit 704 is configured to detect a specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm when the image to be recognized acquired by the acquisition unit 702 includes the two-dimensional code.
  • the function of the detection unit 704 can be realized by the corner detection module 104.
  • the determining unit 706 is configured to determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points detected by the detecting unit 704.
  • the correction unit 708 is configured to perform image correction on the target area determined by the determination unit 706 to obtain a corrected image.
  • the image correction here may include at least perspective transformation.
  • lens distortion correction can also be included.
  • the functions of the determination unit 706 and the correction unit 708 described above may be implemented by the image correction module 106.
  • the recognition unit 710 is configured to perform two-dimensional code recognition on the image corrected by the correction unit 708.
  • the function of the identification unit 710 can be implemented by the identification module 108.
  • the device may further include: a judging unit (not shown in the figure), which is used to perform feature detection on the image to be recognized to detect whether the image to be recognized contains a back word feature. If the backtrack feature is detected, the center point of the backtrack feature is used as the starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the backtrack feature. The gray histogram statistics are performed on the regular rectangular area. If the statistical grayscale histogram is a bimodal histogram, it is determined that the image to be recognized contains a two-dimensional code.
  • the function of the above-mentioned judgment unit can be realized by the feature detection module 102.
  • the device may further include: a conversion unit, an extraction unit, and an amplification unit.
  • the obtaining unit 702 is also used to obtain the size of the back word feature.
  • the conversion unit is configured to convert the size of the two-dimensional code according to a preset conversion rule and the size of the back word feature acquired by the acquisition unit 702.
  • the extracting unit is used to extract the region to be recognized centered on the character-returning feature from the image to be recognized if the size of the two-dimensional code converted by the conversion unit does not satisfy the preset condition.
  • An enlargement unit is used to enlarge the region to be recognized extracted by the extraction unit.
  • the detection unit 704 is specifically used for:
  • a specified number of corner points of the two-dimensional code are detected in the enlarged area to be recognized.
  • the identification unit 710 is specifically used for:
  • the method of local histogram is used to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image.
  • the function of the recognition unit 710 here can be realized by the above-mentioned recognition module 108, contrast enhancement module 110, and binarization module 112 together.
  • the obtaining unit 702 obtains an image to be recognized.
  • the detection unit 704 detects the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm.
  • the determining unit 706 determines the target area where the two-dimensional code is located in the image to be recognized according to the position coordinates of the specified number of corner points.
  • the correction unit 708 performs image correction on the target area to obtain a corrected image.
  • the image correction here may include at least perspective transformation.
  • the recognition unit 710 performs two-dimensional code recognition on the corrected image.
  • an embodiment of this specification also provides a two-dimensional code recognition device, as shown in FIG. 8, the device may include: a memory 802, one or more processors 804, and one or more Programs.
  • the one or more programs are stored in the memory 802, and are configured to be executed by one or more processors 804, and when the program is executed by the processor 804, the following steps are implemented:
  • the specified number of corner points of the two-dimensional code are detected in the image to be recognized.
  • the target area where the two-dimensional code is located in the image to be identified is determined.
  • the image correction includes at least perspective transformation.
  • the two-dimensional code recognition device provided by an embodiment of the present specification can realize accurate recognition of the two-dimensional code in imperfect images.
  • the steps of the method or algorithm described in conjunction with the disclosure of the present specification may be implemented in hardware, or may be implemented by a processor executing software instructions.
  • the software instructions can be composed of corresponding software modules, which can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, mobile hard disk, CD-ROM or any other form of storage known in the art Medium.
  • An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and can write information to the storage medium.
  • the storage medium may also be a component of the processor.
  • the processor and the storage medium may be located in the ASIC.
  • the ASIC may be located in the server.
  • the processor and the storage medium may also exist as discrete components in the server.
  • Computer-readable media includes computer storage media and communication media, where communication media includes any medium that facilitates transfer of a computer program from one place to another.
  • the storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.

Abstract

Embodiments of the present description provide a two-dimensional code identification method, apparatus, and device. The method comprises: obtaining an image to be identified; when the image to be identified comprises a two-dimensional code, detecting a specified number of angular points of the two-dimensional code in the image to be identified according to a deep learning detection algorithm; determining, according to position coordinates of the specified number of angular points, a target area where the two-dimensional code is located in the image to be identified; performing image correction on the target area to obtain a corrected image, the image correction herein comprising at least perspective transformation; and performing two-dimensional code identification on the corrected image.

Description

二维码识别方法、装置及设备Two-dimensional code recognition method, device and equipment 技术领域Technical field
本说明书一个或多个实施例涉及图像识别领域,尤其涉及一种二维码识别方法、装置及设备。One or more embodiments of this specification relate to the field of image recognition, and in particular, to a two-dimensional code recognition method, device, and equipment.
背景技术Background technique
二维码(2-dimensional bar code)是通过按一定规律在平面的二维方向上分布的图形来记录信息的条码。其中,以QR二维码最为常见。QR二维码具有3个用于定位的类似“回”字的图案(以下称为回字特征),分别位于二维码的左上角、右上角、左下角。其识别方法可以如下:采用图像处理技术,在待识别图像中搜索二维码的3个回字特征。根据回字特征的个数和位置,恢复出正常的待识别图像。再通过二值化方法,转换成二值化点阵。最终根据二维码标准语法解析出点阵隐含的字符内容。A two-dimensional code (2-dimensional bar code) is a bar code that records information by graphs distributed in a two-dimensional direction on a plane according to certain rules. Among them, QR two-dimensional code is the most common. The QR two-dimensional code has three patterns resembling "back" characters for positioning (hereinafter referred to as backword features), which are located in the upper left corner, upper right corner, and lower left corner of the two-dimensional code, respectively. The recognition method can be as follows: the image processing technology is used to search for the three linguistic features of the two-dimensional code in the image to be recognized. According to the number and location of the backtracking features, the normal image to be recognized is restored. Then through the binarization method, it is converted into a binarization lattice. Finally, the character content implied by the dot matrix is parsed according to the standard grammar of the QR code.
然而,当待识别图像不够完美时,如,待识别图像中的二维码的回字特征出现较大形变、被遮挡或者待识别图像为大角度图像。依照传统的方法通常搜索不到理想的3个回字特征,从而也就不能恢复出正常的待识别图像,最终也就无法对二维码进行识别。因此,需要提供一种鲁棒性更强的二维码识别方法。However, when the to-be-recognized image is not perfect, for example, the lingering feature of the two-dimensional code in the to-be-recognized image is greatly deformed, blocked, or the to-be-recognized image is a large-angle image. According to the traditional method, it is usually impossible to search for the ideal three back-word features, so that the normal image to be recognized cannot be restored, and finally the two-dimensional code cannot be recognized. Therefore, there is a need to provide a more robust two-dimensional code recognition method.
发明内容Summary of the invention
本说明书一个或多个实施例描述了一种二维码识别方法、装置及设备,可以对非完美图像中的二维码进行准确识别。One or more embodiments of this specification describe a two-dimensional code identification method, device, and equipment, which can accurately identify two-dimensional codes in imperfect images.
第一方面,提供了一种二维码识别方法,包括:In the first aspect, a two-dimensional code recognition method is provided, including:
获取待识别图像;Obtain the image to be recognized;
当所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;When the two-dimensional code is included in the image to be recognized, the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm;
根据所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;Determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points;
对所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视 变换;Performing image correction on the target area to obtain a corrected image; the image correction includes at least a perspective transformation;
对所述校正后的图像进行二维码识别。Perform two-dimensional code recognition on the corrected image.
第二方面,提供了一种二维码识别装置,包括:In a second aspect, a two-dimensional code identification device is provided, including:
获取单元,用于获取待识别图像;An obtaining unit, used to obtain an image to be recognized;
检测单元,用于当所述获取单元获取的所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;The detection unit is configured to detect a specified number of corner points of the two-dimensional code in the image to be recognized according to a deep learning detection algorithm when the image to be recognized acquired by the acquisition unit includes a two-dimensional code ;
确定单元,用于根据所述检测单元检测到的所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;A determining unit, configured to determine a target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points detected by the detecting unit;
校正单元,用于对所述确定单元确定的所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视变换;A correction unit, configured to perform image correction on the target area determined by the determination unit to obtain a corrected image; the image correction includes at least perspective transformation;
识别单元,用于对所述校正单元校正后的图像进行二维码识别。The identification unit is used for performing two-dimensional code identification on the image corrected by the correction unit.
第三方面,提供了一种二维码识别设备,包括:In a third aspect, a two-dimensional code identification device is provided, including:
存储器;Memory
一个或多个处理器;以及One or more processors; and
一个或多个程序,其中所述一个或多个程序存储在所述存储器中,并且被配置成由所述一个或多个处理器执行,所述程序被所述处理器执行时实现以下步骤:One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and when the programs are executed by the processors, the following steps are implemented:
获取待识别图像;Obtain the image to be recognized;
当所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;When the two-dimensional code is included in the image to be recognized, the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm;
根据所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;Determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points;
对所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视变换;Performing image correction on the target area to obtain a corrected image; the image correction includes at least perspective transformation;
对所述校正后的图像进行二维码识别。Perform two-dimensional code recognition on the corrected image.
本说明书一个或多个实施例提供的二维码识别方法、装置及设备,获取待识别图像。当待识别图像中包含二维码时,根据深度学习检测算法,在待识别图像中检测二维 码的指定个数的角点。根据指定个数的角点的位置坐标,确定二维码在待识别图像中所在的目标区域。对目标区域进行图像校正,得到校正后的图像。这里的图像校正至少可以包括透视变换。对校正后的图像进行二维码识别。由此可以看出,本说明书提供的方案,在识别二维码之前,先基于深度学习检测算法,在待识别图像中确定出二维码区域。之后对二维码区域进行校正并识别。由此可以实现对非完美图像中二维码的准确识别,此外,还可以大大提升二维码的识别效率。The two-dimensional code recognition method, device and equipment provided in one or more embodiments of this specification acquire images to be recognized. When the two-dimensional code is included in the image to be recognized, the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm. According to the position coordinates of the specified number of corner points, the target area where the two-dimensional code is located in the image to be identified is determined. Perform image correction on the target area to obtain the corrected image. The image correction here may include at least perspective transformation. Perform two-dimensional code recognition on the corrected image. It can be seen from this that the scheme provided in this specification, before recognizing the two-dimensional code, first determines the two-dimensional code area in the image to be recognized based on the deep learning detection algorithm. After that, the two-dimensional code area is corrected and recognized. In this way, accurate recognition of the two-dimensional code in the imperfect image can be achieved, and in addition, the recognition efficiency of the two-dimensional code can be greatly improved.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly explain the technical solutions of the embodiments of the present specification, the following will briefly introduce the drawings used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present specification. Those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
图1为本说明书提供的二维码识别系统示意图;Figure 1 is a schematic diagram of the two-dimensional code recognition system provided by this specification;
图2为本说明书一个实施例提供的二维码识别方法流程图;2 is a flowchart of a two-dimensional code recognition method provided by an embodiment of the present specification;
图3为本说明书提供的二维码示意图;Figure 3 is a schematic diagram of the two-dimensional code provided by this specification;
图4为本说明书提供的待识别区域的放大过程示意图;4 is a schematic diagram of an enlargement process of an area to be identified provided by this specification;
图5为本说明书提供的二维码的角点示意图;5 is a schematic diagram of corners of a two-dimensional code provided by this specification;
图6a为本说明书提供的校正后的图像示意图;Figure 6a is a schematic diagram of the corrected image provided by this specification;
图6b为本说明书提供的对比度增强图像示意图;6b is a schematic diagram of a contrast-enhanced image provided by this specification;
图6c为本说明书提供的二值化图像示意图;6c is a schematic diagram of a binary image provided by the specification;
图7为本说明书一个实施例提供的二维码识别装置示意图;7 is a schematic diagram of a two-dimensional code recognition device provided by an embodiment of the present specification;
图8为本说明书一个实施例提供的二维码识别设备示意图。8 is a schematic diagram of a two-dimensional code identification device provided by an embodiment of the present specification.
具体实施方式detailed description
下面结合附图,对本说明书提供的方案进行描述。The solution provided in this specification will be described below in conjunction with the drawings.
在描述本说明书提供的方案之前,先对该方案的发明构思作如下介绍:Before describing the solution provided in this specification, the invention of the solution will be introduced as follows:
由于受到摄像头位置、距离、角度、环境光照等因素的影响,获取的待识别二维 码的图像(简称待识别图像)通常不是完美的图像。为了适应各种质量的待识别图像,传统方法通常会设计复杂的多特征融合的逻辑,也即传统的二维码识别方法的复杂度通常都比较高。这里的二维码可以是指PDF417二维码,Datamatrix二维码以及QR二维码等等。在本说明书的以下描述中,以QR二维码为例进行说明。Due to the influence of factors such as camera position, distance, angle, ambient lighting, etc., the acquired image of the two-dimensional code to be recognized (referred to as the image to be recognized for short) is usually not a perfect image. In order to adapt to images of various qualities to be recognized, traditional methods usually design complex multi-feature fusion logic, that is, the complexity of traditional two-dimensional code recognition methods is usually relatively high. The QR code here can refer to PDF417 QR code, Datamatrix QR code and QR QR code. In the following description of this specification, a QR two-dimensional code is used as an example for description.
本申请的申请人考虑到,传统的二维码识别方法之所以复杂,是因为待识别图像本身不够完美。如果能在对待识别图像进行识别之前,先对其进行很好的校正,那么将大大降低二维码识别方法的复杂度。因此,本方案主要是针对待识别图像的前期处理流程(框架)而提出的。The applicant of the present application considered that the reason why the traditional two-dimensional code recognition method is complicated is that the image to be recognized is not perfect enough. If the image to be recognized can be corrected well before being recognized, the complexity of the two-dimensional code recognition method will be greatly reduced. Therefore, this solution is mainly proposed for the preliminary processing flow (framework) of the image to be recognized.
首先,由于本申请是基于深度学习检测算法,来确定待识别图像的二维码区域,之后针对该二维码区域进行校正并识别。而深度学习检测算法是一种比较耗算力的算法,因此要尽量减少不必要的输入。一种实现思路可以是:先对待识别图像是否包含二维码进行判断,在判断其包含二维码的情况下才输入深度学习检测算法。First, because the present application is based on a deep learning detection algorithm to determine the two-dimensional code area of the image to be recognized, and then correct and identify the two-dimensional code area. The deep learning detection algorithm is a relatively computationally intensive algorithm, so it is necessary to minimize unnecessary input. One implementation idea may be: first determine whether the image to be recognized contains a two-dimensional code, and then input the deep learning detection algorithm only when it is determined that the image contains a two-dimensional code.
在一种实现方式中,可以在待识别图像中检测置信度比较高的回字特征。若检测到一个置信度比较高的回字特征,则可以判断该待识别图像中包含二维码。上述回字特征的置信度的判断过程可以如下:以回字特征的中心点为起点,向其周围扩展若干个像素,以得到包含回字特征的正矩形区域。针对正矩形区域进行灰度直方图统计。若统计的灰度直方图为双峰型直方图,则该回字特征的置信度比较高,否则该回字特征的置信度比较低。In an implementation manner, it is possible to detect a back word feature with relatively high confidence in the image to be recognized. If a character with high confidence is detected, it can be judged that the image to be recognized contains a two-dimensional code. The process of determining the confidence of the above-mentioned back word feature may be as follows: the center point of the back word feature is used as a starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the back word feature. The gray histogram statistics are performed on the regular rectangular area. If the statistical gray-scale histogram is a bimodal histogram, the confidence of the Huizi feature is relatively high, otherwise the confidence of the Huizi feature is relatively low.
在另一种实现方式中,可以尝试在待识别图像中检测3个理想的回字特征,如果检测到该3个理想的回字特征,则也可以判断该待识别图像中包含二维码。In another implementation manner, an attempt can be made to detect 3 ideal linguistic features in the image to be recognized. If the 3 ideal linguistic features are detected, it can also be determined that the image to be recognized contains a two-dimensional code.
其次,图片校正通常是一个比较耗时的过程,而因为我们最终是为了对待识别图像中的二维码进行识别,因此,为了加快待识别图像的校正效率,可以考虑仅对待识别图像中的二维码区域进行校正。那么如何从待识别图像中确定识别出二维码区域呢?Secondly, picture correction is usually a time-consuming process, and because we are ultimately trying to recognize the two-dimensional code in the recognized image, in order to speed up the correction efficiency of the image to be recognized, we can consider only the two Dimension code area for correction. So how to determine and recognize the two-dimensional code area from the image to be recognized?
一种实现思路可以是,根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。根据指定个数的角点的位置坐标,确定待识别图像中的二维码区域。需要说明的是,上述深度学习检测算法可以是根据多张预先标定好二维码的指定个数的角点的多张图像训练得到的。One implementation idea may be that, according to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code are detected in the image to be recognized. According to the position coordinates of the specified number of corner points, the two-dimensional code area in the image to be recognized is determined. It should be noted that the above-mentioned deep learning detection algorithm may be obtained by training a plurality of images of a specified number of corner points of a pre-calibrated two-dimensional code.
另一种实现思路可以是,根据在待识别图像中检测到的3个理想的回字特征的位置,来确定二维码区域。Another implementation idea may be that the two-dimensional code area is determined according to the positions of the three ideal ligature features detected in the image to be recognized.
最后,由于通过深度学习检测算法,可以检测出二维码的指定个数的角点。从而基于该指定个数的角点的坐标,可以同时对二维码区域进行透视变换以及镜头畸变校正等图像校正处理。当上述多种图像校正处理可以同时进行时,可以避免图像数据在内存的多次写入,这可以大大提升图像的校正效率,从而可以进一步提升二维码的识别效率。Finally, due to the deep learning detection algorithm, the specified number of corner points of the two-dimensional code can be detected. Therefore, based on the coordinates of the specified number of corner points, image correction processing such as perspective transformation and lens distortion correction can be simultaneously performed on the two-dimensional code area. When the above-mentioned various image correction processes can be performed at the same time, multiple writing of image data in the memory can be avoided, which can greatly improve the correction efficiency of the image, thereby further improving the recognition efficiency of the two-dimensional code.
可以理解的是,在待识别图像经过上述一系列的前期处理之后,可以大幅提升待识别图像的质量,从而使得后续识别算法能够更轻松的识别出二维码包含的内容。It can be understood that, after the image to be recognized has undergone the above-mentioned series of preliminary processing, the quality of the image to be recognized can be greatly improved, so that subsequent recognition algorithms can more easily recognize the content contained in the two-dimensional code.
基于上述发明构思,就可以得到本说明提供的方案。以下对本说明书提供的方案进行详细描述。Based on the above inventive concept, the solution provided in this description can be obtained. The solutions provided in this specification are described in detail below.
图1为本说明书提供的二维码识别系统示意图。图1中,该二维码识别系统10可以包括:特征检测模块102、角点检测模块104、图像校正模块106以及识别模块108。FIG. 1 is a schematic diagram of a two-dimensional code recognition system provided by this specification. In FIG. 1, the two-dimensional code recognition system 10 may include: a feature detection module 102, a corner detection module 104, an image correction module 106, and a recognition module 108.
特征检测模块102,用于在待识别图像中检测置信度比较高的回字特征。这里的回字特征具有如下特点:黑白像素构成的线段长度比为:1:1:3:1:1。利用这个特点,可以在待识别图像中识别出该回字特征。上述回字特征的置信度高低的判断如上所述,在此不复赘述。The feature detection module 102 is used to detect a back word feature with relatively high confidence in the image to be recognized. The hyphen feature here has the following characteristics: the length ratio of line segments composed of black and white pixels is 1:1:3:1:1. Using this feature, the Huizi feature can be recognized in the image to be recognized. The determination of the confidence level of the above-mentioned back word feature is as described above and will not be repeated here.
角点检测模块104,用于在包含二维码的待识别图像中检测二维码的指定个数的角点。这里的包含二维码的待识别图像可以是指检测到置信度比较高的回字特征的待识别图像。如前所述,角点检测模块104具体可以通过深度学习检测算法,来检测二维码的指定个数的角点。The corner detection module 104 is configured to detect a specified number of corners of the two-dimensional code in the image to be recognized including the two-dimensional code. The to-be-recognized image containing the two-dimensional code here may refer to the to-be-recognized image that has detected a character with high confidence. As mentioned above, the corner detection module 104 can specifically detect the specified number of corners of the two-dimensional code through a deep learning detection algorithm.
图像校正模块106,用于对由上述指定个数的角点的位置坐标所确定的区域(即二维码区域)进行图像校正。这里的图像校正可以包括但不限于透视变换以及镜头畸变校正等。需要说明的是,由于通过深度学习检测算法,可以检测出二维码的指定个数的角点。从而基于该指定个数的角点,可以同时对二维码区域进行透视变换以及镜头畸变校正,这可以大大提升图像校正的效率。The image correction module 106 is used to perform image correction on the area (that is, the two-dimensional code area) determined by the position coordinates of the specified number of corner points. The image correction here may include but is not limited to perspective transformation and lens distortion correction. It should be noted that, due to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code can be detected. Therefore, based on the specified number of corner points, two-dimensional code regions can be simultaneously subjected to perspective transformation and lens distortion correction, which can greatly improve the efficiency of image correction.
识别模块108,用于对图像校正后的二维码区域进行识别。如,识别输出二维码中所包含的内容。The recognition module 108 is used to recognize the two-dimensional code area after image correction. For example, identify and output the content contained in the QR code.
可选地,上述二维码识别系统还可以包括对比度增强模块110。对比度增强模块110,用于采用局部直方图的方法对图像校正后的二维码区域进行对比度增强,从而可以得到更好的对比度。Optionally, the above two-dimensional code recognition system may further include a contrast enhancement module 110. The contrast enhancement module 110 is used to enhance the contrast of the image-corrected two-dimensional code region by using a local histogram method, so that a better contrast can be obtained.
此外,还可以包括二值化模块112。二值化模块112,用于对图像校正后的二维码区域或者对比度增强后的二维码区域进行二值化处理,从而使得二维码区域更易于识别。In addition, a binarization module 112 may also be included. The binarization module 112 is used to perform binarization processing on the image-corrected two-dimensional code region or the contrast-enhanced two-dimensional code region, thereby making the two-dimensional code region easier to recognize.
图2为本说明书一个实施例提供的二维码识别方法流程图。所述方法的执行主体可以为具有处理能力的设备:服务器或者系统或者装置,如,可以为图1中的二维码识别系统。如图2所示,所述方法具体可以包括:2 is a flowchart of a two-dimensional code recognition method provided by an embodiment of the present specification. The execution subject of the method may be a device with processing capabilities: a server or a system or an apparatus, for example, it may be a two-dimensional code recognition system in FIG. 1. As shown in FIG. 2, the method may specifically include:
步骤202,获取待识别图像。Step 202: Acquire an image to be recognized.
此处,可以是通过终端设备的摄像头获取待识别图像,这里的终端设备可以是指智能手机、平板电脑、数码相机或其它类似终端设备。在获取到待识别图像之后,可以对待识别图像进行灰度处理,以得到灰度图像。需要说明的是,灰度图像中的像素点的灰度值(简称像素值)的取值范围可以为:[0,255]。Here, the image to be recognized may be obtained through the camera of the terminal device, and the terminal device here may refer to a smartphone, tablet computer, digital camera, or other similar terminal device. After acquiring the image to be recognized, the image to be recognized may be processed in grayscale to obtain a grayscale image. It should be noted that the value range of the gray value (referred to as the pixel value) of the pixels in the gray image may be: [0,255].
如前所述,为了减少深度学习检测算法的不必要的输入,在得到上述灰度图像之后,还可以执行如下是否包含二维码的判断步骤。该步骤具体可以是由特征检测模块102来执行,其具体可以包括:As described above, in order to reduce unnecessary input of the deep learning detection algorithm, after obtaining the grayscale image, the following determination step of whether a two-dimensional code is included may be performed. This step may be specifically performed by the feature detection module 102, which may specifically include:
步骤a,对灰度图像进行特征检测,以检测待识别图像中是否包含回字特征。Step a: Perform feature detection on the gray-scale image to detect whether the image to be recognized contains linguistic features.
如前所述,本说明书中的回字特征具有1:1:3:1:1的特点,因此可以基于该特点来检测上述回字特征。需要说明的是,在待识别图像比较完美的情况下,通常可以检测出3个回字特征。而在待识别图像中的回字特征出现变形、遮挡或者待识别图像为大角度图像时,往往不能检测出理想的3个回字特征,但是单个回字特征通常还是可以检测到的,从而本说明书实施例的是否包含二维码的判断方法具有较高的鲁棒性。以图3所示的二维码为例来说,可以检测到左上角的回字特征。As mentioned above, the syllable feature in this specification has the characteristics of 1:1:3:1:1, so the aforementioned syllable feature can be detected based on this feature. It should be noted that, in the case where the image to be recognized is relatively perfect, it is usually possible to detect three back features. However, when the ligature features in the image to be recognized appear deformed, occluded, or the image to be recognized is a large-angle image, the ideal three ligature features cannot be detected, but a single ligature feature can usually be detected. The method for judging whether a two-dimensional code is included in the embodiment of the specification has high robustness. Taking the two-dimensional code shown in FIG. 3 as an example, the back word feature in the upper left corner can be detected.
步骤b,若检测到该回字特征,则以回字特征的中心点为起点,向其周围扩展若干个像素,以得到包含回字特征的正矩形区域。In step b, if the lingering feature is detected, the center point of the lingering feature is used as a starting point, and a number of pixels are expanded to the surrounding area to obtain a regular rectangular area containing the lingering feature.
这里的“周围”可以是指回字特征的四个方向,因此上述扩展的操作即为在回字特征的四个方向上分别扩展若干个像素。其中,在每个方向上所扩展像素的个数由回字特征的大小确定。具体地,根据上述1:1:3:1:1的特点可知,本说明书中的回字特征可以包含7*7个点阵单元,假设1个点阵单元与1个像素相对应,则回字特征的大小为:1*7=7个像素。在一种实现方式中,上述扩展像素的个数可以为:1*8,这里设定为8是因为最终得到的正矩形区域需包含回字特征(也即要大于7个点阵单元),这里的1代表前述1个像素。当然,在实际应用中,公式中的8也可以替换为任一大于8的数字,本说 明书对此不作限定。Here, "surrounding" may refer to the four directions of the back character feature, so the above expansion operation is to extend several pixels in the four directions of the back character feature, respectively. Among them, the number of pixels expanded in each direction is determined by the size of the back word feature. Specifically, according to the above characteristics of 1:1:3:1:1, it can be known that the ligature feature in this specification may include 7*7 dot matrix units. Assuming that 1 dot matrix unit corresponds to 1 pixel, then return The size of the word feature is: 1*7=7 pixels. In an implementation manner, the number of the extended pixels may be: 1*8, which is set to 8 here because the final rectangular area obtained needs to include a back word feature (that is, greater than 7 dot-matrix units), The 1 here represents the aforementioned 1 pixel. Of course, in practical applications, the 8 in the formula can also be replaced by any number greater than 8, which is not limited in this manual.
步骤c,针对正矩形区域进行灰度直方图统计。Step c: Perform gray histogram statistics on the positive rectangular area.
这里的灰度直方图的横坐标可以为正矩形区域所包含的不同的像素值,如前所述,这里的像素值的取值范围为:[0,255],纵坐标为不同像素值的个数。The horizontal coordinate of the grayscale histogram here can be different pixel values contained in the regular rectangular area. As mentioned above, the value range of the pixel value here is: [0,255], and the vertical coordinate is the number of different pixel values .
步骤d,若统计的灰度直方图为双峰型直方图,则判断待识别图像中包含二维码。Step d: If the statistical grayscale histogram is a bimodal histogram, it is determined that the image to be recognized contains a two-dimensional code.
需要说明的是,上述步骤b-步骤d可以是在检测不到理想的3个回字特征时执行。若通过步骤a可以检测到3个理想的回字特征,则可以直接判断待识别图像中包含二维码,而不执行步骤b-步骤d,本说明书对此不作限定。It should be noted that, the above steps b-d may be performed when the ideal three syllable features cannot be detected. If three ideal linguistic features can be detected through step a, it can be directly judged that the image to be recognized contains a two-dimensional code without performing steps b-d, which is not limited in this specification.
本说明书实施例通过检测单个置信度较高的回字特征,来判断待识别图像中是否包含二维码的方法,可以降低是否包含二维码的误识别率。In this embodiment of the present specification, a method for determining whether a two-dimensional code is included in an image to be recognized by detecting a single linguistic feature with high confidence can reduce the misrecognition rate of whether a two-dimensional code is included.
步骤204,当待识别图像中包含二维码时,根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。Step 204: When the image to be recognized contains a two-dimensional code, detect the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm.
此处,可以是指角点检测模块104根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。Here, it may mean that the corner detection module 104 detects the specified number of corners of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm.
可选地,为了确保在待识别图像包含二维码时,深度学习检测算法能够检测到该二维码的指定个数的角点,本说明书实施例在执行步骤204之前,还可以执行如下二维码大小的判断步骤,包括:Optionally, in order to ensure that when the image to be recognized contains a two-dimensional code, the deep learning detection algorithm can detect the specified number of corners of the two-dimensional code, before performing step 204 in this embodiment of the present specification, the following two may also be performed: The judgment steps of the dimension code include:
获取回字特征的大小。根据预设的换算规则以及回字特征的大小,换算二维码的大小。若二维码的大小不满足预设条件,则从待识别图像中提取以回字特征为中心的待识别区域。对该待识别区域进行放大。Get the size of the back word feature. Convert the size of the QR code according to the preset conversion rules and the size of the back word feature. If the size of the two-dimensional code does not satisfy the preset condition, the region to be recognized centered on the character back is extracted from the image to be recognized. Enlarge the area to be identified.
上述二维码的大小的换算过程可以举例如下:假设获取的回字特征的大小为:3*7=21个像素,从而可以确定回字特征的1个点阵单元对应3个像素。且假设预设的换算规则为:二维码的大小根据1个点阵单元对应的像素个数与预设的最大二维码点阵确定。那么当预设的最大二维码点阵为:57*57时,二维码的大小可以为:3*57=171个像素。The conversion process of the size of the above two-dimensional code can be exemplified as follows: Suppose that the size of the obtained back word feature is: 3*7=21 pixels, so that it can be determined that one dot unit of the back word feature corresponds to 3 pixels. And it is assumed that the preset conversion rule is: the size of the two-dimensional code is determined according to the number of pixels corresponding to one lattice unit and the preset maximum two-dimensional code lattice. Then, when the preset maximum two-dimensional code lattice is 57*57, the size of the two-dimensional code may be: 3*57=171 pixels.
当然,在实际应用中,上述预设的换算规则也可以设定为其它算法,如,将回字特征的大小放大预设倍数来确定二维码的大小,本说明书对此不作限定。Of course, in practical applications, the above-mentioned preset conversion rule can also be set to other algorithms, for example, the size of the back word feature is enlarged by a preset multiple to determine the size of the two-dimensional code, which is not limited in this specification.
图4示出了待识别区域的放大过程示意图。图4中,假设待识别图像的大小为: 1000*1000,且假设根据上述换算规则,换算得到的二维码的大小不满足预设条件,则可以从待识别图像中提取以回字特征为中心的待识别区域,其大小可以为400*400,之后对该400*400的待识别区域进行放大。FIG. 4 shows a schematic diagram of an enlargement process of an area to be recognized. In FIG. 4, assuming that the size of the image to be recognized is: 1000*1000, and assuming that the size of the converted two-dimensional code does not meet the preset conditions according to the above conversion rule, the character-return feature can be extracted from the image to be recognized as The size of the area to be recognized in the center may be 400*400, and then the 400*400 area to be recognized is enlarged.
可以理解的是,当还执行待识别区域的放大操作时,步骤204可以替换为:根据深度学习检测算法,在放大后的待识别区域中检测二维码的指定个数的角点。It can be understood that when the enlargement operation of the area to be recognized is also performed, step 204 may be replaced by: detecting the specified number of corner points of the two-dimensional code in the enlarged area to be recognized according to the deep learning detection algorithm.
在一个例子中,步骤204中,或者上述替换后的步骤中的指定个数的角点可以是指二维码的4的角点。还以图3为例来说,检测出的4个角点可以如图5所示。In one example, the specified number of corner points in step 204, or in the step after the replacement may refer to 4 corner points of the two-dimensional code. Taking FIG. 3 as an example, the detected four corner points may be as shown in FIG. 5.
此外,本说明书中的深度学习检测算法可以是根据多张预先标定好二维码的指定个数的角点的多张图像训练得到的。通过训练该深度学习检测算法,可以模拟人眼对二维码角点的感知能力,从而得到较高的鲁棒性。当出现新的场景时,通过深度学习微调(finetune),也可以较快的更新算法。In addition, the deep learning detection algorithm in this specification may be obtained by training a plurality of images of a specified number of corner points of a pre-calibrated two-dimensional code. By training the deep learning detection algorithm, the human eye's ability to perceive the corners of the two-dimensional code can be simulated, thereby obtaining higher robustness. When new scenes appear, the algorithm can also be updated faster through deep learning fine tuning.
由此可以看出,本说明书检测出的单个置信度较高的回字特征,不仅可以用于判断待识别图像中是否包含二维码,其大小还可以用于换算二维码的大小。当二维码的大小不满足预设条件时,可以对回字特征的周围区域进行放大,由此来提升二维码的角点的检测的成功率。此外,放大后的区域也可以理解为是二维码的粗定位,通过该粗定位方式,可以降低深度学习检测算法的搜索空间。It can be seen from this that the single-word-return feature detected with high confidence in this specification can be used not only to determine whether the image to be recognized contains a two-dimensional code, but also to convert the size of the two-dimensional code. When the size of the two-dimensional code does not meet the preset condition, the surrounding area of the back word feature can be enlarged, thereby improving the success rate of detecting the corner points of the two-dimensional code. In addition, the enlarged area can also be understood as the coarse positioning of the two-dimensional code, and this coarse positioning method can reduce the search space of the deep learning detection algorithm.
再者,本说明书实施例通过深度学习检测算法,来确定二维码区域的方法相比于传统的方法(即基于3个理想的回字特征来定位二维码区域),具有较好的鲁棒性。具体地,本说明书实施例提供的深度学习检测算法,在二维码的回字特征出现变形、被遮挡或者待识别图像为大角度图像时,也能够准确地对二维码区域进行定位。Furthermore, the embodiment of this specification uses a deep learning detection algorithm to determine the two-dimensional code area compared with the traditional method (that is, based on three ideal ligature features to locate the two-dimensional code area), the method has better Greatness. Specifically, the deep learning detection algorithm provided by the embodiments of the present specification can accurately locate the two-dimensional code area even when the traverse feature of the two-dimensional code is deformed, blocked, or the image to be recognized is a large-angle image.
步骤206,根据指定个数的角点的位置坐标,确定二维码在待识别图像中所在的目标区域。Step 206: Determine the target area where the two-dimensional code is located in the image to be recognized according to the position coordinates of the specified number of corner points.
以图5为例来说,该步骤确定的目标区域可以为由图中4个角点所构成的矩形区域。Taking FIG. 5 as an example, the target area determined in this step may be a rectangular area composed of four corner points in the figure.
步骤208,对目标区域进行图像校正,得到校正后的图像。Step 208: Perform image correction on the target area to obtain a corrected image.
如,可以是由图像校正模块108来执行上述步骤206以及步骤208。For example, the image correction module 108 may perform the above steps 206 and 208.
还以图5为例来说,在对其目标区域进行图像校正之后,可以得到如图6a所示的校正后的图像。Taking FIG. 5 as an example, after image correction is performed on the target area, the corrected image as shown in FIG. 6a can be obtained.
上述图像校正至少可以包括透视变换。此外,还可以包括镜头畸变校正等。需要说明的是,由于通过步骤204已经可以确定出目标区域的4个角点,所以该步骤可以直接进行透视变换。而无需先对目标区域进行镜头畸变校正,以确定目标区域的4个角点,之后再对其进行透视变换。在一种实现方式中,当还对目标区域进行镜头畸变校正时,该镜头畸变校正与透视变换可以同时进行,也即只需向内存中写入一次图像数据,从而可以大大提升图像校正的效率。The above image correction may include at least perspective transformation. In addition, lens distortion correction can also be included. It should be noted that, since step 4 can already determine the four corner points of the target area, this step can directly perform perspective transformation. There is no need to perform lens distortion correction on the target area to determine the four corner points of the target area, and then perform perspective transformation on it. In one implementation, when lens distortion correction is also performed on the target area, the lens distortion correction and perspective transformation can be performed simultaneously, that is, only image data needs to be written to the memory once, thereby greatly improving the efficiency of image correction .
此外,由于镜头畸变校正属于非线性变化,其非常消耗资源。因此本步骤只对目标区域进行图像校正,而不对整个待识别图像进行图像校正的方式,可以大大降低运算量。In addition, since the lens distortion correction is a non-linear change, it is very resource intensive. Therefore, in this step, only the image correction is performed on the target area, and the image correction is not performed on the entire image to be recognized, which can greatly reduce the amount of calculation.
步骤210,对校正后的图像进行二维码识别。Step 210, perform two-dimensional code recognition on the corrected image.
如,可以是由识别模块108来对校正后的图像进行二维码识别。For example, the recognition module 108 may perform two-dimensional code recognition on the corrected image.
为了使得校正后的图像更易于识别,本说明书实施例还可以对校正后的图像执行对比度增强以及二值化等图像处理步骤。具体地,先采用局部直方图的方法,对校正后的图像进行对比度增强处理,得到对比度增强图像。再对增强图像进行二值化处理,得到二值化图像。最后对二值化图像进行二维码识别。In order to make the corrected image easier to recognize, the embodiments of the present specification may also perform image processing steps such as contrast enhancement and binarization on the corrected image. Specifically, the local histogram method is first used to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image. Then, the enhanced image is binarized to obtain a binarized image. Finally, two-dimensional code recognition is performed on the binary image.
以图6a为例来说,在对其执行对比度增强处理之后,可以得到如图6b所示的对比度增强图像。之后,当对图6b所示的图像进行二值化处理之后,可以得到如图6c所示的二值化图像。Taking FIG. 6a as an example, after performing contrast enhancement processing on it, a contrast enhanced image as shown in FIG. 6b can be obtained. After that, when the image shown in FIG. 6b is binarized, the binarized image shown in FIG. 6c can be obtained.
综上,本说明书实施例提供的二维码识别方法,通过检测单个置信度较高的回字特征,来判断待识别图像中是否包含二维码。对不包含二维码的待识别图像进行丢弃,由此可以避免所有图像都经过后续比较耗算力的深度学习检测算法。此外,通过该单个置信度较高的回字特征,还可以实现二维码的粗定位,以便在二维码的大小不满足预设条件时,以该回字特征为中心,对其周围区域进行放大。再者,通过训练深度学习检测算法,来对二维码的角点进行定位,可以避免传统算法为了适应各种二维码图像质量,而设计复杂的多特征融合的逻辑。最后,基于深度学习检测算法所检测出的角点,可以同时对二维码区域进行透视变化以及镜头畸变校正等图像校正处理,从而大大提升了图像的校正效率。In summary, the two-dimensional code recognition method provided by the embodiment of the present specification determines whether the two-dimensional code is included in the image to be recognized by detecting a single ligature feature with high confidence. Discard the to-be-recognized images that do not contain the two-dimensional code, so that all images can be prevented from going through a deep learning detection algorithm that is relatively computationally intensive. In addition, through the single-word-back feature with high confidence, coarse positioning of the two-dimensional code can also be achieved, so that when the size of the two-dimensional code does not meet the preset conditions, the back-characteristic feature is used as the center to determine the surrounding area. To zoom in. Furthermore, by training the deep learning detection algorithm to locate the corners of the two-dimensional code, it is possible to avoid the complex logic of multi-feature fusion designed by the traditional algorithm in order to adapt to the image quality of various two-dimensional codes. Finally, based on the corners detected by the deep learning detection algorithm, image correction processing such as perspective change and lens distortion correction can be simultaneously performed on the two-dimensional code area, thereby greatly improving the image correction efficiency.
与上述二维码识别方法对应地,本说明书一个实施例还提供的一种二维码识别装置,如图7所示,该装置可以包括:Corresponding to the above two-dimensional code recognition method, an embodiment of this specification also provides a two-dimensional code recognition device. As shown in FIG. 7, the device may include:
获取单元702,用于获取待识别图像。The obtaining unit 702 is used to obtain an image to be recognized.
检测单元704,用于当获取单元702获取的待识别图像中包含二维码时,根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。The detection unit 704 is configured to detect a specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm when the image to be recognized acquired by the acquisition unit 702 includes the two-dimensional code.
检测单元704的功能可以由角点检测模块104来实现。The function of the detection unit 704 can be realized by the corner detection module 104.
确定单元706,用于根据检测单元704检测到的指定个数的角点的位置坐标,确定二维码在待识别图像中所在的目标区域。The determining unit 706 is configured to determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points detected by the detecting unit 704.
校正单元708,用于对确定单元706确定的目标区域进行图像校正,得到校正后的图像,这里的图像校正至少可以包括透视变换。此外,还可以包括镜头畸变校正等。The correction unit 708 is configured to perform image correction on the target area determined by the determination unit 706 to obtain a corrected image. The image correction here may include at least perspective transformation. In addition, lens distortion correction can also be included.
上述确定单元706以及校正单元708的功能可以由图像校正模块106来实现。The functions of the determination unit 706 and the correction unit 708 described above may be implemented by the image correction module 106.
识别单元710,用于对校正单元708校正后的图像进行二维码识别。The recognition unit 710 is configured to perform two-dimensional code recognition on the image corrected by the correction unit 708.
其中,识别单元710的功能可以由识别模块108来实现。The function of the identification unit 710 can be implemented by the identification module 108.
可选地,该装置还可以包括:判断单元(图中未示出),用于对待识别图像进行特征检测,以检测待识别图像中是否包含回字特征。若检测到回字特征,则以回字特征的中心点为起点,向其周围扩展若干个像素,以得到包含回字特征的正矩形区域。针对所述正矩形区域进行灰度直方图统计。若统计的灰度直方图为双峰型直方图,则判断待识别图像中包含二维码。Optionally, the device may further include: a judging unit (not shown in the figure), which is used to perform feature detection on the image to be recognized to detect whether the image to be recognized contains a back word feature. If the backtrack feature is detected, the center point of the backtrack feature is used as the starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the backtrack feature. The gray histogram statistics are performed on the regular rectangular area. If the statistical grayscale histogram is a bimodal histogram, it is determined that the image to be recognized contains a two-dimensional code.
上述判断单元的功能可以由特征检测模块102来实现。The function of the above-mentioned judgment unit can be realized by the feature detection module 102.
可选地,该装置还可以包括:换算单元、提取单元以及放大单元。Optionally, the device may further include: a conversion unit, an extraction unit, and an amplification unit.
获取单元702,还用于获取回字特征的大小。The obtaining unit 702 is also used to obtain the size of the back word feature.
换算单元,用于根据预设的换算规则以及获取单元702获取的回字特征的大小,换算二维码的大小。The conversion unit is configured to convert the size of the two-dimensional code according to a preset conversion rule and the size of the back word feature acquired by the acquisition unit 702.
提取单元,用于若换算单元换算的二维码的大小不满足预设条件,则从待识别图像中提取以回字特征为中心的待识别区域。The extracting unit is used to extract the region to be recognized centered on the character-returning feature from the image to be recognized if the size of the two-dimensional code converted by the conversion unit does not satisfy the preset condition.
放大单元,用于对提取单元提取的待识别区域进行放大。An enlargement unit is used to enlarge the region to be recognized extracted by the extraction unit.
检测单元704具体用于:The detection unit 704 is specifically used for:
根据深度学习检测算法,在放大后的待识别区域中检测二维码的指定个数的角点。According to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code are detected in the enlarged area to be recognized.
识别单元710具体用于:The identification unit 710 is specifically used for:
采用局部直方图的方法,对校正后的图像进行对比度增强处理,得到对比度增强图像。The method of local histogram is used to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image.
对对比度增强图像进行二值化处理,得到二值化图像。Binarize the contrast-enhanced image to obtain a binary image.
对二值化图像进行二维码识别。Perform two-dimensional code recognition on the binary image.
这里的识别单元710的功能可以由上述识别模块108、对比度增强模块110以及二值化模块112共同来实现。The function of the recognition unit 710 here can be realized by the above-mentioned recognition module 108, contrast enhancement module 110, and binarization module 112 together.
本说明书上述实施例装置的各功能模块的功能,可以通过上述方法实施例的各步骤来实现,因此,本说明书一个实施例提供的装置的具体工作过程,在此不复赘述。The functions of the functional modules of the device in the above embodiments of the present specification can be implemented through the steps of the above method embodiments. Therefore, the specific working process of the device provided by an embodiment of the present specification will not be repeated here.
本说明书一个实施例提供的二维码识别装置,获取单元702获取待识别图像。当待识别图像中包含二维码时,检测单元704根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。确定单元706根据指定个数的角点的位置坐标,确定二维码在待识别图像中所在的目标区域。校正单元708对目标区域进行图像校正,得到校正后的图像,这里的图像校正至少可以包括透视变换。识别单元710对校正后的图像进行二维码识别。由此,可以实现对非完美图像中二维码的准确识别,此外,还可以大大提升二维码的识别效率。In a two-dimensional code recognition device provided by an embodiment of this specification, the obtaining unit 702 obtains an image to be recognized. When the two-dimensional code is included in the image to be recognized, the detection unit 704 detects the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm. The determining unit 706 determines the target area where the two-dimensional code is located in the image to be recognized according to the position coordinates of the specified number of corner points. The correction unit 708 performs image correction on the target area to obtain a corrected image. The image correction here may include at least perspective transformation. The recognition unit 710 performs two-dimensional code recognition on the corrected image. As a result, accurate recognition of the two-dimensional code in the imperfect image can be achieved, and in addition, the recognition efficiency of the two-dimensional code can be greatly improved.
与上述二维码识别方法对应地,本说明书实施例还提供了一种二维码识别设备,如图8所示,该设备可以包括:存储器802、一个或多个处理器804以及一个或多个程序。其中,该一个或多个程序存储在存储器802中,并且被配置成由一个或多个处理器804执行,该程序被处理器804执行时实现以下步骤:Corresponding to the above two-dimensional code recognition method, an embodiment of this specification also provides a two-dimensional code recognition device, as shown in FIG. 8, the device may include: a memory 802, one or more processors 804, and one or more Programs. The one or more programs are stored in the memory 802, and are configured to be executed by one or more processors 804, and when the program is executed by the processor 804, the following steps are implemented:
获取待识别图像。Acquire the image to be recognized.
当待识别图像中包含二维码时,根据深度学习检测算法,在待识别图像中检测二维码的指定个数的角点。When the image to be recognized contains a two-dimensional code, according to the deep learning detection algorithm, the specified number of corner points of the two-dimensional code are detected in the image to be recognized.
根据指定个数的角点的位置坐标,确定二维码在待识别图像中所在的目标区域。According to the position coordinates of the specified number of corner points, the target area where the two-dimensional code is located in the image to be identified is determined.
对目标区域进行图像校正,得到校正后的图像,该图像校正至少包括透视变换。Perform image correction on the target area to obtain a corrected image. The image correction includes at least perspective transformation.
对校正后的图像进行二维码识别。Perform two-dimensional code recognition on the corrected image.
本说明书一个实施例提供的二维码识别设备,可以实现对非完美图像中二维码的 准确识别。The two-dimensional code recognition device provided by an embodiment of the present specification can realize accurate recognition of the two-dimensional code in imperfect images.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于设备实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The embodiments in this specification are described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant part can be referred to the description of the method embodiment.
结合本说明书公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于RAM存储器、闪存、ROM存储器、EPROM存储器、EEPROM存储器、寄存器、硬盘、移动硬盘、CD-ROM或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。另外,该ASIC可以位于服务器中。当然,处理器和存储介质也可以作为分立组件存在于服务器中。The steps of the method or algorithm described in conjunction with the disclosure of the present specification may be implemented in hardware, or may be implemented by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, mobile hard disk, CD-ROM or any other form of storage known in the art Medium. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in the ASIC. In addition, the ASIC may be located in the server. Of course, the processor and the storage medium may also exist as discrete components in the server.
本领域技术人员应该可以意识到,在上述一个或多个示例中,本发明所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。Those skilled in the art should realize that in one or more of the above examples, the functions described in the present invention may be implemented by hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media includes computer storage media and communication media, where communication media includes any medium that facilitates transfer of a computer program from one place to another. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order shown or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
以上所述的具体实施方式,对本说明书的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本说明书的具体实施方式而已,并不用于限定本说明书的保护范围,凡在本说明书的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本说明书的保护范围之内。The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of this specification in detail. It should be understood that the above descriptions are only specific implementations of this specification and are not intended to limit the scope of this specification. The scope of protection, any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of this specification, shall be included in the scope of protection of this specification.

Claims (11)

  1. 一种二维码识别方法,包括:A two-dimensional code recognition method, including:
    获取待识别图像;Obtain the image to be recognized;
    当所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;When the two-dimensional code is included in the image to be recognized, the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm;
    根据所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;Determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points;
    对所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视变换;Performing image correction on the target area to obtain a corrected image; the image correction includes at least perspective transformation;
    对所述校正后的图像进行二维码识别。Perform two-dimensional code recognition on the corrected image.
  2. 根据权利要求1所述的方法,还包括:判断所述待识别图像中是否包含所述二维码的步骤,包括:The method according to claim 1, further comprising the step of determining whether the two-dimensional code is included in the image to be recognized, including:
    对所述待识别图像进行特征检测,以检测所述待识别图像中是否包含回字特征;Performing feature detection on the image to be recognized, to detect whether the image to be recognized contains a back word feature;
    若检测到所述回字特征,则以所述回字特征的中心点为起点,向其周围扩展若干个像素,以得到包含所述回字特征的正矩形区域;If the back word feature is detected, the center point of the back word feature is used as a starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the back word feature;
    针对所述正矩形区域进行灰度直方图统计;Perform gray histogram statistics on the regular rectangular area;
    若统计的灰度直方图为双峰型直方图,则判断所述待识别图像中包含所述二维码。If the statistical gray-scale histogram is a bimodal histogram, it is determined that the two-dimensional code is included in the image to be recognized.
  3. 根据权利要求2所述的方法,在所述根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点之前,还包括:The method according to claim 2, before detecting the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm, further comprising:
    获取所述回字特征的大小;Obtain the size of the back word feature;
    根据预设的换算规则以及所述回字特征的大小,换算所述二维码的大小;Convert the size of the two-dimensional code according to a preset conversion rule and the size of the back word feature;
    若所述二维码的大小不满足预设条件,则从所述待识别图像中提取以所述回字特征为中心的待识别区域;If the size of the two-dimensional code does not satisfy the preset condition, extract the region to be recognized centered on the character back feature from the image to be recognized;
    对所述待识别区域进行放大;Enlarge the area to be identified;
    所述根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点,包括:The detecting the specified number of corner points of the two-dimensional code in the image to be recognized according to the deep learning detection algorithm includes:
    根据深度学习检测算法,在放大后的待识别区域中检测所述二维码的指定个数的角点。According to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code are detected in the enlarged area to be recognized.
  4. 根据权利要求1所述的方法,所述图像校正还包括镜头畸变校正。The method of claim 1, the image correction further comprising lens distortion correction.
  5. 根据权利要求1-4任一项所述的方法,所述对所述校正后的图像进行二维码识别,包括:The method according to any one of claims 1 to 4, wherein the two-dimensional code recognition of the corrected image includes:
    采用局部直方图的方法,对所述校正后的图像进行对比度增强处理,得到对比度增强图像;Adopting a local histogram method to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image;
    对所述对比度增强图像进行二值化处理,得到二值化图像;Performing binary processing on the contrast-enhanced image to obtain a binary image;
    对所述二值化图像进行二维码识别。Perform two-dimensional code recognition on the binary image.
  6. 一种二维码识别装置,包括:A two-dimensional code recognition device, including:
    获取单元,用于获取待识别图像;An obtaining unit, used to obtain an image to be recognized;
    检测单元,用于当所述获取单元获取的所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;The detection unit is configured to detect a specified number of corner points of the two-dimensional code in the image to be recognized according to a deep learning detection algorithm when the image to be recognized acquired by the acquisition unit includes a two-dimensional code ;
    确定单元,用于根据所述检测单元检测到的所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;A determining unit, configured to determine a target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points detected by the detecting unit;
    校正单元,用于对所述确定单元确定的所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视变换;A correction unit, configured to perform image correction on the target area determined by the determination unit to obtain a corrected image; the image correction includes at least perspective transformation;
    识别单元,用于对所述校正单元校正后的图像进行二维码识别。The identification unit is used for performing two-dimensional code identification on the image corrected by the correction unit.
  7. 根据权利要求6所述的装置,还包括:判断单元,用于对所述待识别图像进行特征检测,以检测所述待识别图像中是否包含回字特征;The apparatus according to claim 6, further comprising: a judging unit, configured to perform feature detection on the image to be recognized to detect whether the image to be recognized contains a back word feature;
    若检测到所述回字特征,则以所述回字特征的中心点为起点,向其周围扩展若干个像素,以得到包含所述回字特征的正矩形区域;If the back word feature is detected, the center point of the back word feature is used as a starting point, and a number of pixels are extended around it to obtain a regular rectangular area containing the back word feature;
    针对所述正矩形区域进行灰度直方图统计;Perform gray histogram statistics on the regular rectangular area;
    若统计的灰度直方图为双峰型直方图,则判断所述待识别图像中包含所述二维码。If the statistical gray-scale histogram is a bimodal histogram, it is determined that the two-dimensional code is included in the image to be recognized.
  8. 根据权利要求7所述的装置,还包括:换算单元、提取单元以及放大单元;The device according to claim 7, further comprising: a conversion unit, an extraction unit and an amplification unit;
    所述获取单元,还用于获取所述回字特征的大小;The acquiring unit is also used to acquire the size of the back word feature;
    所述换算单元,用于根据预设的换算规则以及所述获取单元获取的所述回字特征的大小,换算所述二维码的大小;The conversion unit is configured to convert the size of the two-dimensional code according to a preset conversion rule and the size of the back word feature acquired by the acquisition unit;
    所述提取单元,用于若所述换算单元换算的所述二维码的大小不满足预设条件,则从所述待识别图像中提取以所述回字特征为中心的待识别区域;The extracting unit is configured to extract, from the image to be recognized, a region to be recognized centered on the syllable feature from the image to be recognized if the size of the two-dimensional code converted by the conversion unit does not satisfy a preset condition;
    所述放大单元,用于对所述提取单元提取的所述待识别区域进行放大;The enlargement unit is used to enlarge the region to be recognized extracted by the extraction unit;
    所述检测单元具体用于:The detection unit is specifically used for:
    根据深度学习检测算法,在放大后的待识别区域中检测所述二维码的指定个数的角点。According to the deep learning detection algorithm, a specified number of corner points of the two-dimensional code are detected in the enlarged area to be recognized.
  9. 根据权利要求6所述的装置,所述图像校正还包括镜头畸变校正。The apparatus of claim 6, the image correction further comprises lens distortion correction.
  10. 根据权利要求6-9任一项所述的装置,所述识别单元具体用于:The apparatus according to any one of claims 6-9, the identification unit is specifically configured to:
    采用局部直方图的方法,对所述校正后的图像进行对比度增强处理,得到对比度增强图像;Adopting a local histogram method to perform contrast enhancement processing on the corrected image to obtain a contrast enhanced image;
    对所述对比度增强图像进行二值化处理,得到二值化图像;Performing binary processing on the contrast-enhanced image to obtain a binary image;
    对所述二值化图像进行二维码识别。Perform two-dimensional code recognition on the binary image.
  11. 一种二维码识别设备,包括:A two-dimensional code identification device, including:
    存储器;Memory
    一个或多个处理器;以及One or more processors; and
    一个或多个程序,其中所述一个或多个程序存储在所述存储器中,并且被配置成由所述一个或多个处理器执行,所述程序被所述处理器执行时实现以下步骤:One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and when the programs are executed by the processors, the following steps are implemented:
    获取待识别图像;Obtain the image to be recognized;
    当所述待识别图像中包含二维码时,根据深度学习检测算法,在所述待识别图像中检测所述二维码的指定个数的角点;When the two-dimensional code is included in the image to be recognized, the specified number of corner points of the two-dimensional code are detected in the image to be recognized according to the deep learning detection algorithm;
    根据所述指定个数的角点的位置坐标,确定所述二维码在所述待识别图像中所在的目标区域;Determine the target area where the two-dimensional code is located in the image to be identified according to the position coordinates of the specified number of corner points;
    对所述目标区域进行图像校正,得到校正后的图像;所述图像校正至少包括透视变换;Performing image correction on the target area to obtain a corrected image; the image correction includes at least perspective transformation;
    对所述校正后的图像进行二维码识别。Perform two-dimensional code recognition on the corrected image.
PCT/CN2019/114218 2018-12-11 2019-10-30 Two-dimensional code identification method, apparatus, and device WO2020119301A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811513649.8 2018-12-11
CN201811513649.8A CN110046529B (en) 2018-12-11 2018-12-11 Two-dimensional code identification method, device and equipment

Publications (1)

Publication Number Publication Date
WO2020119301A1 true WO2020119301A1 (en) 2020-06-18

Family

ID=67273847

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/114218 WO2020119301A1 (en) 2018-12-11 2019-10-30 Two-dimensional code identification method, apparatus, and device

Country Status (3)

Country Link
CN (1) CN110046529B (en)
TW (1) TWI726422B (en)
WO (1) WO2020119301A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818979A (en) * 2020-08-26 2021-05-18 腾讯科技(深圳)有限公司 Text recognition method, device, equipment and storage medium
EP4202856A1 (en) * 2021-12-22 2023-06-28 Bayer AG Reading of optically readable codes

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046529B (en) * 2018-12-11 2020-06-09 阿里巴巴集团控股有限公司 Two-dimensional code identification method, device and equipment
CN110490023A (en) * 2019-08-27 2019-11-22 广东工业大学 A kind of two dimensional code deformation restoration methods, device and equipment
CN110705329B (en) * 2019-09-30 2021-09-14 联想(北京)有限公司 Processing method and device and electronic equipment
CN112686959A (en) * 2019-10-18 2021-04-20 菜鸟智能物流控股有限公司 Method and device for correcting image to be recognized
CN111860489A (en) * 2019-12-09 2020-10-30 北京嘀嘀无限科技发展有限公司 Certificate image correction method, device, equipment and storage medium
CN110751004B (en) * 2019-10-25 2024-04-30 北京达佳互联信息技术有限公司 Two-dimensional code detection method, device, equipment and storage medium
CN113378595B (en) * 2020-03-10 2023-09-22 顺丰科技有限公司 Two-dimensional code positioning method, device, equipment and storage medium
CN111222510B (en) * 2020-03-13 2024-03-15 中冶长天国际工程有限责任公司 Trolley grate image pickup method and system of sintering machine
CN111612012A (en) * 2020-05-25 2020-09-01 信雅达系统工程股份有限公司 Health code identification method and device
CN111428707B (en) * 2020-06-08 2020-11-10 北京三快在线科技有限公司 Method and device for identifying pattern identification code, storage medium and electronic equipment
CN117372011A (en) * 2020-06-15 2024-01-09 支付宝(杭州)信息技术有限公司 Counting method and device of traffic card, code scanning equipment and counting card server
CN111723802A (en) * 2020-06-30 2020-09-29 北京来也网络科技有限公司 AI-based two-dimensional code identification method, device, equipment and medium
CN112308899B (en) * 2020-11-09 2024-05-07 北京经纬恒润科技股份有限公司 Trailer angle identification method and device
CN112541367A (en) * 2020-12-11 2021-03-23 上海品览数据科技有限公司 Multiple two-dimensional code identification method based on deep learning and image processing
CN113935909A (en) * 2021-09-22 2022-01-14 南方电网深圳数字电网研究院有限公司 Two-dimensional code correction identification method and device
CN114139564B (en) * 2021-12-07 2024-05-07 Oppo广东移动通信有限公司 Two-dimensional code detection method and device, terminal equipment and training method of detection network
CN116882433B (en) * 2023-09-07 2023-12-08 无锡维凯科技有限公司 Machine vision-based code scanning identification method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268498A (en) * 2014-09-29 2015-01-07 杭州华为数字技术有限公司 Two-dimension code recognition method and terminal
CN105046184A (en) * 2015-07-22 2015-11-11 福建新大陆自动识别技术有限公司 Distortion image correction based two-dimensional code decoding method and system
CN105701434A (en) * 2015-12-30 2016-06-22 广州卓德信息科技有限公司 Image correction method for two-dimensional code distorted image
CN108629221A (en) * 2018-05-11 2018-10-09 南京邮电大学 A kind of bearing calibration of fold distortion QR Quick Response Codes
CN110046529A (en) * 2018-12-11 2019-07-23 阿里巴巴集团控股有限公司 Two-dimensional code identification method, device and equipment

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104424458B (en) * 2013-08-23 2017-08-04 希姆通信息技术(上海)有限公司 Image-recognizing method and device, the webserver, image recognition apparatus and system
CN104200188B (en) * 2014-08-25 2017-02-15 北京慧眼智行科技有限公司 Method and system for rapidly positioning position detection patterns of QR code
CN104809422B (en) * 2015-04-27 2017-09-05 江苏中科贯微自动化科技有限公司 QR code recognition methods based on image procossing
CN104881770A (en) * 2015-06-03 2015-09-02 秦志勇 Express bill information identification system and express bill information identification method
CN105260693B (en) * 2015-12-01 2017-12-08 浙江工业大学 A kind of laser two-dimensional code localization method
CN106951812B (en) * 2017-03-31 2018-12-07 腾讯科技(深圳)有限公司 Identify the method, apparatus and terminal of two dimensional code
CN108416412B (en) * 2018-01-23 2021-04-06 浙江瀚镪自动化设备股份有限公司 Logistics composite code identification method based on multitask deep learning

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268498A (en) * 2014-09-29 2015-01-07 杭州华为数字技术有限公司 Two-dimension code recognition method and terminal
CN105046184A (en) * 2015-07-22 2015-11-11 福建新大陆自动识别技术有限公司 Distortion image correction based two-dimensional code decoding method and system
CN105701434A (en) * 2015-12-30 2016-06-22 广州卓德信息科技有限公司 Image correction method for two-dimensional code distorted image
CN108629221A (en) * 2018-05-11 2018-10-09 南京邮电大学 A kind of bearing calibration of fold distortion QR Quick Response Codes
CN110046529A (en) * 2018-12-11 2019-07-23 阿里巴巴集团控股有限公司 Two-dimensional code identification method, device and equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818979A (en) * 2020-08-26 2021-05-18 腾讯科技(深圳)有限公司 Text recognition method, device, equipment and storage medium
CN112818979B (en) * 2020-08-26 2024-02-02 腾讯科技(深圳)有限公司 Text recognition method, device, equipment and storage medium
EP4202856A1 (en) * 2021-12-22 2023-06-28 Bayer AG Reading of optically readable codes
WO2023117688A1 (en) * 2021-12-22 2023-06-29 Bayer Aktiengesellschaft Readout of optically readable codes
WO2023117687A1 (en) * 2021-12-22 2023-06-29 Bayer Aktiengesellschaft Readout of optically readable codes
US11922269B2 (en) 2021-12-22 2024-03-05 Bayer Aktiengesellschaft Reading out optically readable codes

Also Published As

Publication number Publication date
CN110046529B (en) 2020-06-09
TW202024997A (en) 2020-07-01
CN110046529A (en) 2019-07-23
TWI726422B (en) 2021-05-01

Similar Documents

Publication Publication Date Title
WO2020119301A1 (en) Two-dimensional code identification method, apparatus, and device
US9171204B2 (en) Method of perspective correction for devanagari text
CN107220640B (en) Character recognition method, character recognition device, computer equipment and computer-readable storage medium
US9076056B2 (en) Text detection in natural images
US20130129216A1 (en) Text Detection Using Multi-Layer Connected Components With Histograms
JP2016167273A (en) System and method for recognizing text information in object
US10438083B1 (en) Method and system for processing candidate strings generated by an optical character recognition process
US10339657B2 (en) Character detection apparatus and method
CN110647882A (en) Image correction method, device, equipment and storage medium
US20180082456A1 (en) Image viewpoint transformation apparatus and method
US11341739B2 (en) Image processing device, image processing method, and program recording medium
US11354883B2 (en) Image processing method and apparatus, and electronic device
CN112287867B (en) Multi-camera human body action recognition method and device
JP6177541B2 (en) Character recognition device, character recognition method and program
US10509934B1 (en) Methods and apparatus for improving QR code locator detectability and/or finding the corners of a locator pattern
JP7121132B2 (en) Image processing method, apparatus and electronic equipment
WO2019019681A1 (en) Method and apparatus for acquiring tilt value of identity card image, terminal and storage medium
US10217020B1 (en) Method and system for identifying multiple strings in an image based upon positions of model strings relative to one another
CN113129298A (en) Definition recognition method of text image
CN110610163A (en) Table extraction method and tool based on ellipse fitting in natural scene
US10296788B1 (en) Method and system for processing candidate strings detected in an image to identify a match of a model string in the image
JP5857634B2 (en) Word space detection device, word space detection method, and computer program for word space detection
CN112308044B (en) Image enhancement processing method and palm vein identification method for palm vein image
CN114998347A (en) Semiconductor panel corner positioning method and device
JP2015176252A (en) Image processor and image processing method

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: 19894591

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: 19894591

Country of ref document: EP

Kind code of ref document: A1