CN116306731A - Method and device for identifying bar codes, electronic equipment and storage medium - Google Patents

Method and device for identifying bar codes, electronic equipment and storage medium Download PDF

Info

Publication number
CN116306731A
CN116306731A CN202310149642.7A CN202310149642A CN116306731A CN 116306731 A CN116306731 A CN 116306731A CN 202310149642 A CN202310149642 A CN 202310149642A CN 116306731 A CN116306731 A CN 116306731A
Authority
CN
China
Prior art keywords
pixel
bar
width
bar code
categories
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.)
Pending
Application number
CN202310149642.7A
Other languages
Chinese (zh)
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.)
Shenzhen Jiuniuyimao Intelligent Internet Of Things Technology Co ltd
Original Assignee
Shenzhen Jiuniuyimao Intelligent Internet Of Things 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 Shenzhen Jiuniuyimao Intelligent Internet Of Things Technology Co ltd filed Critical Shenzhen Jiuniuyimao Intelligent Internet Of Things Technology Co ltd
Priority to CN202310149642.7A priority Critical patent/CN116306731A/en
Publication of CN116306731A publication Critical patent/CN116306731A/en
Pending legal-status Critical Current

Links

Images

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
    • G06K7/14131D bar codes

Abstract

The embodiment of the application provides a method, a device, electronic equipment and a storage medium for identifying a bar code, which relate to the technical field of bar code identification, and the scheme comprises the following steps: and acquiring the bar code to be identified. And classifying the pixel points in the bar code to be identified to obtain a plurality of classified bar categories and a plurality of blank categories. And determining a target width stream of the bar code to be identified according to the bar categories and the empty categories, wherein the target width stream is formed by alternately arranging the bar categories and the empty categories in turn, and the pixel values of the pixels belonging to the same category in the target width stream are the same. And decoding the bar code to be identified according to the target width stream. The scheme is used for solving the technical problem of how to improve the capability of decoding the bar code.

Description

Method and device for identifying bar codes, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of bar code identification technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for identifying a bar code.
Background
With the development of deep learning technology, the bar code technology is mature, and is widely applied to the fields of commodity circulation, book management, banking systems and the like. By means of the bar code on the item, various information about the item, such as the item name, date of production, price, etc., can be identified. In the prior art, the bar code can be decoded by adopting a technology based on software programming, and the method has the advantages of non-contact property, high efficiency, low cost and the like. However, in the practical application scene, the bar code may have partial occlusion, partial defect and other poor quality conditions, so that the bar code cannot be decoded.
Disclosure of Invention
The embodiment of the application provides a method, a device, electronic equipment and a storage medium for identifying a bar code.
In a first aspect, embodiments of the present application provide a method of identifying a bar code, the method comprising: and acquiring the bar code to be identified. And classifying the pixel points in the bar code to be identified to obtain a plurality of classified bar categories and a plurality of blank categories. And determining a target width stream of the bar code to be identified according to the bar categories and the empty categories, wherein the target width stream is formed by alternately arranging the bar categories and the empty categories in turn, and the pixel values of the pixels belonging to the same category in the target width stream are the same. And decoding the bar code to be identified according to the target width stream.
The embodiment of the application provides a method for identifying a bar code, because a bar code to be identified is obtained, pixel points in the bar code to be identified are classified, a plurality of bar categories and a plurality of empty categories are obtained after classification, and a target width stream of the bar code to be identified is determined according to the plurality of bar categories and the plurality of empty categories, the target width stream is formed by orderly and alternately arranging the plurality of bar categories and the plurality of empty categories, and pixel values of the pixel points belonging to the same category in the target width stream are the same.
In one possible implementation of the present application, determining a target width stream of a barcode to be identified according to a plurality of bar categories and a plurality of null categories includes: and updating the pixel values of the pixel points belonging to the bar class into first pixel values, and updating the pixel values of the pixel points belonging to the empty class into second pixel values, so as to obtain a first width stream. In the event that the first width stream is incomplete, the first width stream is processed to obtain a complete target width stream. In the case that the first width stream is complete, the first width stream is determined as the target width stream.
In this embodiment of the present application, if there is no region formed by pixels that are not classified in the first width stream, the first width stream is a complete width stream, and may be used as a target width stream, and if there is a region formed by pixels that are not classified in the first width stream, the first width stream is an incomplete width stream.
In one possible implementation manner of the present application, after updating the pixel value of the pixel point belonging to the stripe class to the first pixel value and updating the pixel value of the pixel point belonging to the null class to the second pixel value, to obtain the first width stream, the method provided by the embodiment of the present application further includes: and detecting lengths of a plurality of equidirectional horizontal detection lines emitted in the horizontal direction of the first width flow, wherein the initial positions of the plurality of horizontal detection lines are positions of first-appearing strip categories on the left side in the first width flow, and the end positions of the plurality of horizontal detection lines are positions of non-strip categories or empty categories in the first width flow. And determining that the first width flow is incomplete in the case that the number of the horizontal detection lines with the length smaller than the first preset value in the plurality of horizontal detection lines is larger than or equal to the second preset value. And determining that the first width flow is complete under the condition that the number of the horizontal detection lines with the length smaller than the first preset value in the plurality of horizontal detection lines is smaller than the second preset value.
In one possible implementation of the present application, in a case where it is determined that the first width stream is incomplete, processing the first width stream to obtain the complete target width stream includes: and under the condition that the first width stream is detected to be incomplete, determining at least one area to be processed in the first width stream, wherein the area to be processed is an area formed by pixels which are not classified in the first width stream. And updating the pixel value of the pixel point in each region to be processed to the pixel values of other pixel points in the belonging category.
In one possible implementation manner of the present application, in a case that the first width flow is detected to be incomplete, determining at least one area to be processed in the first width flow includes: and under the condition that the first width flow is incomplete, scanning the first width flow in the vertical direction to obtain a plurality of vertical detection lines. The position and size of at least one region to be treated in the first width stream is determined from the plurality of horizontal detection lines and the plurality of vertical detection lines.
In one possible implementation manner of the present application, updating the pixel value of the pixel point in each area to be processed to the pixel value of the other pixel points in the belonging category includes: and under the condition that the pixel points in the to-be-processed area belong to the bar category, updating the pixel values of the pixel points in the to-be-processed area into first pixel values. And under the condition that the pixel points in the to-be-processed area belong to the empty category, updating the pixel values of the pixel points in the to-be-processed area into second pixel values.
In one possible implementation manner of the present application, classifying pixels in a barcode to be identified to obtain a plurality of classified bar categories and a plurality of empty categories includes: the electronic equipment utilizes the target segmentation model to identify the image corresponding to the bar code to be identified, so as to obtain the category of each pixel point. The target segmentation model is obtained by carrying out iterative training and compression on the first segmentation model based on a sample data set, wherein the sample data set comprises at least one bar code sample, and the quality of each bar code sample is different.
In a second aspect, embodiments of the present application provide a device for identifying a barcode, where the device for identifying a barcode may implement the method in the first aspect or any possible implementation manner of the first aspect, and thus may also implement the beneficial effect in the first aspect or any possible implementation manner of the first aspect. The means for identifying a bar code may be an electronic device, or may be means for supporting the electronic device to implement the method of the first aspect or any possible implementation manner of the first aspect, e.g. applied to a chip or a control circuit in the electronic device. The bar code identifying device may implement the method by software, hardware, or by hardware executing corresponding software.
As an example, an embodiment of the present application provides an apparatus for identifying a barcode, which is an electronic device or a chip applied in the electronic device, including: and the acquisition unit is used for acquiring the bar code to be identified. The classifying unit is used for classifying the pixel points in the bar code to be identified to obtain a plurality of classified bar categories and a plurality of blank categories. The determining unit is used for determining a target width stream of the bar code to be identified according to the bar categories and the empty categories, wherein the target width stream is formed by alternately arranging the bar categories and the empty categories in sequence, and the pixel values of the pixels belonging to the same category in the target width stream are the same. And the decoding unit is used for decoding the bar code to be identified according to the target width stream.
In one possible implementation manner of the present application, the determining unit is further configured to update a pixel value of a pixel point belonging to a stripe class to a first pixel value, and update a pixel value of a pixel point belonging to an empty class to a second pixel value, so as to obtain a first width stream, where the first width stream is incomplete, process the first width stream to obtain a complete target width stream, and determine the first width stream as the target width stream where the first width stream is complete.
In one possible implementation manner of the present application, the determining unit is further configured to detect lengths of a plurality of horizontal detection lines emitted in a horizontal direction of the first width flow, where a start position of the plurality of horizontal detection lines is a position where a strip type appears for the first time on a left side in the first width flow, an end position of the plurality of horizontal detection lines is a position where a strip type or a blank type appears for the first width flow, determine that the first width flow is incomplete when a number of horizontal detection lines with lengths smaller than a first preset value in the plurality of horizontal detection lines is greater than or equal to a second preset value, and determine that the first width flow is complete when a number of horizontal detection lines with lengths smaller than the first preset value in the plurality of horizontal detection lines is smaller than the second preset value.
In one possible implementation manner of the present application, the determining unit is further configured to determine, when the first width stream is detected to be incomplete, at least one to-be-processed area in the first width stream, where the to-be-processed area is an area formed by pixels that are not classified in the first width stream, and update a pixel value of a pixel in each to-be-processed area to a pixel value of other pixels in the class to which the pixel belongs.
In one possible implementation manner of the present application, the determining unit is further configured to scan the first width flow in a vertical direction under a condition that the first width flow is incomplete, obtain a plurality of vertical detection lines, and determine a position and a size of at least one to-be-processed area in the first width flow according to the plurality of horizontal detection lines and the plurality of vertical detection lines.
In one possible implementation manner of the present application, the determining unit is further configured to update a pixel value of a pixel in the to-be-processed area to a first pixel value if the pixel in the to-be-processed area belongs to the stripe class, and update the pixel value of the pixel in the to-be-processed area to a second pixel value if the pixel in the to-be-processed area belongs to the null class.
In one possible implementation manner of the application, the determining unit is further configured to identify, by using the target segmentation model, an image corresponding to the barcode to be identified, so as to obtain a category of each pixel point.
In a third aspect, embodiments of the present application provide an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the electronic device implementing a method of identifying a barcode as described in any one of the possible implementations of the first aspect to the first aspect when the computer program is executed by the processor.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having stored therein a computer program or instructions which, when run on a computer, cause the computer to perform a method of identifying a barcode as described in any one of the possible implementations of the first aspect to the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform a method of identifying a barcode as described in the first aspect or in various possible implementations of the first aspect.
In a sixth aspect, embodiments of the present application provide a chip comprising a processor for executing a computer program or instructions to implement the method of identifying a barcode described in the first aspect or in various possible implementations of the first aspect.
Drawings
FIG. 1 is a flow chart of a method for identifying a bar code according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a bar code identification according to an embodiment of the present application;
FIG. 3 is a schematic diagram of detecting integrity of a width stream according to an embodiment of the present application;
FIG. 4 is a schematic diagram of determining a region to be treated according to an embodiment of the present application;
FIG. 5 is a schematic view of a region to be treated according to an embodiment of the present disclosure;
FIG. 6 is a schematic structural diagram of an apparatus for identifying a bar code according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Before describing the embodiments of the present application, the following definitions are first applied to the relevant terms referred to in the present application:
(1) Strip category: the connected region in the bar code is a black region.
(2) Empty category: the connected areas in the bar code are white areas.
(3) Pixel point: the smallest elementary constituent unit in a bar code.
(4) Width flow: representing a sequence of consecutive black bars and spaces mentioned from the image level.
(5) And (3) a horizontal detection line: a ray representing a level from left to right in the bar code, the bar code being decodable if the ray is capable of finding all bar and space categories; if not, decoding is not possible.
(6) And (3) a target segmentation model: a deep learning model adopts a pixel-level classification algorithm, and the target segmentation model can assign a category model to each pixel point.
A bar code (Barcode) is a graphic identifier in which a plurality of black bars and spaces having different widths and different reflectivities are arranged according to a certain coding rule to express a set of information. Wherein the set of information expressed by the bar code may include: the production country, manufacturer, commodity name, date of production, book classification number, category, etc. of the article, and thus are widely used in many fields such as commodity circulation, book management, postal management, banking system, etc. Because the black bars and the blanks in the bar code symbol have different reflectivities to light rays, when the bar code is identified, electric pulses with different electric potential levels are correspondingly generated by receiving reflected light signals with different intensities, and the widths of the black bars and the blanks in the bar code determine the lengths of the electric pulse signals, so that the bar code is identified. Bar codes can be classified into one-dimensional bar codes and two-dimensional bar codes, and the embodiments of the present application are described by taking one-dimensional bar codes as examples.
In the prior art, a bar code can be decoded by adopting a technology based on software programming, for example, a bar code identification method based on a Zbar technology and a Zxing technology, which is a technology adopting traditional digital image processing, for example, a gradient solving method, a binarization contour finding method and the like, so as to extract boundaries of bar categories and empty categories in the bar code. Exemplary, the bar code identification method based on the Zbar technology comprises the following steps: (1) performing image compression on the bar code to obtain a thumbnail; (2) If the bar code cannot be recognized, detecting the inclination angle of the compressed image according to a bar code region recognition method (for example, gradient calculation, etc.), and correcting the bar code and/or the compressed image by using the inclination angle to obtain a target image; (3) Positioning the rectangular area in the target graph to obtain a width stream, and identifying the bar code according to the width stream. The method has the advantages of non-contact property, high efficiency, low cost and the like. However, in the practical application scene, the bar code may have partial occlusion, partial defect and other poor quality conditions, so that the decoding of the bar code is inaccurate.
Accordingly, the present application provides a method, apparatus, electronic device, and storage medium for identifying a barcode, which are used for solving the technical problem of how to improve the capability of decoding the barcode.
In order to illustrate the technical solutions described in the present application, the following description is made by specific examples.
In the present embodiment, the specific structure of the execution subject of a method of identifying a barcode is not particularly limited as long as communication can be performed with a method of identifying a barcode according to the present embodiment by running a program in which codes of the method of identifying a barcode of the present embodiment are recorded. For example, an execution subject of a method for identifying a barcode provided in an embodiment of the present application may be a functional module in an electronic device that can call a program and execute the program, or an apparatus for identifying a barcode applied to an electronic device, for example, a chip.
The following embodiments describe an example in which an execution subject of a method of recognizing a bar code is an electronic device.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for identifying a barcode according to an embodiment of the present application, where the method includes the following steps:
Step 110, the electronic device obtains the bar code to be identified.
It will be appreciated that the bar code to be identified may be a clear, clean, good quality bar code, as shown in figure 2 (a); the bar code to be identified may also be of poor quality, for example, there may be cases of blurring, overexposure, partial occlusion, etc. of the bar code to be identified, as shown in fig. 2 (b).
As an example, the electronic device is a device with a code scanning function, for example, the electronic device may be a mobile phone, a tablet computer or a bar code recognition device. The bar code to be identified in the embodiment of the application can be a logistics bar code or a bar code attached to books or commodities.
It may be understood that the barcode to be identified may be acquired by the electronic device, may be sent to the electronic device by other devices, may be a barcode stored in the electronic device, or may be downloaded from a web page by the electronic device, which is not limited in the embodiment of the present application.
And 120, classifying the pixel points in the bar code to be identified by the electronic equipment to obtain a plurality of classified bar categories and a plurality of blank categories.
In the embodiment of the application, the difference between the pixel value of the pixel point belonging to the bar class and the pixel value of the pixel point belonging to the null class is greater than or equal to a preset value. For example, the pixel value of the pixel belonging to the bar class and the pixel value of the pixel belonging to the null class are located at both ends of the pixel section. For example, the pixel value of the pixel point belonging to the bar class may be 0. The pixel value of the pixel belonging to the null class may be 255.
By classifying the pixel points to obtain the classified bar categories and the blank categories, the electronic equipment can decode and convert the bar codes to be identified in the mode of identifying the areas formed by the pixel points into the bar codes to be identified by identifying the classified bar categories and the blank categories, so that the success rate of decoding of the electronic equipment is improved.
It should be explained that, as another example, in the plurality of bar categories and the plurality of empty categories after the classification, the pixel values of the pixel points belonging to the same category may be the same or may be different. For example, as shown in the (b) diagram in fig. 2, the pixel point a belongs to the bar category, and the pixel value of the pixel point a is different from the pixel value of the pixel point adjacent thereto; accordingly, the pixel points b belong to the same class, and the pixel values of the pixel points b are different from the pixel values of the adjacent pixel points.
Specifically, as shown in fig. 2, the bar category may be a black bar category in the bar code to be identified. The empty category may be a blank bar category in the bar code to be identified. Alternatively, the empty category may be a black bar category in the bar code to be identified, and the bar category may be a blank bar category in the bar code to be identified. In the embodiment of the application, the bar type is a black bar type, and the blank type is a blank bar type.
It is understood that a plurality of black bar categories and a plurality of blank bar categories exist in one bar code to be identified, and the black bar categories and the blank bar categories are alternately arranged. Alternatively, the width of any black bar category or any blank bar category may be different.
It should be explained that the pixel point is the smallest image unit constituting the barcode to be identified, and the barcode to be identified includes a plurality of pixel points, where each pixel point has a different pixel value. The pixel value is used to represent the average luminance information for each pixel in the bar code to be identified. Typically, the pixel interval of the pixel value of the pixel point is [0,255], that is, the pixel value of one pixel point may be one gray level of 256 gray levels, each representing different brightness information of the pixel point. Wherein, in the case that the pixel value of the pixel point is 0, the pixel point is black; in the case where the pixel value of the pixel is 255, the pixel is white.
Step 130, the electronic device determines a target width stream of the bar code to be identified according to the bar categories and the empty categories. Wherein, the pixel values of the pixel points belonging to the same class in the target width stream are the same.
Wherein, referring to a schematic diagram for identifying a bar code as shown in fig. 2, a target width stream is composed of a plurality of bar categories and a plurality of empty categories alternately arranged in sequence.
It is understood that, in the embodiment of the present application, the target width stream refers to a complete width stream, that is, a region that does not include pixels that are not classified in the width stream. In other words, an incomplete width stream in this application refers to an area in the width stream that is composed of pixels that are not classified.
It should be explained that, in any bar category and any empty category, since the pixels belonging to the same bar category or the same empty category are adjacent and continuous between the pixels, and the pixel values of the pixels are the same, the adjacent and continuous pixels, and the pixel values of which are the same, can be regarded as one bar category or empty category, so that a plurality of bar categories and a plurality of empty categories, which are sequentially alternately arranged, can be obtained in one target width stream formed by the bar code to be recognized.
As an example, referring to a schematic diagram of identifying a bar code as shown in fig. 2, there are 14 bar categories and 13 null categories in a target width stream formed by the bar code to be identified as shown in (a). In any one bar category, the pixel points are adjacent and continuous, and the pixel values of the pixel points are all 0; the pixels in different bar categories are not adjacent and discontinuous. Correspondingly, in any empty category, the pixel points are adjacent and continuous, and the pixel values of the pixel points are 255; the pixels in different empty categories are not adjacent and discontinuous.
And 140, the electronic equipment decodes the bar code to be identified according to the target width stream.
As an example, since the target width stream is composed of a plurality of bar categories and a plurality of null categories alternately arranged in order, the electronic device can decode the bar code to be recognized according to a specific decoding rule. For example, when the electronic device detects a bar category, the electronic device may convert the bar category information into 1 according to the presentation modes of the bar category and the empty category, and when the electronic device detects an empty category, the electronic device may convert the empty category information into 0; the target width stream defines unit widths of the bar and space classes, each unit width being expressed as a digital signal, so that the width of each bar or space class is expressed as the number converted into the corresponding digital signal.
As an example, refer to a target width stream as shown in the (a) diagram in fig. 2: assuming that the width of the first stripe class at the leftmost side in the target width stream is specified to be one unit width, the width of the second stripe class from the left side is two unit widths, and the width of the third stripe class is one unit width in turn; correspondingly, the width of the first empty category from the left side is one unit width, the width of the second empty category is two unit widths, and the width of the third empty category is one unit width in sequence. From this, the electronic device, according to the target width stream, represents the digital signal after decoding the barcode to be identified as: 1011001011101011011010110010110101011.
The embodiment of the application provides a method for identifying a bar code, because a bar code to be identified is obtained, pixel points in the bar code to be identified are classified, a plurality of bar categories and a plurality of empty categories are obtained after classification, and a target width stream of the bar code to be identified is determined according to the plurality of bar categories and the plurality of empty categories, the target width stream is formed by orderly and alternately arranging the plurality of bar categories and the plurality of empty categories, and pixel values of the pixel points belonging to the same category in the target width stream are the same.
In one possible implementation manner of the present application, the foregoing step 130 includes the following steps in a method provided in an embodiment of the present application:
step 131, the electronic device updates the pixel value of the pixel point belonging to the bar class to a first pixel value and updates the pixel value of the pixel point belonging to the empty class to a second pixel value according to the class of each pixel point, so as to obtain a first width stream.
Wherein the first width stream includes a plurality of bar categories and a plurality of null categories.
Specifically, when the bar type is a black bar type and the blank type is a blank bar type, the first pixel value is 0 and the second pixel value is 255.
It will be appreciated that each pixel in the bar code to be identified may have a different pixel value, which may be 0 or 255, although any value in the range of 0 to 255 is possible. And the electronic equipment respectively updates the pixel values of the pixel points belonging to the bar category and the empty category obtained by classification, and then obtains a first width stream.
Illustratively, as shown in the (b) diagram in fig. 2, in the case where there is blurring or overexposure of the bar code to be recognized, the pixel value of the pixel points classified into the bar category is any one of the pixel values from 0 to 255. Illustratively, since there is overexposure in the black bar category in the bar code to be recognized, there may be a pixel point having a pixel value of 255 in the black bar category, for example, pixel point a; pixel point a having a pixel value of 255 is classified into a bar category. For example, since the blank bar type of the bar code to be recognized has black stain, there may be a pixel point having a pixel value of 0 in the blank bar type, for example, a pixel point b, and thus the pixel point b having a pixel value of 0 is classified into the blank type.
As an example, taking a first pixel value of 0 and a second pixel value of 255 as an example, a schematic diagram of identifying a bar code is shown in fig. 2: the electronic device updates the pixel value of the pixel classified in the bar category to 0 and updates the pixel value of the pixel classified in the empty category to 255 by judging whether the pixel belongs to the bar category or the empty category. Illustratively, the pixel value of pixel a in the bar class is 255, and since pixel a is classified into the bar class, the pixel value of pixel a is updated from 255 to 0. The pixel value of the pixel b in the empty category is 0, and since the pixel b is classified into the empty category, the pixel value of the pixel b is updated from 0 to 255. In this way, the electronic apparatus can obtain the first width stream, and the first width stream is constituted by alternately arranging the plurality of bar categories and the plurality of empty categories in order.
And 132, the electronic device processes the first width stream to obtain a complete target width stream under the condition that the first width stream is determined to be incomplete when detecting that the pixel points with the pixel values which are not updated in the bar code to be identified exist.
Since after the electronic device updates the pixel values of the pixel points in the bar category and the null category according to the category of each pixel point, there may be a pixel point in the bar code to be identified, where the pixel value cannot be updated, so that the first width stream is determined to be incomplete. For example, as shown in the graph (b) in fig. 3, there may be a pixel value of not 0 in the bar class in the first width stream, and there may be a pixel value of not 255 in the null class, so the electronic device determines that the first width stream is incomplete, and processes the first width stream to obtain a complete target width stream.
And step 133, when the electronic device detects that the pixel points in the bar code to be identified are all updated pixel points and determines that the first width stream is complete, determining the first width stream as a target width stream.
As an example, as shown in the (a) diagram in fig. 3, the pixel values of the pixel points in the bar class in the first width stream are all 0, and the pixel values of the pixel points in the empty class are all 255, so the electronic device determines that the first width stream is complete, and determines the first width stream as the target width stream.
For a method how the electronic device detects whether the first width stream is complete or not, and a method how to process the first width stream to obtain the complete width stream, reference may be made to the following embodiments, which are not described herein.
In one possible embodiment of the present application, after the step 131, the method provided in the embodiment of the present application further includes: the electronic device detects whether the first width stream is complete.
As an example, the electronic device detecting whether the first width stream is complete may be implemented by: the electronic device outputs a first width stream to determine whether the first width stream is complete by a user, and if it is detected that the user indicates that the first width stream is incomplete, the electronic device determines that the first width stream is incomplete. If it is detected that the user indicates that the first width stream is complete, the electronic device determines that the first width stream is complete. Or the electronic equipment is provided with a preset model which is used for detecting whether the first width flow is complete or not. For example, the electronic device inputs the first width stream into the preset model to obtain a result of whether the first width stream is complete. It will be appreciated that the pre-set model is trained from a plurality of complete width stream samples and incomplete width stream samples.
Or the electronic device feeds back the first width stream to the server to determine whether the first width stream is complete or not, and feeds back the result to the electronic device.
Of course, in the embodiment of the present application, the electronic device may also detect whether the first width stream is complete by the following manner:
step 1311, the electronic device detects lengths of a plurality of horizontal detection lines emitted in a same direction in a horizontal direction of the first width stream.
The starting positions of the plurality of horizontal detection lines are positions of the first-appearing strip type at the left side in the first width flow, and the ending positions of the plurality of horizontal detection lines are positions of the non-strip type or the empty type in the first width flow.
It should be noted that the horizontal detection line is represented in the first width stream as a detection line emitted from the position where the strip class first appears on the left side as the start point in the other side direction. When detecting other pixel points except the bar type and the empty type, the detection line stops emitting, and the position when detecting other pixel points is taken as the end position.
As an example, a schematic diagram of detecting width stream integrity as shown in fig. 3: the electronic device takes a strip type at the left position in the first width stream as a starting point position, and sends 10 horizontal detection lines to the right in the horizontal direction, and when other pixel points except the strip type and the empty type are detected, each horizontal detection line takes the position at which other pixel points are detected as a termination position. As shown in the figure (a), when the first width flow is complete, the end positions of the horizontal detection lines a to I are the other side positions. And detecting that 14 categories and 13 blank categories exist in the first width flow through the horizontal detection lines A to J. As shown in the graph (b), when the first width flow is incomplete, the end positions of the horizontal detection lines C 'to J' are positions at which other pixels excluding the bar type and the blank type are detected. Thus, by detecting the length of the horizontal detection line, the number of bar categories and empty categories in the first width stream can be determined; and by detecting the lengths of the plurality of horizontal detection lines, it can be determined whether the first width stream is complete.
In step 1312, the electronic device determines that the first width flow is incomplete when the number of horizontal detection lines with a length smaller than the first preset value in the plurality of horizontal detection lines is greater than or equal to the second preset value.
It may be understood that the first preset value and the second preset value may be preset values set by people, or may be preset values set by the electronic device according to the size of the first width stream, which is not limited in the embodiment of the present application.
As an example, assume that the overall width of the first width stream is L, the first preset value is L/3, and the second preset value is 5. Fig. 3 (b) shows a schematic diagram of detecting the integrity of the width stream: among the horizontal detection lines A '-J', the length of the horizontal detection line A '-C' is greater than L/3, and the length of the horizontal detection line D '-J' is less than 3/L. And if the lengths of 7 horizontal detection lines (horizontal detection line D '-horizontal detection line J') which are larger than the second preset value are detected to be smaller than the first preset value, determining that the first width flow is incomplete.
Step 1313, determining that the first width flow is complete by the electronic device when the number of horizontal detection lines with the length smaller than the first preset value in the plurality of horizontal detection lines is smaller than the second preset value.
As an example, assume that the overall width of the first width stream is L, the first preset value is L/3, and the second preset value is 5. Fig. 3 (a) shows a schematic diagram of detecting width flow integrity: and in the horizontal detection lines A to J, the lengths of the horizontal detection lines A to I are L, and the lengths of the horizontal detection lines J are less than 3/L. And if the length of 1 (less than the second preset value) horizontal detection line (horizontal detection line I) is detected to be less than the first preset value, determining that the first width flow is complete.
In one possible embodiment of the present application, the step 132 includes the following steps in the embodiment of the present application:
in step 1321, the electronic device determines at least one to-be-processed area in the first width stream if the first width stream is detected to be incomplete.
The region to be processed is a region formed by pixels which are not classified in the first width stream, and may also refer to a region in the first width stream, where the pixel having one or more regions in at least one class is different from the pixel having other regions.
As an example, a schematic diagram of determining a region to be treated is shown in fig. 4: the electronic equipment determines a to-be-processed area A1-to-be-processed area A6 in the first width stream, wherein the to-be-processed area A1-to-be-processed area A6 is a to-be-processed area in the strip type, and the pixel values of the to-be-processed area A1-to-be-processed area A6 and other pixel points in the strip type are different. Correspondingly, the electronic device determines a to-be-processed area B1-to-be-processed area B2 in the first width stream, wherein the to-be-processed area B1-to-be-processed area B2 is an area to be processed in the null class, and pixel values of other pixel points in the null class are different from the area to be processed B1-to-be-processed area B2.
In step 1322, the electronic device updates the pixel value of the pixel point in each to-be-processed area to the pixel values of other pixel points in the belonging category.
As an example, a schematic diagram of a processing region to be processed is shown in fig. 5: the areas to be treated A1 to A4 are areas to be treated in the strip type, and the areas to be treated B1 to B2 are areas to be treated in the blank type. Therefore, the electronic device updates the pixel values of the pixel points in the to-be-processed areas A1 to A4 to the pixel values of the other pixel points in the bar class, and updates the pixel values of the pixel points in the to-be-processed areas B1 to B2 to the pixel values of the other pixel points in the null class.
In one possible embodiment of the present application, step 1321 includes the following steps in an embodiment of the present application:
in step 13211, the electronic device scans the first width flow in the vertical direction under the condition that the first width flow is incomplete, so as to obtain a plurality of vertical detection lines.
It is understood that the plurality of vertical detection lines may be a position with an upper position of the first width flow as a start position and a lower position as an end position, for example, a vertical detection line K 'to a vertical detection line P' in fig. 4; of course, the plurality of vertical detection lines may also be a start position at a lower position of the first width flow and an end position at an upper position, for example, vertical detection lines Q 'to V' in fig. 4.
As an example, a schematic diagram for determining a region to be treated as shown in fig. 4 illustrates: among the vertical detection lines K 'to V', the vertical detection line K 'to P' is a position above the first width flow as a start point, and the vertical detection line Q 'to V' is a position below the first width flow as a start point.
Step 13212, the electronic device determines a position and a size of the plurality of areas to be processed in the first width stream according to the plurality of horizontal detection lines and the plurality of vertical detection lines.
As an example, a schematic diagram of treating a region to be treated is shown in fig. 4: the electronic equipment determines the positions and the sizes of the areas to be processed A1 to A6 and the positions and the sizes of the areas to be processed B1 to B2 according to the horizontal detection line A 'to J' and the vertical detection line K 'to V'. The electronic equipment determines the position and the size of the area A1 to be processed according to the horizontal detection line H ' -the horizontal detection line J ' and the vertical detection line K '; determining the position and the size of the area A2 to be processed according to the horizontal detection line G 'and the vertical detection line L'; determining the position and the size of the area A3 to be processed according to the horizontal detection lines E '-F' and the vertical detection lines M 'and S'; determining the position and the size of the area A4 to be processed according to the horizontal detection line D ', the vertical detection line N ' and the vertical detection line T '; determining the position and the size of the area A5 to be processed according to the horizontal detection line C ', the vertical detection line O ' and the vertical detection line U '; and determining the position and the size of the area to be processed A6 according to the horizontal detection lines A '-B', the vertical detection line P 'and the vertical detection line V'. The electronic equipment determines the position and the size of the to-be-processed area B1 according to the horizontal detection line H 'and the vertical detection line Q'; and determining the position and the size of the to-be-processed area B2 according to the horizontal detection lines G ' -H ' and the vertical detection lines R '.
In one possible embodiment of the present application, step 1322 includes the following in the embodiment of the present application:
under the condition that the pixel points in the to-be-processed area belong to the bar category, the electronic equipment updates the pixel values of the pixel points in the to-be-processed area to be a first pixel value;
wherein the first pixel value is 0.
As an example, a schematic diagram of a processing region to be processed is shown in fig. 5: under the condition that the electronic equipment determines that the pixel points in the to-be-processed areas A1 to A4 belong to the to-be-processed areas in the bar category, updating the pixel values of the pixel points in the to-be-processed areas A1 to A4 to be 0.
And 2, under the condition that the pixel points in the to-be-processed area belong to the empty category, the electronic equipment updates the pixel values of the pixel points in the to-be-processed area to be the second pixel values.
Wherein the second pixel value is 255.
As an example, a schematic diagram of a processing region to be processed is shown in fig. 5: under the condition that the electronic equipment determines that the pixel points in the to-be-processed areas B1 to B2 belong to the to-be-processed areas in the empty category, the pixel values of the pixel points in the to-be-processed areas B1 to B2 are updated to 255.
In one possible embodiment of the present application, the above step 120 may be specifically implemented by: the electronic equipment utilizes the target segmentation model to identify the image corresponding to the bar code to be identified, so as to obtain the category of each pixel point.
Of course, the electronic device may also provide the barcode to be identified to the server having the target segmentation model to determine the category of each pixel in the barcode to be identified by the server and feed back to the electronic device.
The target segmentation model is obtained by carrying out iterative training and compression on the first segmentation model based on a sample data set, wherein the sample data set comprises at least one bar code sample, and the quality of each bar code sample is different.
It should be explained that the target segmentation model and the first segmentation model may be a network structure model based on an image segmentation algorithm, such as a convolutional neural network model, a semantic feature segmentation model, and the like.
Image segmentation (Semantic Segmentation) refers to dividing an image into several mutually disjoint regions according to gray scale, color, geometry, etc. features such that the features exhibit consistency or similarity within the same region and differ significantly between different regions. In an exemplary embodiment, according to the method for identifying a barcode provided in the embodiment of the present application, the electronic device classifies each pixel according to the difference of pixel values of the pixels of the barcode, divides the barcode into a bar type area and a blank type area, and updates the pixel values of the pixels in the same area. The pixel points in the areas of the same genus have connectivity, namely the pixel points are adjacent to and continuous with the pixel points in the areas of the same genus, and the pixel values among the pixel points are the same.
As one example, the first segmentation model may be a segmentation model built by employing a U2 Net (U Square Net) network model framework based on salient object detection. The PAN (Pyramid Attention Network) structure is introduced into a first segmentation model taking a U2 Net network model as a framework, a feature pyramid is constructed, high-level strong semantic features are transferred from the top to the bottom, and the learning capacity of the first segmentation model is enhanced. And carrying out iterative training on the first segmentation model according to the sample data set, and refining the trained first segmentation model by adopting a model compression technology to obtain a compressed target segmentation model, wherein the target segmentation model can be suitable for more complex scenes. The sample data set comprises at least one bar code sample from a real scene, wherein the sample data set at least comprises bar code samples of the types of clear, partial shielding, local damage, blurring, transitional exposure and the like. It will be appreciated that the quality of these bar code samples is not the same. Among them, the model compression technique is used to achieve the effect of simplifying the original model (e.g., the first segmentation model) without significantly degrading the accuracy, including knowledge distillation, pruning, etc. And through the established target segmentation model, the electronic equipment infers each pixel in the bar code to be identified, and determines the category of each pixel in the bar code to be identified. It may be understood that the target segmentation model in the embodiment of the present application may be obtained by self-training of the electronic device, or may be configured in the electronic device after the server is trained, or obtained by the electronic device from the server, which is not limited in the embodiment of the present application.
It will be appreciated that the electronic device may periodically obtain an updated target segmentation model from the server, and then, after obtaining the updated target segmentation model, the electronic device determines a class of each pixel in the barcode to be identified based on the updated target segmentation model.
As a possible implementation manner, the method provided by the embodiment of the application further includes: the electronic device is configured with a high-speed processor for decoding the bar code to be identified.
The high-speed processor may be a graphics processor (Graphics Processing Unit, GPU), a central processor (Central Processing Unit, CPU), or an embedded Neural network processor (Neural-network Processing Unit, NPU), among others, as an example. The electronic equipment can realize the acceleration of the real-time decoding of the bar code to be identified by the electronic equipment by configuring the high-speed processor.
It is understood that the graphics processor, also called a display core, a vision processor, and a display chip, is a microprocessor that is specially used for performing image and graphics related operations on a personal computer, a workstation, a game machine, and some mobile devices (such as a tablet computer, a smart phone, etc.). The central processing unit is used as the operation and control core of the computer system and is the final execution unit for information processing and program running, for example, the central processing unit is used for executing the operation of decoding the bar code to be identified. The neural network processor is an accelerator based on artificial intelligence and is used for accelerating the operation of the neural network and solving the problem that the efficiency of a traditional chip (such as a CPU) is low when the neural network is operated.
It is to be understood that each device, such as an electronic device, includes corresponding structures and/or software modules that perform the functions described above. Those of skill in the art will readily appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the present application may perform the division of the functional units according to the above method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated in one processing unit. The integrated units may be implemented in hardware or in software functional units. It should be noted that, in the embodiment of the present application, the division of the units is schematic, which is merely a logic function division, and other division manners may be implemented in actual practice.
The method according to the embodiment of the present application is described above with reference to fig. 1 to 5, and the apparatus for performing the method according to the embodiment of the present application is described below. It will be appreciated by those skilled in the art that the methods and apparatus may be combined and referred to, and that the apparatus for identifying a bar code provided in the embodiments of the present application may perform the steps performed by the electronic device in the method for identifying a bar code described above.
In the case of an integrated unit, fig. 6 shows the apparatus for identifying a bar code related to the above embodiment, which may be an electronic device or an apparatus applied to an electronic device, such as a chip or a processing circuit, and the apparatus for identifying a bar code may include: an acquisition unit 210, a classification unit 220, a determination unit 230, a decoding unit 240.
In an alternative implementation, the device for identifying a bar code may further comprise a storage unit for storing program code and data of the device for identifying a bar code.
The means for identifying the bar code is, for example, an electronic device or a chip for application in an electronic device. An acquiring unit 210, configured to acquire a barcode to be identified. The classifying unit 220 is configured to classify the pixel points in the barcode to be identified, and obtain a plurality of classified bar categories and a plurality of blank categories. The determining unit 230 determines a target width stream of the barcode to be identified according to the plurality of bar categories and the plurality of empty categories, wherein the target width stream is formed by alternately arranging the plurality of bar categories and the plurality of empty categories in turn, and pixel values of pixels belonging to the same category in the target width stream are the same. And a decoding unit 240 for decoding the bar code to be identified according to the target width stream.
In a possible implementation manner of the present application, the determining unit 230 is further configured to update a pixel value of a pixel point belonging to a stripe class to a first pixel value, and update a pixel value of a pixel point belonging to an empty class to a second pixel value, so as to obtain a first width stream, where the first width stream is incomplete, process the first width stream to obtain a complete target width stream, and determine the first width stream as the target width stream where the first width stream is complete.
In one possible implementation manner of the present application, the determining unit 230 is further configured to detect lengths of a plurality of horizontal detection lines emitted in a horizontal direction of the first width flow, where a start position of the plurality of horizontal detection lines is a position where a strip type appears for the first time on a left side in the first width flow, an end position of the plurality of horizontal detection lines is a position where a strip type or a blank type appears for the first width flow, determine that the first width flow is incomplete when a number of horizontal detection lines with a length smaller than a first preset value in the plurality of horizontal detection lines is greater than or equal to a second preset value, and determine that the first width flow is complete when a number of horizontal detection lines with a length smaller than the first preset value in the plurality of horizontal detection lines is smaller than the second preset value.
In a possible implementation manner of the present application, the determining unit 230 is further configured to determine, when the first width stream is detected to be incomplete, at least one to-be-processed area in the first width stream, where the to-be-processed area is an area formed by pixels that are not classified in the first width stream, and update a pixel value of a pixel in each to-be-processed area to a pixel value of other pixels in the class to which the pixel belongs.
In a possible implementation manner of the present application, the determining unit 230 is further configured to scan the first width flow in a vertical direction in the case where the first width flow is incomplete, obtain a plurality of vertical detection lines, and determine a position and a size of at least one area to be processed in the first width flow according to the plurality of horizontal detection lines and the plurality of vertical detection lines.
In one possible implementation manner of the present application, the determining unit 230 is further configured to update the pixel value of the pixel in the area to be processed to a first pixel value if the pixel in the area to be processed belongs to the bar class, and update the pixel value of the pixel in the area to be processed to a second pixel value if the pixel in the area to be processed belongs to the null class.
In one possible implementation manner of the present application, the determining unit 230 is further configured to identify, by using the target segmentation model, an image corresponding to the barcode to be identified, so as to obtain a class of each pixel.
The device for identifying the bar code may further comprise a processing unit, which may be a processor or a controller, for example, a central processing unit, a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules, and circuits described in connection with this disclosure. A processor may also be a combination that performs a computational function, such as a combination comprising one or more microprocessors, a combination of a digital signal processor and a microprocessor, and so forth. The memory module may be a memory.
With further reference to fig. 7, fig. 7 is a schematic structural diagram of an electronic device 300 according to an embodiment of the present application. As shown in fig. 7, the electronic apparatus 300 of this embodiment includes: at least one processor 310 (only one processor is shown in fig. 7), a memory 320, and a computer program 330, such as a data processing program, stored in the memory 320 and executable on the at least one processor 310. The steps of any of the various method embodiments described above are implemented by processor 310 when executing computer program 330. The steps of the embodiments of the various data processing methods described above are implemented when the processor 310 executes the computer program 330. The processor 310, when executing the computer program 330, performs the functions of the modules/units in the above-described apparatus embodiments, such as the functions of the acquisition unit 210 to the decoding unit 240 shown in fig. 6.
Alternatively, the structure of the electronic device 300 as shown in fig. 7 may further include a memory, which may be a read-only memory (ROM) or other type of static storage device that may store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that may store information and instructions, or an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc (compact disc read-only memory, CD-ROM) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. The memory may also be integrated with the processor.
The memory is used for storing computer execution instructions for executing the scheme, and the processor is used for controlling the execution. The processor is configured to execute computer-executable instructions stored in the memory, thereby implementing a method for identifying a bar code provided in the embodiments described below.
Alternatively, the computer-executable instructions in the embodiments of the present application may be referred to as application program codes, which are not specifically limited in the embodiments of the present application.
In one aspect, a computer-readable storage medium is provided having instructions stored therein that, when executed, perform functions as performed by the electronic device 300 of fig. 1.
In one aspect, a computer program product is provided that includes instructions that, when executed, perform functions as performed by the electronic device 300 of fig. 1.
In one aspect, embodiments of the present application provide a chip for use in an electronic device 300, the chip including at least one processor for executing instructions to perform functions as performed by the electronic device 300 in fig. 1.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are performed in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, a network device, a user device, or other programmable apparatus. The computer program or instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer program or instructions may be transmitted from one website site, computer, server, or data center to another website site, computer, server, or data center by wired or wireless means. The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that integrates one or more available media. The usable medium may be a magnetic medium, e.g., floppy disk, hard disk, tape; optical media, such as digital video discs (digital video disc, DVD); but also semiconductor media such as solid state disks (solid state drive, SSD).
Although the present application has been described herein in connection with various embodiments, other variations to the disclosed embodiments can be understood and effected by those skilled in the art in practicing the claimed application, from a review of the figures, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other elements or steps, and the "a" or "an" does not exclude a plurality. A single processor or other unit may fulfill the functions of several items recited in the claims. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
Although the present application has been described in connection with specific features and embodiments thereof, it will be apparent that various modifications and combinations can be made without departing from the spirit and scope of the application. Accordingly, the specification and drawings are merely exemplary illustrations of the present application as defined in the appended claims and are considered to cover any and all modifications, variations, combinations, or equivalents that fall within the scope of the present application. It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A method of identifying a bar code, comprising:
acquiring a bar code to be identified;
classifying the pixel points in the bar code to be identified to obtain a plurality of classified bar categories and a plurality of blank categories;
determining a target width stream of the bar code to be identified according to a plurality of bar categories and a plurality of empty categories, wherein the target width stream is formed by alternately arranging a plurality of bar categories and a plurality of empty categories in turn, and pixel values of pixel points belonging to the same category in the target width stream are the same;
and decoding the bar code to be identified according to the target width stream.
2. The method of claim 1, wherein said determining a target width stream of the bar code to be identified based on a plurality of said bar categories and a plurality of said null categories comprises:
updating the pixel value of the pixel points belonging to the bar class into a first pixel value, and updating the pixel value of the pixel points belonging to the empty class into a second pixel value, so as to obtain a first width stream;
processing the first width stream to obtain a complete target width stream in case the first width stream is incomplete;
and determining the first width stream as the target width stream when the first width stream is complete.
3. The method of claim 2, wherein after updating the pixel values of the pixel points belonging to the bar class to a first pixel value and updating the pixel values of the pixel points belonging to the null class to a second pixel value to obtain the first width stream, the method further comprises:
detecting lengths of a plurality of equidirectional horizontal detection lines emitted in the horizontal direction of the first width flow, wherein the initial positions of the plurality of horizontal detection lines are positions where the bar category appears for the first time on the left side in the first width flow, and the final positions of the plurality of horizontal detection lines are positions where the bar category is not in the first width flow or the blank category;
determining that the first width flow is incomplete when the number of the horizontal detection lines with the length smaller than a first preset value in the plurality of horizontal detection lines is larger than or equal to a second preset value;
and determining that the first width flow is complete under the condition that the number of the horizontal detection lines with the length smaller than a first preset value in the plurality of horizontal detection lines is smaller than a second preset value.
4. A method according to claim 2 or 3, wherein, in the event that the first width stream is incomplete, processing the first width stream to obtain a complete target width stream comprises:
Determining at least one region to be processed in the first width stream under the condition that the first width stream is detected to be incomplete, wherein the region to be processed is a region formed by pixels which are not classified in the first width stream;
and updating the pixel value of the pixel point in each to-be-processed area to the pixel values of other pixel points in the belonging category.
5. The method of claim 4, wherein the determining at least one region to be processed in the first width stream if the first width stream is detected to be incomplete comprises:
under the condition that the first width flow is incomplete, scanning the first width flow in the vertical direction to obtain a plurality of vertical detection lines;
and determining the position and the size of at least one region to be treated in the first width flow according to a plurality of horizontal detection lines and a plurality of vertical detection lines.
6. The method of claim 4, wherein updating the pixel values of the pixels in each of the regions to be processed to the pixel values of the other pixels in the class comprises:
updating the pixel value of the pixel point in the area to be processed into the first pixel value under the condition that the pixel point in the area to be processed belongs to the bar category;
And under the condition that the pixel points in the to-be-processed area belong to the empty category, updating the pixel values of the pixel points in the to-be-processed area into the second pixel values.
7. A method according to any one of claims 1 to 3, wherein classifying the pixels in the barcode to be identified to obtain a plurality of classified bar categories and a plurality of empty categories includes:
identifying the image corresponding to the bar code to be identified by utilizing a target segmentation model so as to obtain the category of each pixel point;
the target segmentation model is obtained by performing iterative training and compression on a first segmentation model based on a sample data set, wherein the sample data set comprises at least one bar code sample, and the quality of each bar code sample is different.
8. An apparatus for identifying a bar code, comprising:
the acquisition unit is used for acquiring the bar code to be identified;
the classifying unit is used for classifying the pixel points in the bar code to be identified to obtain a plurality of classified bar categories and a plurality of empty categories;
the determining unit is further used for determining a target width stream of the bar code to be identified according to a plurality of bar categories and a plurality of empty categories, the target width stream is formed by alternately arranging a plurality of bar categories and a plurality of empty categories in turn, and pixel values of pixel points belonging to the same category in the target width stream are the same; and the decoding unit is used for decoding the bar code to be identified according to the target width stream.
9. An electronic device comprising a memory and a processor, the memory having stored therein a computer program, characterized in that the processor is adapted to implement the method of any of claims 1 to 7 when the computer program is invoked and executed.
10. A computer readable storage medium storing a computer program, which when invoked and executed by a processor, performs the method of any one of claims 1 to 7.
CN202310149642.7A 2023-02-06 2023-02-06 Method and device for identifying bar codes, electronic equipment and storage medium Pending CN116306731A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310149642.7A CN116306731A (en) 2023-02-06 2023-02-06 Method and device for identifying bar codes, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310149642.7A CN116306731A (en) 2023-02-06 2023-02-06 Method and device for identifying bar codes, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116306731A true CN116306731A (en) 2023-06-23

Family

ID=86795396

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310149642.7A Pending CN116306731A (en) 2023-02-06 2023-02-06 Method and device for identifying bar codes, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116306731A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117574930A (en) * 2024-01-15 2024-02-20 北京航空航天大学杭州创新研究院 Method and device for generating three-dimensional bar code information, electronic equipment and readable medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117574930A (en) * 2024-01-15 2024-02-20 北京航空航天大学杭州创新研究院 Method and device for generating three-dimensional bar code information, electronic equipment and readable medium
CN117574930B (en) * 2024-01-15 2024-04-12 北京航空航天大学杭州创新研究院 Method and device for generating three-dimensional bar code information, electronic equipment and readable medium

Similar Documents

Publication Publication Date Title
US9547800B2 (en) System and a method for the detection of multiple number-plates of moving cars in a series of 2-D images
US8873856B1 (en) Determining a class associated with an image
Szentandrási et al. Fast detection and recognition of QR codes in high-resolution images
US10423852B1 (en) Text image processing using word spacing equalization for ICR system employing artificial neural network
US9294665B2 (en) Feature extraction apparatus, feature extraction program, and image processing apparatus
EP3462372B1 (en) System and method for detecting optical codes with damaged or incomplete finder patterns
CN110766017B (en) Mobile terminal text recognition method and system based on deep learning
CN110598566A (en) Image processing method, device, terminal and computer readable storage medium
US20230351130A1 (en) Method for detecting and reading a matrix code marked on a glass substrate
US20090218404A1 (en) Camera based code reading
WO2015002719A1 (en) Method of improving contrast for text extraction and recognition applications
CN111860027A (en) Two-dimensional code identification method and device
WO2019209756A1 (en) System and method of decoding a barcode using machine learning
CN107403179B (en) Registration method and device for article packaging information
CN116306731A (en) Method and device for identifying bar codes, electronic equipment and storage medium
CN113971792A (en) Character recognition method, device, equipment and storage medium for traffic sign board
CN116976372A (en) Picture identification method, device, equipment and medium based on square reference code
Rampurkar et al. An approach towards text detection from complex images using morphological techniques
CN115272143A (en) Visual enhancement method, device and equipment for bar code and storage medium
EP3098758B1 (en) System and method for reading machine readable codes in transportation and logistic applications
CN115527023A (en) Image detection method, image detection device, electronic equipment and storage medium
Jia et al. Grayscale-projection based optimal character segmentation for camera-captured faint text recognition
CN112215783B (en) Image noise point identification method, device, storage medium and equipment
CN109977943B (en) Image target recognition method, system and storage medium based on YOLO
KR102430120B1 (en) Apparatus and method for improving the performance of stereo-based ROI detection algorithm

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
CB03 Change of inventor or designer information
CB03 Change of inventor or designer information

Inventor after: Wen Ding

Inventor after: Fang Shuibo

Inventor after: Fang Guocai

Inventor before: Wen Ding

Inventor before: Fang Shuiye

Inventor before: Fang Guocai