Barcode correction method, device and electronic device based on perspective coordinate transformation

By using perspective coordinate transformation method in barcode correction, the image distortion problem caused by the non-vertical shooting angle is solved, and the barcode image is restored to the rectangular form is improved, the recognition speed and accuracy are simplified, and the calculation process is simplified.

CN114140330BActive Publication Date: 2024-11-05WUHAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111425336.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-26
Publication Date
2024-11-05
Estimated Expiration
2041-11-26

AI Technical Summary

Technical Problem

The existing barcode correction methods cannot effectively solve the problem of image angle distortion caused by the non-vertical shooting angle, resulting in irregular quadrilaterals in the barcode image, affecting the recognition speed and accuracy.

Method used

Using a method based on perspective coordinate transformation, the barcode image is covered with a quadrilateral mask after tilt correction, a plane rectangular coordinate system is established, the mask type is judged, and pixel coordinate transformation is performed according to the type to restore the barcode image to the rectangular shape.

Benefits of technology

It effectively solves the problem of image angle distortion, improves the first reading rate of barcode recognition, reduces the bit error rate, and simplifies calculations through predefined mask types, improving correction speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114140330B_ABST
    Figure CN114140330B_ABST
Patent Text Reader

Abstract

The present application discloses a barcode correction method, device, electronic device and storage medium based on perspective coordinate transformation, the method comprising: obtaining a barcode image to be corrected; using a preset algorithm to perform tilt correction on the barcode image to obtain a horizontal barcode image; covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system, and obtaining the coordinates of the four vertices of the mask; judging the type of the mask according to the vertex coordinates; according to the type of the mask, using the coordinate conversion formula corresponding to the mask type, performing coordinate transformation on all pixel points in the mask to obtain a corrected barcode image; outputting the corrected barcode image. The present application can solve the problem of perspective distortion of a barcode image into an irregular quadrilateral caused by a non-vertical shooting angle, and restore the barcode image to a rectangular shape; avoid internal distortion of the image caused by external shape stretching and filling, improve the first read rate of barcode recognition, and reduce the bit error rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of barcode correction, and in particular to a barcode correction method, device, electronic device and computer-readable storage medium based on perspective coordinate transformation. Background Art

[0002] Barcodes have penetrated into commerce, transportation, library management, logistics distribution, military, engineering projects and other fields, playing an important role in promoting social and economic development.

[0003] Barcode correction methods mostly focus on tilt correction. Existing tilt correction methods include Hough transform, Radon transform, linear regression method, two-point method, etc. All of them first find the straight line in the image and then rotate the entire barcode image to correct the tilt.

[0004] However, the existing barcode correction method cannot solve the problem of image angle distortion caused by non-vertical shooting angle. The barcode image processed by tilt correction alone may not be a rectangle but an irregular quadrilateral, which affects the barcode recognition speed and accuracy. Summary of the invention

[0005] In view of this, it is necessary to provide a barcode correction method, device, electronic device and computer-readable storage medium based on perspective coordinate transformation to solve the problem that the existing technology cannot effectively correct the image angle distortion caused by the non-vertical shooting angle.

[0006] In order to solve the above problems, the present invention provides a barcode correction method based on perspective coordinate transformation, comprising:

[0007] Obtain the barcode image to be corrected;

[0008] Using a preset algorithm to perform tilt correction on the barcode image to obtain a horizontal barcode image;

[0009] Covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask;

[0010] Determine the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point;

[0011] According to the type of the mask, using the coordinate transformation formula corresponding to the mask type, coordinate transformation is performed on all the pixels in the mask to obtain a corrected barcode image;

[0012] The corrected barcode image is output.

[0013] Furthermore, the plane rectangular coordinate system established according to the mask takes the left bottom point as the coordinate origin, the straight line determined by the left bottom point and the right bottom point as the horizontal axis, and the straight line perpendicular to the horizontal axis as the vertical axis.

[0014] Further, judging the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point includes:

[0015] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the first type:

[0016] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the second type;

[0017] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the third type;

[0018] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the fourth type;

[0019] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the fifth type;

[0020] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the sixth type;

[0021] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be the seventh type;

[0022] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the eighth category.

[0023] Furthermore, coordinate transformation is performed on all pixels in the mask to obtain a corrected barcode image, including:

[0024] A first straight line is established according to the left vertex and the right vertex of the mask, and a second straight line is established according to the left bottom point and the right bottom point of the mask; the intersection of the first straight line and the second straight line is a first intersection point;

[0025] A third straight line is established according to the left vertex and the left bottom point of the mask, and a fourth straight line is established according to the right vertex and the right bottom point of the mask; the intersection of the third straight line and the fourth straight line is the second intersection point;

[0026] A fifth straight line is established according to the pixel point in the mask and the first intersection point, and a sixth straight line is established according to the pixel point and the second intersection point; the intersection point of the fifth straight line and the third straight line is the third intersection point; the intersection point of the fifth straight line and the fourth straight line is the fourth intersection point; the intersection point of the sixth straight line and the first straight line is the fifth intersection point; the intersection point of the sixth straight line and the second straight line is the sixth intersection point;

[0027] Obtaining the plane coordinates of the pixel point after conversion according to the coordinates of the pixel point, the third intersection point, the fourth intersection point, the fifth intersection point and the sixth intersection point and the preset barcode length value and width value;

[0028] Traversing all pixel points in the mask to obtain the converted plane coordinates of all pixel points in the mask;

[0029] According to the converted plane coordinates of all the pixel points, a corrected barcode image is obtained.

[0030] Further, when it is determined that the mask is any one of the first to seventh categories, and the pixel points in the mask are on the first straight line, the ordinate of the transformed coordinates of the pixel points is a preset barcode width value.

[0031] Further, when it is determined that the mask is any one of the first to seventh categories, and the pixel points in the mask are on the fourth straight line, the horizontal coordinate of the transformed coordinates of the pixel points is a preset barcode length value.

[0032] Further, when it is determined that the mask is the eighth type of mask, the horizontal barcode image is directly output.

[0033] The present invention also provides a barcode correction device based on perspective coordinate transformation, comprising:

[0034] An acquisition module, used for acquiring a barcode image to be corrected;

[0035] A tilt correction module, used to perform tilt correction on the barcode image using a preset algorithm to obtain a horizontal barcode image;

[0036] A rectangular coordinate system establishment module, used for covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask;

[0037] A judging module, judging the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point;

[0038] A correction module, used for performing coordinate transformation on all pixels in the mask according to the type of the mask and the preset barcode length and width values, using a corresponding coordinate transformation method, to obtain a corrected barcode image;

[0039] An output module is used to output the corrected barcode image.

[0040] The present invention also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the barcode correction method based on perspective coordinate transformation as described in any of the above technical solutions is implemented.

[0041] The present invention also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the barcode correction method based on perspective coordinate transformation as described in any of the above technical solutions is implemented.

[0042] Compared with the prior art, the beneficial effects of the present invention include: first, obtaining the barcode image to be corrected, performing tilt correction on the barcode image, and obtaining a horizontal barcode image; then, covering the horizontal barcode image with a quadrilateral mask, establishing a plane rectangular coordinate system, obtaining the coordinates of the four vertices of the mask, and determining the type of the mask according to the vertex coordinates; finally, according to the type of the mask, using the corresponding coordinate conversion formula, performing coordinate transformation on all pixel points in the mask, obtaining the corrected barcode image, and outputting the corrected barcode image. The present invention solves the problem of perspective distortion of the barcode image into an irregular quadrilateral caused by the non-vertical shooting angle, and restores the barcode image to a rectangular shape on the basis of the existing tilt correction algorithm; at the same time, avoiding the internal distortion of the image caused by the stretching and filling of the outer shape, thereby improving the first reading rate of barcode recognition and reducing the bit error rate; since each mask type is summarized, it is not necessary to recalculate the coordinates of each pixel point during operation, and it is only necessary to determine which type it is and then directly bring it into the coordinate formula, which saves a lot of calculations and improves the speed of barcode correction. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 A schematic diagram of an application scenario of a barcode correction device based on perspective coordinate transformation provided by the present invention;

[0044] Figure 2 A schematic flow chart of an embodiment of a barcode correction method based on perspective coordinate transformation provided by the present invention;

[0045] Figure 3 A schematic diagram of a first type of mask provided in an embodiment of the present invention;

[0046] Figure 4 A schematic diagram of a second type of mask provided in an embodiment of the present invention;

[0047] Figure 5 A schematic diagram of a third type of mask provided in an embodiment of the present invention;

[0048] Figure 6 A schematic diagram of a fourth type of mask provided in an embodiment of the present invention;

[0049] Figure 7 A schematic diagram of a fifth type of mask provided in an embodiment of the present invention;

[0050] Figure 8 A schematic diagram of a sixth type of mask provided in an embodiment of the present invention;

[0051] Fig. 9 A schematic diagram of the seventh type of mask provided in an embodiment of the present invention;

[0052] Fig.10 A schematic diagram of an eighth type of mask provided in an embodiment of the present invention;

[0053] Fig.11 Schematic diagram of perspective coordinates of a barcode mask to be corrected in an embodiment of the present invention;

[0054] Fig.12 Schematic diagram of perspective coordinates of a barcode mask after correction in an embodiment of the present invention;

[0055] Fig.13 A structural block diagram of an embodiment of a barcode correction device based on perspective coordinate transformation provided by the present invention;

[0056] Fig.14 This is a structural block diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0057] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.

[0058] The present invention provides a barcode correction method, device, electronic device and computer-readable storage medium based on perspective coordinate transformation, which are described in detail below.

[0059] The embodiment of the present invention provides an application system of a barcode correction method based on perspective coordinate transformation. Figure 1 A schematic diagram of a scenario of an embodiment of a barcode correction method application system based on perspective coordinate transformation provided by the present invention. The system may include a server 100, in which a barcode correction device based on perspective coordinate transformation is integrated. Figure 1 Servers in .

[0060] In the embodiment of the present invention, the server 100 is mainly used for:

[0061] Obtain the barcode image to be corrected;

[0062] Using a preset algorithm to perform tilt correction on the barcode image to obtain a horizontal barcode image;

[0063] Covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask;

[0064] Determine the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point;

[0065] According to the type of the mask, using the coordinate transformation formula corresponding to the mask type, coordinate transformation is performed on all the pixels in the mask to obtain a corrected barcode image;

[0066] The corrected barcode image is output.

[0067] In the embodiment of the present invention, the server 100 may be an independent server, or a server network or server cluster composed of servers. For example, the server 100 described in the embodiment of the present invention includes but is not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of a plurality of servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.

[0068] It is understandable that the terminal 200 used in the embodiment of the present invention may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. Such a device may include: a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display. The specific terminal 200 may be a desktop computer, a portable computer, a network server, a PDA (Personal Digital Assistant), a mobile phone, a tablet computer, a wireless terminal device, a communication device, an embedded device, etc. This embodiment does not limit the type of the terminal 200.

[0069] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the solution of the present invention and does not constitute a limitation on the application scenario of the solution of the present invention. Other application environments may also include Figure 1 More or fewer terminals as shown in Figure 1 Only two terminals are shown in the figure. It can be understood that the application system of the barcode correction method based on perspective coordinate transformation can also include one or more other terminals, which are not specifically limited here.

[0070] In addition, if Figure 1 As shown, the application system of the barcode correction method based on perspective coordinate transformation may also include a memory 200 for storing data, such as vertex coordinates, barcode images, and the like.

[0071] It should be noted that Figure 1 The scenario diagram of the application system for barcode correction based on perspective coordinate transformation is only an example. The application system and scenario of the barcode correction method based on perspective coordinate transformation described in the embodiment of the present invention are intended to more clearly illustrate the technical solution of the embodiment of the present invention, and do not constitute a limitation on the technical solution provided by the embodiment of the present invention. A person of ordinary skill in the art can know that with the evolution of the application system for the barcode correction method based on perspective coordinate transformation and the emergence of new business scenarios, the technical solution provided by the embodiment of the present invention is also applicable to similar technical problems.

[0072] The embodiment of the present invention provides a barcode correction method based on perspective coordinate transformation, and its flow chart is as follows: Figure 2 As shown, the barcode correction based on perspective coordinate transformation includes:

[0073] Step S201, obtaining a barcode image to be corrected;

[0074] Step S202: using a preset algorithm to perform tilt correction on the barcode image to obtain a horizontal barcode image;

[0075] Step S203, covering the horizontal barcode image with a quadrilateral mask, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask;

[0076] Step S204, judging the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point;

[0077] Step S205: according to the type of the mask, using the coordinate conversion formula corresponding to the mask type, coordinate transformation is performed on all the pixels in the mask to obtain a corrected barcode image;

[0078] Step S206: output the corrected barcode image.

[0079] Compared with the prior art, the barcode correction method based on perspective coordinate transformation provided in this embodiment can solve the problem of perspective distortion of the barcode image into an irregular quadrilateral caused by the non-vertical shooting angle, and restore the barcode image to a rectangular shape; at the same time, it avoids the internal distortion of the image caused by stretching and filling of the outer shape, thereby improving the first reading rate of barcode recognition and reducing the bit error rate; since each mask type is summarized, it is not necessary to recalculate the coordinates of each pixel point during operation. It is only necessary to determine which type it is and then directly substitute it into the coordinate formula, which saves a lot of calculations and improves the speed of barcode correction.

[0080] As a specific embodiment, in step S202, the barcode image is tilt-corrected by using Hough transform, so that the bottom edge of the barcode image is horizontal, which is convenient for subsequent image processing.

[0081] As a preferred embodiment, in step S203, the plane rectangular coordinate system established according to the mask takes the left bottom point as the coordinate origin, the straight line determined by the left bottom point and the right bottom point as the horizontal axis, and the straight line perpendicular to the horizontal axis as the vertical axis.

[0082] As a specific example, Figure 3 As shown, a quadrilateral mask is covered on the horizontal barcode, the left vertex of the mask is A', the right vertex is B', the right bottom point is C', and the left bottom point is D'. With D' as the origin and D'C' as the positive direction of the x-axis, a plane rectangular coordinate system is established to obtain the coordinates of the four points of the quadrilateral D', A', B', and C': A'(x a ,y a ), B'(x b ,y b ), C'(x c , 0), D'(0, 0).

[0083] As a preferred embodiment, in step S204, judging the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point includes:

[0084] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the first type:

[0085] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the second type;

[0086] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the third type;

[0087] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the fourth type;

[0088] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the fifth type;

[0089] When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the sixth type;

[0090] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be the seventh type;

[0091] When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the eighth category.

[0092] As a specific example, Figure 3 , xa≠0, xb≠xc, ya≠yb, the mask is of the first type; Figure 4 , xa≠0, xb≠xc, ya=yb, the mask is of the second type; Figure 5 , xa=0, xb≠xc, ya≠yb, the mask is of the third type; Figure 6 , x a =0,x b ≠x c ,y a =Y b , the mask is of the fourth type; Figure 7 , xa≠0, xb=xc, ya≠yb, the mask is of the fifth type; Figure 8 , xa≠0, xb=xc, ya=yb, the mask is of the sixth type; Fig. 9 , xa=0, xb=xc, ya≠yb, the mask is the seventh category; Fig.10 , xa=0, xb=xc, ya=yb, the mask is of the eighth category.

[0093] As a preferred embodiment, in step S205, coordinate transformation is performed on all pixels in the mask to obtain a corrected barcode image, including:

[0094] A first straight line is established according to the left vertex and the right vertex of the mask, and a second straight line is established according to the left bottom point and the right bottom point of the mask; the intersection of the first straight line and the second straight line is a first intersection point;

[0095] A third straight line is established according to the left vertex and the left bottom point of the mask, and a fourth straight line is established according to the right vertex and the right bottom point of the mask; the intersection of the third straight line and the fourth straight line is the second intersection point;

[0096] A fifth straight line is established according to the pixel point in the mask and the first intersection point, and a sixth straight line is established according to the pixel point and the second intersection point; the intersection point of the fifth straight line and the third straight line is the third intersection point; the intersection point of the fifth straight line and the fourth straight line is the fourth intersection point; the intersection point of the sixth straight line and the first straight line is the fifth intersection point; the intersection point of the sixth straight line and the second straight line is the sixth intersection point;

[0097] Obtaining the plane coordinates of the pixel point after conversion according to the coordinates of the pixel point, the third intersection point, the fourth intersection point, the fifth intersection point and the sixth intersection point and the preset barcode length value and width value;

[0098] Traversing all pixel points in the mask to obtain the converted plane coordinates of all pixel points in the mask;

[0099] According to the converted plane coordinates of all the pixel points, a corrected barcode image is obtained.

[0100] As a specific example, Fig.11 As shown, the extended D'A' and C'B' intersect at point E; the extended B'A' and C'D' intersect at point F; the pixel point in the mask is P'; connect F and P' and extend them, intersecting A'D' at G', and intersecting B'C' at M'; connect E and P' and extend them, intersecting D'C' at H', and intersecting A'B' at N'; the coordinates of E, F, N', H', G', M', and P' are: E(x e ,y e ), F(x f ,y f ), N'(x n ,y n ), H'(x h ,y h ), G'(x g ,y g ), M'(x m ,y m ), P'(x p,y p ).

[0101] If the corrected barcode quadrilateral mask is Fig.12 , the preset barcode length is |DC|, the barcode width is |DA|, after correction, P' corresponds to P(x, y), A' corresponds to A, B' corresponds to B, C' corresponds to C, D' corresponds to D, G' corresponds to G, H' corresponds to H, G' corresponds to G, M' corresponds to M, N' corresponds to N; then:

[0102] The horizontal coordinate x of point P is the length of GP, and the vertical coordinate y is the length of PH, and they satisfy:

[0103]

[0104]

[0105] As a specific example, Figure 3 , when the mask is type 1, the equation of the line on which each side of the quadrilateral lies is:

[0106]

[0107]

[0108] L C’D’ :y=0 (5)

[0109]

[0110] From this, we can obtain the coordinates of the intersection points E and F:

[0111]

[0112]

[0113]

[0114] y f =0 (10)

[0115] For any point P', the equation of the line where EP' and FP' lie can be obtained, and thus the coordinates of the intersection points N', H', G', and M' can be obtained.

[0116] Find L first EP’ Equation and N', H' coordinates:

[0117] 1) When x P =x e hour:

[0118] L EP’ :x=x p (11)

[0119] x n =x p (12)

[0120]

[0121] x h =x p (14)

[0122] y h =0 (15)

[0123] 2) When x P ≠x e hour:

[0124]

[0125]

[0126]

[0127]

[0128] y h =0 (20)

[0129] Ask L again FP’ Equation and G', M' coordinates:

[0130]

[0131]

[0132]

[0133]

[0134]

[0135] As a specific example, Figure 4 , when the mask is type 2, the equation of the line where each side of the quadrilateral lies is:

[0136] L A’B’ :y=y a (26)

[0137]

[0138] L C’D’ :y=0(28)

[0139]

[0140] From this we can get the coordinates of the intersection point E:

[0141]

[0142]

[0143] Ask for L EP, Equation and N', H' coordinates:

[0144] 1) When x p =x e hour:

[0145] L EP ':x=x p (32)

[0146] x n =x p (33)

[0147] y n =ya (34)

[0148] x h =x p (35)

[0149] y h =0 (36)

[0150] 2) When x P ≠x e hour:

[0151]

[0152]

[0153] y n =y a (39)

[0154]

[0155] y h =0 (41)

[0156] Find the coordinates of G' and M':

[0157] Because A'B' / / D'C', there is no intersection point F for type 2. Draw a horizontal line L1 through P' to replace FP', and intersect A'D', B'C' at G', M', then:

[0158] L1: y = y p (42)

[0159]

[0160] yg =y p (44)

[0161]

[0162] y m =y p (46)

[0163] As a specific example, Figure 5 , when the mask is type three, the equation of the line where each side of the quadrilateral lies is:

[0164]

[0165]

[0166] L C’D’ :y=0 (49)

[0167] L A’D’ :x=0 (50)

[0168] From this, we can obtain the coordinates of the intersection points E and F:

[0169] x e =0 (51)

[0170]

[0171]

[0172] y f =0 (54)

[0173] For any point P', the equation of the line where EP' and FP' lie can be obtained, and thus the coordinates of the intersection points N', H', G', and M' can be obtained.

[0174]

[0175]

[0176]

[0177]

[0178] y h =0 (59)

[0179]

[0180] x g =0 (61)

[0181]

[0182]

[0183]

[0184] As a specific example, Figure 6 , when the mask is type 4, the equation of the straight line where each side of the quadrilateral lies: The equation of the straight line where each side of the quadrilateral lies can be found:

[0185] L A’B’ :y=y a (65)

[0186]

[0187] L C’D’ :y=0 (67)

[0188] L A’D’ :x=0 (68)

[0189] From this we can get the coordinates of the intersection point E:

[0190] x e =0 (69)

[0191]

[0192] Ask for L EP’ Equation and N', H' coordinates:

[0193]

[0194]

[0195] y n =y a (73)

[0196]

[0197] y h =0 (75)

[0198] Find the coordinates of G' and M':

[0199] Because A'B' / / D'C', there is no intersection point F in type 4. Draw a horizontal line L1 through P' to replace FP', and intersect A'D', B'C' at G', M', then:

[0200] L1: y = y p (76)

[0201] xg=0 (77)

[0202] yg =y p (78)

[0203]

[0204] y m =y p (80)

[0205] As a specific example, Figure 7 , when the mask is type five, the equation of the straight line where each side of the quadrilateral lies: According to the known conditions, the equation of the straight line where each side of the quadrilateral lies can be obtained:

[0206]

[0207] L B’C’ :x=x b (82)

[0208] L C’D’ :y=0 (83)

[0209]

[0210] From this, we can obtain the coordinates of the intersection points E and F:

[0211] x e =x b (85)

[0212]

[0213]

[0214] y f =0 (88)

[0215] For any point P', the equation of the line where EP' and FP' lie can be obtained, and thus the coordinates of the intersection points N', H', G', and M' can be obtained.

[0216]

[0217]

[0218]

[0219]

[0220] y h =0 (93)

[0221]

[0222]

[0223]

[0224] x m =x b (97)

[0225]

[0226] As a specific example, Figure 8 , when the mask is type six, the equation of the straight line where each side of the quadrilateral lies: According to the known conditions, the equation of the straight line where each side of the quadrilateral lies can be obtained:

[0227] L A’B’ :y=y a (99)

[0228] L B’C’ :x=x b (100)

[0229] L C’D’ :y=0 (101)

[0230]

[0231] From this we can get the coordinates of the intersection point E:

[0232] x e =x b (103)

[0233]

[0234] Ask for L EP’ Equation and N', H' coordinates:

[0235]

[0236]

[0237] y n =y a (107)

[0238]

[0239] y h =0 (109)

[0240] Find the coordinates of G' and M':

[0241] Because A'B' / / D'C', there is no intersection point F in type 6. Draw a horizontal line L1 through P' to replace FP', and intersect A'D', B'C' at G', M', then:

[0242] L1: y = y p (110)

[0243]

[0244] y g =y p (112)

[0245] x m =x b (113)

[0246] y m =y p (114)

[0247] As a specific example, Fig. 9 , when the mask is type seven, the equation of the straight line where each side of the quadrilateral lies: According to the known conditions, the equation of the straight line where each side of the quadrilateral lies can be obtained:

[0248]

[0249] L B’C’ :x=x b (116)

[0250] L C’D’ :y=0 (117)

[0251] L A’D’ :x=0 (118)

[0252] Find the N' and H' coordinates:

[0253] Because A'D' / / B'C', there is no intersection point E in type 7. Draw a perpendicular line L2 through P' to replace EP', and intersect A'B', D'C' at N', H', then:

[0254] L2: x = x p (119)

[0255] x n =x p (120)

[0256]

[0257] x h =x p (122)

[0258] y h =0 (123)

[0259] Find the coordinates of the intersection point F:

[0260]

[0261] y f =0 (125)

[0262] Ask for L FP, Equation and G', M' coordinates:

[0263]

[0264] x g =x a (127)

[0265]

[0266] x m =x b (129)

[0267]

[0268] As a specific embodiment, when the mask is type eight, the image is already rectangular and does not need correction.

[0269] As a specific example, let P'(x p ,y p ) is transformed to P(x', y'), then: For the first seven types above:

[0270]

[0271]

[0272] When P' is a vertex: it is divided into the following four cases:

[0273] a) P'=A':

[0274] x′=0 (133)

[0275] y′=|AD| (134)

[0276] b) P'=B':

[0277] x′=|DC| (135)

[0278] y′=|AD| (136)

[0279] c) P'=C':

[0280] x′=|DC| (137)

[0281] y′=0 (138)

[0282] d) P'=D':

[0283] x=0 (139)

[0284] y′=0 (140)

[0285] As a preferred embodiment, when it is determined that the mask is one of the first to seventh categories, if a pixel point in the mask is on the first straight line, the ordinate of the transformed coordinate of the pixel point is a preset barcode width value.

[0286] As a specific example, when P' is on A'B':

[0287]

[0288] y′=|AD| (142)

[0289] As a preferred embodiment, when it is determined that the mask is one of the first to seventh categories, if a pixel point in the mask is on the fourth straight line, the horizontal coordinate of the transformed coordinate of the pixel point is a preset barcode length value.

[0290] As a specific example, when P' is on B'C':

[0291] x′=|DC| (143)

[0292]

[0293] As a specific example, P' is on C'D':

[0294]

[0295] y′=0 (146)

[0296] As a specific example P' on D'A':

[0297] x′=0 (147)

[0298]

[0299] As a preferred embodiment, when it is determined that the mask is the eighth type of mask, the horizontal barcode image is directly output.

[0300] As a specific example, Fig.10 , xa=0, xb=xc, ya=yb, the mask is of the eighth category, and the barcode image is directly output at this time.

[0301] The embodiment of the present invention provides a barcode correction device based on perspective coordinate transformation, and its structural block diagram is as follows: Fig.13As shown, the barcode correction device based on perspective coordinate transformation includes an acquisition module 1301, a tilt correction module 1302, a rectangular coordinate system establishment module 1303, a judgment module 1304, a correction module 1305 and an output module 1306;

[0302] The acquisition module 1301 is used to acquire the barcode image to be corrected;

[0303] The tilt correction module 1302 is used to perform tilt correction on the barcode image using a preset algorithm to obtain a horizontal barcode image;

[0304] The rectangular coordinate system establishment module 1303 is used to cover a quadrilateral mask on the horizontal barcode image, establish a plane rectangular coordinate system according to the mask, and obtain the position coordinates of the left vertex, right vertex, left bottom point, and right bottom point of the mask;

[0305] The judging module 1304 judges the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point;

[0306] The correction module 1305 is used to perform coordinate transformation on all pixels in the mask according to the type of the mask and the preset barcode length and width values, using a corresponding coordinate transformation method, to obtain a corrected barcode image;

[0307] The output module 1306 is used to output the corrected barcode image.

[0308] like Fig.14 As shown, the barcode correction method based on perspective coordinate transformation is described above. The present invention also provides an electronic device, which can be a computing device such as a mobile terminal, a desktop computer, a notebook, a palm computer, and a server. The electronic device includes a processor 10, a memory 20, and a display 30.

[0309] In some embodiments, the memory 20 may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory 20 may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory 20 may also include both an internal storage unit of the computer device and an external storage device. The memory 20 is used to store application software and various types of data installed in the computer device, such as program codes for installing the computer device. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a barcode correction method program 40 based on perspective coordinate transformation is stored on the memory 20, and the barcode correction method program 40 based on perspective coordinate transformation can be executed by the processor 10, thereby realizing the barcode correction method based on perspective coordinate transformation of each embodiment of the present invention.

[0310] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, and is used to run program codes or process data stored in the memory 20, such as executing a barcode correction program based on perspective coordinate transformation.

[0311] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the computer device and to display a visual user interface. The components 10-30 of the computer device communicate with each other through a system bus.

[0312] This embodiment further provides a computer-readable storage medium, on which a program of a barcode correction method based on perspective coordinate transformation is stored. When a processor executes the program, the barcode correction method based on perspective coordinate transformation as described above is implemented.

[0313] The computer-readable storage medium and computing device provided according to the above embodiments of the present invention can be implemented with reference to the specific description of the barcode correction method based on perspective coordinate transformation as described above according to the present invention, and have similar beneficial effects as the barcode correction method based on perspective coordinate transformation as described above, which will not be repeated here.

[0314] The present invention discloses a barcode correction method, device, electronic device and computer-readable storage medium based on perspective coordinate transformation. First, a barcode image to be corrected is obtained, and the barcode image is tilt-corrected to obtain a horizontal barcode image; then, a quadrilateral mask is covered on the horizontal barcode image, a plane rectangular coordinate system is established, the coordinates of the four vertices of the mask are obtained, and the type of the mask is determined according to the vertex coordinates; finally, according to the type of the mask, the corresponding coordinate conversion formula is used to transform the coordinates of all pixel points in the mask to obtain a corrected barcode image, and the corrected barcode image is output.

[0315] The technical solution of the present invention solves the problem of perspective distortion of a barcode image into an irregular quadrilateral caused by a non-vertical shooting angle, and restores the barcode image to a rectangular shape on the basis of an existing tilt correction algorithm; at the same time, internal distortion of the image caused by stretching and filling of the outer shape is avoided, thereby improving the first read rate of barcode recognition and reducing the bit error rate; since each mask type is summarized, there is no need to recalculate the coordinates of each pixel point during operation, and it is only necessary to determine which type it is and then directly bring it into the coordinate formula, which saves a lot of calculations and improves the speed of barcode correction.

[0316] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A barcode correction method based on perspective coordinate transformation, It is characterized in that include: Obtain the barcode image to be corrected; Using a preset algorithm to perform tilt correction on the barcode image to obtain a horizontal barcode image; Covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask; Determine the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point; According to the type of the mask, using the coordinate transformation formula corresponding to the mask type, coordinate transformation is performed on all the pixels in the mask to obtain a corrected barcode image; Outputting the corrected barcode image; According to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point, determining the type of the mask includes: When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the first type: When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the second type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the third type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the fourth type; When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the fifth type; When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the sixth type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be the seventh type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the eighth category; The coordinates of all pixels in the mask are transformed to obtain a corrected barcode image, including: A first straight line is established according to the left vertex and the right vertex of the mask, and a second straight line is established according to the left bottom point and the right bottom point of the mask; the intersection of the first straight line and the second straight line is a first intersection point; A third straight line is established according to the left vertex and the left bottom point of the mask, and a fourth straight line is established according to the right vertex and the right bottom point of the mask; the intersection of the third straight line and the fourth straight line is the second intersection point; A fifth straight line is established according to the pixel point in the mask and the first intersection point, and a sixth straight line is established according to the pixel point and the second intersection point; the intersection point of the fifth straight line and the third straight line is the third intersection point; the intersection point of the fifth straight line and the fourth straight line is the fourth intersection point; the intersection point of the sixth straight line and the first straight line is the fifth intersection point; the intersection point of the sixth straight line and the second straight line is the sixth intersection point; Obtaining the plane coordinates of the pixel point after conversion according to the coordinates of the pixel point, the third intersection point, the fourth intersection point, the fifth intersection point and the sixth intersection point and the preset barcode length value and width value; Traversing all pixel points in the mask to obtain the converted plane coordinates of all pixel points in the mask; According to the converted plane coordinates of all the pixel points, a corrected barcode image is obtained.

2. The barcode correction method based on perspective coordinate transformation according to claim 1, It is characterized in that The plane rectangular coordinate system established according to the mask takes the left bottom point as the coordinate origin, the straight line determined by the left bottom point and the right bottom point as the horizontal axis, and the straight line perpendicular to the horizontal axis as the vertical axis.

3. The barcode correction method based on perspective coordinate transformation according to claim 1, It is characterized in that When it is determined that the mask is any one of the first to seventh categories, and the pixel points in the mask are on the first straight line, the ordinate of the transformed coordinates of the pixel points is a preset barcode width value.

4. The barcode correction method based on perspective coordinate transformation according to claim 1, It is characterized in that When it is determined that the mask is any one of the first to seventh categories, and the pixel points in the mask are on the fourth straight line, the horizontal coordinates of the transformed coordinates of the pixel points are the preset barcode length values.

5. The barcode correction method based on perspective coordinate transformation according to claim 1, It is characterized in that When it is determined that the mask is the eighth type of mask, the horizontal barcode image is directly output.

6. Barcode correction device based on perspective coordinate transformation, It is characterized in that include: An acquisition module, used for acquiring a barcode image to be corrected; A tilt correction module, used to perform tilt correction on the barcode image using a preset algorithm to obtain a horizontal barcode image; A rectangular coordinate system establishment module, used for covering a quadrilateral mask on the horizontal barcode image, establishing a plane rectangular coordinate system according to the mask, and obtaining the position coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point of the mask; A judging module, judging the type of the mask according to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point; A correction module, used for performing coordinate transformation on all pixels in the mask according to the type of the mask and the preset barcode length and width values, using a corresponding coordinate transformation method, to obtain a corrected barcode image; Output module: used for outputting the corrected barcode image; According to the coordinates of the left vertex, the right vertex, the left bottom point, and the right bottom point, determining the type of the mask includes: When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the first type: When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the second type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the third type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is not equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be the fourth type; When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be of the fifth type; When the horizontal coordinate of the left vertex of the mask is not equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the sixth type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is not equal to the vertical coordinate of the right vertex, the mask is determined to be the seventh type; When the horizontal coordinate of the left vertex of the mask is equal to the horizontal coordinate of the left bottom point, the horizontal coordinate of the right vertex is equal to the horizontal coordinate of the right bottom point, and the vertical coordinate of the left vertex is equal to the vertical coordinate of the right vertex, the mask is determined to be of the eighth category; The coordinates of all pixels in the mask are transformed to obtain a corrected barcode image, including: A first straight line is established according to the left vertex and the right vertex of the mask, and a second straight line is established according to the left bottom point and the right bottom point of the mask; the intersection of the first straight line and the second straight line is a first intersection point; A third straight line is established according to the left vertex and the left bottom point of the mask, and a fourth straight line is established according to the right vertex and the right bottom point of the mask; the intersection of the third straight line and the fourth straight line is the second intersection point; A fifth straight line is established according to the pixel point in the mask and the first intersection point, and a sixth straight line is established according to the pixel point and the second intersection point; the intersection point of the fifth straight line and the third straight line is the third intersection point; the intersection point of the fifth straight line and the fourth straight line is the fourth intersection point; the intersection point of the sixth straight line and the first straight line is the fifth intersection point; the intersection point of the sixth straight line and the second straight line is the sixth intersection point; Obtaining the plane coordinates of the pixel point after conversion according to the coordinates of the pixel point, the third intersection point, the fourth intersection point, the fifth intersection point and the sixth intersection point and the preset barcode length value and width value; Traversing all pixel points in the mask to obtain the converted plane coordinates of all pixel points in the mask; According to the converted plane coordinates of all the pixel points, a corrected barcode image is obtained.

7. An electronic device, It is characterized in that It comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the barcode correction method based on perspective coordinate transformation as described in any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, and when the computer program is executed by a processor, the barcode correction method based on perspective coordinate transformation as described in any one of claims 1 to 5 is implemented.