CN112541370A - QR code position detection graph positioning method based on FPGA - Google Patents

QR code position detection graph positioning method based on FPGA Download PDF

Info

Publication number
CN112541370A
CN112541370A CN202011484527.8A CN202011484527A CN112541370A CN 112541370 A CN112541370 A CN 112541370A CN 202011484527 A CN202011484527 A CN 202011484527A CN 112541370 A CN112541370 A CN 112541370A
Authority
CN
China
Prior art keywords
scanning
image
position detection
column
line
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
CN202011484527.8A
Other languages
Chinese (zh)
Other versions
CN112541370B (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.)
University of Electronic Science and Technology of China
Original Assignee
University of Electronic Science and Technology of China
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 University of Electronic Science and Technology of China filed Critical University of Electronic Science and Technology of China
Priority to CN202011484527.8A priority Critical patent/CN112541370B/en
Publication of CN112541370A publication Critical patent/CN112541370A/en
Application granted granted Critical
Publication of CN112541370B publication Critical patent/CN112541370B/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

Abstract

A QR code position detection graph positioning method based on FPGA belongs to the field of QR code image identification. The invention adopts a novel compression storage method, can obtain all information of 3 position detection graphs by only carrying out scanning twice, including abscissa, ordinate, line scanning length and column scanning length, and improves algorithm execution efficiency while greatly reducing storage space occupation. Compared with the prior art, the QR code position detection graph positioning method based on the FPGA occupies smaller storage space and has higher efficiency, and by adopting the parameterized design, when the size of an input image is changed or internal parameters need to be adjusted, excessive code modification is not needed.

Description

QR code position detection graph positioning method based on FPGA
Technical Field
The invention belongs to the field of QR code image identification, and particularly relates to a QR code position detection graph positioning method based on an FPGA.
Background
The QR code is a two-dimensional matrix code, and information is stored by utilizing dark and light grids in the matrix. Compared with the traditional one-dimensional bar code, the QR two-dimensional bar code has the advantages of large storage capacity, small occupied space, strong error correction capability, capability of scanning and identifying from any direction and the like. And the QR code can store Chinese characters, so the QR code is widely applied to the fields of mobile payment, intelligent logistics, transportation and the like.
Preprocessing the collected original image in the QR code identification process, and generally carrying out graying, median filtering, binarization and other processing; the preprocessed image is represented by 0 or 1 with a single bit width as black and white, corresponding to dark and light squares of the stored information in the two-dimensional code.
On the premise of correctly identifying the QR code, the related information of the position detection graph is accurately positioned, on the basis, the version information of the two-dimensional code can be calculated, a sampling grid is further generated, and the information carried by the QR code is correctly read, so that the efficient positioning of the position detection graph is very important.
Any version of the QR code has 3 position detection patterns with specific features, which are distributed at the vertices of the QR code, like a black and white alternating "hui" shape. When a position detection graph of a standard QR code is scanned in a row-column mode, the length ratio of black, white, black, white and black sub-line segments is 1:1:3:1:1, the central coordinates of a long line segment formed by the 5 sub-line segments are recorded, the central coordinates of the long line segment in line scanning are connected to form a longitudinal line segment, the central coordinates of the long line segment in column scanning are connected to form a transverse line segment, and the intersection point of the two line segments is the central point of the position detection graph. In the traditional QR code position detection graph positioning method, two RAMs which are consistent with the size of an image are generated, wherein 1 in the corresponding position represents that the image is a suspected point, 0 represents that the image is not a suspected point, the result of the first line scanning is stored in a line scanning suspected point RAM, and the result of the second line scanning is stored in a column scanning suspected point RAM; and then comparing whether the values stored in the two RAMs with the same coordinate are both 1, and if so, determining the center of the position detection graph. The method has the following defects: the RAM space is excessively occupied. If the binary image is 1024 × 768, the row scanning suspected point RAM and the column scanning suspected point RAM also need such a large space, and the RAM space of 1536K is needed under the condition that the row/column scanning length of the target point is not saved; if the line/column scan length is saved while the dot attribute (whether it is a suspected dot) is saved, the RAM resources are multiplied by the image size. If only the point attribute (whether the point attribute is a suspected point) is stored, a fourth line scanning and a fifth line scanning are needed to determine the line/line scanning length, so that the execution time of the algorithm is increased, and the efficiency is reduced.
Disclosure of Invention
The invention aims to provide a QR code position detection graph positioning method based on an FPGA (field programmable gate array), aiming at the defects in the background technology.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
a novel compressed storage method is adopted, all information of 3 position detection graphs can be obtained only by scanning twice, including horizontal coordinates, vertical coordinates, line scanning length and column scanning length, and algorithm execution efficiency is improved while storage space occupation is greatly reduced. Because the number of long line sections satisfying the color distribution and the proportion characteristics of the position detection graph in the image is limited, on the basis, when the image is scanned for the first time, the index number is used for counting the scanned suspected points, meanwhile, the index number is used as an address to store the central horizontal coordinate and the line scanning length of the scanned long line sections into the line suspected point information RAM, and the line suspected point index RAM uses the vertical coordinate as an address to store the latest index number after the line scanning is completed. During the second vertical column scanning, the vertical scanning is generally performed in a 'horizontal and vertical combination' mode, but the images stored in the image cache RAM are merged and stored, namely, the adjacent N pixel points are merged into one pixel block and then stored in the image cache RAM. This has no effect on the horizontal line scan, but if the vertical column scan is performed by reading N-bit wide data and only 1 bit is scanned, the efficiency will be reduced. Therefore, a scheme of scanning the read N pixel points column by column from left to right is adopted, and the intermediate variables of the N columns are stored by using a memory, which is equivalent to scanning the N columns longitudinally at the same time. After the long line segment which satisfies the proportion longitudinally is detected, the longitudinal coordinate of the center of the long line segment is taken as an address, the index numbers stored in the line and the previous line in the line suspected point index number RAM are read, the line scanning suspected point information stored in the line is read from the line suspected point information RAM according to the read index numbers, and the read index numbers and the line scanning suspected point information are compared to judge whether the line scanning point information is the center of the position detection graph or not.
A QR code position detection graph positioning method based on FPGA is characterized by comprising the following steps:
s1, acquiring a QR code image in real time by using a camera, wherein the format is RGB565, the size of the image is M x L, M represents the number of columns of an image matrix, L represents the number of rows of the image matrix, and each pixel point P is represented by 16 bits;
s2, establishing a rectangular coordinate system for the image matrix: taking the pixel point at the upper left corner of the image matrix as an origin, taking the horizontal rightward direction as an x axis, and taking the horizontal downward direction as a y axis, wherein x is more than or equal to 0 and less than or equal to M-1, and y is more than or equal to 0 and less than or equal to L-1, so that each pixel point P can be determined by (x, y) coordinates;
s3, carrying out graying processing on the acquired QR code image, and compressing the bit width of the pixel point P from 16 bits to 8 bits;
s4, carrying out median filtering processing on the image subjected to the graying processing in the step S3 to eliminate noise in the image;
s5, carrying out binarization on the QR code image after median filtering by using a Kittler threshold method, and adopting a method of 'error frame binarization' in order to improve the real-time property of the system and reduce the occupation of image cache resources:
assuming that the gray value of a pixel point after median filtering is f (x, y), wherein f (x, y) belongs to [0, 255], the optimal threshold value of the ith frame image is Pt (i) (0 is more than or equal to Pt (i) is less than or equal to 255), the value of the pixel point after binarization is G (x, y), and G (x, y) belongs to {0,1 }; after a system is electrified and works, counting the number of image frames i acquired by a camera in real time from 0, wherein an optimal threshold value Pt (0) is 0 at the beginning; and carrying out binarization on any ith frame image by adopting the following method:
s5.1, when i is equal to 0, Pt (0) is equal to 0, and the input 0 th frame image is binarized: if the gray value f (x, y) is less than or equal to Pt (0), G (x, y) is 0, and if f (x, y) > Pt (0), G (x, y) is 1; meanwhile, the optimal threshold value Pt (0) 'of the 0 th frame image is calculated in real time by using a Kittler threshold value method, when the input of the 0 th frame image is finished, the optimal threshold value calculation of the frame image is finished, Pt (1) is made to be Pt (0)', and then S5.2 is carried out;
s5.2, when i is equal to 1, Pt (1) ═ Pt (0)', binarizes the input 1 st frame image: if f (x, y) ≦ Pt (1), then G (x, y) equals 0, if f (x, y) > Pt (1), then G (x, y) equals 1; meanwhile, the optimal threshold value Pt (1) 'of the 1 st frame image is calculated in real time by using a Kittler threshold value method, when the 1 st frame image is input, the optimal threshold value calculation of the frame image is completed, Pt (2) is made to be Pt (1)', and then S5.3 is carried out;
s5.3, when i is k +1, Pt (k +1) is Pt (k)', binarizes the input (k +1) th frame image: if f (x, y) ≦ Pt (k +1), then G (x, y) equals 0, if f (x, y) > Pt (k +1), then G (x, y) equals 1; meanwhile, the optimal threshold value Pt (k +1) 'of the (k +1) th frame image is calculated in real time by using a Kittler threshold method, when the (k +1) th frame image is input, the optimal threshold value calculation of the frame image is completed, Pt (k +2) ═ Pt (k + 1)', and then S5.4 is carried out;
and S5.4, continuously circulating according to the rule, wherein the core idea is that the optimal threshold value obtained by calculating the image of the previous frame is used for carrying out binarization on the image of the current frame, and the optimal threshold value obtained by calculating the image of the current frame is used for carrying out binarization on the image of the next frame. Because the images collected by the camera cannot be suddenly changed between adjacent frames, the larger the frame rate is, the smaller the error is, the more a frame of complete images is not required to be cached, and after the optimal threshold value is calculated, the binaryzation operation is carried out;
s6, receiving a serial image bit stream after any frame binarization, and storing the serial image bit stream into an image cache RAM by taking an N-bit pixel block as a unit after serial-parallel conversion; where N is chosen according to image size and memory bit width, typically an even power of 2, such as 4, 8, 16, 32, etc.;
s7, scanning the whole frame image received in the step S6 line by line and pixel point by pixel point to obtain suspected point information meeting the characteristics of the position detection graph;
assuming that C1-C6 correspond to colors representing 6 sub-line segments, S1-S6 correspond to x coordinates representing starting points of 6 sub-line segments, and L1-L6 correspond to lengths representing 6 sub-line segments, respectively; a large number of experiments show that the number of suspected points meeting the proportional relation during line scanning is limited in a specific scene, and the upper limit value of the number of the suspected points is assumed to be T;the MEM1 (line plausible point information RAM) is for storing line plausible point information, and has a depth T and a bit width T
Figure BDA0002838634130000041
A represents the index number of the suspected point of the line, the initial value is 0, and the index number is increased by 1 when one suspected point is scanned; MEM2 (line suspected point index RAM) stores the latest index after each line is scanned, its depth is L and its bit width is
Figure BDA0002838634130000042
Figure BDA0002838634130000043
Represents rounding down;
s7.1, before starting scanning, x ═ y ═ 0, a is set to 0, C1-C6 are all set to 0(0 indicates black, 1 indicates white), S1-S6 are all set to 0, and L1-L6 are all set to 0;
s7.2, scanning the whole frame image received in step S6 line by line, where x represents the abscissa, and if G (x, y) is C6, L6 is (L6+1), and the other variables remain unchanged; if G (x, y) ≠ C6, values of C2, C3, C4, C5, and C6 are assigned to C1, C2, C3, C4, and C5, C6 is inverted, values of S2, S3, S4, S5, and S6 are assigned to S1, S2, S3, S4, S5, S6 ═ x, L2, L3, L4, L5, and L6 are assigned to L1, L2, L3, L4, and L4, if L4 ═ 1, that is, C4 ═ C4, C4 ═ L4, S4 ═ S4, S4 ═ L4, S4 ═ S4, S4 ═ L4, S4 ═ 4, S4: judging whether the values of C1-C5 are 0,1, 0,1 and 0 respectively, namely black, white, black and black are alternated, if not, the long line section formed by the five sub line sections does not meet the position detection pattern characteristics, neglecting and continuing to scan; if so, determine L1: l2: l3: l4: whether L5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if the above proportional relationship is satisfied, the central abscissa of the long line segment composed of five sub-line segments of C1-C5
Figure BDA0002838634130000044
And the line scan length (S6-S1) are stored to MEM1 at address a, then index a is incremented by 1, if not, ignored, and scanning continues; finally, whether x is (M-2) or not is judged, if yes, the step S7.3 is skipped to, otherwise, x is made to be (x +1), and the process of the step S7.2 is repeated; where-represents the negation,
Figure BDA0002838634130000045
represents rounding down;
s7.3, reading the value G (M-1, y) of the last 1 pixel point, scanning, and if G (M-1, y) ═ C, assigning the values of C, S, C, S +1, S ═ S, S ═ M, L ═ L, L ═ L, and L +1, respectively; if G (M-1, y) ≠ C, values of C, C are assigned to C, S ═ M-1, values of L, i.e. C ═ C, S ═ S, S ═ M-1, L ═ L; then judging whether the five assigned sub-line segments meet the position detection pattern characteristics: judging whether the values of C1-C5 are 0,1, 0,1 and 0 respectively, namely black, white, black and black are alternated, if not, the long line section formed by the five sub line sections does not meet the position detection pattern characteristics, neglecting and continuing to scan; if so, determine L1: l2: l3: l4: whether L5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if the above proportional relationship is satisfied, the central abscissa of the long line segment composed of five sub-line segments of C1-C5
Figure BDA0002838634130000051
And the line scan length (S6-S1) are stored to the MEM1 at address A, and thenIncreasing the index number A by 1, if not, ignoring, and continuing to scan; wherein the content of the first and second substances,
Figure BDA0002838634130000052
represents rounding down;
s7.4, storing the obtained latest index a in the MEM2 at address y, and if y is equal to (L-1), indicating that the line scanning of the entire frame of image is completed, then the process goes to step S8; otherwise, let x be 0, y be y +1, set all C1-C6 to 0(0 represents black, 1 represents white), S1-S6 to 0, and L1-L6 to 0, and then go to step S7.2;
s8, after the line scanning is finished, performing line scanning on the whole frame image received in the step S6, and simultaneously scanning N columns in a mode of scanning from left to right column by column; after the target point is scanned, the MEM1 and the MEM2 are read, and compared to determine whether the coordinates of the suspected points are consistent, the coordinate of the center of the position detection pattern is determined if the coordinates are consistent. The image is stored in the image cache RAM by taking the N-bit pixel block as a unit, and the scanning mode can reduce the access to the memory.
Hypothesis Cm1-Cm6 respectively corresponding to colors, S, representing 6 sub-line segments in a scanning process of a certain columnm1-Sm6 respectively correspond to the y-coordinate, L, representing the starting points of the 6 sub-line segmentsm1-Lm6 correspondingly represent the lengths of 6 subsegments in the column scanning, wherein m is x% N, the value range of m is 0 to (N-1), x represents the abscissa of the scanned pixel point, and the "%" symbol represents the remainder operation; these information are stored using 6 memories Q each having a bit width of
Figure BDA0002838634130000053
The depth is N, corresponding to the number of columns N scanned simultaneously, and 6 memories respectively store C of 1 sub-line segmentm、Sm、LmInformation, e.g. storage Q1 storing C m1、S m1、L m1, memory Q2 stores C m2、S m2、L m2, …, memory Q6 stores Cm6、Sm6、Lm6, then the 6 memories store the intermediate information in the scanning process of a certain column at the same address,n addresses completely store the N columns of scan information, e.g., address 0 of Q1-Q6 completely stores the x-th column of scan information, where x% N is 0. The MEM3 is used to store N columns of suspected point information during a line scan, and has a depth of N and a bit width of N
Figure BDA0002838634130000061
NUM records the number of suspected points scanned by N columns in the scanning process of a certain line, and POS with the bit width of N records the corresponding columns scanned by the suspected points;
Figure BDA0002838634130000062
represents rounding down;
s8.1, scanning x to x + (N-1) columns of the image simultaneously, setting x to y to 0 and NUM to 0 before starting the scanning, setting POS to 0, and initializing variables in 6 memories Q1 to Q6 by a method in line scanning, that is, C is Cm1-CmAll of 6 are set to 0(0 means black, 1 means white), Sm1-Sm6 are all set to 0, Lm1-Lm6 are all set to 0;
s8.2, scanning the x to x + (N-1) columns of the whole frame image received in the step S6 at the same time, reading pixel blocks representing (x, y) - (x + N-1, y) from the image cache RAM for scanning, and scanning the N columns column by column;
s8.3, the specific process is as follows: reading the scanning information stored in the row of addresses m ═ x% N (the value range of m is 0 to (N-1), x represents the abscissa of the scanned pixel, and the "%" symbol represents the remainder calculation position) in Q1-Q6, and if G (x, y) ═ Cm6, then Lm6=(Lm6+1), the other variables remain unchanged; if G (x, y) ≠ Cm6, then C is addedm2、C m3、Cm4、Cm5、CmValues of 6 are respectively assigned to C m1、C m2、C m3、Cm4、Cm5,Cm6 negation, S m2、S m3、Sm4、Sm5、SmValues of 6 are respectively assigned to S m1、S m2、S m3、Sm4、Sm5,Sm6=y,L m2、L m3、Lm4、Lm5、LmValues of 6 are respectively assigned to L m1、L m2、L m3、Lm4、Lm5,Lm6-1, i.e. C m1=C m2,C m2=C m3,C m3=Cm4,Cm4=Cm5,Cm5=Cm6,Cm6=~Cm6,S m1=S m2,S m2=S m3,S m3=Sm4,Sm4=Sm5,Sm5=Sm6,Sm6=y,L m1=L m2,L m2=L m3,L m3=Lm4,Lm4=Lm5,Lm5=Lm6,LmAnd 6, judging whether the five assigned sub-line segments meet the position detection pattern characteristics or not at the same time: judgment Cm1-CmWhether the value of 5 is 0,1, 0,1 and 0 respectively, namely black, white, black and black are alternated, if not, the result shows that the long line section formed by the five sub-line sections does not meet the position detection graphic characteristics, neglects and continues to scan; if yes, judging Lm1:Lm2:Lm3:Lm4:LmWhether or not 5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if the proportional relation is satisfied, the long line section composed of the five sub-line sections satisfies the position detection pattern characteristics, and if not, the scanning is continued by neglecting. If a suspected point meeting the position detection image characteristic is scanned in a certain column, namely the long line section meets the position detection graphic characteristic, the abscissa x and the central ordinate corresponding to the midpoint of the long line section consisting of five sub-line sections are determined
Figure BDA0002838634130000071
And line scan length (S)m6-Sm1) At the address (x% N) stored in MEM3, the "%" symbol indicates remainder, NUM increments by 1; setting the (x% N) th position of POS to 1, and then updating Cm1-Cm6、Sm1-Sm6、Lm1-Lm6 write back Q1-Q6 at address m ═ (x% N); when (x% N) is (N-1), it representsThe scanning of the y-th row is completed, and the process proceeds to step S8.4, otherwise, x is made (x +1), and the process in step S8.3 is repeated;
s8.4, determining whether the value of NUM is 0, if it is 0, indicating that the number of existing pseudo dots in the y-th row corresponding to the N column is 0, and if y is (L-1) and x is (M-1), indicating that scanning of the entire frame image column is completed, then go to step S8.9; if y is (L-1), indicating that the N-column scan is complete, let y be 0, x be (x +1), and store C at each address in the 6 memories Q1-Q6m、Sm、LmInitializing the variable to be 0, scanning the next N columns, and jumping to the step S8.2; if y ≠ (L-1), which indicates that the current N columns have not been scanned, let y ═ y +1 and x ═ x-N +1, and then jump to step S8.2; if NUM is not equal to 0, the number of the existing suspected points is larger than 0, a position of 1 in the POS is searched, after the position of 1 is found, the value of NUM is reduced by 1, and the step S8.5 is carried out;
s8.5, reading out column scanning suspected point information of a column corresponding to a position with the MEM3 address being POS position 1, assuming that the read abscissa, ordinate and column scanning length are x1, y1 and LY respectively, and entering step S8.6;
s8.6, reading the address (y1-1) of the MEM2 and the index numbers a0 and a1 stored in y1, and if a0 is a1, indicating that the y1 row does not detect a plausible point during row scanning, jumping to step S8.4; if a0< a1 indicates that the y1 row detected a suspected point during the row scan, go to step S8.7;
s8.7, reading the row suspected point information stored at the MEM1 address with the index number A0, assuming that the abscissa of the row suspected point information is x2 and the row scanning length is LX, and entering the step S8.8;
s8.8, if x2 is larger than x1, the suspected point horizontal coordinates are not matched, the center of the non-position detection graph is not located, and the step S8.4 is skipped; if x2 is x1 and the suspected point coordinates are consistent, the suspected point coordinates are the center of the position detection pattern, the abscissa x1, the ordinate y1, the row scanning length LX and the column scanning length LY are recorded, and the step S8.4 is skipped; if x2< x1, increment index a0 by 1, if a0< a1, go to step S8.7, if a0 is a1, go to step S8.4;
s8.9, completing the row-column scanning, checking whether the number of the recorded position detection pattern centers is 3, if so, executing the algorithm correctly, and entering the step S9; otherwise, the acquired image does not contain the target QR code or the QR code is incomplete, and the step S6 is skipped to cache a frame of new image for rescanning;
and S9, outputting the center coordinates and the scanning length of the 3 position detection patterns after the algorithm is executed, wherein the center coordinates and the scanning length comprise the abscissa, the ordinate, the line scanning length and the column scanning length.
Compared with the prior art, the invention has the beneficial effects that:
1. the QR code position detection graph positioning method based on the FPGA occupies smaller storage space. When the traditional algorithm positions the position detection graph, the storage of the target point information in the scanning process at least occupies 2 × M × L bit space; the invention adopts a novel compression storage method, can obtain all information of 3 position detection graphs by only scanning twice, including abscissa, ordinate, line scanning length and column scanning length, and improves algorithm execution efficiency while greatly reducing storage space occupation. For example, when M ═ L ═ 512, T ═ 1024, and N ═ 32, the space occupied by the conventional algorithm is 512Kbit, and the space occupied by the present invention is 23.8Kbit, which is only 4.6% of the conventional algorithm. When M is 1024, T is 2048, and N is 32, the occupied space of the conventional algorithm is 2048Kbit, and the occupied space of the present invention is 51.9Kbit, which is only 2.5% of the conventional algorithm.
2. The QR code position detection graph positioning method based on the FPGA has higher efficiency. For a QR code image with an image size of M × L, the conventional algorithm requires approximately 5 × M × L clock cycles, and the maximum number of clock cycles required by the present invention is approximately 4.1 × M × L, which is 82% of that of the conventional algorithm.
3. The QR code position detection graph positioning method based on the FPGA provided by the invention has the advantages that the FPGA is utilized to drive the camera to acquire a QR code image, after the graying, median filtering and binarization processes are finished, the number of clock cycles delayed relative to the original image acquired by the camera is limited, the method can be approximately regarded as real-time processing of the QR code image acquired by the camera, and the method can be applied to occasions with high real-time requirements.
4. According to the QR code position detection graph positioning method based on the FPGA, due to the adoption of the parametric design, when the size of an input image is changed or internal parameters need to be adjusted, excessive modification on codes is not needed. And as the size of the image increases, the space occupation of the traditional algorithm is increased by multiple times, and the method has extremely small growth amplitude.
Drawings
Fig. 1 is a schematic diagram of a QR code;
FIG. 2 is a schematic diagram of a rectangular coordinate system established for a QR code image matrix;
FIG. 3 is a schematic diagram of mapping and storing a QR code binary image bit stream;
FIG. 4 is a schematic diagram showing the ratio of the occupation space of the method of the present invention to the occupation space of the conventional method as a function of the image size;
FIG. 5 is a schematic diagram of the size of the occupied space varying with the size of the image according to the method of the present invention;
FIG. 6 is a diagram illustrating the size of the occupied space varying with the size of the image according to the conventional method;
FIG. 7 is a schematic diagram of position detection pattern scanning positioning;
FIG. 8 is a flow chart of a conventional method;
FIG. 9 is a flow chart of the method of the present invention;
FIG. 10 is a schematic view of a horizontal line scan sequence of the method of the present invention;
FIG. 11 is a schematic view of a vertical column scanning sequence of the method of the present invention.
Detailed Description
Examples
A QR code position detection graph positioning method based on FPGA is characterized by comprising the following steps:
s1, acquiring a QR code image in real time by using a camera, as shown in fig. 1, the format is RGB565, the size of the image is M × L, M represents the number of columns of an image matrix, L represents the number of rows of the image matrix, and each pixel P is represented by 16 bits;
s2, as shown in fig. 2, a rectangular coordinate system is established for the image matrix: taking the pixel point at the upper left corner of the image matrix as an origin, taking the horizontal rightward direction as an x axis, and taking the horizontal downward direction as a y axis, wherein x is more than or equal to 0 and less than or equal to M-1, and y is more than or equal to 0 and less than or equal to L-1, so that each pixel point P can be determined by (x, y) coordinates;
s3, carrying out graying processing on the acquired QR code image, and compressing the bit width of the pixel point P from 16 bits to 8 bits;
s4, carrying out median filtering processing on the image subjected to the graying processing in the step S3 to eliminate noise in the image;
s5, carrying out binarization on the QR code image after median filtering by using a Kittler threshold method, and adopting a method of 'error frame binarization' in order to improve the real-time property of the system and reduce the occupation of image cache resources:
assuming that the gray value of a pixel point after median filtering is f (x, y), wherein f (x, y) belongs to [0, 255], the optimal threshold value of the ith frame image is Pt (i) (0 is more than or equal to Pt (i) is less than or equal to 255), the value of the pixel point after binarization is G (x, y), and G (x, y) belongs to {0,1 }; after a system is electrified and works, counting the number of image frames i acquired by a camera in real time from 0, wherein an optimal threshold value Pt (0) is 0 at the beginning; and carrying out binarization on any ith frame image by adopting the following method:
s5.1, when i is equal to 0, Pt (0) is equal to 0, and the input 0 th frame image is binarized: if the gray value f (x, y) is less than or equal to Pt (0), G (x, y) is 0, and if f (x, y) > Pt (0), G (x, y) is 1; meanwhile, the optimal threshold value Pt (0) 'of the 0 th frame image is calculated in real time by using a Kittler threshold value method, when the input of the 0 th frame image is finished, the optimal threshold value calculation of the frame image is finished, Pt (1) is made to be Pt (0)', and then S5.2 is carried out;
s5.2, when i is equal to 1, Pt (1) ═ Pt (0)', binarizes the input 1 st frame image: if f (x, y) ≦ Pt (1), then G (x, y) equals 0, if f (x, y) > Pt (1), then G (x, y) equals 1; meanwhile, the optimal threshold value Pt (1) 'of the 1 st frame image is calculated in real time by using a Kittler threshold value method, when the 1 st frame image is input, the optimal threshold value calculation of the frame image is completed, Pt (2) is made to be Pt (1)', and then S5.3 is carried out;
s5.3, when i is k +1, Pt (k +1) is Pt (k)', binarizes the input (k +1) th frame image: if f (x, y) ≦ Pt (k +1), then G (x, y) equals 0, if f (x, y) > Pt (k +1), then G (x, y) equals 1; meanwhile, the optimal threshold value Pt (k +1) 'of the (k +1) th frame image is calculated in real time by using a Kittler threshold method, when the (k +1) th frame image is input, the optimal threshold value calculation of the frame image is completed, Pt (k +2) ═ Pt (k + 1)', and then S5.4 is carried out;
and S5.4, continuously circulating according to the rule, wherein the core idea is that the optimal threshold value obtained by calculating the image of the previous frame is used for carrying out binarization on the image of the current frame, and the optimal threshold value obtained by calculating the image of the current frame is used for carrying out binarization on the image of the next frame. Because the images collected by the camera cannot be suddenly changed between adjacent frames, the larger the frame rate is, the smaller the error is, the more a frame of complete images is not required to be cached, and after the optimal threshold value is calculated, the binaryzation operation is carried out;
s6, receiving a serial image bit stream after any frame binarization, and storing the serial image bit stream into an image cache RAM by taking an N-bit pixel block as a unit after serial-parallel conversion; wherein, N is selected according to the image size and the memory bit width, and is usually an even power of 2, and in the embodiment, N is 4;
assume that the value of each pixel after binarization of the collected image of one frame 8 × 8(M ═ L ═ 8) is as shown in the following table, where black pixels are represented by 0 and white pixels are represented by 1;
Figure BDA0002838634130000101
storing the binary image into an image cache RAM with the depth of 16 and the bit width of 4 by taking a pixel block with 4 bits as a unit, wherein the information stored in the image cache RAM at the moment is shown as the following table:
0 0 0 0
0 0 0 1
0 1 1 1
1 1 0 1
0 1 0 0
0 1 0 1
0 1 0 0
0 1 0 1
0 1 0 0
0 1 0 1
0 1 1 1
1 1 0 1
0 0 0 0
0 0 0 1
1 1 1 1
1 1 1 1
s7, scanning the whole frame image received in the step S6 line by line and pixel point by pixel point to obtain suspected point information meeting the characteristics of the position detection graph;
assuming that C1-C6 correspond to colors representing 6 sub-line segments, S1-S6 correspond to x coordinates representing starting points of 6 sub-line segments, and L1-L6 correspond to lengths representing 6 sub-line segments, respectively; a large number of experiments find that the number of suspected points meeting the color distribution and proportion relation is limited in line scanning in a specific scene, wherein the upper limit value of the number of the suspected points is taken as T-4; the MEM1 (line plausible point information RAM) is for storing line plausible point information, and has a depth of 4 and a bit width of 4
Figure BDA0002838634130000111
A represents the index number of the suspected point of the line, the initial value is 0, and the index number is increased by 1 when one suspected point is scanned; MEM2 (line suspected point index RAM) stores the latest index after each line scan is completed, with a depth L of 8 and a bit width of 8
Figure BDA0002838634130000112
Figure BDA0002838634130000113
Represents rounding down; MEM1 and MEM2 default to each data bit to blank since no data has been stored as follows;
MEM1
Figure BDA0002838634130000114
Figure BDA0002838634130000121
MEM2
s7.1, before starting scanning, x ═ y ═ 0, a is set to 0, C1-C6 are all set to 0(0 indicates black, 1 indicates white), S1-S6 are all set to 0, and L1-L6 are all set to 0;
and S7.2, sequentially reading the pixel points of the 0 th line from the image cache RAM, and starting scanning from left to right, wherein the scanning range is from x being equal to 0 to x being equal to (M-2) being equal to 6. Firstly, reading a1 st 4-bit pixel block 4' b0000 at an image cache RAM address of 0, wherein x is 0, G (0,0) is C6 is 0, and L6 is (L6+1) is 1; when x is 1, (x +1) and G (1,0) is C6 is 0, then L6 is 2 (L6+ 1); when x is 2, (2,0) C6 is 0, then L6 is 3 (L6+ 1); when x is 3, (3,0) is C6 is 0, then L6 is 4 (L6+ 1); then, the 2 nd 4-bit pixel block 4' b0001 at the address of the image cache RAM is read for scanning, where x is (x +1) ═ 4, G (4,0) ═ C6 is 0, and then L6 is (L6+1) ═ 5; when x is 5, (5,0) is C6 is 0, then L6 is 6 (L6+ 1); when x is 6, (6,0) is C6 is 0, then L6 is 7 (L6+ 1);
s7.3, the last 1 pixel in the 0 th row is read and scanned, x ═ x +1 ═ 7, G (7,0) ≠ C6, C1 ═ C2 ═ 0, C2 ═ 0, S2 ═ S2, S2 ═ 0, S2 ═ M-1 ═ 7, L2 ═ 2, L ═ 2 ═ L2 ═ 2, L2 ═ 2, L ═ 2, L ═ 2 ═. Then judging whether the 5 assigned sub-line segments meet the position detection graphic characteristics or not, wherein C1-C5 are all 0 and do not meet the position detection graphic characteristics, and ignoring;
s7.4, storing the index number a of 0 in the MEM2 at the position where the address y is 0, then making y (y +1) 1, setting all of C1-C6 to 0(0 indicates black, 1 indicates white), setting all of S1-S6 to 0, setting all of L1-L6 to 0, and then starting to scan the 1 st row; the binary value of a ═ 0 is 2' b00, and the binary value is stored at address 0 of MEM as follows:
0 0
MEM2
and S7.5, sequentially reading the pixels in the 1 st line from the image cache RAM, and starting scanning from left to right, wherein the scanning range is from x being equal to 0 to x being equal to (M-2) being equal to 6. Firstly, reading a1 st 4-bit pixel block 4' b0111 at the address of the image cache RAM 2, wherein x is 0, G (0,1) is C6 is 0, and then L6 is (L6+1) is 1; x ═ 1 ≠ C, C ═ 0, C ═ 0, S ═ 0, S ═ x ═ 1, L ═ 0, L ═ 1, and L ═ 5, and the position of the segment is determined to be unsatisfied, and the feature is ignored; when x is 2, (2,1) C6 is 1, then L6 is 2 (L6+ 1); when x is 3, (3,1) is C6 is 1, then L6 is 3 (L6+ 1); then, the 2 nd 4-bit pixel block 4' b1101 at the image cache RAM address of 3 is read for scanning, where x is (x +1) to 4, G (4,1) is C6 to 1, and then L6 is (L6+1) to 4; when x is 5, (5,1) C6 is 1, then L6 is 5 (L6+ 1); x ═ x +1 ═ 6, G (6,1) ≠ C, C ═ 0, C ═ 1, C ═ 0, S ═ 1, S ═ x 6, L ═ 0, L ═ 1, L ═ 5, L ═ 1, and the position of the segment is determined to be satisfied, and the segment position is assigned to 5, and the feature is ignored;
s7.6, the last 1 pixel point in the 1 st row is read and scanned, x ═ x +1 ═ 7, G (7,1 ≠ C6, then C1 ═ C2 ═ 0, C2 ═ 1, C2 ═ 0, S2 ═ 0, S2 ═ 6, S2 ═ M-1 ═ 7, L2 ═ 2, L ═ 2 ═ L ═ 2, L ═ 2, L. Then judging whether the 5 assigned sub-line segments meet the position detection graphic characteristics, wherein C1-C5 are 0,1 and 0, and do not meet the position detection graphic characteristics and ignore;
s7.7, storing the index number a of 0 in the MEM2 at the address y of 1, then making y (y +1) 2, setting all C1-C6 to 0(0 indicates black, 1 indicates white), setting all S1-S6 to 0, setting all L1-L6 to 0, and then starting to scan the 2 nd row; the binary value of a ═ 0 is 2' b00, and the binary value is stored at address 1 of MEM as follows:
0 0
0 0
MEM2
and S7.8, sequentially reading the pixel points in the 2 nd row from the image cache RAM, and starting scanning from left to right, wherein the scanning range is from x being equal to 0 to x being equal to (M-2) being equal to 6. Firstly, reading a1 st 4-bit pixel block 4' b0100 at the address of the image cache RAM of 4 to scan, wherein x is 0, G (0,2) is C6 is 0, and then L6 is (L6+1) is 1; when x is equal to (x +1) 1, G (1,2) is equal to 1, C is equal to 0, C is equal to C — 1, S is equal to 0, S is equal to x1, L is equal to 0, L is equal to 1, and the position of the segment is determined to be not satisfied; x ═ x +1 ═ 2, G (2,2) ≠ C, C ═ 0, C ═ 1, C ═ 0, S ═ 1, S ═ x ═ 2, L ═ 0, L ═ 1, L ═ 5, and the assigned value is determined to satisfy the graph position, and the graph is ignored; when x is 3, (3,2) C6 is 0, then L6 is 2 (L6+ 1); then, the 2 nd 4-bit pixel block 4' b0101 at the image cache RAM address 5 is read for scanning, where x is (x +1) ═ 4, G (4,2) ═ C6 is 0, and then L6 is (L6+1) ═ 3; x ═ x +1 ═ 5, G (5,2) ≠ C, C ═ 0, C ═ 1, S ═ 0, S ═ 1, S ═ 2, S ═ x 5, L ═ 0, L ═ 1, L ═ 3, L ═ 1, and the assigned value of the position of the segment is determined to be satisfied, and the segment position is ignored; x ═ x +1 ═ 6, G (6,2) ≠ C, C ═ 0, C ═ 0, S ═ 1, S ═ 2, S ═ 5, S ═ x ═ 6, L ═ 0, L ═ 1, L ═ 3, L ═ 1, and L ═ 5, and the position of the segment is determined to be unsatisfied, and the feature is ignored;
s7.9, read the last 1 pixel in the 2 nd row and scan, where x is (x +1) 7, G (7,2) is 1 ≠ C, C is 0, C is 1, S is 2, S is 5, S is 6, S is (M-1) 7, L is 1, L is 3, L is 1. Then judging whether the 5 assigned sub-line segments meet the position detection graphic characteristics or not, wherein the C1-C5 values are 0,1, 0,1 and 0 respectively and represent black-white-black alternation, the length ratio of the 5 sub-line segments L1: L2: L3: L4: L5 is 1:1:3:1:1, and the center horizontal coordinate of the current long line segment completely meets the position detection graphic characteristics
Figure BDA0002838634130000141
And the line scan length (S6-S1) is 7, stored in MEM1 at address a0, and then the index a is changed from 1 to 1; the center coordinate abscissa 3 has a binary value of 3 'b 011, and the row scan length 7 has a binary value of 3' b111, and they are combined and stored in the MEM1 at address 0 as follows:
0 1 1 1 1 1
MEM1
s7.10, storing the latest index number a of 1 in MEM2 at address y of 2, then making y (y +1) 3, setting C1-C6 to 0(0 indicates black, 1 indicates white), S1-S6 to 0, and L1-L6 to 0, and then starting to scan line 3; the binary value of a ═ 1 is 2' b01, and the binary value is stored at address 1 of MEM as follows:
0 0
0 0
0 1
MEM2
s7.11, after completing the scanning of the remaining 5 lines of the QR code image, 3 total pseudo dots (3,2), (3,3), and (3,4) are obtained, the line scan lengths are all 7, and the MEM1 and MEM2 are stored as follows:
0 1 1 1 1 1
0 1 1 1 1 1
0 1 1 1 1 1
MEM1
0 0
0 0
0 1
1 0
1 1
1 1
1 1
1 1
MEM2
s8, after completing the line scanning, performing the line scanning on the whole frame image received in step S6, and scanning N-4 columns simultaneously in a manner of scanning from left to right column by column; after the target point is scanned, the MEM1 and the MEM2 are read, and compared to determine whether the coordinates of the suspected points are consistent, the coordinate of the center of the position detection pattern is determined if the coordinates are consistent. The image is stored in the image cache RAM by taking the N-bit pixel block as a unit, and the scanning mode can reduce the access to the memory.
Hypothesis Cm1-Cm6 respectively corresponding to colors, S, representing 6 sub-line segments in a scanning process of a certain columnm1-Sm6 respectively correspond to the y-coordinate, L, representing the starting points of the 6 sub-line segmentsm1-Lm6 correspondingly represent the lengths of 6 subsegments in the column scanning, wherein m is x% N, the value range of m is 0 to (N-1), x represents the abscissa of the scanned pixel point, and the "%" symbol represents the remainder operation; these information are stored using 6 memories Q each having a bit width of
Figure BDA0002838634130000161
The depth is N-4, corresponding to the number of columns N scanned simultaneously, 6 memories are respectively corresponding to C storing 1 sub-line segmentm、Sm、LmInformation, e.g. storage Q1 storing Cm1、Sm1、Lm1, memory Q2 stores Cm2、Sm2、Lm2, …, memory Q6 stores Cm6、Sm6、Lm6, the same address of the 6 memories stores the intermediate information in the scanning process of a certain column, and the N addresses completely store the scanning information of the N columns, for example, the address 0 of Q1-Q6 completely stores the scanning information of the x-th column, where x% N is 0. The MEM3 is used to store the suspected point information of N columns in a certain line scanning process, and has a depth of N-4 and a bit width of 4
Figure BDA0002838634130000162
NUM records the number of suspected points scanned by N columns in the scanning process of a certain line, and POS records with the bit width of N-4 correspond to the scanned suspected points;
Figure BDA0002838634130000163
to representRounding down;
for convenience of illustration, the memories Q and MEM3 herein combine a plurality of bits corresponding to 1 address, and are shown in a slightly different manner from the above row scan for each bit, because the data bit width is larger during the column scan, and the process is more complicated;
s8.1, scanning 0 to 3 columns of the image simultaneously, before starting the scanning, setting x to y to 0 and NUM to 0, setting POS to 0, and initializing variables in 6 memories Q1-Q6 by a method in line scanning, that is, Cm1-CmAll of 6 are set to 0(0 means black, 1 means white), Sm1-Sm6 are all set to 0, Lm1-Lm6 are all set to 0, and the schematic after initialization is as follows; the significance of the data stored at each address in Q is, color Cm(1 st) + starting ordinate S of the sub-line segmentm(3-position) + length L of the sub-line segmentm(3 bits) are spliced together in binary form and stored in an address, and the address stored in Q1 is C m1+S m1+L m1;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000
Memory Q
Figure BDA0002838634130000164
Figure BDA0002838634130000171
MEM3
0 0 0 0
POS
S8.2, read the pixel block representing (0,0) - (3,0) from the image cache RAM for scanning, which is stored at address 0 in the image cache RAM, at 4' b 0000. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,0) is 0, and values stored at addresses 0 of Q1 to Q6 are respectively changed to 7 'b 0_000_000 (here, the underlined is to divide binary values representing a color (1 bit), a starting ordinate (3 bits) of a sub-line segment, and a sub-line segment length (3 bits) for improving readability, and to improve data readability), 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_001, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,0) is 0, and the values stored at addresses 1 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000, and 7' b0_000_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,0) ═ 0, values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000, and 7' b0_000_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,0) ═ 0, values stored at addresses 3 from Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000, and 7' b0_000_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 0 th line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scan of the 0-3 column on the 0 th row is completed, the process jumps to step S8.3;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001
memory Q
MEM3
0 0 0 0
POS
S8.3, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) equals 1, and x equals (x-N +1) equals 0, and scanning continues on the 1 st row in the current 0-3 columns;
s8.4, the pixel blocks representing (0,1) - (3,1) are read from the image cache RAM for scanning, which is stored in the image cache RAM at address 2, 4' b 0111. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,1) is 0, and values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_010, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,1) ═ 1, and values stored at addresses 1 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, and 7' b1_001_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,1) ═ 1, and values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, and 7' b1_001_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,1) ═ 0, values stored at addresses 3 from Q1 to Q6 are respectively changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, and 7' b1_001_001, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scanning of the 0-3 column on the 1 st row is completed, the process jumps to step S8.5;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000010
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001
memory Q
MEM3
0 0 0 0
POS
S8.5, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) to 2, and x equals (x-N +1) to 0, and continues to scan the 2 nd row in the current 0-3 columns;
s8.6, read the pixel blocks representing (0,2) - (3,2) from the image cache RAM for scanning, which is stored at address 4 in the image cache RAM as 4' b 0100. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,2) is 0, and values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_011, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,2) is 1, the values stored at addresses 1 of Q1 to Q6 are respectively changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_010, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,2) ═ 0, and values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,2) ═ 0, values stored at addresses 3 from Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scan of the 0-3 column on the 2 nd row is completed, the process jumps to step S8.7;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000011
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001010
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010001
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010001
memory Q
MEM3
0 0 0 0
POS
S8.7, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) to 3, and x equals (x-N +1) to 0, and continues to scan the 3 rd row in the current 0-3 columns;
s8.8, read the pixel blocks representing (0,3) - (3,3) from the image cache RAM for scanning, which is stored at address 6 in the image cache RAM as 4' b 0100. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,3) is 0, the values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_100, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,3) ═ 1, values stored at addresses 1 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_011, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,3) ═ 0, and values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_010, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,3) ═ 0, values stored at addresses 3 from Q1 to Q6 are respectively changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_010, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scanning of the 0-3 column on the 3 rd row is completed, the process jumps to step S8.9;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000100
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001011
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010010
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010010
memory Q
MEM3
0 0 0 0
POS
S8.9, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) to 4, and x equals (x-N +1) to 0, and continues to scan the 4 th row in the current 0-3 columns;
s8.10, read the pixel blocks representing (0,4) - (3,4) from the image cache RAM for scanning, which is stored at address 8 in the image cache RAM as 4' b 0100. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,4) is 0, the values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_101, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,4) is 1, the values stored at addresses 1 of Q1 to Q6 are respectively changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, and 7' b1_001_100, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,4) ═ 0, and the values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_011, respectively, and the column is not scanned to a long line segment that satisfies the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,4) ═ 0, values stored at addresses 3 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_011, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scan of the 0-3 column on the 4 th row is completed, the process jumps to step S8.11;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000101
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001100
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010011
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010011
memory Q
MEM3
0 0 0 0
POS
S8.11, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) equals 5, and x equals (x-N +1) equals 0, and scanning continues on the 5 th row of the current 0-3 columns;
s8.12, pixel blocks representing (0,5) - (3,5) are read from the image cache RAM for scanning, which is stored at address 10 in the image cache RAM as 4' b 0111. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,5) is 0, the values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_110, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,5) ═ 1, values stored at addresses 1 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_101, respectively, and the column is not scanned to long segments satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,5) ═ 1, and values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_001, 7 'b 0_010_011, and 7' b1_101_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,5) ═ 1, and values stored at addresses 3 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_001, 7 'b 0_010_011, and 7' b1_101_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scan of the 0-3 column on the 5 th row is completed, the process jumps to step S8.13;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000110
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001101
7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010011 7’b1101001
7’b0000000 7’b0000000 7’b0000001 7’b1001001 7’b0010011 7’b1101001
memory Q
MEM3
0 0 0 0
POS
S8.13, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) 6, and x equals (x-N +1) 0, and scanning continues on the 6 th row of the current 0-3 columns;
s8.14, read the pixel blocks representing (0,6) - (3,6) from the image cache RAM for scanning, which is stored at address 12 in the image cache RAM, at 4' b 0000. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,6) is 0, the values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, and 7' b0_000_111, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,6) is 0, and the values stored at addresses 1 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001_101, and 7' b0_110_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 2, the 2 nd column is scanned, G (2,6) ═ 0, and the values stored at addresses 2 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_011, 7 'b 1_101_001, 7' b0_110_001, respectively, and the column is not scanned to a long line segment that satisfies the feature of the position detection pattern; when x is (x +1) ═ 3, the 3 rd column is scanned, G (3,6) ═ 0, and values stored at addresses 3 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_001, 7 'b 1_001, 7' b0_010_011, 7 'b 1_101_001, and 7' b0_110_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; because 0-3 columns have no long line segment meeting the position detection pattern characteristics after the 1 st line is scanned, NUM is not changed, and 4 bits of the POS variable are all 0; when x is 3, N is 4, and x% N is (N-1), which indicates that the scan of the 0-3 column on the 6 th row is completed, the process jumps to step S8.15;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000111
7’b0000000 7’b0000000 7’b0000000 7’b0000001 7’b1001101 7’b0110001
7’b0000000 7’b0000001 7’b1001001 7’b0010011 7’b1101001 7’b0110001
7’b0000000 7’b0000001 7’b1001001 7’b0010011 7’b1101001 7’b0110001
memory Q
MEM3
0 0 0 0
POS
S8.15, where NUM equals 0, indicates that no suspected point is scanned, and y equals (y +1) to 7, and x equals (x-N +1) to 0, and continues to scan the 7 th row in the current 0-3 columns;
s8.16, read the pixel blocks representing (0,7) - (3,7) from the image cache RAM for scanning, which is stored at address 14 in the image cache RAM as 4' b 1111. These 4 columns are scanned column by column. When x is 0, the 0 th column is scanned, G (0,7) is 1, and values stored at addresses 0 of Q1 to Q6 are changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_111, and 7' b1_111_001, respectively, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) ═ 1, the 1 st column is scanned, G (1,7) is 1, the values stored at addresses 1 of Q1 to Q6 are respectively changed to 7 'b 0_000_000, 7' b0_000_000, 7 'b 0_000_001, 7' b1_001_101, 7 'b 0_110_001, 7' b1_111_001, and the column is not scanned to a long line segment satisfying the position detection pattern feature; when x is (x +1) 2, the 2 nd column is scanned, G (2,7) is 1, values stored at addresses 2 of Q1 to Q6 are respectively changed to 7 'b 0_000_001, 7' b1_001, 7 'b 0_010_011, 7' b1_101_001, 7 'b 0_110_001, and 7' b1_111_001, and when the column is scanned to a long line segment satisfying the position detection pattern feature, NUM is (NUM +1) 1, and the abscissa x corresponding to the scanned long line segment is 2 and the ordinate is 2
Figure BDA0002838634130000241
Column scan length (S)26-S21) The address (x% N) ═ 2% (% 4) ═ 2 stored in the MEM3, the binary systems of decimal 2, decimal 3 and decimal 7 are respectively 3 'b 010, 3' b011 and 3 'b 111, the binary systems are merged to be 9' b010011111, and the position of POS vector (2% 4) ═ 2 is 1; when x is (x +1) 3, the 3 rd column is scanned, G (3,7) is 1, values stored at addresses 3 of Q1 to Q6 are respectively changed to 7 'b 0_000_001, 7' b1_001, 7 'b 0_010_011, 7' b1_101_001, 7 'b 0_110_001, and 7' b1_111_001, when the column is scanned to a long line segment satisfying the position detection pattern feature, NUM is (NUM +1) 2, and the abscissa x corresponding to the scanned long line segment is 3 and the ordinate x corresponding to the point is vertical to the point 3, and NUM +1 is 2
Figure BDA0002838634130000242
Column scan length (S)36-S31) The address (x% N) ═ 3% > (4) ═ 3 stored in the MEM3 at 7, the binary systems of decimal 3, decimal 7 are respectively 3 'b 011, 3' b011 and 3 'b 111, the binary systems are merged to 9' b011011111, and the position of POS vector (3% 4) ═ 3 is set to 1; when x is 3, N is 4, and x% N is (N-1), which indicates that the scanning of the 0-3 column on the 7 th row is completed, the process jumps to step S8.17;
Q1 Q2 Q3 Q4 Q5 Q6
7’b0000000 7’b0000000 7’b0000000 7’b0000000 7’b0000111 7’b1111001
7’b0000000 7’b0000000 7’b0000001 7’b1001101 7’b0110001 7’b1111001
7’b0000001 7’b1001001 7’b0010011 7’b1101001 7’b0110001 7’b1111001
7’b0000001 7’b1001001 7’b0010011 7’b1101001 7’b0110001 7’b1111001
memory Q
9’b010011111
9’b011011111
MEM3
0 0 1 1
POS
S8.17, where NUM is 2, which indicates that the number of existing suspected points in the 7 th row in the 4 columns is 2, finds a bit in POS of 1, finds that the value of the 2 nd bit is 1, and jumps to step S8.18 by self-subtracting 1 from NUM, that is, by changing NUM to (NUM-1) to 1;
s8.18, reading out column scan pseudo-dot information at a column corresponding to a bit where the MEM3 address is POS 1, where the address is 2, and the abscissa, ordinate, and column scan length of the reading are x 1-2, y 1-3, and LY-7, respectively, and the process advances to step S8.19;
s8.19, reading MEM2 with the stored addresses (y1-1) 2 and y 1-3, the stored index numbers a 0-1 and a 1-2, a0< a1, which indicates that y 1-3 rows detected a plausible point during row scanning, and the process advances to step S8.20;
s8.20, reading the row suspected point information stored at the MEM1 address with the index a0, reading the abscissa of x2 being 3 and the row scan length LX being 7, and proceeding to step S8.21;
s8.21, wherein x2 is greater than x1, the abscissa of the suspected point is not matched, the center of the graph is not detected, and the step S8.22 is carried out;
s8.22, where NUM is 1, indicates that the number of existing suspected dots in the 7 th row in the 4 columns is 1, the bit set 1 in the POS is searched for, the value of the 3 rd bit is found to be 1, NUM is subtracted from 1, that is, NUM is (NUM-1) is 0, and the process proceeds to step S8.23;
s8.23, reading out column scan pseudo-dot information at a column corresponding to a bit with the address of POS of MEM3 being 1, where the address is 3, and the abscissa, ordinate, and column scan length of the reading are x1 ═ 3, y1 ═ 3, and LY ═ 7, respectively, and the process advances to step S8.24;
s8.24, reading MEM2 with addresses (y1-1) 2 and y 1-3, storing index numbers a 0-1 and a 1-2, a0< a1, indicating that y 1-3 rows detected a suspected point during row scanning, and proceeding to step S8.25;
s8.25, reading the row suspected point information stored at the MEM1 address with the index a0, reading the abscissa of x2 being 3 and the row scan length LX being 7, and proceeding to step S8.26;
s8.26 and x2 are x1, the coordinates of the suspected points match, the center of the position detection pattern is determined, the abscissa, the ordinate, the row scanning length, and the column scanning length information x1 is 3, y1 is 3, LX is 7, and LY is 7 are recorded, and the process proceeds to step S8.27;
s8.27, where NUM is 0, which indicates that the number of existing plausible dots in the 7 th row in the 4 columns is 0, and y is (L-1) 7, which indicates that the scanning of the 4 columns of the current 0-3 columns is completed, and makes y be 0, x be (x +1) 4, and start scanning the next 4 columns, that is, the 4 th-7 th columns, and then proceed to step S8.28;
s8.28, after the 4 th to 7 th rows are scanned by the method, the central point of the 4 rows of the non-position detection graphs can be found, the whole frame of image is scanned completely, and the step S8.29 is carried out;
s8.29, completing the scanning of the rows and columns, and checking whether the number of the centers of the recorded position detection graphs is 3, wherein for convenience of description, only the scanning of the information image containing 1 position detection graph is completed, and the principle of the complete QR code image is similar, and is not repeated herein. Under the condition of collecting correct QR code images, all information of 3 position detection graphs can be obtained after the system is operated.

Claims (1)

1. A QR code position detection graph positioning method based on FPGA is characterized by comprising the following steps:
s1, acquiring a QR code image in real time by using a camera, wherein the size of the image is M x L, M represents the number of columns of an image matrix, and L represents the number of rows of the image matrix;
s2, establishing a rectangular coordinate system for the image matrix: taking the pixel point at the upper left corner of the image matrix as an origin, taking the horizontal rightward direction as an x axis, and taking the horizontal downward direction as a y axis, wherein x is more than or equal to 0 and less than or equal to M-1, and y is more than or equal to 0 and less than or equal to L-1;
s3, carrying out graying processing on the acquired QR code image, and compressing the bit width of the pixel point to 8 bits;
s4, carrying out median filtering processing on the image subjected to the graying processing in the step S3 to eliminate noise in the image;
s5, carrying out binarization on the QR code image after median filtering by using a Kittler threshold method, and carrying out binarization on the (i +1) th frame image by using an optimal threshold value obtained by calculating the ith frame image;
s6, receiving a serial image bit stream after any frame binarization, and storing the serial image bit stream into an image cache RAM by taking an N-bit pixel block as a unit after serial-parallel conversion;
s7, scanning the whole frame of image line received in the step S6 to obtain suspected point information meeting the characteristics of the position detection graph; the specific process is as follows:
assuming that C1-C6 respectively represent colors of 6 sub-line segments, S1-S6 respectively represent x coordinates of starting points of the 6 sub-line segments, L1-L6 respectively represent lengths of the 6 sub-line segments, and the upper limit value of the number of suspected points is T; MEM1 is used to store row suspect point information, with depth T and bit width T
Figure FDA0002838634120000011
A represents the index number of the suspected point of the line, the initial value is 0, and the index number is increased by 1 when one suspected point is scanned; MEM2 stores the latest index number after each line scan is completed, the depth is L, and the bit width is L
Figure FDA0002838634120000012
Figure FDA0002838634120000013
Represents rounding down;
s7.1, before starting scanning, setting x-y-0, setting a to 0, setting C1-C6 to 0, setting S1-S6 to 0, and setting L1-L6 to 0;
s7.2, where the abscissa x is 0 to (M-2), and if the value G (x, y) of the binarized pixel is C6, then L6 is L6+ 1; if G (x, y) ≠ C6, C2, C3, C4, C5 and C6 are respectively assigned to C1, C2, C3, C4 and C5, C6 is inverted, S2, S3, S4, S5 and S6 are respectively assigned to S1, S2, S3, S4 and S5, S6 is x, L2, L3, L4, L5 and L6 are respectively assigned to L1, L2, L3, L4 and L5, and L6 is 1, and whether the assigned five sub-line segments satisfy the position detection pattern feature is determined at the same time: judging whether the values of C1-C5 are 0,1, 0,1 and 0 respectively, if not, ignoring, and continuing to scan; if so, determine L1: l2: l3: l4: whether L5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if satisfied, the central abscissa of the long line segment composed of five sub-line segments of C1-C5
Figure FDA0002838634120000014
And the line scanning length S6-S1 are stored in the address A of the MEM1, then the index number A is increased by 1 by self, if not, the index number A is ignored, and the scanning is continued;
s7.3, if the value G (M-1, y) of the last 1 pixel point is equal to C6, assigning C2, C3, C4, C5, C6 to C1, C2, C3, C4, C5, S2, S3, S4, S5, S6 to S1, S2, S3, S4, S5, S6 is equal to M, assigning L2, L3, L4, L5, L6+1 to L1, L2, L3, L4, L5, respectively; if G (M-1, y) ≠ C6, then C2, C3, C4, C5, C6 are assigned to C1, C2, C3, C4, C5, S2, S3, S4, S5, S6 are assigned to S1, S2, S3, S4, S5, S6 ═ M-1, L2, L3, L4, L5, L6 are assigned to L1, L2, L3, L4, L5, respectively; then judging whether the five assigned sub-line segments meet the position detection pattern characteristics: judging whether the values of C1-C5 are 0,1, 0,1 and 0 respectively, if notIf yes, ignoring and continuing to scan; if so, determine L1: l2: l3: l4: whether L5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if satisfied, the central abscissa of the long line segment composed of five sub-line segments of C1-C5
Figure FDA0002838634120000021
And the line scanning length S6-S1 are stored in the address A of the MEM1, then the index number A is increased by 1 by self, if not, the index number A is ignored, and the scanning is continued;
s7.4, storing the obtained latest index a in the MEM2 at address y, and if y is L-1, proceeding to step S8; otherwise, setting y to y +1, setting all of C1-C6 to 0, all of S1-S6 to 0, and all of L1-L6 to 0, and then jumping to step S7.2;
s8, performing column scanning on the image, and judging the center of the position detection graph, wherein the specific process is as follows:
hypothesis Cm1-Cm6 denote the colors of 6 sub-line segments during the column scanning, Sm1-Sm6 y coordinates, L, representing the starting points of the 6 sub-line segments, respectivelym1-Lm6 respectively represents the length of 6 sub-line segments in the column scanning, and m is x% N; the 6 memories Q1-Q6 are respectively corresponding to C for storing 1 sub-line segmentm、Sm、LmInformation, bit width of each memory being
Figure FDA0002838634120000022
The depth is N; MEM3 is used to store suspected point information in a column scan, and has a depth of N and a bit width of N
Figure FDA0002838634120000023
NUM records the number of the scanned suspected points, and POS records the corresponding columns of the scanned suspected points;
s8.1, scanning x to x + N-1 columns of the image simultaneously, and before starting scanning, setting x to y to 0 and NUM to 0, setting POS to 0, Cm1-Cm6 are all set to 0, Sm1-Sm6 are all set to 0, Lm1-Lm6 are all set to 0;
s8.2, reading the scanning information stored in the addresses m of Q1-Q6 as x% N, and if the value G (x, y) of the pixel point after binarization is Cm6, then Lm6=Lm6+ 1; if G (x, y) ≠ Cm6, then C is addedm2、Cm3、Cm4、Cm5、Cm6 are respectively assigned to Cm1、Cm2、Cm3、Cm4、Cm5,Cm6 negation, Sm2、Sm3、Sm4、Sm5、Sm6 are respectively assigned to Sm1、Sm2、Sm3、Sm4、Sm5,Sm6=y,Lm2、Lm3、Lm4、Lm5、Lm6 are respectively assigned to Lm1、Lm2、Lm3、Lm4、Lm5,LmAnd 6, judging whether the five assigned sub-line segments meet the position detection pattern characteristics or not at the same time: judgment Cm1-CmWhether the value of 5 is 0,1, 0,1 and 0 respectively, if not, neglecting, and continuing to scan; if yes, judging Lm1:Lm2:Lm3:Lm4:LmWhether or not 5 satisfies (0.5-1.5): (0.5-1.5): (2-4): (0.5-1.5): (0.5-1.5), if the position detection pattern characteristics are met, the long line section formed by the five sub-line sections meets the position detection pattern characteristics, and if the position detection pattern characteristics are not met, the long line section is ignored and the scanning is continued; the abscissa x and the ordinate corresponding to the midpoints of the long line segments satisfying the position detection graph characteristics
Figure FDA0002838634120000031
And the line scan length Sm6-Sm1 is stored to MEM3 at address x% N, NUM increments by 1; setting the x% N position of POS as 1, then updating Cm1-Cm6、Sm1-Sm6、Lm1-Lm6 writing back the address m of Q1-Q6 to x% N; when x% N is equal to N-1, go to step S8.3, otherwise, let x be equal to x +1, and repeat the process of step S8.2;
s8.3, determining whether the value of NUM is 0, if 0 indicates that the number of suspected dots is 0, and if y is L-1 and x is M-1, jumping to step S8.8; if y is L-1, let y be 0,x +1, C stored in 6 memories Q1-Q6m、Sm、LmInitializing to 0, scanning the next N columns, and jumping to the step S8.2; if y ≠ L-1, let y ═ y +1 and x ═ x-N +1, jump to step S8.2; if NUM is not equal to 0, searching a bit of 1 in the POS, and performing self-subtraction on the value of NUM by 1 to enter a step S8.4;
s8.4, reading column scanning suspected point information corresponding to a position with the address of the MEM3 as POS position 1, assuming that the horizontal coordinate, the vertical coordinate and the column scanning length are x1, y1 and LY respectively, and entering the step S8.5;
s8.5, reading the indexes A0 and A1 stored in the addresses y1-1 and y1 of the MEM2, and jumping to the step S8.3 if A0 is A1; if A0< A1, go to step S8.6;
s8.6, reading the row suspected point information stored at the MEM1 address with the index number A0, assuming that the abscissa thereof is x2 and the row scanning length is LX, and entering the step S8.7;
s8.7, if x2> x1, jumping to the step S8.3; if x2 is x1, recording the abscissa x1, the ordinate y1, the row scanning length LX and the column scanning length LY, and jumping to step S8.3; if x2< x1, increment index a0 by 1, if a0< a1, go to step S8.6, if a0 is a1, go to step S8.3;
s8.8, checking whether the number of the recorded position detection pattern centers is 3, if so, entering a step S9; otherwise, jumping to step S6 to cache a new image frame for rescanning;
and S9, outputting the center coordinates and the scanning length of the 3 position detection patterns, including the abscissa, the ordinate, the line scanning length and the column scanning length.
CN202011484527.8A 2020-12-16 2020-12-16 QR code position detection graph positioning method based on FPGA Active CN112541370B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011484527.8A CN112541370B (en) 2020-12-16 2020-12-16 QR code position detection graph positioning method based on FPGA

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011484527.8A CN112541370B (en) 2020-12-16 2020-12-16 QR code position detection graph positioning method based on FPGA

Publications (2)

Publication Number Publication Date
CN112541370A true CN112541370A (en) 2021-03-23
CN112541370B CN112541370B (en) 2022-03-15

Family

ID=75018823

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011484527.8A Active CN112541370B (en) 2020-12-16 2020-12-16 QR code position detection graph positioning method based on FPGA

Country Status (1)

Country Link
CN (1) CN112541370B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113705270A (en) * 2021-11-01 2021-11-26 深圳思谋信息科技有限公司 Method, device, equipment and storage medium for identifying two-dimensional code positioning code area
CN113822092A (en) * 2021-11-25 2021-12-21 北京紫光青藤微系统有限公司 Method and apparatus for positioning position detection pattern, electronic device, and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104200187A (en) * 2014-08-25 2014-12-10 北京慧眼智行科技有限公司 Method and system for rapidly eliminating false detection for position detection patterns of QR code
CN104200188A (en) * 2014-08-25 2014-12-10 北京慧眼智行科技有限公司 Method and system for rapidly positioning position detection patterns of QR code
CN104346597A (en) * 2014-10-29 2015-02-11 中山大学 QR (quick response) code detection and correction extraction method and IP (intellectual property) core
CN104951726A (en) * 2015-06-25 2015-09-30 福建联迪商用设备有限公司 Method and device for QR (quick response) two-dimension code position detection
US20170032381A1 (en) * 2015-07-28 2017-02-02 Anand Vaidyanathan System and method for detecting counterfeiting product using encryption and decryption methodologies

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104200187A (en) * 2014-08-25 2014-12-10 北京慧眼智行科技有限公司 Method and system for rapidly eliminating false detection for position detection patterns of QR code
CN104200188A (en) * 2014-08-25 2014-12-10 北京慧眼智行科技有限公司 Method and system for rapidly positioning position detection patterns of QR code
CN104346597A (en) * 2014-10-29 2015-02-11 中山大学 QR (quick response) code detection and correction extraction method and IP (intellectual property) core
CN104951726A (en) * 2015-06-25 2015-09-30 福建联迪商用设备有限公司 Method and device for QR (quick response) two-dimension code position detection
US20170032381A1 (en) * 2015-07-28 2017-02-02 Anand Vaidyanathan System and method for detecting counterfeiting product using encryption and decryption methodologies

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
钟阳等: "一种基于CIS的二维码扫描识别算法", 《信息技术》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113705270A (en) * 2021-11-01 2021-11-26 深圳思谋信息科技有限公司 Method, device, equipment and storage medium for identifying two-dimensional code positioning code area
CN113822092A (en) * 2021-11-25 2021-12-21 北京紫光青藤微系统有限公司 Method and apparatus for positioning position detection pattern, electronic device, and medium
CN113822092B (en) * 2021-11-25 2022-03-15 北京紫光青藤微系统有限公司 Method and apparatus for positioning position detection pattern, electronic device, and medium

Also Published As

Publication number Publication date
CN112541370B (en) 2022-03-15

Similar Documents

Publication Publication Date Title
RU2424561C2 (en) Training convolutional neural network on graphics processing units
CN112541370B (en) QR code position detection graph positioning method based on FPGA
KR950005231B1 (en) Graphic processor
CN110647795A (en) Form recognition method
CN106558033A (en) Binary Images Processing method based on morphological dilations erosion algorithm
CN111626145B (en) Simple and effective incomplete form identification and page-crossing splicing method
US5687252A (en) Image processing apparatus
CN112215859B (en) Texture boundary detection method based on deep learning and adjacency constraint
CN116704516B (en) Visual inspection method for water-soluble fertilizer package
CN112883795A (en) Rapid and automatic table extraction method based on deep neural network
CN116958827A (en) Deep learning-based abandoned land area extraction method
CN115909378A (en) Document text detection model training method and document text detection method
JPH0130180B2 (en)
CN112837329B (en) Tibetan ancient book document image binarization method and system
CN115861349A (en) Color image edge extraction method based on reduction concept structural elements and matrix sequence
CN113486894A (en) Semantic segmentation method for satellite image feature component
CN114549649A (en) Feature matching-based rapid identification method for scanned map point symbols
CN110263597B (en) Quick and accurate QR (quick response) code correction method and system
CN114299516A (en) Processing method of table or text line, bill processing method, bill processing device and storage medium
CN112419208A (en) Construction drawing review-based vector drawing compiling method and system
CN114692661A (en) Two-dimensional code recognition method, storage medium and computer
US4435836A (en) Technique for extracting features from images
CN116385289B (en) Progressive inscription character image restoration model and restoration method
JPH03177982A (en) Image processing method
CN112652004B (en) Image processing method, device, equipment and 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