Bar code image recognition method, device, equipment and storage medium

By identifying the endpoint positions and states of line segments in barcode images, the problem of recognition accuracy caused by high-speed inkjet printing in barcode recognition is solved, and efficient barcode decoding is achieved.

CN119647501BActive Publication Date: 2025-11-07BEIJING TSINGTENG MICROSYSTEM CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411800920.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-11-07
Estimated Expiration
2044-12-09

AI Technical Summary

Technical Problem

Existing barcode recognition algorithms struggle to achieve efficient recognition due to issues such as inaccurate spatial spacing, blurring, and severe diffusion caused by high-speed inkjet printing, thus affecting recognition accuracy.

Method used

By identifying the position of the first endpoint of each line segment in the barcode image, the target classification line is determined, and the line segment state is determined based on the positional relationship between the endpoint and the classification line. Finally, decoding is performed to achieve fast barcode decoding.

Benefits of technology

It improves the accuracy and efficiency of barcode recognition and enables rapid barcode decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119647501B_ABST
    Figure CN119647501B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of image processing, and particularly provides a bar code image recognition method and device, equipment and a storage medium, the method comprising the following steps: acquiring a to-be-recognized bar code image, the to-be-recognized bar code image comprising a plurality of parallel line segments; recognizing the positions of first end points of the line segments; determining a target classification line of the first end points according to a set rule; determining the states of the first end points based on the positional relationship between the positions of the first end points and the target classification line of the first end points; determining the states of the line segments based on the states of the first end points of the line segments; and decoding based on the states of the line segments to obtain a recognition result of the to-be-recognized bar code image. The states of the line segments in the bar code are efficiently determined by utilizing the characteristic that the single-side end points of the bar code are located on a straight line, thereby realizing fast decoding of the bar code, and the recognition precision is good.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to a barcode image recognition method and device, equipment and storage medium. BACKGROUND

[0002] At present, barcodes are widely used in logistics company business points or postal companies, and the development purpose is to store information such as sender, delivery address and postal code. Barcodes are generally printed on paper planes, which can be printed in dark color on light background or in light color on dark background, as long as there is enough contrast to ensure readability. Barcodes usually use high-speed inkjet printing and other marking technologies.

[0003] However, the high-speed product marking scheme is accompanied by problems such as inaccurate spatial interval, easy blur and serious diffusion, which brings challenges to the recognition algorithm. SUMMARY

[0004] In order to solve the above technical problems, the present application provides a barcode image recognition method, device, equipment and storage medium, which efficiently determines the state of each line segment in the barcode, and realizes fast decoding of the barcode with good recognition accuracy.

[0005] In a first aspect, the present application provides a barcode image recognition method, which comprises: acquiring a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments; identifying the position of the first endpoint of each line segment; determining the target classification line of the first endpoint according to a set rule; determining the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint; determining the state of each line segment based on the state of the first endpoint of each line segment; and decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image.

[0006] In a second aspect, the present application provides a barcode image recognition device, which comprises: an image acquisition module for acquiring a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments; an endpoint position identification module for identifying the position of the first endpoint of each line segment; a classification line determination module for determining the target classification line of the first endpoint according to a set rule; an endpoint state determination module for determining the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint; a line segment state determination module for determining the state of each line segment based on the state of the first endpoint of each line segment; and a state decoding module for decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image.

[0007] In a third aspect, the present application provides a barcode image recognition device, comprising: one or more processors; a storage device for storing one or more programs; and when the one or more programs are executed by the one or more processors, the one or more processors implement the barcode image recognition method in the first aspect.

[0008] In a fourth aspect, the present application provides a storage medium, which can be a computer readable storage medium, and the storage medium has stored thereon a computer program, and the computer program is executed by a processor to implement the barcode image recognition method in the first aspect.

[0009] In a fifth aspect, the present application provides a computer program product, which comprises a computer program or instructions, and the computer program or instructions are executed by a processor to implement the barcode image recognition method in any one of the first aspect.

[0010] The present application provides a barcode image recognition method, device, equipment and storage medium, the method comprising: obtaining a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments; recognizing the position of the first endpoint of each line segment; determining the target classification line of the first endpoint according to a set rule; determining the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint; determining the state of each line segment based on the state of the first endpoint of each line segment; and decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image. The characteristics of the barcode single-side endpoint being located on a straight line are utilized to efficiently determine the state of each line segment in the barcode, and then the fast decoding of the barcode is realized, and the recognition accuracy is good. BRIEF DESCRIPTION OF DRAWINGS

[0011] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate one embodiment consistent with the present application and, together with the description, serve to explain the principles of the application.

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0013] Figure 1 A flowchart of the barcode image recognition method provided by the present application embodiment is shown in the figure;

[0014] Figure 2 A schematic diagram of a binary barcode provided by the present application embodiment is shown in the figure;

[0015] Figure 3A flowchart of a method for determining a classification line of an endpoint provided in an embodiment of the present application is shown in FIG. 1.

[0016] Figure 4 A flowchart of a method for recognizing an optimized barcode image provided in an embodiment of the present application is shown in FIG. 2.

[0017] Figure 5 A schematic diagram of a state of a quaternary barcode provided in an embodiment of the present application is shown in FIG. 3.

[0018] Figure 6 A schematic diagram of an initial segmentation line of a quaternary barcode provided in an embodiment of the present application is shown in FIG. 4.

[0019] Figure 7a A schematic diagram of a state line of a first endpoint of a quaternary barcode provided in an embodiment of the present application is shown in FIG. 5.

[0020] Figure 7b A schematic diagram of a state line of a second endpoint of a quaternary barcode provided in an embodiment of the present application is shown in FIG. 6.

[0021] Figure 8 A structural schematic diagram of a barcode image recognition device provided in an embodiment of the present application is shown in FIG. 7.

[0022] Figure 9 A structural schematic diagram of an electronic device provided in an embodiment of the present application is shown in FIG. 8. DETAILED DESCRIPTION

[0023] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the schemes of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0024] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced in other ways different from those described herein; obviously, the embodiments described in the specification are only some embodiments of the present application, not all embodiments.

[0025] The term "comprising" and its variants as used herein are open-ended, that is "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment". The term "another embodiment" means "at least one additional embodiment". The term "some embodiments" means "at least some embodiments". Related definitions of other terms will be given in the following description.

[0026] It should be noted that the concepts of "first", "second", etc. mentioned in the present application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0027] It should be noted that the modification of "one", "a plurality of" mentioned in the present application is illustrative but not restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".

[0028] The barcode image recognition method provided by the embodiments of the present application will be described in detail below in combination with the drawings and specific embodiments.

[0029] Figure 1 For the flowchart of the barcode image recognition method in the embodiments of the present application, the present embodiment can be applicable to the case of recognizing and interpreting a multi-state barcode image. The method can be executed by a barcode image recognition device, which can be realized in the form of software and / or hardware, and can be configured in an electronic device. The electronic device can include a scanning gun or a scanning box or other code scanning and reading devices.

[0030] As shown in Figure 1 The barcode image recognition method provided by the embodiments of the present application mainly includes steps S101-S106.

[0031] The barcode image recognition method provided by the present application can recognize binary (2-state) barcode images and can also recognize quaternary (4-state) barcode images. First, the process of recognizing binary barcode images will be introduced.

[0032] S101, acquiring a barcode image to be recognized, the barcode image to be recognized including a plurality of parallel line segments.

[0033] A barcode is a technology for automatic identification and data acquisition, which represents data through a set of black and white stripes and spaces. The stripes and spaces are arranged according to certain rules to form a coded form that can be read by a machine. Barcodes are commonly used in product identification, inventory management, logistics tracking, ticket management, etc. to improve the speed and accuracy of data entry. In the embodiments of the present application, a binary barcode is taken as an example for illustration.

[0034] The binary barcode provided in the embodiments of the present application refers to a barcode encoding method in which the widths of the barcodes (line segments) are the same, but the lengths of the barcodes are different. As shown in Figure 2 The binary barcode consists of line segments of only two lengths, and each line segment is combined in parallel. The first line segment 21, the third line segment 23, the fourth line segment 24, and the sixth line segment 26 have a first length, and the second line segment 22, the fifth line segment 25, and the seventh line segment 27 have a second length. The first length is greater than the second length.

[0035] The barcode image refers to an image obtained by photographing the binary barcode region. The barcode image to be recognized can be understood as a barcode image that needs to be read by an electronic device through a camera to obtain information contained therein.

[0036] Further, the barcode in the barcode image to be recognized can be horizontally placed (as shown in the placement direction of Figure 2 ), vertically placed (as shown in the vertical direction of Figure 2 ), or placed in any other direction, for example, a direction having an angle with the horizontal direction or a direction having an angle with the vertical direction.

[0037] S102, identify the position of the first endpoint of each line segment.

[0038] As can be seen from Figure 2 , the barcode image to be recognized includes a plurality of parallel line segments, and the lengths of the line segments are different. In the binary barcode, the first endpoint of the line segment refers to the endpoint of the line segment that is not aligned. For example: Figure 2 The upper endpoints of the first line segment 21, the second line segment 22, the third line segment 23, the fourth line segment 24, the fifth line segment 25, the sixth line segment 26, and the seventh line segment 27 are the first endpoints.

[0039] The position of the first endpoint refers to the position parameter of the first endpoint in the barcode image to be recognized, which can be marked by coordinates. Further, the position of the first endpoint can be represented by the coordinates of the pixel point of the first endpoint in the barcode image to be recognized.

[0040] Identifying the position of the first endpoint of the line segment mainly includes the following steps:

[0041] 1) Image preprocessing. Convert the color barcode image to be recognized into a grayscale image, use Gaussian filtering or other smoothing techniques to reduce noise in the image, and improve the accuracy of edge detection.

[0042] 2) Edge detection. Use Canny edge detector or Sobel operator method to detect the edges in the grayscale image. The above algorithm can highlight the boundary information in the image to find the possible line segments.

[0043] 3) Line segment detection. Use Hough Transform algorithm or Probabilistic Hough Transform algorithm to detect straight lines from the above edge image. By parameterizing the straight lines and accumulating votes in the parameter space, the straight lines in the image can be effectively detected.

[0044] 4) Endpoint Localization. If a line segment is detected in the barcode image to be recognized, the endpoints of the line segment can be determined by calculating the positions of the pixels at both ends of the line segment. Since a line segment is composed of a series of continuous edge points, the endpoints are typically the first and last two points on the line segment. Furthermore, for more precise endpoint localization, the region near the line segment can be further refined, for example, by applying sub-pixel level edge detection or fitting a more accurate model (such as least squares linear regression) to obtain the true location of the line segment.

[0045] 5) Post-processing. Further processing is used to remove incorrectly detected line segments (e.g., line segments that are too short, line segments that do not conform to the expected direction, etc.) and to merge line segment endpoints that are too close together.

[0046] In this embodiment, only the method for identifying the position of the first endpoint of a line segment is briefly introduced. Other methods for identifying the endpoints of line segments can also be used to determine the first endpoints of each line segment in the barcode image to be identified. This embodiment does not specifically limit the method.

[0047] S103. Determine the target classification line of the first endpoint according to the set rules.

[0048] The target classification line at the first endpoint is a straight line located within a designated area, approximately parallel to or parallel to the set straight line. This target classification line at the first endpoint is primarily used to identify the state of the first endpoint. The aforementioned set straight line can refer to a straight line formed by connecting the first endpoints of a line segment of a first length, such as... Figure 2 The dashed line 27 shown above can also refer to the straight line formed by connecting the first endpoints of line segments with a length of the second length, such as... Figure 2 The dashed line 28 is shown in the diagram. The designated area refers to the region between dashed lines 27 and 28.

[0049] The following section introduces the rules for setting up rules. Specifically, for example... Figure 3 As shown, the method for determining the classification line of a line segment endpoint provided in this application embodiment mainly includes steps S201-S214. The method for determining the classification line of a line segment endpoint provided in this application embodiment can be used to determine the target classification line of the first endpoint in a binary barcode, and can also be used to determine the target classification line of the first endpoint in a quaternary barcode and the target classification line of the second endpoint in a quaternary barcode. In this application embodiment, the determination of the target classification line of the first endpoint in a binary barcode is used as an example for illustration.

[0050] S201. Determine the initial classification line of the current endpoint, which may include the first endpoint or the second endpoint.

[0051] Firstly, an initial classification line of the first end point is obtained, wherein the initial classification line of the first end point is a straight line in the specified area and has no intersection with the dashed line 28 and the dashed line 29 in the to-be-recognized barcode image.

[0052] Further, the initial classification line of the first end point is a line obtained by connecting the first end point of the first line segment and the first end point of the last line segment in the plurality of parallel line segments.

[0053] The first line segment is the first line segment in the barcode image, such as the first line segment 21 in the barcode image 20. Figure 2 The last line segment is the last line segment at the end of the barcode image, such as the seventh line segment 27 in the barcode image 20. Figure 2

[0054] The first end point of the first line segment 21 and the first end point of the seventh line segment 27 are connected to obtain the initial classification line 210 of the first end point.

[0055] S202, calculate the distance between each current end point and the initial classification line.

[0056] The distance between each first end point and the initial classification line of the first end point is calculated. The distance between the first end point and the initial classification line of the first end point can be the vertical distance from the initial classification line to the first end point.

[0057] Based on the coordinate values of the first end point of the first line segment and the coordinate values of the first end point of the last line segment, the straight line expression of the initial classification line 210 of the first end point is determined. Based on the coordinate values of each first end point, the straight line expression of the initial classification line 210 of the first end point, and the distance formula from a point to a line, the distance between each first end point and the initial classification line of the first end point is calculated.

[0058] S203, grouping the current end points based on the distance between each current end point and the initial classification line to obtain a first end point group, a second end point group and a third end point group.

[0059] The first end point group includes: the current end point with a distance greater than or equal to the first set threshold value from the initial classification line, the second end point group includes: the current end point with a distance less than the second set threshold value from the initial classification line, and the third end point group includes: the current end point with a distance less than the first set threshold value and greater than the second set threshold value from the initial classification line.

[0060] The second set threshold value is the opposite of the first set threshold value. For example, if the first set threshold value is th, then the second set threshold value is -th.

[0061] The first set threshold value is in a positive proportional relationship with the distance of the adjacent line segment. For example, Figure 2 ​As shown, the distance of adjacent line segments refers to the width of the blank area between adjacent line segments, such as d1. Figure 2 As shown, the distance of adjacent line segments is d1. The first set threshold is in a proportional relationship with the distance d1 of adjacent line segments. The first set threshold is less than or equal to the distance d1 of adjacent line segments, and the first set threshold is greater than or equal to half of the distance d1 of adjacent line segments.

[0062] Further, the first set threshold th is the product of a constant c1 and the distance d1 of adjacent line segments, that is, th = c1 x d1. The selection range of the constant c1 is [0.5, 1].

[0063] After calculating the distance between each first endpoint and the initial classification line of the first endpoint in S202, the distance between each first endpoint and the initial classification line of the first endpoint is compared with the first set threshold respectively, the first endpoint with the distance greater than or equal to the first set threshold is divided into the first endpoint group, the first endpoint with the distance less than or equal to the second set threshold is divided into the second endpoint group, and the first endpoint with the distance less than the first set threshold and greater than the second set threshold is divided into the third endpoint group.

[0064] In other words, the distance between the first endpoint included in the first endpoint group and the initial classification line of the first endpoint is greater than or equal to the first set threshold, the distance between the first endpoint included in the second endpoint group and the initial classification line of the first endpoint is less than or equal to the second set threshold, and the distance between the first endpoint included in the third endpoint group and the initial classification line of the first endpoint is less than the first set threshold and greater than the second set threshold.

[0065] S204, respectively, the number of endpoints included in the first endpoint group, the number of endpoints included in the second endpoint group, and the number of endpoints included in the third endpoint group.

[0066] After grouping in S203, the first endpoint group, the second endpoint group and the third endpoint group are obtained, and each endpoint group includes a plurality of first endpoints, then the number of endpoints included in each group is counted.

[0067] The first endpoint included in the first endpoint group is traversed using a counter, and after the traversal is completed, the counter value is taken as the number n1 of endpoints included in the first endpoint group. The first endpoint included in the second endpoint group is traversed using a counter, and after the traversal is completed, the counter value is taken as the number n2 of endpoints included in the second endpoint group. The first endpoint included in the third endpoint group is traversed using a counter, and after the traversal is completed, the counter value is taken as the number n3 of endpoints included in the third endpoint group.

[0068] S205, the endpoint group with the largest number of endpoints is taken as the target endpoint group.

[0069] The number of endpoints in each group is compared, and the endpoint group with the largest number of endpoints is selected. Specifically, the number of endpoints n1 included in the first endpoint group, the number of endpoints n2 included in the second endpoint group, and the number of endpoints n3 included in the third endpoint group are compared, and the endpoint group with the largest number of endpoints is selected as the target endpoint group.

[0070] For example, if the number of endpoints n3 included in the third endpoint group is greater than the number of endpoints n1 included in the first endpoint group and greater than the number of endpoints n2 included in the second endpoint group, the third endpoint group is the endpoint group with the largest number of endpoints, and the third endpoint group is selected as the target endpoint group.

[0071] S206, each current endpoint in the target endpoint group is fitted to obtain a first straight line.

[0072] After determining the target endpoint group in S205, the target endpoint group includes a plurality of first endpoints, and the coordinates of the first endpoints are known. The coordinates of each first endpoint in the target endpoint group are fitted to obtain the expression of the first straight line. For example, the fitting process can be implemented using the least squares method.

[0073] Specifically, the coordinates of each first endpoint in the target endpoint group are (xi, yi), where i = 1, 2, …, n; and a straight line y = ax + b is desired to be found, which can best fit these points. Define an error function E(a, b) as the sum of the squares of the perpendicular distances from all first endpoints to the straight line y = ax + b, and find a and b such that E(a, b) is minimized. For this purpose, take the partial derivatives of E(a, b) with respect to a and b, and set them equal to zero. The condition that the above partial derivatives are zero can be rewritten as a linear equation system, which is solved to obtain the slope a and the intercept b of the first straight line. That is, the expression of the first straight line L1 is obtained.

[0074] S207, the current endpoints with a distance less than a first set threshold from the first straight line are divided into a fourth endpoint group.

[0075] The distance between the first endpoint of each line segment and the first straight line L1 is calculated. The distance between the first endpoint and the first straight line L1 can be the perpendicular distance from the first endpoint to the first straight line L1.

[0076] Based on the coordinate values of the first endpoints of each line segment, the straight line expression of the first straight line L1, and the distance formula from a point to a line, the distance between the first endpoint of each line segment and the first straight line L1 is calculated.

[0077] The distance between each first endpoint and the first straight line L1 is compared with the first set threshold value respectively, and the first endpoint with the distance greater than or equal to the first set threshold value is divided into the fourth endpoint group. In other words, the distance between the first endpoint included in the fourth endpoint group and the first straight line L1 is greater than or equal to the first set threshold value.

[0078] S208, the number of endpoints included in the fourth endpoint group is counted.

[0079] The counter is used to traverse the first endpoints included in the fourth endpoint group, and after the traversal is completed, the counter value is taken as the number n4 of endpoints included in the fourth endpoint group.

[0080] S209, the current endpoint included in the fourth endpoint group is fitted to obtain a second straight line.

[0081] The fourth endpoint group includes a plurality of first endpoints, and the coordinates of the first endpoints are known. The coordinates of each first endpoint in the fourth endpoint group are fitted to obtain the expression of the second straight line L2. For example, the fitting process can be realized by using the least squares method (Least Squares Method). For details, refer to the fitting process of the first straight line, which will not be described herein again.

[0082] S210, the current endpoint with the distance less than the first set threshold value from the second straight line is divided into a fifth endpoint group.

[0083] The distance between each first endpoint and the second straight line L2 is calculated. The distance between the first endpoint and the second straight line L2 can be the perpendicular distance from the first endpoint to the second straight line L2.

[0084] Based on the coordinate values of each first endpoint, the straight line expression of the second straight line L2, and the distance formula from a point to a line, the distance between each first endpoint and the second straight line L2 is calculated.

[0085] The distance between each first endpoint and the second straight line L2 is compared with the first set threshold value respectively, and the first endpoint with the distance greater than or equal to the first set threshold value is divided into the fifth endpoint group. In other words, the distance between the first endpoint included in the fifth endpoint group and the second straight line L2 is greater than or equal to the first set threshold value.

[0086] S211, the number of endpoints included in the fifth endpoint group is counted.

[0087] The counter is used to traverse the first endpoints included in the fifth endpoint group, and after the traversal is completed, the counter value is taken as the number n5 of endpoints included in the fourth endpoint group.

[0088] S212, judging whether the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is greater than a set value, if yes, executing S213, if not, executing S214.

[0089] The set value is mainly used to represent the difference between the number of endpoints n4 included in the fourth endpoint group and the number of endpoints n5 included in the fifth endpoint group. The set value can be set according to actual conditions, for example, the set value can be 1 or 2.

[0090] The difference between the number of endpoints n4 included in the fourth endpoint group and the number of endpoints n5 included in the fifth endpoint group is obtained. If the difference is less than or equal to the set value, it indicates that the number of endpoints n4 included in the fourth endpoint group is close to the number of endpoints n5 included in the fifth endpoint group, and the difference is not large. If the difference is greater than the set value, it indicates that the number of endpoints n4 included in the fourth endpoint group is greatly different from the number of endpoints n5 included in the fifth endpoint group.

[0091] S213, taking the second straight line as the first straight line, and the fifth endpoint group as the fourth endpoint group, and returning to execute S209.

[0092] If the difference is less than or equal to the set value, it indicates that the number of endpoints n4 included in the fourth endpoint group is greatly different from the number of endpoints n5 included in the fifth endpoint group, and it indicates that the second straight line is not a straight line in the set region, and the second straight line L2 is not suitable as the target classification line of the first endpoint. Therefore, the second straight line is taken as a new first straight line, the fifth endpoint group is taken as a new fourth endpoint group, the first endpoints included in the new fourth endpoint group are fitted to obtain a new second straight line, and subsequent steps are executed.

[0093] Until the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is less than or equal to the set value, the appropriate target classification line of the first endpoint is determined.

[0094] S214, taking the second straight line as the target classification line of the current endpoint.

[0095] If the difference is less than or equal to the set value, it indicates that the number of endpoints n4 included in the fourth endpoint group is close to the number of endpoints n5 included in the fifth endpoint group, and the difference is not large, and it indicates that the second straight line is a straight line in the set region, and the second straight line L2 can be taken as the target classification line of the first endpoint.

[0096] In the embodiment of the application, a determination manner of the target classification line of the first endpoint is provided, which can efficiently and quickly determine the classification line of the endpoint, so as to quickly determine the length of the line segment.

[0097] S104, determine the state of each first endpoint based on the position relationship between the position of each first endpoint and the target classification line of the first endpoint.

[0098] In one possible implementation, determining the state of each first endpoint based on the position relationship between each first endpoint and the target classification line of the first endpoint includes: for the first endpoint of each line segment, if the first endpoint is on the first side of the target classification line of the first endpoint, the first side of the target classification line of the first endpoint refers to the side of the target classification line of the first endpoint away from the second endpoint, then the first endpoint is determined to be in the first state; if the first endpoint is on the second side of the target classification line of the first endpoint, the second side of the target classification line of the first endpoint refers to the side of the target classification line of the first endpoint close to the second endpoint, then the first endpoint is determined to be in the second state.

[0099] The first side of the target classification line of the first endpoint and the second side of the target classification line of the first endpoint refer to the two sides of the target classification line of the first endpoint, as shown in Figure 2 The first side of the target classification line of the first endpoint is the upper side of the target classification line of the first endpoint, and the second side of the target classification line of the first endpoint is the lower side of the target classification line of the first endpoint. Alternatively, the first side of the target classification line of the first endpoint is the lower side of the target classification line of the first endpoint, and the second side of the target classification line of the first endpoint is the upper side of the target classification line of the first endpoint. The two sides of the classification line can be divided and determined according to actual conditions, which are not specifically limited in the embodiments of the present application.

[0100] The first state and the second state can be understood as two different states of the first endpoint, for example: in the embodiments of the present application, the first state is taken as 0 in binary, and the second state is taken as 1 in binary.

[0101] For example: for the first endpoint of each line segment, if the first endpoint is on the upper side of the target classification line of the first endpoint, the state of the first endpoint is recorded as 0; for the first endpoint of each line segment, if the first endpoint is on the lower side of the target classification line of the first endpoint, the state of the first endpoint is recorded as 1. As shown in Figure 2 The state of the first endpoint of the first line segment 21 is 0, the state of the first endpoint of the second line segment 22 is 1, the state of the first endpoint of the third line segment 23 is 0, the state of the first endpoint of the fourth line segment 24 is 0, the state of the first endpoint of the fifth line segment 25 is 1, the state of the first endpoint of the sixth line segment 26 is 0, and the state of the first endpoint of the seventh line segment 27 is 1.

[0102] S105, determine the state of each line segment based on the state of the first endpoint of each line segment.

[0103] In one possible implementation, the state of each line segment is determined by the state of the first endpoint of each line segment, including: when the barcode is a binary barcode, for each line segment, if the first endpoint of the line segment is in the first state, then the state of the line segment is determined to be the first state; if the first endpoint of the line segment is in the second state, then the state of the line segment is determined to be the second state.

[0104] When the barcode in the barcode image to be recognized is a binary barcode, since the second endpoints of the binary barcode are on the same straight line, representing the same state, the state of the first endpoint of each line segment is directly taken as the state of that line segment. For example: for each line segment, if the first endpoint is above the target classification line of the first endpoint, then the state of the first endpoint is recorded as 1, and the corresponding state of the line segment is 1. If the first endpoint is below the target classification line of the first endpoint, then the state of the first endpoint is recorded as 0, and the corresponding state of the line segment is 0.

[0105] like Figure 2 As shown, the state of the first line segment 21 is 0, the state of the second line segment 22 is 1, the state of the third line segment 23 is 0, the state of the fourth line segment 24 is 0, the state of the fifth line segment 25 is 1, the state of the sixth line segment 26 is 0, and the state of the seventh line segment 27 is 1.

[0106] S106. Decode based on the state of each line segment to obtain the recognition result of the barcode image to be recognized.

[0107] After determining the state of each line segment, the states of each line segment are combined according to their arrangement order in the barcode to obtain the state of the barcode to be identified, for example: Figure 2 The status of the barcode shown is 0100101.

[0108] After determining the status of the barcode to be identified, it can be decoded according to pre-set barcode rules. For example, the first digit is the identifier, and the subsequent digits are grouped into sets of three and decoded according to binary rules. Figure 2 The barcode decoding result shown is 45. It should be noted that this embodiment only illustrates the decoding process. Specific barcode rules can be set according to actual circumstances.

[0109] The embodiment of the present application provides a bar code image recognition method, device, equipment and storage medium, the method comprises the following steps: acquiring a to-be-recognized bar code image, the to-be-recognized bar code image comprises a plurality of parallel line segments; the positions of first end points of each line segment are recognized; a target classification line of the first end point is determined according to a set rule; the state of each first end point is determined based on the position relationship between the position of each first end point and the target classification line of the first end point; the state of each line segment is determined according to the state of the first end point of each line segment; and decoding is performed based on the state of each line segment to obtain a recognition result of the to-be-recognized bar code image. The characteristics that the single-side end points of the bar code are located on one or two straight lines are used, the state of each line segment of the bar code is efficiently determined, the fast decoding of the bar code is realized, and the recognition accuracy is good.

[0110] On the basis of the above-mentioned embodiment, the bar code image recognition method is further optimized in the embodiment of the present application, as shown in the following table. Figure 4 The optimized bar code image recognition method mainly comprises steps S301-S309.

[0111] In the embodiment of the present application, the process of recognizing a quaternary bar code image is introduced.

[0112] S301, a to-be-recognized bar code image is acquired, and the to-be-recognized bar code image comprises a plurality of parallel line segments.

[0113] The quaternary bar code provided in the embodiment of the present application refers to a bar code encoding method in which the widths of bar codes (line segments) are the same, but the lengths of the bar codes are different. The quaternary bar code is composed of line segments with three lengths, and the line segments are arranged side by side. Based on the positions of the line segments, the quaternary bar code can be divided into four states. The longest line segment is recorded as state 0; the shortest line segment is recorded as state 3; the line segment that protrudes upwards is composed of an upper end point on the upper side and a lower end point on the upper side, and is recorded as state 1; and the line segment that protrudes downwards is composed of an upper end point on the lower side and a lower end point on the lower side, and is recorded as state 2. As shown in the following table, the first line segment 51 is recorded as state 1, the second line segment 52 is recorded as state 2, the third line segment 53 is recorded as state 3, and the fourth line segment 54 is recorded as state 0. Figure 5

[0114] S302, the positions of first end points of each line segment are recognized.

[0115] The to-be-recognized bar code image comprises a plurality of parallel line segments, and the lengths of the line segments are different. In the quaternary bar code, the first end point of the line segment can be an end point on any one side. For example, when the quaternary bar code is placed horizontally, the first end point of the line segment can refer to the upper end point of the line segment, and when the quaternary bar code is placed vertically, the first end point of the line segment can refer to the left end point of the line segment.

[0116] ​The S302 provided in the embodiments of the present application is the same as the S102 in the above-described embodiments, and details can be referred to the description in the above-described embodiments, which will not be repeated in the embodiments of the present application.

[0117] S303, identifying the position of the second endpoint of each line segment.

[0118] It can be known from Figure 5 that the to-be-recognized barcode image includes a plurality of parallel line segments, and the lengths of the line segments are different. In the quaternary barcode, the second endpoint of the line segment refers to the endpoint opposite to the first endpoint of the line segment, in other words, the second endpoint of the line segment refers to the endpoint other than the first endpoint in the line segment. For example: Figure 5 The upper endpoints of the first line segment 51, the second line segment 52, the third line segment 53, and the fourth line segment 54 are the first endpoints. The lower endpoints of the first line segment 51, the second line segment 52, the third line segment 53, and the fourth line segment 54 are the second endpoints.

[0119] The position of the second endpoint refers to a position parameter of the second endpoint in the to-be-recognized barcode image, and the position parameter can be marked by a coordinate. Further, the position of the second endpoint can be represented by the coordinate of the pixel point of the second endpoint in the to-be-recognized barcode image.

[0120] The method for identifying the position of the second endpoint of the line segment is consistent with the method for identifying the position of the first endpoint of the line segment, and details can be referred to the description in the above-described embodiments, which will not be repeated in the embodiments of the present application.

[0121] S304, determining the target classification line of the first endpoint according to a set rule.

[0122] The S304 provided in the embodiments of the present application is the same as the S103 in the above-described embodiments, and details can be referred to the description in the above-described embodiments, which will not be repeated in the embodiments of the present application.

[0123] S305, determining the target classification line of the second endpoint according to a set rule.

[0124] First, an initial classification line of the second endpoint is obtained, and the initial classification line of the second endpoint is a line obtained by connecting the second endpoint of the first line segment to the second endpoint of the last line segment in the plurality of parallel line segments.

[0125] The first line segment is the first line segment in the barcode image, such as Figure 6 the first line segment 61 in the above-described embodiment, and the last line segment is the last line segment at the end in the barcode image, such as Figure 6 the last line segment 62 in the above-described embodiment. The second endpoint of the first line segment 61 and the second endpoint of the last line segment 62 are connected to obtain the initial classification line 63 of the second endpoint.

[0126] The distance between each second end point and the initial classification line 63 of the second end points is calculated. The distance between each second end point and the initial classification line 63 of the second end points can be the perpendicular distance from the second end point to the initial classification line. The expression of the straight line of the initial classification line 63 of the second end points is determined based on the coordinate values of the second end point of the first line segment and the coordinate values of the second end point of the last line segment. The distance between each second end point and the initial classification line 63 of the second end points is calculated based on the coordinate values of each second end point, the expression of the straight line of the initial classification line 63 of the second end points, and the distance formula from a point to a line.

[0127] After the distance between each second end point and the initial classification line 63 of the second end points is calculated, the distance between each second end point and the initial classification line 63 of the second end points is compared with the first set threshold value respectively. The second end points with the distance greater than or equal to the first set threshold value are classified into the first end point group. The second end points with the distance less than or equal to the second set threshold value are classified into the second end point group. The second end points with the distance less than the first set threshold value and greater than the second set threshold value are classified into the third end point group.

[0128] In other words, the distance between the second end points included in the second end point group and the initial classification line is greater than or equal to the first set threshold value, the distance between the second end points included in the second end point group and the initial classification line is less than or equal to the second set threshold value, and the distance between the second end points included in the third end point group and the initial classification line is less than the first set threshold value and greater than the second set threshold value.

[0129] The second end points included in the second end point group are traversed using a counter. After the traversal is completed, the counter value is taken as the number n1 of end points included in the second end point group. The second end points included in the second end point group are traversed using a counter. After the traversal is completed, the counter value is taken as the number n2 of end points included in the second end point group. The second end points included in the third end point group are traversed using a counter. After the traversal is completed, the counter value is taken as the number n3 of end points included in the third end point group.

[0130] The numbers of end points of each group are compared, and the end point group with the largest number of end points is selected as the target end point group.

[0131] The target end point group includes a plurality of second end points, and the coordinates of the second end points are known. The coordinates of each second end point in the target end point group are fitted to obtain the expression of the first straight line L1. For example, the fitting process can be realized by using the least squares method.

[0132] The distance between each second endpoint and the first straight line L1 is calculated. The distance between the second endpoint and the first straight line L1 can be the perpendicular distance from the second endpoint to the first straight line L1. The distance between each second endpoint and the first straight line L1 is calculated based on the coordinate values of each second endpoint, the linear expression of the first straight line L1, and the distance formula from a point to a line. The distance between each second endpoint and the first straight line L1 is compared with the first set threshold value respectively, and the second endpoint whose distance is greater than or equal to the first set threshold value is classified into the fourth endpoint group. In other words, the second endpoint included in the fourth endpoint group has a distance greater than or equal to the first set threshold value from the first straight line L1.

[0133] The counter is used to traverse the second endpoints included in the fourth endpoint group. After the traversal is completed, the counter value is taken as the number n4 of endpoints included in the fourth endpoint group.

[0134] The fourth endpoint group includes a plurality of second endpoints, the coordinates of which are known. The coordinates of each second endpoint in the fourth endpoint group are fitted to obtain the expression of the second straight line L2. For example, the fitting process can be implemented by using the least squares method.

[0135] The distance between each second endpoint and the second straight line L2 is calculated. The distance between the second endpoint and the second straight line L2 can be the perpendicular distance from the second endpoint to the second straight line L2. The distance between each second endpoint and the second straight line L2 is calculated based on the coordinate values of each second endpoint, the linear expression of the second straight line L2, and the distance formula from a point to a line.

[0136] The distance between each second endpoint and the second straight line L2 is compared with the first set threshold value respectively, and the second endpoint whose distance is greater than or equal to the first set threshold value is classified into the fifth endpoint group.

[0137] The counter is used to traverse the second endpoints included in the fifth endpoint group. After the traversal is completed, the counter value is taken as the number n5 of endpoints included in the fourth endpoint group.

[0138] It is determined whether the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is greater than a set value. If yes, the second straight line is taken as the first straight line, the fifth endpoint group is taken as the fourth endpoint group, and the fitting of the current endpoint included in the fourth endpoint group to obtain the second straight line is performed again. If no, the second straight line is taken as the classification line of the current endpoint.

[0139] The difference between the number of endpoints included in the fourth endpoint group n4 and the number of endpoints included in the fifth endpoint group n5 is obtained. If the difference is less than or equal to a set value, it indicates that the number of endpoints included in the fourth endpoint group n4 and the number of endpoints included in the fifth endpoint group n5 are close, and the second straight line is a straight line in the set region. The second straight line L2 can be used as the target classification line of the second endpoint.

[0140] If the difference is less than or equal to a set value, it indicates that the number of endpoints included in the fourth endpoint group n4 and the number of endpoints included in the fifth endpoint group n5 are close, and the second straight line is a straight line in the set region. The second straight line L2 can be used as the target classification line of the second endpoint.

[0141] In the embodiments of the present application, a determination method of the target classification line of the second endpoint is provided, which can efficiently and quickly determine the classification line of the endpoint, so as to quickly determine the length of the line segment.

[0142] S306, determine the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint.

[0143] S306 provided in the embodiments of the present application is the same as S104 in the above-described embodiments, and specific reference can be made to the description in the above-described embodiments. Details are not described herein again.

[0144] S307, determine the state of each second endpoint based on the positional relationship between the position of each second endpoint and the target classification line of the second endpoint.

[0145] In one possible implementation, the state of each second endpoint is determined based on the positional relationship between the second endpoint and the target classification line of the second endpoint, including: for the second endpoint of each line segment, if the second endpoint is on the first side of the target classification line of the second endpoint, it is determined that the second endpoint is in the second state; the first side of the target classification line of the second endpoint refers to the side of the target classification line of the second endpoint away from the first endpoint; if the second endpoint is on the second side of the target classification line of the second endpoint, it is determined that the second endpoint is in the first state; the second side of the target classification line of the second endpoint refers to the side of the target classification line of the second endpoint close to the first endpoint.

[0146] The first state and the second state can be understood as two different states of the second endpoint, for example, in the embodiment of the present application, the first state is 0 in binary, and the second state is 1 in binary.

[0147] For example, for the second endpoint of each line segment, if the second endpoint is on the upper side of the target classification line of the second endpoint, the state of the first endpoint is recorded as 1, and for the second endpoint of each line segment, if the second endpoint is on the lower side of the target classification line of the second endpoint, the state of the first endpoint is recorded as 0.

[0148] Further, as shown in Figure 7a The first endpoints on the upper side of the target classification line of the first endpoints are connected to obtain the state 0 line 71 of the first endpoints, and the state of all the first endpoints on the state 0 line 71 of the first endpoints is state 0. The first endpoints on the lower side of the target classification line of the first endpoints are connected to obtain the state 1 line 72 of the first endpoints, and the state of all the first endpoints on the state 1 line 72 of the first endpoints is state 1.

[0149] As shown in Figure 7b The second endpoints on the upper side of the target classification line of the second endpoints are connected to obtain the state 0 line 73 of the second endpoints, and the state of all the second endpoints on the state 0 line 73 of the second endpoints is state 0. The second endpoints on the lower side of the target classification line of the second endpoints are connected to obtain the state 1 line 74 of the second endpoints, and the state of all the second endpoints on the state 1 line 74 of the second endpoints is state 1.

[0150] S308, the state of the first endpoint of each line segment is combined with the state of the second endpoint to obtain the state of the line segment.

[0151] In the embodiment of the present application, as shown in Figure 5 The state of the line segment has four states, the first line segment 51 is recorded as state 1, the second line segment 52 is recorded as state 2, the third line segment 53 is recorded as state 3, and the fourth line segment 54 is recorded as state 0. State 0 represents the longest line segment, state 3 represents the shortest line segment, state 1 represents the line segment with intermediate length and upward head, and state 2 represents the line segment with intermediate length and downward head.

[0152] The state of the first end point and the state of the second end point of each line segment are combined to obtain the state of each line segment, including: when the barcode is a quaternary barcode, for each line segment, if the first end point of the line segment is in the first state and the second end point is in the first state, it is determined that the state of the line segment is the first state; if the first end point of the line segment is in the first state and the second end point is in the second state, it is determined that the state of the line segment is the second state; if the first end point of the line segment is in the second state and the second end point is in the first state, it is determined that the state of the line segment is the third state; and if the first end point of the line segment is in the second state and the second end point is in the second state, it is determined that the state of the line segment is the fourth state.

[0153] The first state can be state 0 shown in Figure 5 The second state can be state 1 shown in Figure 5 The third state can be state 2 shown in Figure 5 The fourth state can be state 3 shown in Figure 5

[0154] Specifically, if the state of the first end point of the line segment is 0 and the state of the second end point is 0, it is determined that the state of the line segment is 0; if the state of the first end point of the line segment is 0 and the state of the second end point is 1, it is determined that the state of the line segment is 1; if the state of the first end point of the line segment is 1 and the state of the second end point is 1, it is determined that the state of the line segment is 3; and if the state of the first end point of the line segment is 1 and the state of the second end point is 0, it is determined that the state of the line segment is 2.

[0155] Further, the state of the line segment can also be calculated according to the following formula.

[0156] V = 2 * V1 + V2.

[0157] V represents the state of the line segment, V1 represents the state of the first end point of the line segment, and V2 represents the state of the second end point of the line segment.

[0158] It should be noted that only the first state, the second state, the third state and the fourth state are exemplarily described in the embodiments of the present application, and other actual meanings can be given to the above states according to actual situations in actual application.

[0159] S309, decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image.

[0160] After determining the state of each line segment, the states of the line segments are combined according to the arrangement order of the line segments in the barcode to obtain the state of the to-be-recognized barcode, for example: Figure 6 The state of the barcode shown in is 1301011030302.

[0161] ​After the state of the to-be-recognized barcode is determined, decoding can be performed according to a preset barcode rule. Only decoding is described in the embodiments of this application. The specific barcode rule can be set according to actual conditions.

[0162] The embodiments of this application provide a barcode image recognition method, device, equipment and storage medium. The method comprises: acquiring a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments; recognizing the position of a first endpoint of each line segment; recognizing the position of a second endpoint of each line segment; determining a target classification line of the first endpoint according to a set rule; determining a target classification line of the second endpoint according to the set rule; determining the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint; determining the state of each second endpoint based on the positional relationship between the position of each second endpoint and the target classification line of the second endpoint; combining the state of the first endpoint of each line segment with the state of the second endpoint to obtain the state of the line segment; and decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image. The characteristics that the single-side endpoints of a barcode are located on one or two straight lines are utilized to efficiently determine the state of each line segment of the barcode, thereby realizing fast decoding of the barcode and achieving good recognition accuracy.

[0163] Figure 8 The structure of a barcode image recognition device in the embodiments of this application is shown in FIG. 8, which mainly comprises an image acquisition module 81, an endpoint position recognition module 82, a classification line determination module 83, an endpoint state determination module 84, a line segment state determination module 85 and a state decoding module 86. Figure 8

[0164] The image acquisition module 81 is configured to acquire a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments. The endpoint position recognition module 82 is configured to recognize the position of a first endpoint of each line segment. The classification line determination module 83 is configured to determine a target classification line of the first endpoint according to a set rule. The endpoint state determination module 84 is configured to determine the state of each first endpoint based on the positional relationship between the position of each first endpoint and the target classification line of the first endpoint. The line segment state determination module 85 is configured to combine the state of the first endpoint of each line segment to determine the state of each line segment. The state decoding module 86 is configured to decode based on the state of each line segment to obtain the recognition result of the to-be-recognized barcode image.

[0165] ​The embodiment of the present application provides a bar code image recognition device, which is mainly used for executing the following process: obtaining a to-be-recognized bar code image, the to-be-recognized bar code image comprising a plurality of parallel line segments; recognizing the position of a first end point of each line segment; determining a target classification line of the first end point according to a set rule; determining the state of each first end point based on the positional relationship between the position of each first end point and the target classification line of the first end point; determining the state of each line segment based on the state of the first end point of each line segment; and decoding based on the state of each line segment to obtain the recognition result of the to-be-recognized bar code image. The characteristics that the single-side end points of the bar code are located on one or two straight lines are utilized, the state of each line segment of the bar code is efficiently determined, the fast decoding of the bar code is realized, and the recognition precision is good.

[0166] In a possible implementation, the end point position recognition module 82 is further configured to recognize the position of a second end point of each line segment; the classification line determination module 83 is further configured to determine a target classification line of the second end point according to a set rule; the end point state determination module 84 is further configured to determine the state of each second end point based on the positional relationship between the position of each second end point and the target classification line of the second end point; and the line segment state determination module 85 is specifically configured to combine the state of the first end point and the state of the second end point of each line segment to obtain the state of the line segment.

[0167] In a possible implementation, the classification line determination module 83 is specifically configured to determine an initial classification line of a current endpoint, the current endpoint including the first endpoint or the second endpoint; calculate distances between the respective current endpoints and the initial classification line; group the current endpoints based on the distances between the respective current endpoints and the initial classification line to obtain a first endpoint group, a second endpoint group and a third endpoint group, wherein the first endpoint group includes the current endpoints with distances greater than or equal to a first set threshold value from the initial classification line, the second endpoint group includes the current endpoints with distances less than or equal to a second set threshold value from the initial classification line, and the third endpoint group includes the current endpoints with distances less than the first set threshold value and greater than the second set threshold value from the initial classification line; respectively count the number of endpoints included in the first endpoint group, the number of endpoints included in the second endpoint group, and the number of endpoints included in the third endpoint group; take the endpoint group with the largest number of endpoints as a target endpoint group; fit the respective current endpoints in the target endpoint group to obtain a first straight line; divide the current endpoints with distances less than the first set threshold value from the first straight line into a fourth endpoint group; count the number of endpoints included in the fourth endpoint group; fit the current endpoints included in the fourth endpoint group to obtain a second straight line; divide the current endpoints with distances less than the first set threshold value from the second straight line into a fifth endpoint group; count the number of endpoints included in the fifth endpoint group; if the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is greater than a set value, take the second straight line as the first straight line, take the fifth endpoint group as the fourth endpoint group, and return to perform the step of fitting the current endpoints included in the fourth endpoint group to obtain the second straight line; until the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is less than or equal to the set value, take the second straight line as the classification line of the current endpoint.

[0168] In a possible implementation, when the current endpoint includes the first endpoint, the initial classification line of the first endpoint is a line obtained by connecting the first endpoint of a first line segment to the first endpoint of a last line segment in a plurality of parallel line segments; and when the current endpoint includes the second endpoint, the initial classification line of the second endpoint is a line obtained by connecting the second endpoint of a first line segment to the second endpoint of a last line segment in a plurality of parallel line segments.

[0169] In a possible implementation, the second set threshold value is the opposite of the first set threshold value, and the first set threshold value is in a positive proportional relationship with the distance of adjacent line segments.

[0170] In a possible implementation, the endpoint state determining module 84 is specifically configured to, for the first endpoint of each line segment, determine the first endpoint as the first state if the first endpoint is on a first side of a target classification line of the first endpoint, the first side of the target classification line of the first endpoint being a side of the target classification line of the first endpoint that is far away from the second endpoint; and determine the first endpoint as the second state if the first endpoint is on a second side of the target classification line of the first endpoint, the second side of the target classification line of the first endpoint being a side of the target classification line of the first endpoint that is close to the second endpoint.

[0171] In a possible implementation, the endpoint state determining module 84 is specifically configured to, for the second endpoint of each line segment, determine the second endpoint as the second state if the second endpoint is on a first side of a target classification line of the second endpoint, the first side of the target classification line of the second endpoint being a side of the target classification line of the second endpoint that is far away from the first endpoint; and determine the second endpoint as the first state if the second endpoint is on a second side of the target classification line of the second endpoint, the second side of the target classification line of the second endpoint being a side of the target classification line of the second endpoint that is close to the first endpoint.

[0172] In a possible implementation, the line segment state determining module 85 is specifically configured to, when the barcode is a binary barcode, for each line segment, determine a state of the line segment as the first state if the first endpoint of the line segment is in the first state.

[0173] determine the state of the line segment as the second state if the first endpoint of the line segment is in the second state.

[0174] In a possible implementation, the line segment state determining module 85 is specifically configured to, when the barcode is a quaternary barcode, for each line segment, determine the state of the line segment as the first state if the first endpoint of the line segment is in the first state and the second endpoint of the line segment is in the first state; determine the state of the line segment as the second state if the first endpoint of the line segment is in the first state and the second endpoint of the line segment is in the second state; determine the state of the line segment as the third state if the first endpoint of the line segment is in the second state and the second endpoint of the line segment is in the first state; and determine the state of the line segment as the fourth state if the first endpoint of the line segment is in the second state and the second endpoint of the line segment is in the second state.

[0175] The barcode image recognition apparatus provided in the embodiments of the present application can perform the barcode image recognition method provided in any of the embodiments of the present application, and has the function modules and beneficial effects corresponding to the execution method.

[0176] Figure 9 is a structural schematic diagram of an electronic device provided in the embodiments of the present application. The electronic device can include a barcode image recognition apparatus, such as Figure 9As shown, the electronic device 900 includes a processor 910, a memory 920, an input device 930, and an output device 940; the number of processors 910 in the electronic device can be one or more, Figure 9 The processor 910 in the electronic device is exemplified as one processor 910; the processor 910, the memory 920, the input device 930, and the output device 940 in the electronic device can be connected through a bus or other means, Figure 9 The connection through the bus is exemplified.

[0177] The memory 920 as a kind of computer readable storage medium, can be used to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the bar code image recognition method in the embodiment of the application. The processor 910 executes the software program, instruction and module stored in the memory 920, so as to perform various function applications and data processing of the electronic device, that is, to realize the bar code image recognition method provided by the embodiment of the application.

[0178] The memory 920 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required by a function; the data storage area can store data created according to the use of the terminal and the like. In addition, the memory 920 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state memory device. In some examples, the memory 920 can further include a memory remotely arranged with respect to the processor 910, and these remote memories can be connected to the electronic device through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0179] The input device 930 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device, and can include a keyboard, a mouse and the like. The output device 940 can include a display device such as a display screen.

[0180] The embodiment also provides a storage medium containing computer executable instructions, which are used to implement the bar code image recognition method provided by the embodiment of the application when executed by a computer processor.

[0181] Of course, the storage medium containing computer executable instructions provided by the embodiment of the application is not limited to the method operations as described above, and can also perform related operations in the bar code image recognition method provided by any embodiment of the application.

[0182] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be realized by means of software and necessary universal hardware, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH, a hard disk, or an optical disc, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in various embodiments of the present application.

[0183] It is worth noting that in the above embodiment of the bar code image recognition device, each unit and module included is only divided according to functional logic, but is not limited to the above division, as long as the corresponding function can be realized; in addition, the specific names of each functional unit are only for the convenience of mutual differentiation, and do not limit the protection scope of the present application.

[0184] It should be noted that in this paper, relationship terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such process, method, article or device. Without more limitations, the element defined by the sentence "including a…" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0185] The above is only a specific embodiment of the present application, which enables those skilled in the art to understand or implement the present application. Various modifications of these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method of recognizing a bar code image, characterized by, The method comprises: acquiring a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of parallel line segments, each of the line segments having a different length; identifying a position of a first end point of each of the line segments, the first end point of the line segment being an unaligned end point of the line segment; determining a target classification line of the first end point according to a set rule, the target classification line of the first end point being a straight line located in a specified region and being approximately parallel or parallel to a set straight line; determining a state of each of the first end points based on a positional relationship between the position of each of the first end points and the target classification line of the first end point; determining a state of each of the line segments based on the state of the first end point of each of the line segments; decoding based on the state of each of the line segments to obtain a recognition result of the to-be-recognized barcode image.

2. The method of claim 1, wherein, Before the determining of the state of each of the line segments based on the state of the first end point of each of the line segments, the method further comprises: identifying a position of a second end point of each of the line segments; determining a target classification line of the second end point according to the set rule; determining a state of each of the second end points based on a positional relationship between the position of each of the second end points and the target classification line of the second end point; determining the state of each of the line segments based on the state of the first end point of each of the line segments, comprising: merging the state of the first end point of each of the line segments and the state of the second end point to obtain the state of the line segment.

3. The method according to claim 1 or 2, characterized in that, The set rule comprises: determining an initial classification line of a current end point, the current end point comprising the first end point or the second end point; calculating a distance between each of the current end points and the initial classification line; grouping the current end points based on the distance between each of the current end points and the initial classification line to obtain a first end point group, a second end point group and a third end point group, wherein the first end point group comprises the current end points having a distance greater than or equal to a first set threshold value from the initial classification line, the second end point group comprises the current end points having a distance less than or equal to a second set threshold value from the initial classification line, and the third end point group comprises the current end points having a distance less than the first set threshold value and greater than the second set threshold value from the initial classification line; respectively counting a number of end points included in the first end point group, a number of end points included in the second end point group and a number of end points included in the third end point group; taking the end point group with the largest number of end points as a target end point group; fitting each of the current end points in the target end point group to obtain a first straight line; dividing the current end points having a distance less than the first set threshold value from the first straight line into a fourth end point group; counting a number of end points included in the fourth end point group; fitting the current end points included in the fourth end point group to obtain a second straight line; dividing the current end points having a distance less than the first set threshold value from the second straight line into a fifth end point group; counting a number of end points included in the fifth end point group; If the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is greater than a set value, the second straight line is taken as the first straight line, the fifth endpoint group is taken as the fourth endpoint group, and the step of fitting the current endpoints included in the fourth endpoint group to obtain the second straight line is performed again; Until the difference between the number of endpoints included in the fourth endpoint group and the number of endpoints included in the fifth endpoint group is less than or equal to the set value, the second straight line is taken as the target classification line of the current endpoint.

4. The method of claim 3, wherein, When the current endpoint includes the first endpoint, the initial classification line of the first endpoint is a line obtained by connecting the first endpoint of the first line segment to the first endpoint of the last line segment in the plurality of parallel line segments; When the current endpoint includes the second endpoint, the initial classification line of the second endpoint is a line obtained by connecting the second endpoint of the first line segment to the second endpoint of the last line segment in the plurality of parallel line segments.

5. The method of claim 3, wherein, The second set threshold value is the opposite of the first set threshold value, and the first set threshold value is in a positive proportional relationship with the distance of adjacent line segments.

6. The method of claim 2, wherein, Based on the positional relationship between each first endpoint and the target classification line of the first endpoint, the state of each first endpoint is determined, including: For the first endpoint of each line segment, if the first endpoint is on the first side of the target classification line of the first endpoint, the first endpoint is determined to be in a first state, the first side of the target classification line of the first endpoint being the side of the target classification line of the first endpoint that is away from the second endpoint; If the first endpoint is on the second side of the target classification line of the first endpoint, the first endpoint is determined to be in a second state, the second side of the target classification line of the first endpoint being the side of the target classification line of the first endpoint that is close to the second endpoint; Correspondingly, based on the positional relationship between each second endpoint and the target classification line of the second endpoint, the state of each second endpoint is determined, including: For the second endpoint of each line segment, if the second endpoint is on the first side of the target classification line of the second endpoint, the second endpoint is determined to be in a second state, the first side of the target classification line of the second endpoint being the side of the target classification line of the second endpoint that is away from the first endpoint; If the second endpoint is on the second side of the target classification line of the second endpoint, the second endpoint is determined to be in a first state, the second side of the target classification line of the second endpoint being the side of the target classification line of the second endpoint that is close to the first endpoint.

7. The method of claim 6, wherein, The states of the first endpoints and the states of the second endpoints of each line segment are combined to obtain the state of each line segment, including: When the barcode is a quaternary barcode, for each line segment, if the first endpoint of the line segment is in a first state and the second endpoint is in a first state, the state of the line segment is determined to be in a first state; If the first endpoint of the line segment is in a first state and the second endpoint is in a second state, the state of the line segment is determined to be in a second state; if the first end point of the line segment is in the second state and the second end point is in the first state, determining the state of the line segment as a third state; if the first end point of the line segment is in the second state and the second end point is in the second state, determining the state of the line segment as a fourth state.

8. A barcode image recognition device, characterized in that, The apparatus comprises: an image acquisition module, configured to acquire a to-be-recognized barcode image, the to-be-recognized barcode image comprising a plurality of juxtaposed line segments, each of the line segments having a different length; an end point position identification module, configured to identify a position of a first end point of each of the line segments, the first end point of the line segment being an unaligned end point of the line segment; a classification line determination module, configured to determine a target classification line of the first end point according to a set rule, the target classification line of the first end point being a straight line located in a specified region and being approximately parallel or parallel to a set straight line; an end point state determination module, configured to determine a state of each of the first end points based on a positional relationship between the position of each of the first end points and the target classification line of the first end point; a line segment state determination module, configured to determine a state of each of the line segments based on the state of the first end point of each of the line segments; a state decoding module, configured to decode based on the state of each of the line segments to obtain a recognition result of the to-be-recognized barcode image.

9. An electronic device, comprising: The apparatus comprises: one or more processors; a storage device configured to store one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the barcode image recognition method according to any one of claims 1-7.

10. A storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to implement the barcode image recognition method according to any one of claims 1-7. The program is executed by the processor to implement the barcode image recognition method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Bar code recognition method and recognition device

    JP2004246795A

  • Print controller

    JP2013167967A