WO2023274097A1 - Qr code image processing method and apparatus - Google Patents

Qr code image processing method and apparatus Download PDF

Info

Publication number
WO2023274097A1
WO2023274097A1 PCT/CN2022/101359 CN2022101359W WO2023274097A1 WO 2023274097 A1 WO2023274097 A1 WO 2023274097A1 CN 2022101359 W CN2022101359 W CN 2022101359W WO 2023274097 A1 WO2023274097 A1 WO 2023274097A1
Authority
WO
WIPO (PCT)
Prior art keywords
dimensional code
image
code image
grid
area
Prior art date
Application number
PCT/CN2022/101359
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 WO2023274097A1 publication Critical patent/WO2023274097A1/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/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges
    • 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/146Methods for optical code recognition the method including quality enhancement steps
    • G06K7/1478Methods for optical code recognition the method including quality enhancement steps adapting the threshold for pixels in a CMOS or CCD pixel sensor for black and white recognition

Definitions

  • the present application relates to the field of image processing, in particular to a two-dimensional code image processing method and device.
  • a two-dimensional code refers to a black and white graphic that records data symbol information distributed on a plane with a certain specific geometric figure according to a certain rule. Analyzing the two-dimensional code can obtain the recorded data symbol information.
  • the two-dimensional code analysis method in the prior art usually obtains the two-dimensional code image through the camera first, and then uses the analysis library to complete the two-dimensional code analysis. However, when the size of the two-dimensional code is small, or the two-dimensional code is worn, the success rate of parsing the two-dimensional code image is not high.
  • the embodiments of the present application provide a two-dimensional code image processing method and device, which can generate a standard two-dimensional code based on the two-dimensional code image, and improve the success rate of parsing the two-dimensional code image.
  • the embodiment of the present application provides a two-dimensional code image processing method, including: identifying the specified shape contained in the two-dimensional code from the two-dimensional code image; determining the size of the code grain in the two-dimensional code image according to the specified shape ; using the size of the code grain as the grid reference, divide the grid in the two-dimensional code image; generate a standard two-dimensional code according to the image content in each grid.
  • the embodiment of the present application further provides a two-dimensional code image processing device, which is used to implement the above two-dimensional code image processing method.
  • the two-dimensional code image processing device includes: a recognition unit, used to recognize the specified shape contained in the two-dimensional code from the two-dimensional code image; a size unit, used to determine the shape of the two-dimensional code image according to the specified shape The size of the code grain; the grid unit is used to divide the grid in the two-dimensional code image using the size of the code grain as a grid reference; the generation unit is used to generate a standard two-dimensional code according to the image content in each grid code.
  • the embodiment of the present application also provides an electronic device, including: a processor; and a memory arranged to store computer-executable instructions, and the executable instructions cause the processor to perform the above two-dimensional code image processing when executed method.
  • the embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including multiple application programs, the electronic The device executes the above two-dimensional code image processing method.
  • the above-mentioned at least one technical solution adopted in the embodiment of the present application can achieve the following beneficial effects: by identifying the designated shape such as "back" from the two-dimensional code image, determine the size of the code grains that constitute the two-dimensional code, and use this as a
  • the benchmark divides the two-dimensional code image into grids, and can generate standard two-dimensional codes according to the image content of each grid, and can further analyze the two-dimensional codes, which is easy to implement, high in accuracy and efficiency, and low in cost.
  • FIG. 1 shows a schematic flow diagram of a two-dimensional code image processing method according to an embodiment of the present application
  • Fig. 2 shows the image obtained by shooting the micro two-dimensional code on the main board
  • Fig. 3 shows the image obtained by converting Fig. 2 to grayscale adaptive binarization
  • Fig. 4 shows the base image obtained according to Fig. 3;
  • Fig. 5 shows a schematic diagram of the effective area obtained according to Fig. 4.
  • Fig. 6 shows the two-dimensional code image obtained according to Fig. 5;
  • Fig. 7 shows the designated area determined according to Fig. 6;
  • Fig. 8 shows the two-dimensional code image obtained according to Fig. 6 after dividing the grid
  • Fig. 9 shows a schematic diagram of a standard two-dimensional code generated according to Fig. 6;
  • Fig. 10 shows a schematic structural diagram of a two-dimensional code image processing device according to an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of an electronic device in an embodiment of the present application.
  • Fig. 1 shows a schematic flowchart of a method for processing a two-dimensional code image according to an embodiment of the present application.
  • the two-dimensional code image processing method includes:
  • Step S110 identifying the specified shape included in the two-dimensional code from the two-dimensional code image.
  • QR codes usually contain special shapes such as the character "Hui", and these shapes can be used as specified shapes for determining the size of code particles. There are many ways to recognize the specified shape. For example, a pre-trained recognition model may be used to recognize a two-dimensional code image, or a template matching method may be used, which is not limited in this embodiment.
  • Step S120 determining the size of the code grains in the two-dimensional code image according to the specified shape.
  • a code particle is the smallest unit that constitutes a two-dimensional code, such as the aforementioned "Hui” font, each side of “Hui” is composed of several code particles, so the size of the code particle can be determined according to the specified shape.
  • Step S130 using the size of the code grain as a grid reference, to divide the grid in the two-dimensional code image.
  • step S140 can be executed.
  • Step S140 generating a standard two-dimensional code according to the image content in each grid.
  • the grid is the foreground or the background part of the two-dimensional code according to the average value of the pixel values in the grid, so as to avoid misjudgment caused by wear and tear or blurred photos.
  • the method shown in Figure 1 utilizes the characteristic that the two-dimensional code is composed of code particles, reconstructs the standard two-dimensional code based on the two-dimensional code image, and uses the special designation such as the "back" shape in the two-dimensional code image
  • the shape makes the determined code particle size more accurate, improves the reconstruction accuracy of standard two-dimensional codes, and thus improves the accuracy of subsequent two-dimensional code analysis.
  • determining the size of the code particles in the two-dimensional code image according to the specified shape in step S120 includes: according to the ratio of the size of each side in the specified shape to the number of code particles contained in it, and the size of each side in the two-dimensional code image The ratio of the size of and the number of code grains it contains determines the size of the code grains in the two-dimensional code image.
  • the size of the two-dimensional code image is 200 ⁇ 200 (pixels), and there are 10 code grains on the length and width, then in some embodiments, it can be calculated only based on these data, and the size of each code grain is 20 ⁇ 20 (pixels).
  • the size of the two-dimensional code image can also be inversely deduced according to the proportion of the specified shape in the two-dimensional code image.
  • a more accurate code can be obtained through comprehensive calculation based on the size of the two-dimensional code image and the number of code grains contained in each side of the two-dimensional code image. grain size.
  • the size of the code particles in the two-dimensional code image can be determined by the following formula:
  • micro_qrcode_width represents the width of the code grain
  • micro_qrcode_height represents the height of the code grain
  • the two-dimensional code image processing method further includes: acquiring a basic image containing the two-dimensional code; determining the area where the two-dimensional code is located from the basic image, and obtaining the two-dimensional code image according to the determined area.
  • FIG. 2 shows an image obtained by shooting a micro two-dimensional code on the main board.
  • the image can be converted to gray scale adaptive binarization, distortion correction, etc. to obtain the basic image containing the two-dimensional code.
  • FIG. 3 shows the image obtained by performing grayscale adaptive binarization on FIG. 2 ;
  • FIG. 4 shows the basic image obtained according to FIG. 3 .
  • the minimum circumscribed rectangle of the micro-two-dimensional code can be obtained first according to the method of maximum connected area, and four vertices point1, point2, point3 and point4 are obtained, and then distortion correction is performed on the rectangle to obtain Figure 4.
  • obtaining the two-dimensional code image according to the determined area includes: removing the noise of the basic image according to the outline of the basic image to obtain an effective area; determining the boundary line of the two-dimensional code image according to the outline of the effective area to obtain QR code image.
  • FIG. 5 shows a schematic diagram of the effective area obtained according to FIG. 4 .
  • the black part around the boundary line is basically removed, leaving only four corners and some remaining parts.
  • FIG. 6 shows the two-dimensional code image obtained according to FIG. 5 .
  • Fig. 4 to Fig. 6 also show positioning characters used for positioning, which are preserved in the above-mentioned process of obtaining the effective area.
  • the base image is a grayscale image
  • removing the noise of the base image includes: for each boundary line in the outline of the base image, according to the length of the boundary line and the first preset width , determine the first candidate region in the basic image; if the gray average value of the first candidate region is greater than the gray average value of the basic image, remove the first candidate region as a region containing noise.
  • the first candidate area Bottom_rect(0,y_bottom,width,k) corresponding to the lower boundary line;
  • the first candidate region Left_rect(x_left,0,k,height) corresponding to the left boundary line;
  • the first candidate region Right_rect(x_right,0,k,height) corresponding to the right boundary line.
  • Top_rect(0, y_top, width, k) Take Top_rect(0, y_top, width, k) as an example, 0 and y_top are the data normalized (normalized) coordinates of the center point of the area, width represents the width of the area, and k represents the height (thickness) of the area.
  • the first candidate area is regarded as an area containing noise and removed.
  • the upper boundary line of the basic image is moved down by k pixels as a whole, that is, the first candidate region corresponding to the original upper boundary line is removed.
  • the above noise removal can be performed multiple times, that is, after the new boundary line is obtained, the first candidate area is re-determined according to the new boundary line, and the gray level average value is compared until the boundary line is no longer needed. change.
  • the basic image is a grayscale image
  • determining the boundary line of the two-dimensional code image includes: for each boundary line in the outline of the effective area, according to the length of the boundary line and the second Preset width, determine the second candidate area in the effective area; if the gray average value of the second candidate area is less than the gray threshold, remove the second candidate area, and determine the two-dimensional code image according to the remaining part of the effective area borderline.
  • the determination of the second candidate region may refer to the above-mentioned embodiment, but the judgment standard is different from it, and the judgment is made by setting a gray threshold. For example, if the grayscale threshold is set to 255, then:
  • the removal of the second candidate region can also be performed multiple times until the boundary line does not need to be changed.
  • identifying the specified shape contained in the two-dimensional code from the two-dimensional code image includes: according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image, determine the specified shape in two The specified area in the QR code image; recognize the specified shape in the specified area.
  • the specified shape is usually at a fixed position in the QR code, but it may not be directly facing the QR code when shooting.
  • the image captured in Figure 2 should be rotated 90° counterclockwise. This makes it difficult to recognize the specified shape.
  • the embodiment of the present application proposes a method of judging according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image, which can overcome this problem.
  • the two-dimensional code image includes positioning characters, and the positioning character and the specified shape have a preset relative positional relationship; according to the distance between each boundary line of the two-dimensional code image and each boundary line of the base image, the specified
  • the specified area of the shape in the two-dimensional code image includes: among the boundary lines of the two-dimensional code image, the one closest to the corresponding boundary line of the base image (among the boundary lines of the two-dimensional code image, the corresponding boundary line of the base image The one with the smallest distance difference) is used as the target boundary line corresponding to the positioning character, and the position of the positioning character in the two-dimensional code image is determined according to the target boundary line; according to the position of the positioning character in the two-dimensional code image, and the relative positional relationship , to determine the specified area of the specified shape in the QR code image.
  • Figure 6 contains the characters "16AF". It can be seen that these characters should be located at the bottom of the two-dimensional code, and the character " ⁇ " should be located at the upper left of the two-dimensional code, accounting for about 1/4 of the entire two-dimensional code. Therefore, these characters can be used as positioning characters, and the positioning characters have a preset relative positional relationship with the designated shape.
  • the one closest to the corresponding boundary line of the base image is the target boundary line corresponding to the positioning character.
  • the position of "16AF" in the two-dimensional code image can be determined, and the designated area of the character "hui” in the two-dimensional code image can be further obtained.
  • the two-dimensional code image can also be rotated, and positioning characters that are not helpful for subsequent analysis can also be removed.
  • the specified shape can be accurately identified according to the connected region method by using the specified area where the specified shape is known.
  • the largest part of the connected area in the region where the "back" character is located in the upper right corner of the figure is 1/4, and the figure 7 is obtained (the gray scale inversion and other processing can be performed on figure 6 in advance).
  • FIG. 7 shows designated areas determined according to FIG. 6 .
  • FIG. 8 shows the grid-divided two-dimensional code image obtained according to FIG. 6 .
  • the pixel value of the grid may be compared with a preset condition to determine whether to generate a code particle of the two-dimensional code according to the grid.
  • This application gives two specific examples of preset conditions: the first preset condition is that the pixel value of the center point of the grid is equal to the first preset pixel value; the second preset condition is that the average value of the pixels of the grid is less than the first Two preset pixel values.
  • the pixel value Pixel_dst of the grid with m columns and n rows is processed as follows using the first preset condition (the first preset pixel value is set to 0):
  • gray(m, n) represents the pixel value of the center point of the grid.
  • the coordinates of the grid center point can be calculated as follows:
  • micro_qrcode_width is the width of the grid
  • micro_qrcode_height is the height of the grid.
  • the pixel value Pixel_dst of the grid with m columns and n rows is processed as follows by using the second preset condition (the second preset pixel value is set to 128):
  • average(m, n) represents the pixel average value of the grid.
  • FIG. 9 shows a schematic diagram of a standard two-dimensional code generated according to FIG. 6 .
  • the embodiment of the present application also provides a two-dimensional code image processing device, which is used to implement any of the above two-dimensional code image processing methods.
  • FIG. 10 shows a schematic structural diagram of a two-dimensional code image processing device according to an embodiment of the present application.
  • the two-dimensional code image processing device 1000 includes:
  • the recognition unit 1010 is configured to recognize the specified shape included in the two-dimensional code from the two-dimensional code image.
  • the size unit 1020 is configured to determine the size of the code grains in the two-dimensional code image according to the specified shape.
  • the grid unit 1030 is configured to divide the two-dimensional code image into a grid using the size of the code grain as a grid reference.
  • the generating unit 1040 is configured to generate a standard two-dimensional code according to the image content in each grid.
  • the size unit 1020 is used to, according to the ratio of the size of each side in the specified shape to the number of code grains it contains, and the ratio of the size of each side in the two-dimensional code image to the number of code grains it contains, Determine the size of the code grains in the QR code image.
  • the device further includes: a preprocessing unit, configured to obtain a basic image containing a two-dimensional code; determine the area where the two-dimensional code is located from the basic image, and obtain the two-dimensional code image according to the determined area.
  • a preprocessing unit configured to obtain a basic image containing a two-dimensional code; determine the area where the two-dimensional code is located from the basic image, and obtain the two-dimensional code image according to the determined area.
  • the preprocessing unit is configured to remove the noise of the basic image according to the outline of the basic image to obtain the effective area; according to the outline of the effective area, determine the boundary line of the two-dimensional code image to obtain the two-dimensional code image.
  • the basic image is a grayscale image
  • the preprocessing unit is used to determine the first boundary line in the basic image according to the length of the boundary line and the first preset width for each boundary line in the outline of the basic image.
  • a candidate area if the gray average value of the first candidate area is greater than the gray average value of the base image, then remove the first candidate area as an area containing noise.
  • the basic image is a grayscale image
  • the preprocessing unit is configured to determine the first boundary line in the effective area according to the length of the boundary line and the second preset width for each boundary line in the outline of the effective area. Two candidate areas; if the average gray value of the second candidate area is less than the gray threshold, the second candidate area is removed, and the boundary line of the two-dimensional code image is determined according to the remaining part of the effective area.
  • the recognition unit 1010 is configured to determine the specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the base image; in the specified area Recognizes the specified shape.
  • the two-dimensional code image includes positioning characters, and the positioning character has a preset relative positional relationship with the specified shape; the recognition unit 1010 is used to combine the boundary lines of the two-dimensional code image with the corresponding boundary lines of the base image The closest one is used as the target boundary line corresponding to the positioning character, and the position of the positioning character in the two-dimensional code image is determined according to the target boundary line; according to the position of the positioning character in the two-dimensional code image, and the relative positional relationship, determine the specified The specified area of the shape in the QR code image.
  • the generating unit 1040 is configured to: if the pixel value of the center point of a grid is equal to the first preset pixel value, or the average value of pixels of a grid is smaller than the second preset pixel value, then according to the network grid to generate a code grain of a standard QR code.
  • the above-mentioned two-dimensional code image processing device can realize each step of the two-dimensional code image processing method provided in the foregoing embodiments, and relevant explanations about the two-dimensional code image processing method are applicable to the two-dimensional code image processing device. I won't repeat them here.
  • Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory.
  • the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM random-Access Memory
  • non-volatile memory such as at least one disk memory.
  • the electronic device may also include hardware required by other services.
  • the processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc.
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 11 , but it does not mean that there is only one bus or one type of bus.
  • Memory for storing programs.
  • the program may include program code, and the program code includes computer operation instructions.
  • Storage which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a two-dimensional code image processing device on a logical level.
  • the two-dimensional code image processing device shown in FIG. 11 does not constitute a limit to the number of practical applications.
  • the processor executes the program stored in the memory, and is specifically used to perform the following operations:
  • the above method performed by the two-dimensional code image processing device disclosed in the embodiment shown in FIG. 1 of the present application may be applied to a processor or implemented by the processor.
  • a processor may be an integrated circuit chip with signal processing capabilities.
  • each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the electronic device can also execute the method performed by the two-dimensional code image processing device in FIG. 1 , and realize the functions of the two-dimensional code image processing device in the embodiment shown in FIG. 10 , which will not be repeated in this embodiment of the present application.
  • the embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs include instructions, and when the instructions are executed by an electronic device including a plurality of application programs , the electronic device can be made to execute the method executed by the two-dimensional code image processing device in the embodiment shown in FIG. 1, and is specifically used to execute:
  • the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
  • 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), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridge, tape magnetic disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
  • the embodiments of the present application may be provided as methods, systems or computer program products. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • a computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.

Abstract

Disclosed in the present application are a QR code image processing method and apparatus. The method comprises: identifying, from a QR code image, a specified shape included in a QR code; determining the size of a code particle in the QR code image according to the specified shape; dividing the QR code image into grids by taking the size of the code particle as a grid reference; and generating a standard QR code according to image content in each grid. In the technical solution, by means of a characteristic of a QR code being formed by code particles, a standard QR code is re-constructed on the basis of a QR code image; and the determined size of a code particle is more precise by means of a special specified shape, such as the shape of the Chinese character "回", in the QR code image, thereby improving the re-construction accuracy of the standard QR code, and improving the accuracy of subsequent QR code parsing.

Description

二维码图像处理方法和装置Two-dimensional code image processing method and device 技术领域technical field
本申请涉及图像处理领域,尤其涉及二维码图像处理方法和装置。The present application relates to the field of image processing, in particular to a two-dimensional code image processing method and device.
发明背景Background of the invention
二维码是指用某种特定的几何图形按一定规律在平面分布的黑白相间的记录数据符号信息的图形,对二维码进行解析可以获得其记录的数据符号信息。现有技术中的二维码解析方式通常是先通过摄像头获得二维码图像,再利用解析库完成二维码解析。但是,当二维码的尺寸较小,或者二维码有磨损等场景下,二维码图像的解析成功率不高。A two-dimensional code refers to a black and white graphic that records data symbol information distributed on a plane with a certain specific geometric figure according to a certain rule. Analyzing the two-dimensional code can obtain the recorded data symbol information. The two-dimensional code analysis method in the prior art usually obtains the two-dimensional code image through the camera first, and then uses the analysis library to complete the two-dimensional code analysis. However, when the size of the two-dimensional code is small, or the two-dimensional code is worn, the success rate of parsing the two-dimensional code image is not high.
发明内容Contents of the invention
本申请实施例提供了二维码图像处理方法和装置,能够根据二维码图像生成标准二维码,提高二维码图像的解析成功率。The embodiments of the present application provide a two-dimensional code image processing method and device, which can generate a standard two-dimensional code based on the two-dimensional code image, and improve the success rate of parsing the two-dimensional code image.
本申请实施例采用下述技术方案:The embodiment of the application adopts the following technical solutions:
第一方面,本申请实施例提供一种二维码图像处理方法,包括:从二维码图像中识别出二维码所包含的指定形状;根据指定形状确定二维码图像中码粒的尺寸;将码粒的尺寸作为网格基准,在二维码图像中划分出网格;根据各网格内的图像内容,生成标准二维码。In the first aspect, the embodiment of the present application provides a two-dimensional code image processing method, including: identifying the specified shape contained in the two-dimensional code from the two-dimensional code image; determining the size of the code grain in the two-dimensional code image according to the specified shape ;Using the size of the code grain as the grid reference, divide the grid in the two-dimensional code image; generate a standard two-dimensional code according to the image content in each grid.
第二方面,本申请实施例还提供一种二维码图像处理装置,用于实现如上的二维码图像处理方法。In a second aspect, the embodiment of the present application further provides a two-dimensional code image processing device, which is used to implement the above two-dimensional code image processing method.
在一些实施例中,二维码图像处理装置包括:识别单元,用于从二维码图像中识别出二维码所包含的指定形状;尺寸单元,用于根据指定形状确定二维码图像中码粒的尺寸;网格单元,用于将码粒的尺寸作为网格基准,在二维码图像中划分出网格;生成单元,用于根据各网格内的图像内容,生成标准二维码。In some embodiments, the two-dimensional code image processing device includes: a recognition unit, used to recognize the specified shape contained in the two-dimensional code from the two-dimensional code image; a size unit, used to determine the shape of the two-dimensional code image according to the specified shape The size of the code grain; the grid unit is used to divide the grid in the two-dimensional code image using the size of the code grain as a grid reference; the generation unit is used to generate a standard two-dimensional code according to the image content in each grid code.
第三方面,本申请实施例还提供一种电子设备,包括:处理器;以及被安 排成存储计算机可执行指令的存储器,可执行指令在被执行时使处理器执行如上的二维码图像处理方法。In the third aspect, the embodiment of the present application also provides an electronic device, including: a processor; and a memory arranged to store computer-executable instructions, and the executable instructions cause the processor to perform the above two-dimensional code image processing when executed method.
第四方面,本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质存储一个或多个程序,一个或多个程序当被包括多个应用程序的电子设备执行时,使得电子设备执行如上的二维码图像处理方法。In the fourth aspect, the embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including multiple application programs, the electronic The device executes the above two-dimensional code image processing method.
本申请实施例采用的上述至少一个技术方案能够达到以下有益效果:通过从二维码图像中识别出“回”字形等指定形状,确定出构成二维码的码粒的尺寸,并以此为基准对二维码图像进行网格划分,可以根据各网格的图像内容来生成标准二维码,并可进一步进行二维码解析,实现简便,准确度和效率都很高,成本较低。The above-mentioned at least one technical solution adopted in the embodiment of the present application can achieve the following beneficial effects: by identifying the designated shape such as "back" from the two-dimensional code image, determine the size of the code grains that constitute the two-dimensional code, and use this as a The benchmark divides the two-dimensional code image into grids, and can generate standard two-dimensional codes according to the image content of each grid, and can further analyze the two-dimensional codes, which is easy to implement, high in accuracy and efficiency, and low in cost.
附图简要说明Brief description of the drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described here are used to provide a further understanding of the application and constitute a part of the application. The schematic embodiments and descriptions of the application are used to explain the application and do not constitute an improper limitation to the application. In the attached picture:
图1示出了根据本申请一个实施例的二维码图像处理方法的流程示意图;FIG. 1 shows a schematic flow diagram of a two-dimensional code image processing method according to an embodiment of the present application;
图2图2示出了对主板上的微二维码进行拍摄得到的图像;Fig. 2 Fig. 2 shows the image obtained by shooting the micro two-dimensional code on the main board;
图3示出了对图2进行转灰度自适应二值化处理得到的图像;Fig. 3 shows the image obtained by converting Fig. 2 to grayscale adaptive binarization;
图4示出了根据图3得到的基础图像;Fig. 4 shows the base image obtained according to Fig. 3;
图5示出了根据图4得到的有效区域的示意图;Fig. 5 shows a schematic diagram of the effective area obtained according to Fig. 4;
图6示出了根据图5得到的二维码图像;Fig. 6 shows the two-dimensional code image obtained according to Fig. 5;
图7示出了根据图6确定的指定区域;Fig. 7 shows the designated area determined according to Fig. 6;
图8示出了根据图6得到的划分网格后的二维码图像;Fig. 8 shows the two-dimensional code image obtained according to Fig. 6 after dividing the grid;
图9示出了根据图6生成的标准二维码的示意图;Fig. 9 shows a schematic diagram of a standard two-dimensional code generated according to Fig. 6;
图10示出了根据本申请一个实施例的二维码图像处理装置的结构示意图。Fig. 10 shows a schematic structural diagram of a two-dimensional code image processing device according to an embodiment of the present application.
图11为本申请实施例中一种电子设备的结构示意图。FIG. 11 is a schematic structural diagram of an electronic device in an embodiment of the present application.
具体实施方式detailed description
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and corresponding drawings. Apparently, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
以下结合附图,详细说明本申请各实施例提供的技术方案。The technical solutions provided by various embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
图1示出了根据本申请一个实施例的二维码图像处理方法的流程示意图。如图1所示,二维码图像处理方法包括:Fig. 1 shows a schematic flowchart of a method for processing a two-dimensional code image according to an embodiment of the present application. As shown in Figure 1, the two-dimensional code image processing method includes:
步骤S110,从二维码图像中识别出二维码所包含的指定形状。Step S110, identifying the specified shape included in the two-dimensional code from the two-dimensional code image.
二维码中通常会包含“回”字等特殊的形状,这些形状可以作为用于确定码粒尺寸的指定形状。识别出该指定形状的方式有多种,例如可以通过预训练的识别模型对二维码图像进行识别,或者通过模板匹配等方式实现,本实施例对此不做限制。QR codes usually contain special shapes such as the character "Hui", and these shapes can be used as specified shapes for determining the size of code particles. There are many ways to recognize the specified shape. For example, a pre-trained recognition model may be used to recognize a two-dimensional code image, or a template matching method may be used, which is not limited in this embodiment.
步骤S120,根据指定形状确定二维码图像中码粒的尺寸。Step S120, determining the size of the code grains in the two-dimensional code image according to the specified shape.
码粒,是构成二维码的最小单元,例如前面所提到的“回”字形,“回”的每条边都由若干个码粒构成,因此可以根据指定形状的确定码粒的尺寸。A code particle is the smallest unit that constitutes a two-dimensional code, such as the aforementioned "Hui" font, each side of "Hui" is composed of several code particles, so the size of the code particle can be determined according to the specified shape.
步骤S130,将码粒的尺寸作为网格基准,在二维码图像中划分出网格。Step S130, using the size of the code grain as a grid reference, to divide the grid in the two-dimensional code image.
例如,一个码粒的尺寸为20×20(像素),那么可以以此为基准,选择二维码图像中非背景色的一处角点为坐标系原点,进行网格的划分,那么网格中就会存在着背景色或者非背景色,从而可以执行步骤S140。For example, if the size of a code grain is 20×20 (pixels), you can use this as a benchmark to select a corner point of the non-background color in the two-dimensional code image as the origin of the coordinate system to divide the grid, then the grid There will be a background color or a non-background color in , so that step S140 can be executed.
步骤S140,根据各网格内的图像内容,生成标准二维码。Step S140, generating a standard two-dimensional code according to the image content in each grid.
例如,可以根据网格内像素值的均值来判断该网格是二维码的前景还是背景部分,这样可以避免因磨损或者拍照模糊等原因带来的误判断。For example, it can be judged whether the grid is the foreground or the background part of the two-dimensional code according to the average value of the pixel values in the grid, so as to avoid misjudgment caused by wear and tear or blurred photos.
可见,图1所示的方法,利用二维码是由码粒组成这一特点,基于二维码图像重构出标准二维码,并且利用二维码图像中“回”字形等特殊的指定形状,使 确定出的码粒尺寸更加精准,提高了标准二维码的重构准确度,从而提升后续二维码解析的准确度。It can be seen that the method shown in Figure 1 utilizes the characteristic that the two-dimensional code is composed of code particles, reconstructs the standard two-dimensional code based on the two-dimensional code image, and uses the special designation such as the "back" shape in the two-dimensional code image The shape makes the determined code particle size more accurate, improves the reconstruction accuracy of standard two-dimensional codes, and thus improves the accuracy of subsequent two-dimensional code analysis.
在一些实施例中,步骤S120中根据指定形状确定二维码图像中码粒的尺寸包括:根据指定形状中各边的尺寸与其所包含的码粒数量的比值,以及二维码图像中各边的尺寸与其所包含的码粒数量的比值,确定二维码图像中码粒的尺寸。In some embodiments, determining the size of the code particles in the two-dimensional code image according to the specified shape in step S120 includes: according to the ratio of the size of each side in the specified shape to the number of code particles contained in it, and the size of each side in the two-dimensional code image The ratio of the size of and the number of code grains it contains determines the size of the code grains in the two-dimensional code image.
例如,二维码图像的尺寸是200×200(像素),长和宽上各有10个码粒,则在一些实施例中,可以仅根据这些数据计算,得到每个码粒的尺寸为20×20(像素)。由此,还可以根据指定形状在二维码图像中的比例,反推得到二维码图像的尺寸。For example, the size of the two-dimensional code image is 200 × 200 (pixels), and there are 10 code grains on the length and width, then in some embodiments, it can be calculated only based on these data, and the size of each code grain is 20 ×20 (pixels). Thus, the size of the two-dimensional code image can also be inversely deduced according to the proportion of the specified shape in the two-dimensional code image.
在另一些实施例中,在能够获知二维码图像尺寸的情况下,可以进一步根据二维码图像尺寸以及二维码图像中各边所包含的码粒数量的,综合计算得到更精准的码粒的尺寸。In other embodiments, when the size of the two-dimensional code image can be known, a more accurate code can be obtained through comprehensive calculation based on the size of the two-dimensional code image and the number of code grains contained in each side of the two-dimensional code image. grain size.
在一些实施例中,记指定形状的宽为width hui,高为height hui,宽和高方向上的码粒个数均为num hui;二维码图像的宽为width,高为height,宽和高方向上的码粒个数均为num,则可以通过如下公式确定二维码图像中码粒的尺寸: In some embodiments, remember that the width of the specified shape is width hui , the height is height hui , and the number of code grains in the width and height directions are both num hui ; the width of the two-dimensional code image is width, the height is height, and the width and The number of code particles in the high direction is num, then the size of the code particles in the two-dimensional code image can be determined by the following formula:
Figure PCTCN2022101359-appb-000001
Figure PCTCN2022101359-appb-000001
Figure PCTCN2022101359-appb-000002
Figure PCTCN2022101359-appb-000002
其中,micro_qrcode_width表示码粒的宽,micro_qrcode_height表示码粒的高。Among them, micro_qrcode_width represents the width of the code grain, and micro_qrcode_height represents the height of the code grain.
在一些实施例中,二维码图像处理方法还包括:获取包含二维码的基础图像;从基础图像中确定出二维码所在的区域,根据确定出的区域得到二维码图像。In some embodiments, the two-dimensional code image processing method further includes: acquiring a basic image containing the two-dimensional code; determining the area where the two-dimensional code is located from the basic image, and obtaining the two-dimensional code image according to the determined area.
现今VR(Virtual Reality,虚拟现实)产品火爆,VR产品的主板上通常设置有较小的二维码,即微二维码,用于表征主板的序列号,一般地可通过扫码枪扫描微二维码进行识别,但是成本高,效果差。例如,图2示出了对主板上的微二维码进行拍摄得到的图像。该图像可以经过转灰度自适应二值化、畸变 校正等处理,得到包含二维码的基础图像。Nowadays, VR (Virtual Reality, virtual reality) products are popular, and the motherboard of VR products is usually equipped with a small QR code, that is, a micro QR code, which is used to represent the serial number of the motherboard. Two-dimensional codes are used for identification, but the cost is high and the effect is poor. For example, FIG. 2 shows an image obtained by shooting a micro two-dimensional code on the main board. The image can be converted to gray scale adaptive binarization, distortion correction, etc. to obtain the basic image containing the two-dimensional code.
具体地,图3示出了对图2进行转灰度自适应二值化处理得到的图像;图4示出了根据图3得到的基础图像。其中,对图3可以根据最大连通区域法先获取微二维码的最小外接矩形,得到四个顶点point1、point2、point3和point4,然后对该矩形进行畸变校正,得到图4。Specifically, FIG. 3 shows the image obtained by performing grayscale adaptive binarization on FIG. 2 ; FIG. 4 shows the basic image obtained according to FIG. 3 . Among them, for Figure 3, the minimum circumscribed rectangle of the micro-two-dimensional code can be obtained first according to the method of maximum connected area, and four vertices point1, point2, point3 and point4 are obtained, and then distortion correction is performed on the rectangle to obtain Figure 4.
可以看出,图4的上下左右四条边界线附近遗留有未去除的黑色部分,可以进一步进行处理,确定出二维码所在的区域,得到可供使用的二维码图像。It can be seen that there are unremoved black parts left near the four boundary lines in Figure 4, which can be further processed to determine the area where the two-dimensional code is located and obtain a usable two-dimensional code image.
在一些实施例中,根据确定出的区域得到二维码图像包括:根据基础图像的轮廓,去除基础图像的噪点,得到有效区域;根据有效区域的轮廓,确定二维码图像的边界线,得到二维码图像。In some embodiments, obtaining the two-dimensional code image according to the determined area includes: removing the noise of the basic image according to the outline of the basic image to obtain an effective area; determining the boundary line of the two-dimensional code image according to the outline of the effective area to obtain QR code image.
参考图4,先尽量去除四条边界线周围的黑色部分,这些黑色像素点可以认为是噪点。图5示出了根据图4得到的有效区域的示意图。如图5所示,边界线周围的黑色部分基本被去除,只剩下四个角还有部分残留,同时,二维码距离有效区域的轮廓还有很大一部分无用的白色区域,这些都可以再进行去除,最终得到二维码图像,图6示出了根据图5得到的二维码图像。另外,图4~图6中除了二维码外,还示出了用于定位的定位字符,这在上述得到有效区域的过程中得到了保留。Referring to Figure 4, first try to remove the black parts around the four border lines, these black pixels can be considered as noise. FIG. 5 shows a schematic diagram of the effective area obtained according to FIG. 4 . As shown in Figure 5, the black part around the boundary line is basically removed, leaving only four corners and some remaining parts. At the same time, there is a large part of useless white area between the two-dimensional code and the outline of the effective area. These can be Removal is performed to finally obtain a two-dimensional code image, and FIG. 6 shows the two-dimensional code image obtained according to FIG. 5 . In addition, in addition to the two-dimensional code, Fig. 4 to Fig. 6 also show positioning characters used for positioning, which are preserved in the above-mentioned process of obtaining the effective area.
在一些实施例中,基础图像为灰度图像,根据基础图像的轮廓,去除基础图像的噪点包括:对基础图像的轮廓中的每段边界线,根据该边界线的长度和第一预设宽度,在基础图像中确定第一候选区域;若该第一候选区域的灰度均值大于基础图像的灰度均值,则将该第一候选区域作为包含噪点的区域进行去除。In some embodiments, the base image is a grayscale image, and according to the outline of the base image, removing the noise of the base image includes: for each boundary line in the outline of the base image, according to the length of the boundary line and the first preset width , determine the first candidate region in the basic image; if the gray average value of the first candidate region is greater than the gray average value of the basic image, remove the first candidate region as a region containing noise.
例如,记第一预设宽度为k像素,在本实施例中令k=1,则通过上下左右四段边界线,分别往中心截取厚度为1的四个矩形的第一候选区域,分别记为:For example, record the first preset width as k pixels, let k=1 in this embodiment, then through four sections of boundary lines up, down, left, and right, respectively go to the center to intercept the first candidate areas of four rectangles with a thickness of 1, record respectively for:
上边界线对应的第一候选区域Top_rect(0,y_top,width,k);The first candidate area Top_rect(0,y_top,width,k) corresponding to the upper boundary line;
下边界线对应的第一候选区域Bottom_rect(0,y_bottom,width,k);The first candidate area Bottom_rect(0,y_bottom,width,k) corresponding to the lower boundary line;
左边界线对应的第一候选区域Left_rect(x_left,0,k,height);以及The first candidate region Left_rect(x_left,0,k,height) corresponding to the left boundary line; and
右边界线对应的第一候选区域Right_rect(x_right,0,k,height)。The first candidate region Right_rect(x_right,0,k,height) corresponding to the right boundary line.
以Top_rect(0,y_top,width,k)为例进行说明,0、y_top是该区域的中心点的数据规范化(normalized)坐标,width代表该区域的宽度,k代表该区域的高度(厚度)。Take Top_rect(0, y_top, width, k) as an example, 0 and y_top are the data normalized (normalized) coordinates of the center point of the area, width represents the width of the area, and k represents the height (thickness) of the area.
分别计算上述四个第一候选区域内的灰度均值gray_average_top,gray_average_bottom,gray_average_left,gray_average_right,以及计算整图(基础图像)的灰度均值gray_average;Calculate the gray average gray_average_top, gray_average_bottom, gray_average_left, gray_average_right in the above four first candidate regions, and calculate the gray average gray_average of the whole image (basic image);
如果一个第一候选区域的灰度均值大于基础图像的灰度均值,则将该第一候选区域作为包含噪点的区域进行去除。If the gray average value of a first candidate area is greater than the gray average value of the base image, the first candidate area is regarded as an area containing noise and removed.
以Top_rect(0,y_top,width,k)为例,该区域的灰度均值gray_average_top与基础图像的灰度均值gray_average之间判定条件如下:Taking Top_rect(0,y_top,width,k) as an example, the determination conditions between the gray average gray_average_top of this area and the gray average gray_average of the base image are as follows:
Figure PCTCN2022101359-appb-000003
Figure PCTCN2022101359-appb-000003
也就是如果该区域的灰度均值大于基础图像的灰度均值,就将基础图像的上段边界线整体下移k像素,也就是去除了与原上段边界线对应的第一候选区域。That is, if the gray mean value of the region is greater than the gray mean value of the basic image, the upper boundary line of the basic image is moved down by k pixels as a whole, that is, the first candidate region corresponding to the original upper boundary line is removed.
同理,In the same way,
Figure PCTCN2022101359-appb-000004
Figure PCTCN2022101359-appb-000004
Figure PCTCN2022101359-appb-000005
Figure PCTCN2022101359-appb-000005
Figure PCTCN2022101359-appb-000006
Figure PCTCN2022101359-appb-000006
在一些实施例中,上述噪点的去除可以进行多次,即得到新的边界线后,再根据新的边界线重新确定第一候选区域,进行灰度均值的比较,直到不需要对边界线进行变动。In some embodiments, the above noise removal can be performed multiple times, that is, after the new boundary line is obtained, the first candidate area is re-determined according to the new boundary line, and the gray level average value is compared until the boundary line is no longer needed. change.
在一些实施例中,基础图像为灰度图像,根据有效区域的轮廓,确定二维码图像的边界线包括:对有效区域的轮廓中的每段边界线,根据该边界线的长度和第二预设宽度,在有效区域中确定第二候选区域;若该第二候选区域的灰 度均值小于灰度阈值,则将该第二候选区域进行去除,根据有效区域的剩余部分确定二维码图像的边界线。In some embodiments, the basic image is a grayscale image, and according to the outline of the effective area, determining the boundary line of the two-dimensional code image includes: for each boundary line in the outline of the effective area, according to the length of the boundary line and the second Preset width, determine the second candidate area in the effective area; if the gray average value of the second candidate area is less than the gray threshold, remove the second candidate area, and determine the two-dimensional code image according to the remaining part of the effective area borderline.
第二候选区域的确定可以参照前述实施例,但是判断标准与其不同,是通过设置灰度阈值来进行判断。例如设置灰度阈值为255,则:The determination of the second candidate region may refer to the above-mentioned embodiment, but the judgment standard is different from it, and the judgment is made by setting a gray threshold. For example, if the grayscale threshold is set to 255, then:
Figure PCTCN2022101359-appb-000007
Figure PCTCN2022101359-appb-000007
Figure PCTCN2022101359-appb-000008
Figure PCTCN2022101359-appb-000008
Figure PCTCN2022101359-appb-000009
Figure PCTCN2022101359-appb-000009
Figure PCTCN2022101359-appb-000010
Figure PCTCN2022101359-appb-000010
同样地,去除第二候选区域也可以进行多次,直到边界线不需要再进行变动。Similarly, the removal of the second candidate region can also be performed multiple times until the boundary line does not need to be changed.
在一些实施例中,从二维码图像中识别出二维码所包含的指定形状包括:根据二维码图像的各边界线与基础图像的各边界线之间的距离,确定指定形状在二维码图像中的指定区域;在指定区域中识别指定形状。In some embodiments, identifying the specified shape contained in the two-dimensional code from the two-dimensional code image includes: according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image, determine the specified shape in two The specified area in the QR code image; recognize the specified shape in the specified area.
指定形状由于其形状的特殊性,通常处于二维码中的固定位置,但是拍摄时可能并不是正对着二维码进行拍摄,例如图2中拍摄的图像应当逆时针旋转90°。这就为识别出指定形状带来了困难。本申请的实施例提出了依据二维码图像的各边界线与基础图像的各边界线之间的距离来判断的方式,能够克服这一点。Due to its particular shape, the specified shape is usually at a fixed position in the QR code, but it may not be directly facing the QR code when shooting. For example, the image captured in Figure 2 should be rotated 90° counterclockwise. This makes it difficult to recognize the specified shape. The embodiment of the present application proposes a method of judging according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image, which can overcome this problem.
在一些实施例中,二维码图像包含定位字符,定位字符与指定形状具有预设的相对位置关系;根据二维码图像的各边界线与基础图像的各边界线之间的距离,确定指定形状在二维码图像中的指定区域包括:将二维码图像的边界线中,与基础图像的相应边界线距离最近的一条(二维码图像的边界线中,与基础图像的相应边界线距离差值最小的一条)作为与定位字符对应的目标边界线,根据该目标边界线确定定位字符在二维码图像中的位置;根据定位字符在二维码图像中的位置,以及相对位置关系,确定指定形状在二维码图像中的指定区 域。In some embodiments, the two-dimensional code image includes positioning characters, and the positioning character and the specified shape have a preset relative positional relationship; according to the distance between each boundary line of the two-dimensional code image and each boundary line of the base image, the specified The specified area of the shape in the two-dimensional code image includes: among the boundary lines of the two-dimensional code image, the one closest to the corresponding boundary line of the base image (among the boundary lines of the two-dimensional code image, the corresponding boundary line of the base image The one with the smallest distance difference) is used as the target boundary line corresponding to the positioning character, and the position of the positioning character in the two-dimensional code image is determined according to the target boundary line; according to the position of the positioning character in the two-dimensional code image, and the relative positional relationship , to determine the specified area of the specified shape in the QR code image.
例如,图6中包含字符“16AF”,可以看出这些字符应当是位于二维码的下方,而“回”字形应当位于二维码的左上方,占整个二维码约1/4,由此可以将这些字符作为定位字符,定位字符与指定形状具有预设的相对位置关系。For example, Figure 6 contains the characters "16AF". It can be seen that these characters should be located at the bottom of the two-dimensional code, and the character "回" should be located at the upper left of the two-dimensional code, accounting for about 1/4 of the entire two-dimensional code. Therefore, these characters can be used as positioning characters, and the positioning characters have a preset relative positional relationship with the designated shape.
并且可以看出,与基础图像的相应边界线距离最近的一条,就是与定位字符对应的目标边界线。由此,就能够确定“16AF”在二维码图像中的位置,并进一步可以得到“回”字形在二维码图像中的指定区域。And it can be seen that the one closest to the corresponding boundary line of the base image is the target boundary line corresponding to the positioning character. In this way, the position of "16AF" in the two-dimensional code image can be determined, and the designated area of the character "hui" in the two-dimensional code image can be further obtained.
进一步地,还可以对二维码图像进行旋转,也可以去除对后续解析没有帮助的定位字符。Furthermore, the two-dimensional code image can also be rotated, and positioning characters that are not helpful for subsequent analysis can also be removed.
在一些实施例中,利用获知的指定形状所在的指定区域中,可以根据连通区域法来准确地识别出指定形状,例如,指定区域为图像右上角方位的1/4图像所在的区域,则计算图右上角1/4处“回”字形所在的区域中连通区域最大的部分,得到图7(可预先对图6进行灰度反转等处理)。图7示出了根据图6确定的指定区域。In some embodiments, the specified shape can be accurately identified according to the connected region method by using the specified area where the specified shape is known. The largest part of the connected area in the region where the "back" character is located in the upper right corner of the figure is 1/4, and the figure 7 is obtained (the gray scale inversion and other processing can be performed on figure 6 in advance). FIG. 7 shows designated areas determined according to FIG. 6 .
在一些实施例中,根据各网格内的图像内容,生成标准二维码包括:若一个网格的中心点的像素值等于第一预设像素值,或者一个网格的像素平均值小于第二预设像素值,则根据该网格生成标准二维码的一个码粒。In some embodiments, according to the image content in each grid, generating the standard two-dimensional code includes: if the pixel value of the center point of a grid is equal to the first preset pixel value, or the average value of the pixels of a grid is less than the first If two preset pixel values are used, a code particle of a standard two-dimensional code is generated according to the grid.
图8示出了根据图6得到的划分网格后的二维码图像。在本申请的实施例中,可以利用网格的像素值与预设条件进行比较,来确定是否要根据该网格生成二维码的一个码粒。本申请给出了预设条件的两个具体示例:第一预设条件为网格的中心点的像素值等于第一预设像素值;第二预设条件为网格的像素平均值小于第二预设像素值。FIG. 8 shows the grid-divided two-dimensional code image obtained according to FIG. 6 . In the embodiment of the present application, the pixel value of the grid may be compared with a preset condition to determine whether to generate a code particle of the two-dimensional code according to the grid. This application gives two specific examples of preset conditions: the first preset condition is that the pixel value of the center point of the grid is equal to the first preset pixel value; the second preset condition is that the average value of the pixels of the grid is less than the first Two preset pixel values.
一种方式下,对m列n行的网格的像素值Pixel_dst,利用第一预设条件(第一预设像素值设为0)进行如下处理:In one way, the pixel value Pixel_dst of the grid with m columns and n rows is processed as follows using the first preset condition (the first preset pixel value is set to 0):
Figure PCTCN2022101359-appb-000011
Figure PCTCN2022101359-appb-000011
其中,gray(m,n)表示网格中心点的像素值。网格中心点的坐标可以通过如 下方式计算:Among them, gray(m, n) represents the pixel value of the center point of the grid. The coordinates of the grid center point can be calculated as follows:
中心点坐标=(x+micro_qrcode_width/2,y+micro_qrcode_height/2)Center point coordinates = (x+micro_qrcode_width/2, y+micro_qrcode_height/2)
其中,(x,y)为网格左上角坐标,micro_qrcode_width为网格宽度,micro_qrcode_height为网格高度。Among them, (x, y) is the coordinate of the upper left corner of the grid, micro_qrcode_width is the width of the grid, and micro_qrcode_height is the height of the grid.
另一种方式下,对m列n行的网格的像素值Pixel_dst,利用第二预设条件(第二预设像素值设为128)进行如下处理:In another way, the pixel value Pixel_dst of the grid with m columns and n rows is processed as follows by using the second preset condition (the second preset pixel value is set to 128):
Figure PCTCN2022101359-appb-000012
Figure PCTCN2022101359-appb-000012
其中,average(m,n)表示网格的像素平均值。Among them, average(m, n) represents the pixel average value of the grid.
最终处理为255的网格,则对应二维码中的白色背景,处理为0的网格,对应二维码中的黑色前景,也就是一个码粒。图9示出了根据图6生成的标准二维码的示意图。The final processed grid of 255 corresponds to the white background in the QR code, and the grid processed as 0 corresponds to the black foreground in the QR code, that is, a code particle. FIG. 9 shows a schematic diagram of a standard two-dimensional code generated according to FIG. 6 .
当然,除了上面示例性示出的两种预设条件外,本领域技术人员还可以选择用其他方式来实现判断。Of course, in addition to the two preset conditions exemplarily shown above, those skilled in the art may choose to implement the judgment in other ways.
本申请实施例还提供一种二维码图像处理装置,用于实现如上任一的二维码图像处理方法。The embodiment of the present application also provides a two-dimensional code image processing device, which is used to implement any of the above two-dimensional code image processing methods.
图10示出了根据本申请一个实施例的二维码图像处理装置的结构示意图,如图10所示,二维码图像处理装置1000包括:FIG. 10 shows a schematic structural diagram of a two-dimensional code image processing device according to an embodiment of the present application. As shown in FIG. 10 , the two-dimensional code image processing device 1000 includes:
识别单元1010,用于从二维码图像中识别出二维码所包含的指定形状。The recognition unit 1010 is configured to recognize the specified shape included in the two-dimensional code from the two-dimensional code image.
尺寸单元1020,用于根据指定形状确定二维码图像中码粒的尺寸。The size unit 1020 is configured to determine the size of the code grains in the two-dimensional code image according to the specified shape.
网格单元1030,用于将码粒的尺寸作为网格基准,在二维码图像中划分出网格。The grid unit 1030 is configured to divide the two-dimensional code image into a grid using the size of the code grain as a grid reference.
生成单元1040,用于根据各网格内的图像内容,生成标准二维码。The generating unit 1040 is configured to generate a standard two-dimensional code according to the image content in each grid.
在一些实施例中,尺寸单元1020,用于根据指定形状中各边的尺寸与其所包含的码粒数量的比值,以及二维码图像中各边的尺寸与其所包含的码粒数量的比值,确定二维码图像中码粒的尺寸。In some embodiments, the size unit 1020 is used to, according to the ratio of the size of each side in the specified shape to the number of code grains it contains, and the ratio of the size of each side in the two-dimensional code image to the number of code grains it contains, Determine the size of the code grains in the QR code image.
在一些实施例中,装置还包括:预处理单元,用于获取包含二维码的基础 图像;从基础图像中确定出二维码所在的区域,根据确定出的区域得到二维码图像。In some embodiments, the device further includes: a preprocessing unit, configured to obtain a basic image containing a two-dimensional code; determine the area where the two-dimensional code is located from the basic image, and obtain the two-dimensional code image according to the determined area.
在一些实施例中,预处理单元,用于根据基础图像的轮廓,去除基础图像的噪点,得到有效区域;根据有效区域的轮廓,确定二维码图像的边界线,得到二维码图像。In some embodiments, the preprocessing unit is configured to remove the noise of the basic image according to the outline of the basic image to obtain the effective area; according to the outline of the effective area, determine the boundary line of the two-dimensional code image to obtain the two-dimensional code image.
在一些实施例中,基础图像为灰度图像,预处理单元,用于对基础图像的轮廓中的每段边界线,根据该边界线的长度和第一预设宽度,在基础图像中确定第一候选区域;若该第一候选区域的灰度均值大于基础图像的灰度均值,则将该第一候选区域作为包含噪点的区域进行去除。In some embodiments, the basic image is a grayscale image, and the preprocessing unit is used to determine the first boundary line in the basic image according to the length of the boundary line and the first preset width for each boundary line in the outline of the basic image. A candidate area; if the gray average value of the first candidate area is greater than the gray average value of the base image, then remove the first candidate area as an area containing noise.
在一些实施例中,基础图像为灰度图像,预处理单元,用于对有效区域的轮廓中的每段边界线,根据该边界线的长度和第二预设宽度,在有效区域中确定第二候选区域;若该第二候选区域的灰度均值小于灰度阈值,则将该第二候选区域进行去除,根据有效区域的剩余部分确定二维码图像的边界线。In some embodiments, the basic image is a grayscale image, and the preprocessing unit is configured to determine the first boundary line in the effective area according to the length of the boundary line and the second preset width for each boundary line in the outline of the effective area. Two candidate areas; if the average gray value of the second candidate area is less than the gray threshold, the second candidate area is removed, and the boundary line of the two-dimensional code image is determined according to the remaining part of the effective area.
在一些实施例中,识别单元1010,用于根据二维码图像的各边界线与基础图像的各边界线之间的距离,确定指定形状在二维码图像中的指定区域;在指定区域中识别指定形状。In some embodiments, the recognition unit 1010 is configured to determine the specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the base image; in the specified area Recognizes the specified shape.
在一些实施例中,二维码图像包含定位字符,定位字符与指定形状具有预设的相对位置关系;识别单元1010,用于将二维码图像的边界线中,与基础图像的相应边界线距离最近的一条作为与定位字符对应的目标边界线,根据该目标边界线确定定位字符在二维码图像中的位置;根据定位字符在二维码图像中的位置,以及相对位置关系,确定指定形状在二维码图像中的指定区域。In some embodiments, the two-dimensional code image includes positioning characters, and the positioning character has a preset relative positional relationship with the specified shape; the recognition unit 1010 is used to combine the boundary lines of the two-dimensional code image with the corresponding boundary lines of the base image The closest one is used as the target boundary line corresponding to the positioning character, and the position of the positioning character in the two-dimensional code image is determined according to the target boundary line; according to the position of the positioning character in the two-dimensional code image, and the relative positional relationship, determine the specified The specified area of the shape in the QR code image.
在一些实施例中,生成单元1040,用于若一个网格的中心点的像素值等于第一预设像素值,或者一个网格的像素平均值小于第二预设像素值,则根据该网格生成标准二维码的一个码粒。In some embodiments, the generating unit 1040 is configured to: if the pixel value of the center point of a grid is equal to the first preset pixel value, or the average value of pixels of a grid is smaller than the second preset pixel value, then according to the network grid to generate a code grain of a standard QR code.
能够理解,上述二维码图像处理装置,能够实现前述实施例中提供的二维码图像处理方法的各个步骤,关于二维码图像处理方法的相关阐释均适用于二维码图像处理装置,此处不再赘述。It can be understood that the above-mentioned two-dimensional code image processing device can realize each step of the two-dimensional code image processing method provided in the foregoing embodiments, and relevant explanations about the two-dimensional code image processing method are applicable to the two-dimensional code image processing device. I won't repeat them here.
图11是本申请的一个实施例电子设备的结构示意图。请参考图11,在硬件层面,该电子设备包括处理器,可选地还包括内部总线、网络接口、存储器。其中,存储器可能包含内存,例如高速随机存取存储器(Random-Access Memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少1个磁盘存储器等。当然,该电子设备还可能包括其他业务所需要的硬件。Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Please refer to FIG. 11 , at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Wherein, the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Of course, the electronic device may also include hardware required by other services.
处理器、网络接口和存储器可以通过内部总线相互连接,该内部总线可以是ISA(Industry Standard Architecture,工业标准体系结构)总线、PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图11中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc. The bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 11 , but it does not mean that there is only one bus or one type of bus.
存储器,用于存放程序。具体地,程序可以包括程序代码,程序代码包括计算机操作指令。存储器可以包括内存和非易失性存储器,并向处理器提供指令和数据。Memory for storing programs. Specifically, the program may include program code, and the program code includes computer operation instructions. Storage, which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成二维码图像处理装置。图11中示出的二维码图像处理装置不构成实际应用时的数量限制。处理器,执行存储器所存放的程序,并具体用于执行以下操作:The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a two-dimensional code image processing device on a logical level. The two-dimensional code image processing device shown in FIG. 11 does not constitute a limit to the number of practical applications. The processor executes the program stored in the memory, and is specifically used to perform the following operations:
从二维码图像中识别出二维码所包含的指定形状;根据指定形状确定二维码图像中码粒的尺寸;将码粒的尺寸作为网格基准,在二维码图像中划分出网格;根据各网格内的图像内容,生成标准二维码。Identify the specified shape contained in the two-dimensional code from the two-dimensional code image; determine the size of the code grain in the two-dimensional code image according to the specified shape; use the size of the code grain as the grid reference, and divide the grid in the two-dimensional code image grid; according to the image content in each grid, a standard QR code is generated.
上述如本申请图1所示实施例揭示的二维码图像处理装置执行的方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成 电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。The above method performed by the two-dimensional code image processing device disclosed in the embodiment shown in FIG. 1 of the present application may be applied to a processor or implemented by the processor. A processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
该电子设备还可执行图1中二维码图像处理装置执行的方法,并实现二维码图像处理装置在图10所示实施例的功能,本申请实施例在此不再赘述。The electronic device can also execute the method performed by the two-dimensional code image processing device in FIG. 1 , and realize the functions of the two-dimensional code image processing device in the embodiment shown in FIG. 10 , which will not be repeated in this embodiment of the present application.
本申请实施例还提出了一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令,该指令当被包括多个应用程序的电子设备执行时,能够使该电子设备执行图1所示实施例中二维码图像处理装置执行的方法,并具体用于执行:The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs include instructions, and when the instructions are executed by an electronic device including a plurality of application programs , the electronic device can be made to execute the method executed by the two-dimensional code image processing device in the embodiment shown in FIG. 1, and is specifically used to execute:
从二维码图像中识别出二维码所包含的指定形状;根据指定形状确定二维码图像中码粒的尺寸;将码粒的尺寸作为网格基准,在二维码图像中划分出网格;根据各网格内的图像内容,生成标准二维码。Identify the specified shape contained in the two-dimensional code from the two-dimensional code image; determine the size of the code grain in the two-dimensional code image according to the specified shape; use the size of the code grain as the grid reference, and divide the grid in the two-dimensional code image grid; according to the image content in each grid, a standard QR code is generated.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式 处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowcharts and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. 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), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridge, tape magnetic disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程 序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems or computer program products. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
以上仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above are only examples of the present application, and are not intended to limit the present application. For those skilled in the art, various modifications and changes may occur in this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims (19)

  1. 一种二维码图像处理方法,包括:A two-dimensional code image processing method, comprising:
    从二维码图像中识别出二维码所包含的指定形状;Identify the specified shape contained in the two-dimensional code from the two-dimensional code image;
    根据所述指定形状确定所述二维码图像中码粒的尺寸;determining the size of code grains in the two-dimensional code image according to the specified shape;
    将所述码粒的尺寸作为网格基准,在所述二维码图像中划分出网格;Using the size of the code grain as a grid reference, dividing the grid in the two-dimensional code image;
    根据各网格内的图像内容,生成标准二维码。According to the image content in each grid, a standard two-dimensional code is generated.
  2. 如权利要求1所述的方法,其中,所述根据所述指定形状确定所述二维码图像中码粒的尺寸包括:The method according to claim 1, wherein said determining the size of code grains in said two-dimensional code image according to said specified shape comprises:
    根据所述指定形状中各边的尺寸与其所包含的码粒数量的比值,以及所述二维码图像中各边的尺寸与其所包含的码粒数量的比值,确定所述二维码图像中码粒的尺寸。According to the ratio of the size of each side in the specified shape to the number of code grains it contains, and the ratio of the size of each side in the two-dimensional code image to the number of code grains it contains, determine the two-dimensional code image The size of the grains.
  3. 如权利要求1或2所述的方法,其中,所述方法还包括:The method according to claim 1 or 2, wherein said method further comprises:
    获取包含二维码的基础图像;Get the base image containing the QR code;
    从所述基础图像中确定出二维码所在的区域,根据确定出的区域得到所述二维码图像。The area where the two-dimensional code is located is determined from the basic image, and the image of the two-dimensional code is obtained according to the determined area.
  4. 如权利要求3所述的方法,其中,所述根据确定出的区域得到所述二维码图像包括:The method according to claim 3, wherein said obtaining the two-dimensional code image according to the determined area comprises:
    根据所述基础图像的轮廓,去除所述基础图像的噪点,得到有效区域;removing the noise of the basic image according to the outline of the basic image to obtain an effective area;
    根据所述有效区域的轮廓,确定二维码图像的边界线,得到所述二维码图像。Determine the boundary line of the two-dimensional code image according to the outline of the effective area, and obtain the two-dimensional code image.
  5. 如权利要求4所述的方法,其中,所述基础图像为灰度图像,所述根据所述基础图像的轮廓,去除所述基础图像的噪点包括:The method according to claim 4, wherein the basic image is a grayscale image, and removing the noise of the basic image according to the outline of the basic image comprises:
    对所述基础图像的轮廓中的每段边界线,根据该边界线的长度和第一预设宽度,在所述基础图像中确定第一候选区域;For each boundary line in the outline of the basic image, determine a first candidate area in the basic image according to the length of the boundary line and the first preset width;
    若该第一候选区域的灰度均值大于所述基础图像的灰度均值,则将该第一候选区域作为包含噪点的区域进行去除。If the gray average value of the first candidate area is greater than the gray average value of the basic image, then remove the first candidate area as an area containing noise.
  6. 如权利要求4所述的方法,其中,所述基础图像为灰度图像,所述根据所述有效区域的轮廓,确定二维码图像的边界线包括:The method according to claim 4, wherein the basic image is a grayscale image, and determining the boundary line of the two-dimensional code image according to the outline of the effective area comprises:
    对所述有效区域的轮廓中的每段边界线,根据该边界线的长度和第二预设宽度,在所述有效区域中确定第二候选区域;For each boundary line in the outline of the effective area, determine a second candidate area in the effective area according to the length of the boundary line and a second preset width;
    若该第二候选区域的灰度均值小于灰度阈值,则将该第二候选区域进行去除,根据有效区域的剩余部分确定二维码图像的边界线。If the gray average value of the second candidate area is smaller than the gray threshold, the second candidate area is removed, and the boundary line of the two-dimensional code image is determined according to the remaining part of the effective area.
  7. 如权利要求4所述的方法,其中,所述从二维码图像中识别出二维码所包含的指定形状包括:The method according to claim 4, wherein said identifying the specified shape contained in the two-dimensional code from the two-dimensional code image comprises:
    根据所述二维码图像的各边界线与所述基础图像的各边界线之间的距离,确定所述指定形状在所述二维码图像中的指定区域;determining a specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image;
    在所述指定区域中识别所述指定形状。The specified shape is recognized in the specified area.
  8. 如权利要求7所述的方法,其中,所述二维码图像包含定位字符,所述定位字符与所述指定形状具有预设的相对位置关系;The method according to claim 7, wherein the two-dimensional code image includes positioning characters, and the positioning characters have a preset relative positional relationship with the designated shape;
    所述根据所述二维码图像的各边界线与所述基础图像的各边界线之间的距离,确定所述指定形状在所述二维码图像中的指定区域包括:The determining the specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image includes:
    将所述二维码图像的边界线中,与所述基础图像的相应边界线距离最近的一条作为与所述定位字符对应的目标边界线,根据该目标边界线确定所述定位字符在所述二维码图像中的位置;Among the boundary lines of the two-dimensional code image, the one closest to the corresponding boundary line of the basic image is used as the target boundary line corresponding to the positioning character, and according to the target boundary line, it is determined that the position of the positioning character in the location in the QR code image;
    根据所述定位字符在所述二维码图像中的位置,以及所述相对位置关系,确定所述指定形状在所述二维码图像中的指定区域。According to the position of the positioning character in the two-dimensional code image and the relative positional relationship, the designated area of the designated shape in the two-dimensional code image is determined.
  9. 如权利要求1所述的方法,其中,所述根据各网格内的图像内容,生成标准二维码包括:The method according to claim 1, wherein said generating a standard two-dimensional code according to the image content in each grid comprises:
    若一个网格的中心点的像素值等于第一预设像素值,或者一个网格的像素平均值小于第二预设像素值,则根据该网格生成标准二维码的一个码粒。If the pixel value of the central point of a grid is equal to the first preset pixel value, or the pixel average value of a grid is smaller than the second preset pixel value, then a code particle of the standard two-dimensional code is generated according to the grid.
  10. 一种二维码图像处理装置,包括:A two-dimensional code image processing device, comprising:
    识别单元,用于从二维码图像中识别出二维码所包含的指定形状;The recognition unit is used to recognize the specified shape contained in the two-dimensional code from the two-dimensional code image;
    尺寸单元,用于根据所述指定形状确定所述二维码图像中码粒的尺寸;a size unit, configured to determine the size of code grains in the two-dimensional code image according to the specified shape;
    网格单元,用于将所述码粒的尺寸作为网格基准,在所述二维码图像中划分出网格;a grid unit, for dividing the grid in the two-dimensional code image by using the size of the code grain as a grid reference;
    生成单元,用于根据各网格内的图像内容,生成标准二维码。The generating unit is configured to generate a standard two-dimensional code according to the image content in each grid.
  11. 如权利要求10所述的装置,其中,The apparatus of claim 10, wherein,
    所述尺寸单元,用于根据指定形状中各边的尺寸与其所包含的码粒数量的比值,以及二维码图像中各边的尺寸与其所包含的码粒数量的比值,确定二维码图像中码粒的尺寸。The size unit is used to determine the two-dimensional code image according to the ratio of the size of each side in the specified shape to the number of code grains it contains, and the ratio of the size of each side in the two-dimensional code image to the number of code grains it contains The size of medium grain.
  12. 如权利要求10或11所述的装置,其中,Apparatus as claimed in claim 10 or 11, wherein,
    所述装置还包括:预处理单元,用于获取包含二维码的基础图像;从基础图像中确定出二维码所在的区域,根据确定出的区域得到二维码图像。The device further includes: a preprocessing unit, configured to acquire a basic image containing a two-dimensional code; determine the area where the two-dimensional code is located from the basic image, and obtain a two-dimensional code image according to the determined area.
  13. 如权利要求12所述的装置,其中,The apparatus of claim 12, wherein,
    所述识别单元,用于根据二维码图像的各边界线与基础图像的各边界线之间的距离,确定指定形状在二维码图像中的指定区域;在指定区域中识别指定形状。The identification unit is used to determine the specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the base image; and identify the specified shape in the specified area.
  14. 如权利要求10所述的装置,其中,The apparatus of claim 10, wherein,
    所述生成单元,用于若一个网格的中心点的像素值等于第一预设像素值,或者一个网格的像素平均值小于第二预设像素值,则根据该网格生成标准二维码的一个码粒。The generation unit is used to generate a standard two-dimensional pixel value according to the grid if the pixel value of the center point of a grid is equal to the first preset pixel value, or the pixel average value of a grid is smaller than the second preset pixel value. A code granule of the code.
  15. 一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令,该指令当被包括多个应用程序的电子设备执行时,能够使该电子设备执行下述的二维码图像处理方法:A computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs include instructions that, when executed by an electronic device including a plurality of application programs, enable the electronic device to Perform the following two-dimensional code image processing method:
    从二维码图像中识别出二维码所包含的指定形状;根据指定形状确定二维码图像中码粒的尺寸;将码粒的尺寸作为网格基准,在二维码图像中划分出网格;根据各网格内的图像内容,生成标准二维码。Identify the specified shape contained in the two-dimensional code from the two-dimensional code image; determine the size of the code grain in the two-dimensional code image according to the specified shape; use the size of the code grain as the grid reference, and divide the grid in the two-dimensional code image grid; according to the image content in each grid, a standard QR code is generated.
  16. 如权利要求15所述的计算机可读存储介质,其中,该指令当被包括多个应用程序的电子设备执行时,进一步执行下述的二维码图像处理方法:The computer-readable storage medium as claimed in claim 15, wherein, when the instruction is executed by an electronic device including multiple application programs, the following two-dimensional code image processing method is further executed:
    根据所述指定形状中各边的尺寸与其所包含的码粒数量的比值,以及所述二维码图像中各边的尺寸与其所包含的码粒数量的比值,确定所述二维码图像中码粒的尺寸。According to the ratio of the size of each side in the specified shape to the number of code grains it contains, and the ratio of the size of each side in the two-dimensional code image to the number of code grains it contains, determine the two-dimensional code image The size of the grains.
  17. 如权利要求15或16所述的计算机可读存储介质,其中,该指令当被包括多个应用程序的电子设备执行时,进一步执行下述的二维码图像处理方法:The computer-readable storage medium as claimed in claim 15 or 16, wherein, when the instruction is executed by an electronic device including multiple application programs, the following two-dimensional code image processing method is further performed:
    获取包含二维码的基础图像;Get the base image containing the QR code;
    从所述基础图像中确定出二维码所在的区域,根据确定出的区域得到所述二维码图像。The area where the two-dimensional code is located is determined from the basic image, and the image of the two-dimensional code is obtained according to the determined area.
  18. 如权利要求17所述的计算机可读存储介质,其中,该指令当被包括多个应用程序的电子设备执行时,进一步执行下述的二维码图像处理方法:The computer-readable storage medium as claimed in claim 17, wherein, when the instruction is executed by an electronic device including multiple application programs, the following two-dimensional code image processing method is further executed:
    根据所述基础图像的轮廓,去除所述基础图像的噪点,得到有效区域;removing the noise of the basic image according to the outline of the basic image to obtain an effective area;
    根据所述有效区域的轮廓,确定二维码图像的边界线,得到所述二维码图像。Determine the boundary line of the two-dimensional code image according to the outline of the effective area, and obtain the two-dimensional code image.
  19. 如权利要求17所述的计算机可读存储介质,其中,该指令当被包括多个应用程序的电子设备执行时,进一步执行下述的二维码图像处理方法:The computer-readable storage medium as claimed in claim 17, wherein, when the instruction is executed by an electronic device including multiple application programs, the following two-dimensional code image processing method is further executed:
    根据所述二维码图像的各边界线与所述基础图像的各边界线之间的距离,确定所述指定形状在所述二维码图像中的指定区域;determining a specified area of the specified shape in the two-dimensional code image according to the distance between each boundary line of the two-dimensional code image and each boundary line of the basic image;
    在所述指定区域中识别所述指定形状。The specified shape is recognized in the specified area.
PCT/CN2022/101359 2021-06-28 2022-06-27 Qr code image processing method and apparatus WO2023274097A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110719074.0A CN113449534B (en) 2021-06-28 2021-06-28 Two-dimensional code image processing method and device
CN202110719074.0 2021-06-28

Publications (1)

Publication Number Publication Date
WO2023274097A1 true WO2023274097A1 (en) 2023-01-05

Family

ID=77813271

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/101359 WO2023274097A1 (en) 2021-06-28 2022-06-27 Qr code image processing method and apparatus

Country Status (2)

Country Link
CN (1) CN113449534B (en)
WO (1) WO2023274097A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111062455A (en) * 2019-12-18 2020-04-24 北京远度互联科技有限公司 Two-dimensional code simplifying and displaying method and device
CN116188440A (en) * 2023-02-28 2023-05-30 聊城市红日机械配件厂 Production analysis optimization method, equipment and medium for bearing retainer
CN117082344A (en) * 2023-08-11 2023-11-17 蚂蚁区块链科技(上海)有限公司 Image shooting method and device

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113449534B (en) * 2021-06-28 2023-03-28 歌尔股份有限公司 Two-dimensional code image processing method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6758399B1 (en) * 1998-11-06 2004-07-06 Datalogic S.P.A. Distortion correction method in optical code reading
CN105138943A (en) * 2015-09-02 2015-12-09 福建联迪商用设备有限公司 Method and system for decoding QR code with damaged position detection graph
CN106909869A (en) * 2017-02-27 2017-06-30 浙江华睿科技有限公司 A kind of sampling grid partitioning method and device of matrix two-dimensional code
US20180365459A1 (en) * 2017-06-14 2018-12-20 Capital One Services, Llc Systems and methods for generating and reading intrinsic matrixed bar codes
CN110765795A (en) * 2019-09-24 2020-02-07 北京迈格威科技有限公司 Two-dimensional code identification method and device and electronic equipment
CN112052702A (en) * 2020-08-10 2020-12-08 北京智通云联科技有限公司 Method and device for identifying two-dimensional code
CN113449534A (en) * 2021-06-28 2021-09-28 歌尔股份有限公司 Two-dimensional code image processing method and device
CN114036968A (en) * 2021-11-10 2022-02-11 北京科技大学 Correction and restoration method for steel coil surface laser identification fuzzy two-dimensional code image

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530590B (en) * 2013-10-19 2016-02-24 高韬 DPM Quick Response Code recognition system
CN104573601A (en) * 2013-10-28 2015-04-29 江苏联海通信技术有限公司 Recognition system for DPM two-dimension code of device in complex environment
CN104636118B (en) * 2013-11-10 2017-07-04 航天信息股份有限公司 QR Quick Response Code self-adaption binaryzation treating method and apparatus based on photo-equilibrium
CN103886353B (en) * 2014-03-10 2017-02-01 百度在线网络技术(北京)有限公司 Method and device for generating two-dimension code image
CN106713739B (en) * 2016-10-20 2019-09-17 广州视源电子科技股份有限公司 A kind of recognition methods of the two dimensional code shown based on electronic curtain
WO2019023864A1 (en) * 2017-07-31 2019-02-07 深圳传音通讯有限公司 Two-dimensional code identification method and system based on intelligent terminal camera
CN110543798B (en) * 2019-08-12 2023-06-20 创新先进技术有限公司 Two-dimensional code identification method and device
CN111523341B (en) * 2020-04-03 2023-07-11 青岛进化者小胖机器人科技有限公司 Binarization method and device for two-dimensional code image
CN111523630B (en) * 2020-04-21 2024-04-19 中钞印制技术研究院有限公司 Two-dimensional code encoding method and device, and two-dimensional code recognition method and device
CN112990896A (en) * 2020-10-04 2021-06-18 曹建荣 Two-dimensional code identification method based on block chain

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6758399B1 (en) * 1998-11-06 2004-07-06 Datalogic S.P.A. Distortion correction method in optical code reading
CN105138943A (en) * 2015-09-02 2015-12-09 福建联迪商用设备有限公司 Method and system for decoding QR code with damaged position detection graph
CN106909869A (en) * 2017-02-27 2017-06-30 浙江华睿科技有限公司 A kind of sampling grid partitioning method and device of matrix two-dimensional code
US20180365459A1 (en) * 2017-06-14 2018-12-20 Capital One Services, Llc Systems and methods for generating and reading intrinsic matrixed bar codes
CN110765795A (en) * 2019-09-24 2020-02-07 北京迈格威科技有限公司 Two-dimensional code identification method and device and electronic equipment
CN112052702A (en) * 2020-08-10 2020-12-08 北京智通云联科技有限公司 Method and device for identifying two-dimensional code
CN113449534A (en) * 2021-06-28 2021-09-28 歌尔股份有限公司 Two-dimensional code image processing method and device
CN114036968A (en) * 2021-11-10 2022-02-11 北京科技大学 Correction and restoration method for steel coil surface laser identification fuzzy two-dimensional code image

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111062455A (en) * 2019-12-18 2020-04-24 北京远度互联科技有限公司 Two-dimensional code simplifying and displaying method and device
CN116188440A (en) * 2023-02-28 2023-05-30 聊城市红日机械配件厂 Production analysis optimization method, equipment and medium for bearing retainer
CN116188440B (en) * 2023-02-28 2023-08-29 聊城市红日机械配件厂 Production analysis optimization method, equipment and medium for bearing retainer
CN117082344A (en) * 2023-08-11 2023-11-17 蚂蚁区块链科技(上海)有限公司 Image shooting method and device

Also Published As

Publication number Publication date
CN113449534B (en) 2023-03-28
CN113449534A (en) 2021-09-28

Similar Documents

Publication Publication Date Title
WO2023274097A1 (en) Qr code image processing method and apparatus
TWI726422B (en) Two-dimensional code recognition method, device and equipment
TWI766855B (en) A character recognition method and device
CN109272016B (en) Target detection method, device, terminal equipment and computer readable storage medium
WO2017118356A1 (en) Text image processing method and apparatus
US20180253852A1 (en) Method and device for locating image edge in natural background
CN110647882A (en) Image correction method, device, equipment and storage medium
WO2021190155A1 (en) Method and apparatus for identifying spaces in text lines, electronic device and storage medium
CN114529459A (en) Method, system and medium for enhancing image edge
WO2023284502A1 (en) Image processing method and apparatus, device, and storage medium
CN111222507A (en) Automatic identification method of digital meter reading and computer readable storage medium
CN112651953A (en) Image similarity calculation method and device, computer equipment and storage medium
CN110751156A (en) Method, system, device and medium for table line bulk interference removal
CN114359665A (en) Training method and device of full-task face recognition model and face recognition method
JP7121132B2 (en) Image processing method, apparatus and electronic equipment
CN113129298A (en) Definition recognition method of text image
WO2024016686A1 (en) Corner detection method and apparatus
CN116597466A (en) Engineering drawing text detection and recognition method and system based on improved YOLOv5s
CN113870292A (en) Edge detection method and device for depth image and electronic equipment
CN114219831A (en) Target tracking method and device, terminal equipment and computer readable storage medium
CN114648751A (en) Method, device, terminal and storage medium for processing video subtitles
CN114692661A (en) Two-dimensional code recognition method, storage medium and computer
Wang et al. Efficient Euclidean distance transform using perpendicular bisector segmentation
TW202129540A (en) Method and device for recognizing character and storage medium
CN116109891B (en) Image data amplification method, device, computing equipment and storage medium

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE