A kind of two-dimensional code identification method and deviceTechnical field
The present invention relates to two dimensional code identification technology, especially a kind of two-dimensional code identification method and device.
Background technique
Two dimensional code (dimensional barcode), also known as two-dimensional bar code, are expanded on the basis of bar codeIt is a kind of with readable bar code, be distributed on planar direction according to certain rules with certain specific geometric figure it is blackWhite alternate graphic recording data symbol information utilizes " 0 ", " 1 " for constituting computer-internal logical foundations in code compilationThe concept of bit stream indicates text numerical information using several geometrical bodies corresponding with binary system, defeated by imageEnter equipment or photoelectric scanning device automatically identifying and reading to realize automatic processing of information.
Common two dimensional code code system has Data Matrix, Maxi Code, Aztec, QR Code etc., wherein QR Code(Quick Response Code, quick response coding) square matrix code is presently the most popular code system, it has information capacityGreatly, high reliablity, can indicate Chinese character and image kinds of words information, the advantages that security and antiforge purpose is strong.QR code is square, black and whiteDichromatism, three corners are printed on the square pattern of " returning " word, wherein and the square pattern for being printed on " returning " word is the alignment code of QR code,A QR code can be positioned using three alignment codes.
Existing Some Enterprises have used product two dimensional code way to manage, and two dimensional code is corresponding with each station, and each station is completedSemi-finished product afterwards carry out patch code and flow into production line to use for the latter in specified region.After the completion of multistation, to specified regionMultiple two dimensional codes are identified, multiple two-dimensional barcode informations are selectively integrated into a two dimensional code and attach or be sprayed on productOr in outer packing, used for other internal departments or consumer.
Existing two-dimensional code identification method uses single camera, and two-dimension code recognition device is single camera device, in faceWhen to two dimensional code uneven illumination, two dimensional code can not be identified, the phenomenon could be solved by needing artificially to adjust light source or two-dimentional code position.Equally, when facing two-dimension code image torsional deformation, existing two-dimensional code identification method and device can only identify that deformation is smallerTwo dimensional code, two dimensional code can not be identified if deformation is excessive.
Summary of the invention
The purpose of the present invention is to provide one kind to read in the case where two-dimension code image torsional deformation, uneven illuminationThe two-dimensional code identification method and device of two-dimensional barcode information out.
Realize the technical solution of the object of the invention are as follows: a kind of two-dimensional code identification method, comprising the following steps:
Two-dimension code image is acquired simultaneously from different perspectives by two cameras;
Two two-dimension code images of acquisition are pre-processed;
Two dimensional code dividing processing is carried out to pretreated two-dimension code image, extracts two dimensional code;
According to the edge distorting event of two two dimensional codes to two dimensional code locating for veneer determined and calculated, correctedFormula carries out image rectification to two dimensional code using updating formula, is reduced to the two dimensional code of standard shape;
Two standard shape two dimensional code code area information are recorded, according to pixel black in one of code area to anotherCode area carries out supplement process, obtains can recognize two dimensional code;
Extract the two-dimensional barcode information that can recognize in two dimensional code.
A kind of two-dimension code recognition device, comprising:
Two cameras, for acquiring two-dimension code image simultaneously from different perspectives;
Image pre-processing module is pre-processed for two two-dimension code images to acquisition;
Two dimensional code dividing processing module is extracted for carrying out two dimensional code dividing processing to pretreated two-dimension code imageTwo dimensional code out;
Two dimensional code correction module, for according to the edge distorting event of two two dimensional codes to two dimensional code locating for veneer carry outDetermine and calculate, obtain updating formula, image rectification is carried out to two dimensional code using updating formula, is reduced to standard shapeTwo dimensional code;
Two dimensional code complementation module, for recording two standard shape two dimensional code code area information, according to one of codingBlack pixel carries out supplement process to another code area in area, obtains can recognize two dimensional code;
Two-dimensional barcode information extraction module, for extracting the two-dimensional barcode information in recognizable two dimensional code.
Compared with prior art, remarkable advantage of the invention are as follows:
(1) present invention can restore preferable image when uneven illumination occurs for two dimensional code and extract two dimensional code letterBreath;
(2) prior art only can identify two-dimensional barcode information in the lesser situation of two dimensional code deformation, when two dimensional code occur compared withIt can not then identify that two-dimensional barcode information, the present invention can preferably restore image when two dimensional code is distorted and deforms when big deformationAnd extract two-dimensional barcode information.
Detailed description of the invention
Fig. 1 is the flow chart of recognition methods of the present invention.
Fig. 2 is the module map of identification device of the present invention.
Specific embodiment
To facilitate the understanding of the present invention, below with reference to the module map of the flow chart of recognition methods and identification device, to thisInvention is described in detail.
In conjunction with Fig. 1, a kind of two-dimensional code identification method of the invention, comprising the following steps:
Two-dimension code image is acquired simultaneously from different perspectives by two cameras;
Two two-dimension code images of acquisition are pre-processed;
Two dimensional code dividing processing is carried out to pretreated two-dimension code image, extracts two dimensional code;
According to the edge distorting event of two two dimensional codes to two dimensional code locating for veneer determined and calculated, correctedFormula carries out image rectification to two dimensional code using updating formula, is reduced to the two dimensional code of standard shape;
Two standard shape two dimensional code code area information are recorded, according to pixel black in one of code area to anotherCode area carries out supplement process, obtains can recognize two dimensional code;
Extract the two-dimensional barcode information that can recognize in two dimensional code.
Further, pretreatment includes image gray processing processing, image binaryzation processing and image denoising processing.
Further, the process of dividing processing are as follows:
Three position sensing figures on two dimensional code are detected, determine two dimension code position;
Vacancy filling is carried out to two dimensional code, makes two dimensional code in same connected domain;
Edge detection is carried out, two dimensional code is extracted.
Further, correction process process is
Detect two dimensional code key point;
Two dimensional code edge fitting and the fitting of two dimensional code veneer are carried out according to two dimensional code key point;
It determines updating formula, and two dimensional code is corrected by updating formula, obtain the two dimensional code of standard shape.
In conjunction with Fig. 2, the present invention also provides a kind of two-dimension code recognition devices, comprising:
Two cameras, for acquiring two-dimension code image simultaneously from different perspectives;
Image pre-processing module is pre-processed for two two-dimension code images to acquisition;
Two dimensional code dividing processing module is extracted for carrying out two dimensional code dividing processing to pretreated two-dimension code imageTwo dimensional code out;
Two dimensional code correction module, for according to the edge distorting event of two two dimensional codes to two dimensional code locating for veneer carry outDetermine and calculate, obtain updating formula, image rectification is carried out to two dimensional code using updating formula, is reduced to standard shapeTwo dimensional code;
Two dimensional code complementation module, for recording two standard shape two dimensional code code area information, according to one of codingBlack pixel carries out supplement process to another code area in area, obtains can recognize two dimensional code;
Two-dimensional barcode information extraction module, for extracting the two-dimensional barcode information in recognizable two dimensional code.
The pretreatment includes image gray processing processing, image binaryzation processing and image denoising processing.
The segmentation process of the two dimensional code dividing processing module are as follows:
Three position sensing figures on two dimensional code are detected, determine two dimension code position;
Vacancy filling is carried out to two dimensional code, makes two dimensional code in same connected domain;
Edge detection is finally carried out, two dimensional code is extracted.
The present invention is further explained in the light of specific embodiments.
Embodiment
As shown in Figure 1, the two-dimensional code identification method of the present embodiment the following steps are included:
The first step acquires two-dimension code image
It is shot from different perspectives using two cameras and two dimensional code is shot, two cameras difference of the present embodimentAt positive and negative 20 degree away from two dimensional code plane normal.
Second step, pretreatment
After obtaining the picture containing two dimensional code, image preprocessing is carried out to two-dimension code image, image preprocessing includesImage gray processing processing, image binaryzation processing and image denoising processing.
Image containing two dimensional code is shown in the form of color image.However, actual two-dimension code area is only handed over by the depthWrong module composition, color image do not have special significance.The meter that image after gray processing and binary conversion treatment needsEvaluation time and calculating space are less, can greatly improve processing speed.Image denoising processing can reduce picture noise, make two dimensionCode picture becomes more smooth, can be significantly convenient for below to the dividing processing of two dimensional code and to the recognition work of two dimensional codeEnhance the recognition capability to two dimensional code.
Image preprocessing is prepared for the extraction work of two dimensional code, which is conducive to improve the processing speed of deviceDegree and enhancement device are to the recognition capability of two dimensional code.
Third step, dividing processing
Two dimensional code dividing processing is carried out to pretreated two-dimension code image, is mainly comprised the processes of
Three position sensing figures on two dimensional code are detected first, determine two dimension code position;
Then vacancy filling is carried out to two dimensional code, makes two dimensional code in same connected domain;
Edge detection is finally carried out, two dimensional code is extracted.
The effect of dividing processing is to be split two dimensional code from picture according to the edge of two dimensional code, is directed to convenient for subsequentTwo dimensional code is handled.
4th step, correction process
After two dimensional code is opened in acquisition two, first determine whether two dimensional code has the appearance of the case where torsional deformation, if two-dimentionalCode is not rectangle, then processing will be corrected to two dimensional code, according to the edge distorting event of two two-dimension code images to twoVeneer locating for dimension code is determined and is calculated, and updating formula is obtained further according to calculated result, using formula to two dimensional codeImage rectification is carried out, the two dimensional code of specification is reduced to.Detailed process is as follows:
Firstly, the key point of two two dimensional codes of detection, key point includes two dimensional code edge angle point and position sensing figure anglePoint.
The detection method of two dimensional code edge angle point are as follows: because scalloping makes the scaling of image in 2 D code each sectionIt changes, the distance between three position sensing figures change ratio also can not be identical, finds out and visits at a distance of longest two positionsThe connection of mapping shape is in alignment, and finds out the slope of straight line, with the straight line parallel two straight lines and vertical two directlyLine approaches two-dimension code area from four direction respectively, until straight line is tangent with two dimensional code, finds out four straight lines and two-dimension code areaPoint of contact, as two dimensional code edge angle point.
The detection method of position sensing figure angle point are as follows: using the center of position sensing figure as seed point, increased using regionLong algorithm finds out the connection threshold where the position sensing centre of figure, and enables the region for white;Then using central point as seedPoint finds out the connection threshold where the position sensing centre of figure using region growing algorithm, and enabling the region is black;Again withCentral point is seed point, using region growing algorithm, finds out the connection threshold where the position sensing centre of figure to get to onePosition sensing figure to get arrive position sensing figure angle point.
Then carry out two dimensional code edge fitting, above oneself found two dimensional code key point, then intended with least square method curveThe key point in each edge is closed, edge fitting line is obtained, two dimensional code edge extracting is gone out.
Two dimensional code veneer fitting is carried out again, includes: by the key point on above-mentioned two groups of distortion two dimensional codes that we find outTwo dimensional code edge angle point, the matched curve of the angle point and four edges of position sensing figure fit two dimensional code veneer shape.
Updating formula is determined again, and the image that we will obtain is known as ideograph, first with the method for integral, finds out fitting patchOn face on same side the adjacent key point of every two distance, it is cumulative to obtain the length of four matched curves, since two dimensional code is sent outRaw non-linear deformation, the deformation size of each edge is not identical, we are using the mean value of four edges as the side length of ideograph, according to reasonThe side length L for thinking figure finds out the coefficient of dilatation k of distortion two dimensional code each edget=L/Lt, t=1,2,3,4.LtFor four matched curvesLength;The key point on veneer will be fitted as the corresponding points of ideograph, the key point found out on fitting veneer is bent in fittingThe length on each side of distance on face, the corresponding points on corresponding ideograph are found out by coefficient of dilatation again.It is assumed that the point in ideograph(x ', y '), respective coordinates are (x, y) in fitting veneer, the mapping relations between (x, y) and (x ', y ') are as follows:It is image abscissa maximum value that wherein i, which takes 0 to m, j to take 0 to n, m, and n is ordinate maximum value, kFor variable, m >=k >=i, (x, y) is the point being fitted on veneer, uij、vijFor the correction parameter of coordinate points (x, y), it is based on this n pairsCorresponding point data least squares identification goes out the correction parameter in formula, so that it is determined that updating formula.
Two dimensional code is corrected finally by updating formula, coordinate mapping is carried out to two dimensional code according to the shape of two dimensional code veneer and is becomeIt changes, two dimensional code key point is first corrected to normal place, then correct two dimensional code other parts again.
Above-mentioned correction process allows the present invention to restore preferable image simultaneously in the case where two dimensional code is distorted deformationExtract two-dimensional barcode information.
5th step, supplement process
Two standard shape two dimensional code code area information are recorded, according to pixel black in one of code area to anotherCode area carries out supplement process, obtains can recognize two dimensional code;Assuming that the even phenomenon of uneven illumination occurs in two-dimension code image, occur anti-Bright spot from different perspectives shoots two dimensional code by two cameras, acquires the two dimensional code of two different illumination patternsPicture goes to fill up the picture using the two-dimensional barcode information at the same position of another two-dimension code image, obtain a quality compared withGood identifiable two-dimension code image.The processing step goes back apparatus of the present invention when uneven illumination occurs for two dimensional codeOriginal goes out preferable image and extracts two-dimensional barcode information.
6th step extracts two-dimensional barcode information from recognizable two dimensional code obtained in the previous step.