Parallel line fitting method and device for bar code recognition and bar code recognition equipment
By using an angle histogram to determine the slope of the classification line in barcode recognition, binary classification and parallel line fitting of barcode endpoints is achieved, which solves the problem of low fitting accuracy in the prior art and improves the accuracy and robustness of barcode recognition.
Patent Information
- Application Number
- CN202411781946.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-18
AI Technical Summary
When performing barcode recognition, the prior art fails to effectively consider the prior conditions of parallel line characteristics, resulting in low fitting accuracy when discrete points are unevenly distributed or uneven in quantity, which leads to failure in barcode recognition.
By obtaining the angle between the connecting lines of any two discrete points in the barcode endpoint and the x-axis, counting these angles and drawing an angle histogram, determining the slope of the classification line, and then achieving binary classification and parallel line fitting of the barcode endpoint.
It significantly improves the accuracy and robustness of barcode recognition, and can ensure the correct identification of barcodes in the face of uneven distribution of discrete points or uneven quantity, and reduces identification errors caused by fit failure.
Smart Images

Figure CN119649132A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of barcode recognition, for example, to a parallel line fitting method and apparatus for barcode recognition, and a barcode recognition device. Background Art
[0002] Currently, for 2-state and 4-state postal codes, the correct state of the line segment is determined by the length of the line segment protruding upwards and downwards. Taking the 4-state postal code as an example, the line segment is divided into 4 states, namely tracking line (T), upward protruding line segment (A), downward protruding line segment (D), and both upper and lower protruding line segments (H). The upper and lower endpoints of a complete 4-state postal code can be fitted into two pairs of parallel lines. After all the line segments are obtained, the coordinates of the upper and lower endpoints of each line segment can be determined. Therefore, if the two pairs of parallel lines of the upper and lower endpoints of the 4-state postal code can be accurately determined, the correct state of each line segment can be accurately determined, and the correct decoding of the 4-state postal code can be completed.
[0003] In order to determine parallel lines based on the coordinates of the upper and lower endpoints, the related technology discloses a parallel line fitting method based on discrete points, including: using a clustering algorithm to complete the classification of discrete points, and then completing the classified discrete point straight line fitting based on least squares fitting.
[0004] In the process of implementing the embodiments of the present disclosure, it is found that there are at least the following problems in the related art:
[0005] After completing the classification of discrete points, the two types of discrete points are separately fitted based on least squares, without considering the prior conditions of parallel features. When the two types of discrete points are unevenly distributed, it is easy to cause the failure of fitting the straight line of extremely unevenly distributed or very small discrete points, and the fitting accuracy is low, which in turn leads to barcode recognition failure.
[0006] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0007] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0008] The embodiments of the present disclosure provide a parallel line fitting method and apparatus for barcode recognition, and a barcode recognition device, which can improve the accuracy of parallel line fitting.
[0009] In some embodiments, the parallel line fitting method for barcode recognition includes: obtaining the angle between the line connecting any two discrete points in the barcode endpoints and the x-axis; using the slope of the angle in the angle histogram as the slope of the classification line; calculating the classification line according to the slope of the classification line to binary classify the barcode endpoints; performing parallel line fitting on the barcode endpoints that have undergone binary classification, so as to perform barcode recognition through the fitted parallel lines.
[0010] Optionally, taking the slope of the included angle in the angle histogram as the slope of the classification line includes: counting multiple included angles and drawing an angle histogram; calculating tan(θ) according to the included angle θ in the angle histogram; and taking tan(θ) as the slope of the classification line.
[0011] Optionally, calculating the classification line according to the slope of the classification line includes: calculating the intercept of the classification line by a least square method according to the slope of the classification line to obtain the classification line.
[0012] Optionally, the intercept of the classification line is calculated according to the slope of the classification line by the least squares method, including: calculating the distances between all discrete points and the classification line according to the slope of the classification line; calculating the mean of the distances between all discrete points and the classification line; and calculating the intercept of the classification line according to the mean of the distances between all discrete points and the classification line.
[0013] Optionally, the distance between the discrete point and the classification line is calculated according to the following formula:
[0014]
[0015] Among them, d is the distance between the discrete point and the classification line, (px,py) is the coordinate of the discrete point, k is the slope of the classification line, and b is the intercept of the classification line.
[0016] Optionally, the intercept of the classification line is calculated according to the following formula:
[0017]
[0018] Among them, b is the intercept of the classification line, d(i) is the distance between all discrete points and the classification line, is the mean distance between the discrete points and the classification line.
[0019] Optionally, parallel line fitting is performed on the barcode endpoints that have undergone binary classification, including: performing parallel line fitting on two groups of barcode endpoints obtained by classification at the same time; or, performing straight line fitting on one group of barcode endpoints obtained by classification to obtain a first straight line; and performing straight line fitting on another group of barcode endpoints obtained by classification according to the slope of the first straight line to obtain a second straight line.
[0020] Optionally, any two discrete points in the barcode endpoints meet the following condition: a distance between any two discrete points is greater than a distance threshold.
[0021] In some embodiments, the parallel line fitting device for barcode recognition includes a processor and a memory storing program instructions, and the processor is configured to execute the parallel line fitting method for barcode recognition as described above when running the program instructions.
[0022] In some embodiments, the barcode recognition device includes: a barcode recognition device body; and a parallel line fitting device for barcode recognition as described above, installed on the barcode recognition device body.
[0023] The parallel line fitting method and apparatus for barcode recognition and the barcode recognition device provided by the embodiments of the present disclosure can achieve the following technical effects:
[0024] In the disclosed embodiment, the slope of the classification line is determined by accurately measuring the angle between the line connecting any two discrete points in the barcode endpoints and the x-axis, and displaying the distribution of these angles in the form of a histogram. The consistency of the slope of the line connecting the barcode endpoints is utilized to provide a classification method based on angle distribution for the barcode endpoints. According to the determined slope of the classification line, the classification line is calculated to achieve binary classification of the barcode endpoints. Finally, parallel line fitting is performed on the two groups of classified endpoints to ensure that the slopes of the two fitted lines are equal, so as to accurately identify the barcode. The accuracy and robustness of barcode recognition are significantly improved, especially in the case of uneven distribution or uneven number of discrete points, the correct recognition of the barcode can still be guaranteed, reducing recognition errors caused by fitting failure.
[0025] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:
[0027] Figure 1 is a schematic diagram of an implementation environment of a parallel line fitting method for barcode recognition according to an embodiment of the present disclosure;
[0028] Figure 2 is a schematic diagram of a parallel line fitting method for barcode recognition provided by an embodiment of the present disclosure;
[0029] Figure 3 is a schematic diagram of a discrete point classification straight line provided by an embodiment of the present disclosure;
[0030] Figure 4 is a schematic diagram of another parallel line fitting method for barcode recognition provided by an embodiment of the present disclosure;
[0031] Figure 5 is a typical discrete point distribution diagram provided by an embodiment of the present disclosure;
[0032] Figure 6 It is a schematic diagram of a parallel line fitting device for barcode recognition provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0034] The terms "first", "second", etc. in the technical solutions described in the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0035] Unless otherwise stated, the term "plurality" means two or more.
[0036] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0037] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0038] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.
[0039] Currently, in the field of postal code recognition technology, with the rapid progress of image processing and pattern recognition technology, the ability to automatically identify postal codes has been significantly improved. As the core technology in this field, 2-state and 4-state postal codes encode information through the presence or absence or different states of line segments, making mail sorting more efficient. Modern automatic recognition systems can quickly and accurately read and parse postal codes on mail, thanks to the development of high-speed scanners and high-resolution cameras, which provide clear and accurate input data for image processing.
[0040] In addition, the integration of artificial intelligence and machine learning technologies enables the recognition system to learn the patterns of postal codes through training, continuously optimize the recognition algorithm, and improve the accuracy of recognition. The integration of error detection and correction mechanisms enhances the system's tolerance for printing errors, stains, or blurs, ensuring accurate recognition of postal codes.
[0041] Overall, the development of postal code recognition technology has not only improved the efficiency and accuracy of mail processing, but also provided strong technical support for the modernization and internationalization of postal services. At the same time, it also faces new challenges in privacy protection and data security.
[0042] Therefore, the success rate of coding recognition is particularly important. Figure 1 FIG. 1 is a schematic diagram of the implementation environment of the parallel line fitting method for barcode recognition according to an embodiment of the present disclosure. Figure 1 As shown, the implementation environment may include a processor 100 and a scanning device 200 .
[0043] The scanning device 200 can scan a 2-state or 4-state postal code, obtain four line segments of the postal code, and determine their upper and lower endpoints. Then the processor 100 fits the upper and lower endpoints to obtain two parallel lines to achieve barcode recognition.
[0044] Combination Figure 2 As shown, the embodiment of the present disclosure provides a parallel line fitting method for barcode recognition, comprising:
[0045] S201, the processor obtains the angle between the line connecting any two discrete points in the barcode endpoints and the x-axis.
[0046] S202: The processor uses the slope of the included angle in the angle histogram as the slope of the classification line.
[0047] S203: The processor calculates a classification line according to the slope of the classification line to classify the barcode endpoints into two categories.
[0048] S204, the processor performs parallel line fitting on the barcode endpoints after binary classification, so as to perform barcode recognition through the fitted parallel lines.
[0049] The parallel line fitting method for barcode recognition provided by the embodiment of the present disclosure is adopted. The angle between the line connecting any two discrete points in the barcode endpoints and the x-axis is accurately measured, and the distribution of these angles is displayed in the form of a histogram to determine the slope of the classification line. The consistency of the slope of the line connecting the barcode endpoints is utilized to provide a classification method based on angle distribution for the barcode endpoints. According to the determined slope of the classification line, the classification line is calculated to achieve the binary classification of the barcode endpoints. Finally, parallel line fitting is performed on the two groups of classified endpoints to ensure that the slopes of the two fitted lines are equal, so as to accurately identify the barcode. The accuracy and robustness of barcode recognition are significantly improved, especially in the case of uneven distribution or uneven number of discrete points, the correct recognition of the barcode can still be guaranteed, and the recognition errors caused by fitting failure are reduced.
[0050] Optionally, taking the slope of the included angle in the angle histogram as the slope of the classification line includes: counting multiple included angles and drawing an angle histogram; calculating tan(θ) according to the included angle θ in the angle histogram; and taking tan(θ) as the slope of the classification line.
[0051] In the disclosed embodiment, any two discrete points are selected from the barcode endpoints, and the angle between the line connecting the discrete points and the x-axis is calculated; then, all such angles are collected and counted in an angle histogram to observe the frequency distribution of different angles. The angle range is [0,180] degrees. The histogram statistical step size is set according to the allowable parallel line fitting error, and the recommended step size is 1 degree. In the histogram, the frequency peak of a certain angle (angle θ) indicates the angle trend between the lines connecting most discrete points and the x-axis. This angle reflects the dominant direction of the barcode endpoint connection. Next, the tangent value of the angle (tan(θ)) is calculated, and this value will be used as the slope of the classification line. In this way, a straight line can be determined to divide the barcode endpoints into two groups, and the slope of the line connecting each group of endpoints is the same, that is, parallel. The classification line slope determination method based on the angle histogram can improve the accuracy and robustness of barcode recognition. Especially when faced with uneven distribution or imbalanced number of discrete points, the barcode endpoints can be effectively classified by identifying the dominant connection direction, thereby accurately judging the state of each line segment and completing the correct decoding of the barcode.
[0052] For example Figure 3As shown, it is a schematic diagram of a discrete point classification line provided by an embodiment of the present disclosure. Assume that there are 14 discrete points in total, numbered 1, 2, 3...14 in sequence. Connecting any two discrete points can obtain a line segment, based on which the angle between the line segment and the x-axis is calculated, and the distribution of various angle values is statistically displayed in a histogram. The angle between any similar discrete point connection and the x-axis is equal, while the angle between any non-similar point connection and the x-axis is different, and changes with the distance between the two discrete points. Based on this characteristic, the slope of the classification line can be accurately obtained. Assume that the equation of the classification line is
[0053] y=kx+b, where the slope k of the classification line is known. Then the intercept b of the classification line is estimated by the least squares method. In this way, the classification line is obtained, such as Figure 3 As shown by the dividing line in .
[0054] Optionally, calculating the classification line according to the slope of the classification line includes: calculating the intercept of the classification line by a least square method according to the slope of the classification line to obtain the classification line.
[0055] In the disclosed embodiment, first, the slope of the classification line is determined by counting the angle between the line connecting the discrete points in the barcode endpoints and the x-axis, and finding the dominant angle in the angle histogram. Once the slope is determined, the intercept of the classification line is calculated using the least squares method. The least squares method is an optimization technique that finds the best function match for the data by minimizing the sum of squares of the errors. In the disclosed embodiment, it is used to find a straight line so that the sum of squares of the vertical distances from all discrete points to the straight line is minimized. In this way, a best fit line can be determined, which is closest to all discrete points, so that the discrete points are divided into two groups, each with the same slope, i.e. parallel. This can adapt to the uneven distribution of discrete points, and even in the case of an uneven number or uneven distribution of discrete points, the barcode endpoints can be accurately classified, thereby accurately judging the state of each line segment and completing the correct decoding of the barcode. Not only does it improve the recognition efficiency, but it also enhances the stability and reliability of the system under complex or undesirable scanning conditions, and provides an effective technical solution for fields such as automated postal code recognition and industrial detection.
[0056] Optionally, the intercept of the classification line is calculated according to the slope of the classification line by the least squares method, including: calculating the distances between all discrete points and the classification line according to the slope of the classification line; calculating the mean of the distances between all discrete points and the classification line; and calculating the intercept of the classification line according to the mean of the distances between all discrete points and the classification line.
[0057] In the disclosed embodiment, for each discrete point, the vertical distance from the classification line based on the slope is calculated. Then, all the calculated distances are summarized and the mean of these distances is calculated, which represents the average position of the discrete points relative to the classification line. Finally, using this mean, the intercept of the classification line is inferred by the least squares method to obtain the complete classification line equation. This process is actually looking for a straight line that minimizes the sum of the squares of the vertical distances from all discrete points to this line, ensuring that the straight line best fits all discrete points.
[0058] This classification line intercept calculation method based on the least squares method can significantly improve the accuracy and robustness of barcode recognition. This method can effectively improve the motion tolerance of barcode recognition equipment and enhance its performance in various application scenarios. In particular, in the barcode recognition process, it can reduce recognition errors caused by fitting failures and ensure accurate recognition of postal codes.
[0059] Optionally, the distance between the discrete point and the classification line is calculated according to the following formula:
[0060]
[0061] Among them, d is the distance between the discrete point and the classification line, (px,py) is the coordinate of the discrete point, k is the slope of the classification line, and b is the intercept of the classification line.
[0062] In the disclosed embodiment, by accurately calculating the vertical distance from each discrete point to the classification line, it is ensured that the classification line can best fit all discrete points. Specifically, the slope of the classification line is first determined based on the statistical analysis of the angle between the line connecting the discrete points in the barcode endpoints and the x-axis. The slope is the key feature of the classification line and reflects the dominant direction of the line connecting the barcode endpoints. The point-to-line distance formula is used to calculate the vertical distance from each discrete point to the classification line. By calculating the distance from all discrete points to the classification line, a distance set can be obtained. Then, the mean of these distances is calculated, and this mean represents the average position of the discrete points relative to the classification line. Finally, using this mean, the intercept of the classification line is inverted by the least squares method to obtain the complete classification line equation.
[0063] Optionally, the intercept of the classification line is calculated according to the following formula:
[0064]
[0065] Among them, b is the intercept of the classification line, d(i) is the distance between all discrete points and the classification line, is the mean distance between the discrete points and the classification line.
[0066] In the embodiment of the present disclosure, b is the intercept of the classification line, and the intercept of the line can be adjusted so that the line best fits all discrete points. This process is achieved by minimizing the sum of the squares of the distances from the discrete points to the line.
[0067] Optionally, parallel line fitting is performed on the barcode endpoints that have undergone binary classification, including: performing parallel line fitting on two groups of barcode endpoints obtained by classification at the same time; or, performing straight line fitting on one group of barcode endpoints obtained by classification to obtain a first straight line; and performing straight line fitting on another group of barcode endpoints obtained by classification according to the slope of the first straight line to obtain a second straight line.
[0068] Combination Figure 4 As shown, the embodiment of the present disclosure provides another parallel line fitting method for barcode recognition, comprising:
[0069] S401, the processor obtains the angle between the line connecting any two discrete points in the barcode endpoints and the x-axis.
[0070] S402: The processor uses the slope of the included angle in the angle histogram as the slope of the classification line.
[0071] S403: The processor calculates a classification line according to the slope of the classification line to classify the barcode endpoints into two categories.
[0072] S404, the processor simultaneously performs parallel line fitting on the two groups of barcode endpoints obtained by classification; or, performs straight line fitting on one group of barcode endpoints obtained by classification to obtain a first straight line; and performs straight line fitting on another group of barcode endpoints obtained by classification according to the slope of the first straight line to obtain a second straight line.
[0073] S405, the processor performs barcode recognition through the fitted parallel lines.
[0074] In the embodiment of the present disclosure, the specific steps are as follows: First, the barcode endpoints are divided into two groups using the determined classification straight line. Then, two methods can be selected for parallel line fitting.
[0075] The first method is to simultaneously perform parallel line fitting on the two groups of barcode endpoints obtained by classification. First, the average slope of each group of endpoints is calculated, and then based on the slope, two parallel lines are fitted using the least squares method to ensure that the slopes of the two lines are the same, but the intercepts are different to adapt to the respective endpoint distributions.
[0076] The second method is to first perform a straight line fit on the first group of barcode endpoints to obtain the equation of the first line, including its slope and intercept. Then, using the slope of the first line, perform a straight line fit on the second group of barcode endpoints to obtain the equation of the second line. In this way, the second line will be parallel to the first line, ensuring that the slopes of the two lines are consistent, thus reflecting the overall trend of the barcode endpoints.
[0077] By fitting two sets of barcode endpoints with parallel lines, the recognition problem caused by uneven distribution or imbalanced number of discrete points can be effectively solved, ensuring that each set of endpoints can be accurately fitted to a straight line, so as to better judge the status of each line segment, complete the correct decoding of the barcode, and improve the recognition efficiency.
[0078] Figure 5 It is a schematic diagram of the typical discrete point distribution provided by the embodiment of the present disclosure. As shown in Figure (a), this type of discrete point distribution characteristics are good, the number of two types of discrete points is balanced, and each type of discrete points is evenly distributed. As shown in Figure (b), the number of two types of discrete points is relatively unevenly distributed. Since the fitting algorithm is based on the statistical information of the discrete points, the straight line fitting of the lower discrete points can be completed first. After the slope is determined, the straight line fitting of the upper discrete points can be further completed. In this way, the straight line fitting of the smaller number of discrete points can be ensured to be more accurate. As shown in Figure (c), the two types of discrete points are relatively unbalanced, and the upper points are more concentrated. Before parallel line fitting, such discrete points can first determine the slope of the straight line to be fitted, and then perform straight line fitting, which can improve the accuracy of straight line fitting.
[0079] Optionally, any two discrete points in the barcode endpoints meet the following condition: a distance between any two discrete points is greater than a distance threshold.
[0080] In the disclosed embodiment, when processing discrete points in the barcode endpoints, setting a distance threshold helps ensure that the line connecting the selected point pairs can represent the characteristic line segments of the barcode. Specifically, when calculating the angle between the discrete point connection line and the x-axis and the subsequent parallel line fitting, only when the distance between any two discrete points is greater than the preset distance threshold, the two points will be considered for constructing the line segment. The distance threshold (for example, it can be set to 10 unit lengths) helps to filter out close point pairs caused by noise or recognition errors, thereby avoiding adverse effects on the final barcode recognition results.
[0081] Combination Figure 6 As shown, the embodiment of the present disclosure provides a parallel line fitting device 60 for barcode recognition, including a processor 100 and a memory 601. Optionally, the device 60 may also include a communication interface 602 and a bus 603. The processor 100, the communication interface 602, and the memory 601 may communicate with each other through the bus 603. The communication interface 602 may be used for information transmission. The processor 100 may call the logic instructions in the memory 601 to execute the parallel line fitting method for barcode recognition of the above embodiment.
[0082] In addition, the logic instructions in the memory 601 described above can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0083] The memory 601 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor 100 executes the function application and data processing by running the program instructions / modules stored in the memory 601, that is, the parallel line fitting method for barcode recognition in the above embodiment is implemented.
[0084] The memory 601 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 601 may include a high-speed random access memory and may also include a non-volatile memory.
[0085] The disclosed embodiments provide a barcode recognition device, including: a barcode recognition device body, and the above-mentioned parallel line fitting device for barcode recognition. The parallel line fitting device for barcode recognition is installed on the barcode recognition device body. The installation relationship described here is not limited to placement inside the barcode recognition device body, but also includes installation connections with other components of the barcode recognition device, including but not limited to physical connections, electrical connections or signal transmission connections, etc. Those skilled in the art can understand that the parallel line fitting device for barcode recognition can be adapted to a feasible barcode recognition device body, thereby realizing other feasible embodiments.
[0086] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.
[0087] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible changes. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0088] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods for each specific application to implement the described functions, but such implementations should not be considered to exceed the scope of the embodiments of the present disclosure. The technicians may clearly understand that, for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above may refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0089] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0090] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A parallel line fitting method for barcode recognition, characterized in that: include: Get the angle between the line connecting any two discrete points in the barcode endpoints and the x-axis; The slope of the angle in the angle histogram is used as the slope of the classification line; The classification line is calculated according to the slope of the classification line to classify the barcode endpoints into two categories; Parallel line fitting is performed on the binary classified barcode endpoints, so as to identify the barcode through the fitted parallel lines.
2. The parallel line fitting method according to claim 1, characterized in that: The slope of the angle in the angle histogram is used as the slope of the classification line, including: Count multiple angles and draw angle histograms; Calculate tan(θ) based on the angle θ in the angle histogram; Let tan(θ) be the slope of the classification line.
3. The parallel line fitting method according to claim 1, characterized in that: Calculate the classification line based on the slope of the classification line, including: According to the slope of the classification line, the intercept of the classification line is calculated by the least squares method to obtain the classification line.
4. The parallel line fitting method according to claim 3, characterized in that: According to the slope of the classification line, the intercept of the classification line is calculated by the least squares method, including: According to the slope of the classification line, calculate the distance between all discrete points and the classification line; Calculate the mean distance between all discrete points and the classification line; The intercept of the classification line is calculated based on the mean of the distances between all discrete points and the classification line.
5. The parallel line fitting method according to claim 4, characterized in that: The distance between the discrete point and the classification line is calculated according to the following formula: Among them, d is the distance between the discrete point and the classification line, (px,py) is the coordinate of the discrete point, k is the slope of the classification line, and b is the intercept of the classification line.
6. The parallel line fitting method according to claim 4, characterized in that: The intercept of the classification line is calculated according to the following formula: Among them, b is the intercept of the classification line, d(i) is the distance between all discrete points and the classification line, is the mean distance between the discrete points and the classification line.
7. The parallel line fitting method according to any one of claims 1 to 6, characterized in that: Perform parallel line fitting on the binary classified barcode endpoints, including: Simultaneously, parallel line fitting is performed on the two groups of barcode endpoints obtained by classification; A or, Performing straight line fitting on a group of barcode endpoints obtained by classification to obtain a first straight line; A straight line is fitted to another group of barcode endpoints obtained by classification according to the slope of the first straight line to obtain a second straight line.
8. The parallel line fitting method according to any one of claims 1 to 6, characterized in that: Any two discrete points in the barcode endpoints meet the following conditions: The distance between any two discrete points is greater than the distance threshold.
9. A parallel line fitting device for barcode recognition, comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the parallel line fitting method for barcode recognition according to any one of claims 1 to 8 when running the program instructions.
10. A barcode recognition device, characterized in that: include: Barcode recognition device body; The parallel line fitting device for barcode recognition as described in claim 9 is installed on the barcode recognition device body.