CN113850100B - Method for correcting two-dimensional code and electronic equipment - Google Patents

Method for correcting two-dimensional code and electronic equipment Download PDF

Info

Publication number
CN113850100B
CN113850100B CN202111124034.8A CN202111124034A CN113850100B CN 113850100 B CN113850100 B CN 113850100B CN 202111124034 A CN202111124034 A CN 202111124034A CN 113850100 B CN113850100 B CN 113850100B
Authority
CN
China
Prior art keywords
dimensional code
pixel point
offset
pixel
boundary line
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.)
Active
Application number
CN202111124034.8A
Other languages
Chinese (zh)
Other versions
CN113850100A (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

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 electronic equipment for correcting a two-dimensional code, which relate to the technical field of images, can generate a corrected two-dimensional code image by predicting the coordinate offset of image pixels, 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 the rotation; when the outline of the second two-dimensional code is a non-rectangular outline, calculating a first coordinate offset corresponding to each pixel point in 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 two-dimensional code of the fold distortion generated on the non-rigid body surface of express packages and the like, has stronger robustness to factors such as local offset, positioning pattern deletion and the like, and has better universality to different types of distortion.

Description

Method for correcting two-dimensional code and electronic equipment
Technical Field
The embodiment of the application relates to the technical field of images, in particular to a method for correcting a two-dimensional code and electronic equipment.
Background
In some complex scenes for reading two-dimensional codes, all code points of the two-dimensional codes may not be on the same plane due to the material, shape and the like of the object surface where the two-dimensional codes are located, so that obvious image distortion can occur in an imaging result. For example, in the case that a two-dimensional code on a single face 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 existing two-dimensional code correction technology, the traditional image processing algorithm is mostly adopted to extract primary image features such as edges, angular points and the like of a two-dimensional code area, a polynomial function is utilized to fit an edge curve, and a mapping relation between a distorted image and an undistorted template image is established. However, since the two-dimensional code image itself lacks sufficient key point information, the method of determining the distortion-free template image according to the mapping relation is too dependent on the template features, for example, the method is suitable for a locator and a correction pattern of a Quick Response (QR) code, and for a Data Matrix (DM) code or other code systems, the template features need to be redesigned, and each code system has a plurality of versions, and the method is not compatible with the plurality of versions, so the method does not have versatility.
Disclosure of Invention
The embodiment of the application provides a method and electronic equipment for correcting a two-dimensional code, which can generate a corrected two-dimensional code image by predicting the coordinate offset of image pixels without depending on the mapping relation between a distorted image and an undistorted template image, and has high feasibility and universality for different distortion types.
In order to achieve the above purpose, the embodiment of the application adopts the following technical scheme:
in a first aspect, a method for correcting a two-dimensional code is provided, including: the electronic equipment pre-processes 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 the corresponding 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 carries out 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 relative to the pixel point corresponding to the pixel point in the standard sampling grid by using 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 comprise a plurality of grids, the plurality of grids being evenly distributed. Each grid can be understood as a code point, i.e. a standard sampling grid can be a two-dimensional code with uniformly distributed code points.
According to the application, sampling grid homogenization correction is realized based on preprocessing and deep learning of predicted pixel coordinate offset, a complex distortion model of a distortion-undistorted template image is not required to be established, information such as local feature points and locators of a distortion image can be avoided, the coordinate offset of each pixel point of an image pixel of a distorted two-dimensional code relative to an ideal position is predicted, the coordinate offset of the local distorted pixel point in the distorted two-dimensional code is included, a corrected two-dimensional code image can be generated, the local distortion of the two-dimensional code can be eliminated, and the method has good universality for two-dimensional codes in different code systems, namely different distortion types.
In one possible design, the electronic device pre-processing the first two-dimensional code to obtain a second two-dimensional code after the first two-dimensional code is rotated includes: the electronic equipment determines the 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 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 the transformation of each pixel point, so as to obtain a second two-dimensional code after the rotation. Thus, for example, the two-dimensional code obtained by oblique shooting of the user can be calculated through an affine transformation matrix to obtain the two-dimensional code after correcting, so that the two-dimensional code after correcting is further corrected.
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 relative to the pixel point corresponding to the pixel point in the rectangular two-dimensional code 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 the 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 is the same as the abscissa of any pixel point, and determines a second pixel point on the second boundary line, which is the same as the abscissa of any pixel point; the electronic equipment determines a first distance from a first pixel point to a first straight line and determines a second distance from a second pixel point to a second straight line; the electronic device 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 ordinate 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, the pixel point can be moved into the rectangular outline on the basis of determining the horizontal offset of the pixel point, so that the rectangular outline correction is realized.
In one possible design, predicting the second coordinate offset of each pixel point in the third two-dimensional code relative to the pixel point corresponding to the pixel point in the standard sampling grid using the deep learning full convolution network includes: predicting a second horizontal offset of the pixel points on each column in the third two-dimensional code relative to the pixel points in the standard sampling grid by using the deep learning full convolution network, and a second vertical offset of the pixel points on each row relative to the pixel points in the standard sampling grid; 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 are offset in the horizontal and vertical directions 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 positions of each pixel point can be moved back to the positions corresponding to the pixel points in the standard sampling network according to the offset. When each grid is understood as one code point, two-dimensional codes with even distribution of the code points can be obtained.
The method can predict the pixel coordinate offset of the contour corrected two-dimensional code (the third two-dimensional code) based on the deep learning full convolution network so as to realize sampling grid homogenization correction and eliminate local distortion of the two-dimensional code. 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 patterns and the like in the prior art. Therefore, the method has stronger robustness to factors such as local offset of the two-dimensional code, loss of the positioning graph and the like, and has better universality to different types of distortion.
In one possible design, the method further comprises: when the electronic equipment determines that the outline of the second two-dimensional code is a rectangular outline, the electronic equipment directly predicts a third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid 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, there is provided 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; a contour correction unit for: when the outline of the second two-dimensional code is determined to be a non-rectangular outline, determining a first coordinate movable offset of each pixel point in the second two-dimensional code relative to the pixel point corresponding to the 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 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 grid homogenizing 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 by using the deep learning full convolution network; the grid homogenizing unit is further 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 advantages of the second aspect may be seen from the description of the first aspect.
In one possible design, the preprocessing unit is used 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 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 transformation of each pixel point, so as to obtain a second two-dimensional code after rotation.
In one possible design, the first coordinate offset includes a first vertical offset, and 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 except the 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 is the same as the abscissa of any pixel point, and determining a second pixel point on the second boundary line, which is the same as the abscissa of any pixel point; determining a first distance from a first pixel point to a first straight line, and determining a second distance from a second pixel point to a 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 ordinate of any pixel point and the height between the first straight line and the second straight line.
In one possible design, the mesh homogenizing unit is used to: predicting a second horizontal offset 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 by using the deep learning full convolution network, 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; 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 one possible design, the contour correction unit is further configured to, when determining that the contour of the second two-dimensional code is a rectangular contour, further determine that the grid homogenization unit is further configured to: predicting a third coordinate offset of each pixel point in the second two-dimensional code corresponding to the pixel point in the standard sampling grid by using the 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, the electronic device comprising: memory and a processor. The memory is coupled to the processor. The memory is for storing computer program code, the computer program code comprising computer instructions. The transceiver is used for receiving data and transmitting data. When the processor executes the computer instructions, the cloud center is caused to execute any one of the methods for correcting the two-dimensional code as provided in the first aspect or the corresponding possible designs thereof.
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 circuit; 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 the two-dimensional code as provided by the first aspect or its corresponding 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 its corresponding possible design.
In a sixth aspect, the 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 should be appreciated that any of the electronic devices, the chip system, the computer readable storage medium, the computer program product, etc. provided above may be applied to the corresponding method provided above, and thus, the benefits achieved by the electronic devices, the chip system, the computer readable storage medium, the computer program product, etc. may refer to the benefits in the corresponding method, and are not repeated herein.
These and other aspects of the application will be more readily apparent from the following description.
Drawings
Fig. 1 is a schematic diagram of code points in a two-dimensional code according to an embodiment of the present application;
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 application;
fig. 3 is a schematic diagram of an abnormal two-dimensional code according to an embodiment of the present application;
fig. 4 is a schematic flow chart of a method for correcting a two-dimensional code according to an embodiment of the present application;
fig. 5 is a schematic diagram of a deformed two-dimensional code after being rotated;
Fig. 6 is a schematic diagram of implementing contour correction on a two-dimensional code according to an embodiment of the present application;
fig. 7 is a schematic diagram for implementing preprocessing, contour correction and grid homogenization correction on a distorted two-dimensional code image according to an embodiment of the present application;
fig. 8 is a schematic diagram of implementing grid homogenization of a two-dimensional code according to an embodiment of the present application;
fig. 9 is a schematic diagram for correcting an abnormal 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, a description of some of the concepts related to the embodiments of the application are given by way of example for reference. The following is shown:
corner detection: and acquiring the position information of the four corner points of the two-dimensional code area from the original image.
Contour correction: in the present application, it can be understood that a process of correcting a two-dimensional code having an irregular outline shape to a standard rectangular area.
Sampling grid: and dividing the two-dimensional code into grids according to the minimum unit modules so as to conveniently obtain the pixel value of each minimum unit module. For example, in the present application, the minimum unit module can be understood as a code point in the two-dimensional code.
Code point: the minimum unit module in the two-dimensional code can 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, the pixel points are black or white. As shown in fig. 1, black code dots composed of pixel dots that are both black in an image of one two-dimensional code are shown. Similarly, a code point that is the same size as the black code point and the pixel point colors are all white may be referred to as a white code point.
When the two-dimensional code is obtained through scanning, a bit map can be obtained by sampling pixel values of each code point of the two-dimensional code, and decoding is performed. 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 after the two-dimensional code is read is obtained by decoding the bit map, for example, the result is information such as a picture or a link.
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. Wherein, in the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" means two or more than two.
The terms "first" and "second" are used below for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.
At present, a polynomial function is used for fitting an edge curve of the two-dimensional code, and a mapping relation between a distorted image and a normal template image is established, so that the corrected two-dimensional code can be determined. However, this method is too dependent on the designed normal template image, cannot be compatible with various code systems, and cannot be compatible with various version numbers of the code systems. In addition, the method is executed under the condition that the distortion of the two-dimensional code is assumed to be globally uniform, namely, the distortion rule of the two-dimensional code is consistent, and for example, the distortion rule of other parts of the two-dimensional code can be obtained through the distortion rule of one part of the two-dimensional code. However, this method is not suitable for complex distortion types of some two-dimensional codes, and a higher-order function is required to perform fitting. Moreover, such methods only utilize a small amount of local features of the distorted image and do not utilize more local information, and therefore, the method cannot handle the fold distortion that has the characteristics of local distortion.
Although it is proposed to use deep learning to correct distortion at present, the correction method is to input the distorted image of the two-dimensional code into a deep learning network to directly obtain the normal image of the two-dimensional code, and the end-to-end scheme (input the distorted image and output the normal image) has a plurality of difficulties in realization, and the method is very dependent on a training sample designed in advance, and cannot adapt to the distortion type possibly occurring in practice.
In this regard, the method for correcting the two-dimensional code provided by the application can be applied to a scene for correcting the distorted image when the two-dimensional code is distorted. For example, the problem of identifying the two-dimensional code of the fold distortion generated on the surface of the non-rigid body such as the express package is solved. Considering the problem that the traditional method can only utilize the primary image features such as the corner points and the edges of the distorted two-dimensional code or the positioning patterns of the code to carry out relative primary global linear correction, and cannot be applicable to 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, 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 by using the first coordinate offset of each pixel point in the second two-dimensional code relative to the pixel point corresponding to the pixel point in the rectangular two-dimensional code, so as to obtain a third two-dimensional code; and predicting a second coordinate offset of each pixel point in the third two-dimensional code relative to the pixel point corresponding to the pixel point in the standard sampling grid by using 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 of 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.
The method for generating the corrected two-dimensional code image by predicting the pixel coordinate offset of the image has high feasibility, can eliminate local distortion of the two-dimensional code, and has good universality for two-dimensional codes of different code systems or two-dimensional codes of different distortion types.
The embodiment of the application shown in fig. 2 is applicable to various electronic devices with related functions of processing two-dimensional codes. For example, the electronic device is a smart phone with a camera shooting function, when a distorted two-dimensional code is obtained through shooting, the distorted two-dimensional code can be corrected, and a corrected two-dimensional code is obtained, so that links or events corresponding to the corrected two-dimensional code can be processed according to the corrected two-dimensional code. In addition, the embodiment of the application can be also applied to the correction process of the two-dimensional code by a point of sale (POS) terminal or a personal computer (Personal Computer, PC) terminal with an intelligent processing function. The application is not limited.
For example, as shown in fig. 3, for a two-dimensional code shot by an electronic device, the application can correct the malformed two-dimensional code to obtain a normal image of the two-dimensional code, wherein the malformed two-dimensional code is obtained by oblique shooting.
The method for correcting the two-dimensional code provided by the application is described below.
The application provides a method for correcting a two-dimensional code, which is shown in fig. 4, and comprises the following steps:
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 the position information of four corner points in the first two-dimensional code can be detected first.
For example, because the surface of the express package has wrinkles, the electronic device scans the two-dimensional code to obtain the first two-dimensional code, as shown in fig. 3, when detecting that the first two-dimensional code is compared with the preset standard two-dimensional code and distortion exists, the electronic device determines that the first two-dimensional code needs to be corrected. At this time, the electronic device may detect the position information of the 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 shot static two-dimensional code.
The corner detection algorithm can be, for example, a corner detection algorithm based on a gray level image, a corner detection algorithm based on a binary image, a corner detection algorithm based on a contour curve, and the like, and the application is not limited.
402. The electronic equipment pre-processes 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 after the first two-dimensional code is rotated.
It can be understood that the first two-dimensional code shown in fig. 3 can be understood as a first two-dimensional code which is obliquely shot by a user holding the electronic device, and when the first two-dimensional code is corrected, the first two-dimensional code can be corrected first and then continuously.
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 an outline of the two-dimensional code in rotation, and the position information of four corner points of the preset standard rectangle can be preset.
The affine transformation matrix can be understood by carrying out 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 may obtain the position information of each pixel in the first two-dimensional code after the transformation according to the position information of each pixel in the first two-dimensional code and the affine transformation matrix.
For example, the coordinates of each pixel in the first two-dimensional code may be multiplied by an affine transformation matrix to obtain coordinates of each pixel in the first two-dimensional code after rotation, that is, position information of each pixel after transformation.
In this way, the electronic device can move each pixel point in the first two-dimensional code to a position corresponding to the position information after the transformation of each pixel point, so as to obtain the second two-dimensional code after the rotation.
The second two-dimensional code can be understood as a size normalized two-dimensional code region of interest (region ofinterest, ROI).
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, 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, the obtained image of the second two-dimensional code may be 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 a two-dimensional code whose outline is rectangular as shown in the second two-dimensional code (b) in fig. 5.
That is, when the rotated second two-dimensional code is obtained, it may 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 wrinkles may have a borderline of a curve.
By way of example, the positions of four boundary lines of the second two-dimensional code can be obtained by a detection method for detecting the edge profile of the image, and then whether the four boundary lines of the second two-dimensional code are all straight lines or not is determined, so that whether the profile of the two-dimensional code is a rectangular profile or not is further determined. For a border line of the second two-dimensional code, two pixel points 1 and 2 with a longer distance can be selected on the border line, and one pixel point 3 is selected between the pixel point 1 and the pixel point 2 on the border line to obtain a straight line position between the pixel point 1 and the pixel point 2, then whether the coordinate of the pixel point 3 is on the straight line is judged, and if the coordinate of the pixel point 3 is determined to be on the straight line, the border line can be considered as the straight line; if it is determined that the coordinates of the pixel point 3 are not on the straight line, the boundary line may be regarded as not being a straight line or the boundary line may be regarded as a curved line.
When it is determined that a 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 performs 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 with 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 with a rectangular contour, that is, a third two-dimensional code in the present application.
In some embodiments, when the electronic device determines that the outline of the second two-dimensional code is not a rectangular outline 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 the 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 contour correction of the second two-dimensional code.
For example, the first vertical offset of each pixel in the second two-dimensional code may be determined first, and the first difference value operation is performed on each pixel in the second two-dimensional code in the vertical direction, then the first horizontal offset of each pixel in the second two-dimensional code is determined, and the second difference value operation is performed on each pixel in the second two-dimensional code, so as to obtain the third two-dimensional code with the contour corrected to be rectangular.
Specifically, when the first coordinate offset includes a first vertical offset, determining the first coordinate offset of each pixel point in the second two-dimensional code within 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 a first boundary 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 boundary 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 the 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 (x 1, y 1) on the first boundary line 61 that is the same as the abscissa x of any pixel point P (x, y), and determines a second pixel point P2 (x 2, y 2) on the second boundary line 64 that is the same as the abscissa x of any pixel point P (x, y); x=x1=x2;
determining a first distance Δy1 from the first pixel point P (x, Y) to the first straight line 62, and determining a second distance Δy2 from the second pixel point P2 (x 2, Y2) to the second straight line 63;
the first vertical offset Δy of any pixel point P (x, Y) between the first boundary line 61 and the second boundary line 64 is determined according to the first distance Δy1, the second distance Δy2, 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 offset Δy may be expressed as:
it will be appreciated that the value of ΔY may be positive or negative. If the rule is positive, it means that any pixel point needs to be shifted upwards, and if the rule is negative, it means that any pixel point needs to be shifted downwards.
Although how to determine the first vertical offset is illustrated by any pixel P (x, Y), it should be understood that, each pixel in the second two-dimensional code may obtain the first vertical offset corresponding to each pixel by using a similar algorithm, so as to perform a first interpolation operation on each pixel in the second two-dimensional code according to the first vertical offset, for example, after the first interpolation operation, the coordinates of any pixel are changed from P (x, Y) to P (x, y+Δy).
Similar 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:
where Δx denotes a first horizontal offset amount of any pixel point, W denotes a third straight line between two corner points of the third boundary line 65, and a width between the fourth straight line between two corner points of the fourth boundary line 66, Δx1 denotes a third distance from the third pixel point P3 (X3, y 3) having the same ordinate as the first pixel point P (X, y) on the third boundary line 65 to the third straight line, and Δx2 denotes a third distance from the fourth pixel point P4 (X4, y 4) having the same ordinate as the first pixel point P (X, y) on the fourth boundary line 66 to the fourth straight line, where y=y3=y4.
It will be appreciated that the value of ΔX may be positive or negative. If the rule is positive, it indicates that any pixel point needs to be shifted to the left, and if the rule is negative, it indicates that the first pixel point needs to be shifted to the right.
Although how to determine the first horizontal offset is illustrated by any pixel P (X, Y), it should be understood that, each pixel in the second two-dimensional code may obtain the first horizontal offset corresponding to each pixel by using a similar algorithm, so as to perform a second interpolation operation on each pixel in the second two-dimensional code according to the first horizontal offset, for example, after the second interpolation operation, the coordinates of any pixel are changed from P (X, y+Δy) to P (x+Δx, y+Δy).
After the first interpolation operation of the pixel point is performed, a third two-dimensional code may 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 (a) of fig. 7, the two-dimensional code boundary blank area on the right side of the third two-dimensional code is narrower, the two-dimensional code boundary blank area on the left side is wider, and the width of each code point in the third two-dimensional code is different, so that the grid of the third two-dimensional code can be considered to be uneven. The grid here can be understood as a code point. That is, the code points inside the third two-dimensional code are unevenly distributed, and if the pixel value is directly sampled for the third two-dimensional code, an error bit map may be obtained. Therefore, the application can utilize the deep learning full convolution network to carry out grid homogenization correction on the third two-dimensional code.
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 a 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 relative to a pixel point corresponding to the pixel point in the standard sampling grid using a deep learning full convolution network, such as UNet. The correspondence here may be understood as a one-to-one correspondence of the pixel points in the third two-dimensional code with the pixel points in the standard positions in the standard sampling grid. Of course, if the second coordinate offset of any pixel in the third two-dimensional code is 0, it indicates that the any pixel is already at the standard position. For example, the electronic device may predict a second horizontal offset Δu (x, y) of the pixel point on each column in the third two-dimensional code with respect to the pixel point on each column and a second vertical offset Δv (x, y) of the pixel point on each row with respect to the pixel point on each row in the standard sampling grid using the 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.
That is, the second coordinate offset amount corresponding to each pixel point in the third two-dimensional code includes a second vertical offset amount Δv (x, y) and a 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 coordinates (x, y) of each pixel point in the third two-dimensional code and coordinates (x ', y') of each pixel point in the standard sampling grid, and the output may be a coordinate offset of each pixel point in the third two-dimensional code, including a second horizontal offset Δu (x, y) and a second vertical offset Δv (x, y).
And correcting the position of each pixel point of the third two-dimensional code by the electronic equipment according to the coordinate offset corresponding to each pixel point in the third two-dimensional code to obtain a fourth two-dimensional code. It can be understood that the corrected coordinates of each pixel point 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 be further understood as a correction two-dimensional code with even distribution of code points after interpolation calculation is performed on the second two-dimensional code. As shown in fig. 8, in the third two-dimensional code, the distribution of the pixels in the column direction is uneven, after grid homogenization correction, or after shifting the abscissa of the pixels in the column direction by the first horizontal shift amount Δu (x, y), the distribution of the pixels in the column direction in the obtained third two-dimensional code is more even, that is, the distribution of the code points in the fourth two-dimensional code is more even. That is, the fourth two-dimensional code shown in (a) of fig. 7 is obtained.
In the embodiment of the application, before grid homogenization correction is performed by using a deep learning full convolution network, a corresponding training set can be 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 a coordinate offset vector diagram (in horizontal and vertical directions) from the distorted images to the undistorted images is used as a label, so that the deep learning full convolution network is obtained through training. In this way, for the distorted image of the two-dimensional code to be corrected, the deep 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 the ideal sampling point, and then the coordinates of each pixel point in the two-dimensional code in the corrected image are obtained by 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) in the illustration of (b) in fig. 5 and 7. That is, the second two-dimensional code (b) can directly perform grid homogenization correction without performing contour correction.
Similar to step 405, the electronic device may predict a third coordinate offset of each pixel point in the second two-dimensional code relative to each pixel point in the standard sampling grid by using the deep learning full convolution network, and correct 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. As shown in fig. 7 (b).
In step 406, for an implementation manner of predicting the third coordinate offset of each pixel point in the second two-dimensional code relative to each pixel point in the standard sampling grid by using the deep learning full convolution network, reference may be made to step 405 to description of predicting the second coordinate offset of each pixel point in the third two-dimensional code relative to each pixel point in the standard sampling grid by using the deep learning full convolution network.
In step 406, the position of each pixel in the second two-dimensional code is corrected according to the third coordinate offset corresponding to each pixel in the second two-dimensional code to obtain an implementation manner of the fourth two-dimensional code, and in step 405, the position of each pixel in the third two-dimensional code is corrected according to the second coordinate offset corresponding to each pixel in the third two-dimensional code to obtain an explanation of the fourth two-dimensional code.
After the fourth two-dimensional code after the grid homogenization correction is obtained, the electronic device may sample the 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, n pixel points at each interval take the color value of one pixel point, n is a positive integer greater than 1) to obtain the color value of the central pixel point of each code point, so as to obtain a bit map of the third two-dimensional code or the fifth two-dimensional code, so as to decode the bit map, and obtain the information such as an image or a link after the decoding of the fourth two-dimensional code.
Therefore, the second two-dimensional code after the correction 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 with the two-dimensional code area being a standard rectangle, namely a third two-dimensional code, can be obtained through outline correction. Therefore, the traditional correction method which depends on local characteristic points in the prior art can be avoided, a complex distortion model of a distorted image-standard image is not required to be established, and the contour correction image can be obtained as a primary correction result only through simple pixel offset calculation and interpolation operation.
Moreover, the method can predict the pixel coordinate offset of the contour corrected two-dimensional code (the third two-dimensional code or the second two-dimensional code (b)) based on the deep learning full convolution network so as to realize sampling grid homogenization correction and eliminate local distortion of the two-dimensional code. Therefore, the neural network can easily learn the coordinate offset of each pixel point relative to the reference position in the distorted two-dimensional code by taking the row and the column as units on the basis of the initial contour correction result without depending on the information such as local feature points, positioning patterns and the like in the prior art. Therefore, the method has stronger robustness to factors such as local offset of the two-dimensional code, loss of the positioning graph and the like, and has better universality to different types of distortion.
It will be appreciated that in order to achieve the above-described functionality, the electronic device comprises corresponding hardware and/or software modules that perform the respective functionality. The present application can be implemented in hardware or a combination of hardware and computer software, in conjunction with the example algorithm steps described in connection with the embodiments disclosed herein. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The present embodiment may divide the functional modules of the electronic device 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 modules described above may be implemented in hardware. It should be noted that, in this embodiment, the division of the modules is schematic, only one logic function is divided, and another division manner may be implemented in actual implementation.
In the case of dividing the respective functional modules with the respective functions, fig. 9 shows a schematic diagram of one possible composition of the electronic device 1100 involved in the above-described 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 homogenizing unit 903.
Wherein the preprocessing unit 901 may be used to support the electronic device 90 to perform the steps 401, 402, etc. described above, and/or other processes for the techniques described herein.
The contour correction unit 902 may be used to support the electronic device 90 to perform the steps 403, 404, etc. described above, and/or other processes for the techniques described herein.
The grid homogenization unit 903 may be used to support the electronic device 90 in performing the 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 cited to the functional description of the corresponding functional module, which is not described herein.
The electronic device 90 provided in this embodiment is configured to execute the method for correcting the two-dimensional code, so that the same effect as the implementation method can be achieved.
In the case of an integrated unit, the electronic device 90 may include a processing module, a storage module, and a communication module. The processing module may be configured to control and manage the actions of the electronic device 90, for example, may be configured to support the electronic device 90 to perform the foregoing steps: a preprocessing unit 901, a contour correction unit 902, and a mesh homogenizing unit 903. The storage module may be used to support the electronic device 90 to store program code, data, etc., such as data stored with preset standard rectangles, data with outline rectangles, data with deep learning full convolutional networks, etc. The communication module may be configured to support communication between the electronic device 90 and other devices, for example, communication with a server that obtains two-dimensional code information.
Wherein the processing module may be a processor or a controller. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. A processor may also be a combination that performs computing functions, e.g., including one or more microprocessors, digital signal processing (digital signal processing, DSP) and microprocessor combinations, and the like. The memory module may be a memory. The communication module can be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip and other equipment which interact with other electronic equipment.
In one 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 the structure shown in fig. 10.
The embodiment of the application also provides electronic equipment which comprises one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, the one or more memories being configured to store computer program code comprising computer instructions that, when executed by the one or more processors, cause the electronic device to perform the related method steps described above to implement the method of correcting a two-dimensional code in the above-described embodiments.
Embodiments of the present application also provide a computer storage medium having stored therein computer instructions that, when executed on an electronic device, cause the electronic device to perform the above-described related method steps to implement the method of correcting a two-dimensional code in the above-described embodiments.
The embodiment of the application also provides a computer program product, which when run on a computer, causes the computer to execute the related steps so as to realize the method for correcting the two-dimensional code executed by the electronic device in the embodiment.
In addition, embodiments of the present application also provide an apparatus, which may be embodied as a chip, component or module, which may include a processor and a memory coupled to each other; the memory is used for storing computer-executed instructions, and when the device is operated, the processor can execute the computer-executed instructions stored in the memory, so that the chip executes the method for correcting the two-dimensional code executed by the electronic equipment in the method embodiments.
The electronic device, the computer storage medium, the computer program product, or the chip provided in this embodiment are used to execute the corresponding methods provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding methods provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (randomaccess memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within 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 of correcting a two-dimensional code, comprising:
the electronic equipment pre-processes 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 the corresponding pixel point in the rectangular two-dimensional code; the first coordinate offset includes a first horizontal offset and a first vertical offset;
the electronic equipment carries out 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 a second coordinate offset of each pixel point in the third two-dimensional code corresponding to the pixel point in the standard sampling grid by using 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 according to claim 1, wherein the method further comprises:
When the electronic equipment determines that the outline of the second two-dimensional code is a rectangular outline, predicting a third coordinate offset of each pixel point in the second two-dimensional code relative to each pixel point in a standard sampling grid 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 of claim 1 or 2, wherein the first coordinate offset includes the first vertical offset, and wherein determining a first coordinate offset for each pixel in the second two-dimensional code relative to each pixel corresponding to a pixel within a rectangular two-dimensional code 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 the 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 device determines a first pixel point on the first boundary line which is the same as the abscissa of the any pixel point, and determines a second pixel point on the second boundary line which is the same as the abscissa 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 ordinate 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 in the third two-dimensional code relative to each pixel corresponding to a pixel in a standard sampling grid using a deep learning full convolution network comprises:
predicting a second horizontal offset of the pixel point on each column in the third two-dimensional code relative to the pixel point on each column in the standard sampling grid by using a deep learning full convolution network, and a second vertical offset of the pixel point on each row relative to the pixel point on each row in the standard sampling grid; 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.
5. The method of claim 1, wherein the electronic device pre-processing the first two-dimensional code to obtain the second two-dimensional code after the first two-dimensional code is rotated comprises:
the electronic equipment determines the 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 the transformation of each pixel point, so as to obtain the second two-dimensional code after the rotation.
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 each pixel point corresponding to the 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 includes a first horizontal offset and a first vertical offset;
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;
the grid homogenizing 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 by using the deep learning full convolution network;
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, and obtaining a fourth two-dimensional code.
7. The electronic device of claim 6, wherein the contour correction unit is further configured to, when determining that the contour of the second two-dimensional code is a rectangular contour, further perform:
Predicting a third coordinate offset of each pixel point in the second two-dimensional code relative to the pixel point corresponding to the pixel point in the standard sampling grid by using a deep learning full convolution network;
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, and obtaining a fourth two-dimensional code.
8. The electronic device of claim 6 or 7, wherein the first coordinate offset includes 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 except the 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 is identical to the abscissa of the any pixel point, and determining a second pixel point on the second boundary line, which is identical to the abscissa 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 the arbitrary pixel point between the first boundary line and the second boundary line according to the first distance, the second distance, the ordinate of the arbitrary pixel point and the height between the first straight line and the second straight line.
9. The electronic device of claim 6, wherein the mesh homogenizing unit is configured to:
predicting a second horizontal offset of the pixel point on each column in the third two-dimensional code relative to the pixel point on each column in the standard sampling grid by using a deep learning full convolution network, and a second vertical offset of the pixel point on each row relative to the pixel point on each row in the standard sampling grid; 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;
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 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 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 the transformation of each pixel point, so as to obtain the second two-dimensional code after the rotation.
11. An electronic device, comprising: a memory, a transceiver, and a processor; the memory, the transceiver, and the processor are coupled; the memory is used for storing computer program codes, and the computer program codes comprise computer instructions; the transceiver is used for receiving data and transmitting data; when executed by a processor, causes the electronic device to perform the method of any of claims 1-5.
12. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of any of the preceding 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 CN113850100A (en) 2021-12-28
CN113850100B true 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)

Families Citing this family (1)

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

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN111681186A (en) * 2020-06-10 2020-09-18 创新奇智(北京)科技有限公司 Image processing method and device, electronic equipment and readable storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100084472A1 (en) * 2008-10-02 2010-04-08 Silverbrook Research Pty Ltd Method of distinguishing first coding pattern from second coding pattern
US10303913B2 (en) * 2016-12-28 2019-05-28 Datalogic Ip Tech S.R.L. Virtual wave decoder for blurred images and subpixel performance
US20200092468A1 (en) * 2018-09-14 2020-03-19 Umech Technologies, Llc Multi-range imaging system and method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN111681186A (en) * 2020-06-10 2020-09-18 创新奇智(北京)科技有限公司 Image processing method and device, electronic equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《基于图像处理的复杂条件下手机二维码识别》;黄宏博 等;《北京信息科技大学学报》;第26卷(第5期);全文 *

Also Published As

Publication number Publication date
CN113850100A (en) 2021-12-28

Similar Documents

Publication Publication Date Title
US7606439B2 (en) Method for extracting raw data from an image resulting from a camera shot
US7412089B2 (en) Efficient finder patterns and methods for application to 2D machine vision problems
CN109977949B (en) Frame fine adjustment text positioning method and device, computer equipment and storage medium
CN106778996B (en) It is embedded with the generation system and method for the two dimensional code of visual pattern and reads system
CN110348264B (en) QR two-dimensional code image correction method and system
CN115131444B (en) Calibration method based on monocular vision dispensing platform
CN111915485B (en) Rapid splicing method and system for feature point sparse workpiece images
CN105894521A (en) Sub-pixel edge detection method based on Gaussian fitting
CN110009615B (en) Image corner detection method and detection device
WO2007033429A1 (en) Vectorisation of colour gradients
CN106919883B (en) QR code positioning method and device
CN110569845A (en) test paper image correction method and related device
CN113850100B (en) Method for correcting two-dimensional code and electronic equipment
KR101237339B1 (en) A 2D barcode image extracting/decoding device, and the method therefor
CN114266764A (en) Character integrity detection method and device for printed label
CN115482186A (en) Defect detection method, electronic device, and storage medium
CN117576219A (en) Camera calibration equipment and calibration method for single shot image of large wide-angle fish-eye lens
CN111767752A (en) Two-dimensional code identification method and device
CN116894849A (en) Image segmentation method and device
CN107609453A (en) A kind of license plate image correction, registration number character dividing method and equipment
CN110632094A (en) Pattern quality detection method, device and system based on point-by-point comparison analysis
CN109766063A (en) A kind of nail beauty machine printing calibration method, device, nail beauty machine and storage medium
CN111860025A (en) Two-dimensional code region-of-interest positioning method and device
CN113971738B (en) Image detection method, device, electronic equipment and storage medium
US20210303902A1 (en) Image processing device, image processing method, and program

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