CN110399761B - Two-dimensional code extraction method and device, readable storage medium and terminal equipment - Google Patents

Two-dimensional code extraction method and device, readable storage medium and terminal equipment Download PDF

Info

Publication number
CN110399761B
CN110399761B CN201910682204.0A CN201910682204A CN110399761B CN 110399761 B CN110399761 B CN 110399761B CN 201910682204 A CN201910682204 A CN 201910682204A CN 110399761 B CN110399761 B CN 110399761B
Authority
CN
China
Prior art keywords
dimensional code
image
size
target structure
printing
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201910682204.0A
Other languages
Chinese (zh)
Other versions
CN110399761A (en
Inventor
刘燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huiyan Zhixing Technology Co ltd
Original Assignee
Beijing Huiyan Zhixing Technology Co ltd
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 Beijing Huiyan Zhixing Technology Co ltd filed Critical Beijing Huiyan Zhixing Technology Co ltd
Priority to CN201910682204.0A priority Critical patent/CN110399761B/en
Publication of CN110399761A publication Critical patent/CN110399761A/en
Application granted granted Critical
Publication of CN110399761B publication Critical patent/CN110399761B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

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

Abstract

The embodiment of the invention provides a two-dimension code extraction method, a device, a readable storage medium and a terminal device.

Description

Two-dimensional code extraction method and device, readable storage medium and terminal equipment
Technical Field
The invention relates to the technical field of information processing, in particular to a two-dimensional code extraction method and device, a readable storage medium and terminal equipment.
Background
With the popularization of two-dimensional codes, the two-dimensional codes are widely applied to the industrial field. An important link in the two-dimensional code use is just to carry out the two-dimensional code discernment, and carries out the two-dimensional code discernment, need follow earlier and extract the two-dimensional code from the image of gathering, carries out the mode that the two-dimensional code drawed at present and is: the two-dimensional code is directly searched in the image by utilizing the characteristics of the two-dimensional code (usually, a specific graph in the two-dimensional code). However, due to the complex industrial field environment, other background patterns often exist around the position of the two-dimensional code, which brings interference to the extraction of the two-dimensional code, for example, the background patterns similar to the characteristics of the two-dimensional code are mistakenly judged as the two-dimensional code, resulting in low two-dimensional code recognition efficiency.
Disclosure of Invention
In view of this, embodiments of the present invention provide a two-dimensional code extraction method, an apparatus, a readable storage medium, and a terminal device, so as to improve two-dimensional code identification efficiency.
In order to achieve the above purpose, the embodiments of the present invention provide the following technical solutions:
a two-dimensional code extraction method comprises the following steps:
acquiring an image, wherein the image is provided with a two-dimensional code to be identified;
determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for collecting the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
searching a region which accords with the relevant parameters in the image, wherein the region which accords with the relevant parameters is the two-dimensional code region.
In the above method, preferably, the view parameter includes: the resolution and field of view of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
In the above method, preferably, the view parameter includes: the focal length and the object distance of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
In the above method, preferably, the determining the relevant parameters of the two-dimensional code according to the viewing parameters of the camera that collects the image and the printing parameters of the two-dimensional code includes:
calculating the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formula:
Figure BDA0002145079850000021
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
The above method, preferably, the searching for the region in the image that matches the relevant parameter includes:
converting the image into a binary image;
acquiring a sliding window, wherein the size of the sliding window is the same as that of the two-dimensional code in the image;
sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position;
and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area which accords with the related parameters.
A two-dimensional code extraction element includes:
the device comprises an acquisition module, a recognition module and a recognition module, wherein the acquisition module is used for acquiring an image which is provided with a two-dimensional code to be recognized;
the determining module is used for determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for acquiring the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
and the extraction module is used for searching an area which accords with the relevant parameters in the image, wherein the area which accords with the relevant parameters is the two-dimensional code area.
Preferably, in the above apparatus, the viewing parameters include: the resolution and field of view of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
Preferably, in the above apparatus, the view parameter includes: the focal length and the object distance of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
Preferably, in the above apparatus, the determining module is specifically configured to calculate the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formulas:
Figure BDA0002145079850000031
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
The above apparatus, preferably, the extraction module includes:
a conversion unit configured to convert the image into a binary image;
the acquisition unit is used for acquiring a sliding window, and the size of the sliding window is the same as that of the two-dimensional code in the image;
the extraction unit is used for sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position; and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area according with the related parameters.
A terminal device comprising a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement each step of the two-dimensional code extraction method according to any one of the above.
A readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the two-dimensional code extraction method as described in any one of the above.
According to the two-dimensional code extraction method, the two-dimensional code extraction device, the readable storage medium and the terminal equipment, the viewing parameters of the camera for collecting the image and the printing parameters of the two-dimensional code are utilized to determine the related parameters of the two-dimensional code in the image, then the area which accords with the related parameters is searched in the image, the area which accords with the related parameters is used as the two-dimensional code area, the two-dimensional code extraction accuracy is improved, and therefore the two-dimensional code identification efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of an implementation of a two-dimensional code extraction method according to an embodiment of the present invention;
fig. 2 is a diagram illustrating a structure of a functional graph in a two-dimensional code according to an embodiment of the present invention;
FIG. 3 is a flowchart of an implementation of searching for regions in an image that meet relevant parameters according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a two-dimensional code extraction device according to an embodiment of the present invention;
fig. 5 is a block diagram of a hardware structure of a terminal device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The two-dimensional code extraction method and device provided by the embodiment of the invention can be applied to terminal equipment, wherein the terminal equipment can be an industrial camera or a commonly-used handset in an industrial scene, and the handset is provided with a camera.
An implementation flowchart of the two-dimensional code extraction method provided in the embodiment of the present application is shown in fig. 1, and may include:
step S101: and acquiring an image, wherein the image has the two-dimensional code to be identified.
The image is acquired by an industrial camera or a hand-held machine with the camera commonly used in the industrial field.
Step S102: determining relevant parameters of the two-dimensional code according to the framing parameters of the camera for collecting the image and the printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code. The target structure comprises at least part of code blocks in the two-dimensional code and functional patterns in the two-dimensional code.
The two-dimensional code generally comprises a code block region and a functional pattern region, wherein the code block region comprises a plurality of black code blocks and a plurality of white code blocks and is used for bearing format information, version information, data and error correction code words, and the functional pattern in the functional pattern region is used for assisting the identification of the two-dimensional code and can comprise any one of a detection pattern, a positioning pattern and a correction pattern. Fig. 2 is a diagram illustrating a structure example of a functional graph in a two-dimensional code according to an embodiment of the present application. In this example, three functional patterns of a position detection pattern, a positioning pattern, and a correction pattern are provided in the two-dimensional code, and the regions other than the functional pattern region are code block regions (specific code blocks are not shown). The two-dimensional code is composed of symbols, namely square black and white dots which form the two-dimensional code. In an embodiment of the present application, the code block is composed of at least one same-color symbol located in the same row. For example, assuming that a symbol ABC is three symbols sequentially adjacent in a row, where B is a white symbol and a and C are both black symbols, the symbol B constitutes one white code block. For another example, assuming that the symbol ABCD is 4 black code blocks which are adjacent in sequence, where the symbols A, C are all white symbols, and the symbols B, C are all black symbols, the BC constitutes one black code block.
Based on this, at least some of the code blocks included in the target structure in the present application may be all black code blocks in the two-dimensional code, all white code blocks in the two-dimensional code, or all code blocks in the two-dimensional code. The functional pattern included in the target structure may be any one of the above-described various patterns.
The number of target structures refers to: the number of code blocks included in the target structure, and the number of functional patterns. I.e. code blocks and functional patterns are counted separately.
The camera for collecting the images is an industrial camera or a camera on a hand-held machine used in an industrial field.
The view parameter of the camera refers to a parameter configured when the camera acquires an image. The parameter can be configured by the user according to the actual use condition.
The printing parameters of the two-dimensional code refer to parameters when the two-dimensional code is printed, and the parameters are determined before the two-dimensional code is printed and can be provided by a provider of the two-dimensional code.
And the determined related parameters of the two-dimensional code represent the characteristics of the two-dimensional code in the image.
The size of the two-dimensional code in the image may refer to the number of pixels of the two-dimensional code in the image in the longitudinal direction (for convenience of description, denoted as the X-axis direction) and the number of pixels in the width direction (for convenience of description, denoted as the Y-axis direction). Similarly, the size of the target structure in the image refers to the number of pixels of the target structure in the X-axis direction and the number of pixels in the Y-axis direction in the image.
Step S103: and searching a region which accords with the relevant parameters in the image, wherein the region which accords with the relevant parameters is a two-dimensional code region to be identified.
After the two-dimensional code area is determined, the two-dimensional code area can be identified.
The two-dimension code extraction method provided by the application comprises the steps of calculating relevant parameters of a two-dimension code in an image by utilizing framing parameters of a camera for collecting the image and printing parameters of the two-dimension code, searching an area which accords with the relevant parameters in the image, and taking the area which accords with the relevant parameters as a two-dimension code area.
In an alternative embodiment, the viewing parameters may include a resolution and a field of view of the camera; alternatively, the viewing parameters may include the focal length and object distance of the camera.
In the case of an industrial camera, the industrial camera is usually erected at a fixed position, after the industrial camera is erected, the object distance and the field of view can be determined, and the resolution and the focal length of the industrial camera can be configured by a user. For the hand held machine, the resolution and the focal length can be determined through user configuration, if the hand held machine directly contacts the plane where the two-dimensional code is located for reading, the object distance and the visual field are also determined, if the hand held machine does not directly contact the two-dimensional code, the object distance and the visual field can change within a certain range, and the obtained object distance and the obtained visual field are range values. When the obtained object distance and the field of view are range values, the minimum value of the range values of the object distance may be used as the object distance of the camera, or the middle value of the range values of the object distance may be used as the object distance of the camera.
The field of view of the camera is a region, and in the embodiment of the application, the length of the field of view in the X axis or the length of the field of view in the Y axis is used for representing the size of the field of view.
Accordingly, the printing parameters of the two-dimensional code may include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of the target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
The printing size of the two-dimensional code refers to the number of pixels on the X axis and the number of pixels on the Y axis when the two-dimensional code is printed; the printing size of the target structure refers to the number of pixels of the target structure on the X axis and the number of pixels on the Y axis during two-dimensional code printing.
In an optional embodiment, one implementation manner of determining the relevant parameters of the two-dimensional code according to the viewing parameters of the camera for acquiring the image and the printing parameters of the two-dimensional code may be as follows:
calculating the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formula:
Figure BDA0002145079850000071
wherein, the DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
For example, if X is the number of pixels of the two-dimensional code on the X axis at the time of printing, y is the number of pixels of the two-dimensional code on the X axis in the image. If x is the number of pixels of the two-dimensional code on the Y axis during printing, Y is the number of pixels of the two-dimensional code on the Y axis in the image. Similarly, if x is the number of pixels of the first target structure on the Y-axis during printing, then Y is the number of pixels of the first target structure on the Y-axis in the image. The first target structure is any one of the target structures.
In an alternative embodiment, a flowchart of an implementation of searching for a region in an image that meets the relevant parameter is shown in fig. 3, and may include:
step S301: and converting the image into a binary image.
The image collected by the camera is generally a color image, and the image can be subjected to graying processing to obtain a grayscale image, and then the grayscale image is subjected to binarization processing to obtain a binary image. By converting the image into a binary image, the interference of the background image can be removed, and the subsequent processing performance (such as processing speed and accuracy) can be improved.
Step S302: and acquiring a sliding window, wherein the size of the sliding window is the same as that of the two-dimensional code in the image.
Step S303: and sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position.
Alternatively, the step may be determined according to the size of the sliding window. For example, when the sliding window is slid along the X-axis, the step may be half of the length of the sliding window in the X-axis direction, and when the sliding window is slid along the Y-axis, the step may be half of the length of the sliding window in the Y-axis direction. The sliding window may be the same size or different sizes in the X and Y axes, and thus the sliding steps of the sliding window in the X and Y axes may be different.
Step S304: and if the statistical result is matched with the relevant parameters, determining the area where the sliding window is located as the area which accords with the relevant parameters. That is, if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are all matched with the number of the target structures in the two-dimensional code in the relevant parameters, the size of each target structure in the image and the position of each target structure in the two-dimensional code, and the area where the sliding window is located is determined to be the area according with the relevant parameters.
Optionally, the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window may be determined by comparing the factors one by one, and whether the number of the target structures in the two-dimensional code in the relevant parameters, the size of each target structure in the image, and the position of each target structure in the two-dimensional code are all matched. For example,
the number of the target structures in the sliding window and the number of the target structures in the two-dimensional code in the relevant parameters can be compared, if the two are the same, the position of each target structure in the sliding window and the position of each target structure in the relevant parameters in the two-dimensional code are compared to determine whether the position of each target structure in the sliding window and the position of each target structure in the two-dimensional code in the relevant parameters are the same, if the position of each target structure in the sliding window and the position of each target structure in the two-dimensional code in the relevant parameters are the same, the number of the target structures in the image and the position of each target structure in the two-dimensional code are matched, if the size of each target structure in the sliding window and the position of each target structure in the sliding window are the same, any one of the factors is different, the number of the target structures in the image, the size of each target structure in the sliding window and the position of each target structure in the sliding window are not matched with the number of the target structures in the two-dimensional code in the relevant parameters, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the relevant parameters.
In the matching process, if any one factor is different, the sliding window position is not the two-dimensional code area, and the sliding window can be slid to the next position without comparing other factors, so as to continuously judge whether the next position is the two-dimensional code area.
Corresponding to the method embodiment, the present application further provides a two-dimensional code extraction device, and a schematic structural diagram of the two-dimensional code extraction device provided in the embodiment of the present application is shown in fig. 4, and may include:
an acquisition module 41, a calculation module 42 and an extraction module 43; wherein the content of the first and second substances,
the obtaining module 41 is configured to obtain an image, where the image has a two-dimensional code to be identified;
the determining module 42 is configured to determine relevant parameters of the two-dimensional code according to viewing parameters of a camera that collects the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
the extracting module 43 is configured to search the image for an area that meets the relevant parameter, where the area that meets the relevant parameter is the two-dimensional code area.
The utility model provides a two-dimensional code extraction element, utilize the camera of gathering the image to find a view the parameter and the printing parameter of two-dimensional code calculates the relevant parameter of two-dimensional code in the image, then search for the region that accords with this relevant parameter in the image, regard as the two-dimensional code region with this region that accords with relevant parameter, because do not directly utilize the two-dimensional code characteristic to look for the two-dimensional code in the image, therefore can not receive the interference of two-dimensional code background pattern, improve the rate of accuracy that the two-dimensional code drawed, thereby improve two-dimensional code recognition efficiency.
In an alternative embodiment, the viewing parameters may include a resolution and a field of view of the camera; alternatively, the viewing parameters may include the focal length and object distance of the camera.
Accordingly, the printing parameters of the two-dimensional code may include: the method comprises the steps of printing resolution of the two-dimensional code and version parameters of the two-dimensional code, wherein the version parameters are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
In an optional embodiment, the calculating module 42 may specifically be configured to calculate the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formulas:
Figure BDA0002145079850000101
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
In an alternative embodiment, the extraction module 43 may include:
a conversion unit configured to convert the image into a binary image;
the acquisition unit is used for acquiring a sliding window, and the size of the sliding window is the same as that of the two-dimensional code in the image;
the extraction unit is used for sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position; and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area which accords with the related parameters.
The embodiment of the application also provides a terminal device, and the terminal device can be configured with the two-dimensional code extraction device. An exemplary diagram of a hardware structure block diagram of a terminal device provided in an embodiment of the present invention is shown in fig. 5, and may include:
a processor 1, a communication interface 2, a memory 3 and a communication bus 4;
wherein, the processor 1, the communication interface 2 and the memory 3 complete the communication with each other through the communication bus 4;
optionally, the communication interface 2 may be an interface of a communication module, such as an interface of a GSM module;
the processor 1 may be a central processing unit CPU or an Application Specific Integrated Circuit ASIC or one or more Integrated circuits configured to implement embodiments of the present invention.
The memory 3 may comprise high-speed RAM memory and may also comprise non-volatile memory, such as at least one disk memory.
The processor 1 is specifically configured to execute a program stored in the memory 3, so as to implement the following steps:
acquiring an image, wherein the image is provided with a two-dimensional code to be identified;
determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for collecting the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
searching for an area which accords with the relevant parameters in the image, wherein the area which accords with the relevant parameters is the two-dimensional code area.
In an alternative embodiment, the viewing parameters may include a resolution and a field of view of the camera; alternatively, the viewing parameters may include the focal length of the camera and the object distance.
Accordingly, the printing parameters of the two-dimensional code may include: the method comprises the steps of printing resolution of the two-dimensional code and version parameters of the two-dimensional code, wherein the version parameters are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
In an optional embodiment, when determining the relevant parameters of the two-dimensional code according to the viewing parameters of the camera that collects the image and the printing parameters of the two-dimensional code, the processor 1 may be specifically configured to:
calculating the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formula:
Figure BDA0002145079850000121
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
In an alternative embodiment, the processor 1 searches for a region in the image that matches the relevant parameter, comprising:
converting the image into a binary image;
acquiring a sliding window, wherein the size of the sliding window is the same as that of the two-dimensional code in the image;
sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position;
and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area according with the related parameters.
Embodiments of the present application further provide a readable storage medium, where the storage medium may store a program adapted to be executed by a processor, where the program is configured to:
acquiring an image, wherein the image is provided with a two-dimensional code to be identified;
determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for collecting the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
searching for an area which accords with the relevant parameters in the image, wherein the area which accords with the relevant parameters is the two-dimensional code area.
Alternatively, the detailed function and the extended function of the program may be as described above.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the components and steps of the various examples have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (12)

1. A two-dimensional code extraction method is characterized by comprising the following steps:
acquiring an image, wherein the image is provided with a two-dimensional code to be identified;
determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for collecting the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
searching for an area which accords with the relevant parameters in the image, wherein the area which accords with the relevant parameters is the two-dimensional code area.
2. The method of claim 1, wherein the view parameters comprise: the resolution and field of view of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
3. The method of claim 1, wherein the framing parameters comprise: the focal length and the object distance of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
4. The method according to claim 2 or 3, wherein the determining the relevant parameters of the two-dimensional code according to the framing parameters of a camera acquiring the image and the printing parameters of the two-dimensional code comprises:
calculating the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formula:
Figure FDA0002145079840000011
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
5. The method of claim 1, wherein searching for a region in the image that matches the relevant parameter comprises:
converting the image into a binary image;
acquiring a sliding window, wherein the size of the sliding window is the same as that of the two-dimensional code in the image;
sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position;
and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area according with the related parameters.
6. The utility model provides a two-dimensional code extraction element which characterized in that includes:
the device comprises an acquisition module, a recognition module and a recognition module, wherein the acquisition module is used for acquiring an image which is provided with a two-dimensional code to be recognized;
the determining module is used for determining relevant parameters of the two-dimensional code according to viewing parameters of a camera for acquiring the image and printing parameters of the two-dimensional code; the relevant parameters include: the size of the two-dimensional code in the image, the number of target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code;
and the extraction module is used for searching an area which accords with the relevant parameters in the image, wherein the area which accords with the relevant parameters is the two-dimensional code area.
7. The apparatus of claim 6, wherein the view parameters comprise: the resolution and field of view of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
8. The apparatus of claim 6, wherein the view parameters comprise: the focal length and the object distance of the camera;
the printing parameters include: the printing resolution of the two-dimensional code and the version parameter of the two-dimensional code are used for representing the printing size of the two-dimensional code, the number of target structures in the two-dimensional code, the printing size of each target structure and the position of each target structure in the two-dimensional code.
9. The apparatus according to claim 7 or 8, wherein the determining module is specifically configured to calculate the size of the two-dimensional code in the image and the size of the target structure in the image according to the following formulas:
Figure FDA0002145079840000031
wherein, DPI1 is the resolution of the camera; s is the visual field of the camera; j is the focal length of the camera; l is the object distance of the camera; the DPI2 is the printing resolution of the two-dimensional code; x is the printing size of the two-dimensional code, and y is the size of the two-dimensional code in the image; alternatively, x is the print size of the target structure and y is the size of the target structure in the image.
10. The apparatus of claim 6, wherein the extraction module comprises:
a conversion unit configured to convert the image into a binary image;
the acquisition unit is used for acquiring a sliding window, and the size of the sliding window is the same as that of the two-dimensional code in the image;
the extraction unit is used for sliding the sliding window on the binary image according to preset steps, and counting the number of target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window when the sliding window slides to one position; and if the number of the target structures in the sliding window, the size of each target structure and the position of each target structure in the sliding window are matched with the number of the target structures in the two-dimensional code, the size of each target structure in the image and the position of each target structure in the two-dimensional code in the related parameters, and the area where the sliding window is located is determined to be the area according with the related parameters.
11. A terminal device comprising a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the two-dimensional code extraction method according to any one of claims 1 to 5.
12. A readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the two-dimensional code extraction method according to any one of claims 1 to 5.
CN201910682204.0A 2019-07-26 2019-07-26 Two-dimensional code extraction method and device, readable storage medium and terminal equipment Active CN110399761B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910682204.0A CN110399761B (en) 2019-07-26 2019-07-26 Two-dimensional code extraction method and device, readable storage medium and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910682204.0A CN110399761B (en) 2019-07-26 2019-07-26 Two-dimensional code extraction method and device, readable storage medium and terminal equipment

Publications (2)

Publication Number Publication Date
CN110399761A CN110399761A (en) 2019-11-01
CN110399761B true CN110399761B (en) 2023-02-17

Family

ID=68326157

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910682204.0A Active CN110399761B (en) 2019-07-26 2019-07-26 Two-dimensional code extraction method and device, readable storage medium and terminal equipment

Country Status (1)

Country Link
CN (1) CN110399761B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000343784A (en) * 1999-06-04 2000-12-12 Fujitsu Ltd Printing reproducing method for two-dimensional code, printed matter, printing method and apparatus, and reproducing method and apparatus
CN107704793A (en) * 2016-07-07 2018-02-16 立德高科(昆山)数码科技有限责任公司 According to the size of Quick Response Code with automatically adjust recognition area size method and device
CN108629220A (en) * 2018-03-23 2018-10-09 阿里巴巴集团控股有限公司 A kind of two dimension code reading method, apparatus and equipment
CN109598162A (en) * 2018-08-20 2019-04-09 天津字节跳动科技有限公司 Identify method, apparatus, terminal device and the storage medium of two dimensional code

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000343784A (en) * 1999-06-04 2000-12-12 Fujitsu Ltd Printing reproducing method for two-dimensional code, printed matter, printing method and apparatus, and reproducing method and apparatus
CN107704793A (en) * 2016-07-07 2018-02-16 立德高科(昆山)数码科技有限责任公司 According to the size of Quick Response Code with automatically adjust recognition area size method and device
CN108629220A (en) * 2018-03-23 2018-10-09 阿里巴巴集团控股有限公司 A kind of two dimension code reading method, apparatus and equipment
CN109598162A (en) * 2018-08-20 2019-04-09 天津字节跳动科技有限公司 Identify method, apparatus, terminal device and the storage medium of two dimensional code

Also Published As

Publication number Publication date
CN110399761A (en) 2019-11-01

Similar Documents

Publication Publication Date Title
CN110046529B (en) Two-dimensional code identification method, device and equipment
CN109657629B (en) Text line extraction method and device
CN109409377B (en) Method and device for detecting characters in image
KR101606469B1 (en) Method for image analysis, especially for mobile stations
US7349588B2 (en) Automatic meter reading
WO2013044875A1 (en) Linear barcode identification method and system
US10621427B2 (en) Information processing apparatus, storage medium, and information processing method for character recognition by setting a search area on a target image
JP7102103B2 (en) Portable information processing equipment and methods and programs using the information processing equipment
CN111985465A (en) Text recognition method, device, equipment and storage medium
CN111582282A (en) Text recognition method, device, equipment and storage medium
US9117132B2 (en) System and method facilitating designing of classifier while recognizing characters in a video
CN110796095A (en) Instrument template establishing method, terminal equipment and computer storage medium
CN111523340B (en) Two-dimensional code identification method and device, electronic equipment and storage medium
CN110399761B (en) Two-dimensional code extraction method and device, readable storage medium and terminal equipment
US10049309B2 (en) Character recognition device, character recognition method and program
CN109919164B (en) User interface object identification method and device
CN110874538A (en) Method and device for evaluating decoding result of bar code and electronic equipment
CN116229098A (en) Image recognition method based on mask contour tracking and related products
CN111127529B (en) Image registration method and device, storage medium and electronic device
JPWO2019097690A1 (en) Image processing apparatus, control method, and control program
KR101660476B1 (en) Metod for recognizing payment information in printed credit card
CN111814535B (en) Palm print image recognition method, device, equipment and computer readable storage medium
CN111402281B (en) Book edge detection method and device
CN109934036B (en) Method and system for recognizing and reading QR (quick response) code through single-position detection graph
CN113689378A (en) Method and device for judging accurate positioning of test strip, storage medium and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant