Summary of the invention
In view of this, the object of this invention is to provide fast a kind of, efficient bar code decoding method, the method utilizes Principle of Statistics, by image feature information statistics quick position barcode position; Then, barcode types and bar code direction is judged; Finally, bar code content is parsed according to coding rule.
In order to achieve the above object, the invention provides a kind of bar code decoding method based on image feature information statistics, it is characterized in that, comprise the following steps:
1. sample: polytype bar code is taken respectively, obtains multiple image pattern with bar code; Such as can take the image pattern of 80 kinds of bar codes in different scene, often kind of bar code can take the image pattern in one or more scenes; The scope of sampling can contain multiple common bar code type, the Quick Response Codes such as one-dimension code and PDF417, Code49, Code16K, QR such as such as EAN, UPC, Code39, ITF25, Codebar, Code93, Code128;
2. the characteristics of image statistical information data storehouse of bar code is set up: carry out image characteristics extraction to each described image pattern and also set up the database be made up of multiple image feature information subset, described multiple image feature information subset at least comprises image-region edge feature subset A={ A
1, A
2, A
3..., A
n, wherein n is positive integer;
A
1, A
2, A
3..., A
nbe respectively the image-region edge feature parameter group of each image pattern, obtained by following steps: each image pattern is carried out after horizontal direction and vertical direction decile obtain X*X region, to each extracted region images edge, by the image border composition diagram in all regions in each described image pattern as edges of regions characteristic parameter group; Wherein, X be greater than 1 integer; Mapping relations are formed between each image-region edge feature parameter group and a kind of bar code;
3. take image: object to be decoded is taken pictures, get the real image i with bar code;
4. characteristics of image statistical information is obtained: carried out by real image i after horizontal direction and vertical direction decile obtain X*X region, to each extracted region images edge, by the image border in all regions in described real image i composition actual image area edge feature parameter group A
i; In one embodiment, X is preferably 8;
5. characteristic matching: by actual image area edge feature parameter group A
imate with the parameter group in described image-region edge feature subset A, after the match is successful, and a kind of bar code is determined in mapping;
6. decode; After determining bar code, decode according to coding rule;
If 7. successfully decoded, then export decoded result; If decode unsuccessfully, then attempt decoding to next secondary real image, repeat step 3. extremely 6..
Some simple one-dimension code, obtain actual image area edge feature parameter group A
iafter, pass through A
iduring quick position barcode position, the image-region edge feature parameter group in the database corresponding to it also by unique determination, thus just can determine barcode types and bar code direction rapidly.
Because bar code part is the region that edge is assembled, when only relying on actual image area edge feature parameter group Ai cannot determine barcode types and bar code direction, we are by adding up the distribution of the first differential signal in the image level direction of bar code region and the image of vertical direction, barcode position can be judged rapidly, barcode types and bar code direction.Such as, the UPC-A code first differential signal in the horizontal direction of horizontal direction is very large, and the first differential signal of vertical direction is very little; The first differential signal of QR Code in which direction all can be very large.
Particularly, described step 2. in, described multiple image feature information subset also comprises the first differential signal characteristic subset B={ B of bar code area area image
1, B
2, B
3..., B
n; B
1, B
2, B
3..., B
nbe respectively the image border first differential signal characteristic parameter group of the bar code region in each image pattern, obtained by following steps: the first differential edge in the image of the bar code region in each image pattern being done horizontal direction and vertical direction, first obtain two secondary first differential signal graphs, respectively statistics with histogram is done to two width first differential signal graphs, obtains the image border first differential signal characteristic parameter group of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction; Mapping relations are formed between each image border first differential signal characteristic parameter group and a kind of bar code;
4. described step also comprises: the first differential edge in the image of the bar code region in real image i being done horizontal direction and vertical direction, first obtain two secondary first differential signal graphs, respectively statistics with histogram is done to two width first differential signal graphs, obtains the real image edge first differential signal characteristic parameter group B of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction
i;
5. described step also comprises: by actual image area edge feature parameter group A
iwhen it fails to match with the parameter group in described image-region edge feature subset A, by real image edge first differential signal characteristic parameter group B
imate with the parameter group in the first differential signal characteristic subset B of described bar code area area image, after the match is successful, map and determine a kind of bar code.
Certainly, the distribution of the first differential signal of the image of the diagonal in the image of bar code region can also be added up simultaneously.Particularly, edge in the image of the bar code region in each image pattern is done the first differential of horizontal direction, vertical direction and diagonal, first obtain three secondary first differential signal graphs, respectively statistics with histogram is done to three width first differential signal graphs, obtains the image border first differential signal characteristic parameter group of the first differential signal statistics with histogram information comprising horizontal direction, vertical direction and diagonal.
Wherein, if when relying on Ai and Bi still cannot uniquely determine to be any bar code in database, Bi is relied on roughly to judge barcode types and bar code direction, we, by adding up the peak value number on the spectrum analysis figure of the image water of bar code region, determine barcode types and bar code direction further.
Particularly, described multiple image feature information subset also comprises the edge spectrum analytical characteristic subset C={ C of bar code area area image
1, C
2, C
3..., C
n; C
1, C
2, C
3..., C
nbe respectively the spectrum analysis characteristic parameter group of the image of the bar code region in each image pattern, obtained by following steps: the image of the bar code region in each image pattern is done spectrum analysis, first obtain spectrum analysis figure, then statistics obtains the spectrum analysis characteristic parameter group comprising all peak values and peak value number; Mapping relations are formed between each spectrum analysis characteristic parameter group and a kind of bar code;
4. described step also comprises: the image of the bar code region in real image i is done spectrum analysis, first obtains spectrum analysis figure, and then statistics obtains the actual spectrum analytical characteristic parameter group C comprising all peak values and peak value number
i;
5. described step also comprises: by real image edge first differential signal characteristic parameter group B
iafter it fails to match with the parameter group in the first differential signal characteristic subset B of described bar code area area image, by actual spectrum analytical characteristic parameter group C
imate with the parameter group in the edge spectrum analytical characteristic subset C of described bar code area area image, map after the match is successful and determine a kind of bar code;
5. described step also comprises: by actual image area edge feature parameter group A
iwhen it fails to match with the parameter group in described image-region edge feature subset A, by real image edge first differential signal characteristic parameter group B
imate with the parameter group in the first differential signal characteristic subset B of described bar code area area image, map after the match is successful and determine a kind of bar code.
Preferably, described step 7. in decode unsuccessfully, also comprise step: 8. under low contrast condition, coding rule is adjusted, produce a new coding rule, decode, if successfully decoded, output decoded result.
Further, the failure if 8. described step decodes, also comprises step: 9. adjust coding rule under low sampling rate condition, produces the coding rule that another is new, decodes, if successfully decoded, exports decoded result.
Again further, the failure if 9. described step decodes, also comprises step: 10. adjust coding rule under height distortion condition, produce the coding rule that another is new, decode, successfully decoded, exports decoded result.
In the process of decoding, the present invention also can finely tune the parameter group in database, when by means of only A
iduring successfully decoded, trim step is: after successfully decoded, according to actual image area edge feature parameter group A
i, the image-region edge feature parameter group in the database corresponding to it is finely tuned, makes image-region edge feature parameter group in database near actual image area edge feature parameter group A
i.
When passing through A
iand B
iduring common successfully decoded, trim step is: after successfully decoded, according to actual image area edge feature parameter group A
iwith real image edge first differential signal characteristic parameter group B
ithe image border first differential signal characteristic parameter group of the image-region edge feature parameter group in the database corresponding to it and bar code region is finely tuned, makes image-region edge feature parameter group in database near actual image area edge feature parameter group A
i, make the image border first differential signal characteristic parameter group of the bar code region in database near real image edge first differential signal characteristic parameter group B
i.
When passing through A
i, B
iand C
iduring by successfully decoded, trim step is: after successfully decoded, according to actual image area edge feature parameter group A
i, real image edge first differential signal characteristic parameter group B
iand actual spectrum analytical characteristic parameter group C
ithe spectrum analysis characteristic parameter group of image-region edge feature parameter group, the image border first differential signal characteristic parameter group of bar code region and the image of bar code region in the database corresponding to it is finely tuned, makes image-region edge feature parameter group in database near actual image area edge feature parameter group A
i, make the image border first differential signal characteristic parameter group of the bar code region in database near real image edge first differential signal characteristic parameter group B
i, make the spectrum analysis characteristic parameter group of the image of the bar code region in database near actual spectrum analytical characteristic parameter group C
i.
When being decoded to the bar code on certain object by bar code decoding method of the present invention, typical decode procedure is generally divided into three steps: after the Image Acquisition image feature information according to shooting, utilize statistics to obtain A
iquick position bar code, then utilizes the B adding up and obtain
ijudge barcode types and bar code direction, last foundation coding rule is decoded.
Compared to prior art, the present invention utilizes Principle of Statistics, establish bar code image characteristic statistics information database, the image obtained by taking pictures is added up by characteristics of image and is determined barcode position fast, barcode types and bar code direction, thus realize decoding fast, substantially increase identification and the decoding efficiency of bar code, and can self-teaching and the characteristics of image statistical information revised in database in decode procedure repeatedly, along with the increase of number of applications, constantly can improve decoding efficiency.
Embodiment
Below in conjunction with accompanying drawing, the preferred embodiment of the present invention is described in detail.
Refer to Fig. 1 and Fig. 2, the bar code decoding method based on image feature information statistics of the present embodiment, mainly comprise the sampling in early stage, set up the basic steps in the characteristics of image statistical information data storehouse of bar code, and shooting image, obtain the practical application step of characteristics of image statistical information, characteristic matching, decoding and fine setting.
In sampling process, the present embodiment is taken respectively to 80 conventional type bar codes in different scene, obtains multiple image pattern with bar code.Various scene can be arranged according to the situation of bar code practical application, the different product surface that such as bar code is applied, the various complex backgrounds etc. residing for bar code.
When setting up the characteristics of image statistical information data storehouse of bar code, image characteristics extraction being carried out to each image pattern and also sets up the database be made up of multiple image feature information subset.Multiple image feature information subset at least comprises image-region edge feature subset A={ A
1, A
2, A
3..., A
n, the first differential signal characteristic subset B={ B of bar code area area image
1, B
2, B
3..., B
n, and the edge spectrum analytical characteristic subset C={ C of bar code area area image
1, C
2, C
3..., C
n, wherein n is positive integer, and n is greater than 80 here.
Wherein, A
1, A
2, A
3..., A
nbe respectively the image-region edge feature parameter group of each image pattern, obtained by following steps: each image pattern is carried out after horizontal direction and vertical direction decile obtain 8*8 region, to each extracted region images edge, by the image border composition diagram in all regions in each described image pattern as edges of regions characteristic parameter group; Mapping relations are formed between each image-region edge feature parameter group and a kind of bar code.
B1, B2, B3, Bn is respectively the image border first differential signal characteristic parameter group of the bar code region in each image pattern, obtained by following steps: the first differential edge in the image of the bar code region in each image pattern being done horizontal direction and vertical direction, first obtain two secondary first differential signal graphs, respectively statistics with histogram is done to two width first differential signal graphs, obtains the image border first differential signal characteristic parameter group of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction; Mapping relations are formed between each image border first differential signal characteristic parameter group and a kind of bar code.
C
1, C
2, C
3..., C
nbe respectively the spectrum analysis characteristic parameter group of the image of the bar code region in each image pattern, obtained by following steps: the image of the bar code region in each image pattern is done spectrum analysis, first obtain spectrum analysis figure, then statistics obtains the spectrum analysis characteristic parameter group comprising all peak values and peak value number; Mapping relations are formed between each spectrum analysis characteristic parameter group and a kind of bar code.
After Database completes, the image of the implication bar code that Principle of Statistics just can be utilized to obtain taking pictures carries out feature extraction and statistics obtains the corresponding characteristic parameter group of real image, then barcode position can be judged fast, barcode types and bar code direction, and then decode according to coding rule.
As shown in Figure 1, the decode procedure of the present embodiment is described in detail as follows
Step S01: start.
Step S02: take object to be decoded, obtains the real image i with bar code.
Step S03: real image i is carried out after horizontal direction and vertical direction decile obtain 8*8 region, to each extracted region images edge, by the image border in all regions in described real image i composition actual image area edge feature parameter group A
i; By actual image area edge feature parameter group A
imate with the parameter group in image-region edge feature subset A in database, after the match is successful, and a kind of bar code is determined in mapping.
Then according to coding rule, bar code is decoded by step S031, after successfully decoded, export decoded result.Afterwards, also comprise the parameter group corresponding to image-region edge feature subset A in database and carry out trim step S032, make image-region edge feature parameter group in database near actual image area edge feature parameter group A
i.
As actual image area edge feature parameter group A
iwhen it fails to match with the parameter group in described image-region edge feature subset A, Ai is utilized to determine barcode position, then by step S04, statistics real image edge first differential signal characteristic parameter group B
i, particularly, B
istatistic processes be: the first differential edge in the image of the bar code region in real image i being done horizontal direction and vertical direction, first obtain two secondary first differential signal graphs, respectively statistics with histogram is done to two width first differential signal graphs, obtains the real image edge first differential signal characteristic parameter group B of the first differential signal statistics with histogram information comprising horizontal direction and vertical direction
i.
Then by real image edge first differential signal characteristic parameter group B
imate with the parameter group in the first differential signal characteristic subset B of the bar code area area image in database, after the match is successful, map and determine a kind of bar code.
Then according to coding rule, bar code is decoded by step S041, after successfully decoded, export decoded result.Afterwards, by trim step S042, according to A
i, B
ithe parameter group corresponding with the first differential signal characteristic subset B of bar code area area image to the parameter group that image-region edge feature subset A in database is corresponding is finely tuned, and makes image-region edge feature parameter group in database near actual image area edge feature parameter group A
i, make the first differential signal characteristic parameter group of the bar code area area image in database near real image edge first differential signal characteristic parameter group B
i.
As real image edge first differential signal characteristic parameter group B
ialso when it fails to match with the parameter group in the first differential signal characteristic subset B of the bar code area area image in database; The roughly barcode types utilizing Bi to obtain and bar code direction, again by step S05, the image of the bar code region in real image i is done spectrum analysis, first obtains spectrum analysis figure, then statistics obtains the actual spectrum analytical characteristic parameter group C comprising all peak values and peak value number
i, by actual spectrum analytical characteristic parameter group C
imate with the parameter group in the edge spectrum analytical characteristic subset C of the bar code area area image in database, map after the match is successful and determine a kind of bar code.
According to coding rule, bar code is decoded by step S051 again, after successfully decoded, export decoded result.Afterwards, by trim step S052, according to A
i, B
i, C
ithe parameter group corresponding to the first differential signal characteristic subset B of the corresponding parameter group of image-region edge feature subset A in database, bar code area area image and the edge spectrum analytical characteristic subset C of bar code area area image relative to parameter group finely tune, make image-region edge feature parameter group in database near actual image area edge feature parameter group A
i, make the first differential signal characteristic parameter group of the bar code area area image in database near real image edge first differential signal characteristic parameter group B
i, make database, the parameter group in the edge spectrum analytical characteristic subset C of the bar code area area image in database is near actual spectrum analytical characteristic parameter group C
i.
In addition, the present embodiment also improves the concrete steps of decoding, enables the decode system autonomous learning of employing bar code decoding method of the present invention, constantly adjusts the environment that coding rule is commonly used with adapted solu-tion code system, realizes decoding quickly.As shown in Figure 2, the present embodiment is to pass through A
iand B
ithe parameter group coupling of two image information statistics determines barcode position, and barcode types and bar code direction are example, and decoding step specifically comprises:
Step S11: determine barcode position, barcode types and bar code direction.
Step S12: the coding rule according to presetting carries out normal decoder, after successfully decoded, exports decoded result by step S17, otherwise enters step S13.
Step S13: adjust coding rule under low contrast condition, produces new coding rule, decodes, and after successfully decoded, exports decoded result, otherwise enter step S14 by step S17.
Step S14: adjust coding rule under low sampling rate condition, produces another new coding rule, decodes, and after successfully decoded, exports decoded result, otherwise enter step S15 by step S17.
Step S15: under height distortion condition, coding rule is adjusted, produce the coding rule that another is new, decode, after successfully decoded, decoded result is exported by step S17, otherwise attempt next pictures of shooting by step S16 and repeat above decode procedure S02 to S05 and decoding step S11 to S14, until successfully decoded.
Above-described embodiment is only for illustrating technical conceive of the present invention and feature; its object is to person skilled in the art can be understood content of the present invention and implement according to this; can not limit the scope of the invention with this; all equivalences done according to Spirit Essence of the present invention change or modify, and all should be encompassed within protection scope of the present invention.