One-dimensional barcode generation and recognition method, terminal device and storage medium

CN116127998BActive Publication Date: 2026-08-07SHANDONG AIKEDA BIOTECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG AIKEDA BIOTECHNOLOGY CO LTD
Filing Date
2023-03-06
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

因为常见的试管上并没有框出限定的贴标位置,同时试管上的一维条码标签的粘贴也会出现一些不规范性,所以贴在试管上的一维条码标签通常会出现各种方向的偏移,加上试管表面弧形对光线反射不均匀的影响,从而导致一些一维条码识别不出来的情况发生

Benefits of technology

[0033]本发明采用上述技术方案,具有的有益效果是,可以提高一维条码识别的准确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116127998B_ABST
    Figure CN116127998B_ABST
Patent Text Reader

Abstract

The application relates to a one-dimensional bar code generation and recognition method, a terminal device and a storage medium. The one-dimensional bar code generation method comprises the following steps: setting a basic width, recording a black bar with the basic width as B, recording a white bar with the basic width as W, and recording the 0 and 1 codes as BBBBBW and BWWW respectively; converting each information byte into 8-bit 0 and 1 codes, wherein the low bits are in the front; selecting a synchronization head byte and taking the synchronization head byte as the first byte of the one-dimensional bar code; selecting a check byte generation mode and taking the check byte as the last byte of the one-dimensional bar code; and generating the one-dimensional bar code, connecting the synchronization head byte, a plurality of information bytes and the check byte according to the 0 and 1 codes from left to right, adding a head white bar with the basic width on the left side of the synchronization head byte, and adding a tail black bar with the basic width on the right side of the check byte. The one-dimensional bar code recognition accuracy can be improved by adopting the method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of one-dimensional barcodes, and more specifically to a one-dimensional barcode generation and recognition method, terminal device, and storage medium. Background Technology

[0002] In the field of in vitro diagnostic instruments, test tubes are often labeled with one-dimensional barcodes along their length for information identification. One-dimensional barcodes have various encoding and decoding standards, such as Code 39 and Code 128. Traditional one-dimensional barcodes are primarily based on infrared barcode scanners. With the continuous development of information technology, image recognition can be used to identify QR codes. Because common test tubes do not have clearly defined label placement areas, and the application of one-dimensional barcode labels can be inconsistent, the labels often shift in various directions. Furthermore, the uneven light reflection caused by the curved surface of the test tube can lead to situations where some one-dimensional barcodes cannot be recognized. Summary of the Invention

[0003] The purpose of this invention is to provide a method for generating and recognizing one-dimensional barcodes to solve the above-mentioned problems.

[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0005] According to a first aspect of the present invention, a method for generating a one-dimensional barcode is provided, which may include:

[0006] Set a basic width, and denote the black bar of the basic width as B and the white bar of the basic width as W. Then the codes for 0 and 1 are: BBBW and BWWW, respectively.

[0007] Each information byte is converted into an 8-bit 0 and 1 code, with the least significant bit first;

[0008] Select the synchronization header byte and use it as the first byte of the one-dimensional barcode.

[0009] Select the method for generating the check byte and use the check byte as the last byte of the one-dimensional barcode;

[0010] Generate a one-dimensional barcode by connecting the synchronization header byte, several information bytes, and the check byte sequentially from left to right according to the encoding of 0 and 1. Add a white header bar of basic width to the left of the synchronization header byte and a black tail bar of basic width to the right of the check byte.

[0011] In a preferred embodiment, the synchronization header byte is not 0x00 or 0xFF.

[0012] In a preferred embodiment, the check byte is generated by a combination of cumulative checksum and CRC-8 checksum.

[0013] According to a second aspect of the present invention, a one-dimensional barcode recognition method is also provided, which may include:

[0014] Obtain a one-dimensional barcode image;

[0015] Starting from the beginning of the one-dimensional barcode, each time a transition from white to black is detected, a falling edge of a clock synchronization signal is generated, and the position of the corresponding pixel is recorded. The value of a white pixel is 1, and the value of a black pixel is 0.

[0016] Take the value of the middle pixel between the falling edges of two adjacent clock synchronization signals as the corresponding code value;

[0017] Each 8 code values ​​are combined into 1 byte. In a one-dimensional barcode, the white bar near the top is the low-order byte, and the black bar near the bottom is the high-order byte. If there are fewer than 8 bits at the end, the extra bits are discarded.

[0018] The orientation of a one-dimensional barcode is identified by synchronizing the header bytes.

[0019] The decoding of the preceding part is checked by verifying the check byte.

[0020] In a preferred embodiment, the acquisition of the one-dimensional barcode image is achieved through a camera, which includes a monochrome camera, a grayscale camera, and a color camera.

[0021] In a preferred embodiment, if a non-black-and-white camera is used, the one-dimensional barcode image needs to be converted to grayscale and then to binary.

[0022] In a preferred embodiment, if the number of pixels corresponding to the falling edges of two clock synchronization signals is odd, the value of the middle pixel is directly taken as the corresponding code value; if the number of pixels corresponding to the falling edges of two clock synchronization signals is even, the values ​​of the two middle pixels are ANDed as the corresponding code value.

[0023] In a preferred embodiment, if a portion of the one-dimensional barcode is located at the center of the one-dimensional barcode image, then each pixel sampling line is obtained by rotating around the center point of the one-dimensional barcode image. Each pixel sampling line searches for the existence of a synchronization header byte using a shift recognition decoding method. If a synchronization header byte is found, subsequent byte decoding is performed. Then, the validity of the previously obtained byte data is judged using the checksum of the last byte. If the checksum is valid, it is recorded. When multiple pixel sampling lines yield correctly verified decoding results, the decoding result of the pixel sampling line with the middle angle is taken as the recognition result.

[0024] In a preferred embodiment, if the one-dimensional barcode is not in the center of the one-dimensional barcode image, the one-dimensional barcode image is shifted left and right and / or up and down so that a portion of the one-dimensional barcode is located in the center of the one-dimensional barcode image.

[0025] In a preferred embodiment, the specific process of image translation is as follows:

[0026] From left to right of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, sum the values ​​of all pixels on each column pixel line and the N / 2 pixel lines on both sides, for a total of N+1 pixel lines, and then find the position X of the pixel line with the smallest result;

[0027] The image is translated according to the relative position of X and the center pixel of the image. If X is to the right of the center pixel of the image, the image is translated to the left, and the pixel value of the position moved to the right is filled by 1, and vice versa.

[0028] From the top to the bottom of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, add up the values ​​of all pixels on each horizontal pixel line and the N / 2 pixel lines on each side, for a total of N+1 pixel lines, and then find the position Y of the pixel line with the smallest result;

[0029] The image is translated according to the relative position of Y and the center pixel of the image. If Y is below the center pixel of the image, the image is translated upwards and the pixel value of the position moved below is filled by 1, and vice versa.

[0030] Where N is an even number.

[0031] According to a third aspect of the present invention, a terminal device is also provided, including a processor and a memory, the memory storing program instructions, wherein the processor executes the program instructions to implement the steps of the method described above.

[0032] According to a fourth aspect of the present invention, a computer-readable storage medium is also provided, characterized in that the computer-readable storage medium stores program instructions executable by a processor to implement the steps of the method described above.

[0033] The present invention adopts the above technical solution, which has the beneficial effect of improving the accuracy of one-dimensional barcode recognition. Attached Figure Description

[0034] Figure 1 This is a flowchart of the one-dimensional barcode generation method of the present invention;

[0035] Figure 2 This is a schematic diagram of the 0 and 1 encoding of the one-dimensional barcode of the present invention;

[0036] Figure 3This is a schematic diagram of a one-dimensional barcode obtained using the one-dimensional barcode generation method of the present invention;

[0037] Figure 4 This is a flowchart of the one-dimensional barcode recognition method of the present invention;

[0038] Figure 5 This is a schematic diagram illustrating the principle of the one-dimensional barcode recognition method of the present invention;

[0039] Figure 6 This is a schematic diagram of pixel sampling line division in the one-dimensional barcode recognition method of the present invention;

[0040] Figure 7 This is a schematic diagram of a one-dimensional barcode image that has not been translated.

[0041] Figure 8 yes Figure 7 The diagram shows a one-dimensional barcode image being translated left and right.

[0042] Figure 9 yes Figure 7 A schematic diagram of the one-dimensional barcode image after horizontal translation;

[0043] Figure 10 yes Figure 9 The diagram shows a one-dimensional barcode image being translated vertically.

[0044] Figure 11 yes Figure 9 The diagram shows a one-dimensional barcode image after being shifted vertically; and

[0045] Figure 12 This is a schematic diagram of a one-dimensional barcode image where the barcode plane is not perpendicular to the camera. Detailed Implementation

[0046] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings to provide a clearer understanding of the purpose, features, and advantages of the present invention. It should be understood that the embodiments shown in the drawings are not intended to limit the scope of the present invention, but are merely illustrative of the essential spirit of the technical solution of the present invention.

[0047] In the following description, certain specific details are set forth for the purpose of illustrating various disclosed embodiments in order to provide a thorough understanding of the various disclosed embodiments. However, those skilled in the art will recognize that embodiments may be practiced without one or more of these specific details. In other instances, well-known apparatuses, structures, and techniques associated with this application may not have been shown or described in detail to avoid unnecessarily obscuring the description of the embodiments.

[0048] Unless the context requires otherwise, throughout the specification and claims, the word “comprising” and its variations, such as “including” and “having”, shall be understood to have an open, inclusive meaning, that is, to be interpreted as “including, but not limited to”.

[0049] Throughout this specification, references to "an embodiment" or "an embodiment" indicate that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Therefore, the appearance of "in an embodiment" or "an embodiment" in various places throughout the specification does not necessarily refer to the same embodiment. Furthermore, a particular feature, structure, or characteristic may be combined in any manner in one or more embodiments.

[0050] The singular forms “a” and “the” used in this specification and the appended claims include plural references unless otherwise expressly stated herein. It should be noted that the term “or” is generally used to mean “and / or” unless otherwise expressly stated herein.

[0051] like Figure 1 and 2 As shown, the first embodiment of the present invention provides a QR code generation method, which includes the following steps:

[0052] S11. Set a basic width (e.g., 1 pixel). Label the black bar of the basic width as B and the white bar as W. Then the codes for 0 and 1 are: BBBW and BWWW, respectively. Figure 2 As shown;

[0053] S12. Convert each information byte into an 8-bit 0 and 1 code, with the least significant bit first;

[0054] S13. Select the synchronization header byte and use it as the first byte of the one-dimensional barcode. The synchronization header byte is not 0x00 or 0xFF, for example, it can be 0x55 or 0xAA. The synchronization byte is also converted into an 8-bit 0 and 1 code.

[0055] S14. Select the method for generating the check byte and use the check byte as the last byte of the one-dimensional barcode. The method for generating the check byte can be the sum of the previous bytes or CRC-8 check, etc. The check byte is also converted into an 8-bit 0 and 1 code.

[0056] S15. Generate a one-dimensional barcode. Concatenate the synchronization header byte, several information bytes, and the check byte from left to right according to the encoding of 0s and 1s. Add a basic-width white header bar to the left of the synchronization header byte and a basic-width black tail bar to the right of the check byte. Figure 3 As shown, the synchronization header byte is 0x55, the information byte is 0xAA, and the check byte is 0xAA.

[0057] Furthermore, the one-dimensional barcode generation method of the present invention also includes step S16: selecting the corresponding displayable character encoding method, and the software generates displayable characters on one side (e.g., the top or bottom side) of the image barcode according to the encoding method. For the displayable character encoding method, it is possible to customize the selection of 1 byte corresponding to ASCII encoding, two bytes corresponding to UCODE encoding, or three bytes corresponding to Chinese UTF-8 encoding, etc.

[0058] The above-mentioned one-dimensional barcode generation method can be implemented by software, and then the software outputs an image one-dimensional barcode for paper one-dimensional barcode printing.

[0059] A second embodiment of the present invention provides a terminal device, including a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to implement steps S11-S16 of the QR code generation method described in the first embodiment of the present invention.

[0060] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal.

[0061] A terminal can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. A terminal may include, but is not limited to, a processor and memory. For example, it may also include input / output devices, network access devices, and buses.

[0062] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, 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. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting various parts of the terminal device via various interfaces and lines.

[0063] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the terminal by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0064] A third embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions executable by a processor to implement steps S11-S16 of the QR code generation method described in the first embodiment of the present invention.

[0065] If the various modules / units of the terminal are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0066] The fourth embodiment of the present invention provides a one-dimensional barcode recognition method. For example... Figure 4As shown, this one-dimensional barcode recognition method may include:

[0067] S21. Obtain a one-dimensional barcode image. For example, the barcode image can be obtained by taking a picture of the barcode using a black-and-white camera, a grayscale camera, or a color camera. If a non-black-and-white camera is used, the image needs to be converted to grayscale and then to binary to obtain a black-and-white barcode image. The camera resolution can be selected according to the barcode printing precision (i.e., the width of the basic bar width). The narrower the basic bar width, the higher the required camera resolution.

[0068] S22. Starting from the beginning position of the one-dimensional barcode, each detected transition from white to black corresponds to a falling edge of a clock synchronization signal, and the position of the corresponding pixel is recorded. The value of a white pixel is 1, and the value of a black pixel is 0. For example... Figure 5 As shown.

[0069] S23. Take the value of the intermediate pixel between the falling edges of two adjacent clock synchronization signals as the corresponding code value, such as... Figure 5 As shown. If the number of pixels corresponding to the falling edges of the two clock synchronization signals is odd, the value of the middle pixel is directly taken as the corresponding code value. If the number of pixels corresponding to the falling edges of the two clock synchronization signals is even, the values ​​of the two middle pixels are ANDed as the corresponding code value.

[0070] S24. Combine every 8 code values ​​into 1 byte. In the one-dimensional barcode, the white bar near the head is the low-order byte, and the black bar near the tail is the high-order byte. If there are fewer than 8 bytes at the end, discard the extra bits.

[0071] S25. The direction of the one-dimensional barcode is identified by the synchronization header byte. If the byte closest to the white bar at the head is equal to the preset synchronization header byte, it means that the synchronization header byte has been identified.

[0072] S26. Verify the decoding of the preceding part using the check byte. If it is correct, output the recognition result; otherwise, output the recognition error message.

[0073] During recognition and detection, a portion of the one-dimensional barcode must be located in the center of the captured one-dimensional barcode image. Therefore, during image processing, sampling lines for each pixel are obtained by rotating the image around its center point. For example, 1 degree would result in 360 lines, and 2 degrees would result in 180 lines. Figure 6 As shown. Figure 6Only a portion of the pixel sampling lines are shown. Each pixel sampling line searches for the presence of a synchronization byte using a shift-based decoding method. Specifically, the shift-based decoding method scans from one side of the pixel sampling line to the other, assuming pixels at different positions as the starting pixels of the barcode for decoding to determine the presence of the synchronization byte. If a synchronization header byte is found, subsequent byte decoding is performed. Then, the checksum of the last byte is used to verify the validity of the previously obtained byte data; if the verification is valid, it is recorded. When multiple pixel sampling lines yield correctly verified decoding results, the decoding result of the pixel sampling line with the middle angle is taken as the recognition result, such as... Figure 6 As shown.

[0074] If the one-dimensional barcode is not centered in the one-dimensional barcode image, such as Figure 7 As shown, by shifting the one-dimensional barcode image horizontally and / or vertically, a portion of the one-dimensional barcode is positioned at the center of the one-dimensional barcode image, such as... Figure 11 As shown, one-dimensional barcode recognition can then be achieved using the detection methods described above. One method for image translation is as follows:

[0075] 1) From left to right of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, sum the values ​​of all pixels on each column's pixel line and the N / 2 pixel lines on either side, for a total of N+1 pixel lines. Then find the position X of the pixel line with the smallest result (this pixel line passes through the barcode), such as... Figure 8 As shown;

[0076] 2) Translate the image according to the relative position of X and the center pixel. If X is to the right of the center pixel, shift the image to the left, and fill the shifted pixel position with a value of 1 (white). Figure 9 As shown, the reverse is also true;

[0077] 3) From the top to the bottom of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, sum the values ​​of all pixels on each horizontal pixel line and the N / 2 pixel lines on each side, for a total of N+1 pixel lines. Then find the position Y of the pixel line with the smallest result (this pixel line passes through the barcode), such as... Figure 10 As shown;

[0078] 4) Translate the image according to the relative position of Y and the center pixel. If Y is below the center pixel, translate the image upwards, filling the shifted pixel position with a value of 1 (white). Figure 11 As shown, the reverse is also true.

[0079] exist Figure 8-11In the example, a 38×27 dot matrix area (excluding the boundary) is used. In actual applications, the dot matrix area is larger, and N=6. It should be understood that N can be other even numbers, such as 2, 4, 8, or 10. N can be a fixed empirical value based on the test results of actual scenarios, or N values ​​can be scanned within a certain range. A different N value is set each time for one-dimensional barcode shifting and recognition. When the recognized one-dimensional barcode data passes the verification, the N value adjustment stops and the recognition process is completed.

[0080] The one-dimensional barcode recognition method of this invention can still achieve correct decoding even when the one-dimensional barcode is pasted with an arc, including skewed pasting or small "bulges" in some areas, thereby improving the accuracy of one-dimensional barcode recognition. This is because the decoding position of each symbol is determined by the position of the "rising edge" between its two "falling edges," meaning the distance between the decoding positions of two adjacent symbols is variable and adaptive.

[0081] Typical variations that occur when the barcode plane and the camera are not perpendicular, such as... Figure 12 As shown, the code elements gradually widen to one side. In conventional one-dimensional barcode encoding and decoding, variations in the width of each code element within the barcode can lead to recognition errors. However, the barcode generation and recognition method of this invention can adaptively adjust the code element recognition position, thereby correctly recognizing one-dimensional barcodes generated using this invention's method. Therefore, this invention also provides a solution for correctly recognizing one-dimensional barcodes even when viewed from an angle. For some specialized devices with limited internal space, one-dimensional barcode recognition can be achieved by adjusting the camera's orientation.

[0082] The fifth embodiment of the present invention provides a terminal device, including a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to implement steps S21-S26 of the QR code recognition method described in the fourth embodiment of the present invention.

[0083] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal.

[0084] A terminal can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. A terminal may include, but is not limited to, a processor and memory. For example, it may also include input / output devices, network access devices, and buses.

[0085] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, 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. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting various parts of the terminal device via various interfaces and lines.

[0086] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the terminal by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0087] The sixth embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions executable by a processor to implement steps S21-S26 of the QR code recognition method described in the fourth embodiment of the present invention.

[0088] If the various modules / units of the terminal are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0089] The preferred embodiments of the present invention have been described in detail above. However, it should be understood that after reading the above teachings, those skilled in the art can make various alterations or modifications to the present invention. These equivalent forms also fall within the scope defined by the appended claims.

Claims

1. A method for generating and recognizing one-dimensional barcodes, characterized in that, It includes a generation process and a recognition process, wherein the generation process includes: Set a basic width, and denote the black bar of the basic width as B and the white bar of the basic width as W. Then the codes for 0 and 1 are: BBBW and BWWW, respectively. Each information byte is converted into an 8-bit 0 and 1 code, with the least significant bit first; Select the synchronization header byte and use it as the first byte of the one-dimensional barcode. Select the method for generating the check byte and use the check byte as the last byte of the one-dimensional barcode; Generate a one-dimensional barcode by connecting the synchronization header byte, several information bytes, and the check byte from left to right according to the encoding of 0 and 1. Add a white header bar of basic width to the left of the synchronization header byte and a black tail bar of basic width to the right of the check byte. The identification process includes: Obtain a one-dimensional barcode image; Starting from the beginning of the one-dimensional barcode, each time a transition from white to black is detected, a falling edge of a clock synchronization signal is generated, and the position of the corresponding pixel is recorded. The value of a white pixel is 1, and the value of a black pixel is 0. Take the value of the middle pixel between the falling edges of two adjacent clock synchronization signals as the corresponding code value; Each 8 code values ​​are combined into 1 byte. In a one-dimensional barcode, the white bar near the top is the low-order byte, and the black bar near the bottom is the high-order byte. If there are fewer than 8 bits at the end, the extra bits are discarded. The orientation of a one-dimensional barcode is identified by synchronizing the header bytes. The decoding of the preceding part is checked by verifying the byte order; In this process, if a portion of the one-dimensional barcode is located at the center of the one-dimensional barcode image, pixel sampling lines are obtained by rotating around the center point of the one-dimensional barcode image. Each pixel sampling line searches for the existence of a synchronization byte using a shift recognition decoding method. If a synchronization byte is found, subsequent byte decoding is performed. Then, the validity of the previously obtained byte data is judged using the checksum of the last byte. If the checksum is valid, it is recorded. When multiple pixel sampling lines yield correctly verified decoding results, the decoding result of the pixel sampling line with the middle angle is taken as the recognition result. If the one-dimensional barcode is not in the center of the one-dimensional barcode image, then the one-dimensional barcode image is shifted left and right and / or up and down so that a part of the one-dimensional barcode is in the center of the one-dimensional barcode image.

2. The one-dimensional barcode generation and recognition method according to claim 1, characterized in that, The synchronization header byte is either 0x00 or 0xFF.

3. The one-dimensional barcode generation and recognition method according to claim 1, characterized in that, The check byte can be generated through methods including cumulative checksum and CRC-8 check.

4. The one-dimensional barcode generation and recognition method according to claim 1, characterized in that, The acquisition of the one-dimensional barcode image is achieved through a camera, which includes a black-and-white camera, a grayscale camera, and a color camera.

5. The one-dimensional barcode generation and recognition method according to claim 4, characterized in that, If a non-black-and-white camera is used, the one-dimensional barcode image needs to be converted to grayscale and then to binary.

6. The one-dimensional barcode generation and recognition method according to claim 1, characterized in that, If the number of pixels between the falling edges of two clock synchronization signals is odd, the value of the middle pixel is directly taken as the corresponding code value. If the number of pixels between the falling edges of two clock synchronization signals is even, the values ​​of the two middle pixels are ANDed together as the corresponding code value.

7. The one-dimensional barcode generation and recognition method according to claim 1, characterized in that, The specific process of image translation is as follows: From left to right of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, sum the values ​​of all pixels on each column pixel line and the N / 2 pixel lines on both sides, for a total of N+1 pixel lines, and then find the position X of the pixel line with the smallest result; The image is translated according to the relative position of X and the center pixel of the image. If X is to the right of the center pixel of the image, the image is translated to the left, and the pixel value of the position moved to the right is filled by 1, and vice versa. From the top to the bottom of the image, excluding the leftmost N / 2 pixel lines and the rightmost N / 2 pixel lines, add up the values ​​of all pixels on each horizontal pixel line and the N / 2 pixel lines on each side, for a total of N+1 pixel lines, and then find the position Y of the pixel line with the smallest result; The image is translated according to the relative position of Y and the center pixel of the image. If Y is below the center pixel of the image, the image is translated upwards and the pixel value of the position moved below is filled by 1, and vice versa. Where N is an even number.

8. A terminal device, comprising a processor and a memory, wherein the memory stores program instructions, characterized in that, The processor executes the program instructions to implement the steps of the method as claimed in any one of claims 1-7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions executable by a processor to implement the steps of the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Encoding and decoding method of one-dimensional bar code

    CN112561014A