CN109754044B - Bar code, bar code generation method and identification method - Google Patents

Bar code, bar code generation method and identification method Download PDF

Info

Publication number
CN109754044B
CN109754044B CN201910032714.3A CN201910032714A CN109754044B CN 109754044 B CN109754044 B CN 109754044B CN 201910032714 A CN201910032714 A CN 201910032714A CN 109754044 B CN109754044 B CN 109754044B
Authority
CN
China
Prior art keywords
pattern
bar
information
bar code
strip
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910032714.3A
Other languages
Chinese (zh)
Other versions
CN109754044A (en
Inventor
朱鹏
秦鹏飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Himalaya Technology Co ltd
Original Assignee
Shanghai Himalaya Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Himalaya Technology Co ltd filed Critical Shanghai Himalaya Technology Co ltd
Priority to CN201910032714.3A priority Critical patent/CN109754044B/en
Publication of CN109754044A publication Critical patent/CN109754044A/en
Application granted granted Critical
Publication of CN109754044B publication Critical patent/CN109754044B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application provides a bar code, a bar code generation method and an identification method, and relates to the technical field of bar codes. The bar code comprises a first characteristic area, a data area, a second characteristic area and different data information, wherein the first characteristic area is formed by a first bar-shaped pattern and a second bar-shaped pattern which are used for representing coded version information and identification information, the data area is formed by at least two data bar-shaped patterns which are used for representing target information, the second characteristic area is formed by at least two characteristic bar-shaped patterns which are used for representing characteristic information (including masks, data lengths and check codes) corresponding to the data bar-shaped patterns, and then the different data information is represented by the height of each bar-shaped pattern. For the bar code, in order to obtain the data information hidden in the bar code, it is necessary to identify a plurality of feature information such as encoded version information, identification information, and mask corresponding to the bar code, and then decode the target information contained in the data area according to the feature information. Therefore, the bar code has higher security than the prior art.

Description

Bar code, bar code generation method and identification method
Technical Field
The present application relates to the field of barcode technologies, and in particular, to a barcode, a barcode generating method, and a barcode identifying method.
Background
A bar code (barcode) is a graphic identifier in which a plurality of bar-shaped patterns and spaces are arranged according to a certain rule to express target information. The information identification is carried out through the bar code, and the method has the advantages of high speed, high reliability, convenience, flexibility and the like.
However, the barcode used at present is simple in coding system, and only the width of each bar pattern and the space between the bar patterns are used to express information, which is very easy to be obtained and forged by lawbreakers. Therefore, it is of particular importance to those skilled in the art to improve the information security of bar codes.
Disclosure of Invention
In view of the above, the present application provides a barcode to solve at least one technical problem in the background art.
In order to achieve the above purpose, the preferred embodiment of the present application adopts the following technical solutions:
in a first aspect, an embodiment of the present application provides a barcode, where the barcode includes a first characteristic region, a second characteristic region, and a data region; wherein the content of the first and second substances,
the first characteristic area comprises a first strip pattern and a second strip pattern, and the first characteristic area represents the coding version information and the identification information of the bar code through the heights of the first strip pattern and the second strip pattern;
the data area comprises at least two data strip patterns, and the data area represents target information stored by the bar code through the height of the data strip patterns;
the second characteristic area comprises at least two characteristic strip patterns, the second characteristic area represents characteristic information corresponding to the data strip patterns through the heights of the characteristic strip patterns, and the characteristic information comprises a mask code, a data length and a check code.
Optionally, in an embodiment of the present application, a height difference between the first stripe pattern and the second stripe pattern is used to characterize the encoding version information;
and the height difference value of the first strip-shaped pattern and the second strip-shaped pattern is used for representing the identification information.
Optionally, in one embodiment of the present application, the first feature region is located at an end of the barcode.
Optionally, in an embodiment of the present application, the first bar pattern is located at one end of the bar code;
the other end of the bar code includes a third stripe pattern having the same height as the first stripe pattern.
In a second aspect, an embodiment of the present application provides a barcode generating method, configured to generate a barcode as described above, where the method includes:
acquiring target information to be converted into a bar code;
obtaining feature information corresponding to the bar code to be generated according to the target information and a preset coding rule, wherein the feature information comprises coding version information, identification feature information, a data type, a data length, a mask code and a check code, and the identification feature information comprises unit heights corresponding to the bar patterns;
calculating a target height for representing the target information according to the mask, the unit height and a preset basic height, and generating a data strip pattern corresponding to the target information according to the target height;
generating a characteristic strip pattern and an identification strip pattern for representing the characteristic information according to the corresponding relation between the preset characteristic information and the unit height;
and arranging the data strip patterns, the characteristic strip patterns and the identification strip patterns in parallel according to a preset arrangement sequence to obtain the bar code containing the target information.
In a third aspect, an embodiment of the present application provides a barcode identification method, configured to identify a barcode as described above, where the method includes:
acquiring an image of a bar code to be identified;
identifying a first bar pattern and a second bar pattern of the bar code from the image;
obtaining coding version information and identification information corresponding to the bar code according to the height ratio and the height difference value of the first strip-shaped pattern and the second strip-shaped pattern;
identifying a data strip pattern used for representing target information and a characteristic strip pattern used for representing characteristic information corresponding to the data strip pattern in the bar code according to the coding version information;
obtaining the meaning represented by each data strip pattern and each characteristic strip pattern according to the identification information and the bar code height of each identified strip pattern;
and obtaining the data information contained in the bar code to be identified according to the data bar pattern and the meaning represented by the characteristic bar pattern.
Optionally, in an embodiment of the application, the feature information includes a mask, and the step of obtaining the data information included in the barcode to be identified according to the data stripe pattern and the meaning indicated by the feature stripe pattern includes:
obtaining a mask corresponding to the bar code to be identified according to the meaning represented by the characteristic strip pattern;
and decoding the meaning represented by the data strip pattern according to the mask to obtain the data information contained in the bar code to be identified.
Optionally, in an embodiment of the present application, before the step of identifying the first and second bar patterns of the barcode from the image, the method further includes: and carrying out binarization processing on the image.
Optionally, in an embodiment of the present application, after the step of identifying the first and second bar patterns of the barcode from the image, the method further includes:
detecting the slope of the first strip-shaped pattern;
and judging whether the image is inclined or not according to the slope, and rotating the image according to the slope when the image is inclined.
Optionally, in an embodiment of the present application, the first bar pattern is located at one end of the barcode to be identified, and the other end of the barcode to be identified includes a third bar pattern having the same height as the first bar pattern, and the method further includes:
detecting whether the heights of the third strip-shaped pattern and the first strip-shaped pattern are the same or not;
if the two bar codes are different, the image is subjected to perspective transformation processing to recover the shape of the bar code to be identified.
Compared with the prior art, the method has the following beneficial effects:
according to the bar code provided by the embodiment of the application, the first characteristic region is formed by the first strip-shaped pattern and the second strip-shaped pattern which are used for representing the coded version information and the identification information, the data region is formed by at least two data strip-shaped patterns which are used for representing the target information, the second characteristic region is formed by at least two characteristic strip-shaped patterns which are used for representing the characteristic information (including a mask code, a data length and a check code) corresponding to the data strip-shaped patterns, and then different data information is represented by the height of each strip-shaped pattern. For the barcode provided in the embodiment of the present application, in order to obtain the data information hidden in the barcode, it is necessary to identify a plurality of feature information, such as the coding version information, the identification information, and the mask, corresponding to the barcode, and then decode the target information contained in the data area according to the feature information. Therefore, the barcode provided by the application has higher safety compared with the prior art.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments are briefly described below, it should be understood that the following drawings only show some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic view of a first structure of a barcode provided in an embodiment of the present application;
fig. 2 is a second schematic structural diagram of a barcode provided in the embodiment of the present application;
FIG. 3 is a schematic diagram of a third structure of a barcode provided in the embodiment of the present application;
fig. 4 is a structure of a first electronic device provided in an embodiment of the present application;
fig. 5 is a schematic block diagram of a barcode generating apparatus in a first electronic device according to an embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating steps of a barcode generation method according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a second electronic device according to an embodiment of the present application;
fig. 8 is a schematic block diagram of a barcode identification apparatus in a second electronic device according to an embodiment of the present disclosure;
fig. 9 is a schematic flowchart illustrating steps of a barcode identification method according to an embodiment of the present application.
Icon: 10-a first feature region; 11-a first stripe pattern; 12-a second stripe pattern; 20-a second feature region; 21-a first characteristic stripe pattern; 22-a second characteristic stripe pattern; 23-a third characteristic stripe pattern; 30-a data area; 31-first data stripe pattern; 32-second data stripe pattern; 40-a third striped pattern; 100-a first electronic device; 111-a first memory; 112-a first storage controller; 113-a first processor; 70-bar code generating means; 701-a first obtaining module; 702-a first processing module; 703-a calculation module; 704-a generation module; 705-ranking module; 200-a second electronic device; 211-a second memory; 212-a second storage controller; 213-a second processor; 80-a bar code identification device; 801-a second acquisition module; 802-a second processing module; 803-a first identification module; 804-a second identification module; 805-decoding module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the embodiments of the present application, it should be noted that the terms "first", "second", and the like are named only for distinguishing different features, so as to facilitate description of the present application and simplify description, but do not indicate or imply relative importance, and thus should not be construed as limiting the present application.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, a schematic structural diagram of a barcode provided in an embodiment of the present application is shown, where the barcode includes a first characteristic region 10, a second characteristic region 20, and a data region 30.
Wherein, the first characteristic region 10 is used for characterizing the encoding version information (such as the total number of the bar patterns in the bar code, the parameter represented by each bar pattern) and the identification information (the unit height corresponding to each bar pattern) corresponding to the bar code; the data area 30 is used for storing target information (such as numerical numbers, data types, and the like); the second characteristic information is used to characterize characteristic information (such as mask, data length, check code, etc.) corresponding to each stripe pattern in the data area 30.
The barcode provided in the embodiment of the present application is described in detail below with reference to fig. 1.
In an embodiment of the present application, the first characteristic region 10 is disposed at the left end of the barcode, considering that in the barcode identification process, the encoded version information and the identification information corresponding to the barcode need to be identified first. It should be noted that, as an alternative to this embodiment, the first characteristic region 10 may also be disposed at the right end of the barcode.
Further, with reference to fig. 1, the first feature region 10 includes a first bar-shaped pattern 11 and a second bar-shaped pattern 12, and a height of the first bar-shaped pattern 11 is different from a height of the second bar-shaped pattern 12, and a height relationship thereof is used to represent the encoded version information and the identification information corresponding to the barcode.
In particular, in a possible implementation, the height difference between the first stripe pattern 11 and the second stripe pattern 12 is used to characterize the identification information. In the process of identifying the barcode, the difference between the heights of the first and second bar patterns 11 and 12 can be used as a unit height (reference height) of the barcode, and then the meaning represented by the true height of each bar pattern can be obtained according to the unit height.
In this embodiment, the height ratio of the first bar-shaped pattern 11 to the second bar-shaped pattern 12 can also be used to characterize the encoded version information of the barcode. In the identification process, the coded version information corresponding to the barcode can be obtained by identifying the proportional relationship between the heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12. For example, when the height ratio is identified as 5:4, the barcode may include 21 bar patterns in total, wherein the 1 st to 2 nd bar patterns from left to right are the first feature area 10 of the barcode, the 3 rd to 8 th bar patterns are the second feature area 20 of the barcode, the 9 th to 20 th bar patterns are the data area 30 of the barcode, and the 21 st bar pattern is the terminator of the barcode.
It should be noted that, in the embodiment of the present application, the ratio of the heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12 may be, but is not limited to, the above ratio, and the barcode may represent different encoded version information corresponding to the barcode by using different height ratios between the first bar-shaped pattern 11 and the second bar-shaped pattern 12.
It should be further noted that, in the embodiment of the present application, the first feature region 10 may include other stripe patterns besides the first stripe patterns 11 and the second stripe patterns 12. In actual use, the encoded version information and the identification information of the barcode may be characterized by a height relationship between the plurality of bar patterns.
With continued reference to fig. 1, the data area 30 includes a first data stripe pattern 31 for indicating a data type, and a second data stripe pattern 32 for indicating digital information.
The first data stripe pattern 31 represents different data types, such as sound, album, merchandise, etc., through different heights; the second data stripe pattern 32 represents different digital information, such as 0-9, by different heights.
Specifically, in one possible embodiment, the second data stripe pattern 32 is used to represent numbers 0 to 9, wherein the number "0" is represented by a base height, and the numbers 1 to 9 are represented by unit heights that are increased by a factor corresponding to the target number. This characterization may be expressed as: h is k m + n m, where h is the height of the stripe pattern, k is the number represented by the stripe pattern, m is the unit height, and n m represents the base height.
It should be noted that, in the embodiment of the present application, the second data stripe pattern 32 in the data area 30 may also be used to represent other data information besides the numbers 0 to 9, such as letters a to Z, characters, and the like, and specifically, the corresponding relationship between each height and the target information may be configured.
With continued reference to fig. 1, the second feature area 20 includes a first feature stripe pattern 21 for indicating the number of stripe patterns in the data area 30, a second feature stripe pattern 22 for characterizing a mask corresponding to the data area 30, and a third feature stripe pattern 23 for characterizing a check code.
The first characteristic stripe pattern 21 may include one, two, or more than two stripe patterns, and the specific situation may be determined according to the number of the data stripe patterns in the data area 30. For example, when the number of the data stripe patterns included in the data area 30 is two digits (10 to 99), two stripe patterns may be used as the first characteristic stripe pattern 21 to represent the data length of the barcode.
The second characteristic stripe pattern 22 is used to represent a mask corresponding to each data stripe pattern in the data area 30, and in the identification process, the mask corresponding to the second characteristic stripe pattern 22 needs to be identified first to decode the data stripe pattern in the data area 30, so that the barcode provided in the embodiment of the present application can improve the information security of the barcode to a certain extent.
The third characteristic strip pattern 23 represents the check code information corresponding to the barcode by its height, and during the identification process, the identified data can be checked by the check code information to determine whether the identified result is correct.
In the embodiment of the present application, by providing the first characteristic stripe pattern 21, the second characteristic stripe pattern 22, and the third characteristic stripe pattern 23 in the barcode, not only the accuracy of barcode identification can be ensured, but also the security of barcode information can be improved.
With continued reference to fig. 1, in one embodiment of the present application, the end of the bar code remote from the first feature 10 is further provided with a third bar pattern 40 having the same height as the first bar pattern 11 at the end thereof. In the identification process, whether the barcode image collected by the identification device such as a barcode scanner has deformation can be determined by the third stripe pattern 40.
Specifically, when the first bar-shaped pattern 11 and the third bar-shaped pattern 40 are detected to have different heights in the process of identifying the barcode information, it indicates that the acquired image has deformation.
Further, in an embodiment of the present application, after detecting that the acquired image has a deformation, the image is subjected to perspective transformation to recover the deformation, so as to improve the accuracy of the recognition result.
For the bar code provided in the above embodiment, it should be further noted that the bar patterns in the bar code may be arranged according to, but not limited to, the arrangement sequence shown in fig. 1, and the positions of the bar patterns in the bar code may be arbitrarily exchanged according to the requirement, for example, the first data bar pattern 31 for characterizing the data type in the data area 30 may also be interposed between the second bar pattern 12 and the first characteristic bar pattern 21.
Further, with continued reference to fig. 1, in one embodiment of the present application, to facilitate identifying the height of each bar pattern in the bar code, the bar patterns are arranged in a manner that they are aligned centrally and equidistantly. By the arrangement mode, the height of the bar code can be obtained by scanning the middle point in each bar pattern up and down in the process of identifying the bar code.
Alternatively, referring to fig. 2 and fig. 3, as an alternative of the present application, the bar patterns in the barcode may also be arranged in an arrangement manner that the upper ends are aligned or the lower ends are aligned. When the alignment is performed in the upper-end alignment manner as shown in fig. 2, the height of each stripe pattern can be obtained by scanning downward from the upper end of the stripe pattern; when arranged in a lower end aligned manner as shown in fig. 3, the height of each stripe pattern can be obtained by scanning upward from the lower end thereof.
Referring to fig. 4 to fig. 6, in which fig. 4 is a schematic structural diagram of a first electronic device 100 provided in the embodiment of the present application, fig. 5 is a schematic block diagram of a barcode generating apparatus 70 in the first electronic device 100, and fig. 6 is a schematic step flow diagram of a barcode generating method provided in the embodiment of the present application.
The method shown in fig. 6 may be applied to the first electronic device 100 shown in fig. 4 in the form of a computer program, and when the first electronic device 100 executes the computer program corresponding to the method, the barcode as described above is generated.
The following describes the barcode generation method provided in the embodiment of the present application in detail with reference to fig. 4 and 6.
Referring to fig. 4 and 5, the first electronic device 100 includes a barcode generating apparatus 70, a first memory 111, a first memory controller 112, and a first processor 113. The barcode generating apparatus 70 includes a first obtaining module 701, a first processing module 702, a calculating module 703, a generating module 704, and an arranging module 705.
The elements of the first memory 111, the first memory controller 112 and the first processor 113 are directly or indirectly electrically connected to each other to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The barcode generating apparatus 70 may include at least one software functional module which may be stored in the first memory 111 in a form of software or firmware (firmware) or solidified in an Operating System (OS) of the first electronic device 100. The first processor 113 is configured to execute executable modules stored in the first memory 111, such as software functional modules and computer programs included in the barcode generating apparatus 70.
The first Memory 111 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The first memory 111 is used for storing a program, and the first processor 113 executes the program after receiving an execution instruction. Access to the first memory 111 by the first processor 113 and possibly other components may be under the control of the first memory controller 112.
The first processor 113 may be an integrated circuit chip having signal processing capability; or a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; but also as Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., that may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application.
It should be understood that the structure shown in fig. 4 is only a schematic diagram, and the first electronic device 100 may also include more or fewer components than those shown in fig. 4, or have a different configuration than that shown in fig. 4. The components shown in fig. 4 may be implemented in hardware, software, or a combination thereof.
Referring to fig. 6, a schematic flowchart of steps of a barcode generation method provided in an embodiment of the present application is shown. The method comprises the following steps:
step S10, target information to be converted into a barcode is acquired.
Step S11, obtaining feature information corresponding to the barcode to be generated according to the target information and a preset encoding rule, where the feature information includes encoding version information, identification feature information, a data type, a data length, a mask, and a check code, and the identification feature information includes a unit height corresponding to each bar pattern.
The step S10 may be implemented by the first obtaining module 701, and the step S11 may be implemented by the first processing module 702.
In this embodiment, after the first electronic device 100 obtains the target information to be converted into the barcode, the user may select a corresponding encoding rule to process the target information according to a requirement, so as to obtain the barcode with a shape corresponding to the encoding rule.
Specifically, the generating process of the barcode may include: the first electronic device 100 obtains feature information such as encoding version information, identification feature information, mask code, check code, and the like according to the information such as the data type, data length, and the like of the target information and then according to the encoding rule selected by the user.
With continued reference to fig. 4, after the above-mentioned steps S10 and S11, the barcode generation method further includes:
step S12, calculating a target height for representing the target information according to the mask, the unit height, and a preset base height, and generating a data stripe pattern corresponding to the target information according to the target height.
Step S13, generating a characteristic stripe pattern and an identification stripe pattern for representing the characteristic information according to the corresponding relationship between the preset characteristic information and the unit height.
The step S12 may be implemented by the calculation module 703, and the step S13 may be implemented by the generation module 704.
After determining the code version information and the identification feature information corresponding to the barcode to be generated through the above steps, the height ratio and the height difference between the first bar-shaped pattern 11 and the second bar-shaped pattern 12 in the barcode may be obtained, and then the target heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12 (identification bar-shaped pattern) used for representing the code version information and the identification information of the barcode are obtained.
For example, if the unit height corresponding to the identification feature information is 1cm (that is, the height difference between the first stripe pattern 11 and the second stripe pattern 12 is 1cm), and the height ratio corresponding to the coding version information is 5:4, it can be obtained that the target height of the first stripe pattern 11 is 5cm, and the target height of the second stripe pattern 12 is 4 cm.
Further, the unit height, the mask, the preset base height (used for representing the number 0), and the corresponding relationship between the barcode height and the target information are calculated, so that the target height of each bar pattern in the data area 30, which is used for representing the target information, can be obtained. For example, in one possible embodiment, if the mask is 2, the actual number represented by the second data bar pattern 32 representing the digital information in the barcode data area 30 is equal to the number corresponding to the current height plus 2.
Specifically, the target height may be represented by h ═ k + a) × m + n × m, where h is the target height of the stripe pattern, k is the target information represented by the stripe pattern, a is the mask, m is the unit height, and n × m is the base height.
For example, if the unit height is 1cm, the base height is 3 times the unit height, and the mask is 2, and it is desired to generate a stripe pattern for representing a numeral 5, then (5+2) × 1cm may be added to the base height (3cm), that is, a stripe pattern with a height of 10cm is used to represent a numeral 5.
In a possible implementation manner, the target information further includes a first data stripe pattern 31 for characterizing a data type, and a height of the first data stripe pattern 31 may be determined according to a preset corresponding relationship between the data type and the height.
Similarly, in the embodiment of the present application, for the first characteristic stripe pattern 21, the second characteristic stripe pattern 22, and the third characteristic stripe pattern 23 in the second characteristic region 20, which are used to represent the data length, the mask, and the check code, the target heights may be obtained through a preset corresponding relationship between the first characteristic stripe pattern and the second characteristic stripe pattern and the height.
Further, with reference to fig. 4, after the step S12 and the step S13, the method further includes:
step S14, arranging the data bar patterns, the characteristic bar patterns, and the identification bar patterns in parallel according to a preset arrangement order, to obtain the barcode including the target information.
The step S14 may be implemented by the ranking module 705. After the data stripe patterns, the characteristic stripe patterns and the target heights of the identification stripe patterns are obtained through the above steps, the stripe patterns are arranged in parallel according to a preset arrangement sequence, and the bar code containing the target information as shown in fig. 1 to 3 can be obtained.
It should be noted that, in the embodiment of the present application, the above-mentioned stripe patterns may be aligned in a central equidistant parallel arrangement as shown in fig. 1, in an upper equidistant parallel arrangement as shown in fig. 2, and in a lower equidistant parallel arrangement as shown in fig. 3, but not limited thereto.
Referring to fig. 7 to 9, wherein fig. 7 is a schematic structural diagram of a second electronic device 200 provided in the embodiment of the present application, fig. 8 is a schematic block diagram of a barcode recognition apparatus 80 in the second electronic device 200, and fig. 9 is a schematic step flow diagram of a barcode recognition method provided in the embodiment of the present application.
The barcode recognition method shown in fig. 9 may be applied to the second electronic device 200 shown in fig. 7 in the form of a computer program, and when the second electronic device 200 executes the computer program corresponding to the recognition method, the data information stored in the barcode is recognized.
The barcode identification method provided by the embodiment of the present application is described in detail below with reference to fig. 7 to 9.
Referring to fig. 7 and 8, the second electronic device 200 includes a barcode recognition apparatus 80, a second memory 211, a second memory controller 212, and a second processor 213. The barcode identification apparatus 80 includes a second obtaining module 801, a second processing module 802, a first identifying module 803, a second identifying module 804, and a decoding module 805.
For the connection relationship among the barcode recognition device 80, the second memory 211, the second memory controller 212, and the second processor 213 and the respective functional descriptions, reference may be made to the first electronic device 100 described above, and no further description is provided herein.
It should be understood that the configuration shown in fig. 7 is merely a schematic diagram, and the second electronic device 200 may also include more or fewer components than shown in fig. 7, or have a different configuration than shown in fig. 7. The components shown in fig. 7 may be implemented in hardware, software, or a combination thereof.
Referring to fig. 9, a schematic flowchart of steps of a barcode identification method according to an embodiment of the present application is provided. The method comprises the following steps:
step S20, an image of the barcode to be recognized is acquired.
In step S21, the first and second bar patterns 11 and 12 of the barcode are recognized from the image.
The step S20 may be implemented by the second obtaining module 801, and the step S21 may be implemented by the first identifying module 803.
Since the height relationship between the first bar-shaped pattern 11 and the second bar-shaped pattern 12 represents the encoded version information and the identification information corresponding to the barcode, it is necessary to identify the encoded version information and the identification information hidden in the first bar-shaped pattern 11 and the second bar-shaped pattern 12 first in order to identify the information hidden in the barcode.
In consideration of the need to identify the bar-like patterns in the bar code and the spaces (blank portions) between the bar-like patterns in the identification process, in one possible embodiment, in order to facilitate image identification, the image may be subjected to binarization processing before identification, with the bar-like patterns in the bar code set to black and the blank portions between the bar-like patterns set to white.
Further, in an embodiment of the present application, the first stripe pattern 11 and the second stripe pattern 12 are disposed at a left end of the barcode, wherein the first stripe pattern 11 is located at a leftmost end, and the second stripe pattern 12 is adjacent to the first stripe pattern 11. And, the space between the first stripe pattern 11 and the second stripe pattern 12 is the same as the width of the first stripe pattern 11 and the second stripe pattern 12. For the bar code, in the process of identifying the first bar-shaped pattern 11 and the second bar-shaped pattern 12, the image may be scanned from left to right, and if the ratio of the width of the first bar-shaped pattern 11, the pitch width, and the width of the second bar-shaped pattern 12, which is identified in the scanning process, meets a preset ratio (e.g., 1: 1: 1), it indicates that the first bar-shaped pattern 11 and the second bar-shaped pattern 12 for representing the bar code encoding version information and the identification information have been found.
With continued reference to fig. 9, after the above-mentioned steps S20 and S21, the barcode recognition method further includes:
step S22, obtaining the code version information and the identification information corresponding to the barcode according to the height ratio and the height difference between the first stripe pattern 11 and the second stripe pattern 12.
The step S22 can be implemented by the second processing module 802.
In the embodiment of the present application, after the first and second stripe patterns 11 and 12 are identified, the center coordinates of the first and second stripe patterns 11 and 12 in the width direction may be scanned upwards and downwards to obtain the highest point coordinates and the lowest point coordinates of the stripe patterns, so as to calculate the heights of the first and second stripe patterns 11 and 12.
Considering that the barcode image captured by the second electronic device 200 during the barcode recognition process may be tilted, a certain degree of deviation in the width direction is allowed during the up-and-down scanning process through the midpoint, and the maximum deviation value may be half of the width of the first and second bar patterns 11 and 12.
For example, if the width of the first and second stripe patterns 11 and 12 is 2cm, the first and second stripe patterns may be shifted by 1cm to the left or right during the up-and-down scanning process to accurately find the highest and lowest points of the stripe patterns, thereby ensuring the accuracy of the identified height data.
In addition, in consideration of the fact that the accuracy of the identification information is affected if the collected barcode image is inclined or deformed in the identification process, in an embodiment of the present application, the slope of the first bar-shaped pattern 11 is calculated by using the highest point coordinate and the lowest point coordinate obtained in the above steps, and if the first bar-shaped pattern 11 is detected to have an inclination, the barcode to be identified is rotated according to the slope to be aligned. For example, if the first bar pattern 11 is detected to be inclined by 10 ° clockwise, the bar code is rotated by 10 ° counterclockwise to be aligned. By the method, the accuracy of the bar code information identification can be improved to a certain degree.
Further, in the case of a deformed barcode image, the first bar-shaped pattern 11 at one end of the barcode and the third bar-shaped pattern 40 at the other end of the barcode are used for determination in one embodiment of the present application. If the height of the first stripe pattern 11 is detected to be different from the height of the third stripe pattern 40, it indicates that the image has distortion. After the image is determined to have deformation, the image is processed through a perspective transformation algorithm, and the original shape of the bar code is recovered, so that the accuracy of the identification information is further ensured.
Further, after the highest point coordinate and the lowest point coordinate of the first bar-shaped pattern 11 and the second bar-shaped pattern 12 are obtained respectively, the heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12 can be obtained through calculation of the coordinates, the code version information corresponding to the bar code to be identified is obtained according to the height ratio, and the identification information corresponding to the bar code to be identified is obtained according to the height difference.
With continued reference to fig. 9, after the above step S22, the barcode identification method further includes:
step S23, identifying a data stripe pattern used for representing target information and a characteristic stripe pattern used for representing characteristic information corresponding to the data stripe pattern in the barcode according to the encoding version information.
The step S23 may be implemented by the second identification module 804.
In the embodiment of the present application, the encoding version information includes the total number of the bar patterns in the barcode and the parameter represented by each bar pattern, so that the parameter represented by each bar pattern in the barcode to be identified can be determined by the encoding version information. For example, when the height ratio is identified as 5:4, the barcode may include 21 bar patterns in total, wherein the 1 st to 2 nd bar patterns from left to right are the first feature area 10 of the barcode, the 3 rd to 8 th bar patterns are the second feature area 20 of the barcode, the 9 th to 20 th bar patterns are the data area 30 of the barcode, and the 21 st bar pattern is the terminator of the barcode.
Further, with continued reference to fig. 9, after the above step S23, the method further includes:
step S24, obtaining the meaning of each data stripe pattern and the characteristic stripe pattern according to the identification information and the bar code height of each identified stripe pattern.
Step S25, obtaining the data information included in the barcode to be identified according to the meaning indicated by the data stripe pattern and the characteristic stripe pattern.
The steps S24 and S25 may be implemented by the decoding module 805.
In the embodiment of the application, the unit height of each bar pattern can be determined through the identification information, so that the meaning represented by each data bar pattern and each characteristic bar pattern in the bar code to be identified can be obtained according to the relationship between the unit height and the bar code height of each identified bar pattern and the corresponding relationship between the preset height and the target information.
For example, in one possible embodiment, it is recognized that the height of the first bar-shaped pattern 11 in the barcode is 5cm, the height of the second bar-shaped pattern 12 is 4cm, the height of the second characteristic bar-shaped pattern 22 for characterizing the mask is 2cm (corresponding to 2 masks), and the preset base height is 3 times the difference between the heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12. When the height of a certain bar pattern in the barcode data area 30 is identified to be 10cm, the bar pattern is characterized by k ═ h-n ×/m-a ═ 10-3 × (1)/1-2 ═ 5. The meaning of each letter can be referred to above, and the description thereof is omitted.
Alternatively, in another possible embodiment, the mask characterized by the second characteristic stripe pattern 22 may be used as an index for searching the corresponding mask string (i.e. the height of the second characteristic stripe pattern 22 may correspond to a mask string, such as "12011341231"). The mask character string may be used to represent a mask corresponding to each data stripe pattern in the data area 30 of the barcode to be identified, and in this way, information security during the barcode identification process may be further ensured. In addition, in the process of generating the barcode, if the mask character string is used for information encryption, the height of the data stripe pattern in the data area 30 can be adjusted by adjusting the mask character string, so that the shape of the barcode is more beautiful.
It should be noted that, in the embodiment of the present application, the second feature stripe pattern 22 may correspond to a base height for representing a number "0". For example, when the base height is 3cm and the unit height is 1cm, if it is recognized that the height of the second characteristic stripe pattern 22 is 5cm, it indicates that the mask or the index corresponding to the barcode is 2.
The base height corresponding to the second feature stripe pattern 22 may be the same as or different from the base height used for representing the number "0" in the data area 30.
Further, in the embodiment of the present application, the characteristic stripe pattern includes, in addition to the second characteristic stripe pattern for characterizing the mask code, a first characteristic stripe pattern 21 for characterizing a data length and a third characteristic stripe pattern 23 for characterizing a check code, and during the identification process, the identified target information may be checked through the data length corresponding to the first characteristic stripe pattern 21 and the check code corresponding to the third characteristic stripe pattern 23, for example, the check is calculated through the crc8 algorithm, so as to ensure the accuracy of the identified target information.
Optionally, in the embodiment of the present application, whether the barcode is valid may also be determined by identifying a ratio of the heights of the first bar-shaped pattern 11 and the second bar-shaped pattern 12 or a ratio of the widths of the first bar-shaped pattern and the second bar-shaped pattern to the pitch width. For example, when it is detected that the ratio of the heights of the first and second bar patterns 11 and 12 or the ratio of the widths of the first and second bar patterns to the pitch widths does not satisfy the preset ratio, it is determined that the barcode is invalid, and the recognition task of the barcode is skipped directly, thereby improving the recognition efficiency of the barcode to a certain extent.
It should be noted that the apparatuses and methods disclosed in the embodiments of the present application can also be implemented in other ways. The embodiments described above are merely illustrative, and for example, the flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
To sum up, the embodiments of the present application provide a barcode, a barcode generating method, and an identifying method, where the barcode forms a first feature region by a first stripe pattern and a second stripe pattern for representing encoded version information and identification information, forms a data region by at least two data stripe patterns for representing target information, forms a second feature region by at least two feature stripe patterns for representing feature information (including a mask, a data length, and a check code) corresponding to the data stripe patterns, and then represents different data information by a height of each stripe pattern. For the barcode provided in the embodiment of the present application, in order to obtain the data information hidden in the barcode, it is necessary to identify a plurality of feature information, such as the coding version information, the identification information, and the mask, corresponding to the barcode, and then decode the target information contained in the data area according to the feature information. Therefore, the barcode provided by the application has higher safety compared with the prior art.
The above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the exemplary embodiments of the present application, and are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (9)

1. A bar code, wherein the bar code comprises a first feature area, a second feature area, and a data area; wherein the content of the first and second substances,
the first characteristic area comprises a first strip pattern and a second strip pattern, and the first characteristic area represents the coding version information and the identification information of the bar code through the heights of the first strip pattern and the second strip pattern;
the data area comprises at least two data strip patterns, and the data area represents target information stored by the bar code through the height of the data strip patterns;
the second characteristic area comprises at least two characteristic strip patterns, the second characteristic area represents characteristic information corresponding to the data strip patterns through the heights of the characteristic strip patterns, and the characteristic information comprises a mask code, a data length and a check code;
the height ratio of the first strip-shaped pattern to the second strip-shaped pattern is used for representing the coding version information;
and the height difference value of the first strip-shaped pattern and the second strip-shaped pattern is used for representing the identification information.
2. The bar code of claim 1, wherein the first feature region is located at an end of the bar code.
3. The bar code of claim 2, wherein said first bar pattern is located at one end of said bar code;
the other end of the bar code includes a third stripe pattern having the same height as the first stripe pattern.
4. A barcode generation method for generating a barcode according to any one of claims 1 to 3, the method comprising:
acquiring target information to be converted into a bar code;
obtaining feature information corresponding to the bar code to be generated according to the target information and a preset coding rule, wherein the feature information comprises coding version information, identification feature information, a data type, a data length, a mask code and a check code, and the identification feature information comprises unit heights corresponding to the bar patterns;
calculating a target height for representing the target information according to the mask, the unit height and a preset basic height, and generating a data strip pattern corresponding to the target information according to the target height;
generating a characteristic strip pattern and an identification strip pattern for representing the characteristic information according to the corresponding relation between the preset characteristic information and the unit height;
and arranging the data strip patterns, the characteristic strip patterns and the identification strip patterns in parallel according to a preset arrangement sequence to obtain the bar code containing the target information.
5. A bar code recognition method for recognizing a bar code according to any one of claims 1 to 3, the method comprising:
acquiring an image of a bar code to be identified;
identifying a first bar pattern and a second bar pattern of the bar code from the image;
obtaining coding version information and identification information corresponding to the bar code according to the height ratio and the height difference value of the first strip-shaped pattern and the second strip-shaped pattern;
identifying a data strip pattern used for representing target information and a characteristic strip pattern used for representing characteristic information corresponding to the data strip pattern in the bar code according to the coding version information;
obtaining the meaning represented by each data strip pattern and each characteristic strip pattern according to the identification information and the bar code height of each identified strip pattern;
and obtaining the data information contained in the bar code to be identified according to the data bar pattern and the meaning represented by the characteristic bar pattern.
6. The method according to claim 5, wherein the characteristic information includes a mask, and the step of obtaining the data information included in the barcode to be identified according to the data bar pattern and the meaning indicated by the characteristic bar pattern includes:
obtaining a mask corresponding to the bar code to be identified according to the meaning represented by the characteristic strip pattern;
and decoding the meaning represented by the data strip pattern according to the mask to obtain the data information contained in the bar code to be identified.
7. The method of claim 5, wherein prior to the step of identifying the first and second bar patterns of the bar code from the image, the method further comprises: and carrying out binarization processing on the image.
8. The method of claim 5, wherein after the step of identifying the first and second bar patterns of the bar code from the image, the method further comprises:
detecting the slope of the first strip-shaped pattern;
and judging whether the image is inclined or not according to the slope, and rotating the image according to the slope when the image is inclined.
9. The method of claim 5, wherein the first bar pattern is located at one end of the bar code to be identified, and the other end of the bar code to be identified includes a third bar pattern having the same height as the first bar pattern, the method further comprising:
detecting whether the heights of the third strip-shaped pattern and the first strip-shaped pattern are the same or not;
if the two bar codes are different, the image is subjected to perspective transformation processing to recover the shape of the bar code to be identified.
CN201910032714.3A 2019-01-14 2019-01-14 Bar code, bar code generation method and identification method Active CN109754044B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910032714.3A CN109754044B (en) 2019-01-14 2019-01-14 Bar code, bar code generation method and identification method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910032714.3A CN109754044B (en) 2019-01-14 2019-01-14 Bar code, bar code generation method and identification method

Publications (2)

Publication Number Publication Date
CN109754044A CN109754044A (en) 2019-05-14
CN109754044B true CN109754044B (en) 2021-10-15

Family

ID=66404684

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910032714.3A Active CN109754044B (en) 2019-01-14 2019-01-14 Bar code, bar code generation method and identification method

Country Status (1)

Country Link
CN (1) CN109754044B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110503174B (en) * 2019-08-28 2023-08-15 苏州儒拉玛特智芸科技有限公司 Product information marking and identifying method, device and storage medium
CN111144161A (en) * 2020-04-03 2020-05-12 支付宝(杭州)信息技术有限公司 Barcode identification method and device, commodity information determination method and payment method
CN112990404B (en) * 2021-02-08 2022-01-28 北京声智科技有限公司 Method and device for generating sample identification code pattern, acquisition method and electronic equipment
CN113298211B (en) * 2021-05-25 2023-09-01 北京京东振世信息技术有限公司 Bar code generation and bar code identification method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901328A (en) * 2009-05-29 2010-12-01 株式会社东芝 Barcode processing apparatus and barcode processing method
CN106779005A (en) * 2016-08-17 2017-05-31 杭州甄别网络科技有限公司 A kind of particular bar, its forming method and its formation system
CN106951946A (en) * 2017-01-25 2017-07-14 海南亚元防伪技术研究所(普通合伙) Two-in-one bar code

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE60228894D1 (en) * 2002-12-17 2008-10-23 Sharp Kk DEVICE FOR DETECTING BAR CODES

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901328A (en) * 2009-05-29 2010-12-01 株式会社东芝 Barcode processing apparatus and barcode processing method
CN106779005A (en) * 2016-08-17 2017-05-31 杭州甄别网络科技有限公司 A kind of particular bar, its forming method and its formation system
CN106951946A (en) * 2017-01-25 2017-07-14 海南亚元防伪技术研究所(普通合伙) Two-in-one bar code

Also Published As

Publication number Publication date
CN109754044A (en) 2019-05-14

Similar Documents

Publication Publication Date Title
CN109754044B (en) Bar code, bar code generation method and identification method
EP2393038A1 (en) Matrix-type two-dimensional barcode decoding chip and decoding method thereof
CN110659529B (en) Bar code identification method, bar code identification device, computer equipment and storage medium
JP3115003B2 (en) Method and apparatus for decoding barcode symbols using module size ratio analysis
JP2002541566A (en) Imaging engine and technology for reading zip codes
CN104346640A (en) Two dimensional code and method of creating same
CN111539502B (en) Anti-counterfeiting two-dimensional code generation method and device, server and storage medium
JP3640573B2 (en) Bar code reading method and bar code reading system
US20150090795A1 (en) Method and system for detecting detection patterns of qr code
CN110765795B (en) Two-dimensional code identification method and device and electronic equipment
CN113673655B (en) Method and device for determining decoding direction of two-dimensional code, electronic equipment and medium
CN111783495A (en) Bar code identification method and device, electronic equipment and storage medium
CN112733568B (en) One-dimensional bar code recognition method, device, equipment and storage medium
CN110222547B (en) Bar code identification method and device
CN109214486B (en) Three-dimensional code, three-dimensional code generation method and device, and three-dimensional code identification method and device
CN116739022B (en) Decoding method and device for bar code image and electronic equipment
CN113420580A (en) Method and device for positioning auxiliary locator for two-dimensional code, two-dimensional code scanning equipment and storage medium
CN100462997C (en) Information processing device and method, and program
CN109635613B (en) Two-dimensional code generation method, system and device for sphere surface
JP2007094584A (en) Method for detecting two dimensional code, detecting device, and detecting program
CN109214230B (en) Data matrix code identification method and device and electronic equipment
CN113496132A (en) Two-dimensional code identification method and device, electronic equipment and storage medium
US9530039B2 (en) Identifier eligibility
CN115860034B (en) Decoding method, decoding device, decoding chip and code scanning equipment
CN108875868A (en) Method for positioning mobile robot, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 201100 Shanghai city Minhang District Zixing Road No. 588 Building 2 room 2062

Applicant after: Shanghai Himalaya Technology Co., Ltd

Address before: 201100 Shanghai city Minhang District Zixing Road No. 588 Building 2 room 2062

Applicant before: SHANGHAI ZHENGDA HIMALAYAN NETWORK TECHNOLOGY CO., LTD.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant