The content of the invention
In view of this, it is an object of the invention to provide a kind of quick, efficient bar code decoding method, this method, which utilizes, unites
Meter learns principle, and fast positioning barcode position is counted by image feature information;Then, barcode types and bar code direction are judged;Most
Afterwards, bar code content is parsed according to coding rule.
In order to achieve the above object, the present invention provides a kind of bar code decoding method based on image feature information statistics,
It is characterised in that it includes following steps:
1. sample:Polytype bar code is shot respectively, obtains multiple image patterns with bar code;Example
The image pattern of 80 kinds of bar codes in different scenes can be such as shot, every kind of bar code can shoot the figure in one or more scenes
Decent;The scope of sampling can cover a variety of common bar code types, for example, EAN, UPC, Code39, ITF25, Codebar,
The Quick Response Code such as the one-dimension codes such as Code93, Code128 and PDF417, Code49, Code16K, QR;
2. establish the characteristics of image statistical information data storehouse of bar code:Characteristics of image is carried out to each described image pattern
The database being made up of multiple images characteristic information subset is extracted and establishes, the multiple image feature information subset comprises at least
Image-region edge feature subset A={ A1, A2, A3... ..., An, wherein n is positive integer;
A1, A2, A3... ..., AnThe image-region edge feature parameter group of respectively each image pattern, passes through following step
Suddenly obtain:After each image pattern progress horizontal direction and vertical direction decile are obtained into X*X region, to each extracted region
Image border, the image border of all areas in each described image sample is formed into image-region edge feature parameter group;Its
In, X is the integer more than 1;Each mapping relations are formed between image-region edge feature parameter group and a kind of bar code;
3. shooting image:Object to be decoded is taken pictures, gets the real image i with bar code;
4. obtain characteristics of image statistical information:Real image i is subjected to horizontal direction and vertical direction decile obtains X*X
Behind region, to each extracted region images edge, the image border of all areas in the real image i is formed into real image
Edges of regions characteristic parameter group Ai;In one embodiment, X is preferably 8;
5. characteristic matching:By actual image area edge feature parameter group AiWith described image edges of regions character subset A
In parameter group matched, after the match is successful, and map and determine a kind of bar code;
6. decode;After determining bar code, decoded according to coding rule;
7. if successfully decoded, exports decoded result;If decoding failure, it tries solved to next secondary real image
Code, repeat step is 3. to 6..
Some simple one-dimension codes, obtain actual image area edge feature parameter group AiAfterwards, A is passed throughiFast positioning bar
During code position, the image-region edge feature parameter group in the database corresponding to it is also uniquely determined, so as to can
Quickly determine barcode types and bar code direction.
, can not when only relying on actual image area edge feature parameter group Ai because bar code part is the region of edge aggregation
When determining barcode types and bar code direction, we can be by counting image level direction and the vertical direction of bar code region
The distribution of the first differential signal of image, it can rapidly judge barcode position, barcode types and bar code direction.It is for example, horizontal
The first differential signal of the UPC-A codes in direction in the horizontal direction is very big, and the first differential signal very little of vertical direction;QR
First differential signals of the Code in which direction all can be very big.
Specifically, the step 2. in, the multiple image feature information subset also includes the one of bar code area area image
Rank differential signal character subset B={ B1, B2, B3... ..., Bn};B1, B2, B3... ..., BnBar in respectively each image pattern
The image border first differential signal characteristic parameter group of shape code region, is obtained by following steps:By each image pattern
In bar code region image in edge do the first differential of horizontal direction and vertical direction, first obtain two secondary single orders
Differential signal figure, statistics with histogram is done respectively to two width first differential signal graphs, obtained comprising horizontal direction and vertical direction
The image border first differential signal characteristic parameter group of first differential signal statistics with histogram information;Each image border single order is micro-
Sub-signal characteristic parameter group all forms mapping relations between a kind of bar code;
4. the step also includes:Edge in the image of bar code region in real image i is done into level side
To the first differential with vertical direction, two secondary first differential signal graphs are first obtained, two width first differential signal graphs are done directly respectively
Side's figure statistics, obtains the real image edge of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction
First differential signal characteristic parameter group Bi;
5. the step also includes:By actual image area edge feature parameter group AiWith described image edges of regions feature
Parameter group in subset A is when it fails to match, by real image edge first differential signal characteristic parameter group BiWith the bar code
Parameter group in the first differential signal characteristic subset B of area image is matched, and after the match is successful, mapping determines a kind of stripe shape
Code.
It is, of course, also possible to the first differential letter of the image of diagonal in counting the image of bar code region simultaneously
Number distribution.Specifically, the edge in the image of the bar code region in each image pattern is done into horizontal direction, vertical
Direction and the first differential of diagonal, three secondary first differential signal graphs are first obtained, three width first differential signal graphs are distinguished
Statistics with histogram is done, the first differential signal statistics with histogram comprising horizontal direction, vertical direction and diagonal is obtained and believes
The image border first differential signal characteristic parameter group of breath.
Wherein, it is big by Bi if still can not be uniquely determined by Ai and Bi when being any bar code in database
Cause judges barcode types and bar code direction, and we can pass through the peak on the spectrum analysis figure for the image water for counting bar code region
It is worth number, further determines that barcode types and bar code direction.
Specifically, edge spectrum analysis feature of the multiple image feature information subset also including bar code area area image
Subset C={ C1, C2, C3... ..., Cn};C1, C2, C3... ..., CnBar code region in respectively each image pattern
The spectrum analysis characteristic parameter group of image, is obtained by following steps:By the bar code region in each image pattern
Image does spectrum analysis, first obtains spectrum analysis figure, and then statistics obtains the spectrum analysis comprising all peak values and peak value number
Characteristic parameter group;Each mapping relations are formed between spectrum analysis characteristic parameter group and a kind of bar code;
4. the step also includes:The image of bar code region in real image i is done into spectrum analysis, first obtained
Spectrum analysis figure, then statistics obtains including all peak values and the actual spectrum of peak value number analyzes characteristic parameter group Ci;
5. the step also includes:By real image edge first differential signal characteristic parameter group BiWith the bar code area
Actual spectrum is analyzed characteristic parameter group C after it fails to match by parameter group in the first differential signal characteristic subset B of area imagei
Matched with the parameter group in the edge spectrum analysis character subset C of the bar code area area image, mapped after the match is successful
Determine a kind of bar code;
5. the step also includes:By actual image area edge feature parameter group AiWith described image edges of regions feature
Parameter group in subset A is when it fails to match, by real image edge first differential signal characteristic parameter group BiWith the bar code
Parameter group in the first differential signal characteristic subset B of area image is matched, a kind of stripe shape of mapping determination after the match is successful
Code.
Preferably, the step is 7. after middle decoding failure, in addition to step:8. to coding rule under the conditions of low contrast
It is adjusted, produces a new coding rule, decoded, if successfully decoded, exports decoded result.
Further, if 8. the step decodes failure, in addition to step:9. to coding rule under the conditions of low sampling rate
It is adjusted, produces another new coding rule, decoded, if successfully decoded, exports decoded result.
Yet further, if 9. the step decodes failure, in addition to step:10. to coding rule under the conditions of height distorts
It is adjusted, produces another new coding rule, decoded, successfully decoded, exports decoded result.
During decoding, the present invention can be also finely adjusted to the parameter group in database, when only passing through AiIt is decoded into
During work(, trim step is:After successfully decoded, according to actual image area edge feature parameter group Ai , by the number corresponding to it
It is finely adjusted according to the image-region edge feature parameter group in storehouse, makes the image-region edge feature parameter group in database close
Actual image area edge feature parameter group Ai。
When passing through AiAnd BiDuring common successfully decoded, trim step is:After successfully decoded, according to actual image area side
Edge characteristic parameter group Ai With real image edge first differential signal characteristic parameter group Bi, by the figure in the database corresponding to it
As the image border first differential signal characteristic parameter group of edges of regions characteristic parameter group and bar code region is finely adjusted,
Make the image-region edge feature parameter group in database close to actual image area edge feature parameter group Ai, make in database
Bar code region image border first differential signal characteristic parameter group close to real image edge first differential signal
Characteristic parameter group Bi。
When passing through Ai、BiAnd CiWhen passing through successfully decoded, trim step is:After successfully decoded, according to actual image area
Edge feature parameter group Ai , real image edge first differential signal characteristic parameter group BiAnd actual spectrum analysis characteristic parameter group
Ci, by the image-region edge feature parameter group in the database corresponding to it, the image border single order of bar code region
The spectrum analysis characteristic parameter group of the image of differential signal characteristic parameter group and bar code region is finely adjusted, and makes database
In image-region edge feature parameter group close to actual image area edge feature parameter group Ai, make the bar code in database
The image border first differential signal characteristic parameter group of region is close to real image edge first differential signal characteristic parameter
Group Bi, the spectrum analysis characteristic parameter group of the image of the bar code region in database is analyzed feature close to actual spectrum
Parameter group Ci。
When being decoded by the bar code decoding method of the present invention to the bar code on some object, typically decoded
Journey is generally divided into three steps:After obtaining image feature information according to the image of shooting, A is obtained using statisticsiFast positioning bar code,
Then the B obtained using statisticsiJudge barcode types and bar code direction, it is last to be decoded according to coding rule.
Compared to prior art, the present invention utilizes Principle of Statistics, establishes bar code image characteristic statisticses information data
Storehouse, count quick by characteristics of image by the image for acquisition of taking pictures and determine barcode position, barcode types and bar code direction, so as to
It is quick to realize decoding, identification and the decoding efficiency of bar code are substantially increased, and can self in multiple decoding process
Characteristics of image statistical information in study and amendment database, it can constantly improve decoding effect with the increase of number of applications
Rate.
Embodiment
The preferred embodiment of the present invention is described in detail below in conjunction with the accompanying drawings.
Refer to Fig. 1 and Fig. 2, the bar code decoding method based on image feature information statistics of the present embodiment, main bag
The sampling that includes early stage, the basic steps in the characteristics of image statistical information data storehouse for establishing bar code, and shooting image, obtain figure
As characteristic statisticses information, characteristic matching, decoding and the practical application of fine setting step.
In sampling process, the present embodiment is shot in different scenes respectively to 80 conventional type bar codes,
Obtain multiple image patterns with bar code.Various scenes can be set according to the situation of bar code practical application, such as bar shaped
The different product surface, the various complex backgrounds residing for bar code etc. that code is applied.
When establishing the characteristics of image statistical information data storehouse of bar code, image characteristics extraction is carried out to each image pattern
And establish the database being made up of multiple images characteristic information subset.Multiple images characteristic information subset comprises at least image-region
Edge feature subset A={ A1, A2, A3... ..., An, first differential signal characteristic subset B={ B of bar code area area image1,
B2, B3... ..., Bn, and edge spectrum analysis character subset C={ C of bar code area area image1, C2, C3... ..., Cn, its
Middle n is positive integer, and n is more than 80 here.
Wherein, A1, A2, A3... ..., AnThe image-region edge feature parameter group of respectively each image pattern, by with
Lower step obtains:After each image pattern progress horizontal direction and vertical direction decile are obtained into 8*8 region, to each region
Image border is extracted, the image border of all areas in each described image sample is formed into image-region edge feature parameter
Group;Each mapping relations are formed between image-region edge feature parameter group and a kind of bar code.
B1, B2, B3 ... ..., Bn are respectively that the image border single order of the bar code region in each image pattern is micro-
Sub-signal characteristic parameter group, is obtained by following steps:By in the image of the bar code region in each image pattern
Edge does the first differential of horizontal direction and vertical direction, first obtains two secondary first differential signal graphs, and two width first differentials are believed
Number figure does statistics with histogram respectively, obtains the first differential signal statistics with histogram information comprising horizontal direction and vertical direction
Image border first differential signal characteristic parameter group;Each image border first differential signal characteristic parameter group and a kind of bar shaped
Mapping relations are formed between code.
C1, C2, C3... ..., CnThe spectrum analysis of the image of bar code region in respectively each image pattern is special
Parameter group is levied, is obtained by following steps:The image of bar code region in each image pattern is done into spectrum analysis, first
Spectrum analysis figure is obtained, then statistics obtains the spectrum analysis characteristic parameter group comprising all peak values and peak value number;Each frequency
Spectrum analysis characteristic parameter group all forms mapping relations between a kind of bar code.
After the completion of Database, it is possible to carried out using the image of implication bar code of the Principle of Statistics to taking pictures to obtain
Feature extraction and statistics obtain the corresponding characteristic parameter group of real image, then can quickly judge barcode position, barcode types and
Bar code direction, and then decoded according to coding rule.
As shown in figure 1, the decoding process detailed description of the present embodiment is as follows
Step S01:Start.
Step S02:Object to be decoded is shot, obtains the real image i with bar code.
Step S03:After real image i progress horizontal directions and vertical direction decile are obtained into 8*8 region, to each area
Image border is extracted in domain, and the image border of all areas in the real image i is formed into actual image area edge feature ginseng
Array Ai;By actual image area edge feature parameter group AiWith the parameter group in image-region edge feature subset A in database
Matched, after the match is successful, and map and determine a kind of bar code.
Then bar code is decoded according to coding rule by step S031, after successfully decoded, exports decoded result.
Afterwards, in addition to image-region edge feature subset A in database, corresponding parameter group is finely adjusted step S032, makes number
According to the image-region edge feature parameter group in storehouse close to actual image area edge feature parameter group Ai。
As actual image area edge feature parameter group AiWith the parameter group in described image edges of regions character subset A
During with failure, barcode position is determined using Ai, then passes through step S04, statistics real image edge first differential signal characteristic
Parameter group Bi, specifically, BiStatistic processes be:Edge in the image of bar code region in real image i is done into water
Square to the first differential with vertical direction, two secondary first differential signal graphs are first obtained, two width first differential signal graphs are distinguished
Statistics with histogram is done, obtains the real image of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction
Edge first differential signal characteristic parameter group Bi。
Then by real image edge first differential signal characteristic parameter group BiWith the bar code area area image in database
First differential signal characteristic subset B in parameter group matched, after the match is successful, mapping determines a kind of bar code.
Then bar code is decoded according to coding rule by step S041, after successfully decoded, exports decoded result.
Afterwards, by trim step S042, according to Ai、BiThe parameter group corresponding to image-region edge feature subset A in database and
The parameter group that the first differential signal characteristic subset B of bar code area area image is corresponding is finely adjusted, and makes the image in database
Edges of regions characteristic parameter group is close to actual image area edge feature parameter group Ai, make the bar code area area image in database
First differential signal characteristic parameter group close to real image edge first differential signal characteristic parameter group Bi。
As real image edge first differential signal characteristic parameter group BiWith one of the bar code area area image in database
Parameter group in rank differential signal character subset B is when also it fails to match;Using the obtained substantially barcode types of Bi and bar code direction,
Again by step S05, the image of the bar code region in real image i is done into spectrum analysis, first obtains spectrum analysis figure,
Then statistics obtains the actual spectrum analysis characteristic parameter group C comprising all peak values and peak value numberi, actual spectrum is analyzed special
Levy parameter group CiWith the parameter group progress in the edge spectrum analysis character subset C of the bar code area area image in database
Match somebody with somebody, a kind of bar code of mapping determination after the match is successful.
Bar code is decoded according to coding rule by step S051 again, after successfully decoded, exports decoded result.It
Afterwards, by trim step S052, according to Ai、Bi、Ci, the parameter corresponding to image-region edge feature subset A in database
Group, the first differential signal characteristic subset B of bar code area area image corresponding parameter group and the side of bar code area area image
Edge spectrum analysis character subset C relative to parameter group be finely adjusted, make the image-region edge feature parameter group in database
Close to actual image area edge feature parameter group Ai, make the first differential signal characteristic of the bar code area area image in database
Parameter group is close to real image edge first differential signal characteristic parameter group Bi, make database, the barcode size or text field in database
Parameter group in the edge spectrum analysis character subset C of image is close to actual spectrum analysis characteristic parameter group Ci。
In addition, the present embodiment is also improved the specific steps of decoding, make the bar code decoding side using the present invention
The solution code system of method can autonomous learning, constantly adjust coding rule to adapt to solve the conventional environment of code system, it is quickly real
Now decode.As shown in Fig. 2 the present embodiment is to pass through AiAnd BiThe parameter group matching of two image information statistics determines bar code bit
Put, exemplified by barcode types and bar code direction, decoding step specifically includes:
Step S11:Determine barcode position, barcode types and bar code direction.
Step S12:Normally decoded according to default coding rule, after successfully decoded, exported and decoded by step S17
As a result, otherwise into step S13.
Step S13:Coding rule is adjusted under the conditions of low contrast, new coding rule is produced, is decoded,
After successfully decoded, decoded result is exported by step S17, otherwise into step S14.
Step S14:Coding rule is adjusted under the conditions of low sampling rate, produces another new coding rule, is carried out
Decode, after successfully decoded, decoded result is exported by step S17, otherwise into step S15.
Step S15:Coding rule is adjusted under the conditions of height distorts, another new coding rule is produced, is solved
Yard, after successfully decoded, decoded result is exported by step S17, otherwise passes through step S16 and attempts to shoot next pictures and repetition
Above decoding process S02 to S05 and decoding step S11 to S14, until successfully decoded.
The above embodiments merely illustrate the technical concept and features of the present invention, and its object is to allow person skilled in the art
Scholar can understand present disclosure and implement according to this, and it is not intended to limit the scope of the present invention, all according to the present invention
The equivalent change or modification that Spirit Essence is made, it should all be included within the scope of the present invention.