CN113850100A - Method and device for correcting two-dimensional code - Google Patents

Method and device for correcting two-dimensional code Download PDF

Info

Publication number
CN113850100A
CN113850100A CN202111124034.8A CN202111124034A CN113850100A CN 113850100 A CN113850100 A CN 113850100A CN 202111124034 A CN202111124034 A CN 202111124034A CN 113850100 A CN113850100 A CN 113850100A
Authority
CN
China
Prior art keywords
dimensional code
pixel point
offset
boundary line
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111124034.8A
Other languages
Chinese (zh)
Other versions
CN113850100B (en
Inventor
周彬
李云廷
周海涛
万其明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN202111124034.8A priority Critical patent/CN113850100B/en
Publication of CN113850100A publication Critical patent/CN113850100A/en
Application granted granted Critical
Publication of CN113850100B publication Critical patent/CN113850100B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • G06K7/1473Methods for optical code recognition the method including quality enhancement steps error correction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/80Geometric correction

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Electromagnetism (AREA)
  • Toxicology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Quality & Reliability (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Processing (AREA)

Abstract

The application provides a method and a device for correcting a two-dimensional code, which relate to the technical field of images, can generate a corrected two-dimensional code image through the coordinate offset of a predicted image pixel, and have universality for different distortion types. The scheme is as follows: preprocessing the first two-dimensional code to obtain a second two-dimensional code after rotation; when the outline of the second two-dimensional code is a non-rectangular outline, calculating the first coordinate offset of each pixel point corresponding to the rectangular two-dimensional code; obtaining a third two-dimensional code according to the first coordinate offset; predicting a second coordinate offset of each pixel point corresponding to a standard pixel point in a standard two-dimensional code sampling grid by using a deep learning full convolution network; and obtaining a fourth two-dimensional code according to the second coordinate offset of each pixel point. The embodiment of the application is used for solving the problem of identifying the fold distortion two-dimensional code generated on the surface of the non-rigid body such as an express package, has stronger robustness on factors such as local fouling and positioning pattern loss, and has better universality on different types of distortion.

Description

Method and device for correcting two-dimensional code
Technical Field
The embodiment of the application relates to the technical field of images, in particular to a method and a device for correcting a two-dimensional code.
Background
In some complex scenes for reading the two-dimensional code, due to the material and shape of the surface of the object where the two-dimensional code is located, all code points of the two-dimensional code may not be on the same plane, resulting in obvious image distortion of the imaging result. For example, when a two-dimensional code on a single side of an express delivery is wrinkled, automatic identification of the two-dimensional code is seriously affected, and an accurate result may be difficult to obtain by a conventional code reading scheme.
In the current two-dimensional code correction technology, the traditional image processing algorithm is mostly adopted to extract the primary image characteristics such as the edge and the angular point of a two-dimensional code area, a polynomial function is utilized to fit an edge curve, and the mapping relation between a distorted image and a non-distorted template image is established. However, the method for determining an undistorted template image according to the mapping relationship is too dependent on the template features because the two-dimensional code image itself lacks sufficient key point information, for example, the method is suitable for the locator and correction pattern of a Quick Response (QR) code, while the template features need to be redesigned for a Data Matrix (DM) code or other code systems, and there are multiple versions of each code system, and the method is not compatible with the multiple versions, so the method is not universal.
Disclosure of Invention
The embodiment of the application provides a method and a device for correcting a two-dimensional code, which can generate a corrected two-dimensional code image through the coordinate offset of a predicted image pixel without depending on the mapping relation between a distorted image and an undistorted template image, and have high feasibility and universality for different distortion types.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
in a first aspect, a method for correcting a two-dimensional code is provided, including: the electronic equipment preprocesses the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated; when the electronic equipment determines that the outline of the second two-dimensional code is a non-rectangular outline, determining a first coordinate offset of each pixel point in the second two-dimensional code relative to a pixel point, corresponding to each pixel point, in the rectangular two-dimensional code; the first coordinate offset of each pixel point in the second two-dimensional code comprises a first horizontal offset and a first vertical offset; the electronic equipment performs interpolation operation on the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code; predicting the coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing a deep learning full convolution network; and the electronic equipment corrects the position of each pixel point of the third two-dimensional code according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code. The standard sampling grid herein may include a plurality of grids, and the plurality of grids are uniformly distributed. Each grid can be understood as a code point, i.e. the standard sampling grid can be a two-dimensional code with uniformly distributed code points.
The application predicts the pixel coordinate offset based on preprocessing and depth learning to realize sampling grid homogenization correction, a complex distortion model of a distortion-undistorted template image is not required to be established, dependence on information such as local feature points and locators of the distortion image can be avoided, the coordinate offset of each pixel point of an image pixel of a distortion two-dimensional code relative to an ideal position is predicted, the coordinate offset of the pixel point of local distortion in the distortion two-dimensional code is included, a corrected two-dimensional code image can be generated, local distortion of the two-dimensional code can be eliminated, two-dimensional codes of different code systems are obtained, and different distortion types also have good universality.
In one possible design, the electronic device performs preprocessing on the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated and corrected, including: the electronic equipment determines position information of four corner points of the first two-dimensional code; the electronic equipment obtains an affine transformation matrix according to the position information of the four corner points of the first two-dimensional code and the position information of the four corner points of the preset standard rectangle; the electronic equipment obtains position information of each pixel point in the first two-dimensional code after transformation according to the position information of each pixel point in the first two-dimensional code and the affine transformation matrix; and the electronic equipment moves each pixel point in the first two-dimensional code to a position corresponding to the position information after each pixel point is converted, so that the second two-dimensional code after being rotated is obtained. In this way, for the two-dimensional code with distortion, for example, the two-dimensional code obtained by shooting obliquely by the user, the corrected two-dimensional code can be obtained through affine transformation matrix calculation, so as to further correct the corrected two-dimensional code.
In one possible design, the first coordinate offset includes a first vertical offset, and determining the first coordinate offset of each pixel point in the second two-dimensional code with respect to the pixel point in the rectangular two-dimensional code corresponding to each pixel point includes: the electronic equipment determines a first straight line between two corner points of a first boundary line in the second two-dimensional code, and determines a second straight line between two corner points except the two corner points of the first boundary line; the first boundary line is not a straight line, and in the second two-dimensional code, a boundary line between two corner points except two corner points of the first boundary line is a second boundary line; for any pixel point in the second two-dimensional code, the electronic equipment determines a first pixel point on the first boundary line, which has the same abscissa as that of the any pixel point, and determines a second pixel point on the second boundary line, which has the same abscissa as that of the any pixel point; the electronic equipment determines a first distance from the first pixel point to the first straight line and determines a second distance from the second pixel point to the second straight line; the electronic equipment determines a first vertical offset of any pixel point between the first boundary line and the second boundary line according to the first distance, the second distance, the vertical coordinate of any pixel point and the height between the first straight line and the second straight line.
When the outline of the second two-dimensional code is not a rectangular outline, for example, when a boundary line of a curve exists, the pixel point can be moved into the rectangular outline by determining the vertical offset of the pixel point, and similarly, on the basis of determining the horizontal offset of the pixel point, the rectangular outline can be corrected.
In one possible design, predicting a second coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by using the deep learning full convolution network includes: predicting a second horizontal offset of the pixel points on each row in the third two-dimensional code relative to the pixel points in the standard sampling grid and a second vertical offset of the pixel points on each row relative to the pixel points in the standard sampling grid by using a deep learning full convolution network; the second horizontal offset of each pixel point on the same column is the same, and the second vertical offset of each pixel point on the same row is the same; the second coordinate offset corresponding to each pixel point in the third two-dimensional code comprises a second vertical offset and a second horizontal offset corresponding to each pixel point in the third two-dimensional code. When the third two-dimensional code is distorted, the positions of the pixel points in the two-dimensional code have horizontal and vertical offsets relative to the standard sampling grid, the offset of each pixel point relative to the pixel points in the standard sampling grid can be predicted through the deep learning full convolution network, and the position of each pixel point can be moved back to the position corresponding to the pixel point in the standard sampling network according to the offset. When each grid is understood as a code point, a two-dimensional code with uniformly distributed code points can be obtained.
The pixel coordinate offset of the two-dimensional code (the third two-dimensional code) after the contour correction can be predicted based on the deep learning full convolution network, so that sampling grid homogenization correction is realized, and local distortion of the two-dimensional code is eliminated. Therefore, the coordinate offset of each pixel point in the distorted two-dimensional code relative to the ideal position can be easily learned by using a neural network without depending on information such as local feature points, positioning graphs and the like in the prior art. Therefore, the method and the device have strong robustness for factors such as local contamination of the two-dimensional code and positioning pattern loss, and have good universality for different types of distortion.
In one possible design, the method further includes: when the electronic equipment determines that the outline of the second two-dimensional code is a rectangular outline, the electronic equipment directly predicts the third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by using a deep learning full convolution network; and the electronic equipment corrects the position of each pixel point in the second two-dimensional code according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code to obtain a fourth two-dimensional code.
In a second aspect, an electronic device is provided, comprising: the preprocessing unit is used for preprocessing the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated; a contour correction unit to: when the outline of the second two-dimensional code is determined to be a non-rectangular outline, determining the movable offset of each pixel point in the second two-dimensional code relative to the first coordinate of the pixel point corresponding to each pixel point in the rectangular two-dimensional code; the first coordinate offset of each pixel point in the second two-dimensional code comprises a first horizontal offset and a first vertical offset; performing interpolation operation of the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code; the grid uniformization unit is used for predicting the coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing a deep learning full convolution network; and the grid homogenizing unit is also used for correcting the position of each pixel point of the third two-dimensional code according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code.
The advantageous effects of the second aspect can be seen from the description of the first aspect.
In one possible design, the preprocessing unit is configured to: determining position information of four corner points of the first two-dimensional code; obtaining an affine transformation matrix according to the position information of the four corner points of the first two-dimensional code and the position information of the four corner points of the preset standard rectangle; obtaining position information of each pixel point in the first two-dimensional code after transformation according to the position information of each pixel point in the first two-dimensional code and the affine transformation matrix; and moving each pixel point in the first two-dimensional code to a position corresponding to the position information after each pixel point is converted, so as to obtain the second two-dimensional code after being rotated.
In one possible design, the first coordinate offset comprises a first vertical offset, and the contour correction unit is to: determining a first straight line between two corner points of a first boundary line in a second two-dimensional code, and determining a second straight line between two corner points except the two corner points of the first boundary line; the first boundary line is not a straight line, and in the second two-dimensional code, a boundary line between two corner points except two corner points of the first boundary line is a second boundary line; for any pixel point in the second two-dimensional code, determining a first pixel point on the first boundary line, which has the same abscissa as that of the any pixel point, and determining a second pixel point on the second boundary line, which has the same abscissa as that of the any pixel point; determining a first distance from the first pixel point to the first straight line, and determining a second distance from the second pixel point to the second straight line; and determining a second vertical offset of any pixel point between the first boundary line and the second boundary line according to the first distance, the second distance, the vertical coordinate of any pixel point and the height between the first straight line and the second straight line.
In one possible design, the grid uniformizing unit is configured to: predicting a second horizontal offset of the pixel point on each row in the third two-dimensional code corresponding to the pixel point on each row in the standard sampling grid and a second vertical offset of the pixel point on each row corresponding to the pixel point on each row in the standard sampling grid by using a deep learning full convolution network; the second horizontal offset of each pixel point on the same column is the same, and the second vertical offset of each pixel point on the same row is the same; the second coordinate offset corresponding to each pixel point in the third two-dimensional code comprises a second vertical offset and a second horizontal offset corresponding to each pixel point in the third two-dimensional code.
In a possible design, the contour correcting unit is further configured to determine that the contour of the second two-dimensional code is a rectangular contour, and the grid uniformizing unit is further configured to: predicting the third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing a deep learning full convolution network; and correcting the position of each pixel point of the second two-dimensional code according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code to obtain a fourth two-dimensional code.
In a third aspect, an electronic device is provided, which includes: a memory and a processor. The memory is coupled to the processor. The memory is for storing computer program code comprising computer instructions. The transceiver is used for receiving data and transmitting data. The computer instructions, when executed by a processor, cause the cloud center to perform any one of the methods of correcting a two-dimensional code as provided by the first aspect or its corresponding possible design.
In a fourth aspect, the present application provides a chip system, which is applied to a cloud center. The system-on-chip includes one or more interface circuits, and one or more processors. The interface circuit and the processor are interconnected through a line; the interface circuit is to receive a signal from a memory of the cloud center and to send the signal to the processor, the signal including computer instructions stored in the memory. When the processor executes the computer instructions, the cloud center performs the method of correcting a two-dimensional code as provided by the first aspect or its respective possible design.
In a fifth aspect, the present application provides a computer readable storage medium comprising computer instructions which, when run on a computer, cause the computer to perform a method as provided by the first aspect or a corresponding possible design thereof.
In a sixth aspect, the present application provides a computer program product comprising computer instructions which, when run on a computer, cause the computer to perform the method as provided by the first aspect or its corresponding possible design.
It is understood that any electronic device, chip system, computer readable storage medium or computer program product provided above can be applied to the corresponding method provided above, and therefore, the beneficial effects achieved by the method can refer to the beneficial effects in the corresponding method, and are not described herein again.
These and other aspects of the present application will be more readily apparent from the following description.
Drawings
Fig. 1 is a schematic diagram of a code point in a two-dimensional code according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of a terminal capable of processing an image of a two-dimensional code according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of a deformed two-dimensional code according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a method for correcting a two-dimensional code according to an embodiment of the present disclosure;
fig. 5 is a schematic diagram illustrating a deformed two-dimensional code being rotated according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram illustrating a two-dimensional code implementing contour correction according to an embodiment of the present disclosure;
fig. 7 is a schematic diagram illustrating preprocessing, contour correction, and grid uniformity correction of a distorted two-dimensional code image according to an embodiment of the present disclosure;
fig. 8 is a schematic diagram illustrating a two-dimensional code implementing grid homogenization according to an embodiment of the present application;
fig. 9 is a schematic diagram illustrating an implementation of correcting a deformed two-dimensional code according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For ease of understanding, examples are given in part to illustrate concepts related to embodiments of the present application. As follows:
angular point detection: and obtaining the position information of four corner points of the two-dimensional code area from the original image.
And (3) contour correction: in the present application, a process of correcting a two-dimensional code having an irregular outline shape to a standard rectangular area can be understood.
Sampling grid: and the two-dimensional code is divided into grids according to the minimum unit module so as to conveniently obtain the pixel value of each minimum unit module. For example, in the present application, the minimum unit module may be understood as a code point in a two-dimensional code.
Code point: the minimum unit module in the two-dimensional code may be composed of a plurality of pixel points, and the color values of the pixel points in the same minimum unit module are the same, for example, black or white. As shown in fig. 1, a black code point formed by black pixel points in an image of a two-dimensional code is shown. Similarly, a code dot that has the same size as the black code dot and is white in color may be referred to as a white code dot.
When the two-dimensional code is obtained by scanning, pixel values can be sampled for each code point of the two-dimensional code, so that a bitmap is obtained and decoded. For example, the black code point is marked as 1, the white code point is marked as 0, a plurality of black code points and a plurality of white code points in the two-dimensional code can be sampled to obtain a bit map of the two-dimensional code, and a result obtained after reading the two-dimensional code, such as information of one picture or one link, is obtained by decoding the bit map.
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality" means two or more than two.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified.
At present, a polynomial function is used for fitting an edge curve of a two-dimensional code and establishing a mapping relation from a distorted image to a normal template image, so that the corrected two-dimensional code can be determined. However, this method is too dependent on the designed normal template image, and cannot be compatible with various code systems and various version numbers of the code systems. In addition, the method is performed under the assumption that the distortion of the two-dimensional code is globally uniform, that is, the rule of the distortion of the two-dimensional code is consistent, and for example, the distortion rule of a part of the two-dimensional code can be known from the distortion rule of the other part of the two-dimensional code. However, this method is not suitable for some complicated distortion types of two-dimensional codes, and a higher-order function is required to perform fitting. Moreover, such methods only use a small number of local features of the distorted image and do not use much local information, and therefore, the method cannot handle fold distortion that is characteristic of local distortion.
Although the distortion correction is carried out by utilizing the deep learning at present, the distortion image of the two-dimensional code is input into the deep learning network to directly obtain the normal image of the two-dimensional code, the end-to-end scheme (inputting the distortion image and outputting the normal image) has a plurality of difficulties in implementation, and the method is very dependent on the pre-designed training sample and cannot adapt to the distortion type which may appear in practice.
Therefore, the method for correcting the two-dimensional code can be applied to a scene of correcting a distorted image when the two-dimensional code is distorted. For example, the problem of two-dimensional code identification of fold distortion generated on the surface of a non-rigid body such as an express parcel is solved. Considering that the conventional method can only utilize primary image features such as corners and edges of a distorted two-dimensional code or a positioning graph of the code to perform relatively primary global linear correction and cannot be suitable for various code systems and various version numbers of the code systems, the application provides a method for correcting the two-dimensional code, which can correct the distorted two-dimensional code into a normal two-dimensional code based on contour correction and deep learning sampling grid homogenization correction, and specifically comprises the following steps: preprocessing the first two-dimensional code with distortion to obtain a second two-dimensional code after the first two-dimensional code is rotated; when the outline of the second two-dimensional code is determined to be a non-rectangular outline, utilizing the first coordinate offset of each pixel point in the second two-dimensional code relative to the pixel point of each pixel point in the rectangular two-dimensional code, and performing interpolation operation on the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code; and predicting a second coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing the deep learning full convolution network, and correcting the position of each pixel point of the third two-dimensional code according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code. The fourth two-dimensional code can be understood as a corrected normal two-dimensional code.
According to the method, the sampling grid homogenization correction is realized by predicting the pixel coordinate offset based on preprocessing and deep learning, a complex distortion model of a distortion-undistorted image does not need to be established, dependence on information such as local feature points and locators of the distortion image can be avoided, and relatively speaking, the method for generating the corrected two-dimensional code image through the coordinate offset of the predicted image pixel is high in feasibility, not only can the local distortion of the two-dimensional code be eliminated, but also has good universality on two-dimensional codes of different code systems or two-dimensional codes of different distortion types.
The embodiment of the present application as shown in fig. 2 is applicable to various electronic devices having related functions of processing two-dimensional codes. For example, the electronic device is a smartphone with a camera shooting function, and when the distorted two-dimensional code is obtained by shooting, the distorted two-dimensional code can be corrected to obtain a corrected two-dimensional code, so that a link or an event and the like corresponding to the corrected two-dimensional code can be processed according to the corrected two-dimensional code. In addition, the embodiments of the present application can also be applied to a two-dimensional code (POS) terminal or a Personal Computer (PC) terminal having an intelligent processing function, and the like. The application is not limited.
For example, as shown in fig. 3, the two-dimensional code photographed by the electronic device may be a deformed two-dimensional code obtained by oblique photographing, and the deformed two-dimensional code may be corrected by the application to obtain a normal image of the two-dimensional code.
The following describes a method for correcting a two-dimensional code provided in the present application.
The present application provides a method for correcting a two-dimensional code, as shown in fig. 4, the method includes:
401. the electronic device determines position information of four corner points of the first two-dimensional code.
When the electronic equipment obtains the first two-dimensional code and determines that the first two-dimensional code is a distorted two-dimensional code, the first two-dimensional code needs to be corrected, and position information of four corner points in the first two-dimensional code can be detected firstly.
Exemplarily, because express delivery parcel surface has the fold, electronic equipment scans the two-dimensional code and obtains first two-dimensional code, as shown in fig. 3, when detecting first two-dimensional code and the contrast of predetermined standard two-dimensional code, when having the distortion, electronic equipment confirms that need rectify first two-dimensional code. At this time, the electronic device may first detect position information of four corner points in the first two-dimensional code, where the position information may be understood as coordinate values of the four corner points of the photographed static two-dimensional code.
The algorithm for detecting the corner may be, for example, a gray-scale image-based corner detection algorithm, a binary image-based corner detection algorithm, a contour curve-based corner detection algorithm, and the like, which is not limited in the present application.
402. The electronic equipment preprocesses the first two-dimensional code according to the position information of the four corner points of the first two-dimensional code to obtain a second two-dimensional code obtained by rotating the first two-dimensional code.
It can be understood that the first two-dimensional code shown in fig. 3 can be understood as a code that a user holds the electronic device to shoot obliquely, and when the first two-dimensional code is corrected, the first two-dimensional code may be corrected continuously after being corrected by rotating.
In some embodiments, the electronic device may obtain the affine transformation matrix according to the position information of the four corner points of the first two-dimensional code and the position information of the four corner points of the preset standard rectangle. The preset standard rectangle can be understood as a profile of the two-dimensional code when the two-dimensional code is rotated, and the position information of four corner points of the preset standard rectangle can be preset.
The affine transformation matrix can be understood as a transformation matrix obtained by performing affine transformation according to the position information of the four corner points of the first two-dimensional code and the position information of the four corner points of the preset standard rectangle.
Then, the electronic device can obtain the position information of each pixel point in the first two-dimensional code after transformation according to the position information of each pixel point in the first two-dimensional code and the affine transformation matrix.
For example, the coordinate of each pixel in the first two-dimensional code may be multiplied by the affine transformation matrix to obtain a rotated coordinate of each pixel in the first two-dimensional code, that is, the position information of each pixel after transformation.
Therefore, the electronic equipment can move each pixel point in the first two-dimensional code to the position corresponding to the position information after each pixel point is converted, and the second two-dimensional code after being rotated is obtained.
The second two-dimensional code can be understood as a two-dimensional code region of interest (ROI) with normalized size.
403. The electronic device determines whether the outline of the second two-dimensional code is a rectangular outline, and if the electronic device determines that the outline of the second two-dimensional code is a non-rectangular outline, the step 404 is executed; if the electronic device determines that the outline of the second two-dimensional code is a rectangular outline, step 406 is performed.
For example, after the first two-dimensional code shown in fig. 3 is rotated, an image of the second two-dimensional code may be obtained as shown in fig. 5. The second two-dimensional code may be a two-dimensional code whose outline is non-rectangular as shown in the second two-dimensional code (a) in fig. 5, or may be a two-dimensional code whose outline is rectangular as shown in the second two-dimensional code (b) in fig. 5.
That is, when the second two-dimensional code after being rotated is obtained, it can be further determined whether the outline of the second two-dimensional code is a rectangular outline, because the distorted two-dimensional code generated by the wrinkle may have a curved boundary line.
For example, the positions of four boundary lines of the second two-dimensional code can be obtained by a detection method for detecting an edge contour of an image, and then whether the four boundary lines of the second two-dimensional code are all straight lines is determined, so as to further determine whether the contour of the two-dimensional code is a rectangular contour. For a boundary line of the second two-dimensional code, optionally selecting two pixel points 1 and 2 with longer distances on the boundary line, and optionally selecting one pixel point 3 between the pixel point 1 and the pixel point 2 on the boundary line to obtain a linear position between the pixel point 1 and the pixel point 2, and then judging whether a coordinate of the pixel point 3 is on the linear position, if the coordinate of the pixel point 3 is determined to be on the linear position, the boundary line can be considered as a linear line; if the coordinate of the pixel point 3 is determined not to be on the straight line, the boundary line can be considered not to be a straight line, or the boundary line can be considered to be a curve.
When it is determined that the boundary line which is a curve exists among the four boundary lines, it is determined that the outline of the second two-dimensional code is not a rectangular outline.
404. And the electronic equipment carries out contour correction on the second two-dimensional code to obtain a third two-dimensional code after contour correction.
In some embodiments, if the second two-dimensional code is a two-dimensional code having a curved boundary line as shown in the second two-dimensional code (a) in fig. 5, the electronic device needs to perform contour correction on the second two-dimensional code to obtain a corrected two-dimensional code having a rectangular contour, that is, a third two-dimensional code in the present application.
In some embodiments, when the electronic device determines that the contour of the second two-dimensional code is not a rectangular contour according to the position information of the four corner points, determining a first coordinate offset of each pixel point in the second two-dimensional code relative to a pixel point corresponding to each pixel point in the rectangular two-dimensional code; the first coordinate offset of each pixel point in the second two-dimensional code comprises a first horizontal offset and a first vertical offset; and the electronic equipment performs interpolation operation on the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code. The third two-dimensional code is the two-dimensional code after the contour correction is carried out on the second two-dimensional code.
For example, a first vertical offset of each pixel point in the second two-dimensional code may be determined first, a first difference operation may be performed on each pixel point in the second two-dimensional code in the vertical direction, a first horizontal offset of each pixel point in the second two-dimensional code may be determined, a second difference operation may be performed on each pixel point in the second two-dimensional code, and a third two-dimensional code whose outline is corrected to be rectangular may be obtained finally.
Specifically, when the first coordinate offset includes the first vertical offset, determining the first coordinate offset of each pixel point in the second two-dimensional code in the outline of the second two-dimensional code may include:
as shown in fig. 6, the electronic device determines a first straight line 62 between two corner points of the first border line 61 in the second two-dimensional code, and determines a second straight line 63 between two corner points other than the two corner points of the first border line 61; the first boundary line 61 is not a straight line, and in the second two-dimensional code, a boundary line between two corner points other than two corner points of the first boundary line 61 is a second boundary line 64.
When the first boundary line and the second boundary line are in the vertical direction, for any pixel point P (x, y) in the second two-dimensional code, the electronic device determines a first pixel point P1(x1, y1) on the first boundary line 61, which is the same as the abscissa x of any pixel point P (x, y), and determines a second pixel point P2(x2, y2) on the second boundary line 64, which is the same as the abscissa x of any pixel point P (x, y); x-x 1-x 2;
determining a first distance delta Y1 from the first pixel point P (x, Y) to the first straight line 62, and determining a second distance delta Y2 from the second pixel point P2(x2, Y2) to the second straight line 63;
and determining a first vertical offset deltay of any pixel point P (x, Y) between the first boundary line 61 and the second boundary line 64 according to the first distance deltay 1, the second distance deltay 2, the ordinate Y of any pixel point and the height H between the first straight line and the second straight line.
At this time, the first vertical shift amount Δ Y may be expressed as:
Figure BDA0003278185130000071
it will be appreciated that the value of Δ Y may be positive or negative. If the specification is positive, it means that any pixel needs to be shifted upward, and if the specification is negative, it means that any pixel needs to be shifted downward.
Although how to determine the first vertical offset is illustrated by any pixel point P (x, Y), it should be understood that each pixel point in the second two-dimensional code may obtain the first vertical offset corresponding to each pixel point by using a similar algorithm, so as to perform a first interpolation operation on each pixel point in the second two-dimensional code according to the first vertical offset, for example, after the first interpolation operation, a coordinate of any pixel point is changed from P (x, Y) to P (x, Y + Δ Y).
Similarly to the interpolation calculation based on the first vertical offset, if at least one boundary line of the third boundary line 65 and the fourth boundary line 66 of the second two-dimensional code is not a straight line, the first horizontal offset of each pixel point in the second two-dimensional code may be calculated by calculating the first vertical offset.
For example, the first horizontal offset may be expressed as:
Figure BDA0003278185130000081
where Δ X represents a first horizontal offset of any pixel, W represents a third straight line between two corner points of the third boundary line 65 and a width between a fourth straight line between two corner points of the fourth boundary line 66, Δ X1 represents a third distance from a third pixel P3(X3, y3) on the third boundary line 65, which has the same vertical coordinate as the first pixel P (X, y), to the third straight line, and Δ X2 represents a third distance from a fourth pixel P4(X4, y4) on the fourth boundary line 66, which has the same vertical coordinate as the first pixel P (X, y), to the fourth straight line, where y3 is y 4.
It is understood that the value of Δ X may be positive or negative. If the specification is positive, it means that any pixel needs to be shifted to the left, and if negative, it means that the first pixel needs to be shifted to the right.
Although how to determine the first horizontal offset is illustrated by any pixel point P (X, Y), it should be understood that each pixel point in the second two-dimensional code may obtain the first horizontal offset corresponding to each pixel point by using a similar algorithm, so as to perform a second interpolation operation on each pixel point in the second two-dimensional code according to the first horizontal offset, for example, after the second interpolation operation, a coordinate of any pixel point is changed from P (X, Y + Δ Y) to P (X + Δ X, Y + Δ Y).
After the first interpolation operation of the pixel is performed, a third two-dimensional code can be obtained, as shown in (a) of fig. 7.
405. And the electronic equipment performs grid homogenization correction on the third two-dimensional code by using the deep learning full convolution network to obtain a corrected fourth two-dimensional code.
As can be seen from the third two-dimensional code shown in fig. 7 (a), the two-dimensional code boundary blank region on the right side of the third two-dimensional code is narrow, the two-dimensional code boundary blank region on the left side of the third two-dimensional code is wide, and the width of each code point in the third two-dimensional code is not uniform, and it can be considered that the grid of the third two-dimensional code is not uniform. A grid is here understood to be a code point. That is, the code points inside the third two-dimensional code are not uniformly distributed, and if the pixel value sampling is directly performed on the third two-dimensional code, an erroneous bit map may be obtained. Therefore, the grid homogenization correction can be performed on the third two-dimensional code by utilizing the deep learning full convolution network.
In some embodiments, a standard sampling grid may be preset in the electronic device, where the standard sampling grid includes a plurality of grids that are uniformly distributed, and when each grid is understood as one code point, the standard sampling grid may be understood as a two-dimensional code with uniformly distributed code points. Each code point includes a plurality of pixel points. The electronic device may predict a second coordinate offset of each pixel point in the third two-dimensional code with respect to a pixel point in the standard sampling grid corresponding to each pixel point using a deep learning full convolution network, such as UNet. The correspondence here can be understood as one-to-one correspondence between the pixel points in the third two-dimensional code and the pixel points in the standard position in the standard sampling grid. Of course, if the second coordinate offset of any pixel point in the third two-dimensional code is 0, it indicates that any pixel point is already at the standard position. For example, the electronic device may predict, by using the deep learning full convolution network, a second horizontal offset Δ U (x, y) of the pixel point on each column in the third two-dimensional code corresponding to the pixel point on each column in the standard sampling grid, and a second vertical offset Δ V (x, y) of the pixel point on each row corresponding to the pixel point on the standard sampling grid. And the second horizontal offset of each pixel point on the same column is the same, and the second vertical offset of each pixel point on the same row is the same.
That is, the second coordinate offset amount corresponding to each pixel point in the third two-dimensional code includes the second vertical offset amount Δ V (x, y) and the second horizontal offset amount Δ U (x, y) corresponding to each pixel point in the second two-dimensional code.
At this time, the input of the deep learning full convolution network includes the coordinate (x, y) of each pixel point in the third two-dimensional code and the coordinate (x ', y') of each pixel point in the standard sampling grid, and the output may be the coordinate offset of each pixel point in the third two-dimensional code, including the second horizontal offset Δ U (x, y) and the second vertical offset Δ V (x, y).
And then, the electronic equipment corrects the position of each pixel point of the third two-dimensional code according to the coordinate offset corresponding to each pixel point in the third two-dimensional code, so as to obtain a fourth two-dimensional code. The corrected coordinates of each pixel point after correction are obtained according to the coordinates of each pixel point in the third two-dimensional code and the second coordinate offset corresponding to each pixel point, and the two-dimensional code formed by each pixel point under the corrected coordinates is the fourth two-dimensional code. The fourth two-dimensional code can also be understood as a corrected two-dimensional code in which the code points are uniformly distributed after the interpolation calculation is performed on the second two-dimensional code. As shown in fig. 8, in the third two-dimensional code, the pixel points in the column direction are not uniformly distributed, and after the grid homogenization correction, or after the abscissa of the pixel points in the column direction is offset by the first horizontal offset Δ U (x, y), the pixel points in the column direction in the obtained third two-dimensional code are distributed more uniformly, that is, the code points in the fourth two-dimensional code are distributed more uniformly. That is, the fourth two-dimensional code shown in fig. 7 (a) is obtained.
In the embodiment of the application, before the grid homogenization correction is performed by using the deep learning full convolution network, a corresponding training set is established, the training set comprises distorted images of a plurality of two-dimensional codes, the distorted images of the two-dimensional codes are used as input, and coordinate offset vector diagrams (in the horizontal direction and the vertical direction) from the distorted images to undistorted images are used as labels, so that the deep learning full convolution network is obtained through training. Therefore, for the distorted image of the two-dimensional code to be corrected, the depth learning full-convolution network can predict the first coordinate offset (delta U and delta V) from each pixel point in the two-dimensional code to an ideal sampling point, and then the coordinates of each pixel point in the two-dimensional code in the corrected image are obtained by utilizing linear interpolation operation.
406. And the electronic equipment performs grid homogenization correction on the second two-dimensional code with the rectangular outline by using the deep learning full convolution network to obtain a corrected fourth two-dimensional code.
The second two-dimensional code processed in step 406 may be understood as the second two-dimensional code (b) shown in fig. 5 and (b) in fig. 7. That is, the second two-dimensional code (b) can be directly subjected to the grid uniformization correction without performing the contour correction.
Similar to step 405, the electronic device may predict, by using the deep learning full convolution network, a third coordinate offset of each pixel point in the second two-dimensional code with respect to a pixel point of each pixel point in the standard sampling grid, and correct, according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code, a position of each pixel point in the second two-dimensional code, to obtain a fourth two-dimensional code. As shown in fig. 7 (b).
In step 406, referring to step 405, a description of predicting a second coordinate offset of each pixel point in the third two-dimensional code relative to a pixel point of each pixel point in the standard sampling grid by using the deep learning full convolution network may be given to an implementation of predicting a third coordinate offset of each pixel point in the second two-dimensional code relative to a pixel point of each pixel point in the standard sampling grid by using the deep learning full convolution network.
In step 406, the position of each pixel point in the second two-dimensional code is corrected according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code to obtain an implementation manner of the fourth two-dimensional code, and in reference to step 405, the position of each pixel point in the third two-dimensional code is corrected according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a description of the fourth two-dimensional code.
After the fourth two-dimensional code after grid homogenization correction is obtained, the electronic device may sample pixel values of the code points in the fourth two-dimensional code, for example, the electronic device may sample the pixel values at equal intervals (for example, a color value of one pixel point is taken for every n pixel points at intervals, where n is a positive integer greater than 1), obtain a color value of a center pixel point of each code point, obtain a bitmap of the third two-dimensional code or the fifth two-dimensional code, decode the bitmap, and obtain information such as an image or a link after the fourth two-dimensional code is decoded.
Therefore, the second two-dimensional code after being rotated can be obtained by preprocessing the distorted first two-dimensional code. If the outline of the second two-dimensional code is not a rectangular outline, a global correction result that the two-dimensional code area is a standard rectangle, namely a third two-dimensional code, can be obtained through outline correction. Therefore, the traditional correction method relying on local characteristic points in the prior art can be avoided, a complex distortion model of a distorted image-standard image does not need to be established, and a contour correction image can be obtained as a preliminary correction result only through simple pixel offset calculation and interpolation operation.
In addition, the pixel coordinate offset of the two-dimensional code (the third two-dimensional code or the second two-dimensional code (b)) after contour correction can be predicted based on the deep learning full convolution network, so that sampling grid homogenization correction is realized, and local distortion of the two-dimensional code is eliminated. Therefore, the neural network can easily learn the coordinate offset of each pixel point in the distorted two-dimensional code relative to the reference position by using the row and column as the unit on the basis of the initial contour correction result without depending on information such as local feature points, positioning graphs and the like in the prior art. Therefore, the method and the device have strong robustness for factors such as local contamination of the two-dimensional code and positioning pattern loss, and have good universality for different types of distortion.
It will be appreciated that in order to implement the above-described functions, the electronic device comprises corresponding hardware and/or software modules for performing the respective functions. The present application is capable of being implemented in hardware or a combination of hardware and computer software in conjunction with the exemplary algorithm steps described in connection with the embodiments disclosed herein. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, with the embodiment described in connection with the particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In this embodiment, the electronic device may be divided into functional modules according to the above method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module may be implemented in the form of hardware. It should be noted that the division of the modules in this embodiment is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
In the case of dividing each functional module by corresponding functions, fig. 9 shows a possible composition diagram of the electronic device 1100 involved in the above embodiment, and as shown in fig. 9, the electronic device 90 may include: a preprocessing unit 901, a contour correction unit 902, and a mesh uniformization unit 903.
Among other things, the preprocessing unit 901 can be used to support the electronic device 90 in performing the above-described steps 401, 402, etc., and/or other processes for the techniques described herein.
Contour correction unit 902 may be used to support electronic device 90 in performing steps 403, 404, etc., described above, and/or other processes for the techniques described herein.
Grid uniformization unit 903 may be used to support electronic device 90 in performing steps 405, 406, etc., described above, and/or other processes for the techniques described herein.
It should be noted that all relevant contents of each step related to the above method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again.
The electronic device 90 provided by the embodiment is used for executing the method for correcting the two-dimensional code, so that the same effect as the implementation method can be achieved.
Where an integrated unit is employed, the electronic device 90 may include a processing module, a memory module, and a communication module. The processing module may be configured to control and manage an action of the electronic device 90, for example, may be configured to support the electronic device 90 to perform the following: a preprocessing unit 901, a contour correction unit 902, and a mesh uniformization unit 903. The storage module may be used to support the electronic device 90 to store program codes, data and the like, for example, data of a preset standard rectangle, data of a contour rectangle, data of a deep learning full convolution network and the like. The communication module may be used to support communication between the electronic device 90 and other devices, for example, a server for acquiring two-dimensional code information.
The processing module may be a processor or a controller. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. A processor may also be a combination of computing functions, e.g., a combination of one or more microprocessors, a Digital Signal Processing (DSP) and a microprocessor, or the like. The storage module may be a memory. The communication module may specifically be a radio frequency circuit, a bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.
In an embodiment, when the processing module is a processor, the storage module is a memory, and the communication module is a transceiver, the electronic device according to this embodiment may be an electronic device having a structure shown in fig. 10.
Embodiments of the present application also provide an electronic device including one or more processors and one or more memories. The one or more memories are coupled to the one or more processors for storing computer program code comprising computer instructions which, when executed by the one or more processors, cause the electronic device to perform the associated method steps described above to implement the method of correcting two-dimensional codes in the above embodiments.
Embodiments of the present application further provide a computer storage medium, where computer instructions are stored, and when the computer instructions are run on an electronic device, the electronic device is caused to execute the above related method steps to implement the method for correcting a two-dimensional code in the above embodiments.
Embodiments of the present application further provide a computer program product, which when running on a computer, causes the computer to execute the above related steps to implement the method for correcting a two-dimensional code executed by an electronic device in the above embodiments.
In addition, embodiments of the present application also provide an apparatus, which may be specifically a chip, a component or a module, and may include a processor and a memory connected to each other; the memory is used for storing computer execution instructions, and when the device runs, the processor can execute the computer execution instructions stored in the memory, so that the chip can execute the method for correcting the two-dimensional code, which is executed by the electronic device in the above-mentioned method embodiments.
The electronic device, the computer storage medium, the computer program product, or the chip provided in this embodiment are all configured to execute the corresponding method provided above, so that the beneficial effects achieved by the electronic device, the computer storage medium, the computer program product, or the chip may refer to the beneficial effects in the corresponding method provided above, and are not described herein again.
Through the description of the above embodiments, those skilled in the art will understand that, for convenience and simplicity of description, only the division of the above functional modules is used as an example, and in practical applications, the above function distribution may be completed by different functional modules as needed, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical functional division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, that is, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or partially contributed to by the prior art, or all or part of the technical solutions may be embodied in the form of a software product, where the software product is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A method for correcting a two-dimensional code is characterized by comprising the following steps:
the electronic equipment preprocesses the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated;
when the electronic equipment determines that the outline of the second two-dimensional code is a non-rectangular outline, determining a first coordinate offset of each pixel point in the second two-dimensional code relative to a pixel point, corresponding to each pixel point, in the rectangular two-dimensional code; the first coordinate offset comprises a first horizontal offset and a first vertical offset;
the electronic equipment performs interpolation operation on the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code;
the electronic equipment predicts second coordinate offset of each pixel point in the third two-dimensional code relative to the pixel point corresponding to each pixel point in the standard sampling grid by utilizing a deep learning full convolution network;
and the electronic equipment corrects the position of each pixel point in the third two-dimensional code according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code.
2. The method of claim 1, further comprising:
when the electronic equipment determines that the outline of the second two-dimensional code is a rectangular outline, predicting the third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by using a deep learning full convolution network;
and the electronic equipment corrects the position of each pixel point of the second two-dimensional code according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code to obtain a fourth two-dimensional code.
3. The method according to claim 1 or 2, wherein the first coordinate offset comprises the first vertical offset, and the determining the first coordinate offset of each pixel point in the second two-dimensional code with respect to a pixel point in the rectangular two-dimensional code corresponding to each pixel point comprises:
the electronic equipment determines a first straight line between two corner points of a first boundary line in the second two-dimensional code, and determines a second straight line between two corner points except the two corner points of the first boundary line; the first boundary line is not a straight line, and in the second two-dimensional code, a boundary line between two corner points other than two corner points of the first boundary line is a second boundary line;
for any pixel point in the second two-dimensional code, the electronic equipment determines a first pixel point on the first boundary line and having the same abscissa as that of the any pixel point, and determines a second pixel point on the second boundary line and having the same abscissa as that of the any pixel point;
the electronic equipment determines a first distance from the first pixel point to the first straight line and determines a second distance from the second pixel point to the second straight line;
and the electronic equipment determines a second vertical offset of any pixel point between the first boundary line and the second boundary line according to the first distance, the second distance, the vertical coordinate of any pixel point and the height between the first straight line and the second straight line.
4. The method of claim 1, wherein predicting the second coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid with respect to each pixel point by using a deep learning full convolution network comprises:
predicting a second horizontal offset of a pixel point on each column in the third two-dimensional code corresponding to a pixel point in the standard sampling grid relative to a pixel point on each column by using a deep learning full convolution network, and a second vertical offset of a pixel point on each row corresponding to a pixel point in the standard sampling grid relative to a pixel point on each row; the second horizontal offset of each pixel point on the same column is the same, and the second vertical offset of each pixel point on the same row is the same;
and the second coordinate offset corresponding to each pixel point in the third two-dimensional code comprises a second vertical offset and a second horizontal offset corresponding to each pixel point in the third two-dimensional code.
5. The method of claim 1, wherein the electronic device preprocesses the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated, and the method comprises:
the electronic equipment determines position information of four corner points of the first two-dimensional code;
the electronic equipment obtains an affine transformation matrix according to the position information of the four corner points of the first two-dimensional code and the position information of the four corner points of a preset standard rectangle;
the electronic equipment obtains the position information of each pixel point in the first two-dimensional code after transformation according to the position information of each pixel point in the first two-dimensional code and the affine transformation matrix;
and the electronic equipment moves each pixel point in the first two-dimensional code to a position corresponding to the position information after each pixel point is converted, so that the second two-dimensional code after being rotated is obtained.
6. An electronic device, comprising:
the preprocessing unit is used for preprocessing the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated;
the contour correction unit is used for determining a first coordinate offset of each pixel point in the second two-dimensional code relative to a pixel point, corresponding to each pixel point, in the rectangular two-dimensional code when the contour of the second two-dimensional code is determined to be a non-rectangular contour; the first coordinate offset comprises a first horizontal offset and a first vertical offset;
performing interpolation operation of the pixel points in the vertical direction and the horizontal direction according to the first coordinate offset of each pixel point in the second two-dimensional code to obtain a third two-dimensional code;
the grid uniformizing unit is used for: predicting a second coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing a deep learning full convolution network;
and correcting the position of each pixel point in the third two-dimensional code according to the second coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code.
7. The electronic device of claim 6, wherein the contour correction unit is further configured to determine that the contour of the second two-dimensional code is a rectangular contour, and the grid uniformization unit is further configured to:
predicting the third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid relative to each pixel point by utilizing a deep learning full convolution network;
and correcting the position of each pixel point of the second two-dimensional code according to the third coordinate offset corresponding to each pixel point in the second two-dimensional code to obtain a fourth two-dimensional code.
8. The electronic device of claim 6 or 7, wherein the first coordinate offset comprises the first vertical offset, and wherein the contour correction unit is configured to:
determining a first straight line between two corner points of a first boundary line in the second two-dimensional code, and determining a second straight line between two corner points except the two corner points of the first boundary line; the first boundary line is not a straight line, and in the second two-dimensional code, a boundary line between two corner points other than two corner points of the first boundary line is a second boundary line;
for any pixel point in the second two-dimensional code, determining a first pixel point on the first boundary line and having the same abscissa as that of the any pixel point, and determining a second pixel point on the second boundary line and having the same abscissa as that of the any pixel point;
determining a first distance from the first pixel point to the first straight line, and determining a second distance from the second pixel point to the second straight line;
and determining a first vertical offset of any pixel point between the first boundary line and the second boundary line according to the first distance, the second distance, the vertical coordinate of any pixel point and the height between the first straight line and the second straight line.
9. The electronic device of claim 6, wherein the grid uniformizing unit is configured to:
predicting a second horizontal offset of a pixel point on each column in the third two-dimensional code corresponding to a pixel point in the standard sampling grid relative to a pixel point on each column by using a deep learning full convolution network, and a second vertical offset of a pixel point on each row corresponding to a pixel point in the standard sampling grid relative to a pixel point on each row; the second horizontal offset of each pixel point on the same column is the same, and the first vertical offset of each pixel point on the same row is the same;
and the second coordinate offset corresponding to each pixel point in the third two-dimensional code comprises a second vertical offset and a second horizontal offset corresponding to each pixel point in the third two-dimensional code.
10. The electronic device of claim 6, wherein the pre-processing unit is to:
determining position information of four corner points of the first two-dimensional code;
obtaining an affine transformation matrix according to the position information of the four corners of the first two-dimensional code and the position information of the four corners of a preset standard rectangle;
obtaining position information of each pixel point in the first two-dimensional code after transformation according to the position information of each pixel point in the first two-dimensional code and the affine transformation matrix;
and moving each pixel point in the first two-dimensional code to a position corresponding to the position information after each pixel point is converted, so as to obtain the second two-dimensional code after being rotated.
11. An electronic device, comprising: a memory, a transceiver, and a processor; the memory, the transceiver, and the processor are coupled; the memory for storing computer program code, the computer program code comprising computer instructions; the transceiver is used for receiving data and transmitting data; the computer instructions, when executed by a processor, cause the electronic device to perform the method of any of claims 1-5.
12. A computer-readable storage medium comprising computer instructions that, when executed on an electronic device, cause the electronic device to perform the method of any of claims 1-5.
CN202111124034.8A 2021-09-24 2021-09-24 Method for correcting two-dimensional code and electronic equipment Active CN113850100B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111124034.8A CN113850100B (en) 2021-09-24 2021-09-24 Method for correcting two-dimensional code and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111124034.8A CN113850100B (en) 2021-09-24 2021-09-24 Method for correcting two-dimensional code and electronic equipment

Publications (2)

Publication Number Publication Date
CN113850100A true CN113850100A (en) 2021-12-28
CN113850100B CN113850100B (en) 2023-08-11

Family

ID=78979381

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111124034.8A Active CN113850100B (en) 2021-09-24 2021-09-24 Method for correcting two-dimensional code and electronic equipment

Country Status (1)

Country Link
CN (1) CN113850100B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114638849A (en) * 2022-05-19 2022-06-17 山东亚历山大智能科技有限公司 DM two-dimensional code identification method, AGV positioning system and AGV

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100084480A1 (en) * 2008-10-02 2010-04-08 Silverbrook Research Pty Ltd Position-coding pattern having tag coordinates encoded by successive subsequences of cyclic position code
CN106909869A (en) * 2017-02-27 2017-06-30 浙江华睿科技有限公司 A kind of sampling grid partitioning method and device of matrix two-dimensional code
US20180181781A1 (en) * 2016-12-28 2018-06-28 Datalogic IP Tech S.r.I. Virtual wave decoder for blurred images and subpixel performance
CN108629221A (en) * 2018-05-11 2018-10-09 南京邮电大学 A kind of bearing calibration of fold distortion QR Quick Response Codes
CN110516494A (en) * 2018-05-22 2019-11-29 杭州海康威视数字技术股份有限公司 A kind of two-dimensional code identification method, device, equipment and system
US20200092468A1 (en) * 2018-09-14 2020-03-19 Umech Technologies, Llc Multi-range imaging system and method
CN111681186A (en) * 2020-06-10 2020-09-18 创新奇智(北京)科技有限公司 Image processing method and device, electronic equipment and readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100084480A1 (en) * 2008-10-02 2010-04-08 Silverbrook Research Pty Ltd Position-coding pattern having tag coordinates encoded by successive subsequences of cyclic position code
US20180181781A1 (en) * 2016-12-28 2018-06-28 Datalogic IP Tech S.r.I. Virtual wave decoder for blurred images and subpixel performance
CN106909869A (en) * 2017-02-27 2017-06-30 浙江华睿科技有限公司 A kind of sampling grid partitioning method and device of matrix two-dimensional code
CN108629221A (en) * 2018-05-11 2018-10-09 南京邮电大学 A kind of bearing calibration of fold distortion QR Quick Response Codes
CN110516494A (en) * 2018-05-22 2019-11-29 杭州海康威视数字技术股份有限公司 A kind of two-dimensional code identification method, device, equipment and system
US20200092468A1 (en) * 2018-09-14 2020-03-19 Umech Technologies, Llc Multi-range imaging system and method
CN111681186A (en) * 2020-06-10 2020-09-18 创新奇智(北京)科技有限公司 Image processing method and device, electronic equipment and readable storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
KEISUKE TATENO等: "《Distortion-Aware Convolutional Filters for Dense Prediction in Panoramic Images》", 《ECCV2018》 *
黄宏博 等: "《基于图像处理的复杂条件下手机二维码识别》", 《北京信息科技大学学报》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114638849A (en) * 2022-05-19 2022-06-17 山东亚历山大智能科技有限公司 DM two-dimensional code identification method, AGV positioning system and AGV
CN114638849B (en) * 2022-05-19 2022-09-09 山东亚历山大智能科技有限公司 DM two-dimensional code identification method, AGV positioning system and AGV

Also Published As

Publication number Publication date
CN113850100B (en) 2023-08-11

Similar Documents

Publication Publication Date Title
CN109584307B (en) System and method for improving calibration of intrinsic parameters of a camera
CN107993263B (en) Automatic calibration method for panoramic system, automobile, calibration device and storage medium
CN109754427A (en) A kind of method and apparatus for calibration
CN109784250B (en) Positioning method and device of automatic guide trolley
CN115131444B (en) Calibration method based on monocular vision dispensing platform
CN105894521A (en) Sub-pixel edge detection method based on Gaussian fitting
WO2014045508A1 (en) Inspection device, inspection method, and inspection program
CN106296587B (en) Splicing method of tire mold images
GB2536429A (en) Image noise reduction
CN110009615B (en) Image corner detection method and detection device
CN110443245A (en) Localization method, device and the equipment of a kind of license plate area under unrestricted scene
CN106919883B (en) QR code positioning method and device
CN112307786A (en) Batch positioning and identifying method for multiple irregular two-dimensional codes
CN111767752A (en) Two-dimensional code identification method and device
CN113850100B (en) Method for correcting two-dimensional code and electronic equipment
CN112767412B (en) Vehicle part classification method and device and electronic equipment
JP7262927B2 (en) Image processing device, image processing method and program
US20210124969A1 (en) Planar and/or undistorted texture image corresponding to captured image of object
CN108961381B (en) Method and device for rendering a three-dimensional geometric model of an object
CN115482186A (en) Defect detection method, electronic device, and storage medium
CN114998347B (en) Semiconductor panel corner positioning method and device
CN112686959A (en) Method and device for correcting image to be recognized
CN115147389A (en) Image processing method, apparatus, and computer-readable storage medium
CN111860025B (en) Two-dimensional code region-of-interest positioning method and device
CN114742705A (en) Image splicing method based on halcon

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant