Barcode correction method, device, equipment and storage medium

The barcode is corrected through correction parameters determined by semantic segmentation and contour points, which solves the problem of low barcode recognition rate in complex scenes and achieves efficient recognition in low contrast and dirty environments.

CN113723136BActive Publication Date: 2024-10-11GUANGZHOU DAIJIN NETWORK TECHNOLOGY CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202111016561.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-31
Publication Date
2024-10-11
Estimated Expiration
2041-08-31

AI Technical Summary

Technical Problem

It is difficult for existing technology to accurately identify distorted barcodes in complex scenarios, resulting in low recognition rates.

Method used

The code area and contour points in the target image are determined through the semantic segmentation algorithm, and correction parameters are calculated based on this information to correct the barcode, thereby improving the recognition rate.

Benefits of technology

It can accurately identify the position of the code area in complex scenes such as low contrast and stains, and improve the correction adaptability and recognition rate of barcodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113723136B_ABST
    Figure CN113723136B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a barcode correction method, device, equipment and storage medium, which belong to the field of data processing technology. The method includes: semantically segmenting the target image to obtain the background area and the code area in the target image, performing barcode recognition on the code area to determine whether the code area is a barcode, and if the code area is a barcode, determining multiple contour points of the code area, determining correction parameters based on the position information of the multiple contour points, correcting the barcode in the target image based on the correction parameters, obtaining a standard distortion-free barcode, and decoding the standard distortion-free barcode. The embodiments of the present application determine the position information of the code area and each corner point by semantically segmenting the target image, and can accurately identify the position of the code area in complex scenes such as low contrast and contamination, thereby avoiding the influence of complex scenes on the recognition of the position of the code area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of data processing technology, and in particular to a barcode correction method, device, equipment and storage medium. Background Art

[0002] Barcodes include one-dimensional barcodes and two-dimensional barcodes. One-dimensional barcodes are also called barcodes, and two-dimensional barcodes are also called QR codes. Barcodes can be scanned by photoelectric scanning equipment to realize automatic recognition of information. However, when a barcode is attached to a non-planar material, it will cause the barcode to be distorted, forming a distorted barcode, thereby reducing the barcode recognition rate. Therefore, a barcode correction method is urgently needed to correct the distorted barcode to a non-distorted state.

[0003] In the related art, when correcting a barcode, a traditional method such as binarization is usually used to extract the barcode area, thereby obtaining the corner points of the barcode boundary. Then, the barcode is corrected by establishing a fitting mapping function. However, the traditional method of extracting the barcode area is not suitable for extracting barcodes in complex scenes. For example, it is difficult to extract the barcode area in scenes with low contrast, contamination or metal materials. This will reduce the recognition rate of the barcode. Summary of the invention

[0004] The embodiments of the present application provide a barcode correction method, device, equipment and storage medium, which can solve the problem of low code area recognition rate in related technologies. The technical solution is as follows:

[0005] In one aspect, a barcode correction method is provided, the method comprising:

[0006] Performing semantic segmentation on the target image to obtain a background area and a code area in the target image;

[0007] Performing barcode recognition on the code area to determine whether the code area is a barcode;

[0008] In the case where the code region is a barcode, determining a plurality of contour points of the code region;

[0009] determining a correction parameter based on the position information of the plurality of contour points;

[0010] Based on the correction parameters, the barcode in the target image is corrected to obtain a standard distortion-free barcode, and the standard distortion-free barcode is decoded.

[0011] Optionally, determining a plurality of contour points of the code region includes:

[0012] Determine a plurality of boundary points from a portion of line segments other than corner points on each boundary line of the code region;

[0013] The determined multiple boundary points and each corner point of the code area are determined as multiple contour points of the code area.

[0014] Optionally, the determining a plurality of boundary points from a portion of line segments other than corner points on each boundary line of the code region comprises:

[0015] Based on the position information of each corner point of the code area, determining a connecting line between every two adjacent corner points to obtain a plurality of connecting lines;

[0016] Draw a plurality of dividing lines on each of the plurality of connecting lines;

[0017] The intersection points between the plurality of boundary lines of the code area and the respective dividing lines on the corresponding connecting lines are determined to obtain the plurality of boundary points.

[0018] Optionally, a plurality of dividing lines on each connecting line are used to equally divide the corresponding connecting line.

[0019] Optionally, performing barcode recognition on the code region to determine whether the code region is a barcode includes:

[0020] Using the code region as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model;

[0021] Based on the recognition result, it is determined whether the code region is a barcode.

[0022] Optionally, performing barcode recognition on the code region to determine whether the code region is a barcode includes:

[0023] Acquire the central area of ​​the code area;

[0024] Using the central area of ​​the code area as the input of the barcode recognition model to obtain the recognition result output by the barcode recognition model;

[0025] Based on the recognition result, it is determined whether the code region is a barcode.

[0026] Optionally, determining the correction parameters based on the position information of the plurality of contour points includes:

[0027] Based on the position information of the plurality of contour points, determining the position information of a plurality of correction points, the plurality of correction points corresponding one-to-one to the plurality of contour points;

[0028] Determine, based on the position information of the plurality of contour points and the position information of the plurality of correction points, a transformation matrix for mapping the plurality of contour points to the plurality of correction points;

[0029] The transformation matrix is ​​determined as the correction parameter.

[0030] Optionally, the correcting the barcode in the target image based on the correction parameter includes:

[0031] Determine the position information of each pixel in the code area;

[0032] Based on the correction parameters and the position information of each pixel in the code area, the barcode in the target image is corrected.

[0033] On the other hand, a barcode correction device is provided, the device comprising:

[0034] A semantic segmentation module, used for performing semantic segmentation on a target image to obtain a background area and a code area in the target image;

[0035] A barcode recognition module, used for performing barcode recognition on the code area to determine whether the code area is a barcode;

[0036] A contour point determination module, for determining a plurality of contour points of the code region when the code region is a barcode;

[0037] A correction parameter determination module, used to determine the correction parameter based on the position information of the plurality of contour points;

[0038] A correction module, used for correcting the barcode in the target image based on the correction parameters to obtain a standard distortion-free barcode;

[0039] The decoding module is used to decode the standard distortion-free barcode.

[0040] Optionally, the contour point determination module includes:

[0041] A boundary point determination unit, used to determine a plurality of boundary points from a portion of line segments other than corner points on each boundary line of the code area;

[0042] The contour point determination unit is used to determine the determined multiple boundary points and each corner point of the code area as multiple contour points of the code area.

[0043] Optionally, the boundary point determination unit includes:

[0044] A connection line determination subunit, configured to determine a connection line between every two adjacent corner points based on the position information of each corner point of the code area, so as to obtain a plurality of connection lines;

[0045] A dividing line drawing subunit, used to draw a plurality of dividing lines on each of the plurality of connecting lines;

[0046] The intersection point determination subunit is used to determine the intersection points between the multiple boundary lines of the code area and the corresponding division lines on the connecting lines to obtain the multiple boundary points.

[0047] Optionally, a plurality of dividing lines on each connecting line are used to equally divide the corresponding connecting line.

[0048] Optionally, the barcode recognition module includes:

[0049] A first recognition result output unit, used to use the code area as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model;

[0050] A barcode determination unit is used to determine whether the code area is a barcode based on the recognition result.

[0051] Optionally, the barcode recognition module includes:

[0052] A central area acquisition unit, used to acquire the central area of ​​the code area;

[0053] A second recognition result output unit, used to use the central area of ​​the code area as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model;

[0054] A barcode determination unit is used to determine whether the code area is a barcode based on the recognition result.

[0055] Optionally, the correction parameter determination module includes:

[0056] A first position information determining unit, configured to determine position information of a plurality of correction points based on the position information of the plurality of contour points, wherein the plurality of correction points correspond to the plurality of contour points one by one;

[0057] a transformation matrix determining unit, configured to determine a transformation matrix for mapping the plurality of contour points to the plurality of correction points based on the position information of the plurality of contour points and the position information of the plurality of correction points;

[0058] A correction parameter determination unit is used to determine the transformation matrix as the correction parameter.

[0059] Optionally, the correction module includes:

[0060] A second position information determining unit, used to determine the position information of each pixel in the code area;

[0061] A correction unit is used to correct the barcode in the target image based on the correction parameters and the position information of each pixel in the code area.

[0062] On the other hand, a barcode reading device is provided, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of the barcode correction method described above.

[0063] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned barcode correction method are implemented.

[0064] On the other hand, a computer program product comprising instructions is provided. When the instructions are executed on a computer, the computer executes the steps of the barcode correction method described above.

[0065] The technical solution provided by the embodiments of the present application can at least bring the following beneficial effects:

[0066] Since the semantic segmentation algorithm is not easily affected by the scene environment, the semantic segmentation of the target image is performed to determine the position information of the code area and each corner point, so that the position of the code area can be accurately identified in complex scenes such as low contrast and contamination, avoiding the influence of complex scenes on the recognition of the code area position. In addition, since the contour points of the code area are generally applicable, the barcode is corrected based on the position information of multiple contour points of the code area, which can make the barcode correction method more adaptable, thereby improving the recognition rate of the barcode. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0068] Figure 1 It is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0069] Figure 2 It is a structural schematic diagram of a code reading device provided in an embodiment of the present application;

[0070] Figure 3 is a flow chart of a barcode correction method provided in an embodiment of the present application;

[0071] Figure 4 is a schematic diagram of code area division in a target image provided by an embodiment of the present application;

[0072] Figure 5 is a schematic diagram of another code area division in a target image provided by an embodiment of the present application;

[0073] Figure 6 This is a schematic diagram of a first method of determining multiple contour points of a code area provided in an embodiment of the present application;

[0074] Figure 7 is a schematic diagram of a second method of determining multiple contour points of a code area provided in an embodiment of the present application;

[0075] Figure 8 This is a schematic diagram of a third method of determining multiple contour points of a code area provided in an embodiment of the present application;

[0076] Fig. 9 This is a schematic diagram of a barcode correction result provided in an embodiment of the present application;

[0077] Fig.10 It is a structural schematic diagram of a barcode correction device provided in an embodiment of the present application;

[0078] Fig.11 It is a structural schematic diagram of a code reading device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0079] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0080] Before explaining in detail the barcode correction method provided in the embodiment of the present application, the application scenario and implementation environment provided in the embodiment of the present application are first introduced.

[0081] The barcode correction method provided in the embodiment of the present application can be applied to a variety of scenarios. For example, in the field of logistics and warehousing, the barcodes on the items can usually be used to identify and retrieve the items. However, for items with non-planar shapes, the barcodes on the items may be distorted. For example, the barcodes on columnar items such as bottles and cans may have overall surface distortion. Moreover, after photographing such barcodes, due to factors such as the perspective distortion of the imaging device, the shape of the barcode will be distorted and will also have other local distortions, such as perspective or shear distortion. Therefore, the barcode on the item can be corrected by the barcode correction method provided in the embodiment of the present application, thereby improving the recognition rate of the barcode.

[0082] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment according to an exemplary embodiment. The implementation environment includes an image acquisition device 101 and an optoelectronic scanning device 102. The image acquisition device 101 can be connected to the optoelectronic scanning device 102 for communication. The communication connection can be a wired or wireless connection, which is not limited in the present application embodiment.

[0083] The image acquisition device 101 can be used as an imaging device to photograph the barcode on the item, and correct the barcode in the photographed image according to the barcode correction method provided in the embodiment of the present application to obtain a corrected barcode. Then, the image acquisition device 101 can display the corrected barcode to the photoelectric scanning device 102, and the photoelectric scanning device 102 scans the corrected barcode to identify the content of the barcode.

[0084] Of course, the above is an exemplary implementation environment, and in other implementation environments, the image acquisition device 101 may not be included. In this way, the photoelectric scanning device 102 can be used as an imaging device to scan the barcode on the item, and correct the scanned barcode according to the barcode correction method provided in the embodiment of the present application to obtain a corrected barcode. Afterwards, the photoelectric scanning device 102 recognizes the corrected barcode to obtain the content of the barcode.

[0085] That is, the embodiment of the present application can correct the barcode through the image acquisition device 101, or can correct the barcode through the photoelectric scanning device 102. For the convenience of description, the image acquisition device or photoelectric scanning device that corrects the barcode can be called a barcode correction device or a barcode reading device.

[0086] Please refer to Figure 2 The code reading device may include a semantic segmentation module, a contour division module and a correction module. The semantic segmentation module is used to perform semantic segmentation on the captured image to determine the background area and the code area. The contour division module is used to divide the outline of the code area to determine the position information of multiple contour points. The correction module is used to determine the correction parameters based on the position information of the multiple contour points, and based on the correction parameters, correct the barcode in the image to obtain a standard distortion-free barcode.

[0087] Optionally, the barcode reading device may further include a decoding module, which is used to decode the standard distortion-free barcode, that is, to identify the standard distortion-free barcode, thereby obtaining the content of the barcode.

[0088] The image acquisition device 101 may be any device that can interact with the user through one or more methods such as keyboard, touch pad, touch screen, remote control, voice interaction or handwriting device to capture the barcode, such as PC (Personal Computer), mobile phone, smart phone, PDA (Personal Digital Assistant), PPC (Pocket PC), tablet computer, smart TV, etc. The photoelectric scanning device 102 may be a drum scanner, flatbed scanner, handheld scanner, film and transparent medium scanner, etc.

[0089] Those skilled in the art should understand that the above-mentioned image acquisition device 101 and photoelectric scanning device 102 are only examples, and other existing or future image acquisition devices or photoelectric scanning devices, if applicable to the embodiments of the present application, should also be included in the protection scope of the embodiments of the present application and are included here by reference.

[0090] Next, the barcode correction method provided in the embodiment of the present application is explained in detail.

[0091] Figure 3 This is a flowchart of a barcode correction method provided in an embodiment of the present application, which can be applied to a barcode reading device. Figure 3 , the method comprises the following steps.

[0092] Step 301: semantically segment the target image to obtain a background area and a code area in the target image.

[0093] In some embodiments, the target image includes a plurality of pixels, and a semantic segmentation algorithm can be used to segment each pixel in the target image according to different semantic expressions to obtain a plurality of regions, and the plurality of regions correspond to various objects in the target image. Afterwards, the other regions except the code region in the plurality of regions are used as the background region in the target image, thereby obtaining the background region and the code region in the target image.

[0094] It should be noted that each region obtained by semantic segmentation of the target image has a corresponding label, which is used to indicate the category of the object in the corresponding region. That is, through the labels corresponding to the multiple regions, it is possible to determine which region of the multiple regions is the code region and which region is not the code region, so that the background region and the code region in the target image can be distinguished.

[0095] Step 302: Perform barcode recognition on the code area in the target image to determine whether the code area in the target image is a barcode.

[0096] In some embodiments, the code area in the target image can be used as the input of a barcode recognition model to obtain a recognition result output by the barcode recognition model, and based on the recognition result output by the barcode recognition model, it is determined whether the code area in the target image is a barcode.

[0097] In other embodiments, the central area of ​​the code area in the target image can be obtained and used as the input of a barcode recognition model to obtain a recognition result output by the barcode recognition model. Based on the recognition result output by the barcode recognition model, it is determined whether the code area in the target image is a barcode.

[0098] As an example, the recognition result output by the barcode recognition model includes a first probability and a second probability, wherein the first probability is the probability that the code region is a barcode, and the second probability is the probability that the code region is a non-barcode. If the first probability is greater than the second probability, the code region in the target image is determined to be a barcode. If the first probability is less than the second probability, the code region in the target image is determined to be a non-barcode.

[0099] As another example, the recognition result output by the barcode recognition model may also be a specific value. In this case, whether the code area in the target image is a barcode can be determined based on the specific value output by the barcode recognition model. For example, if the specific value output by the barcode recognition model is 1, the code area in the target image is determined to be a barcode. If the specific value output by the barcode recognition model is 0, the code area in the target image is determined to be a non-barcode.

[0100] It should be noted that barcodes include one-dimensional barcodes and two-dimensional barcodes. One-dimensional barcodes are also called barcodes, and two-dimensional barcodes are also called QR codes. Non-barcodes refer to graphics that are similar in appearance to barcodes, but are not barcodes. In addition, the barcode recognition model is trained in advance.

[0101] There are multiple implementation methods for obtaining the central area of ​​the code area, and two of them are introduced below.

[0102] In a first implementation, based on the size ratios corresponding to the stored boundary regions, a plurality of boundary regions included in the code region in the target image is determined, and a region in the code region other than the plurality of boundary regions is determined as a central region of the code region.

[0103] As an example, the size ratios corresponding to the multiple boundary regions are multiplied by the size of the code region in the target image to obtain the size of each boundary region. Then, based on the size of each boundary region, multiple boundary regions are determined from the code region of the target image, and then the region other than the multiple boundary regions in the code region is determined as the central region of the code region.

[0104] The second implementation method is to determine the central area from the code area of ​​the target image based on the size ratio corresponding to the stored central area.

[0105] As an example, the size ratio corresponding to the central area is multiplied by the size of the code area in the target image to obtain the size of the central area. Then, the position information of the geometric center point of the code area in the target image is determined, and based on the size of the central area and the position information of the geometric center point, the central area of ​​the code area is determined so that the geometric center point of the code area coincides with the geometric center point of the code area.

[0106] It should be noted that the size ratio corresponding to the central area and the size ratios corresponding to the multiple boundary areas can be set in advance and can also be adjusted according to different requirements.

[0107] Among them, for the central area and any area in the multiple boundary areas, the size proportion corresponding to the area may include the maximum length proportion and the maximum width proportion, the maximum length proportion is the ratio between the maximum length of the area and the maximum length of the code area, and the maximum width proportion is the ratio between the maximum width of the area and the maximum width of the code area. In this way, the maximum length proportion corresponding to the area can be multiplied by the maximum length of the code area to obtain the maximum length of the area, and the maximum width proportion corresponding to the area can be multiplied by the maximum width of the code area to obtain the maximum width of the area, so as to obtain the size of the area.

[0108] In addition, the size ratio corresponding to the region may also be the ratio between the area of ​​the region and the area of ​​the code region. In this way, the size ratio corresponding to the region may be multiplied by the area of ​​the code region to obtain the area of ​​the region, that is, the size of the region.

[0109] It should be noted that, since the shape of the distorted code area is usually not a regular shape, for example, part of the surface of the code area is curved, the length of the code area usually includes a maximum length and a minimum length, so the above-mentioned regions may also include a maximum length and a minimum length. Similarly, the width of the code area includes a maximum width and a minimum width, and the above-mentioned regions also include a maximum width and a minimum width.

[0110] For example, please refer to Figure 4 , assuming that the size proportions corresponding to the upper boundary area include the maximum length proportion of 1 and the maximum width proportion of 1 / 5, multiply the maximum length proportion of the upper boundary area by the maximum length of the code area to obtain the length of the upper boundary area, and multiply the maximum width proportion of the upper boundary area by the maximum width of the code area to obtain the width of the upper boundary area. Based on the length and width of the upper boundary area, it can be determined that the upper boundary area is Figure 4 In the same way, the lower boundary area can be determined as Figure 4 The area indicated by U2 in the figure, the left border area is Figure 4 The area indicated by V1 in the figure, the right border area is Figure 4 The area indicated by V2 in the figure. Figure 4 The area C1 excluding the four boundary areas is determined as the central area of ​​the code area.

[0111] For example, please refer to Figure 5, assuming that the corresponding size proportion of the center area is 1 / 2, and the maximum width is 3 / 5, multiply the maximum length proportion of the center area by the maximum length of the code area to get the length of the center area. Multiply the maximum width proportion of the center area by the maximum width of the code area to get the width of the center area. Assuming that the geometric center point of the code area is point O, then based on the length and width of the center area and the position information of point O, the center area can be determined as Figure 5 The area indicated by C1.

[0112] Step 303: When the code area in the target image is a barcode, determine a plurality of contour points of the code area.

[0113] In some embodiments, multiple boundary points are determined from the partial line segments on each boundary line of the code region except the corner points, and the determined multiple boundary points and the corner points of the code region are determined as multiple contour points of the code region.

[0114] When determining the multiple boundary points, the partial line segments on each boundary line except the corner points can be directly divided, or the partial line segments on each boundary line except the corner points can be indirectly divided. That is, the partial line segments on each boundary line except the corner points can be directly divided, and the division points are determined as the multiple boundary points. Alternatively, based on the position information of each corner point in the code area in the target image, the connecting line between each adjacent two corner points is determined to obtain multiple connecting lines. Multiple dividing lines are drawn on each connecting line in the multiple connecting lines, and the intersection points between the multiple boundary lines of the code area and the corresponding dividing lines on the connecting lines are determined to obtain multiple boundary points.

[0115] In an embodiment of the present application, a coordinate system can be established in the target image. In this way, after the code area in the target image is determined through semantic segmentation, the coordinates of each corner point of the code area in the coordinate system can be obtained to obtain the position information of each corner point.

[0116] When dividing the line segments on each boundary line except the corner points, the line segments can be divided equally or unequally. For any of the multiple connecting lines, the connecting line can be divided equally to determine multiple dividing points, and a dividing line is drawn at each dividing point along a direction perpendicular to the connecting line to obtain multiple dividing lines.

[0117] It should be noted that, for the multiple connecting lines, multiple dividing lines can be drawn on each connecting line in the same manner. Of course, multiple dividing lines can also be drawn on the corresponding connecting lines in different manners, and the embodiments of the present application do not limit this. Moreover, for the same connecting line, the multiple dividing lines on the connecting line can divide the connecting line equally or unequally. That is, the distance between each two adjacent dividing lines in the multiple dividing lines on the same connecting line can be equal or unequal.

[0118] For example, please refer to Figure 6 , 3 boundary points 12, 13, and 14 are determined from the partial line segments on the upper boundary line 1-3 of the code area except the corner points. Similarly, 4 boundary points 15, 16, 17, and 18 are determined from the partial line segments on the lower boundary line 2-4 of the code area except the corner points. Secondly, 4 boundary points 5, 6, 7, and 8 are determined from the partial line segments on the left boundary line 1-2 of the code area except the corner points. And 3 boundary points 9, 10, and 11 are determined from the partial line segments on the right boundary line 3-4 of the code area except the corner points. The 14 boundary points determined and the 4 corner points of the code area are determined as the 18 contour points of the code area.

[0119] For example, please refer to Figure 7 , connect the two corner points 1 and 3 of the code area to obtain the connecting line 1-3. Divide the connecting line 1-3 into 4 equal parts, thereby determining 3 equal division points, and draw a dividing line at each equal division point along a direction perpendicular to the connecting line 1-3 to obtain 3 dividing lines. Secondly, determine the intersection between the outer contour line of the upper boundary area and the 3 dividing lines on the connecting line 1-3, thereby obtaining 3 intersection points 11, 12, and 13. Next, according to the same method, determine the connecting line 1-2, the connecting line 2-4, and the connecting line 3-4, and then determine the intersection between the outer contour line of the left boundary area and the 3 dividing lines on the connecting line 1-2, the intersection between the outer contour line of the lower boundary area and the 3 dividing lines on the connecting line 2-4, and the intersection between the outer contour line of the right boundary area and the 3 dividing lines on the connecting line 3-4, thereby obtaining 9 intersection points 5, 6, 7, 8, 9, 10, 14, 15, and 16. The 12 intersection points and the 4 corner points of the code area are determined as the 16 contour points of the code area.

[0120] For example, please refer to Figure 8, connect the two corner points 1 and 3 of the code area to obtain the connection line 1-3. Divide the connection line 1-3 into 4 equal parts to determine 3 equal division points, and draw a dividing line at each equal division point in a direction perpendicular to the connection line 1-3 to obtain 3 dividing lines. Secondly, determine the intersection points between the outer contour line of the upper boundary area and the 3 dividing lines on the connection line 1-3, thereby obtaining 3 intersection points 12, 13, and 14. Similarly, connect the two corner points 2 and 4 of the code area to obtain the connection line 2-4, divide the connection line 2-4 into 5 equal parts to determine 4 equal division points, and draw a dividing line at each equal division point in a direction perpendicular to the connection line 2-4 to obtain 4 dividing lines. Secondly, determine the intersection points between the outer contour line of the lower boundary area and the 4 dividing lines on the connection line 2-4, and obtain the 4 intersection points 15, 16, 17, and 18. After that, the connecting lines 1-2 and 3-4 are determined, and then the intersection points between the outer contour line of the left boundary area and the four dividing lines on the connecting line 1-2 are determined, and the four intersection points 5, 6, 7, and 8 are obtained. And the intersection points between the outer contour line of the right boundary area and the three dividing lines on the connecting line 3-4 are determined, and the three intersection points 9, 10, and 11 are obtained. The 14 intersection points and the four corner points of the code area are determined as the 18 contour points of the code area.

[0121] Step 304: Determine correction parameters based on the position information of the plurality of contour points.

[0122] In some embodiments, the position information of the plurality of correction points may be determined based on the position information of the plurality of contour points, and the plurality of correction points correspond to the plurality of contour points one by one. Based on the position information of the plurality of contour points and the position information of the plurality of correction points, a transformation matrix mapping the plurality of contour points to the plurality of correction points may be determined, and the transformation matrix may be determined as a correction parameter.

[0123] In the embodiment of the present application, the position information of the multiple correction points can be determined in a variety of ways based on the position information of the multiple contour points. Two implementation methods are introduced below. Since the method of determining the correction point corresponding to each contour point is the same, any contour point among the multiple contour points is used as an example for description below. For ease of description, any contour point is referred to as a target contour point, and the boundary line where the target contour point is located is referred to as a target boundary line.

[0124] The first implementation method isA corner point is selected from the corner points at both ends of the target boundary line as a reference corner point, and the length of the boundary line segment between the target contour point and the reference corner point is determined to obtain a first length. Then, the total length of the target boundary line and the length of the target fitting curve are determined, the target fitting curve is the fitting curve corresponding to the target boundary line, and the target fitting curve is the corrected target boundary line. The ratio between the first length and the total length of the target boundary line is determined, and the ratio is multiplied by the length of the target fitting curve to obtain a second length. Afterwards, a point located on the target fitting curve and having a curve length between the reference corner point and the second length is determined as a correction point corresponding to the target contour point, thereby determining the position information of the correction point.

[0125] It should be noted that the fitting curve corresponding to each boundary line of the code region refers to the corrected boundary line, and the fitting curve corresponding to each boundary line can be determined by a variety of methods.

[0126] As an example, the shape of the barcode can be determined. If the barcode is a square, one boundary line is selected from the four boundary lines of the barcode, and the length of the selected boundary line is determined as the length of the fitting curve corresponding to each boundary line of the barcode. Afterwards, based on the position information of the corner points at both ends of the selected boundary line and the length of the fitting curve corresponding to each boundary line of the barcode, the position information of the correction points corresponding to the four corner points of the barcode are determined according to the square, and then the line between each two adjacent correction points is determined as the fitting curve corresponding to each boundary line of the barcode.

[0127] Similarly, if the barcode is a rectangle, two adjacent boundary lines are selected from the four boundary lines of the barcode, and the lengths of the selected two adjacent boundary lines are determined as the lengths of the fitting curves corresponding to the long side of the barcode and the lengths of the fitting curves corresponding to the short side. Afterwards, based on the position information of the three corner points on the two selected boundary lines, the lengths of the fitting curves corresponding to the long side of the barcode and the lengths of the fitting curves corresponding to the short side, the position information of the correction points corresponding to the four corner points of the barcode are determined according to the rectangle, and then the connecting line between each two adjacent correction points is determined as the fitting curve corresponding to each boundary line of the barcode.

[0128] When determining whether the code area is a barcode, it is also possible to determine whether the barcode is a barcode or a QR code. Since barcodes are usually rectangular and QR codes are usually square, after determining whether the barcode is a barcode or a QR code, the shape of the barcode can be determined.

[0129] The second implementation method isA corner point is selected from the corner points at both ends of the target boundary line as a reference corner point, and a line connecting the target contour point and the reference corner point is determined, and then the angle between the line and the reference line corresponding to the target boundary line, i.e., the first angle, is determined. The reference line corresponding to the target boundary line is perpendicular to the target fitting curve, and the target fitting curve is the fitting curve corresponding to the target boundary line, and the target fitting curve is the corrected target boundary line. Then, based on the length of the line connecting the target contour point and the reference corner point and the first angle, the length of the projection line of the line connecting the target contour point and the reference corner point on the target fitting curve is determined to obtain a second length. A point located on the target fitting curve and having a curve length between the target contour point and the reference corner point of the second length is determined as the correction point corresponding to the target contour point, thereby determining the position information of the correction point.

[0130] It should be noted that when the target boundary line is the upper boundary line or the lower boundary line, the reference line corresponding to the target boundary line is a vertical line, and when the target boundary line is the left boundary line or the right boundary line, the reference line corresponding to the target boundary line is a horizontal line.

[0131] The method for determining the fitting curves corresponding to the boundary lines of the code area may refer to the relevant contents in the first implementation method mentioned above, which will not be described in detail here.

[0132] Step 305: Based on the correction parameters, the barcode in the target image is corrected to obtain a standard distortion-free barcode, and the standard distortion-free barcode is decoded.

[0133] In some embodiments, the position information of each pixel in the code area of ​​the target image is determined. Based on the correction parameters and the position information of each pixel in the code area of ​​the target image, the barcode in the target image is corrected to obtain a standard distortion-free barcode, which can be decoded to obtain the content of the barcode.

[0134] Optionally, not only the barcode in the target image can be corrected, but also the background area in the target image can be corrected in some cases. In this case, the position information of each pixel in the target image can be directly determined, and the target image can be corrected based on the correction parameters and the position information of each pixel in the target image. That is, both the background area and the code area in the target image are corrected.

[0135] Based on the above description, the target image includes multiple pixels, and a coordinate system is established in the target image, so the coordinates of each pixel in the coordinate system can be directly obtained to obtain the position information of each pixel. After that, the position information of each pixel is multiplied by the correction parameter to obtain the corrected position information of each pixel.

[0136] Fig. 9This is a schematic diagram of a barcode correction result provided in the embodiment of the present application. Please refer to Fig. 9 The left picture shows a distorted barcode in a target image, and the right picture shows a barcode in a target image corrected by a barcode correction method provided in an embodiment of the present application, thereby obtaining a corrected barcode.

[0137] In the embodiment of the present application, since the semantic segmentation algorithm is not easily affected by the scene environment, the position information of the code area and each corner point is determined by semantically segmenting the target image, and the position of the code area can be accurately identified in complex scenes such as low contrast and contamination, thereby avoiding the influence of complex scenes on the recognition of the code area position. Moreover, since the contour points of the code area are generally applicable, the barcode is corrected based on the position information of multiple contour points of the code area, which can make the barcode correction method more adaptable, thereby improving the recognition rate of the barcode.

[0138] Fig.10 is a schematic diagram of the structure of a barcode correction device provided in an embodiment of the present application. The barcode correction device can be implemented by software, hardware or a combination of both to become part or all of a barcode reading device. The barcode reading device can be Figure 1 Please refer to the code reading device shown. Fig.10 The device includes: a semantic segmentation module 1001, a barcode recognition module 1002, a contour point determination module 1003, a correction parameter determination module 1004, a correction module 1005 and a decoding module 1006.

[0139] The semantic segmentation module 1001 is used to perform semantic segmentation on the target image to obtain the background area and the code area in the target image. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0140] The barcode recognition module 1002 is used to perform barcode recognition on the code area in the target image to determine whether the code area in the target image is a barcode. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0141] The contour point determination module 1003 is used to determine multiple contour points of the code area when the code area in the target image is a barcode. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0142] The correction parameter determination module 1004 is used to determine the correction parameter based on the position information of the multiple contour points in the code area. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0143] The correction module 1005 is used to correct the barcode in the target image based on the correction parameter to obtain a standard distortion-free barcode. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0144] The decoding module 1006 is used to decode the standard distortion-free barcode. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0145] Optionally, the contour point determination module 1003 includes:

[0146] A boundary point determination unit, used to determine a plurality of boundary points from a portion of line segments other than corner points on each boundary line of the code area;

[0147] The contour point determination unit is used to determine the determined multiple boundary points and each corner point of the code area as multiple contour points of the code area.

[0148] Optionally, the boundary point determination unit includes:

[0149] A connecting line determining subunit, used to determine the connecting line between every two adjacent corner points based on the position information of each corner point of the code area in the target image, so as to obtain a plurality of connecting lines;

[0150] A dividing line drawing subunit, used for drawing a plurality of dividing lines on each of the plurality of connecting lines;

[0151] The intersection point determination subunit is used to determine the intersection points between the multiple boundary lines of the code area and the corresponding division lines on the connection line to obtain multiple boundary points.

[0152] Optionally, a plurality of dividing lines on each connecting line are used to equally divide the corresponding connecting line.

[0153] Optionally, the barcode recognition module 1002 includes:

[0154] A first recognition result output unit, used to use the code area in the target image as an input of the barcode recognition model to obtain a recognition result output by the barcode recognition model;

[0155] The barcode determination unit is used to determine whether the code area in the target image is a barcode based on the recognition result output by the barcode recognition model.

[0156] Optionally, the barcode recognition module 1002 includes:

[0157] A central area acquisition unit, used to acquire the central area of ​​the code area in the target image;

[0158] A second recognition result output unit, used to use the central area of ​​the code area as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model;

[0159] The barcode determination unit is used to determine whether the code area in the target image is a barcode based on the recognition result output by the barcode recognition model.

[0160] Optionally, the correction parameter determination module 1004 includes:

[0161] A first position information determining unit, configured to determine position information of a plurality of correction points based on the position information of the plurality of contour points, the plurality of correction points corresponding to the plurality of contour points one by one;

[0162] A transformation matrix determining unit, configured to determine a transformation matrix for mapping the plurality of contour points to the plurality of correction points based on the position information of the plurality of contour points and the position information of the plurality of correction points;

[0163] The correction parameter determination unit is used to determine the transformation matrix as a correction parameter.

[0164] Optionally, the correction module 1005 includes:

[0165] A second position information determining unit, used to determine the position information of each pixel in the code area of ​​the target image;

[0166] The correction unit is used to correct the barcode in the target image based on the correction parameter and the position information of each pixel in the target image.

[0167] In the embodiment of the present application, since the semantic segmentation algorithm is not easily affected by the scene environment, the position information of the code area and each corner point is determined by semantically segmenting the target image, and the position of the code area can be accurately identified in complex scenes such as low contrast and contamination, thereby avoiding the influence of complex scenes on the recognition of the code area position. Moreover, since the contour points of the code area are generally applicable, the barcode is corrected based on the position information of multiple contour points of the code area, which can make the barcode correction method more adaptable, thereby improving the recognition rate of the barcode.

[0168] It should be noted that: the barcode correction device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate when correcting the barcode in the target image. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the barcode correction device provided in the above embodiment and the barcode correction method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0169] Fig.11 1 is a block diagram of a terminal 1100 provided in an embodiment of the present application. The terminal 1100 is the above-mentioned code reading device, and can be a portable mobile terminal, such as a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 1100 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0170] Typically, the terminal 1100 includes a processor 1101 and a memory 1102 .

[0171] The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1101 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1101 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1101 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0172] The memory 1102 may include one or more computer-readable storage media, which may be non-transitory. The memory 1102 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, which is used to be executed by the processor 1101 to implement the barcode correction method provided in the method embodiment of the present application.

[0173] In some embodiments, the terminal 1100 may also optionally include: a peripheral device interface 1103 and at least one peripheral device. The processor 1101, the memory 1102 and the peripheral device interface 1103 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1103 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1104, a touch display screen 1105, a camera 1106, an audio circuit 1107, a positioning component 1108 and a power supply 1109.

[0174] The peripheral device interface 1103 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1101 and the memory 1102. In some embodiments, the processor 1101, the memory 1102, and the peripheral device interface 1103 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1101, the memory 1102, and the peripheral device interface 1103 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0175] The radio frequency circuit 1104 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1104 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1104 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1104 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 1104 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1104 may also include circuits related to NFC (Near Field Communication), which is not limited in the embodiments of the present application.

[0176] The display screen 1105 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1105 is a touch display screen, the display screen 1105 also has the ability to collect touch signals on the surface or above the surface of the display screen 1105. The touch signal can be input to the processor 1101 as a control signal for processing. At this time, the display screen 1105 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1105 can be one, and the front panel of the terminal 1100 is set; in other embodiments, the display screen 1105 can be at least two, which are respectively set on different surfaces of the terminal 1100 or are folded; in some other embodiments, the display screen 1105 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 1100. Even, the display screen 1105 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1105 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0177] The camera assembly 1106 is used to capture images or videos. Optionally, the camera assembly 1106 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1106 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0178] The audio circuit 1107 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1101 for processing, or input them into the radio frequency circuit 1104 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1100. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1101 or the radio frequency circuit 1104 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1107 may also include a headphone jack.

[0179] The positioning component 1108 is used to locate the current geographical location of the terminal 1100 to implement navigation or LBS (Location Based Service). The positioning component 1108 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system or Russia's Galileo system.

[0180] The power supply 1109 is used to power various components in the terminal 1100. The power supply 1109 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1109 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0181] In some embodiments, the terminal 1100 further includes one or more sensors 1110 , including but not limited to: an acceleration sensor 1111 , a gyroscope sensor 1112 , a pressure sensor 1113 , a fingerprint sensor 1114 , an optical sensor 1115 , and a proximity sensor 1116 .

[0182] The acceleration sensor 1111 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1100. For example, the acceleration sensor 1111 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1101 can control the touch display screen 1105 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1111. The acceleration sensor 1111 can also be used for collecting game or user motion data.

[0183] The gyro sensor 1112 can detect the body direction and rotation angle of the terminal 1100, and the gyro sensor 1112 can cooperate with the acceleration sensor 1111 to collect the user's 3D actions on the terminal 1100. The processor 1101 can implement the following functions based on the data collected by the gyro sensor 1112: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0184] The pressure sensor 1113 can be set on the side frame of the terminal 1100 and / or the lower layer of the touch display screen 1105. When the pressure sensor 1113 is set on the side frame of the terminal 1100, the user's holding signal of the terminal 1100 can be detected, and the processor 1101 performs left and right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 1113. When the pressure sensor 1113 is set on the lower layer of the touch display screen 1105, the processor 1101 controls the operability controls on the UI interface according to the user's pressure operation on the touch display screen 1105. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0185] The fingerprint sensor 1114 is used to collect the user's fingerprint, and the processor 1101 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 1114, or the fingerprint sensor 1114 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 1101 authorizes the user to perform relevant sensitive operations, which include unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 1114 can be set on the front, back, or side of the terminal 1100. When a physical button or a manufacturer logo is set on the terminal 1100, the fingerprint sensor 1114 can be integrated with the physical button or the manufacturer logo.

[0186] The optical sensor 1115 is used to collect the ambient light intensity. In one embodiment, the processor 1101 can control the display brightness of the touch display screen 1105 according to the ambient light intensity collected by the optical sensor 1115. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 1105 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 1105 is reduced. In another embodiment, the processor 1101 can also dynamically adjust the shooting parameters of the camera assembly 1106 according to the ambient light intensity collected by the optical sensor 1115.

[0187] The proximity sensor 1116, also called a distance sensor, is usually arranged on the front panel of the terminal 1100. The proximity sensor 1116 is used to collect the distance between the user and the front of the terminal 1100. In one embodiment, when the proximity sensor 1116 detects that the distance between the user and the front of the terminal 1100 is gradually decreasing, the processor 1101 controls the touch display screen 1105 to switch from the screen-on state to the screen-off state; when the proximity sensor 1116 detects that the distance between the user and the front of the terminal 1100 is gradually increasing, the processor 1101 controls the touch display screen 1105 to switch from the screen-off state to the screen-on state.

[0188] Those skilled in the art will understand that Fig.11 The structure shown in the figure does not constitute a limitation on the terminal 1100, and the terminal 1100 may include more or fewer components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0189] In some embodiments, a computer-readable storage medium is also provided, in which a computer program is stored, and when the computer program is executed by a processor, the steps of the barcode correction method in the above embodiment are implemented. For example, the computer-readable storage medium can be a ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.

[0190] It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transitory storage medium.

[0191] It should be understood that all or part of the steps to implement the above embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.

[0192] That is, in some embodiments, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the steps of the barcode correction method described above.

[0193] It should be understood that the "at least one" mentioned herein refers to one or more, and "multiple" refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit them to be necessarily different.

[0194] The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A barcode correction method, It is characterized in that The method comprises: Performing semantic segmentation on the target image to obtain a background area and a code area in the target image; Performing barcode recognition on the code region by using a barcode recognition model to determine whether the code region is a barcode, wherein the barcode recognition model is pre-trained, and an output result of the barcode recognition model can indicate whether the code region is a barcode; In the case where the code area is a barcode, based on the position information of each corner point of the code area, a connecting line between each adjacent two corner points is determined to obtain a plurality of connecting lines; a plurality of dividing lines are drawn on each connecting line of the plurality of connecting lines; intersection points between the plurality of boundary lines of the code area and the respective dividing lines on the corresponding connecting lines are determined to obtain a plurality of boundary points, and the determined plurality of boundary points and each corner point of the code area are determined as a plurality of contour points of the code area; Determine the shape of the barcode; if the barcode is a square, select one boundary line from the four boundary lines of the code area, determine the length of the selected boundary line as the length of the fitting curve corresponding to each boundary line of the code area, and determine the position information of the correction points corresponding to the four corner points of the code area according to the square based on the position information of the corner points at both ends of the selected boundary line and the length of the fitting curve corresponding to each boundary line of the code area, and then determine the connecting line between each two adjacent correction points as the fitting curve corresponding to each boundary line of the code area; if the barcode is a rectangle, select two adjacent boundary lines from the four boundary lines of the code area, determine the length of the selected two adjacent boundary lines as the length of the fitting curve corresponding to the long side of the code area and the length of the fitting curve corresponding to the short side, and determine the position information of the correction points corresponding to the four corner points of the code area according to the rectangle based on the position information of the three corner points on the two selected boundary lines, the length of the fitting curve corresponding to the long side of the code area and the length of the fitting curve corresponding to the short side, and then determine the connecting line between each two adjacent correction points as the fitting curve corresponding to each boundary line of the code area; Based on the position information of the plurality of contour points, determining the position information of the plurality of correction points, the plurality of correction points corresponding to the plurality of contour points one by one; based on the position information of the plurality of contour points and the position information of the plurality of correction points, determining the transformation matrix mapping the plurality of contour points to the plurality of correction points; determining the transformation matrix as a correction parameter; Based on the correction parameters, the barcode in the target image is corrected to obtain a standard distortion-free barcode, and the standard distortion-free barcode is decoded; Wherein, based on the position information of the plurality of contour points, determining the position information of the plurality of correction points comprises: A corner point is selected from the corner points at both ends of the target boundary line as the reference corner point, a line between the target contour point and the reference corner point is determined, and then the angle between the line and the reference line corresponding to the target boundary line is determined to obtain a first angle. The reference line corresponding to the target boundary line is perpendicular to the target fitting curve. The target fitting curve is the fitting curve corresponding to the target boundary line. Based on the length of the line between the target contour point and the reference corner point and the first angle, the length of the projection line of the line between the target contour point and the reference corner point on the target fitting curve is determined to obtain a second length. A point on the target fitting curve whose curve length with the reference corner point is the second length is determined as a correction point corresponding to the target contour point, thereby determining the position information of the correction point.

2. The method according to claim 1, It is characterized in that The multiple dividing lines on each connecting line are used to equally divide the corresponding connecting line.

3. The method according to claim 1, It is characterized in that The performing barcode recognition on the code region by using a barcode recognition model to determine whether the code region is a barcode includes: Using the code region as input of the barcode recognition model to obtain a recognition result output by the barcode recognition model; Based on the recognition result, it is determined whether the code region is a barcode.

4. The method according to claim 1, It is characterized in that The performing barcode recognition on the code region by using a barcode recognition model to determine whether the code region is a barcode includes: Acquire the central area of ​​the code area; Using the central area of ​​the code area as the input of the barcode recognition model to obtain the recognition result output by the barcode recognition model; Based on the recognition result, it is determined whether the code region is a barcode.

5. The method according to claim 1, It is characterized in that The step of correcting the barcode in the target image based on the correction parameter includes: Determine the position information of each pixel in the code area; Based on the correction parameters and the position information of each pixel in the code area, the barcode in the target image is corrected.

6. A barcode correction device, It is characterized in that The device comprises: A semantic segmentation module, used for performing semantic segmentation on a target image to obtain a background area and a code area in the target image; A barcode recognition module, used for performing barcode recognition on the code area through a barcode recognition model to determine whether the code area is a barcode, wherein the barcode recognition model is pre-trained, and an output result of the barcode recognition model can indicate whether the code area is a barcode; A contour point determination module, for determining a plurality of contour points of the code region when the code region is a barcode; A correction parameter determination module, used to determine the correction parameter based on the position information of the plurality of contour points; A correction module, used for correcting the barcode in the target image based on the correction parameters to obtain a standard distortion-free barcode; A decoding module, used for decoding the standard distortion-free barcode; Wherein, the contour point determination module includes: A boundary point determination unit, used to determine a plurality of boundary points from a portion of line segments other than corner points on each boundary line of the code area; A contour point determination unit, used for determining the determined multiple boundary points and each corner point of the code area as multiple contour points of the code area; Wherein, the boundary point determination unit includes: A connection line determination subunit, configured to determine a connection line between every two adjacent corner points based on the position information of each corner point of the code area, so as to obtain a plurality of connection lines; A dividing line drawing subunit, used to draw a plurality of dividing lines on each of the plurality of connecting lines; An intersection point determination subunit, used to determine the intersection points between the plurality of boundary lines of the code area and the respective dividing lines on the corresponding connecting lines, so as to obtain the plurality of boundary points; Wherein, the correction parameter determination module includes: The first position information determining unit is used to determine the position information of the plurality of correction points based on the position information of the plurality of contour points, and the plurality of correction points correspond to the plurality of contour points one by one; wherein the first position information determining unit is specifically used to: determine the shape of the barcode; if the barcode is a square, select one boundary line from the four boundary lines of the code area, determine the length of the selected boundary line as the length of the fitting curve corresponding to each boundary line of the code area, and determine the position information of the correction points corresponding to the four corner points of the code area according to the square based on the position information of the corner points at both ends of the selected boundary line and the length of the fitting curve corresponding to each boundary line of the code area, and then determine the position information of the correction points corresponding to each of the four corner points of the code area according to the square, and then determine the position information of the correction points corresponding to each of the two adjacent ones of the two boundary lines of the code area; The connecting line between the correction points is determined as the fitting curve corresponding to each boundary line of the code area; if the barcode is a rectangle, two adjacent boundary lines are selected from the four boundary lines of the code area, and the length of the selected two adjacent boundary lines is determined as the length of the fitting curve corresponding to the long side of the code area and the length of the fitting curve corresponding to the short side. Based on the position information of the three corner points on the two selected boundary lines, the length of the fitting curve corresponding to the long side of the code area and the length of the fitting curve corresponding to the short side, the position information of the correction points corresponding to the four corner points of the code area are determined according to the rectangle, and then the connecting line between each two adjacent correction points is determined as the fitting curve corresponding to each boundary line of the code area; a transformation matrix determining unit, configured to determine a transformation matrix for mapping the plurality of contour points to the plurality of correction points based on the position information of the plurality of contour points and the position information of the plurality of correction points; A correction parameter determination unit, configured to determine the transformation matrix as the correction parameter; Wherein, based on the position information of the plurality of contour points, determining the position information of the plurality of correction points comprises: A corner point is selected from the corner points at both ends of the target boundary line as the reference corner point, a line between the target contour point and the reference corner point is determined, and then the angle between the line and the reference line corresponding to the target boundary line is determined to obtain a first angle. The reference line corresponding to the target boundary line is perpendicular to the target fitting curve. The target fitting curve is the fitting curve corresponding to the target boundary line. Based on the length of the line between the target contour point and the reference corner point and the first angle, the length of the projection line of the line between the target contour point and the reference corner point on the target fitting curve is determined to obtain a second length. A point on the target fitting curve whose curve length with the reference corner point is the second length is determined as a correction point corresponding to the target contour point, thereby determining the position information of the correction point.

7. The device according to claim 6, It is characterized in that The multiple dividing lines on each connecting line are used to equally divide the corresponding connecting line; Wherein, the barcode recognition module includes: A first recognition result output unit, used to use the code area as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model; a barcode determination unit, configured to determine whether the code area is a barcode based on the recognition result; Wherein, the barcode recognition module includes: A central area acquisition unit, used to acquire the central area of ​​the code area; A second recognition result output unit, used to use the central area of ​​the code area as an input of a barcode recognition model to obtain a recognition result output by the barcode recognition model; a barcode determination unit, configured to determine whether the code area is a barcode based on the recognition result; Wherein, the correction module comprises: A second position information determining unit, used to determine the position information of each pixel in the code area; A correction unit is used to correct the barcode in the target image based on the correction parameters and the position information of each pixel in the code area.

8. A code reading device, It is characterized in that The code reading device includes a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the steps of any one of the methods described in claims 1-5.

9. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Two-dimension code recognition method and device

    CN104766037A

  • Distortion image correction based QR (quick response) code decoding method and system

    CN105046256A

  • Image correction method for two-dimensional code distorted image

    CN105701434A

  • Identification method and electronic equipment

    CN106156674A

  • Bar code positioning method and system based on neural network

    CN109543486A