CN111797647B - Bar code decoding method and device - Google Patents

Bar code decoding method and device Download PDF

Info

Publication number
CN111797647B
CN111797647B CN202010652102.7A CN202010652102A CN111797647B CN 111797647 B CN111797647 B CN 111797647B CN 202010652102 A CN202010652102 A CN 202010652102A CN 111797647 B CN111797647 B CN 111797647B
Authority
CN
China
Prior art keywords
bar code
image
barcode
character sequence
target
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
CN202010652102.7A
Other languages
Chinese (zh)
Other versions
CN111797647A (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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information 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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010652102.7A priority Critical patent/CN111797647B/en
Publication of CN111797647A publication Critical patent/CN111797647A/en
Application granted granted Critical
Publication of CN111797647B publication Critical patent/CN111797647B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1456Methods for optical code recognition including a method step for retrieval of the optical code determining the orientation of the optical code with respect to the reader and correcting therefore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Character Input (AREA)

Abstract

The application discloses a bar code decoding method and a device, which relate to the technical field of information processing, and specifically comprise the following steps: obtaining a bar code image corresponding to a bar code, wherein the bar code comprises: the device comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code; determining the position information of the original bar code in the bar code image and the target bar code image corresponding to the position information based on the result of the first decoding operation on the front bar code and the rear bar code; and executing a second decoding operation on the target bar code image to determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode. The scheme solves the problem that the bar code is difficult to identify due to impulse noise, and improves the anti-interference capability of bar code identification.

Description

Bar code decoding method and device
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to the technical field of information processing, and particularly relates to a bar code decoding method and device.
Background
The application of bar codes is more and more widespread at present, the bar code is usually identified by a mobile phone, a camera is adopted for framing, a framing image is binarized and then scanned according to a line, and the number of continuous white or black pixels of the bar code record is matched according to the front-back sequence of the scanning result. When impulse noise exists in the bar code due to fuzzy printing, namely, when a certain white noise exists in each row of the bar code, the bar code is difficult to analyze and identify in a decoding mode of scanning according to the row.
Disclosure of Invention
The application provides a bar code decoding method, a device, equipment and a storage medium.
According to a first aspect of the present application, there is provided a barcode decoding method comprising: obtaining a bar code image corresponding to a bar code, wherein the bar code comprises: the device comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code; determining the position information of the original bar code in the bar code image and the target bar code image corresponding to the position information based on the result of the first decoding operation on the front bar code and the rear bar code; and executing a second decoding operation on the target bar code image to determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode.
In some embodiments, the barcode reference width of the front side barcode and/or the back side barcode is greater than the barcode reference width of the original barcode; the front side bar code and/or the rear side bar code are/is separated from the original bar code by a certain distance.
In some embodiments, determining the location information of the original barcode in the barcode image and the target barcode image corresponding to the location information based on the result of performing the first decoding operation on the front barcode and the back barcode includes: performing a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length; determining the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code; according to the slope of the bar code image and the following information of each row of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length; according to the following information of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: the second character sequence, the position coordinates of the ending point and the second length determine the position information of the original bar code in the bar code image; and determining a target bar code image corresponding to the position information according to the position information.
In some embodiments, before performing the first decoding operation on the front-side bar code and the back-side bar code using the line scanning method, further comprising: and carrying out binarization processing on the front side bar code image and/or the rear side bar code image to obtain the front side bar code image and/or the rear side bar code image after the binarization processing.
In some embodiments, the method further comprises: and correcting the bar code image based on the slope of the bar code image to obtain a corrected bar code image.
In some embodiments, performing a second decoding operation on the target barcode image to determine a string corresponding to the target barcode image includes: performing binarization processing on the target bar code image to obtain a binarization image corresponding to the target bar code image; projecting the binarized image; the projection result is identified, and a character sequence corresponding to the binary image is generated, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of a bar code in the binary image; and matching the character sequences according to the coding rule, and determining the character strings corresponding to the target bar code images.
In some embodiments, the identifying the projection result to generate a character sequence corresponding to the binary image includes: recognizing the projection result by using a line scanning method, and generating character sequences of each line corresponding to the projection result; and carrying out statistical analysis on the character sequences of each row to generate a character sequence corresponding to the binarized image.
In some embodiments, after identifying the projection result and generating the character sequence corresponding to the binary image, the method further includes: and selecting the character sequence corresponding to the binarized image to generate a selected character sequence.
In some embodiments, the method further comprises: based on the length of the bar code image, checking the character string corresponding to the target bar code image; and determining a final character string corresponding to the target bar code image in response to the verification.
According to a second aspect of the present application, there is provided a bar code decoding apparatus, the apparatus comprising: an acquisition unit configured to acquire a barcode image corresponding to a barcode, wherein the barcode includes: the device comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code; a first decoding unit configured to determine position information of an original barcode in the barcode image and a target barcode image corresponding to the position information based on a result of performing a first decoding operation on the front barcode and the rear barcode; and the second decoding unit is configured to execute a second decoding operation on the target bar code image and determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode.
In some embodiments, the barcode reference width of the front side barcode and/or the back side barcode in the acquisition unit is greater than the barcode reference width of the original barcode; the front side bar code and/or the rear side bar code in the acquisition unit are/is separated from the original bar code by a certain distance.
In some embodiments, the first decoding unit comprises: the first decoding module is configured to execute a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method, so as to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length; the slope determining module is configured to determine the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code; the statistics module is configured to be according to the slope of the bar code image and the following information of each row of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length; a position determination module configured to determine the following information from the front side barcode: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: the second character sequence, the position coordinates of the ending point and the second length determine the position information of the original bar code in the bar code image; and the image determining module is configured to determine a target bar code image corresponding to the position information according to the position information.
In some embodiments, the first decoding unit further comprises: and the first processing module is used for carrying out binarization processing on the front side bar code image and/or the rear side bar code image to obtain the front side bar code image and/or the rear side bar code image after the binarization processing.
In some embodiments, the apparatus further comprises: and the correction unit is configured to correct the bar code image based on the slope of the bar code image to obtain a corrected bar code image.
In some embodiments, the second decoding unit comprises: the second processing module is configured to perform binarization processing on the target bar code image to obtain a binarized image corresponding to the target bar code image; a projection module configured to project a binarized image; the second decoding module is configured to recognize the projection result and generate a character sequence corresponding to the binary image, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of the bar code in the binary image; and the matching module is configured to match the character sequences according to the coding rule and determine the character strings corresponding to the target bar code images.
In some embodiments, the second decoding module is further configured to identify the projection result using a line scan method, generating a character sequence for each line corresponding to the projection result; and carrying out statistical analysis on the character sequences of each row to generate a character sequence corresponding to the binarized image.
In some embodiments, the second decoding unit further comprises: the selecting module is configured to select a character sequence corresponding to the binary image and generate a selected character sequence.
In some embodiments, the apparatus further comprises: the verification unit is configured to verify the character string corresponding to the target bar code image based on the length of the bar code image; and determining a final character string corresponding to the target bar code image in response to the verification.
According to a third aspect of the present application, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as described in any one of the implementations of the first aspect.
According to a fourth aspect of the present application there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to perform a method as described in any of the implementations of the first aspect.
The technology according to the application adopts the method of acquiring the bar code image corresponding to the bar code, wherein the bar code comprises the following steps: the method comprises the steps of determining the position information of an original bar code in a bar code image and a target bar code image corresponding to the position information based on the result of performing a first decoding operation on the front bar code and the rear bar code, performing a second decoding operation on the target bar code image, determining a character string corresponding to the target bar code image, and adding the front bar code and the rear bar code which are independently coded to determine the position information and the image of the original bar code based on the original bar code in order to identify the impulse noise bar code.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the application or to delineate the scope of the application. Other features of the present application will become apparent from the description that follows.
Drawings
The drawings are included to provide a better understanding of the present application and are not to be construed as limiting the application.
FIG. 1 is a schematic diagram of a first embodiment of a bar code decoding method according to the present application;
FIG. 2 is a scene diagram of a bar code decoding method in which embodiments of the present application may be implemented;
FIG. 3 is a schematic diagram of a second embodiment of a bar code decoding method according to the present application;
FIG. 4 is a schematic diagram of the architecture of one embodiment of a bar code decoding device according to the present application;
fig. 5 is a block diagram of an electronic device for implementing the bar code decoding method of the embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present application are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other. The application will be described in detail below with reference to the drawings in connection with embodiments.
Fig. 1 shows a schematic diagram 100 of a first embodiment of a barcode decoding method according to the present application. The bar code decoding method comprises the following steps:
step 101, obtaining a bar code image corresponding to the bar code.
In this embodiment, the execution body may obtain the barcode image corresponding to the barcode from other electronic devices or locally through a wired connection manner or a wireless connection manner, and the barcode may be obtained through scanning by various electronic devices. Wherein, the bar code includes: the system comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code. It should be noted that the wireless connection may include, but is not limited to, 3G, 4G, 5G, wiFi, bluetooth, wiMAX, zigbee, UWB (ultra wideband), and other now known or later developed wireless connection.
Step 102, determining the position information of the original bar code in the bar code image and the target bar code image corresponding to the position information based on the result of the first decoding operation on the front bar code and the rear bar code.
In this embodiment, the execution subject may determine the position information of the original barcode in the barcode image and the target barcode image corresponding to the position information based on the result of the first decoding operation performed on the front barcode in the barcode image and the rear barcode in the barcode image.
And step 103, executing a second decoding operation on the target bar code image, and determining the character string corresponding to the target bar code image.
In this embodiment, the execution body may perform the second decoding operation on the target barcode image, and determine the character string corresponding to the target barcode image. The second decoding operation decodes the bar codes in the target bar code image based on a single-line scanning mode.
With continued reference to fig. 2, the barcode decoding method 200 of the present embodiment operates in an electronic device 201. The electronic device 201 firstly acquires a bar code image 202 corresponding to a bar code, then the electronic device 201 determines the position information of the original bar code in the bar code image and a target bar code image 203 corresponding to the position information based on the result of performing a first decoding operation on a front bar code in the bar code image and a rear bar code in the bar code image, and finally the electronic device 201 performs a second decoding operation on the target bar code image to determine a character string 204 corresponding to the target bar code image.
The barcode decoding method provided by the embodiment of the application adopts the method for acquiring the barcode image corresponding to the barcode, wherein the barcode comprises the following steps: the method comprises the steps of determining the position information of an original bar code in a bar code image and a target bar code image corresponding to the position information based on the result of performing a first decoding operation on the front bar code and the rear bar code, performing a second decoding operation on the target bar code image, determining a character string corresponding to the target bar code image, and adding the front bar code and the rear bar code which are independently coded to determine the position information and the image of the original bar code based on the original bar code in order to identify the impulse noise bar code.
With further reference to fig. 3, a schematic diagram 300 of a second embodiment of a barcode decoding method is shown. The flow of the method comprises the following steps:
step 301, obtaining a bar code image corresponding to the bar code.
In this embodiment, the execution body may obtain, from other electronic devices or locally, a barcode image corresponding to a barcode in a wired connection manner or a wireless connection manner, where the barcode includes: the system comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code.
In some alternative implementations of this embodiment, the barcode reference width of the front side barcode and/or the back side barcode is greater than the barcode reference width of the original barcode; the front side bar code and/or the rear side bar code are/is separated from the original bar code by a certain distance. The front side bar code and the rear side bar code adopt different coding specifications from the original bar code, so that the anti-interference capability of the bar code is improved, the bar code identification is easier and simpler, and the accuracy and the efficiency of the bar code identification are improved; the bar codes can be compatible with various types of original bar codes by a certain distance from the original bar codes, so that the application range is wider.
Step 302, performing a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method, to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length.
In this embodiment, the execution body may perform the first decoding operation on the front side barcode and the rear side barcode by using the line scanning method, to obtain a first character sequence of each line of the front side barcode, a position coordinate of a start point of each line of the front side barcode, a first length of each line of the front side barcode, a second character sequence of each line of the rear side barcode, a position coordinate of an end point of each line of the rear side barcode, and a second length of each line of the rear side barcode.
In some optional implementations of the present embodiments, before performing the first decoding operation on the front-side barcode and the back-side barcode using the line scanning method, the method may further include: and carrying out binarization processing on the front side bar code image and/or the rear side bar code image to obtain the front side bar code image and/or the rear side bar code image after the binarization processing. The gray level judgment is carried out on the front side bar code image and the rear side bar code image, namely, the judgment of black pixel points or white pixel points, so that the possibility of white noise interference in the front side bar code and the rear side bar code is avoided, and the accuracy rate of bar code identification is further improved.
Step 303, determining the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code.
In this embodiment, the execution body may perform linear regression on the position coordinates of the start point of each row of the front barcode and the position coordinates of the end point of each row of the rear barcode, and determine the slope of the barcode image based on the comparison of the two linear regression results.
In some optional implementations of the present embodiment, the method further includes: and correcting the bar code image based on the slope of the bar code image to obtain a corrected bar code image. The slope of the image is utilized to correct the image, so that the problem of bar code inclination is solved, the error of subsequent projection is reduced, and the accuracy of image decoding is improved.
Step 304, according to the slope of the bar code image and the following information of each row of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length.
In this embodiment, the execution body may select, according to the first character sequence of each row of the front barcode, the start point position coordinate of each row of the front barcode, the first length of each row of the front barcode, and the slope of the barcode image, by adopting a grouping statistical sorting manner, a result with the largest number of parameters in the statistical result, so as to determine the first character sequence of the front barcode, the start point position coordinate of the front barcode, and the first length of the front barcode, and simultaneously select, according to the second character sequence of each row of the rear barcode, the end point position coordinate of each row of the rear barcode, the second length of each row of the rear barcode, and the slope of the barcode image, by adopting a grouping statistical sorting manner, a result with the largest number of parameters in the statistical result, so as to determine the second character sequence of the rear barcode, the end point position coordinate of the rear barcode, and the second length of the rear barcode. Based on analysis and analysis of each row, the result with the same number and the maximum number of each column after sequencing is selected as the final result of the column, so that the problem that recognition errors possibly exist in the result is avoided, and the decoding accuracy is improved.
Step 305, based on the following information of the front side barcode: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: and determining the position information of the original bar code in the bar code image by the second character sequence, the position coordinates of the ending point and the second length.
In this embodiment, the execution body may obtain the position information of the original barcode in the barcode image by performing data statistics and operation according to the first character sequence of the front barcode, the position coordinate of the start point of the front barcode, the first length of the front barcode, the second character sequence of the rear barcode, the position coordinate of the end point of the rear barcode, and the second length of the rear barcode. The position information is represented by the coordinates of the corners of the original bar code.
Step 306, determining the target bar code image corresponding to the position information according to the position information.
In this embodiment, the execution subject may determine the target barcode image based on the above-obtained positional information.
Step 307, a second decoding operation is performed on the target barcode image, and a character string corresponding to the target barcode image is determined.
In some optional implementations of this embodiment, performing a second decoding operation on the target barcode image to determine a string corresponding to the target barcode image includes: performing binarization processing on the target bar code image to obtain a binarization image corresponding to the target bar code image; projecting the binarized image; the projection result is identified, and a character sequence corresponding to the binary image is generated, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of a bar code in the binary image; and matching the character sequences according to the coding rule, and determining the character strings corresponding to the target bar code images. The code specification may be the same as the original barcode code specification, such as code128 code, code39 code, and code93 code. By judging the gray level of the bar code, namely judging the black pixel point or the white pixel point, the white noise interference in the bar code is avoided, the anti-interference capability of bar code identification is improved, and the accuracy of bar code identification is improved.
For example, each row of white pixels is denoted as ', black pixels as ' X ', each row may be denoted (xxxx. XX..xxxx). XXXX. After projection and all rows were counted, it was expressed as (black: 10,9,9,10, white 9, black 9, white 10,10,10, black 10, &. White 10,10 black 10,10,9,9,10,10, white 10, black 10, white 10, black 9,9,9,9), the original code128 is matched with the sequence, and a character string (such as JDLD 1000235435) corresponding to the target bar code image is identified.
In some optional implementations of this embodiment, identifying the projection result to generate a character sequence corresponding to the binarized image includes: recognizing the projection result by using a line scanning method, and generating character sequences of each line corresponding to the projection result; and carrying out statistical analysis on the character sequences of each row to generate a character sequence corresponding to the binarized image. The recognition process is refined, and the recognition accuracy is improved.
In some optional implementations of this embodiment, after identifying the projection result and generating the character sequence corresponding to the binarized image, the method further includes: and selecting the character sequence corresponding to the binarized image to generate a selected character sequence. By selecting the character sequences of all the rows, the decoding process is simplified, and the decoding efficiency is improved.
Step 308, verifying the character string corresponding to the target bar code image based on the length of the bar code image; and determining a final character string corresponding to the target bar code image in response to the verification.
In this embodiment, the execution body may verify the character string corresponding to the target barcode image based on the determined length of the barcode image, and when the execution body receives the instruction of passing the verification, determine the character string corresponding to the target barcode image obtained after the verification as the final character string corresponding to the target barcode image. The length of the barcode image may be determined according to the first character sequence of the front barcode and the second character sequence of the rear barcode, for example: the character sequences are defined in advance, and according to the first character sequence (expressed as 1) and the second character sequence (expressed as 8), the length of the bar code image is calculated to be 1×10+8=18.
In this embodiment, the specific operation of step 307 is substantially the same as that of step 103 in the embodiment shown in fig. 1, and will not be described here again.
As can be seen from fig. 3, compared with the embodiment corresponding to fig. 1, the schematic diagram 300 of the barcode decoding method in this embodiment performs the first decoding operation on the front barcode and the rear barcode by using the line scanning method, determines the slope of the barcode image based on the result of performing linear regression on the start point position coordinates of each line of the front barcode and/or the result of performing linear regression on the end point position coordinates of each line of the rear barcode, further determines the position information of the original barcode in the barcode image and the target barcode image corresponding to the position information, verifies the character string corresponding to the target barcode image based on the length of the barcode image, determines the final character string corresponding to the target barcode image in response to the verification passing, thereby implementing a barcode decoding method, and further improving the accuracy of the image recognition degree by using the length of the barcode image to verify the character sequence of the target barcode image.
With further reference to fig. 4, as an implementation of the method shown in the foregoing figures, the present application provides an embodiment of a barcode decoding apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 1, and the apparatus is particularly applicable to various electronic devices.
As shown in fig. 4, the barcode decoding apparatus 400 of the present embodiment includes: an acquisition unit 401, a first decoding unit 402, and a second decoding unit 403, where the acquisition unit is configured to acquire a barcode image corresponding to a barcode, where the barcode includes: the device comprises an original bar code, a front bar code positioned at the front end of the original bar code and a rear bar code positioned at the rear end of the original bar code; a first decoding unit configured to determine position information of an original barcode in the barcode image and a target barcode image corresponding to the position information based on a result of performing a first decoding operation on the front barcode and the rear barcode; and the second decoding unit is configured to execute a second decoding operation on the target bar code image and determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode.
In this embodiment, the specific processes of the acquiring unit 401, the first decoding unit 402 and the second decoding unit 403 of the barcode decoding apparatus 400 and the technical effects thereof may refer to the relevant descriptions of the steps 101 to 103 in the corresponding embodiment of fig. 1, and are not repeated here.
In some optional implementations of this embodiment, the barcode reference width of the front side barcode and/or the back side barcode in the acquisition unit is greater than the barcode reference width of the original barcode; the front side bar code and/or the rear side bar code in the acquisition unit are/is separated from the original bar code by a certain distance.
In some optional implementations of the present embodiment, the first decoding unit includes: the first decoding module is configured to execute a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method, so as to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length; the slope determining module is configured to determine the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code; the statistics module is configured to be according to the slope of the bar code image and the following information of each row of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length; a position determination module configured to determine the following information from the front side barcode: the first character sequence, the starting point position coordinates, the first length and the following information of the rear bar code: the second character sequence, the position coordinates of the ending point and the second length determine the position information of the original bar code in the bar code image; and the image determining module is configured to determine a target bar code image corresponding to the position information according to the position information.
In some optional implementations of this embodiment, the first decoding unit further includes: and the first processing module is used for carrying out binarization processing on the front side bar code image and/or the rear side bar code image to obtain the front side bar code image and/or the rear side bar code image after the binarization processing.
In some optional implementations of this embodiment, the apparatus further includes: and the correction unit is configured to correct the bar code image based on the slope of the bar code image to obtain a corrected bar code image.
In some optional implementations of the present embodiment, the second decoding unit includes: the second processing module is configured to perform binarization processing on the target bar code image to obtain a binarized image corresponding to the target bar code image; a projection module configured to project a binarized image; the second decoding module is configured to recognize the projection result and generate a character sequence corresponding to the binary image, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of the bar code in the binary image; and the matching module is configured to match the character sequences according to the coding rule and determine the character strings corresponding to the target bar code images.
In some optional implementations of this embodiment, the second decoding module is further configured to identify the projection result using a line scanning method, and generate a character sequence for each line corresponding to the projection result; and carrying out statistical analysis on the character sequences of each row to generate a character sequence corresponding to the binarized image.
In some optional implementations of this embodiment, the second decoding unit further includes: the selecting module is configured to select a character sequence corresponding to the binary image and generate a selected character sequence.
In some optional implementations of this embodiment, the apparatus further includes: the verification unit is configured to verify the character string corresponding to the target bar code image based on the length of the bar code image; and determining a final character string corresponding to the target bar code image in response to the verification.
According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
As shown in fig. 5, there is a block diagram of an electronic device of a bar code decoding method according to an embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein.
As shown in fig. 5, the electronic device includes: one or more processors 501, memory 502, and interfaces for connecting components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 501 is illustrated in fig. 5.
Memory 502 is a non-transitory computer readable storage medium provided by the present application. The memory stores instructions executable by the at least one processor to cause the at least one processor to perform the barcode decoding method provided by the present application. The non-transitory computer readable storage medium of the present application stores computer instructions for causing a computer to execute the barcode decoding method provided by the present application.
The memory 502 is used as a non-transitory computer readable storage medium for storing a non-transitory software program, a non-transitory computer executable program, and modules, such as program instructions/modules (e.g., the acquisition unit 401, the first decoding unit 402, and the second decoding unit 403 shown in fig. 4) corresponding to the barcode decoding method in the embodiment of the present application. The processor 501 executes various functional applications of the server and data processing by running non-transitory software programs, instructions, and modules stored in the memory 502, that is, implements the barcode decoding method in the above-described method embodiment.
Memory 502 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to the use of the barcode decoding electronic device, and the like. In addition, memory 502 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 502 optionally includes memory remotely located relative to processor 501, which may be connected to the barcode decoding electronics via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the barcode decoding method may further include: an input device 503 and an output device 504. The processor 501, memory 502, input devices 503 and output devices 504 may be connected by a bus or otherwise, for example in fig. 5.
The input device 503 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the barcode decoding electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, trackball, joystick, and the like. The output devices 504 may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASIC (application specific integrated circuit), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computing programs (also referred to as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-side component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-side components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme of the embodiment of the application, the bar code image corresponding to the bar code is acquired, wherein the bar code comprises: the method comprises the steps of determining the position information of an original bar code in a bar code image and a target bar code image corresponding to the position information based on the result of performing a first decoding operation on the front bar code and the rear bar code, performing a second decoding operation on the target bar code image, determining a character string corresponding to the target bar code image, and adding the front bar code and the rear bar code which are independently coded to determine the position information and the image of the original bar code based on the original bar code in order to identify the impulse noise bar code. Meanwhile, a first decoding operation is carried out on the front side bar code and the rear side bar code by using a line scanning method, the slope of a bar code image is determined based on the result of linear regression on the position coordinates of the starting points of the front side bar code lines and/or the result of linear regression on the position coordinates of the ending points of the rear side bar code lines, the position information of the original bar code in the bar code image and the target bar code image corresponding to the position information are further determined, the character string corresponding to the target bar code image is verified based on the length of the bar code image, the final character string corresponding to the target bar code image is determined in response to the verification passing, the bar code decoding method is realized, the character sequence of the target bar code image is verified by using the length of the bar code image, and the accuracy of the image recognition degree is further improved.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present application may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution disclosed in the present application can be achieved, and are not limited herein.
The above embodiments do not limit the scope of the present application. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the scope of the present application.

Claims (12)

1. A method of bar code decoding, the method comprising:
obtaining a bar code image corresponding to a bar code, wherein the bar code comprises: the device comprises a raw bar code, a front bar code positioned at the front end of the raw bar code and a rear bar code positioned at the rear end of the raw bar code;
determining, based on a result of performing a first decoding operation on the front side barcode and the rear side barcode, position information of an original barcode in the barcode image and a target barcode image corresponding to the position information, including: performing a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length; determining the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code; according to the slope of the bar code image and the following information of each row of the front bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: a first character sequence, a starting point position coordinate, a first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length; according to the following information of the front side bar code: a first character sequence, a starting point position coordinate, a first length and the following information of the rear bar code: determining the position information of the original bar code in the bar code image by a second character sequence, the position coordinates of the ending point and a second length; determining a target bar code image corresponding to the position information according to the position information;
And executing a second decoding operation on the target bar code image to determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode.
2. The method of claim 1, wherein the barcode reference width of the front side barcode and/or the back side barcode is greater than the barcode reference width of the original barcode; and a certain distance is reserved between the front side bar code and/or the rear side bar code and the original bar code.
3. The method of claim 1, wherein prior to performing a first decoding operation on the front side bar code and the back side bar code using a line scan method, further comprising:
and carrying out binarization processing on the front side bar code image and/or the rear side bar code image to obtain the front side bar code image and/or the rear side bar code image after the binarization processing.
4. The method of claim 1, further comprising:
and correcting the bar code image based on the slope of the bar code image to obtain a corrected bar code image.
5. The method of claim 1, wherein the performing a second decoding operation on the target barcode image to determine a string corresponding to the target barcode image comprises:
Performing binarization processing on the target bar code image to obtain a binarization image corresponding to the target bar code image;
projecting the binarized image; identifying the projection result to generate a character sequence corresponding to the binary image, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of a bar code in the binary image;
and matching the character sequences according to coding rules, and determining the character strings corresponding to the target bar code images.
6. The method of claim 5, wherein the identifying the projection result to generate the character sequence corresponding to the binary image includes:
identifying the projection result by using a line scanning method, and generating a character sequence of each line corresponding to the projection result;
and carrying out statistical analysis on the character sequences of each row to generate a character sequence corresponding to the binarized image.
7. The method of claim 5, wherein, after identifying the projection result and generating the character sequence corresponding to the binarized image, further comprising:
and selecting the character sequence corresponding to the binarized image, and generating the selected character sequence.
8. The method of claim 1, further comprising:
based on the length of the bar code image, checking the character string corresponding to the target bar code image;
and determining a final character string corresponding to the target bar code image in response to the verification.
9. A bar code decoding device, the device comprising:
an acquisition unit configured to acquire a barcode image corresponding to a barcode, wherein the barcode includes: the device comprises a raw bar code, a front bar code positioned at the front end of the raw bar code and a rear bar code positioned at the rear end of the raw bar code;
a first decoding unit configured to determine position information of an original barcode in the barcode image and a target barcode image corresponding to the position information based on a result of performing a first decoding operation on the front barcode and the rear barcode;
the second decoding unit is configured to execute a second decoding operation on the target bar code image and determine a character string corresponding to the target bar code image, wherein the second decoding operation decodes the bar code in the target bar code image based on a single-line scanning mode;
the first decoding unit includes: the first decoding module is configured to execute a first decoding operation on the front side bar code and the rear side bar code by using a line scanning method to obtain the following information of each line of the front side bar code: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: a second character sequence, end point position coordinates, a second length; the slope determining module is configured to determine the slope of the bar code image according to the starting point position coordinates of each row of the front bar code and/or the ending point position coordinates of each row of the rear bar code; a statistics module configured to, based on the slope of the barcode image, the following information for each row of the front side barcode: the first character sequence, the starting point position coordinates, the first length and the following information of each row of the rear bar code: the second character sequence, the end point position coordinates and the second length determine the following information of the front bar code: a first character sequence, a starting point position coordinate, a first length and the following information of the rear bar code: a second character sequence, end point position coordinates, a second length; a position determination module configured to determine the following information for the front side barcode: a first character sequence, a starting point position coordinate, a first length and the following information of the rear bar code: determining the position information of the original bar code in the bar code image by a second character sequence, the position coordinates of the ending point and a second length; and the image determining module is configured to determine a target bar code image corresponding to the position information according to the position information.
10. The apparatus of claim 9, wherein the second decoding unit comprises:
the processing module is configured to perform binarization processing on the target bar code image to obtain a binarized image corresponding to the target bar code image;
a projection module configured to project the binarized image;
the second decoding module is configured to recognize the projection result and generate a character sequence corresponding to the binarized image, wherein the character sequence is used for representing the distribution condition of black pixels and white pixels of a bar code in the binarized image;
and the matching module is configured to match the character sequences according to the coding rule and determine the character strings corresponding to the target bar code image.
11. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
12. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-8.
CN202010652102.7A 2020-07-08 2020-07-08 Bar code decoding method and device Active CN111797647B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010652102.7A CN111797647B (en) 2020-07-08 2020-07-08 Bar code decoding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010652102.7A CN111797647B (en) 2020-07-08 2020-07-08 Bar code decoding method and device

Publications (2)

Publication Number Publication Date
CN111797647A CN111797647A (en) 2020-10-20
CN111797647B true CN111797647B (en) 2023-11-03

Family

ID=72810438

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010652102.7A Active CN111797647B (en) 2020-07-08 2020-07-08 Bar code decoding method and device

Country Status (1)

Country Link
CN (1) CN111797647B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112260872B (en) * 2020-10-22 2022-03-04 北京理工大学 Identification heterogeneous recognition method and system based on character string matching
CN117574930B (en) * 2024-01-15 2024-04-12 北京航空航天大学杭州创新研究院 Method and device for generating three-dimensional bar code information, electronic equipment and readable medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677872A (en) * 2004-03-30 2005-10-05 深圳市朗科科技有限公司 Bar-code decoding method
CN101833645A (en) * 2010-06-01 2010-09-15 福建新大陆电脑股份有限公司 Bar code decoding method based on code word combination
CN101882210A (en) * 2010-06-01 2010-11-10 福建新大陆电脑股份有限公司 Matrix two-dimensional barcode decoding chip and decoding method thereof
CN107016317A (en) * 2017-03-02 2017-08-04 浙江华睿科技有限公司 A kind of bar code decoding method and device
CN108763998A (en) * 2018-04-17 2018-11-06 维沃移动通信有限公司 Barcode recognition method and terminal device
CN110659529A (en) * 2019-09-03 2020-01-07 珠海市杰理科技股份有限公司 Bar code identification method and device, computer equipment and storage medium
CN111144161A (en) * 2020-04-03 2020-05-12 支付宝(杭州)信息技术有限公司 Barcode identification method and device, commodity information determination method and payment method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009157817A (en) * 2007-12-27 2009-07-16 Toshiba Corp Bar code processing apparatus, sorting apparatus and bar code processing method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677872A (en) * 2004-03-30 2005-10-05 深圳市朗科科技有限公司 Bar-code decoding method
CN101833645A (en) * 2010-06-01 2010-09-15 福建新大陆电脑股份有限公司 Bar code decoding method based on code word combination
CN101882210A (en) * 2010-06-01 2010-11-10 福建新大陆电脑股份有限公司 Matrix two-dimensional barcode decoding chip and decoding method thereof
CN107016317A (en) * 2017-03-02 2017-08-04 浙江华睿科技有限公司 A kind of bar code decoding method and device
CN108763998A (en) * 2018-04-17 2018-11-06 维沃移动通信有限公司 Barcode recognition method and terminal device
CN110659529A (en) * 2019-09-03 2020-01-07 珠海市杰理科技股份有限公司 Bar code identification method and device, computer equipment and storage medium
CN111144161A (en) * 2020-04-03 2020-05-12 支付宝(杭州)信息技术有限公司 Barcode identification method and device, commodity information determination method and payment method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于快速面阵相机与图像处理的条码识别算法;刘勇;;廊坊师范学院学报(自然科学版)(01);全文 *
复杂背景下二维条码检测技术;崔冲;刘志;梁荣华;;浙江工业大学学报(05);全文 *

Also Published As

Publication number Publication date
CN111797647A (en) 2020-10-20

Similar Documents

Publication Publication Date Title
CN111784663B (en) Method and device for detecting parts, electronic equipment and storage medium
CN111797647B (en) Bar code decoding method and device
CN112149634B (en) Training method, device, equipment and storage medium for image generator
CN111462174B (en) Multi-target tracking method and device and electronic equipment
CN111310507B (en) Identification method, device and equipment for identification code
US11557062B2 (en) Method and apparatus for processing video frame
CN111832396B (en) Method and device for analyzing document layout, electronic equipment and storage medium
US11995905B2 (en) Object recognition method and apparatus, and electronic device and storage medium
US20210334985A1 (en) Method and apparatus for tracking target
US10509934B1 (en) Methods and apparatus for improving QR code locator detectability and/or finding the corners of a locator pattern
CN113778403A (en) Front-end code generation method and device
CN111709428B (en) Method and device for identifying positions of key points in image, electronic equipment and medium
CN111488821A (en) Method and device for identifying traffic signal lamp countdown information
CN111191619B (en) Method, device and equipment for detecting virtual line segment of lane line and readable storage medium
CN113657398B (en) Image recognition method and device
WO2022007495A1 (en) Method and terminal for identifying barcode
CN111523292B (en) Method and device for acquiring image information
US10810417B2 (en) Method, module and system of gesture recognition
CN112150380B (en) Method, apparatus, electronic device, and readable storage medium for correcting image
CN111767859A (en) Image correction method and device, electronic equipment and computer-readable storage medium
CN111680628B (en) Text frame fusion method, device, equipment and storage medium
CN111858303B (en) Page control method, device, equipment and medium for applet
CN111507944B (en) Determination method and device for skin smoothness and electronic equipment
CN113298211B (en) Bar code generation and bar code identification method and device
CN113160044B (en) Depth image super-resolution method, training method and device, equipment and medium

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
GR01 Patent grant
GR01 Patent grant