[background technology]
Barcode technology is an emerging technology that integrates coding, printing, identification, data acquisition and processing (DAP) that on computer technology and infotech basis, grows up.Barcode technology is because its identification is quick, accurate, reliable and low cost and other advantages; Be widely used in fields such as commerce, taking care of books, storage, post and telecommunications, traffic and Industry Control, and certainly will in " Internet of Things " that rise gradually used, bring into play great function.
The bar code that is widely used at present comprises bar code and two-dimensional bar code.Bar code claims that again linear bar code is made up of a plurality of " bars " that are arranged in parallel and " sky " unit, and bar code information relies on bar and empty different in width and position to express.Two-dimensional bar code is made up of the chequered with black and white particular geometric figure that on two-dimensional directional, distributes according to certain rules, its can be on two-dimensional directional expressing information.Two-dimensional bar code can be divided into determinant two-dimensional bar code and matrix two-dimensional barcode.The determinant two-dimensional bar code is that the bar code by the multirow cutting back piles up and forms, and representational determinant two-dimensional bar code comprises PDF417, Code 49, Code 16K etc.Determinant two-dimensional barcode information method for expressing and bar code are similar, also are to rely on bar and empty different in width and position to express.Matrix two-dimensional barcode is made up of black, the white module that is distributed in by pre-defined rule in the matrix, and representational matrix two-dimensional barcode comprises QR sign indicating number, Data Matrix sign indicating number, Maxi sign indicating number, Aztec sign indicating number, Chinese letter co etc.
In the process that bar code is decoded; Normally utilize scanning device to scan, obtaining reflected light signal, or utilize photographic equipment that bar code is taken for bar code; Obtaining bar code image,, reflected light signal or bar code image obtain bar code information through being discerned to handle.
As shown in Figure 1, be No. the 200510126730.7th, the one Chinese patent application that proposes of Samsung Electronics Co., Ltd, it discloses a kind of method and apparatus that reads bar code.This device comprises: scanning element is used for the sensing bar code and generates sweep signal; Search unit is used to calculate the rate of change of sweep signal, from sweep signal, extracts the oblique line section, and the starting point and the edge of terminal point with the bar of detection bar code of the oblique line section extracted of search; And the bar code reading unit, be used for reading bar code based on the distance between the edge that is detected.This shortcoming that reads the method and apparatus of bar code is; This device must depend on the user and pass through scanning element sensing bar code direction correctly; The device itself that reads bar code can not the identification bar code direction, can not cause use inconvenience and application limit thus according to bar code direction adjustment decoding direction; Bigger in the empty density of the bar of bar code, or can cause under the bigger situation that distorts and can't discern decoding.
Therefore, to the above deficiency that prior art exists, needing badly provides a kind of determinant bar code decoding chip, the feasible empty information of bar that can guarantee correct identification bar code, and raising is decoded into power.
[embodiment]
Relevant characteristic of the present invention and technology contents please refer to following detailed description and accompanying drawing, and accompanying drawing only provides reference and explanation, are not to be used for the present invention is limited.
Below at first determinant bar code decoding chip of the present invention is described in detail, Fig. 2 is a determinant bar code decoding chip synoptic diagram of the present invention.Determinant barcode decoding chip 10 of the present invention connects data-carrier store 11.Data-carrier store 11 is used to store the bar code image information.Bar code image information comprises image pixel coordinate and image pixel gray-scale value etc.These bar code image information are stored in the data-carrier store 11 with the storage mode of a definite sequence.Further; Data-carrier store 11 also comprises address storage space (figure does not show); The address storage space is used for the memory image pixel coordinate, the address bit that image pixel coordinate corresponding address storage space is interior, and the storage mode of image pixel coordinate in the storage space of address is sequential storage.
Determinant barcode decoding chip 10 comprisesstatus control module 100,scan module 110,boundary recognition module 120,directions calculation module 130, bar spacemargin processing module 140, signcharacter extraction module 150, symbolicparameter identification module 160 anddecoding module 170.
Status control module 100 is used for the duty and the treatment scheme ofgated sweep module 110,boundary recognition module 120,directions calculation module 130, bar spacemargin processing module 140, signcharacter extraction module 150, symbolicparameter identification module 160 anddecoding module 170.
Each module below in conjunction with Fig. 2-10 pair determinant bar code decoding chip of the present invention is described in detail one by one.
Fig. 3 is the structural representation of scan module in the determinant bar code decoding chip of the present invention.
Scan module 110 is used to set up scan coordinate system, and produces scanning coordinate, and scanning coordinate is used in thescan data memory 11 and the corresponding bar code image information of address bit corresponding to the address bit in the address storage space of data-carrier store 11.Scan module 110 comprises scanningcoordinate generation unit 111 and coordinate Mapping converter unit 112.Scanningcoordinate generation unit 111 is used to produce the preliminary sweep coordinate.The preliminary sweep coordinate that coordinateMapping converter unit 112 is used for preliminary sweepcoordinate generation unit 111 is produced is through mapping to the address storage space of data-carrier store 11 after the coordinate transform.The coordinate transform function of coordinateMapping converter unit 112 comprises a kind of or its combination in coordinate translation conversion, Rotating Transition of Coordinate or the coordinate axis exchange conversion at least.112 coordinate transforms of coordinate Mapping converter unit can realize bar code image is carried out the scanning of different directions.
In the scanning coordinate reading ofdata storer 11 thatboundary recognition module 120 is produced according toscan module 110 with the corresponding bar code image information of address bit; Bar code image is carried out virtual scan, and bar code image information comprises image pixel coordinate and image pixel gray-scale value.So-called virtual scan is meant through sweep circuit selects pixel coordinate and gray-scale value according to what certain logic was obtained bar code image, for example is that the directions X along continuous straight runs has been swept the 1st row, and the Y direction increases progressively 10 pel spacings, continues the directions X along continuous straight runs and sweeps the 2nd capable.Boundary recognition module 120 is obtained the empty frontier point of the bar that intersects with virtual scan line through calculating the coordinate position that has the pixel of gray scale drop on the virtual scan line.For bar code symbol, bar representes with black or dark color that generally sky is generally represented with white or light color.Further,boundary recognition module 120 can also be discerned barcode types according to the empty frontier point of the bar that obtains.In one embodiment of the invention; The initial symbol of determinant bar codes such as empty frontier point of the bar thatboundary recognition module 120 will be obtained and PDF417, Micro PDF417 or the empty ratio of bar of full stop are mated, whether there to be determinant bar codes such as PDF417, Micro PDF417 in the identification bar code image.
The empty frontier point of bar thatdirection identification module 130 is obtained according toboundary recognition module 120 calculates and obtains the bar code direction.Belowdirection identification module 130 of the present invention is obtained the bar code direction method be described in detail, Fig. 4 is the recognition principle synoptic diagram according to bar code direction recognizing method of the present invention.As shown in Figure 4, bar code image is a heeling condition, and directly along continuous straight runs is discerned decoding as virtual scan line.After need obtaining the bar code direction virtual scanning direction is adjusted.The angle of the first direction of scanning bar code direction is θ 2, and because θ 2 and θ 1 and unified angle supplementary angle each other, so θ 1=θ 2.So only need know the slope tg θ 1 of θ 1, can obtain the slope tg θ 2 of bar code direction.
And can know by Fig. 4,
In the following formula, (x2 is y2) with (x1; Y1) coordinate can be obtained by the frontier point that hand over virtual scan line and bar Kongxiang, and the coordinate figure of the frontier point of handing over according to each bar virtual scan line and bar Kongxiang is through the comparison of X coordinate position; The y coordinate position is relatively judged the parallelogram characteristic of each point, can confirm to be positioned at a parallelogram characteristic (x2 is y2) with (x1; The coordinate of pixel y1), and then calculate the value that obtains tg θ 1, promptly obtain the bar code direction.Above-mentioned parallelogram characteristic also can adopt the parallel lines characteristic to replace, and above-mentioned parallelogram characteristic or parallel lines characteristic are not limited in the empty scope of a bar.
Direction identification module 130 calculate obtain the bar code directions after, bar spacemargin processing module 140 is handled bar code image according to the bar code direction, to obtain in the bar code image the empty border of bar accurately.
Fig. 5 is the structural representation of bar space margin processing module in the determinant bar code decoding chip of the present invention.As shown in Figure 5, bar spacemargin processing module 140 further comprises scanningboundary acquiring unit 141,rectilinear scanning unit 142, sub-pixborder computing unit 143, straightline computing unit 144 and scanning coordinate computing unit 145.Fig. 6 is the principle of work synoptic diagram that bar space margin processing module of the present invention is handled bar code image, and Fig. 7 is the partial enlarged drawing of among Fig. 6 bar code image being handled.Below in conjunction with Fig. 5, Fig. 6 and Fig. 7 the structure function and the treatment scheme of each unit in the bar spacemargin processing module 140 are described.
As shown in Figure 5, scanningboundary acquiring unit 141fillet identification modules 120 and directions calculation module 130.Scanningboundary acquiring unit 141 obtains the bar code border point fromboundary recognition module 120, obtains the bar code direction fromdirections calculation module 130.
Like Fig. 6 and shown in Figure 7, scanningboundary acquiring unit 141 is the center with the bar code border point of both sides, outwards expands with the direction vertical with the bar code direction according to the bar code direction, obtainsborderline region 821 and 826 respectively.Comprised the set of bar code border point and near pixel thereof in theborderline region 821 and 826.In the set input straightline computing unit 144 of scanningboundary acquiring unit 141 with the pixel inborderline region 821 and 826, Hough (Hough) computing is carried out in the set of the pixel in 144 pairs ofborderline regions 821 of straight line computing unit and 826.The ultimate principle of Hough computing is: suppose in rectangular coordinate system, to exist an initial point distance to be ρ, the position angle is the straight line of θ, and then every bit satisfies formula ρ=xcos θ+ysin θ on the straight line.In the bar code border search procedure, for image space coordinate x, the y of each pixel, utilize different θ discrete values to calculate corresponding ρ value through above-mentioned operational formula, through statistics, try to achieve the pairing pixel coordinate of straight line to θ discrete value and ρ value.In embodiments of the present invention, straightline computing unit 144 for example can adopt a plurality of cordic interative computation unit connected in series to realize the Hough in the set of pixel (Hough) is calculated, in the hope of rectilinear coordinates.
Straightline computing unit 144 obtains the pixel coordinate of the pairing boundarystraight line 822 of bar code border in theborderline region 821 through the Hough computing; And the pixel coordinate of theborderline region 826 interior pairing boundarystraight line 827 of bar code border, operation result is back to scanning boundary acquiring unit 141.Boundarystraight line 822 and 827 has reflected the linear feature on the empty border of bar inborderline region 821 and 826.
Scanningboundary acquiring unit 141 is according to the bar code direction, and the translation preset distance is withacquisition scanning boundary 823 and 828 to the bar code zone outside with the pixel coordinate of boundarystraight line 822 and boundarystraight line 827, and preset distance for example is the spacing of 5-10 pixel.What boundarystraight line 822 and 827 reflected is the linear feature on the empty border of bar; But because the influence of bar code printing or bar code imaging; The empty border of bar actual in the bar code image is not to be the straight line of a strictness, and is based on the curve that has minor fluctuations of linear feature or the set of a plurality of straight-line segments.In order to obtain the empty border of bar more accurately; Scanningboundary acquiring unit 141 is through the outside translation of pixel coordinate with boundarystraight line 822 and boundarystraight line 827, being included in the scope ofscanning boundary 823 and 828 based on the curve that has minor fluctuations of linear feature or the set of a plurality of straight-line segments.Afterwards, scanningboundary acquiring unit 141 is with being for further processing inscanning boundary 823 and the 828 inputrectilinear scanning unit 142.
Rectilinear scanning unit 142 is selected point A on aside scanning boundary 823, on thescanning boundary 828 of opposite side, obtains and put corresponding some A ' of A.Put the multiple acquisition methods that comprises of A '.In one embodiment of the invention; Point A ' acquisition methods is for being starting point with an A; According to the some A ' that bar code direction (being the value of tg θ 1) is searched onscanning boundary 828 and some A is located on the same line; Promptly, obtain the coordinate of the intersection point A ' of known straight line and another straight line according to the coordinate of the outer coordinate points A of known straight line, straight line and through the slope value of another straight line of some A.In another embodiment of the invention, some A ' acquisition methods is for calculating onscanning boundary 828 and a shortest coordinate points of A distance, and this coordinate points is an A '.
Rectilinear scanning unit 142 is a sweep starting point with A, and A ' is a sweep stopping point, calculates the coordinate of the pixel on thestraight line 824 between the A-A '.Rectilinear scanning unit 142 is through in the coordinate figure input scancoordinate Calculation unit 145 that will put A and some A ', and the coordinate of thepixel 825 on thestraight line 824 between 145 couples of A-A ' of scanning coordinate computing unit calculates.
The method of the coordinate of scanningcoordinate computing unit 145 calculatingpixel points 825 comprises multiple mode.In one embodiment of the invention, scanningcoordinate computing unit 145 comprises the Breshem arithmetic element, calculates the coordinate of each pixel on thestraight line 824 between 2 of the A-A ' through the Breshem arithmetic element.The Breshem algorithm principle is following: bar code image is made up of pixel, crosses the pixel center of each each row of row in the bar code image and constructs one group of virtual net ruling.Press straight line from the order computation straight line of origin-to-destination and the intersection point of each vertical gridlines, confirm in this row pixel the nearest pixel of intersection point therewith then.The ingenious part of Breshem algorithm is to adopt incremental computations, makes as long as check the symbol of an error term, just can confirm the coordinate of the pixel of asking of these row for each row.Breshem makes and all comes computing with integer in the process of each point coordinate on the straight line asking between 2, thereby promoted computing velocity significantly.
Scanningcoordinate computing unit 145 is back to rectilinearscanning unit 142 with the coordinate of thepixel 825 on thestraight line 824 between 2 of the A-A ' that calculates, in the coordinate input sub-pixborder computing unit 143 ofrectilinear scanning unit 142 with thepixel 825 on thestraight line 824 between 2 of the A-A '.
Sub-pixborder computing unit 143 is according to the coordinate and the gray-scale value of pixel between the A-A ' 825; Carry out the sub-pix border and calculate, be divided into littler unit with the accurate coordinates that obtains the empty border of bar and calculate this accurate coordinates corresponding gray scale drop value withpixel 825 is pairing.
Thus, bar spacemargin processing module 140 has obtained the empty boundary coordinate of accurate bar and this accurate coordinates corresponding gray scale drop value in the bar code image, and with in this empty data boundary incoming symbolcharacter acquisition module 150 and the symbolicparameter identification module 160.
Fig. 8 is the structural representation of the sign character extraction module in the determinant bar code decoding chip of the present invention.As shown in Figure 8, signcharacter extraction module 150 of the present invention comprises empty identifyingunit 151 of bar and bar nullvalue computing unit 152.
Wherein, The empty identifyingunit 151 1 end junction symbolparameter recognition modules 160 and bar spacemargin processing module 140 of bar; Other end connection strap nullvalue computing unit 152; The empty data boundary of bar that its memory stick spacemargin processing module 140 provides is also judged eliminating to interference border wherein, obtains the empty boundary combinations of effective bar.
The empty data boundary of bar that symbolicparameter identification module 160 provides according to bar spacemargin processing module 140; Symbolic parameter to bar code is discerned, and symbolic parameter comprises the empty width of bar, check information of the empty number of boundary of bar, the sign character of line number, columns, row number, row number, the sign character of bar code etc.The method of symbolicparameter identification module 160 distinguished symbol parameters comprises several different methods such as a bunch number calculating, code system judgement.
The symbolic parameter that the empty identifyingunit 151 of bar provides according to symbolicparameter identification module 160 is handled the empty data boundary of bar that bar spacemargin processing module 140 provides, and interference border is wherein got rid of.The concrete course of work of the empty identifyingunit 151 of bar is following: when the empty boundary number of bar of empty identifyingunit 151 storages of bar did not reach the bar sky number of boundary in the symbolic parameter, the empty identifyingunit 151 of bar continued to obtain the empty data boundary of bar that bar spacemargin processing module 140 provides.When the empty boundary number of bar of empty identifyingunit 151 storages of bar reaches the bar sky number of boundary in the symbolic parameter; The empty identifyingunit 151 of bar calculates the empty width value of bar of the empty boundary combinations of bar of having stored; And the empty width value of the bar of the empty boundary combinations of the bar that will store is compared with the empty width of the bar in the symbolic parameter; When the bar sky width in the empty width value in-less-than symbol of the bar parameter of the empty boundary combinations of the bar of having stored; The empty identifyingunit 151 of bar is got rid of the minimum empty border of bar of gray scale drop width of being stored, and continues to obtain the empty border of bar that bar spacemargin processing module 140 provides.When the empty width value of the bar of the empty boundary combinations of the bar of having stored reached the bar sky width in the symbolic parameter, the empty identifyingunit 151 of bar was with array output to the bar nullvalue computing unit 152 on the empty border of the bar of being stored.
Bar nullvalue computing unit 152 obtains the coordinate and the gray scale drop value on each empty border in the combination on the empty border of bar; Through relatively calculating the empty width value of the bar that constitutes by each empty border; And then obtain sign character, in the sign characterinput decoding module 170 that calculates.
Fig. 9 is the structural representation of the decoding module in the determinant bar code decoding chip of the present invention.As shown in Figure 9,decoding module 170 of the present invention comprises codeword acquiring unit 171, code worderror correction unit 172,decoding unit 173 and code table storage unit 174.The sign character thatdecoding module 170 provides signcharacter extraction module 150 converts code word into and carries out error-correcting decoding, to obtain bar code information, then with the decoded information memory block of bar code informationdata memory input 11.
Wherein, the code table of codetable storage unit 174 storage representation sign characters and code word corresponding relation.Codeword acquiring unit 171 obtains initial code word according to the sign character that the code table utilization receives.172 pairs of initial code words of code word error correction unit are carried out the RS correction process, to obtain correct code word.Decodingunit 173 obtains correct sign character according to the correct code word of code table utilization, and deciphers according to the pairing character set of correct sign character and to obtain bar code information.
The code table of codetable storage unit 174 stored symbols characters and code word corresponding relation.Wherein, sign character then makes up corresponding to the different bar null values of bar code.Codetable storage unit 174 is stored in code table among the ROM (Read-Only Memory, read-only memory).
Figure 10 is the structural representation of the another kind of embodiment of the decoding module in the determinant bar code decoding chip of the present invention.Shown in figure 10,decoding module 270 of the present invention compriseserror checking unit 271 and decoding unit 272.Decoding module 270 carries out error checking with the sign character that signcharacter extraction module 150 provides, and obtains bar code information according to the pairing character set of sign character, then with the decoded information memory block of bar code information data memory input.
Determinant bar code decoding chip of the present invention is the identification bar code direction automatically, need not the direction of scanning that the user adjusts scanning element and can realize the identification decoding to bar code image, and the accuracy of identification of bar code border is high, is decoded into the power height.
Determinant bar code decoding chip of the present invention can obtain the accurate coordinates value of bar code border according to bar code direction adjustment decoding direction, has improved the decoding success ratio greatly, is specially adapted to the identification decoding of high density bar code or distortion bar code.
Determinant bar code decoding chip of the present invention adopts the hardware pipeline structure, realizes the identification decoding to bar code image through hardware logic, and owing to the hardware pipeline structure is suitable for bar code image is carried out pipelining and parallel processing, so processing speed is very fast.Owing to adopt the devices at full hardware structure, need not processor and participate in decoding, chip structure structure for processor is more simplified, area is littler, power consumption is lower, cost is lower, it is integrated to be easy to, and realizes portable application easily.Can combine with technology of Internet of things easily, for the application of barcode technology provides more wide development space.
Above with reference to description of drawings various preferred embodiments of the present invention, but only otherwise deviate from essence of the present invention and scope, those skilled in the art can carry out modification and change on the various forms to it, all belongs to protection scope of the present invention.