[summary of the invention]
The decoding device that exists at prior art depends on the user by scanning element sensing bar code direction correctly, can not be according to the deficiency of bar code direction adjustment decoding direction, the bar code identifying device and the recognition methods thereof that the invention provides a kind of bar space margin processing module and disposal route thereof and use this bar space margin processing module, the correct empty information of the bar of identification bar code improves and is decoded into power.
The invention provides a kind of bar code identifying device, comprising: boundary recognition module, read bar code image and carry out virtual scan, with the empty frontier point of the bar that obtains bar code; The direction identification module, the empty frontier point of bar that obtains according to boundary recognition module calculates acquisition bar code direction; Bar space margin processing module is handled bar code image according to the bar code direction, to obtain in the bar code image the empty border of bar accurately; The sign character extraction module, the calculating of empty border obtains sign character accurately according to bar, thereby obtains bar code information.
The present invention also provides a kind of bar space margin processing module, comprising: the scanning boundary acquiring unit, obtain empty frontier point of bar and bar code direction, and calculate scanning boundary; Sweep starting point and the sweep stopping point corresponding with sweep starting point are chosen according to scanning boundary in the rectilinear scanning unit, calculate the coordinate of the pixel on the straight line between sweep starting point and the sweep stopping point; Sub-pix border computing unit according to the coordinate and the gray values of pixel points of pixel, calculates the coordinate on the empty border of bar.
The present invention also provides a kind of bar code recognition, may further comprise the steps: a. reads bar code image and carries out virtual scan, with the empty frontier point of the bar that obtains bar code; B. the empty frontier point of bar that obtains according to boundary recognition module calculates and obtains the bar code direction; C. according to the bar code direction bar code image is handled, to obtain in the bar code image the empty border of bar accurately; D. calculate according to the empty border of bar and obtain sign character accurately, thereby obtain bar code information.
The present invention provides a kind of bar code border disposal route in addition, may further comprise the steps: a. obtains empty frontier point of bar and bar code direction, calculates scanning boundary; B. choose sweep starting point and the sweep stopping point corresponding according to scanning boundary, calculate the coordinate of the pixel on the straight line between sweep starting point and the sweep stopping point with sweep starting point; C. according to the coordinate and the gray values of pixel points of pixel, calculate the coordinate on the empty border of bar.
The present invention provides a kind of bar code border disposal route again, may further comprise the steps: a. obtains bar code border, bar code direction and sign indicating number speech width; B. according to bar code border, bar code direction and sign indicating number speech width, obtain two row separatrix at a distance of at least one yard speech width; C. be the center with two row separatrix, outwards expand, obtain row zone, separatrix respectively according to the bar code direction; D. in borderline region, carry out straight line and calculate, to obtain row separatrix straight line; E. according to row separatrix straight line along the outside translation of bar code direction to obtain scanning boundary; F. on the scanning boundary of a side, choose sweep starting point, on the scanning boundary of opposite side, obtain the sweep stopping point corresponding with sweep starting point, bar code image between sweep starting point and the sweep stopping point is carried out coordinate Calculation, obtain the coordinate of the pixel between sweep starting point and the sweep stopping point; G. according to the coordinate of the pixel between sweep starting point and the sweep stopping point, carry out the sub-pix border and calculate, obtain the empty boundary coordinate of bar.
Bar code identifying device of the present invention and bar code recognition thereof be the identification bar code direction automatically, and need not direction of scanning that the user adjusts scanning element and can realize identification decoding bar code image, and the accuracy of identification height of bar code border, be decoded into the power height.
Bar space margin processing module of the present invention and disposal route thereof can be obtained the accurate coordinates value of bar code border according to bar code direction adjustment decoding direction, have improved the decoding success ratio greatly, are specially adapted to the identification decoding of high density bar code or distortion bar code.
Bar code identifying device of the present invention and bar space margin processing module adopt the hardware pipeline structure, realize the identification of bar code image is decoded by hardware logic, because 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.
[embodiment]
Relevant feature of the present invention and technology contents please refer to following detailed description and accompanying drawing, and accompanying drawing only provides reference and explanation, is not to be used for the present invention is limited.
Below at first bar code identifying device of the present invention is described in detail, Fig. 2 is a bar code identifying device structural representation of the present invention.
As shown in Figure 2, bar code identifying device of the present invention comprisesboundary recognition module 120,direction identification module 130, bar spacemargin processing module 140 and sign character extraction module 150.Bar code identifying device connects data-carrier store 11, and data-carrier store 11 internal memories contain the pixel coordinate and the gray-scale value of bar code image.Bar code identifying device of the present invention adopts the hardware pipeline structure, realizes the identification of bar code image is decoded by hardware logic, is suitable for bar code image is carried out pipelining and parallel processing.
Boundary recognition module 120 reads bar code image and carries out virtual scan, with the empty frontier point of the bar that obtains bar code.So-called virtual scan line is meant by 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.Boundaryrecognition module 120 is obtained the empty frontier point of the bar that intersects with virtual scan line by calculating the coordinate position that has the pixel of gray scale drop on the virtual scan line.For bar code symbol, bar represents with black or dark color that generally sky is generally represented with white or light color.
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. 3 is the recognition principle synoptic diagram according to bar code direction recognizing method of the present invention.As shown in Figure 3, 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 as shown in Figure 3,
In the following formula, (x2, y2) and (x1, the frontier point acquisition that coordinate y1) can be handed over by virtual scan line and bar Kongxiang, the coordinate figure of the frontier point of handing over according to each bar virtual scan line and bar Kongxiang, by the X coordinate position relatively, the y coordinate position is relatively judged the parallelogram feature of each point, can determine to be positioned at (the x2 of a parallelogram feature, y2) and (x1, the coordinate of pixel y1), and then calculate the value that obtains tg θ 1, promptly obtain the bar code direction.Above-mentioned parallelogram feature also can adopt the parallel lines feature to replace, and above-mentioned parallelogram feature or parallel lines feature 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.Signcharacter extraction module 150 obtains sign character accurately according to bar empty border calculating accurately, thereby obtains bar code information.
As shown in Figure 2, 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. 4 is a kind of process flow diagram of embodiment of the disposal route of bar space margin processing module of the present invention, Fig. 5 is the principle of work synoptic diagram that bar space margin processing module of the present invention is handled bar code image, and Fig. 6 is the partial enlarged drawing of among Fig. 5 bar code image being handled.Below in conjunction with Fig. 2, Fig. 4, Fig. 5 and Fig. 6 the structure function and the treatment scheme of each unit in the bar spacemargin processing module 140 are described.
Please in conjunction with Fig. 2 and Fig. 4, scanningboundary acquiring unit 141fillet identification modules 120,directions calculation module 130.
Instep 921, scanningboundary acquiring unit 141 obtains the bar code border point fromboundary recognition module 120, obtains the bar code direction from directions calculation module 130.As shown in Figure 5 and Figure 6, 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.
Instep 923, 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 to exist in rectangular coordinate system 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 by above-mentioned operational formula, by 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 by the Hough computing, and the pixel coordinate of theborderline region 826 interior pairing boundary straight 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.
In step 924, scanningboundary acquiring unit 141 is according to the bar code direction, the translation preset distance is to obtainscanning boundary 823 and 828 outside the bar code zone with the pixel coordinate of boundarystraight line 822 and boundary straight 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 by the outside translation of pixel coordinate with boundarystraight line 822 and boundary straight 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 will be for further processing inscanning boundary 823 and the 828 inputrectilinear scanning unit 142.
Instep 925,rectilinear scanning unit 142 is selected point A on aside scanning boundary 823, obtains and put corresponding some A ' of A on thescanning boundary 828 of opposite side.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 of A straight line.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 '.
Instep 926,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 will be by putting A and putting in the coordinate figure input scancoordinate Calculation unit 145 of 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 ' by the Breshem arithmetic element.The Breshem algorithm principle is as follows: bar code image is made 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, determine 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 determine 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 calculate, 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 '.
Instep 927, 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 result of calculation incoming symbol character extraction module 150.Signcharacter extraction module 150 calculates according to the empty boundary coordinate of accurate bar and gray scale drop value and obtains bar null value accurately, i.e. sign character value, and then obtain bar code information.
More than the structure and the disposal route thereof of bar code identifying device of the present invention, particularly bar space margin processing module are described in detail.Other disposal routes at bar space margin processing module of the present invention are described in detail below.These technical schemes are technical schemes of being protected in order to make those skilled in the art more in depth understand the present invention, should not be construed as the restriction of the technical scheme that the present invention is protected.
Fig. 7 is the process flow diagram of another kind of embodiment of the disposal route of bar space margin processing module of the present invention.This disposal route may further comprise the steps.
As shown in Figure 7, in step 931, obtain bar code border point and bar code direction.
In step 932, be the center with the bar code border point of both sides, outwards expand according to bar code direction and its vertical direction, obtain borderline region respectively.
In step 933, in borderline region, carry out straight line and calculate, to obtain boundary straight line.
In step 934, according to boundary straight line along the outside translation of bar code direction to obtain scanning boundary.
In step 935, please in conjunction with Fig. 5 and Fig. 6, on a side scanning boundary, choose a plurality of somes A, B, C, on the scanning boundary of opposite side, obtain and put A, B, some A ', B ', C ' that C is corresponding.
In step 936, be sweep starting point with A, B, C, A ', B ', C ' they are sweep stopping point, and the bar code image between A-A ', B-B ', the C-C ' is carried out coordinate Calculation, obtain the coordinate of the many groups pixel between A-A ', B-B ', the C-C '.
In step 937, according to the coordinate and the gray-scale value of the many groups pixel between A-A ', B-B ', the C-C ', carry out the sub-pix border and calculate, obtain empty boundary coordinate of many group bars and border gray scale drop.
In step 938, empty boundary coordinate of many groups bar and border gray scale drop are carried out confidence statistics, obtain empty boundary coordinate of bar with a high credibility and border gray scale drop.
Be with the difference that a kind of disposal route of bar space margin processing module of the present invention, this embodiment is to choose a plurality of points to scan, to obtain empty boundary coordinate of many group bars and border gray scale drop, by empty boundary coordinate of many groups bar and border gray scale drop are carried out confidence statistics, obtain empty boundary coordinate of the higher bar of confidence level and border gray scale drop, thereby make the decoding of bar code identifying device have higher success rate.
Fig. 8 is the process flow diagram of another embodiment of the disposal route of bar space margin processing module of the present invention.Be that with the difference of above-mentioned two kinds of disposal routes this embodiment is to handle at determinant two-dimensional bar code, particularly PDF417, Micro PDF417 bar code.This disposal route may further comprise the steps.
As shown in Figure 8, instep 941, obtain PDF417 bar code border, bar code direction and sign indicating number speech width.
Instep 942,, obtain two row separatrix at a distance of at least one yard speech width according to PDF417 bar code border, bar code direction and sign indicating number speech width.
Instep 943, be the center with two row separatrix, outwards expand according to bar code direction and its vertical direction, obtain row zone, separatrix respectively.
Instep 944, in borderline region, carry out straight line and calculate, to obtain row separatrix straight line.
Instep 945, according to row separatrix straight line along the outside translation of bar code direction to obtain scanning boundary.
In step 946, selected point A on a side scanning boundary obtains the some A ' corresponding with putting A on the scanning boundary of opposite side.
Instep 947, be sweep starting point with A, A is a sweep stopping point, and the bar code image between the A-A ' is carried out coordinate Calculation, obtains the coordinate of pixel between the A-A '.
Instep 948, according to the coordinate and the gray-scale value of pixel between the A-A ', carry out the sub-pix border and calculate, obtain empty boundary coordinate of bar and border gray scale drop.
The present invention can obtain the empty border of bar of determinant bar codes such as PDF417, MicroPDF417 accurately by adopting embodiment shown in Figure 8, and then obtains the pairing bar code information in the empty border of shaping accurately.
Bar code identifying device of the present invention and bar code recognition thereof be the identification bar code direction automatically, and need not direction of scanning that the user adjusts scanning element and can realize identification decoding bar code image, and the accuracy of identification height of bar code border, be decoded into the power height.
Bar space margin processing module of the present invention and disposal route thereof can be obtained the accurate coordinates value of bar code border according to bar code direction adjustment decoding direction, have improved the decoding success ratio greatly, are specially adapted to the identification decoding of high density bar code or distortion bar code.
Bar code identifying device of the present invention and bar space margin processing module adopt the hardware pipeline structure, realize the identification of bar code image is decoded by hardware logic, because 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 the spirit and scope of the invention, those skilled in the art can carry out modifications and changes on the various forms to it, all belongs to protection scope of the present invention.