CN109190437A - A kind of method and reading device reading two dimensional code - Google Patents

A kind of method and reading device reading two dimensional code Download PDF

Info

Publication number
CN109190437A
CN109190437A CN201810865945.8A CN201810865945A CN109190437A CN 109190437 A CN109190437 A CN 109190437A CN 201810865945 A CN201810865945 A CN 201810865945A CN 109190437 A CN109190437 A CN 109190437A
Authority
CN
China
Prior art keywords
image
code
vertex
0xf77c
module
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.)
Granted
Application number
CN201810865945.8A
Other languages
Chinese (zh)
Other versions
CN109190437B (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

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

Abstract

The present invention discloses a kind of method and reading device for reading two dimensional code, and it is to be pre-processed and decode image in 2 D code that method, which includes: to receive image in 2 D code and judge whether image in 2 D code is regular according to the image received,;Otherwise judge the first vertex and the second vertex that whether there is two code images in the image received, if it is, the external square of image in 2 D code is determined according to the first vertex and the second vertex, and rotation angle and center point coordinate are determined according to external square, image in 2 D code is rotated according to center point coordinate and rotation angle, pre-processes and decodes image in 2 D code;If there is no the first vertex and the second vertex, judge whether image in 2 D code finishes receiving, if so, image in 2 D code is invalid, otherwise, continues to image in 2 D code and judge the first vertex and the second vertex that whether there is two code images in the image received;In this way, reducing the requirement to system configuration, enhance user experience, while reducing development cost.

Description

A kind of method and reading device reading two dimensional code
Technical field
The present invention relates to decoding field more particularly to a kind of methods and reading device for reading two dimensional code.
Background technique
Two dimensional code is also known as two-dimensional bar code (2-dimensional bar code), is with certain specific set figure by one In the chequered with black and white graphic recording data symbol information of plane distribution, it can be stored set pattern rule than traditional one-dimensional bar code More information, can also indicate more data types, and user usually obtains the letter stored in two dimensional code by two dimensional code decoding Breath;Wherein, QR code is one of the most common type, and supports the two-dimensional bar code to encoding of chinese characters earliest.
But it is existing read two dimensional code method be mainly based upon by imaging sensor acquisition a complete frame data into The pretreatment of row a series of images, then is decoded operation, in this way since every frame original image occupy MCU (micro-control unit) very Big RAM (random access memory) space so that decoding operation it is very high to MCU configuration requirement, increase hardware development at This and image preprocessing time, user experience are bad.
Summary of the invention
To solve problems of the prior art, the invention proposes a kind of method and apparatus for reading two dimensional code.
The present invention provides a kind of methods for reading two dimensional code, comprising:
Step s1: decoding device receives image in 2 D code and judges whether image in 2 D code is rule according to the image received Then and efficient 2-d code image, if so, completely receiving and compressing storage image in 2 D code, step s5 is executed;Otherwise, it executes Step s2;
Step s2: with the presence or absence of the first vertex of image in 2 D code and the second top in the image that decoding device judgement receives Point, if so, executing step s3;It is that then, image in 2 D code is invalid if not, judging whether image in 2 D code finishes receiving Otherwise image, return step s1 continue to image in 2 D code and compress the image received, return step s2;
Step s3: decoding device determines the external square of image in 2 D code according to the first vertex and the second vertex, judgement Whether image in 2 D code has finished receiving, if so, storing effective image in 2 D code, executes step s4;Otherwise, after continued access Receive image in 2 D code, return step s3;
Step s4: decoding device calculates rotation angle and image in 2 D code according to the external square of image in 2 D code Center point coordinate, decoding device rotate image in 2 D code according to center point coordinate and rotation angle;
Step s5: decoding device pre-processes and decodes effective image in 2 D code.
The present invention provides a kind of devices for reading image in 2 D code, comprising:
Receiving module, for receiving image in 2 D code;
Judgment module, the image for being received according to receiving module judge whether image in 2 D code is regular and effective Image in 2 D code;
Receiving module is also used to when judgment module judges that image in 2 D code is rule and efficient 2-d code image, It is complete to receive image in 2 D code;
Compression module, for pressing when judgment module judges that image in 2 D code is rule and efficient 2-d code image The image in 2 D code that contracting receiving module is completely received;
Judgment module is also used to judge to whether there is in image that receiving module receives the first vertex of image in 2 D code With the second vertex;It is also used to when judging that there is no the first vertex of image in 2 D code and the in image that receiving module receives When two vertex, judge whether image in 2 D code finishes receiving, when judging image in 2 D code is invalid image, touches transmitting/receiving Block;
Receiving module is also used to work as judgment module and judges that the first vertex of image in 2 D code and the second vertex are not present, And image in 2 D code continues to image in 2 D code and compresses the image received, trigger judgment module when not finishing receiving also;
Determining module, for judging in the image received there are the first vertex of image in 2 D code when judgment module and When the second vertex, the external square of image in 2 D code is determined according to the first vertex and the second vertex, triggers judgment module;
Judgment module, be also used to when determining module according to the first vertex and the second vertex determine image in 2 D code it is external just When rectangular, judge whether image in 2 D code finishes receiving;When image in 2 D code finishes receiving, image in 2 D code is stored, and touch Send out computing module;When image in 2 D code does not finish receiving, receiving module is triggered;
Computing module, for being calculated in rotation angle and image in 2 D code according to the external square of image in 2 D code Heart point coordinate rotates image in 2 D code according to center point coordinate and rotation angle;
Decoder module, for pre-processing and decoding effective image in 2 D code.
According to the method for this patent, in image acquisition process using extract roughly effective two dimensional code it is external square and It is substantially undistorted and occupy the minimum image to be processed of memory that ranks bi-directional compression algorithm obtains image outline, pre- by image Processing obtains the image to be decoded for being more favorable for storing and parsing, can be in the MCU of lower configuration in conjunction with the two dimensional code algorithm simplified And decoding is realized in other embedded systems, the requirement to system configuration is greatly reduced, enhances user experience, while reducing and opening Send out cost.
Detailed description of the invention
Fig. 1 is a kind of flow chart of the method for the reading two dimensional code provided according to the embodiment of the present invention 1;
Fig. 2 is a kind of flow chart of the method for the reading two dimensional code provided according to the embodiment of the present invention 2;
Fig. 3 is a kind of block diagram of the device of the reading two dimensional code provided according to the embodiment of the present invention 3.
Specific embodiment
Below with reference to the attached drawing in the embodiment of the present application, technical solution in the embodiment of the present invention carries out clear, complete Description, it is clear that described embodiment is a part of the embodiments of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall in the protection scope of this application.
Embodiment 1
The embodiment of the present invention 1 provides a kind of method for reading two dimensional code, comprising:
Step 101: decoding device acquisition image in 2 D code simultaneously judges whether collected be regular two-dimensional code image, if It is to be compressed to image in 2 D code, executes step 104;Otherwise, step 102 is executed;
Step 102: decoding device determines the vertex of image in 2 D code, determines two dimensional code figure according to the vertex of image in 2 D code The external square of picture, and image in 2 D code is compressed;
Step 103: decoding device calculates the center point coordinate and rotation angle of image in 2 D code, according to center point coordinate and It rotates angle and rotates image in 2 D code;
Step 104: decoding device carries out image in 2 D code pretreatment and decoding image in 2 D code.
Embodiment 2
The embodiment of the present invention 2 provides a kind of method for reading two dimensional code, comprising:
Step 201: decoding device carries out system and Image Acquisition initialization.
Specifically, decoding device carries out system initialization, and determines the color of acquired image during initialization The parameters such as the image width image height of color mode, storage format and image, and initialize the first flag bit.
Step 202: decoding device receives image in 2 D code from imaging sensor and point by point to the image in 2 D code received Carry out gray processing processing.
Specifically, decoding device receives the collected image in 2 D code of imaging sensor and point by point by the two dimension of other formats Code image switchs to gray level image;
Such as: image in 2 D code is the image in 2 D code of RGB565 format.
More specifically, the image in 2 D code that the MCU in two-dimentional decoding apparatus is collected, and to the two dimensional code figure received Pixel as in carries out gray processing processing.
Such as: MCU by Red=(color&RED_BASEVALUE) > > 11;
Green=(color&GREEN_BASEVALUE) > > 5;
Blue=(color&BLUE_BASEVALUE);
Gray=(uint8_t) ((Red*38+Green*75+Blue*15) > > 7) will be in the image of RGB565 format Pixel carries out gray processing processing;
Preferably, before step 202, imaging sensor acquires image in 2 D code, and whether judges image in 2 D code acquisition It completes, if so, imaging sensor sets effective for interrupt identification;Otherwise, imaging sensor continues to acquire image in 2 D code;
Accordingly, before step 202, further includes: decoding device judges whether interrupt identification is effective, if so, two-dimentional Code Image Acquisition is completed, and step 202 is executed;Otherwise, image acquisition instruction is sent to imaging sensor, and imaging sensor receives After image acquisition instruction, image in 2 D code is resurveyed.
Optionally, imaging sensor acquires image in 2 D code, and is stored in external image storage space.
Such as: external image storage space can be FIFO (first input first output, first in, first out team Column).
For example, the collected image in 2 D code of imaging sensor are as follows:
0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0 xE6DA,0xDEB9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9 ,0xE6DA, 0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDE B9,0xE6FA, 0xDED9,0xE6FA,0xDED9,0xE6FA,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0x DEDA,0xE6FB, 0xE6FB,0xEF1C,0xEEFB,0xEEFB,0xE6DA,0xE6FB,0xDEDA,0xE6FB ……0xEF3C,0xF75D, 0xF73D,0xF75D,0xEF5C,0xF77D,0xF75D,0xF75D,0xEF3C,0 xF75D,0xF75D,0xF77D, 0xEF5C,0xF77D,0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D ,0xF77D,0xEF5C,0xF77D, 0xF75D,0xF77D,0xEF5C,0xF77D,0xF75D,0xF77D,0xEF 5C,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0x F75B,0xF77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF7B,0xFF9C,0xFF7B,0xFF9C,0xF77B,0xFF9 C,0xFF7B,0xF79C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF 77C,0xEF5B,0xF77C,0xF75B,0xFF9D, 0xF77C,0xF77C,0xF75B,0xF77C,0xEF5B,0 xF77C,0xF75B,0xF77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B ,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C,0xEF 5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0x F75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C,0xEF3B,0xF75C, 0xF73B,0xF75C,0xEF3B,0xF75 C,0xF73B,0xF77C,0xEF5B,0xF75C,0xF73B,0xF75C, 0xEF3B,0xF75C,0xF73B,0xF 75C,0xEF3B,0xF75C,0xF73B,0xF75C,
0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0 xE6DA,0xE6DA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FA ,0xE6DA, 0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6DA,0xE6 DA,0xE6FA, 0xE6FA,0xE6FA,0xE6FA,0xE6FA,0xE6FB,0xE6FB,0xE6FB,0xE6FB,0x E6FB,0xE6FB, 0xEF1C,0xEF1C,0xEEFB,0xEEFB,0xEEFB,0xE6FB,0xE6FB,0xE6FB, 0xEF1B,0xEF1B, 0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEEFB,0xEF1C,0xEF1 C,0xEF1C,0xEF1C, 0xEF1C,0xEF1C,0xEEFC,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xE EFB,0xEF1C,0xEF1C, 0xEF1C,0xEF3C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0 xEF1C,0xEF1C,0xEF1C, 0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C ,0xEF1C,0xEF1C,0xEF1C, 0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF1C,0xEF 1C,0xEF1C,0xEF1C,0xEF1C, 0xEF1C,0xEF1C……0xF77D,0xF77D,0xF77D,0xF77D ,0xF77D,0xF77D,0xF77D,0xF77D, 0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF7 7D,0xF77D,0xF77D,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0x F77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xFF9C,0xFF9D,0xFF9 C,0xFF9D,0xFF9C,0xFF9D,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF 77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xFF9D,0xFF9D,0xF77C,0xF77C,0 xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C ,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF7 7C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0x F77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF75C, 0xF75C,0xF75C,0xF75 C,0xF75C,0xF75C,0xF75C,0xF77C,0xF77C,0xF75C,0xF75C, 0xF75C,0xF75C,0xF 75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,0xF75C,
0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0 xE6DA,0xDEB9,0xE6DA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9,0xE6FA,0xDED9 ,0xE6DA, 0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDEB9,0xE6DA,0xDE D9,0xE6FA, 0xDED9,0xE6FA,0xDED9,0xE6FA,0xDEDA,0xE6FB,0xDEDA,0xE6FB,0x DEDA,0xE6FB, 0xEEFB,0xEEFC,0xE6DA……0xF77C,0xF75D,0xF77C,0xF77C,0xFF 9D,0xFF7D,0xFF9D, 0xEF5C,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0x F77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B, 0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0xF75 B,0xF77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C,0xE F5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF75B,0xF77C,0xEF5B,0xF77C,0 xF75B,0xF77C,0xEF5B,0xF77C, 0xF75B,0xF77C,0xEF5B,0xF77C,0xF75B,0xF77C ,0xEF5B,0xF77C,0xF75B,0xF77C, 0xEF5B,0xF77C,0xF73B,0xF75C,0xEF3B,0xF7 5C,0xF73B,0xF75C,0xEF3B,0xF75C, 0xF73B,0xF75C,0xEF3B,0xF75C,0xF73B,0x F75C,0xEF3B,0xF75C,0xF73B,0xF75C, 0xEF3B,0xF75C,
……
0xB595,0xC5B6,0xBD95,0xC5B6,0xBDB5,0xC5D6,0xBDB5,0xC5D6,0xBD95,0 xC5B6,0xBD95,0xC5B6,0xBD95,0xC5B6,0xBD95,0xBDD6,0xB5B6,0xBDD7,0xB5B6 ,0xBDD7, 0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B6,0xBDD7,0xB5B6,0xBDD7,0xB5 D6,0xBDF7, 0xB5D6,0xC5F7,0xBDD6,0xBDF7,0xB5D6,0xBDD7,0xB5B6,0xBDD6,0x B5B5,0xBDD6, 0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6,0xB5B5,0xBDD6, 0xB595,0xBDB6, 0xB595,0xBDB6,0xB595,0xBDD6,0xB5B5,0xBDD6,0xB5B6……0x AD33,0xA512,0xAD33, 0xA512,0xAD33,0xA512,0xAD33,0xA512,0xAD33,0xA512, 0xAD33,0xA512,0xAD33, 0xA512,0xB554,0xAD33,0xB554,0xAD33,0xB554,0xAD3 3,0xB554,0xAD34,0xB575, 0xAD54,0xBD75,0xB574,0xBD95,0xB575,0xBD96,0xB 575,0xBDB6,0xB595,0xC5B6, 0xB595,0xBDB6,0xB595,0xC5B6,
0xBDB6,0xBD96,0xBDB6,0xBD95,0xC5B6,0xC596,0xC5D6,0xBDB5,0xC5B6,0 xC596,0xC5B6,0xBD95,0xC5B6,0xC596,0xC5B6,0xB5B5,0xBDD7,0xBDB7,0xBDD6 ,0xB5B5, 0xBDD6,0xBDB6,0xBDD6,0xB5B5,0xBDD7,0xBDB7,0xBDD7,0xB5D6,0xBD F7,0xC5D7, 0xC5F7,0xBDD6,0xC5F7,0xC5D7,0xC5F7,0xB5D6,0xBDD7,0xBDB7,0x BDD6,0xB5B5, 0xBDD6,0xBDB6,0xBDD6,0xB5B6,0xBDD7,0xBDB6,0xBDD6,0xB5B5, 0xBDB6,0xBD96, 0xBDB6,0xB595,0xBDB6,0xBDB6,0xBDD6,0xB5B5,0xBDD7,0xBDB 6,0xBDB6,0xB595, 0xBDB6,0xBD96,0xBDD6,0xB5B5,0xBDD7,0xBDB7,0xBDD6,0xB 5B5,0xBDD6,0xBDB6, 0xBDD6,0xB5B5,0xBDB6,0xBD96,0xBDB6,0xB5B5,0xBDD6,0 xBDB6……0xB555,0xAD34, 0xB555,0xB533,0xB554,0xAD33,0xB554,0xB533,0xB 554,0xAD33,0xB554,0xB513, 0xB534,0xAD13,0xB554,0xB533,0xB554,0xAD33,0 xB554,0xB532,0xB553,0xAD32, 0xB553,0xB532,0xB553,0xAD32,0xB554,0xB533 ,0xB554,0xAD33,0xB554,0xB533, 0xB554,0xAD33,0xB554,0xB533,0xB554,0xAD 33,0xAD33,0xAD13,0xAD34,0xA513, 0xAD34,0xAD12,0xAD33,0xA512,0xAD33,0x AD12,0xAD33,0xA512,0xAD33,0xAD12, 0xAD33,0xA512,0xAD33,0xAD12,0xAD33, 0xA512,0xAD33,0xAD12,0xAD33,0xA512, 0xAD33,0xAD12,0xAD33,0xA512,0xAD3 3,0xAD12,0xAD33,0xA512,0xAD33,0xAD12, 0xAD33,0xA512,0xAD33,0xAD12,0xA D33,0xA512,0xAD33,0xAD12,0xAD33,0xA4F2, 0xAD13,0xACF2,0xAD13,0xA4F2,0 xAD33,0xAD12,0xAD33,0xA512,0xAD33,0xAD12, 0xAD33,0xA512,0xAD13,0xAD11 ,0xAD33,0xA512,0xAD53,0xAD12,0xAD33,0xA512, 0xAD33,0xAD12,0xB554,0xAD 33,0xB554,0xB533,0xB554,0xAD33,0xB555,0xB555, 0xB575,0xB554,0xBD95,0x BD75,0xBD95,0xB574,0xBD96,0xBD96,0xBDB6,0xB595, 0xBDB6,0xBD96,0xBDB6, 0xB595;
Step 203: decoding device keeps in the pixel of image in 2 D code line by line and takes sample window.
Specifically, MCU first presets the sample window of n*n and receives from the 1st row to line n pixel and keeps in, and fills simultaneously Sample window.
It is kept in for example, MCU first presets the sampling window of 5*5 and receives the 1st row to the 5th row pixel, while filling sample Window.
Step 204: decoding device judges whether image in 2 D code is regular two-dimensional code image according to the pixel column received, If so, executing step 216;Otherwise, step 205 is executed.
Specifically, whether the depth length in pixels for the pixel column that decoding device judgement receives is black with each positioning image White pixel length, if so, image in 2 D code is regular two-dimensional code image, executes step 216 than consistent;Otherwise, two dimensional code figure As being irregular image in 2 D code, step 205 is executed.
For example, the monochrome pixels length of each positioning image is 1:1:3:1:1, decoding device judges the pixel column received Depth length in pixels whether be 1:1:3:1:1, if so, image in 2 D code be regular two-dimensional code image, execute step 216; Otherwise, image in 2 D code is not regular two-dimensional code image, executes step 205.
Step 205: decoding device judges whether to have obtained the first vertex of image in 2 D code, if so, executing step 209;Otherwise, step 206 is executed.
Optionally, step 205 specifically includes: the value that decoding device judges the first flag bit, when the value of the first flag bit When being 1, the first vertex has been got, has executed step 209;When the value of the first flag bit is 0, the first top is not got Point executes step 206.For example, decoding device judges whether to have got the first fixed point A (x1, y1) of image in 2 D code, if It is to execute step 209;Otherwise, step 206 is executed.
Step 206: decoding device judges the first vertex that whether there is image in 2 D code in pixels sampled row, is to execute Step 207;Otherwise, judge whether image in 2 D code finishes receiving, be that then current two-dimension image is invalid image, decoding device It returns to effective image and responds to imaging sensor, imaging sensor resurveys image in 2 D code;Otherwise, return step 202.
Optionally, step 206 specifically includes:
Step 206-1, decoding device samples the window of a n*n, judges whether window center point is black, if so, Execute step 206-2;Otherwise, judge whether image in 2 D code finishes receiving, if finished receiving, current two-dimension image is nothing Image is imitated, decoding device returns to effective image and responds to imaging sensor;If do not finished receiving, return step 202.
For example, decoding device takes the window of a 5*5, judge whether the central point of the 3rd row 3 of window column is black, if It is to execute step 206-2;Otherwise, judge whether image in 2 D code finishes receiving, if finished receiving, current two-dimension image For invalid image, decoding device returns to effective image and responds to imaging sensor;If do not finished receiving, return step 202;
Step 206-2, decoding device judges the value of central point next line pixel, if immediately below central point or lower section The pixel of two sides is also black, executes step 206-3;Otherwise, judge whether image in 2 D code finishes receiving, if received At current two-dimension image is invalid image, and decoding device returns to effective image and responds to imaging sensor;If do not received It completes, return step 202.
For example, decoding device judges the value of the next line pixel of the central point of the 3rd row 3 column, if immediately below central point Pixel (be located at the 4th row the 3rd arrange) or the pixels (being located at the 4th row the 2nd column and the 4th column) of lower section two sides be also Black executes step 207-3;Otherwise, judge whether image in 2 D code finishes receiving, if finished receiving, current two-dimension figure Picture is invalid image, and decoding device returns to effective image and responds to imaging sensor;If do not finished receiving, return step 202。
Step 206-3, decoding device judges the value of pixel right above central point, if pixel right above central point Value is white, then central point is the first vertex, there is the first vertex, execution step 209 in pixels sampled row;Otherwise, in current Heart point is noise spot, judges whether image in 2 D code finishes receiving, if finished receiving, current two-dimension image is invalid figure Picture, decoding device return to picture null response to imaging sensor;If do not finished receiving, return step 202.
For example, decoding device judges the value of the pixel (be located at the 2nd row the 3rd arrange) right above central point, if it is white, Then central point is the first vertex, executes step 210;Otherwise, central point is noise spot, judges whether image in 2 D code has received At if finished receiving, current two-dimension image is invalid image, and decoding device returns to picture null response to image sensing Device;If do not finished receiving, return step 202.
For example, with the presence or absence of the first vertex A (x1, y1) in the pixel column that decoding device judgement receives, if so, executing Step 207;Otherwise, judge whether image in 2 D code finishes receiving, if so, current two-dimension image is invalid image, decoding Equipment returns to effective image and responds to imaging sensor;Otherwise, return step 202.
Preferably, after imaging sensor receives the effective image response of decoding device return, two dimensional code is resurveyed Image, and judge whether image in 2 D code acquires completion, if acquisition is completed, Image Acquisition completion is returned to decoding device and is referred to It enables;Otherwise, continue to acquire image in 2 D code.
Step 207: decoding device judges whether image in 2 D code is complete according to the first vertex, if so, executing step 208;Otherwise, current two-dimension is invalid image, and decoding device returns to effective image and responds to imaging sensor.
Optionally, decoding device judges whether the ordinate on the first vertex is less than the half of image in 2 D code height, If so, image in 2 D code is complete, step 208 is executed;Otherwise, current two-dimension image is invalid image, and decoding device returns Effective image responds to imaging sensor.
Preferably, after imaging sensor receives the picture null response of decoding device return, two dimensional code is resurveyed Image, and judge whether image in 2 D code acquires completion, if acquisition is completed, Image Acquisition completion is returned to decoding device and is referred to It enables;Otherwise, continue to acquire image in 2 D code.
Step 208: the ordinate on the first vertex of decoding device label is the starting storage line of effective two-dimensional code data.
Step 209: decoding device judges whether image in 2 D code finishes receiving, if so, current two-dimension image is nothing Image is imitated, decoding device returns to effective image and responds to imaging sensor;Otherwise, step 210 is executed.
Preferably, after imaging sensor receives the effective image response of decoding device return, two dimensional code is resurveyed Image, and judge whether image in 2 D code acquires completion, if acquisition is completed, Image Acquisition completion is returned to decoding device and is referred to It enables;Otherwise, continue to acquire image in 2 D code.
Step 210: decoding device continues to image in 2 D code, and the pixel that gray processing receives, and takes sample window.
Step 211: whether the picture element that decoding device judgement receives meets the second preset condition, if so, filling takes Sample window simultaneously stores, and executes step 212;Otherwise, it is only filled with sampling window, executes step 212.
Optionally, step 211 specifically includes: whether the abscissa for the pixel that decoding device judgement receives is odd number, And whether ordinate is consistent with the parity of the ordinate on the first vertex, if so, filling sampling window and storing, executes step Rapid 212;Otherwise, it is only filled with sampling window, executes step 212.
Optionally, the second preset condition can be with are as follows: whether the pixel abscissa received is even number, if so, filling out It fills sampling window and stores, execute step 212;Otherwise, it is only filled with sampling window, executes step 212.
Step 212: decoding device judges whether to have got second vertex of image in 2 D code, if so, executing Step 215;Otherwise, step 213 is executed.
Optionally, step 212 specifically includes: decoding device judges the value of the first flag bit, and if it is 2, decoding device is The second vertex of image in 2 D code is got, step 215 is executed;Otherwise, decoding device does not get image in 2 D code Second vertex executes step 213.
For example, decoding device judges whether to have got the second vertex B (x2, y2) of effective image in 2 D code, if It is to execute step 215;Otherwise, step 213 is executed.
Step 213: decoding device judges whether there is the second vertex of image in 2 D code, if so, setting the first flag bit Value be 2, execute step 214;Otherwise, return step 209;
Optionally, step 213 specifically includes:
Step 213-1, decoding device judges whether window center point is black in the window that a sampling size is n*n Color, if so, executing step 213-2;Otherwise, return step 209.
For example, decoding device takes the window of a 5*5, judge whether the central point of the 3rd row 3 of window column is black, if It is to execute step 213-2;Otherwise, return step 209;
Step 213-2, decoding device judges the relationship of central point abscissa and the first vertex abscissa, if central point is horizontal Coordinate executes step 213-3 less than the first vertex abscissa;If central point abscissa is greater than the first vertex abscissa, execute Step 213-4;
Step 213-3, decoding device judges the point of central point directly to the right or neighbouring two points of point of directly to the right Value, if neighbouring two point of point or the directly to the right point of directly to the right be black, central point be the second vertex, set First flag bit is 2, executes step 214;If the neighbouring point of the point of the point and directly to the right of central point directly to the right is equal It is not black, then central point is not the second vertex, return step 209;
For example, decoding device judges central point directly to the right coordinate for the upper of the point of (3,4) or the point of central point directly to the right Under adjacent coordinate be respectively (2,4) and (4,4) point value, if central point directly to the right coordinate is black for the point of (3,4), Or the point of the neighbouring coordinate of the point of central point directly to the right respectively (2,4) and (4,4) is all black, then central point is Second vertex, the value for setting the first flag bit is 2, executes step 214;If central point directly to the right coordinate be (3,4) point and The neighbouring coordinate of the point of central point directly to the right is respectively that the point of (2,4) and (4,4) is not black, then central point is not Second vertex, return step 209;
Step 213-4, decoding device judges the point of the point of central point directly to the left, the point of directly to the right and directly to the left phase up and down The value of two adjacent points, if the point of central point directly to the left or neighbouring two points of the point of directly to the left are black, and The point of directly to the right is white, then central point is the second vertex, executes step 214;If the point of central point directly to the left and a positive left side Two neighbouring points of the point of side are not that the point of black or central point directly to the right is not white, then central point is not second Vertex, return step 209;
For example, decoding device judge central point directly to the left coordinate for the point of (2,3), point that directly to the right coordinate is (4,3) with And the neighbouring coordinate of the point of directly to the left is respectively the value of the point of (2,2) and (2,4), if coordinate is the point of (2,3) Or coordinate is black for the point of (2,2) and (2,4), and the point of (4,3) is white, then central point is the second vertex, is held Row step 214;If coordinate is the point of (2,3) and coordinate be the point of (2,2) and (2,4) is not black or coordinate is The point of (4,3) is not white, then central point is not the second vertex, return step 209.
Step 214: decoding device determines the third vertex and the 4th of image in 2 D code by the first vertex and the second vertex Vertex, and judge whether image in 2 D code is incomplete, if so, decoding device, which returns to effective image, responds to imaging sensor;It is no Then, step 215 is executed;
Specifically, decoding device is by the first vertex and the second vertex two o'clock coordinate, be calculated third vertex and The coordinate on the 4th vertex, and judge the coordinate on third vertex or the 4th vertex whether not in the range of image, if so, Image in 2 D code is incomplete, and decoding device returns to effective image and responds to imaging sensor;Otherwise, image in 2 D code is complete, executes Step 215;
For example, the first vertex A coordinate is (x1, y1), the second vertex B coordinate is (x2, y2),
Work as x2Greater than x1When, decoding device passes through the first vertex A (x1, y1) and the second vertex B (x2, y2) be calculated Third vertex C coordinate is [x1-(y2-y1), y1+(x2-x1)], the coordinate of the 4th vertex D is [(x1+2y1), y2+(x2-x1)];
Work as x2Less than x1When, decoding device passes through the first vertex A (x1, y1) and the second vertex B (x2, y2) be calculated Third vertex C coordinate is (x1+y2-y1, x1-x2+y2), the 4th vertex D coordinate is (y2-y1+x2, x1-x2+y2)。
Step 215: decoding device judges the external square number of image in 2 D code according to whether completion is stored, if so, executing Step 216;Otherwise, return step 209.
Specifically, decoding device judges whether pixel column where the 4th vertex finishes receiving, if so, outside image in 2 D code It connects square storage to complete, executes step 216;Otherwise, the external square number evidence of image in 2 D code does not store completion, return step 209。
For example, obtained two dimensional code image are as follows:
0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0 xDED9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDEDA,0xDEDA ,0xDEDA, 0xE6FB,0xEEFB,0xE6DA,0xDEDA,0xE6FA,0xEEFA,0xE6FA,0xEEFB,0xE6 FB,0xEEFB, 0xE6FB,0xEEDB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0x E6FB,0xEEFB, 0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB, 0xE6FB,0xEEFB, 0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEF B,0xE6FB,0xEEFB, 0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xE EFB,0xE6FB,0xEF1B, 0xE71B,0xEF1B,0xE71B,0xEF1B,0xE71B,0xEF1B,0xE6FB……0xF75D,0xF77D,0xF77D, 0xF75D,0xF77D,0xF77D,0xF77D,0xF75D,0xF75D,0xF 75D,0xF75D,0xF75D,0xF75D, 0xF75D,0xF75D,0xF75D,0xF75D,0xF77D,0xF75D,0 xF75D,0xF77D,0xF77D,0xF77D, 0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D ,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF7 7C,0xF77C,0xF77C,0xFF9C,0xFF9C, 0xFF9C,0xF79C,0xF77C,0xF77C,0xF77C,0x F77C,0xF77C,0xFF9D,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77 C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF75C,0xF75C,0xF 75C,0xF77C,0xF75C,0xF75C,0xEF3B,0xF73B, 0xF73B;
0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0 xDED9,0xDEB9,0xDEB9,0xDEB9,0xDEB9,0xDED9,0xDED9,0xDED9,0xDEDA,0xDEDA ,0xDEDA, 0xEEFB,0xE6DA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xDEDA,0xEE DA,0xE6DB, 0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB,0xE6FB,0x EEFB,0xE6FB, 0xEEFB,0xE6FB,0xEEFB,0xE6FB,0xEEFB……0xF75D,0xF75D,0xF7 5D,0xF75D,0xF75D, 0xF75D,0xF75D,0xF75D,0xF75D,0xF77D,0xF75D,0xF75D,0x F77D,0xF77D,0xF77D, 0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D,0xF77D, 0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77 C,0xF77C,0xF77C,0xFF9D, 0xFF9D,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF 77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0 xF77C,0xF77C,0xF77C,0xEF5B, 0xF77C,0xF77C,0xF77C,0xF77C,0xF77C,0xF77C ,0xF77C,0xF77C,0xF77C,0xF77C, 0xF77C,0xF77C,0xF77C,0xF75C,0xF75C,0xF7 5C,0xF75C,0xF73B,0xEF3B,0xF73B,0xEF3B
……
0xB595,0xBD95,0xBDB5,0xBDB5,0xBD95,0xBD95,0xBD95,0xBD95,0xB5B6,0 xB5B6,0xB5B5,0xB5B5,0xB5B6,0xB5B6,0xB5D6,0xB5D6,0xBDD6,0xB5D6,0xB5B6 ,0xB5B5, 0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595,0xB595,0xB595,0xB5B5,0xB5 B6,0xB5B5, 0xB595,0xB5B5,0xB5B6,0xB5B6,0xB5B5,0xB5B5,0xB595,0xB5B5,0x B5B5,0xB5B5, 0xB5B5,0xB5B5,0xB5B6,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595, 0xB595,0xB5B5, 0xB5B5,0xB5B5,0xB595,0xB595,0xB5B5,0xB5B5,0xB5B6,0xB5B 5,0xB595,0xB595, 0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB5B5,0xB595,0xBD95,0xB D95,0xBD95,0xBD95, 0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0xB595,0 xB595,0xB595,0xC5D6, 0xC5F7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7,0xC5D7 ,0xC5D7,0xC5D7,0xC5D7, 0xC5D7……0xB554,0xB554,0xB554,0xB554,0xB554,0 xB554,0xAD34,0xAD34,0xAD33, 0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD33 ,0xAD33,0xAD33,0xAD33,0xAD33, 0xAD33,0xAD33,0xAD33,0xAD33,0xAD33,0xAD 33,0xAD33,0xAD33,0xAD13,0xAD13, 0xAD13,0xAD33,0xAD33,0xAD33,0xAD33,0x AD33,0xAD33,0xAD33,0xAD33,0xB554, 0xB554,0xB554,0xB554,0xB575,0xBD75, 0xBD95,0xBD96,0xB595,0xB595,0xB595;
Step 216: decoding device calculates the center point coordinate and rotation angle of image in 2 D code, according to center point coordinate Image in 2 D code is rotated with rotation angle.
Specifically, decoding device calculates the center point coordinate and rotation angle of image in 2 D code, is obtained according to center point coordinate To the rotation angle of image in 2 D code, image rotation is carried out according to rotation angle and obtains the image in 2 D code of rule.
Step 217: the edge for the image in 2 D code that decoding device detection receives.
Optionally, decoding device to common edge detection algorithm include: Roberts operator, Sobel operator, Prewitt operator, Canny operator etc.;
For example, carrying out edge detection using improved Sobel operator in this patent, relatively accurate two dimensional code can be obtained Image.
Step 218: decoding device carries out perspective mapping transformation to image in 2 D code.
Optionally, MCU utilizes the centre of perspectivity, picture point, the condition of target point three point on a straight line, makes to hold shadow by chasles theorem Face (perspective plane) rotates a certain angle around trace (axis of homology), destroys original projected light harness, is still able to maintain image-bearing surface upslide The constant transformation of shadow geometric figure carries out three dimensional change to picture and obtains regular two-dimensional code image.
Step 219: decoding device carries out bilinear interpolation to image in 2 D code.
Specifically, pixel coordinate can change after image rotation, and make the value of pixel become discrete and do not connect Continuous, linear interpolation can be very good to solve the problem of dtmf distortion DTMF after image rotation.
Bilinear interpolation respectively carries out once linear interpolation to pixel horizontal direction and vertical direction, can greatly improve The effect of image procossing.
Step 220: decoding device carries out median filtering to image in 2 D code.
Specifically, MCU sets the gray value of each pixel to all pixels point gray scale in the point field window The intermediate value of value.
Step 221: decoding device carries out binary conversion treatment to image in 2 D code.
Specifically, decoding device selects reasonable threshold value to gray level image, so that pixel becomes two kinds of black " 1 " white " 0 " The image data of color is used for decoding subprogram.
For example, using variance method, also known as Otsu algorithm between most imperial palace, available optimal binary conversion treatment in this patent Image.
Step 222: decoding device carries out two dimensional code and decodes operation.
Two dimensional code decoding algorithm common ZBar, Zxing etc..It uses in view of in low configuration embedded system, makes herein It as the algorithm foundation of QR code decoded portion specifically include: recognition format information with the decoded portion algorithm of quirc algorithm, Version information is distinguished, exposure mask, return information and error correction code word, error correction, decoding are eliminated.
The advantage is that: occupying system resources are small, independent of the function library other than standard C99, size of code is small, decoding effect Rate it is high be suitable for embedded system the characteristics of.
Embodiment 3
The embodiment of the present invention 3 provides a kind of equipment for reading two dimensional code, comprising:
Receiving module 01, for receiving two dimensional code image;
Judgment module 02, the image for being received according to receiving module 01 judge whether image in 2 D code is rule and has The two dimensional code image of effect;
Receiving module 01 is also used to judge image in 2 D code for rule and efficient 2-d code image when judgment module 02 When, completely receive image in 2 D code;
Compression module 03, for judging image in 2 D code for rule and efficient 2-d code image when judgment module 02 When, compress the image in 2 D code that receiving module 01 is completely received;
Judgment module 02 is also used to judge to whether there is the first of image in 2 D code in image that receiving module 01 receives Vertex and the second vertex;It is also used to when judging the first top in image that receiving module 01 receives there is no image in 2 D code When point and the second vertex, judge whether image in 2 D code finishes receiving, when judging image in 2 D code is invalid image, triggering Receiving module 01;
Receiving module 01 is also used to judge that the first vertex of image in 2 D code and the second vertex are not deposited when judgment module 02 , and when image in 2 D code does not finish receiving also, it continues to image in 2 D code and compresses the image received, triggering judges mould Block 02;
Determining module 04, for judging the first top in the image received there are image in 2 D code when judgment module 02 When point and the second vertex, the external square of image in 2 D code is determined according to the first vertex and the second vertex, triggers judgment module 02;
Judgment module 02 is also used to determine the outer of image in 2 D code according to the first vertex and the second vertex when determining module 04 When connecing square, judge whether image in 2 D code finishes receiving;When image in 2 D code finishes receiving, image in 2 D code is stored, And trigger computing module 05;When image in 2 D code does not finish receiving, receiving module 01 is triggered;
Computing module 05, for calculating rotation angle and image in 2 D code according to the external square of image in 2 D code Center point coordinate rotates image in 2 D code according to center point coordinate and rotation angle;
Decoder module 06, for pre-processing and decoding compressed effective image in 2 D code.
Optionally, receiving module 01 is specifically used for receiving image in 2 D code point by point from imaging sensor and gray processing receives Image in 2 D code.
Optionally, a kind of equipment reading image in 2 D code further include:
Initialization module, for carrying out system and Image Acquisition initialization.
Optionally, judgment module 02 is also used to judge whether interrupt identification is completed in acquisition effective;When judgment module 02 judges When acquisition completion interrupt identification is effective out, initialization module is triggered.
Optionally, the equipment of image in 2 D code is read further include:
Storage module, for keeping in the pixel of image in 2 D code line by line and taking sample window.
Compression module 03 is specifically used for compressing image in 2 D code using bi-directional compression algorithm.
Optionally, when judgment module 02 judges that the image in 2 D code received is regular two-dimensional code image, mould is compressed Block 03 is specifically used for the starting point according to regular two-dimensional code image, takes the cross of transverse and longitudinal coordinate parity Yu image in 2 D code starting point The consistent pixel storage of ordinate;
When judgment module 02 judges that image in 2 D code is irregular image in 2 D code, compression module 03 is specifically included:
Submodule is marked, the ordinate for the first vertex of label is the initial storage row of image in 2 D code;
Judging submodule, for judging whether current pixel point abscissa is odd, and whether ordinate is vertical with the first vertex The parity of coordinate is consistent.
Optionally, judgment module 02, the depth length in pixels also particularly useful for the pixel column for judging the image received are It is no consistent with the monochrome pixels length ratio of each positioning image.
Optionally, judgment module 02 is also used to be judged whether according to the first flag bit to have got the first of image in 2 D code Vertex, when judging to have got the first vertex of two dimensional code, judgment module 02 is also used to whether judge image in 2 D code It finishes receiving;
Return module responds to image for when judgment module judges that image in 2 D code is invalid, returning to effective image Sensor;
Receiving module 01, is also used to receive image in 2 D code point by point, and gray processing image in 2 D code simultaneously takes sample window.
Optionally, judgment module 02 is also particularly useful for the value for judging the first flag bit.
Optionally, judgment module 02 further include:
Second judgment submodule, for judging whether image in 2 D code is complete according to the first vertex;
Submodule is marked, the ordinate for the first vertex of label is the starting storage line of image in 2 D code.
Optionally, judgment module 02 is also used to be judged whether according to the first flag bit to have obtained the second vertex;Work as judgement When not obtaining the second vertex out, judge whether image in 2 D code finishes receiving, when judging that image in 2 D code finished receiving When, trigger return module;When judging that image in 2 D code does not finish receiving, receiving module is triggered.
Optionally, judgment module 02 is specifically used for the value by judging the first flag bit to determine whether obtaining the second top Point.
Optionally, decoder module 06 specifically includes:
Detection sub-module, for detecting the edge of the image in 2 D code received;
Perspective mapping submodule, for carrying out perspective mapping transformation to image in 2 D code;
Bilinear interpolation submodule, for carrying out bilinear interpolation module to image in 2 D code;
Median filtering submodule, for carrying out median filtering to image in 2 D code;
Binaryzation submodule, for carrying out binary conversion treatment to image in 2 D code;
Decoding sub-module, for decoding image in 2 D code.

Claims (20)

1. a kind of method for reading two dimensional code characterized by comprising
Step s1: two dimensional code reading device starts to receive image in 2 D code, judges the two dimensional code figure according to the image received It seem no for regular two-dimensional code image, if so, continuing to the image in 2 D code to finishing receiving, while compression receives Image, execute step s5;Otherwise, step s2 is executed;
Step s2: with the presence or absence of the first top of the image in 2 D code in the image that the two dimensional code reading device judgement receives Point and the second vertex, if so, executing step s3;It is then institute if not, judging whether the image in 2 D code finishes receiving Stating image in 2 D code is invalid image, otherwise return step s1 continues to the image in 2 D code and compresses the figure received Picture, return step s2;
Step s3: the two dimensional code reading device determines the image in 2 D code according to first vertex and second vertex External square, judge whether the image in 2 D code received and compresses completion, if so, execute step s4;Otherwise, It continues to, while compressing the image in 2 D code, return step s3;
Step s4: the two dimensional code reading device calculates rotation angle and institute according to the external square of the image in 2 D code The center point coordinate of image in 2 D code is stated, the two dimensional code reading device is revolved according to the center point coordinate and the rotation angle Turn the image in 2 D code, executes step s5;
Step s5: the two dimensional code reading device, which executes, to be pre-processed and decodes the image in 2 D code.
2. the method as described in claim 1, which is characterized in that step s1 further include: the two dimensional code reading device is from image Sensor receives the image that the image in 2 D code and gray processing receive point by point.
3. the method as described in claim 1, which is characterized in that before step s1 further include: the two dimensional code reading device into Row system and Image Acquisition initialization.
4. the method as described in claim 1, which is characterized in that before the step s1 further include: the two dimensional code reads dress It sets acquisition acquisition to complete interrupt identification and judge whether acquisition completion interrupt identification is effective, if so, the image in 2 D code is adopted Collection is completed, and step s1 is executed;Otherwise, the image in 2 D code does not acquire completion, continues acquisition to acquisition and completes.
5. the method as described in claim 1, which is characterized in that the compression image in 2 D code specifically: described two Dimension code reading device compresses the image in 2 D code using bi-directional compression algorithm.
6. the method as described in claim 1, which is characterized in that judge institute according to the image received described in the step s1 State whether image in 2 D code is that regular two-dimensional code image specifically includes:
The depth length in pixels of the pixel column for the image that two dimensional code reading device judgement receives whether with each positioning figure The monochrome pixels length of picture is than consistent, if so, the image in 2 D code is regular two-dimensional code image;Otherwise, the two dimensional code Image is irregular image in 2 D code.
7. the method as described in claim 1, which is characterized in that when the two dimensional code reading device judges the image received It is middle there are when the first vertex of the image in 2 D code, the step s2 further include:
Step s2-1, the described two dimensional code reading device judges whether the image in 2 D code is complete according to first vertex, such as Fruit is to execute step s2-2;Otherwise, the image in 2 D code is invalid image, the two dimensional code reading device return image without Effect response, return step s0;
Step s2-2, the described two dimensional code reading device marks the ordinate on first vertex for the starting of the image in 2 D code Storage line.
8. the method as described in claim 1, which is characterized in that after the step s2, before the step s3 further include:
The two dimensional code reading device judges whether to have obtained second vertex according to the first flag bit, if so, executing Step s3;It is that then the image in 2 D code is invalid image, institute if not, judging whether the image in 2 D code finishes receiving It states two dimensional code reading device return effective image and responds to described image sensor, return step s0, otherwise described in point-by-point reception Image in 2 D code, image in 2 D code described in gray processing simultaneously take sample window, continue to determine whether to obtain second vertex.
9. method according to claim 8, which is characterized in that the two dimensional code reading device is sentenced according to first flag bit It is disconnected whether to have obtained second vertex specifically:
The decoding device judges whether the value of first flag bit is the second preset value, when the value of first flag bit is When the second preset value, the two dimensional code reading device obtains second vertex;When the value of the first flag bit is not second default When value, the two dimensional code reading device does not obtain second vertex.
10. the method as described in claim 1, which is characterized in that step s5 is specifically included:
Step s5-1, the edge for the image in 2 D code that the described decoding device detection receives;
Step s5-2, the described decoding device carries out perspective mapping transformation to the image in 2 D code;
Step s5-3, the described decoding device carries out bilinear interpolation to the image in 2 D code;
Step s5-4, the described decoding device carries out median filtering to the image in 2 D code;
Step s5-5, the described decoding device carries out binary conversion treatment to the image in 2 D code;
Step s5-6, the described decoding device decodes image in 2 D code.
11. a kind of two dimensional code reading device characterized by comprising
Receiving module, for receiving image in 2 D code;
Judgment module, the image for being received according to the receiving module judge whether image in 2 D code is regular and effective Two dimensional code image;
The receiving module is also used to judge the image in 2 D code for rule and efficient 2-d code when the judgment module When image, the image in 2 D code is completely received;
Compression module, the image in 2 D code being completely received for compressing the receiving module;
The judgment module is also used to judge in image that the receiving module receives with the presence or absence of the image in 2 D code First vertex and the second vertex;It is also used to when judging that there is no the two dimensional code figures in image that the receiving module receives When first vertex of picture and second vertex, judge whether the image in 2 D code finishes receiving, it is described when judging When image in 2 D code is invalid image, the receiving module is triggered;
The receiving module is also used to judge first vertex of the image in 2 D code and described when the judgment module Second vertex is not present, and when the image in 2 D code does not finish receiving also, continues to the image in 2 D code and compress connect The image received triggers the judgment module;
Determining module, for judging the first top in the image received there are the image in 2 D code when the judgment module When point and the second vertex, the external square of the image in 2 D code is determined according to first vertex and second vertex, Trigger the judgment module;
The judgment module is also used to determine described two according to first vertex and second vertex when the determining module When tieing up the external square of code image, judge whether the image in 2 D code finishes receiving;When the image in 2 D code has received Cheng Shi stores the image in 2 D code, and triggers computing module;When the image in 2 D code does not finish receiving, described in triggering Receiving module;
Computing module, for calculating rotation angle and the image in 2 D code according to the external square of the image in 2 D code Center point coordinate, the image in 2 D code is rotated according to the center point coordinate and the rotation angle;
Decoder module, for executing pretreatment and decoding the complete received effective image in 2 D code of the receiving module.
12. equipment as claimed in claim 11, which is characterized in that the receiving module is specifically used for point-by-point from imaging sensor Receive the image in 2 D code and the image in 2 D code that gray processing receives.
13. equipment as claimed in claim 12, which is characterized in that further include:
Initialization module, for carrying out system and Image Acquisition initialization.
14. equipment as claimed in claim 12, which is characterized in that the judgment module is also used to judge that acquisition is completed to interrupt mark Whether will is effective;When the judgment module judges that the acquisition completion interrupt identification is effective, the receiving module is triggered.
15. equipment as claimed in claim 11, which is characterized in that further include:
Storage module, for keeping in the pixel of the image in 2 D code line by line and taking sample window.
16. equipment as claimed in claim 11, which is characterized in that the compression module is specifically used for using bi-directional compression algorithm The image in 2 D code is compressed.
17. equipment as claimed in claim 11, which is characterized in that the judgment module is received also particularly useful for judgement Whether the depth length in pixels of the pixel column of image is consistent with the monochrome pixels length ratio of each positioning image.
18. equipment as claimed in claim 11, which is characterized in that the judgment module is also used to according to first flag bit Judge whether to have obtained second vertex;When judging not obtain second vertex, the image in 2 D code is judged Whether finish receiving, when judging that the image in 2 D code has finished receiving, triggers return module;When judging described two When dimension code image does not finish receiving, receiving module is triggered.
19. equipment as claimed in claim 17, which is characterized in that the judgment module is specifically used for by judging described first The value of flag bit is to determine whether obtain second vertex.
20. equipment as claimed in claim 11, which is characterized in that the decoder module specifically includes:
Detection sub-module, for detecting the edge of the image in 2 D code received;
Perspective mapping submodule, for carrying out perspective mapping transformation to the image in 2 D code;
Bilinear interpolation submodule, for carrying out bilinear interpolation module to the image in 2 D code;
Median filtering submodule, for carrying out median filtering to the image in 2 D code;
Binaryzation submodule, for carrying out binary conversion treatment to the image in 2 D code;
Decoding sub-module, for decoding image in 2 D code.
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 true CN109190437A (en) 2019-01-11
CN109190437B 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)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110084080A (en) * 2019-04-28 2019-08-02 上海快仓智能科技有限公司 Method, apparatus, two dimensional code and the trolley two dimensional code identification and generated
CN111507119A (en) * 2019-01-31 2020-08-07 北京骑胜科技有限公司 Identification code identification method and device, electronic equipment and computer readable storage medium
CN116882432A (en) * 2023-07-11 2023-10-13 深圳市裕源欣电子科技有限公司 Method and system for scanning multiple materials, readable storage medium and computer equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070272755A1 (en) * 2006-05-29 2007-11-29 Shenzhen Syscan Technology Co., Ltd. Two-directional bar code symbol and its encoding & decoding method
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

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070272755A1 (en) * 2006-05-29 2007-11-29 Shenzhen Syscan Technology Co., Ltd. Two-directional bar code symbol and its encoding & decoding method
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

Cited By (6)

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

Also Published As

Publication number Publication date
CN109190437B (en) 2021-03-16

Similar Documents

Publication Publication Date Title
CN103714327B (en) Method and system for correcting image direction
EP3306562B1 (en) Image processing method and device
CN109190437A (en) A kind of method and reading device reading two dimensional code
CN105989317B (en) Two-dimensional code identification method and device
US6526161B1 (en) System and method for biometrics-based facial feature extraction
JP5905642B2 (en) Decoding method for matrix type two-dimensional code
CN112396640B (en) Image registration method, device, electronic equipment and storage medium
TW201201107A (en) Barcode image recognition system and associated method for hand-held device
CN108346162B (en) Remote sensing image registration method based on structural information and space constraint
US9270846B2 (en) Content encoded luminosity modulation
CN109117846A (en) A kind of image processing method, device, electronic equipment and computer-readable medium
EP3338249B1 (en) Video image alignment for video stabilization
CN110598139A (en) Web browser augmented reality real-time positioning method based on 5G cloud computing
CN112950673A (en) Target object detection and tracking system and method
CN110503002B (en) Face detection method and storage medium
CN111507119B (en) Identification code recognition method, identification code recognition device, electronic equipment and computer readable storage medium
CN111144156B (en) Image data processing method and related device
CN113627328A (en) Electronic device, image recognition method thereof, system on chip, and medium
Zhang et al. Nonlocal edge-directed interpolation
CN112183148A (en) Batch bar code positioning method and identification system
CN114648768B (en) Handwritten track extraction method and device based on image frame, storage medium and equipment
JP2003189020A (en) Communication method using screen and communication system
JP4222013B2 (en) Image correction apparatus, character recognition method, and image correction program
CN112598728B (en) Projector attitude estimation, trapezoidal correction method and device, projector and medium
CN115311145A (en) Image processing method and device, electronic device and 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