CN109190437B - Method and device for reading two-dimensional code - Google Patents

Method and device for reading two-dimensional code Download PDF

Info

Publication number
CN109190437B
CN109190437B CN201810865945.8A CN201810865945A CN109190437B CN 109190437 B CN109190437 B CN 109190437B CN 201810865945 A CN201810865945 A CN 201810865945A CN 109190437 B CN109190437 B CN 109190437B
Authority
CN
China
Prior art keywords
dimensional code
code image
image
vertex
0xf77c
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
CN201810865945.8A
Other languages
Chinese (zh)
Other versions
CN109190437A (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.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies 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 Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201810865945.8A priority Critical patent/CN109190437B/en
Publication of CN109190437A publication Critical patent/CN109190437A/en
Application granted granted Critical
Publication of CN109190437B publication Critical patent/CN109190437B/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/1447Methods for optical code recognition including a method step for retrieval of the optical code extracting optical codes from image or text carrying said optical code
    • 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
    • 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/1495Methods for optical code recognition the method including an image compression step

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (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)
  • Quality & Reliability (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a method and a device for reading a two-dimensional code, wherein the method comprises the following steps: receiving the two-dimensional code image, judging whether the two-dimensional code image is regular according to the received image, and if so, preprocessing and decoding the two-dimensional code image; otherwise, judging whether a first vertex and a second vertex of the two-dimensional code image exist in the received image, if so, determining an external square of the two-dimensional code image according to the first vertex and the second vertex, determining a rotation angle and a central point coordinate according to the external square, rotating the two-dimensional code image according to the central point coordinate and the rotation angle, and preprocessing and decoding the two-dimensional code image; if the first vertex and the second vertex do not exist, judging whether the two-dimensional code image is received completely, if so, judging that the two-dimensional code image is invalid, otherwise, continuously receiving the two-dimensional code image and judging whether the first vertex and the second vertex of the two-dimensional code image exist in the received image; by the method, the requirement on system configuration is reduced, the user experience is enhanced, and the development cost is reduced.

Description

Method and device for reading two-dimensional code
Technical Field
The present invention relates to the field of decoding, and in particular, to a method and an apparatus for reading a two-dimensional code.
Background
The two-dimensional code is also called a two-dimensional bar code (2-dimensional bar code), which records data symbol information by using a black and white pattern which is distributed on a plane according to a certain rule by using a certain specific set pattern, can store more information and also can represent more data types than the traditional one-dimensional bar code, and a user usually obtains the information stored in the two-dimensional code by decoding the two-dimensional code; among them, the QR code is the most common one, and is the two-dimensional bar code which supports encoding chinese characters at the earliest.
However, the existing method for reading the two-dimensional code is mainly based on a series of image preprocessing of a complete frame of data acquired by an image sensor, and then decoding operation is performed, so that each frame of original image occupies a large RAM (random access memory) space of an MCU (micro control unit), so that the decoding operation has a high requirement on MCU configuration, hardware development cost and image preprocessing time are increased, and user experience is poor.
Disclosure of Invention
In order to solve the problems in the prior art, the invention provides a method and equipment for reading a two-dimensional code.
The invention provides a method for reading a two-dimensional code, which comprises the following steps:
step s 1: the decoding device receives the two-dimensional code image and judges whether the two-dimensional code image is a regular and effective two-dimensional code image according to the received image, if so, the decoding device completely receives, compresses and stores the two-dimensional code image, and executes the step s 5; otherwise, go to step s 2;
step s 2: the decoding device judges whether a first vertex and a second vertex of the two-dimensional code image exist in the received image, if so, the step s3 is executed; if not, judging whether the two-dimensional code image is received completely, if so, judging the two-dimensional code image to be an invalid image, returning to the step s1, otherwise, continuously receiving the two-dimensional code image and compressing the received image, and returning to the step s 2;
step s 3: the decoding device determines the circumscribed square of the two-dimensional code image according to the first vertex and the second vertex, judges whether the two-dimensional code image has been received completely, stores a valid two-dimensional code image if the two-dimensional code image has been received completely, and executes step s 4; otherwise, continuing to receive the two-dimensional code image, and returning to the step s 3;
step s 4: the decoding equipment calculates a rotation angle and a central point coordinate of the two-dimensional code image according to the external square of the two-dimensional code image, and rotates the two-dimensional code image according to the central point coordinate and the rotation angle;
step s 5: the decoding device preprocesses and decodes the valid two-dimensional code image.
The invention provides a device for reading a two-dimensional code image, which comprises:
the receiving module is used for receiving the two-dimensional code image;
the judging module is used for judging whether the two-dimensional code image is a regular and effective two-dimensional code image according to the image received by the receiving module;
the receiving module is also used for completely receiving the two-dimensional code image when the judging module judges that the two-dimensional code image is a regular and effective two-dimensional code image;
the compression module is used for compressing the two-dimension code image completely received by the receiving module when the judgment module judges that the two-dimension code image is a regular and effective two-dimension code image;
the judging module is also used for judging whether the first vertex and the second vertex of the two-dimensional code image exist in the image received by the receiving module; the receiving module is also used for judging whether the two-dimensional code image is received completely when judging that the first vertex and the second vertex of the two-dimensional code image do not exist in the image received by the receiving module, and triggering the receiving module when judging that the two-dimensional code image is an invalid image;
the receiving module is further used for continuing to receive the two-dimensional code image and compressing the received image when the judging module judges that the first vertex and the second vertex of the two-dimensional code image do not exist and the two-dimensional code image is not received completely, and triggering the judging module;
the determining module is used for determining an external square of the two-dimensional code image according to the first vertex and the second vertex when the judging module judges that the first vertex and the second vertex of the two-dimensional code image exist in the received image, and triggering the judging module;
the judging module is further used for judging whether the two-dimensional code image is received completely or not when the determining module determines the external square of the two-dimensional code image according to the first vertex and the second vertex; when the two-dimension code image is received, storing the two-dimension code image and triggering a calculation module; when the two-dimensional code image is not received, triggering a receiving module;
the calculation module is used for calculating a rotation angle and a central point coordinate of the two-dimensional code image according to the circumscribed square of the two-dimensional code image and rotating the two-dimensional code image according to the central point coordinate and the rotation angle;
and the decoding module is used for preprocessing and decoding the effective two-dimensional code image.
According to the method, the to-be-processed image which is basically undistorted in image outline and small in memory occupation is obtained by roughly extracting the effective two-dimensional code external square and the row-column two-way compression algorithm in the image acquisition process, the to-be-decoded image which is more beneficial to storage and analysis is obtained through image preprocessing, decoding can be achieved on the MCU with low configuration and other embedded systems by combining the simplified two-dimensional code algorithm, the requirements for system configuration are greatly reduced, user experience is enhanced, and development cost is reduced.
Drawings
Fig. 1 is a flowchart of a method for reading a two-dimensional code according to embodiment 1 of the present invention;
fig. 2 is a flowchart of a method for reading a two-dimensional code according to embodiment 2 of the present invention;
fig. 3 is a block diagram of an apparatus for reading a two-dimensional code according to embodiment 3 of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention are clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. 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 application.
Example 1
The embodiment 1 of the invention provides a method for reading a two-dimensional code, which comprises the following steps:
step 101: the decoding equipment collects the two-dimensional code image and judges whether the collected two-dimensional code image is a regular two-dimensional code image, if so, the two-dimensional code image is compressed, and step 104 is executed; otherwise, executing step 102;
step 102: the decoding equipment determines the vertex of the two-dimensional code image, determines the external square of the two-dimensional code image according to the vertex of the two-dimensional code image, and compresses the two-dimensional code image;
step 103: the decoding equipment calculates the center point coordinates and the rotation angle of the two-dimensional code image, and rotates the two-dimensional code image according to the center point coordinates and the rotation angle;
step 104: and the decoding equipment performs two-dimensional code image preprocessing and decodes the two-dimensional code image.
Example 2
The embodiment 2 of the invention provides a method for reading a two-dimensional code, which comprises the following steps:
step 201: and the decoding equipment carries out system and image acquisition initialization.
Specifically, the decoding device performs system initialization, determines parameters such as a color mode, a storage format and an image width and an image height of the acquired image in the initialization process, and initializes a first flag bit.
Step 202: the decoding device receives the two-dimensional code image point by point from the image sensor and performs graying processing on the received two-dimensional code image.
Specifically, the decoding device receives two-dimensional code images acquired by the image sensor point by point and converts the two-dimensional code images in other formats into gray level images;
for example: the two-dimensional code image is a two-dimensional code image in an RGB565 format.
More specifically, the MCU in the two-dimensional code device receives the collected two-dimensional code image and performs graying processing on the pixel points in the received two-dimensional code image.
For example: the MCU is greater than 11 through Red ═ (color & RED _ BASEVALUE) >;
Green=(color&GREEN_BASEVALUE)>>5;
Blue=(color&BLUE_BASEVALUE);
graying pixels in the image in the RGB565 format (tint 8_ t) ((Red 38+ Green 75+ Blue 15) > > 7);
preferably, before step 202, the image sensor collects the two-dimensional code image and judges whether the two-dimensional code image collection is completed, if so, the image sensor sets the interrupt flag to be valid; otherwise, the image sensor continues to acquire the two-dimensional code image;
correspondingly, before step 202, the method further includes: the decoding device judges whether the interrupt flag is valid, if so, the two-dimensional code image acquisition is completed, and step 202 is executed; and otherwise, sending an image acquisition instruction to the image sensor, and acquiring the two-dimensional code image again after the image sensor receives the image acquisition instruction.
Optionally, the image sensor acquires a two-dimensional code image and stores the two-dimensional code image in an external image storage space.
For example: the external image storage space may be a FIFO (first input first output).
For example, the two-dimensional code image acquired by the image sensor is:
0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0xE6FB,0xEF1C,0xEEFB,0xEEFB,0xE6DA,0xE6FB,0xDEDA,0xE6FB……0xEF3C,0xF75D,0xF73D,0xF75D,0xEF5C,0xF77D,0xF75D,0xF75D,0xEF3C,0xF75D,0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D,0xF77D,0xEF5C,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF7B,0xFF9C,0xFF7B,0xFF9C,0xF77B,0xFF9C,0xFF7B,0xF79C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xFF9D,0xF77C,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF77C,0xEF5B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,
0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FB,0xE6FB,0xE6FB,0xE6FB,0xE6FB,0xE6FB,0xEF1C,0xEF1C,0xEEFB,0xEEFB,0xEEFB,0xE6FB,0xE6FB,0xE6FB,0xEF1B,0xEF1B,0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEEFC,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEEFB,0xEF1C,0xEF1C,0xEF1C,0xEF3C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C……0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xFF9C,0xFF9D,0xFF9C,0xFF9D,0xFF9C,0xFF9D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xFF9D,0xFF9D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF77C,0xF77C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,
0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0xEEFB,0xEEFC,0xE6DA……0xF77C,0xF75D,0xF77C,0xF77C,0xFF9D,0xFF7D,0xFF9D,0xEF5C,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0xF75C,0xEF3B,0xF75C,
……
0xB595,0xC5B6,0xBD95,0xC5B6,0xBDB5,0xC5D6,0xBDB5,0xC5D6,0xBD95,0xC5B6,0xBD95,0xC5B6,0xBD95,0xC5B6,0xBD95,0xBDD6,0xB5B6,0xBDD7,0xB5B6,0xBDD7,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B6,0xBDD7,0xB5B6,0xBDD7,0xB5D6,0xBDF7,0xB5D6,0xC5F7,0xBDD6,0xBDF7,0xB5D6,0xBDD7,0xB5B6,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB595,0xBDB6,0xB595,0xBDB6,0xB595,0xBDD6,0xB5B5,0xBDD6,0xB5B6……0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512,0xB554,0xAD33,0xB554,0xAD33,0xB554,0xAD33,0xB554,0xAD34,0xB575,0xAD54,0xBD75,0xB574,0xBD95,0xB575,0xBD96,0xB575,0xBDB6,0xB595,0xC5B6,0xB595,0xBDB6,0xB595,0xC5B6,
0xBDB6,0xBD96,0xBDB6,0xBD95,0xC5B6,0xC596,0xC5D6,0xBDB5,0xC5B6,0xC596,0xC5B6,0xBD95,0xC5B6,0xC596,0xC5B6,0xB5B5,0xBDD7,0xBDB7,0xBDD6,0xB5B5,0xBDD6,0xBDB6,0xBDD6,0xB5B5,0xBDD7,0xBDB7,0xBDD7,0xB5D6,0xBDF7,0xC5D7,0xC5F7,0xBDD6,0xC5F7,0xC5D7,0xC5F7,0xB5D6,0xBDD7,0xBDB7,0xBDD6,0xB5B5,0xBDD6,0xBDB6,0xBDD6,0xB5B6,0xBDD7,0xBDB6,0xBDD6,0xB5B5,0xBDB6,0xBD96,0xBDB6,0xB595,0xBDB6,0xBDB6,0xBDD6,0xB5B5,0xBDD7,0xBDB6,0xBDB6,0xB595,0xBDB6,0xBD96,0xBDD6,0xB5B5,0xBDD7,0xBDB7,0xBDD6,0xB5B5,0xBDD6,0xBDB6,0xBDD6,0xB5B5,0xBDB6,0xBD96,0xBDB6,0xB5B5,0xBDD6,0xBDB6……0xB555,0xAD34,0xB555,0xB533,0xB554,0xAD33,0xB554,0xB533,0xB554,0xAD33,0xB554,0xB513,0xB534,0xAD13,0xB554,0xB533,0xB554,0xAD33,0xB554,0xB532,0xB553,0xAD32,0xB553,0xB532,0xB553,0xAD32,0xB554,0xB533,0xB554,0xAD33,0xB554,0xB533,0xB554,0xAD33,0xB554,0xB533,0xB554,0xAD33,0xAD33,0xAD13,0xAD34,0xA513,0xAD34,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA4F2,0xAD13,0xACF2,0xAD13,0xA4F2,0xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xAD33,0xA512,0xAD13,0xAD11,0xAD33,0xA512,0xAD53,0xAD12,0xAD33,0xA512,0xAD33,0xAD12,0xB554,0xAD33,0xB554,0xB533,0xB554,0xAD33,0xB555,0xB555,0xB575,0xB554,0xBD95,0xBD75,0xBD95,0xB574,0xBD96,0xBD96,0xBDB6,0xB595,0xBDB6,0xBD96,0xBDB6,0xB595;
step 203: and the decoding equipment temporarily stores the pixel points of the two-dimensional code image line by line and samples the window.
Specifically, the MCU presets a sample window of n × n, receives the pixels from row 1 to row n, and temporarily stores them, and fills the sample window.
For example, the MCU presets 5 × 5 sampling windows and receives the pixels from row 1 to row 5 for temporary storage, and fills the sampling windows at the same time.
Step 204: the decoding device judges whether the two-dimensional code image is a regular two-dimensional code image according to the received pixel lines, if so, the step 216 is executed; otherwise, step 205 is performed.
Specifically, the decoding device determines whether the depth pixel length of the received pixel row is consistent with the black-white pixel length ratio of each positioning image, if so, the two-dimensional code image is a regular two-dimensional code image, and step 216 is executed; otherwise, the two-dimensional code image is an irregular two-dimensional code image, and step 205 is executed.
For example, the black-and-white pixel length of each positioning image is 1:1:3:1:1, the decoding device determines whether the depth pixel length of the received pixel line is 1:1:3:1:1, if so, the two-dimensional code image is a regular two-dimensional code image, and step 216 is executed; otherwise, the two-dimensional code image is not a regular two-dimensional code image, and step 205 is executed.
Step 205: the decoding device judges whether the first vertex of the two-dimensional code image is obtained or not, if so, step 209 is executed; otherwise, step 206 is performed.
Optionally, step 205 specifically includes: the decoding device determines the value of the first flag bit, and when the value of the first flag bit is 1, the first vertex is already acquired, and step 209 is executed; when the value of the first flag is 0, the first vertex is not acquired, and step 206 is performed. For example, the decoding apparatus determines whether the first fixed point a (x1, y1) of the two-dimensional code image has been acquired, and if so, performs step 209; otherwise, step 206 is performed.
Step 206: the decoding device determines whether a first vertex of the two-dimensional code image exists in the sampling pixel row, if yes, step 207 is executed; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, returning an image invalid response to the image sensor by the decoding equipment, and acquiring the two-dimensional code image again by the image sensor; otherwise, return to step 202.
Optionally, step 206 specifically includes:
step 206-1, the decoding device samples a window of n x n, judge whether the window central point is black, if yes, carry out step 206-2; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, and returning an image invalid response to the image sensor by the decoding equipment; if not, return to step 202.
For example, the decoding apparatus takes a window of 5 × 5, determines whether the center point of the window at row 3 and column 3 is black, and if so, performs step 206-2; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, and returning an image invalid response to the image sensor by the decoding equipment; if the reception is not completed, returning to step 202;
step 206-2, the decoding device judges the value of the pixel point in the next row of the central point, if the pixel points right below the central point or on the two sides below the central point are also black, the step 206-3 is executed; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, and returning an image invalid response to the image sensor by the decoding equipment; if not, return to step 202.
For example, the decoding device determines the value of the pixel point in the next row from the center point in row 3 and column 3, and if the pixel point directly below the center point (located in row 4 and column 3) or the pixel points on both sides below (located in row 4 and column 2 and column 4, respectively) are also black, step 207-3 is executed; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, and returning an image invalid response to the image sensor by the decoding equipment; if not, return to step 202.
Step 206-3, the decoding device judges the value of the pixel point right above the central point, if the value of the pixel point right above the central point is white, the central point is a first vertex, a first vertex exists in the sampling pixel line, and step 209 is executed; if the two-dimensional code image is received, the decoding equipment returns an image invalid response to the image sensor; if not, return to step 202.
For example, the decoding device determines the value of the pixel point (located in row 2 and column 3) directly above the center point, if it is white, the center point is the first vertex, and step 210 is executed; if the two-dimensional code image is received, the decoding equipment returns an image invalid response to the image sensor; if not, return to step 202.
For example, the decoding apparatus determines whether there is a first vertex a (x1, y1) in the received pixel row, and if so, performs step 207; otherwise, judging whether the two-dimensional code image is received completely, if so, judging that the current two-dimensional code image is an invalid image, and returning an image invalid response to the image sensor by the decoding equipment; otherwise, return to step 202.
Preferably, after the image sensor receives an image invalid response returned by the decoding device, the two-dimensional code image is collected again, whether the two-dimensional code image is collected is judged, and if the two-dimensional code image is collected, an image collection completion instruction is returned to the decoding device; otherwise, the two-dimensional code image is continuously acquired.
Step 207: the decoding device judges whether the two-dimensional code image is complete according to the first vertex, if so, step 208 is executed; and if not, the current two-dimensional code is an invalid image, and the decoding equipment returns an image invalid response to the image sensor.
Optionally, the decoding device determines whether the ordinate of the first vertex is less than one-half of the height of the two-dimensional code image, and if so, the two-dimensional code image is complete, and step 208 is executed; and if not, the current two-dimensional code image is an invalid image, and the decoding equipment returns an image invalid response to the image sensor.
Preferably, after the image sensor receives an invalid picture response returned by the decoding device, the two-dimensional code image is collected again, whether the two-dimensional code image is collected is judged, and if the two-dimensional code image is collected, an image collection completion instruction is returned to the decoding device; otherwise, the two-dimensional code image is continuously acquired.
Step 208: the decoding apparatus marks the ordinate of the first vertex as the start memory line of the valid two-dimensional code data.
Step 209: the decoding equipment judges whether the two-dimensional code image is received completely, if so, the current two-dimensional code image is an invalid image, and the decoding equipment returns an image invalid response to the image sensor; otherwise, step 210 is performed.
Preferably, after the image sensor receives an image invalid response returned by the decoding device, the two-dimensional code image is collected again, whether the two-dimensional code image is collected is judged, and if the two-dimensional code image is collected, an image collection completion instruction is returned to the decoding device; otherwise, the two-dimensional code image is continuously acquired.
Step 210: and the decoding equipment continues to receive the two-dimensional code image, grays the received pixel points and samples the window.
Step 211: the decoding device determines whether the received pixel point meets a second preset condition, if yes, fills the sampling window and stores, and executes step 212; otherwise, only the sampling window is filled and step 212 is performed.
Optionally, step 211 specifically includes: the decoding device judges whether the abscissa of the received pixel point is an odd number and whether the ordinate is consistent with the parity of the ordinate of the first vertex, if so, the sampling window is filled and stored, and step 212 is executed; otherwise, only the sampling window is filled and step 212 is performed.
Optionally, the second preset condition may also be: if the abscissa of the received pixel point is even, if so, filling and storing the sampling window, and executing step 212; otherwise, only the sampling window is filled and step 212 is performed.
Step 212: the decoding device judges whether a second vertex of the two-dimensional code image is acquired, if so, step 215 is executed; otherwise, step 213 is performed.
Optionally, step 212 specifically includes: the decoding device judges the value of the first flag bit, if the value is 2, the decoding device has already acquired the second vertex of the two-dimensional code image, and step 215 is executed; otherwise, the decoding device does not acquire the second vertex of the two-dimensional code image, and step 213 is executed.
For example, the decoding apparatus determines whether the second vertex B (x2, y2) of the valid two-dimensional code image has been acquired, and if so, performs step 215; otherwise, step 213 is performed.
Step 213: the decoding device judges whether a second vertex of the two-dimensional code image exists, if so, the value of the first flag bit is set to be 2, and step 214 is executed; otherwise, return to step 209;
optionally, step 213 specifically includes:
step 213-1, the decoding device judges whether the center point of the window is black in a window with a sampling size of n x n, if so, the step 213-2 is executed; otherwise, return to step 209.
For example, the decoding device takes a window of 5 × 5, determines whether the center point of the window at row 3 and column 3 is black, and if so, performs step 213-2; otherwise, return to step 209;
step 213-2, the decoding device judges the relation between the horizontal coordinate of the central point and the horizontal coordinate of the first vertex, if the horizontal coordinate of the central point is smaller than the horizontal coordinate of the first vertex, step 213-3 is executed; if the abscissa of the center point is greater than the abscissa of the first vertex, performing step 213-4;
step 213-3, the decoding device determines values of a point right to the right of the central point or two points adjacent to the right of the central point up and down, if the point right to the right or the two points adjacent to the right of the central point up and down are black, the central point is a second vertex, the first flag bit is set to be 2, and step 214 is executed; if the point right to the right of the center point and the adjacent points above and below the point right to the right are not black, the center point is not the second vertex, and the step 209 is returned;
for example, the decoding apparatus determines that the right-side coordinate of the center point is (3, 4) or the upper and lower adjacent coordinates of the right-side point of the center point are the values of (2, 4) and (4, 4), respectively, and if the right-side coordinate of the center point is (3, 4) is black, or the upper and lower adjacent coordinates of the right-side point of the center point are both (2, 4) and (4, 4) black, the center point is the second vertex, the value of the first flag bit is set to 2, and step 214 is executed; if the point with the coordinate (3, 4) right side of the central point and the points with the adjacent coordinates (2, 4) and (4, 4) above and below the point with the coordinate (3, 4) right side of the central point are not black, the central point is not the second vertex, and the step 209 is returned;
step 213-4, the decoding device determines values of a point right to the left of the central point, a point right to the right, and two points adjacent to the point right to the left, and if the point right to the left or the two points adjacent to the point right to the left are black and the point right to the right is white, the central point is a second vertex, and step 214 is executed; if the point right to the left of the central point and the two points adjacent to the point right to the left are not black or the point right to the right of the central point is not white, the central point is not the second vertex, and the step 209 is returned;
for example, the decoding apparatus determines values of points whose upper and lower adjacent coordinates of a point whose center point right-left side coordinate is (2, 3), a point whose right side coordinate is (4, 3), and a point whose right side coordinate is (4, 4) are (2, 2) and (2, 4), respectively, and if the point whose coordinates are (2, 3) or the points whose coordinates are (2, 2) and (2, 4) are black and the point of (4, 3) is white, the center point is the second vertex, performs step 214; if neither the point with coordinates (2, 3) nor the points with coordinates (2, 2) and (2, 4) is black or the point with coordinates (4, 3) is white, the center point is not the second vertex, and the process returns to step 209.
Step 214: the decoding equipment determines a third vertex and a fourth vertex of the two-dimensional code image through the first vertex and the second vertex, judges whether the two-dimensional code image is incomplete, and returns an image invalid response to the image sensor if the two-dimensional code image is incomplete; otherwise, go to step 215;
specifically, the decoding device calculates coordinates of a third vertex and a fourth vertex through coordinates of two points, namely a first vertex and a second vertex, and judges whether the coordinates of the third vertex or the fourth vertex are not in the range of the image, if so, the decoding device returns an image invalid response to the image sensor; otherwise, the two-dimensional code image is complete, and step 215 is executed;
for example, the first vertex A has a coordinate of (x)1,y1) The second vertex B has the coordinate of (x)2,y2),
When x is2Greater than x1The decoding apparatus passes through the first vertex A (x)1,y1) And a second vertex B (x)2,y2) The C coordinate of the third vertex is calculated to be x1-(y2-y1),y1+(x2-x1)]The fourth vertex D has the coordinate of [ (x)1+2y1),y2+(x2-x1)];
When x is2Less than x1The decoding apparatus passes through the first vertex A (x)1,y1) And a second vertex B (x)2,y2) The C coordinate of the third vertex is calculated to be (x)1+y2-y1,x1-x2+y2) The fourth vertex has the coordinate of (y)2-y1+x2,x1-x2+y2)。
Step 215: the decoding equipment judges whether the storage of the square data externally connected with the two-dimensional code image is finished, if so, the step 216 is executed; otherwise, return to step 209.
Specifically, the decoding device determines whether the pixel row where the fourth vertex is located is received completely, if so, the storage of the two-dimensional code image externally connected with the square is completed, and step 216 is executed; otherwise, the data of the circumscribed square of the two-dimensional code image is not stored, and the step 209 is returned.
For example, the two-dimensional code image obtained is:
0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0xDED9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDEDA,0xDEDA,0xDEDA,0xE6FB,0xEEFB,0xE6DA,0xDEDA,0xE6FA,0xEEFA,0xE6FA,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEDB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEF1B,0xE71B,0xEF1B,0xE71B,0xEF1B,0xE71B,0xEF1B,0xE6FB……0xF75D,0xF77D,0xF77D,0xF75D,0xF77D,0xF77D,0xF77D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF77D,0xF75D,0xF75D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xFF9C,0xFF9C,0xFF9C,0xF79C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xFF9D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF75C,0xF75C,0xF75C,0xF77C,0xF75C,0xF75C,0xEF3B,0xF73B,0xF73B;
0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0xDED9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0xDEDA,0xDEDA,0xDEDA,0xEEFB,0xE6DA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xEEDA,0xE6DB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB……0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF75D,0xF77D,0xF75D,0xF75D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xFF9D,0xFF9D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xEF5B,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF75C,0xF75C,0xF75C,0xF75C,0xF73B,0xEF3B,0xF73B,0xEF3B
……
0xB595,0xBD95,0xBDB5,0xBDB5,0xBD95,0xBD95,0xBD95,0xBD95,0xB5B6,0xB5B6,0xB5B5,0xB5B5,0xB5B6,0xB5B6,0xB5D6,0xB5D6,0xBDD6,0xB5D6,0xB5B6,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595,0xB595,0xB595,0xB5B5,0xB5B6,0xB5B5,0xB595,0xB5B5,0xB5B6,0xB5B6,0xB5B5,0xB5B5,0xB595,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB5B6,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595,0xB595,0xB5B5,0xB5B5,0xB5B5,0xB595,0xB595,0xB5B5,0xB5B5,0xB5B6,0xB5B5,0xB595,0xB595,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595,0xBD95,0xBD95,0xBD95,0xBD95,0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0xC5D6,0xC5F7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7……0xB554,0xB554,0xB554,0xB554,0xB554,0xB554,0xAD34,0xAD34,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD13,0xAD13,0xAD13,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xB554,0xB554,0xB554,0xB554,0xB575,0xBD75,0xBD95,0xBD96,0xB595,0xB595,0xB595;
step 216: the decoding equipment calculates the center point coordinates and the rotation angle of the two-dimensional code image, and rotates the two-dimensional code image according to the center point coordinates and the rotation angle.
Specifically, the decoding device calculates a center point coordinate and a rotation angle of the two-dimensional code image, obtains the rotation angle of the two-dimensional code image according to the center point coordinate, and performs image rotation according to the rotation angle to obtain a regular two-dimensional code image.
Step 217: the decoding apparatus detects an edge of the received two-dimensional code image.
Optionally, the decoding device may include, for a commonly used edge detection algorithm: roberts operators, Sobel operators, Prewitt operators, Canny operators, etc.;
for example, the improved Sobel operator is used for edge detection in the patent, so that a relatively accurate two-dimensional code image can be obtained.
Step 218: the decoding device carries out perspective mapping transformation on the two-dimensional code image.
Optionally, the MCU rotates the bearing surface (see-through surface) by a certain angle around the trace line (see-through axis) according to the law of see-through rotation by using the condition that the three points of the see-through center, the image point and the target point are collinear, so as to destroy the original projection light beam, and still maintain the unchanged transformation of the projection geometry on the bearing surface, and perform three-dimensional change on the picture to obtain a regular two-dimensional code image.
Step 219: and the decoding equipment performs bilinear interpolation on the two-dimensional code image.
Specifically, after the image is rotated, the coordinates of the pixel points are changed, the values of the pixel points become discrete and discontinuous, and the distortion problem after the image is rotated can be well solved through linear interpolation.
The bilinear interpolation is to perform linear interpolation on each of the pixel points in the horizontal direction and the vertical direction, so that the image processing effect can be greatly improved.
Step 220: and the decoding equipment performs median filtering on the two-dimensional code image.
Specifically, the MCU sets the gray value of each pixel point to be the median of the gray values of all pixel points in the window of the certain field of the point.
Step 221: the decoding device performs binarization processing on the two-dimensional code image.
Specifically, the decoding device selects a reasonable threshold value for the grayscale image, so that the pixel point becomes image data of two colors, namely black "1" and white "0", for use by the decoding subprogram.
For example, in this patent, the maximum inter-range variance method, also called the greater amount algorithm, is used to obtain the optimal binarized image.
Step 222: the decoding device performs two-dimensional code decoding operation.
The two-dimensional code decoding algorithm is commonly known as ZBar, Zxing and the like. In view of the use in a low-configuration embedded system, the decoding part algorithm of the quirc algorithm is used here, and specifically includes, as a basis for the algorithm of the QR code decoding part: reading format information, reading version information, eliminating mask, replying information and error correcting code word, correcting error and decoding.
The advantages are that: the method has the characteristics of small occupied system resources, no dependence on function libraries except the standard C99, small code amount, high decoding efficiency and the like, and is suitable for embedded systems.
Example 3
Embodiment 3 of the present invention provides an apparatus for reading a two-dimensional code, including:
the receiving module 01 is used for receiving the two-dimensional code image;
the judging module 02 is used for judging whether the two-dimensional code image is a regular and effective two-dimensional code image according to the image received by the receiving module 01;
the receiving module 01 is further configured to receive the two-dimensional code image completely when the judging module 02 judges that the two-dimensional code image is a regular and valid two-dimensional code image;
the compression module 03 is configured to compress the two-dimensional code image completely received by the receiving module 01 when the judging module 02 judges that the two-dimensional code image is a regular and valid two-dimensional code image;
the judging module 02 is further configured to judge whether the image received by the receiving module 01 has a first vertex and a second vertex of the two-dimensional code image; the receiving module 01 is further configured to determine whether the two-dimensional code image is received completely when it is determined that the first vertex and the second vertex of the two-dimensional code image do not exist in the image received by the receiving module 01, and trigger the receiving module 01 when it is determined that the two-dimensional code image is an invalid image;
the receiving module 01 is further configured to continue receiving the two-dimensional code image and compressing the received image when the judging module 02 judges that the first vertex and the second vertex of the two-dimensional code image do not exist and the two-dimensional code image is not yet received, and trigger the judging module 02;
the determining module 04 is configured to determine an external square of the two-dimensional code image according to the first vertex and the second vertex when the determining module 02 determines that the first vertex and the second vertex of the two-dimensional code image exist in the received image, and trigger the determining module 02;
the judging module 02 is further configured to judge whether the two-dimensional code image is received completely when the determining module 04 determines the circumscribed square of the two-dimensional code image according to the first vertex and the second vertex; when the two-dimension code image is received, storing the two-dimension code image and triggering the calculation module 05; when the two-dimensional code image is not received, triggering a receiving module 01;
the calculation module 05 is used for calculating a rotation angle and a central point coordinate of the two-dimensional code image according to the circumscribed square of the two-dimensional code image and rotating the two-dimensional code image according to the central point coordinate and the rotation angle;
and the decoding module 06 is used for preprocessing and decoding the compressed effective two-dimensional code image.
Optionally, the receiving module 01 is specifically configured to receive the two-dimensional code image point by point from the image sensor and graying the received two-dimensional code image.
Optionally, an apparatus for reading a two-dimensional code image further includes:
and the initialization module is used for initializing the system and image acquisition.
Optionally, the judging module 02 is further configured to judge whether the acquisition completion interrupt flag is valid; and when the judgment module 02 judges that the acquisition completion interrupt flag is valid, triggering the initialization module.
Optionally, the apparatus for reading a two-dimensional code image further includes:
and the storage module is used for temporarily storing the pixel points of the two-dimensional code image line by line and sampling the window.
The compression module 03 is specifically configured to compress the two-dimensional code image by using a bidirectional compression algorithm.
Optionally, when the determining module 02 determines that the received two-dimensional code image is a regular two-dimensional code image, the compressing module 03 is specifically configured to, according to a starting point of the regular two-dimensional code image, take and store a pixel point whose horizontal and vertical coordinate parity is consistent with the horizontal and vertical coordinate of the starting point of the two-dimensional code image;
when the judging module 02 judges that the two-dimensional code image is the irregular two-dimensional code image, the compressing module 03 specifically includes:
the marking submodule is used for marking the vertical coordinate of the first vertex as an initial storage line of the two-dimensional code image;
and the judgment submodule is used for judging whether the horizontal coordinate of the current pixel point is odd or not and whether the vertical coordinate is consistent with the parity of the vertical coordinate of the first vertex or not.
Optionally, the determining module 02 is further specifically configured to determine whether a depth pixel length of a pixel row of the received image is consistent with a ratio of black and white pixel length of each positioning image.
Optionally, the determining module 02 is further configured to determine whether the first vertex of the two-dimensional code image has been acquired according to the first flag bit, and when the first vertex of the two-dimensional code image has been acquired, the determining module 02 is further configured to determine whether the receiving of the two-dimensional code image is completed;
the return module is used for returning an image invalid response to the image sensor when the judging module judges that the two-dimensional code image is invalid;
the receiving module 01 is further configured to receive the two-dimensional code image point by point, gray the two-dimensional code image, and sample the window.
Optionally, the determining module 02 is further specifically configured to determine a value of the first flag bit.
Optionally, the determining module 02 further includes:
the second judgment submodule is used for judging whether the two-dimensional code image is complete or not according to the first vertex;
and the marking submodule is used for marking the vertical coordinate of the first vertex as a starting storage line of the two-dimensional code image.
Optionally, the determining module 02 is further configured to determine whether a second vertex has been obtained according to the first flag bit; when the second vertex is judged not to be obtained, judging whether the two-dimensional code image is received completely, and when the two-dimensional code image is judged to be received completely, triggering a return module; and when the two-dimensional code image is judged not to be received completely, triggering the receiving module.
Optionally, the determining module 02 is specifically configured to determine whether to obtain the second vertex by determining a value of the first flag.
Optionally, the decoding module 06 specifically includes:
the detection submodule is used for detecting the edge of the received two-dimensional code image;
the perspective mapping submodule is used for carrying out perspective mapping transformation on the two-dimensional code image;
the bilinear interpolation submodule is used for carrying out a bilinear interpolation module on the two-dimensional code image;
the median filtering submodule is used for performing median filtering on the two-dimensional code image;
the binarization submodule is used for carrying out binarization processing on the two-dimensional code image;
and the decoding submodule is used for decoding the two-dimensional code image.

Claims (20)

1. A method for reading a two-dimensional code is characterized by comprising the following steps:
step s 1: the two-dimensional code reading device starts to receive the two-dimensional code image, judges whether the two-dimensional code image is a regular two-dimensional code image or not according to the received image, continues to receive the two-dimensional code image until the receiving is finished if the two-dimensional code image is the regular two-dimensional code image, compresses the received image at the same time, and executes the step s 5; otherwise, go to step s 2;
step s 2: the two-dimensional code reading device judges whether a first vertex and a second vertex of the two-dimensional code image exist in the received image, and if so, the step s3 is executed; if not, judging whether the two-dimensional code image is received completely, if so, judging that the two-dimensional code image is an invalid image, returning to the step s1, otherwise, continuously receiving the two-dimensional code image and compressing the received image, and returning to the step s 2;
step s 3: the two-dimensional code reading device determines the circumscribed square of the two-dimensional code image according to the first vertex and the second vertex, judges whether the two-dimensional code image has been received and compressed, and if so, executes step s 4; otherwise, continuing to receive and simultaneously compressing the two-dimensional code image, and returning to the step s 3;
step s 4: the two-dimensional code reading device calculates a rotation angle and a center point coordinate of the two-dimensional code image according to the circumscribed square of the two-dimensional code image, the two-dimensional code reading device rotates the two-dimensional code image according to the center point coordinate and the rotation angle, and step s5 is executed;
step s 5: the two-dimensional code reading device performs preprocessing and decodes the two-dimensional code image.
2. The method of claim 1, wherein step s1 further comprises: the two-dimensional code reading device receives the two-dimensional code image point by point from the image sensor and grays the received image.
3. The method of claim 1, wherein step s1 is preceded by: and the two-dimensional code reading device carries out system and image acquisition initialization.
4. The method of claim 1, wherein said step s1 is preceded by the further step of: the two-dimensional code reading device acquires an acquisition completion interrupt mark and judges whether the acquisition completion interrupt mark is valid, if so, the two-dimensional code image acquisition is completed, and the step s1 is executed; otherwise, the two-dimension code image is not collected and is collected continuously until the collection is completed.
5. The method of claim 1, wherein the compressing the two-dimensional code image is specifically: the two-dimensional code reading device compresses the two-dimensional code image by using a bidirectional compression algorithm.
6. The method according to claim 1, wherein the step s1 of determining whether the two-dimensional code image is a regular two-dimensional code image according to the received image specifically includes:
the two-dimensional code reading device judges whether the depth pixel length of the pixel row of the received image is consistent with the length ratio of black pixels to white pixels of each positioning image, and if so, the two-dimensional code image is a regular two-dimensional code image; otherwise, the two-dimensional code image is an irregular two-dimensional code image.
7. The method according to claim 1, wherein when the two-dimensional code reading device determines that the first vertex of the two-dimensional code image exists in the received image, the step s2 further comprises:
step s2-1, the two-dimensional code reading device judges whether the two-dimensional code image is complete according to the first vertex, if so, step s2-2 is executed; otherwise, the two-dimensional code image is an invalid image, the two-dimensional code reading device returns an image invalid response, and the step s0 is returned;
and step s2-2, the two-dimensional code reading device marks the ordinate of the first vertex as the initial storage line of the two-dimensional code image.
8. The method of claim 1, wherein after step s2, step s3 is preceded by:
the two-dimensional code reading device judges whether the second vertex is obtained or not according to the first flag bit, and if so, the step s3 is executed; if not, judging whether the two-dimensional code image is received completely, if so, judging that the two-dimensional code image is an invalid image, returning an image invalid response to the image sensor by the two-dimensional code reading device, returning to the step s0, otherwise, receiving the two-dimensional code image point by point, graying the two-dimensional code image, sampling the window, and continuously judging whether the second vertex is obtained.
9. The method of claim 8, wherein the determining, by the two-dimensional code reading device according to the first flag bit, whether the second vertex has been obtained specifically includes:
the two-dimensional code reading device judges whether the value of the first zone bit is a second preset value or not, and when the value of the first zone bit is the second preset value, the two-dimensional code reading device obtains the second vertex; and when the value of the first flag bit is not the second preset value, the two-dimensional code reading device does not obtain the second vertex.
10. The method according to claim 1, wherein step s5 specifically comprises:
step s5-1, the two-dimensional code reading device detecting the edge of the received two-dimensional code image;
step s5-2, the two-dimensional code reading device performs perspective mapping transformation on the two-dimensional code image;
step s5-3, the two-dimensional code reading device performs bilinear interpolation on the two-dimensional code image;
step s5-4, the two-dimensional code reading device performs median filtering on the two-dimensional code image;
step s5-5, the two-dimensional code reading device carries out binarization processing on the two-dimensional code image;
and step s5-6, decoding the two-dimensional code image by the two-dimensional code reading device.
11. A two-dimensional code reading apparatus, comprising:
the receiving module is used for receiving the two-dimensional code image;
the judging module is used for judging whether the two-dimensional code image is a regular and effective two-dimensional code image according to the image received by the receiving module;
the receiving module is further used for completely receiving the two-dimension code image when the judging module judges that the two-dimension code image is a regular and effective two-dimension code image;
the compression module is used for compressing the two-dimension code image completely received by the receiving module;
the judging module is further configured to judge whether a first vertex and a second vertex of the two-dimensional code image exist in the image received by the receiving module; the receiving module is further configured to determine whether the two-dimensional code image is received completely when it is determined that the first vertex and the second vertex of the two-dimensional code image do not exist in the image received by the receiving module, and trigger the receiving module when it is determined that the two-dimensional code image is an invalid image;
the receiving module is further configured to continue receiving the two-dimensional code image and compressing the received image to trigger the determining module when the determining module determines that the first vertex and the second vertex of the two-dimensional code image do not exist and the two-dimensional code image is not yet received;
the determining module is used for determining an external square of the two-dimensional code image according to the first vertex and the second vertex when the judging module judges that the first vertex and the second vertex of the two-dimensional code image exist in the received image, and triggering the judging module;
the judging module is further configured to judge whether the two-dimensional code image is received completely when the determining module determines the circumscribed square of the two-dimensional code image according to the first vertex and the second vertex; when the two-dimension code image is received, storing the two-dimension code image and triggering a calculation module; when the two-dimensional code image is not received completely, triggering the receiving module;
the calculation module is used for calculating a rotation angle and a central point coordinate of the two-dimensional code image according to the circumscribed square of the two-dimensional code image and rotating the two-dimensional code image according to the central point coordinate and the rotation angle;
and the decoding module is used for executing preprocessing and decoding the effective two-dimensional code image completely received by the receiving module.
12. The two-dimensional code reading apparatus according to claim 11, wherein the receiving module is specifically configured to receive the two-dimensional code image point by point from an image sensor and grayscale the received two-dimensional code image.
13. The two-dimensional code reading apparatus according to claim 12, further comprising:
and the initialization module is used for initializing the system and image acquisition.
14. The two-dimensional code reading device according to claim 12, wherein the determining module is further configured to determine whether the acquisition completion interrupt flag is valid; and when the judgment module judges that the acquisition completion interrupt mark is valid, triggering the receiving module.
15. The two-dimensional code reading apparatus according to claim 11, further comprising:
and the storage module is used for temporarily storing the pixel points of the two-dimensional code image line by line and sampling the window.
16. The two-dimensional code reading apparatus according to claim 11, wherein the compression module is specifically configured to compress the two-dimensional code image using a bi-directional compression algorithm.
17. The two-dimensional code reading device according to claim 11, wherein the determining module is further configured to determine whether a depth pixel length of a pixel row of the received image is consistent with a black-white pixel length ratio of each positioning image.
18. The two-dimensional code reading device according to claim 11, wherein the determining module is further configured to determine whether the second vertex has been obtained according to the first flag; when the second vertex is judged not to be obtained, judging whether the two-dimensional code image is received completely, and when the two-dimensional code image is judged to be received completely, triggering a return module; and triggering a receiving module when the two-dimensional code image is judged not to be received completely.
19. The two-dimensional code reading apparatus according to claim 17, wherein the determining module is specifically configured to determine whether to obtain the second vertex by determining a value of the first flag.
20. The two-dimensional code reading apparatus according to claim 11, wherein the decoding module specifically includes:
the detection submodule is used for detecting the edge of the received two-dimensional code image;
the perspective mapping submodule is used for carrying out perspective mapping transformation on the two-dimensional code image;
the bilinear interpolation submodule is used for carrying out a bilinear interpolation module on the two-dimensional code image;
the median filtering submodule is used for performing median filtering on the two-dimensional code image;
the binarization submodule is used for carrying out binarization processing on the two-dimensional code image;
and the decoding submodule is used for decoding the two-dimensional code image.
CN201810865945.8A 2018-08-01 2018-08-01 Method and device for reading two-dimensional code Active CN109190437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810865945.8A CN109190437B (en) 2018-08-01 2018-08-01 Method and device for reading two-dimensional code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810865945.8A CN109190437B (en) 2018-08-01 2018-08-01 Method and device for reading two-dimensional code

Publications (2)

Publication Number Publication Date
CN109190437A CN109190437A (en) 2019-01-11
CN109190437B true CN109190437B (en) 2021-03-16

Family

ID=64920336

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810865945.8A Active CN109190437B (en) 2018-08-01 2018-08-01 Method and device for reading two-dimensional code

Country Status (1)

Country Link
CN (1) CN109190437B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111507119B (en) * 2019-01-31 2024-02-06 北京骑胜科技有限公司 Identification code recognition method, identification code recognition device, electronic equipment and computer readable storage medium
CN110084080B (en) * 2019-04-28 2021-07-09 上海快仓自动化科技有限公司 Two-dimensional code identification and generation method and device, two-dimensional code and trolley
CN116882432B (en) * 2023-07-11 2024-03-22 深圳市裕源欣电子科技有限公司 Method and system for scanning multiple materials, readable storage medium and computer equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101093553A (en) * 2007-07-19 2007-12-26 成都博古天博科技有限公司 2D code system, and identification method
CN105069389A (en) * 2015-07-27 2015-11-18 福建联迪商用设备有限公司 Two-dimensional code partitioning decoding method and system
CN105930891A (en) * 2016-04-18 2016-09-07 闫河 Method for generating two-dimensional code

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1885311A (en) * 2006-05-29 2006-12-27 深圳矽感科技有限公司 Two-dimensional code, encoding and decoding method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101093553A (en) * 2007-07-19 2007-12-26 成都博古天博科技有限公司 2D code system, and identification method
CN105069389A (en) * 2015-07-27 2015-11-18 福建联迪商用设备有限公司 Two-dimensional code partitioning decoding method and system
CN105930891A (en) * 2016-04-18 2016-09-07 闫河 Method for generating two-dimensional code

Also Published As

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

Similar Documents

Publication Publication Date Title
US11494577B2 (en) Method, apparatus, and storage medium for identifying identification code
CN103400099B (en) Terminal and two-dimensional code identification method
EP3104332B1 (en) Digital image manipulation
US6526161B1 (en) System and method for biometrics-based facial feature extraction
EP3457327B1 (en) Method and apparatus for generating two-dimensional code picture having dynamic effect
JP3345350B2 (en) Document image recognition apparatus, method thereof, and recording medium
CN109190437B (en) Method and device for reading two-dimensional code
EP3306562A1 (en) Image processing method and device
KR20220050977A (en) Medical image processing method, image processing method and apparatus
CN108470350B (en) Method and device for dividing line in line graph
JP2003523587A (en) Visual attention system
CN110991310B (en) Portrait detection method, device, electronic equipment and computer readable medium
KR101907414B1 (en) Apparus and method for character recognition based on photograph image
CN111144156B (en) Image data processing method and related device
US9270846B2 (en) Content encoded luminosity modulation
CN111507119B (en) Identification code recognition method, identification code recognition device, electronic equipment and computer readable storage medium
CN111046644A (en) Answer sheet template generation method, identification method, device and storage medium
US20170011272A1 (en) Realtime object measurement
US20060164517A1 (en) Method for digital recording, storage and/or transmission of information by means of a camera provided on a comunication terminal
WO2007014014A2 (en) Adaptive contrast control systems and methods
CN104346596A (en) Identification method and identification device for QR (Quick Response) code
US9684984B2 (en) Nearsighted camera object detection
CN114549270A (en) Anti-shooting monitoring video watermarking method combining depth robust watermarking and template synchronization
CN116401484B (en) Method, device, terminal and storage medium for processing paper material in electronization mode
CN116798056B (en) Form image positioning method, apparatus, device and computer readable storage medium

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