WO2020042790A1 - 一种二维码解析方法及装置 - Google Patents

一种二维码解析方法及装置 Download PDF

Info

Publication number
WO2020042790A1
WO2020042790A1 PCT/CN2019/096140 CN2019096140W WO2020042790A1 WO 2020042790 A1 WO2020042790 A1 WO 2020042790A1 CN 2019096140 W CN2019096140 W CN 2019096140W WO 2020042790 A1 WO2020042790 A1 WO 2020042790A1
Authority
WO
WIPO (PCT)
Prior art keywords
algorithm
binarization
dimensional code
selection
black
Prior art date
Application number
PCT/CN2019/096140
Other languages
English (en)
French (fr)
Inventor
杨磊磊
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2020042790A1 publication Critical patent/WO2020042790A1/zh

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

Definitions

  • the embodiments of the present specification relate to the field of information technology, and in particular, to a two-dimensional code analysis method and device.
  • two-dimensional codes are widely used in various industries as an information carrier.
  • the payer can use a code scanning device such as a mobile phone to analyze the account information of the payee from the QR code provided by the payee, so that the payee can be paid online.
  • the process of parsing the QR code mainly includes the following steps:
  • the embodiment of the present specification provides a two-dimensional code analysis method and device, and the technical solution is as follows:
  • a method for analyzing a two-dimensional code is provided.
  • An algorithm set including at least two binarization algorithms is set in advance, and a selection score corresponding to each binarization algorithm in the algorithm set is initialized.
  • the method includes:
  • a binarization algorithm with the highest selection score is selected from the algorithm set as a target algorithm, and the target algorithm is used to perform a binary evaluation on the binary algorithm.
  • Dimensional code image is binarized to obtain two-dimensional code black and white image;
  • the identification fails, determine the binary effect characterization value, and re-determine the selection score corresponding to the target algorithm according to the binary effect characterization value; the binary effect characterization value and the two-dimensional The binarization effect of the black-and-white image of the code is positively correlated and positively related to the re-determined selection score corresponding to the target algorithm;
  • Another method for analyzing a two-dimensional code is provided.
  • An algorithm set including at least two binarization algorithms is set in advance, and a selection corresponding to each binarization algorithm in the algorithm set is initialized.
  • Probability, for each binarization algorithm, the corresponding selection probability of the binarization algorithm is positively related to the probability that the binarization algorithm is selected, the method includes:
  • a binarization algorithm is selected from the algorithm set as a target algorithm, and the two-dimensional code image is processed using the target algorithm. Binarization processing to obtain black and white images of QR codes;
  • the identification fails, determine the binary effect characterization value, and re-determine the selection probability corresponding to the target algorithm according to the binary effect characterization value; the binary effect characterization value, and the two-dimensional
  • the binarization effect of the black-and-white image of the code is positively correlated with the re-determined selection probability corresponding to the target algorithm;
  • a two-dimensional code analysis device is provided.
  • An algorithm set including at least two binarization algorithms is set in advance, and a selection score corresponding to each binarization algorithm in the algorithm set is initialized.
  • the device includes:
  • An acquisition module which acquires a QR code image corresponding to the QR code to be parsed
  • a binarization module based on a selection score corresponding to each binarization algorithm in the algorithm set, selects a binarization algorithm with the highest selection score from the algorithm set as a target algorithm, and uses the target algorithm Performing a binarization process on the two-dimensional code image to obtain a two-dimensional code black-and-white image;
  • a recognition module for identifying the black and white image of the two-dimensional code
  • Select a score reset module and if the recognition module fails to identify, determine a binary effect characteristic value, and re-determine a selection score corresponding to the target algorithm according to the binary effect characteristic value; the binary value
  • the value of the characterization effect is positively related to the binarization effect of the black and white image of the two-dimensional code, and positively related to the reselected selection score corresponding to the target algorithm; and instructing the acquisition module to reacquire
  • the two-dimensional code image of the two-dimensional code to be parsed is described until the recognition by the recognition module is successful.
  • Another type of two-dimensional code analysis device is provided.
  • An algorithm set including at least two binarization algorithms is set in advance, and a selection corresponding to each binarization algorithm in the algorithm set is initialized. Probability. For each binarization algorithm, the corresponding selection probability of the binarization algorithm is positively related to the probability that the binarization algorithm is selected.
  • the device includes:
  • An acquisition module which acquires a QR code image corresponding to the QR code to be parsed
  • a binarization module based on a selection probability corresponding to each binarization algorithm in the algorithm set, selecting a binarization algorithm from the algorithm set as a target algorithm, and using the target algorithm, Binarize the QR code image to obtain a black and white image of the QR code;
  • a recognition module for identifying the black and white image of the two-dimensional code
  • Selecting a probability reset module if the identification fails, determining a binary effect characteristic value, and re-determining a selection probability corresponding to the target algorithm according to the binary effect characteristic value; the binary effect characteristic value Is positively related to the binarization effect of the black and white image of the two-dimensional code, and positively related to the re-determined selection probability corresponding to the target algorithm; and instructs the acquisition module to re-acquire the second A two-dimensional code image of the dimension code until the recognition by the recognition module is successful.
  • a binarization algorithm with the highest score is always selected as the target algorithm to binarize the captured two-dimensional code image.
  • the black-and-white image of the two-dimensional code is obtained through processing, and if the subsequent recognition of the black-and-white image of the two-dimensional code fails, the target algorithm corresponding to the target algorithm is re-determined according to the merits of the binarization effect of the two-dimensional code Select a rating. It should be noted that if the binarization effect of the black-and-white image of the two-dimensional code is better, the selection score corresponding to the re-determined target algorithm is higher.
  • a binary algorithm with better binarization effect is selected as much as possible to binarize the two-dimensional code image captured this time, so that it can be easily identified as much as possible.
  • Black and white image of a QR code This also means that the probability of successful analysis of the two-dimensional code is increased each time, so that the binary information in the two-dimensional code can be parsed with fewer analysis times, and the success rate of the two-dimensional code analysis is improved.
  • FIG. 1 is a schematic flowchart of a two-dimensional code analysis method according to an embodiment of the present specification
  • FIG. 2 is a schematic flowchart of another two-dimensional code analysis method provided by an embodiment of the present specification
  • FIG. 3 is a schematic structural diagram of a two-dimensional code parsing device provided by an embodiment of the present specification
  • FIG. 4 is a schematic structural diagram of another two-dimensional code analysis device provided by an embodiment of the present specification.
  • FIG. 5 is a schematic structural diagram of a device for configuring a method according to an embodiment of the present specification.
  • the success rate of QR code parsing is inversely proportional to the number of times the QR code parsing process is performed. That is, for a certain two-dimensional code, the more times the two-dimensional code is attempted to be parsed, the lower the success rate of the two-dimensional code is.
  • the factors that affect the success rate of two-dimensional code analysis mainly include the following two points:
  • the selected binarization algorithm is appropriate.
  • the two-dimensional code images captured for the same two-dimensional code in different environments will have significant differences. difference.
  • two-dimensional code images captured in a high-light environment often become white due to overexposure, and it is usually suitable to use a local adaptive binary algorithm. This means that, in order to obtain a better binarization effect and obtain an easily identifiable black-and-white image of the QR code, it is necessary to consider the environmental conditions in which the QR code is located, and select the QR code captured in the current environment. Binarization algorithm with better black and white image processing effect.
  • the code scanning device cannot collect relevant information about the environment in which the two-dimensional code is located, and therefore cannot select a suitable binary algorithm for the target.
  • the captured two-dimensional code image is binarized.
  • the adopted binarization algorithm is not suitable for processing the two-dimensional code image captured in the current environment, the obtained black-and-white image of the two-dimensional code is often difficult to be identified. In this way, the analysis of the two-dimensional code fails. , You need to try the parsing again, which reduces the success rate and reduces the parsing efficiency.
  • a binary algorithm is randomly selected from at least two preset binary algorithms to process the captured two-dimensional code image. If this parsing fails, try to parse again until the parsing is successful.
  • the selection score corresponding to the binarization algorithm used in the parsing process is reset according to the binarization effect on the QR code image in the parsing process.
  • the binarization algorithm with the highest score is always selected to process the captured two-dimensional code image.
  • the analysis success rate is generally restricted only by the above-mentioned factor 2, but is rarely restricted by the above-mentioned factor 1. In this way, the number of parsing of the two-dimensional code can be significantly reduced, and the parsing success rate can be improved.
  • FIG. 1 is a schematic flowchart of a two-dimensional code parsing method provided by an embodiment of this specification, including the following steps:
  • the execution subject of the method may be a code scanning device having a data processing function, or a data processing device capable of acquiring a two-dimensional code image from the code scanning device.
  • this article refers to the execution body as the parsing device.
  • the parsing device will first convert the two-dimensional code color image into a two-dimensional code gray image.
  • the two-dimensional code image described herein generally refers to the two-dimensional code gray image.
  • S102 Based on the selection score corresponding to each binarization algorithm in the algorithm set, select a binarization algorithm with the highest selection score from the algorithm set as a target algorithm, and use the target algorithm to perform a
  • the two-dimensional code image is binarized to obtain a two-dimensional code black-and-white image.
  • an algorithm set including at least two binarization algorithms may be set in advance, and a selection score corresponding to each binarization algorithm in the algorithm set may be initialized.
  • the selection score corresponding to each binarization algorithm in the algorithm set may be initialized according to the actual situation. For each binarization algorithm, the initialization selection score corresponding to the binarization algorithm is not determined based on the binarization effect of the binarization algorithm under the current environmental conditions.
  • step S102 a binary algorithm algorithm selected at random is actually used as the target algorithm.
  • the analysis device fails to recognize the black and white image of the two-dimensional code obtained in step S102, it means that the binarization effect of the black and white image of the two-dimensional code is not good. There are three possible reasons:
  • the target algorithm is not a suitable binary algorithm, that is, it does not match the current environment.
  • the image quality of the captured QR code is not high.
  • the target algorithm is not a proper binary algorithm, and the quality of the captured QR code image is not high.
  • the parsing device may quantize the binarization effect of the black and white image of the two-dimensional code in step S108 to obtain a binarization effect characteristic value, and according to the obtained binarization effect A characteristic value, and a selection score corresponding to the target algorithm is re-determined.
  • the larger the characterization value of the binarization effect the better the binarization effect of the black-and-white image of the two-dimensional code; the larger the characterization value of the binarization effect, the more determined the selection corresponding to the target algorithm is. The higher the score.
  • the characteristic value of the binarization effect may be determined according to the time taken from the start of the recognition to the failure of the recognition. The longer the time taken to identify the black and white image of the two-dimensional code, the worse the binarization effect.
  • the recognition rate of the positioning area corresponding to the black-and-white image of the two-dimensional code may be obtained, and the characteristic value of the binarization effect may be determined according to the recognition rate of the positioning area.
  • the positioning region accuracy is a ratio of the number of recognizable positioning regions to the total number of positioning regions in the two-dimensional code black-and-white image. Generally speaking, the higher the accuracy of the positioning region, the better the binarization effect, which means that the characterization value of the binarization effect is larger.
  • the information defacement rate corresponding to the black-and-white image of the two-dimensional code can be obtained, and the characteristic value of the binarization effect is determined according to the information defacement rate.
  • the information defacement rate is a ratio of the amount of unrecognized information to the total amount of information in the two-dimensional code black and white image.
  • the higher the information fouling rate the worse the binarization effect means, which means that the characterization value of the binarization effect is smaller.
  • the characteristic value of the binarization effect may also be determined according to the identification rate of the positioning area and the information defacement rate.
  • step S100 needs to be restarted to trigger the parsing process again until the identification is successful in step S104 (meaning that the parsing is successful).
  • the analysis is successful, the method shown in FIG. 1 is stopped.
  • step S100 when step S100 is restarted, it usually means re-acquiring a frame of a two-dimensional code image corresponding to the two-dimensional code to be parsed, and the reacquired two-dimensional code image may be the same as the two-dimensional code acquired last time.
  • the code images are the same or different.
  • the most suitable binarization algorithms are generally different under different environmental conditions. Therefore, it can be considered that assuming that there are a variety of different environmental conditions, the optimal (ie, best matching) binarization algorithms corresponding to the various environmental conditions are different. Furthermore, it can be considered that the characterization value of the binarization effect determined in step S108 is actually a combination of analyzing the matching degree between the current environmental conditions and the target algorithm in a single analysis process and Comprehensive quantified results obtained by analyzing the quality of the dimension code image.
  • the selected target algorithm is not necessarily the binary algorithm that best matches the current environment. This is because the selection score corresponding to the binarization algorithm is not only affected by the degree of matching between the binarization algorithm and the current environment, but also by the quality of the QR code image captured in a parsing process.
  • a binarization algorithm has the highest selection score, only indicating that the binarization algorithm is more compatible with the current environment, but it cannot be explained that the binarization algorithm is the most suitable for the current environment.
  • iterative execution of the analysis process shown in FIG. 1 can gradually weaken the influence of the captured QR image image quality on the recognition result in step S104 through iterations, and gradually strengthen the binary value.
  • the selection score corresponding to each binarization algorithm in the algorithm set when the selection score corresponding to each binarization algorithm in the algorithm set is initialized, the selection score corresponding to each binarization algorithm can be initialized to a value that is neither too high nor high. Too low score. For example, assuming that the selection score uses a percentage system, the selection score corresponding to each binarization algorithm can be initialized to 50 points.
  • step S108 if the binarization effect of the target algorithm is good, the selection score corresponding to the target algorithm re-determined is usually higher than 50 points; if the binarization effect of the target algorithm is poor, then the The selected selection score corresponding to the target algorithm is usually lower than 50 points.
  • the purpose of this is to make it easier to select a binarization algorithm with a better binarization effect in a parsing process under the current environmental conditions, and a binarization algorithm with a lower binarization effect. Elected.
  • a binarization algorithm with a better binarization effect is not found for the time being, then in the next analysis process, a binarization algorithm that has not been selected is preferentially selected to be tried.
  • each binarization algorithm is used to perform binarization processing without repeating.
  • the selection score corresponding to each binarization algorithm in the algorithm set may be specifically initialized to a score that is not less than a specified score.
  • a selection score corresponding to the target binarization algorithm may be re-determined as a score smaller than the specified score.
  • step S102 it may be specifically determined whether there is at least one unselected binarization algorithm in the algorithm set; if so, the binarization that has never been selected A binarization algorithm is selected from the algorithms; otherwise, based on the selection score corresponding to each binarization algorithm in the algorithm set, a binarization algorithm with the largest selection score is selected from the algorithm set.
  • step S108 if the characteristic value of the binarization effect is smaller than a preset value, the target algorithm is deleted from the algorithm set. That is to say, in a parsing process, if the binarization effect of the binarization algorithm used in this parsing is too poor, then the binarization algorithm directly excludes the algorithm set and no longer participates in subsequent parsing processes. In the selection. In this way, the number of parsings can be further reduced, and the parsing success rate can be improved.
  • FIG. 2 is a schematic flowchart of another two-dimensional code analysis method provided by an embodiment of this specification, including the following steps:
  • a binarization algorithm is selected from the algorithm set as a target algorithm, and the two-dimensional code is used by the target algorithm.
  • the image is binarized to obtain a two-dimensional code black and white image.
  • the characterization value of the binarization effect is positively related to the binarization effect of the black and white image of the two-dimensional code, and positively related to the re-determined selection probability corresponding to the target algorithm.
  • the method shown in FIG. 2 and the method shown in FIG. 1 are based on the same inventive concept. The difference between the two is that in the method shown in FIG. 2, the selection probability corresponding to each binarization algorithm is used in one analysis process. The selection basis of the binary algorithm. For each binarization algorithm, the corresponding selection probability of the binarization algorithm is positively related to the probability that the binarization algorithm is selected.
  • the selection probability corresponding to each binarization algorithm in the algorithm set may be initialized to a probability value that is not less than a specified probability value.
  • the selection probability corresponding to the target algorithm is re-determined as a probability value that is smaller than the specified probability value.
  • step S102 it may be determined whether there is at least one unselected binarization algorithm in the algorithm set; if so, a binarization is selected from the unselected binarization algorithms. Algorithm; otherwise, a binarization algorithm is selected from the algorithm set based on the selection probability corresponding to each binarization algorithm in the algorithm set.
  • the embodiment of the present specification also provides a two-dimensional code analysis device.
  • an algorithm set including at least two binarization algorithms is set in advance and initialized.
  • the selection score corresponding to each binarization algorithm in the algorithm set, and the device includes:
  • the obtaining module 301 obtains a QR code image corresponding to the QR code to be parsed
  • a binarization module 302 based on a selection score corresponding to each binarization algorithm in the algorithm set, selects a binarization algorithm with the highest selection score from the algorithm set as a target algorithm, and uses the target An algorithm to binarize the two-dimensional code image to obtain a two-dimensional code black and white image;
  • a recognition module 303 which recognizes the black-and-white image of the two-dimensional code
  • Selecting a score resetting module 304 if the recognition module fails to identify, determine a binary effect characteristic value, and re-determine a selection score corresponding to the target algorithm according to the binary effect characteristic value; the two The value-characterization effect characterization value is positively related to the binarization effect of the black-and-white image of the two-dimensional code, and positively related to the re-determined selection score corresponding to the target algorithm; and instructs the acquisition module 301 to re-acquire the correspondence The two-dimensional code image of the two-dimensional code to be parsed until the recognition by the recognition module 303 is successful.
  • Initializing the selection score corresponding to each binarization algorithm in the algorithm set specifically includes:
  • the selection score reset module 304 re-determines a selection score corresponding to the target binarization algorithm to be a score that is smaller than the designated score.
  • the binarization module 302 determines whether there is at least one unselected binarization algorithm in the algorithm set; if so, a binarization is selected from the unselected binarization algorithms. Algorithm; otherwise, based on the selection score corresponding to each binarization algorithm in the algorithm set, a binarization algorithm with the highest selection score is selected from the algorithm set.
  • the selection score reset module 304 obtains a recognition rate and / or information defacement rate of the positioning area corresponding to the black-and-white image of the two-dimensional code;
  • the accuracy rate of the positioning area is a ratio of the number of recognizable positioning areas to the total number of positioning areas in the two-dimensional code black-and-white image. The ratio of the amount of identified information to the total amount of information.
  • the device further includes:
  • the deleting module 305 deletes the target algorithm from the algorithm set if the characteristic value of the binarization effect is less than a preset value.
  • an embodiment of the present specification also provides a two-dimensional code analysis device.
  • an algorithm set including at least two binarization algorithms is set in advance and initialized.
  • the corresponding selection probability of the binarization algorithm is positively related to the probability that the binarization algorithm is selected.
  • the device include:
  • the obtaining module 401 obtains a QR code image corresponding to the QR code to be parsed
  • a binarization module 402 based on a selection probability corresponding to each binarization algorithm in the algorithm set, selects a binarization algorithm from the algorithm set as a target algorithm, and uses the target algorithm to The two-dimensional code image is binarized to obtain a two-dimensional code black and white image;
  • the selection probability reset module 404 if the identification fails, determines a binary effect characteristic value, and re-determines a selection probability corresponding to the target algorithm according to the binary effect characteristic value; the binary effect characteristic The value is positively related to the binarization effect of the black and white image of the two-dimensional code, and positively related to the re-determined selection probability corresponding to the target algorithm; and instructing the acquisition module 401 to re-acquire the corresponding to the Analyze the two-dimensional code image of the two-dimensional code until the identification by the identification module 403 is successful.
  • Initializing the selection probability corresponding to each binarization algorithm in the algorithm set specifically includes:
  • the selection probability resetting module 404 re-determines a selection probability corresponding to the target algorithm as a probability value that is smaller than the specified probability value.
  • the binarization module 402 determines whether there is at least one unselected binarization algorithm in the algorithm set; if so, a binarization is selected from the unselected binarization algorithms. Algorithm; otherwise, a binarization algorithm is selected from the algorithm set based on the selection probability corresponding to each binarization algorithm in the algorithm set.
  • An embodiment of the present specification further provides a computer device including at least a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the programs shown in FIG. 1 and FIG. 2 when the program is executed.
  • a computer device including at least a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the programs shown in FIG. 1 and FIG. 2 when the program is executed.
  • FIG. 5 shows a more specific schematic diagram of the hardware structure of a computing device provided by an embodiment of the present specification.
  • the device may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050.
  • the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 implement a communication connection within the device through a bus 1050.
  • the processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits, etc., for performing related operations. Program to implement the technical solutions provided by the embodiments of this specification.
  • a general-purpose CPU Central Processing Unit
  • ASIC Application Specific Integrated Circuit
  • the memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, and the like.
  • the memory 1020 may store an operating system and other application programs.
  • related program codes are stored in the memory 1020 and are called and executed by the processor 1010.
  • the input / output interface 1030 is used to connect an input / output module to implement information input and output.
  • the input / output / module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions.
  • the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc.
  • the output device may include a display, a speaker, a vibrator, and an indicator light.
  • the communication interface 1040 is used to connect a communication module (not shown in the figure) to implement communication interaction between the device and other devices.
  • the communication module can implement communication through a wired method (such as USB, network cable, etc.), and can also implement communication through a wireless method (such as mobile network, WIFI, Bluetooth, etc.).
  • the bus 1050 includes a path for transmitting information between various components of the device (for example, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
  • the device may also include necessary for achieving normal operation Other components.
  • the foregoing device may also include only components necessary to implement the solutions of the embodiments of the present specification, and does not necessarily include all the components shown in the drawings.
  • An embodiment of the present specification also provides a computer-readable storage medium on which a computer program is stored.
  • the program is executed by a processor, the two-dimensional code analysis method shown in FIG. 1 and FIG. 2 is implemented.
  • Computer-readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information can be stored by any method or technology.
  • Information may be computer-readable instructions, data structures, modules of a program, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media may be used to store information that can be accessed by computing devices.
  • computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves.
  • the embodiments of the present specification can be implemented by means of software plus a necessary universal hardware platform. Based on such an understanding, the technical solutions of the embodiments of the present specification may be embodied in the form of software products that are essentially or contribute to the existing technology.
  • the computer software product may be stored in a storage medium, such as ROM / RAM, Magnetic disks, optical disks, and the like include a number of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in various embodiments or portions of the embodiments of this specification.
  • the system, method, module, or unit described in the foregoing embodiments may be specifically implemented by a computer chip or entity or a product with a certain function.
  • a typical implementation device is a computer, and the specific form of the computer may be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email sending and receiving device, and a game control Desk, tablet computer, wearable device, or a combination of any of these devices.

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

公开了一种二维码解析方法及装置。在一次二维码解析流程中,总是选出选择评分最大的二值化算法作为目标算法,以对本次抓取的二维码图像进行二值化处理,得到二维码黑白图像,并且,如果随后对所述二维码黑白图像识别失败,则根据所述二维码黑白图像的二值化效果的优劣,重新确定所述目标算法对应的选择评分。需要说明的是,如果所述二维码黑白图像的二值化效果越好,则重新确定的所述目标算法对应的选择评分越高。

Description

一种二维码解析方法及装置 技术领域
本说明书实施例涉及信息技术领域,尤其涉及一种二维码解析方法及装置。
背景技术
目前,二维码作为一种信息载体,广泛应用于各行业领域。例如,在移动支付领域,付款方可以使用手机等扫码设备从收款方提供的二维码中解析出收款方的账户信息,从而可以在线向收款方付款。
对二维码进行解析的过程主要包括如下步骤:
1、扫描二维码,以便抓取一帧二维码图像。
2、从预设的至少两个二值化算法中随机选择一个二值化算法,采用随机选择的二值化算法对抓取的二维码图像进行二值化处理,得到二维码黑白图像。
3、对二维码黑白图像进行识别(一般包括桩点查找、译码、信息纠错等步骤),若识别成功,则得到二进制信息,若识别失败,则返回步骤1重新抓取一帧二维码图像,直至识别成功。
基于现有技术,需要一种成功率更高的二维码解析方法。
发明内容
针对现有的二维码解析方法成功率较低的问题,本说明书实施例提供一种二维码解析方法及装置,技术方案如下:
根据本说明书实施例的第1方面,提供一种二维码解析方法,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分,所述方法包括:
获取对应于待解析二维码的二维码图像;
基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
对所述二维码黑白图像进行识别;
若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择评分正相关;
重新获取对应于所述待解析二维码的二维码图像,直至识别成功。
根据本说明书实施例的第2方面,提供另一种二维码解析方法,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择概率,针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关,所述方法包括:
获取对应于待解析二维码的二维码图像;
基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
对所述二维码黑白图像进行识别;
若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关;
重新获取对应于所述待解析二维码的二维码图像,直至识别成功。
根据本说明书实施例的第3方面,提供一种二维码解析装置,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分,所述装置包括:
获取模块,获取对应于待解析二维码的二维码图像;
二值化模块,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
识别模块,对所述二维码黑白图像进行识别;
选择评分重置模块,若所述识别模块识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分;所述二值化效果表 征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择评分正相关;以及,指令所述获取模块重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块识别成功。
根据本说明书实施例的第4方面,提供另一种二维码解析装置,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择概率,针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关,所述装置包括:
获取模块,获取对应于待解析二维码的二维码图像;
二值化模块,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
识别模块,对所述二维码黑白图像进行识别;
选择概率重置模块,若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关;以及,指令所述获取模块重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块识别成功。
本说明书实施例所提供的技术方案,在一次二维码解析流程中,总是选出选择评分最大的二值化算法作为目标算法,以对本次抓取的二维码图像进行二值化处理,得到二维码黑白图像,并且,如果随后对所述二维码黑白图像识别失败,则根据所述二维码黑白图像的二值化效果的优劣,重新确定所述目标算法对应的选择评分。需要说明的是,如果所述二维码黑白图像的二值化效果越好,则重新确定的所述目标算法对应的选择评分越高。也就是说,在每次对二维码进行解析时,都尽量选择二值化效果较好的二值化算法对本次抓取的二维码图像进行二值化,从而可以尽量得到易于识别的二维码黑白图像。这也就意味着,提升了每次对二维码解析成功的概率,从而可以用更少的解析次数,解析出二维码中的二进制信息,提升二维码解析成功率。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本说明书实施例。
此外,本说明书实施例中的任一实施例并不需要达到上述的全部效果。
附图说明
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。
图1是本说明书实施例提供的一种二维码解析方法的流程示意图;
图2是本说明书实施例提供的另一种二维码解析方法的流程示意图;
图3是本说明书实施例提供的一种二维码解析装置的结构示意图;
图4是本说明书实施例提供的另一种二维码解析装置的结构示意图;
图5是用于配置本说明书实施例方法的一种设备的结构示意图。
具体实施方式
二维码解析成功率,与执行二维码解析流程的次数呈反比。也就是说,针对某个二维码,对该二维码尝试进行解析的次数越多,二维码解析成功率越低。
在一次二维码解析流程中,影响二维码解析成功率的因素主要有以下两点:
1、选择的二值化算法是否合适。实践中,由于同一个二维码在不同环境下所依附的载体、所处的光照条件等往往存在差异,因此,在不同环境下针对同一二维码抓取的二维码图像会存在显著差别。例如,在光照较强的环境中抓取的二维码图像往往因过曝而泛白,通常适合使用局部自适应二值化算法。这意味着,为了取得较好的二值化效果,得到易于识别的二维码黑白图像,需要考虑二维码所处的环境条件,针对性地选择对在当前环境下抓取的二维码黑白图像处理效果较好的二值化算法。
然而,用户在操作扫码设备(如手机)扫描二维码时,扫码设备并不能采集到二维码所处的环境的相关信息,也就无法针对性的选择合适的二值化算法对抓取的二维码图像进行二值化处理。当采用的二值化算法并不适合处理在当前环境下抓取的二维码图像时,得到的二维码黑白图像往往是难以被识别的,如此,就会导致本次二维码解析失败,需要再次尝试进行解析,从而拉低了成功率,降低了解析效率。
2、用户对二维码的扫码操作是否得当。实践中,用户当想要操作扫码设备扫描二维码时,不一定能够立即在近距离对准二维码进行扫描,从而不一定能够抓取到质量较高 的二维码图像,二值化后得到的二维码黑白图像也往往难以识别。用户往往会不断调整扫码设备的扫描角度、扫描距离,而在用户的调整过程中,扫码设备事实上在不断尝试对扫描到的二维码进行解析,即已经执行了多次解析流程并失败,这就拉低了解析成功率。
此外需要说明的是,实践中往往会出现这种情况,即对于一次解析流程,虽然在本次解析流程中选用的二值化算法是合适的(即与二维码所处的环境条件匹配),但是由于用户扫码操作不当,在本次解析流程中抓取的二维码图像质量较差,导致二值化后得到的二维码黑白图像依然难以识别。
基于以上,在现有技术中,在一次解析流程中,通常是从预设的至少两个二值化算法中,随机选择一个二值化算法对本次抓取的二维码图像进行处理。如果本次解析失败,就再尝试解析一次,直至解析成功。
而在本说明书实施例中,如果一次解析失败,则根据本次解析流程中对二维码图像的二值化效果,对本次解析流程中采用的二值化算法对应的选择评分进行重置,二值化效果越好,选择评分越高。如此,在一次解析流程中,总选择选择评分最高的二值化算法对本次抓取的二维码图像进行处理。这意味着,通过本说明书实施例,解析成功率一般只会受到上述因素2的制约,却很少受到上述因素1的制约。如此,可以显著减少对二维码的解析次数,提升解析成功率。
为了使本领域技术人员更好地理解本说明书实施例中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行详细地描述,显然,所描述的实施例仅仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员所获得的所有其他实施例,都应当属于保护的范围。
以下结合附图,详细说明本说明书各实施例提供的技术方案。
图1是本说明书实施例提供的一种二维码解析方法的流程示意图,包括以下步骤:
S100:获取对应于待解析二维码的二维码图像。
本方法的执行主体可以是具有数据处理功能的扫码设备,也可以是能够从扫码设备获取二维码图像的数据处理设备。为了描述的方便,本文将执行主体称为解析设备。
在实践中,在对待解析二维码进行扫描后,一般会直接得到待解析二维码对应的二维码彩色图像。随后,解析设备会将该二维码彩色图像首先转换成二维码灰度图像。本文所述的二维码图像一般是指所述二维码灰度图像。
S102:基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像。
在本说明书实施例中,可以预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分。
其中,可以根据实际情况,对所述算法集合中每个二值化算法对应的选择评分进行初始化。针对每个二值化算法,该二值化算法对应的初始化的选择评分并不是根据在当前环境条件下该二值化算法的二值化效果确定的。
这就意味着,在第一次对所述待解析二维码进行解析时,在步骤S102中,实际上是随机选出的一种二值化算法算法作为目标算法。
S104:对所述二维码黑白图像进行识别。
S106:若识别成功,则不再执行图1所示的流程。
S108:若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分。
解析设备如果对步骤S102中得到的二维码黑白图像识别失败,则意味着所述二维码黑白图像的二值化效果不佳,有以下3种可能的原因:
1、所述目标算法并不是合适的二值化算法,即与当前环境并不匹配。
2、本次抓取的二维码图像质量不高。
3、所述目标算法并不是合适的二值化算法,且本次抓取的二维码图像质量不高。
不论是上述哪一种可能的原因,解析设备在步骤S108中,可以对所述二维码黑白图像的二值化效果进行量化,得到二值化效果表征值,并根据得到的二值化效果表征值,重新确定对应于所述目标算法的选择评分。其中,所述二值化效果表征值越大,所述二维码黑白图像的二值化效果越好;所述二值化效果表征值越大,重新确定的对应于所述目标算法的选择评分越高。
在本说明书实施例中,可以有多种方式确定所述二值化效果表征值。
例如,可以根据本次识别开始至识别失败所花费的时长,确定所述二值化效果表征值。对所述二维码黑白图像进行识别时所花费的时长越长,意味着二值化效果越差。
例如,可以获取所述二维码黑白图像对应的定位区域识别率,根据所述定位区域识别率,确定二值化效果表征值。其中,所述定位区域准确率是所述二维码黑白图像中,可识别出的定位区域的数量与定位区域的总数量的比值。一般而言,所述定位区域准确率越高,二值化效果就越好,意味着所述二值化效果表征值就越大。
例如,可以获取所述二维码黑白图像对应的信息污损率,根据所述信息污损率,确定二值化效果表征值。其中,所述信息污损率是所述二维码黑白图像中,未识别出的信息量与全部信息量的比值。一般而言,所述信息污损率越高,二值化效果就越差,意味着所述二值化效果表征值就越小。
当然,也可以根据所述定位区域识别率和所述信息污损率,确定二值化效果表征值。
在执行了步骤S108之后,需要重新开始执行步骤S100,以再触发一次解析流程,直到在步骤S104中识别成功(意味着解析成功)。当解析成功时,则停止执行图1所示的方法。需要说明的是,当重新开始执行步骤S100时,通常意味着重新获取对应于所述待解析二维码的一帧二维码图像,重新获取的二维码图像可以与上一次获取的二维码图像相同,也可以不同。
值得强调的是,如前所述,在不同的环境条件下,最合适的二值化算法一般不同。因此,可以认为,假设有多种不同的环境条件,各种环境条件分别对应的最优(即最匹配)二值化算法不同。进而可以认为,步骤S108中确定的二值化效果表征值,实际上是在一次解析流程中,结合对当前环境条件与所述目标算法之间的匹配程度进行分析与对本次抓取的二维码图像的质量进行分析所得到的综合量化结果。
这也就意味着,在一次解析流程中,虽然会将选择评分最大的二值化算法选出,作为目标算法。但是,选出的目标算法并不一定是与当前环境最匹配的二值化算法。这是因为,二值化算法对应的选择评分不仅受到二值化算法与当前环境的匹配程度的影响,还受到在一次解析流程中抓取的二维码图像的质量的影响。
某个二值化算法对应的选择评分最高,只说明该二值化算法与当前环境较为匹配,却无法说明该二值化算法与当前环境最为匹配。
因此,在本说明书实施例中,通过迭代执行图1所示的解析流程,可以通过一次次迭代,逐渐弱化抓取的二维码图像质量对步骤S104中识别结果的影响,而逐渐强化二值化算法与当前环境匹配程度对步骤S104中识别结果的影响。从而可以通过较少的迭代次数,解析出二维码中的二进制信息。
此外还需要说明的是,在对所述算法集合中每个二值化算法对应的选择评分进行初始化时,可以为每个二值化算法对应的选择评分初始化为一个既不太高,又不太低的分值。例如,假设选择评分采用百分制,那么,可以将每个二值化算法对应的选择评分初始化为50分。
相应的,在步骤S108中,如果目标算法的二值化效果较好,则重新确定的对应于目标算法的选择评分通常会高于50分;如果目标算法的二值化效果较差,则重新确定的对应于目标算法的选择评分通常会低于50分。
这样做的目的,是为了使得在当前环境条件下,一次解析流程中,二值化效果较好的二值化算法更容易被选出,二值化效果较差的二值化算法更不容易被选出。并且,如果暂时并未发现二值化效果较好的二值化算法,那么就在下一次解析流程中,优先选择还未被选择过的二值化算法进行尝试。
进一步地,在当前环境条件下,为了以尽可能少的解析次数,尽快根据每种二值化算法的二值化效果重新确定每种二值化算法对应的选择评分,就需要在前几次解析时,不重复得依次采用每个二值化算法进行二值化处理。
因此,在本说明书实施例中,具体可以初始化所述算法集合中每个二值化算法对应的选择评分为,不小于指定分值的分值。在步骤S108中,可以重新确定对应于所述目标二值化算法的选择评分为,小于所述指定分值的分值。
或者,在本说明书实施例中,在步骤S102中,具体可以判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法。
另外,在步骤S108中,若所述二值化效果表征值小于预设值,则从所述算法集合中删除所述目标算法。也就是说,在一次解析流程中,如果在本次解析时选用的二值化算法的二值化效果太差,那么就直接该二值化算法排除出算法集合,不再参与后续若干解析流程中的评选。如此,可以进一步减少解析次数,提升解析成功率。
通过图1所示的方法,在每次对二维码进行解析时,都可以尽量选择二值化效果最好的二值化算法对本次抓取的二维码图像进行二值化,从而可以尽量得到易于识别的二维码黑白图像。这也就意味着,提升了每次对二维码解析成功的概率,从而可以用更少的解析次数,解析出二维码中的二进制信息,提升二维码解析成功率。
图2是本说明书实施例提供的另一种二维码解析方法的流程示意图,包括如下步骤:
S200:获取对应于待解析二维码的二维码图像。
S202:基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像。
S204:对所述二维码黑白图像进行识别。
S206:若识别成功,则不再执行图2所示的流程。
S208:若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率。
其中,所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关。
图2所示的方法与图1所示的方法基于相同的发明构思,二者的区别在于,在图2所示的方法中,以每个二值化算法对应的选择概率为一次解析流程中的二值化算法的评选依据。针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关。
需要说明的是,在一次解析流程中,哪怕某个二值化算法对应的选择概率最高,也不一定会选出该二值化算法作为目标算法。
在图2所示的方法中,类似地,也需要预先针对算法集合中的每个二值化算法,初始化该二值化算法对应的选择概率。
在图2所示的方法中,在当前环境条件下,为了以尽可能少的解析次数,尽快根据每种二值化算法的二值化效果重新确定每种二值化算法对应的选择概率,就需要在前几次解析时,尽可能不重复得依次采用每个二值化算法进行二值化处理。
为此,可以初始化所述算法集合中每个二值化算法对应的选择概率为,不小于指定概率值的概率值。相应的,在步骤S108中,重新确定对应于所述目标算法的选择概率为,小于所述指定概率值的概率值。
或者,可以在步骤S102中,判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算 法。
基于图1所示的二维码解析方法,本说明书实施例还对应提供了一种二维码解析装置,如图3所示,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分,所述装置包括:
获取模块301,获取对应于待解析二维码的二维码图像;
二值化模块302,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
识别模块303,对所述二维码黑白图像进行识别;
选择评分重置模块304,若所述识别模块识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择评分正相关;以及,指令所述获取模块301重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块303识别成功。
初始化所述算法集合中每个二值化算法对应的选择评分,具体包括:
初始化所述算法集合中每个二值化算法对应的选择评分为,不小于指定分值的分值;
所述选择评分重置模块304,重新确定对应于所述目标二值化算法的选择评分为,小于所述指定分值的分值。
所述二值化模块302,判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法。
所述选择评分重置模块304,获取所述二维码黑白图像对应的定位区域识别率和/或信息污损率;根据所述定位区域识别率和/或所述信息污损率,确定二值化效果表征值;所述定位区域准确率与所述二值化效果表征值正相关,所述信息污损率与所述二值化效果表征值负相关;
其中,所述定位区域准确率是所述二维码黑白图像中,可识别出的定位区域的 数量与定位区域的总数量的比值;信息污损率是所述二维码黑白图像中,未识别出的信息量与全部信息量的比值。
所述装置还包括:
删除模块305,若所述二值化效果表征值小于预设值,则从所述算法集合中删除所述目标算法。
基于图2所示的二维码解析方法,本说明书实施例还对应提供了一种二维码解析装置,如图4所示,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择概率,针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关,所述装置包括:
获取模块401,获取对应于待解析二维码的二维码图像;
二值化模块402,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
识别模块403,对所述二维码黑白图像进行识别;
选择概率重置模块404,若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关;以及,指令所述获取模块401重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块403识别成功。
初始化所述算法集合中每个二值化算法对应的选择概率,具体包括:
初始化所述算法集合中每个二值化算法对应的选择概率为,不小于指定概率值的概率值;
所述选择概率重置模块404,重新确定对应于所述目标算法的选择概率为,小于所述指定概率值的概率值。
所述二值化模块402,判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法。
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在 存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现图1和图2所示的二维码解析方法。
图5示出了本说明书实施例所提供的一种更为具体的计算设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。
处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施例所提供的技术方案。
存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。
输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。
通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。
总线1050包括一通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。
需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施例方案所必需的组件,而不必包含图中所示的全部组件。
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该 程序被处理器执行时实现图1和图2所示的二维码解析方法。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本说明书实施例可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本说明书实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本说明书实施例各个实施例或者实施例的某些部分所述的方法。
上述实施例阐明的系统、方法、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任意几种设备的组合。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于方法实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的方法实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,在实施本说明书实施例方案时可以把各模块的功能在同一个或多个软件和/或硬件中实现。也可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
以上所述仅是本说明书实施例的具体实施方式,应当指出,对于本技术领域的 普通技术人员来说,在不脱离本说明书实施例原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本说明书实施例的保护范围。

Claims (18)

  1. 一种二维码解析方法,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分,所述方法包括:
    获取对应于待解析二维码的二维码图像;
    基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
    对所述二维码黑白图像进行识别;
    若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择评分正相关;
    重新获取对应于所述待解析二维码的二维码图像,直至识别成功。
  2. 如权利要求1所述的方法,初始化所述算法集合中每个二值化算法对应的选择评分,具体包括:
    初始化所述算法集合中每个二值化算法对应的选择评分为,不小于指定分值的分值;
    重新确定对应于所述目标二值化算法的选择,具体包括:
    重新确定对应于所述目标二值化算法的选择评分为,小于所述指定分值的分值。
  3. 如权利要求1所述的方法,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,具体包括:
    判断所述算法集合中是否存在至少一个未被选出过的二值化算法;
    若是,则从未被选出过的二值化算法中选出一个二值化算法;
    否则,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法。
  4. 如权利要求1所述的方法,确定二值化效果表征值,具体包括:
    获取所述二维码黑白图像对应的定位区域识别率和/或信息污损率;
    根据所述定位区域识别率和/或所述信息污损率,确定二值化效果表征值;所述定位区域准确率与所述二值化效果表征值正相关,所述信息污损率与所述二值化效果表征值负相关;
    其中,所述定位区域准确率是所述二维码黑白图像中,可识别出的定位区域的数量与定位区域的总数量的比值;所述信息污损率是所述二维码黑白图像中,未识别出的信息量与全部信息量的比值。
  5. 如权利要求1所述的方法,所述方法还包括:
    若所述二值化效果表征值小于预设值,则从所述算法集合中删除所述目标算法。
  6. 一种二维码解析方法,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择概率,针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关,所述方法包括:
    获取对应于待解析二维码的二维码图像;
    基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
    对所述二维码黑白图像进行识别;
    若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关;
    重新获取对应于所述待解析二维码的二维码图像,直至识别成功。
  7. 如权利要求6所述的方法,初始化所述算法集合中每个二值化算法对应的选择概率,具体包括:
    初始化所述算法集合中每个二值化算法对应的选择概率为,不小于指定概率值的概率值;
    重新确定对应于所述目标算法的选择概率,具体包括:
    重新确定对应于所述目标算法的选择概率为,小于所述指定概率值的概率值。
  8. 如权利要求6所述的方法,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法,具体包括:
    判断所述算法集合中是否存在至少一个未被选出过的二值化算法;
    若是,则从未被选出过的二值化算法中选出一个二值化算法;
    否则,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法。
  9. 一种二维码解析装置,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择评分,所述装置包括:
    获取模块,获取对应于待解析二维码的二维码图像;
    二值化模块,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法,作为目标算法,并使用所述目标算法,对所 述二维码图像进行二值化处理,得到二维码黑白图像;
    识别模块,对所述二维码黑白图像进行识别;
    选择评分重置模块,若所述识别模块识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择评分;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择评分正相关;以及,指令所述获取模块重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块识别成功。
  10. 如权利要求9所述的装置,初始化所述算法集合中每个二值化算法对应的选择评分,具体包括:
    初始化所述算法集合中每个二值化算法对应的选择评分为,不小于指定分值的分值;
    所述选择评分重置模块,重新确定对应于所述目标二值化算法的选择评分为,小于所述指定分值的分值。
  11. 如权利要求9所述的装置,所述二值化模块,判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择评分,从所述算法集合中选出一个选择评分最大的二值化算法。
  12. 如权利要求9所述的装置,所述选择评分重置模块,获取所述二维码黑白图像对应的定位区域识别率和/或信息污损率;根据所述定位区域识别率和/或所述信息污损率,确定二值化效果表征值;所述定位区域准确率与所述二值化效果表征值正相关,所述信息污损率与所述二值化效果表征值负相关;
    其中,所述定位区域准确率是所述二维码黑白图像中,可识别出的定位区域的数量与定位区域的总数量的比值;所述信息污损率是所述二维码黑白图像中,未识别出的信息量与全部信息量的比值。
  13. 如权利要求9所述的装置,所述装置还包括:
    删除模块,若所述二值化效果表征值小于预设值,则从所述算法集合中删除所述目标算法。
  14. 一种二维码解析装置,预先设置包含至少两个二值化算法的算法集合,并初始化所述算法集合中每个二值化算法对应的选择概率,针对每个二值化算法,该二值化算法对应选择概率与该二值化算法被选出的可能性正相关,所述装置包括:
    获取模块,获取对应于待解析二维码的二维码图像;
    二值化模块,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集 合中选出一个二值化算法,作为目标算法,并使用所述目标算法,对所述二维码图像进行二值化处理,得到二维码黑白图像;
    识别模块,对所述二维码黑白图像进行识别;
    选择概率重置模块,若识别失败,则确定二值化效果表征值,并根据所述二值化效果表征值,重新确定对应于所述目标算法的选择概率;所述二值化效果表征值,与所述二维码黑白图像的二值化效果正相关,且与重新确定的对应于所述目标算法的选择概率正相关;以及,指令所述获取模块重新获取对应于所述待解析二维码的二维码图像,直至所述识别模块识别成功。
  15. 如权利要求14所述的装置,初始化所述算法集合中每个二值化算法对应的选择概率,具体包括:
    初始化所述算法集合中每个二值化算法对应的选择概率为,不小于指定概率值的概率值;
    所述选择概率重置模块,重新确定对应于所述目标算法的选择概率为,小于所述指定概率值的概率值。
  16. 如权利要求14所述的装置,所述二值化模块,判断所述算法集合中是否存在至少一个未被选出过的二值化算法;若是,则从未被选出过的二值化算法中选出一个二值化算法;否则,基于所述算法集合中每个二值化算法对应的选择概率,从所述算法集合中选出一个二值化算法。
  17. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1至5任一项所述的方法。
  18. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求6至8任一项所述的方法。
PCT/CN2019/096140 2018-08-31 2019-07-16 一种二维码解析方法及装置 WO2020042790A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811010259.9A CN109255277B (zh) 2018-08-31 2018-08-31 一种二维码解析方法及装置
CN201811010259.9 2018-08-31

Publications (1)

Publication Number Publication Date
WO2020042790A1 true WO2020042790A1 (zh) 2020-03-05

Family

ID=65049997

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/096140 WO2020042790A1 (zh) 2018-08-31 2019-07-16 一种二维码解析方法及装置

Country Status (3)

Country Link
CN (1) CN109255277B (zh)
TW (1) TWI691911B (zh)
WO (1) WO2020042790A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109255277B (zh) * 2018-08-31 2020-04-28 阿里巴巴集团控股有限公司 一种二维码解析方法及装置
CN111488752A (zh) * 2019-01-29 2020-08-04 北京骑胜科技有限公司 二维码识别方法、装置、电子设备及存储介质
CN111259680B (zh) * 2020-02-13 2022-04-12 支付宝(杭州)信息技术有限公司 二维码图像二值化处理方法及装置
CN111931884A (zh) * 2020-08-07 2020-11-13 北京字节跳动网络技术有限公司 性能数据采集方法、装置和电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2288135A2 (en) * 2009-08-21 2011-02-23 Konica Minolta Systems Laboratory, Inc Deblurring and Supervised Adaptive Thresholding for Print-and-Scan Document Image Evaluation
US9111186B2 (en) * 2011-10-12 2015-08-18 University Of Rochester Color barcodes for mobile applications: a per channel framework
CN105528485A (zh) * 2015-12-07 2016-04-27 常州天能博智能系统科技有限公司 一种从位图自动轮廓提取及路径生成的方法
CN107832648A (zh) * 2017-10-24 2018-03-23 深圳市丰巢科技有限公司 一种基于zxing的连续扫描方法及移动终端
CN109255277A (zh) * 2018-08-31 2019-01-22 阿里巴巴集团控股有限公司 一种二维码解析方法及装置

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6560349B1 (en) * 1994-10-21 2003-05-06 Digimarc Corporation Audio monitoring using steganographic information
US20060027657A1 (en) * 2004-08-04 2006-02-09 Laurens Ninnink Method and apparatus for high resolution decoding of encoded symbols
CN103235948B (zh) * 2013-04-22 2016-04-20 中山大学 一种二维条码的自适应阈值二值化方法
EP2806374B1 (en) * 2013-05-24 2022-07-06 Tata Consultancy Services Limited Method and system for automatic selection of one or more image processing algorithm
TW201531954A (zh) * 2013-12-17 2015-08-16 Sicpa Holding Sa 二維識別圖案、包括此圖案之製品,及用於標記及識別此圖案之方法
CN104063874B (zh) * 2014-07-09 2017-01-25 武汉科技大学 基于权值模型的灰度图像二值化算法定量评估方法
TWI518547B (zh) * 2014-07-30 2016-01-21 帝商科技股份有限公司 二維條碼的產生及顯示方法
CN104899542B (zh) * 2015-05-27 2017-06-20 广州市韦尔讯信息科技有限公司 一种影像式cmos条码快速识别方法及装置
TWI544419B (zh) * 2015-11-20 2016-08-01 王碩騰 二維條碼之編碼方法、解碼方法與電子裝置
CN106845312B (zh) * 2016-12-28 2020-08-25 广州智慧城市发展研究院 一种二维码图像质量的预判断方法
CN106682560B (zh) * 2016-12-28 2020-01-31 深圳市共进电子股份有限公司 二维码识别方法、装置和系统
US10373111B2 (en) * 2017-01-31 2019-08-06 Bank Of America Corporation Chip card imaging and verification system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2288135A2 (en) * 2009-08-21 2011-02-23 Konica Minolta Systems Laboratory, Inc Deblurring and Supervised Adaptive Thresholding for Print-and-Scan Document Image Evaluation
US9111186B2 (en) * 2011-10-12 2015-08-18 University Of Rochester Color barcodes for mobile applications: a per channel framework
CN105528485A (zh) * 2015-12-07 2016-04-27 常州天能博智能系统科技有限公司 一种从位图自动轮廓提取及路径生成的方法
CN107832648A (zh) * 2017-10-24 2018-03-23 深圳市丰巢科技有限公司 一种基于zxing的连续扫描方法及移动终端
CN109255277A (zh) * 2018-08-31 2019-01-22 阿里巴巴集团控股有限公司 一种二维码解析方法及装置

Also Published As

Publication number Publication date
CN109255277B (zh) 2020-04-28
TW202011265A (zh) 2020-03-16
CN109255277A (zh) 2019-01-22
TWI691911B (zh) 2020-04-21

Similar Documents

Publication Publication Date Title
WO2020042790A1 (zh) 一种二维码解析方法及装置
WO2020119301A1 (zh) 二维码识别方法、装置及设备
RU2721188C2 (ru) Улучшение контраста и снижение шума на изображениях, полученных с камер
CN107220640B (zh) 字符识别方法、装置、计算机设备和计算机可读存储介质
WO2020038140A1 (zh) 人脸识别方法及装置
US10438086B2 (en) Image information recognition processing method and device, and computer storage medium
US9495590B1 (en) Extended depth-of-field biometric system
US20130251262A1 (en) Text image trimming method
WO2018059365A1 (zh) 图形码处理方法及装置、存储介质
US11210502B2 (en) Comparison method and apparatus based on a plurality of face image frames and electronic device
CN110348257B (zh) 一种条码解析方法及装置
US20190191078A1 (en) Information processing apparatus, a non-transitory computer readable storage medium and information processing method
US20170365061A1 (en) Image recognition method and apparatus
US9940700B2 (en) Information processing apparatus, information processing method, information processing system, and non-transitory computer readable medium
US9600871B2 (en) Image correcting apparatus, image correcting method and computer readable recording medium recording program thereon
CN108197638B (zh) 对待评估样本进行分类的方法及装置
JP6160138B2 (ja) パターン認識のためのモアレ除去方法およびこの方法を用いたモアレ除去装置ならびにプログラム
CN106258009A (zh) 一种采集指纹的方法、指纹采集器以及终端
EP3553702A1 (en) Image recognition-based communication method and device
JP2018147240A (ja) 画像処理装置、画像処理方法、及び画像処理プログラム
JP2014508342A (ja) バーコード画像のボケ修正を行う方法、端末、およびコンピュータ可読記録媒体
US9646225B2 (en) Defocus estimation from single image based on Laplacian of Gaussian approximation
US10373329B2 (en) Information processing apparatus, information processing method and storage medium for determining an image to be subjected to a character recognition processing
JP2006133941A (ja) 画像処理装置、画像処理方法、画像処理プログラム及び携帯型端末
CN105631850B (zh) 对齐多视图扫描

Legal Events

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

Ref document number: 19853765

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

Country of ref document: EP

Kind code of ref document: A1