[go: up one dir, main page]

CN114611540A - One-dimensional code image area identification method based on digital image processing and electronic equipment - Google Patents

One-dimensional code image area identification method based on digital image processing and electronic equipment Download PDF

Info

Publication number
CN114611540A
CN114611540A CN202111514075.8A CN202111514075A CN114611540A CN 114611540 A CN114611540 A CN 114611540A CN 202111514075 A CN202111514075 A CN 202111514075A CN 114611540 A CN114611540 A CN 114611540A
Authority
CN
China
Prior art keywords
dimensional code
image
dimensional
boundary
images
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
CN202111514075.8A
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.)
Xiamen Codefair Semiconductor Technology Co ltd
Original Assignee
Xiamen Codefair Semiconductor 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 Xiamen Codefair Semiconductor Technology Co ltd filed Critical Xiamen Codefair Semiconductor Technology Co ltd
Priority to CN202111514075.8A priority Critical patent/CN114611540A/en
Publication of CN114611540A publication Critical patent/CN114611540A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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)
  • Image Analysis (AREA)

Abstract

The embodiment of the invention provides a one-dimensional code image area identification method based on digital image processing, a computer readable storage medium and electronic equipment, wherein the method comprises the following steps: acquiring a one-dimensional code image to be identified, and confirming a first size of the one-dimensional code image in the preset direction according to the difference value between the maximum value of the ordinate and the minimum value of the ordinate in the preset direction in a first boundary of the preset direction on the basis of the size of the pixels scribed in the preset direction and a first pixel threshold; dividing at least one row of transverse cutting images into a plurality of columns in the boundary of the one-dimensional code image along the preset direction, analyzing the coordinates of the transverse cutting images in the transverse boundary, and determining a second size and midpoint coordinates of the one-dimensional code image in the direction perpendicular to the preset direction; and identifying the image area of the one-dimensional code according to the first size, the second size and the midpoint coordinate of the one-dimensional code. Under the condition of not increasing the algorithm identification complexity, the one-dimensional code image region identification accuracy can be improved.

Description

One-dimensional code image area identification method based on digital image processing and electronic equipment
Technical Field
The embodiment of the invention relates to the technical field of information, in particular to a one-dimensional code image area identification method based on digital image processing, a computer readable storage medium and electronic equipment.
Background
With the development of scientific technology, the bar code becomes a commodity transaction language, and commodities on the market are identified by different types of bar codes. The more and more developed and improved bar code technology promotes the development of electronic commerce and improves the production and operation efficiency.
With the rapid development of computer networks and the application of devices such as smart phones, the information of commodities can be known conveniently, the authenticity of the commodities can be identified, and the information of related commodities can be known rapidly by photographing the bar codes and utilizing the networks. Therefore, it is necessary to locate and read the barcode by using the related method of image processing and recognition. By adopting the image processing method, the image quality can be improved, the influence of noise, uneven illumination, image blurring and the like on the bar code identification is reduced or eliminated, then the automatic positioning of the bar code area is realized, and the bar code is identified, read and decoded.
As the technology of bar codes is developed and gradually permeates into various technical fields, the kinds of bar codes are more and more according to the requirements of different applications, and the bar codes popular in society at present are mainly divided into two main categories: one-dimensional bar codes and two-dimensional bar codes. A one-dimensional barcode is a mark composed of a set of regularly arranged bars, spaces, and corresponding characters, and the "bars" refer to black straight lines in a barcode image. "empty" refers to a line of white in the barcode image. The bars and spaces combine to represent different information and can be identified by certain methods. Typically, its code is unique for each item. For a one-dimensional bar code, a corresponding relationship between the bar code and article information needs to be established through a database. The one-dimensional bar code only expresses information in the horizontal direction, but does not express any information in the vertical direction, and the height of the bar code is convenient for the terminal equipment to decode.
Many studies have been made on a method of positioning a barcode, and various methods have been proposed for positioning a barcode. For example, a DCT transform-based method, a method using texture characteristics of an image, a block matching method, a method using mathematical morphology, a gradient algorithm-based method, and the like are advantageous for positioning. The advantages and disadvantages in the prior art solutions are as follows:
1, positioning is carried out based on a difference method, and the method is simple and suitable for positioning bar codes in the vertical and horizontal directions; moreover, this method is not very robust to localization in complex contexts.
2, positioning is carried out based on the principle that straight lines at the edges of the bar codes are parallel: firstly, dividing an image into 32 x 32 small region blocks; then, the angle of a parallel line is obtained for each small block, and the small blocks with similar angles in a certain range are combined together to form a bar code region.
And 3, performing a rapid positioning method based on a discrete cosine transform method, mainly performing DCT (discrete cosine transform) on the image, extracting the value of an AC (alternating Current) area for processing, performing smooth detection by using a morphological method, and finally positioning the bar code by using the extracted area characteristics. This method is relatively simple. However, the weighting matrix coefficients used in the article are fixed, so this method is not robust.
4, although some algorithms are simple, the algorithm adopts a template matching algorithm, the calculation complexity is high, the calculation amount is large, and the situation that the bar code can be placed in different angular directions in the image is known, so that the template selection is relatively difficult.
5, a method based on integral images is also provided, and the area similar to a rectangle is judged; however, this method requires a certain threshold value and is therefore not necessarily suitable for any environment.
Disclosure of Invention
The embodiment of the invention provides a one-dimensional code image area identification method based on digital image processing, a computer readable storage medium and electronic equipment, which can improve the identification accuracy of the one-dimensional code image area under the condition of not increasing the algorithm identification complexity.
In a first aspect of the embodiments of the present invention, a method for identifying a one-dimensional code image region based on digital image processing is provided, which is characterized by comprising:
acquiring a one-dimensional code image to be identified,
judging the boundary of the one-dimensional code image in the preset direction based on the size of the pixels scribed in the preset direction and a first pixel threshold value; determining a difference value between a maximum value of a vertical coordinate and a minimum value of a vertical coordinate of a transverse image in a preset direction as a first size of the one-dimensional code image in the preset direction according to pixel contrast analysis of the transverse image in the preset direction within a first boundary of the preset direction;
dividing at least one row of transverse cutting images into a plurality of columns in the boundary of the one-dimensional code image along the preset direction, analyzing the pixel value corresponding to each column of images in the at least one row of transverse cutting images on the transverse coordinate column by column, determining whether the transverse cutting images are effective one-dimensional code images according to the size of a second pixel threshold value, judging the transverse boundary of the one-dimensional code images vertical to the preset direction, analyzing the coordinate of the transverse cutting images in the transverse boundary, and determining a second size and a midpoint coordinate of the one-dimensional code images vertical to the preset direction;
and identifying the image area of the one-dimensional code according to the first size, the second size and the midpoint coordinate of the one-dimensional code.
Optionally, the predetermined direction is a vertical direction and/or a horizontal direction; scribing the one-dimensional code image along the vertical direction based on the vertical direction to obtain a transverse image perpendicular to the vertical direction; and scribing the one-dimensional code image along the horizontal direction based on the horizontal direction to obtain a transverse cutting image vertical to the horizontal direction.
Further optionally, according to the number of the one-dimensional codes identified in the vertical direction and the horizontal direction, when the number of the one-dimensional codes identified in the vertical direction is greater than 0 and the number of the one-dimensional codes identified in the horizontal direction is 0, determining that the one-dimensional codes are placed transversely; when the number of the one-dimensional codes identified in the horizontal direction is greater than 0 and the number of the one-dimensional codes identified in the vertical direction is 0, determining that the one-dimensional codes are placed longitudinally; and when the number of the one-dimensional codes identified in the vertical direction is more than 0 and the number of the one-dimensional codes identified in the horizontal direction is more than 0, determining that the one-dimensional codes are placed in an inclined manner.
Optionally, the analyzing, column by column, a pixel value corresponding to each column of images in the at least one row of cross-cut images on a lateral coordinate, and a size of a second pixel threshold value, determining whether the one-dimensional code image is valid, and determining a lateral boundary of the one-dimensional code image perpendicular to the predetermined direction, further includes: and judging the spacing distance between two adjacent effective one-dimensional code images according to the threshold comparison result, and determining that the two adjacent effective one-dimensional code images belong to two different one-dimensional code regions respectively when the spacing distance is greater than a preset value.
Optionally, analyzing, column by column, a pixel value corresponding to each column of images in the at least one row of cross-cut images on a lateral coordinate, and a size of a second pixel threshold, determining whether the one-dimensional code image is a valid one-dimensional code image, and determining a lateral boundary of the one-dimensional code image perpendicular to the predetermined direction, includes: and in the direction perpendicular to the preset direction, determining the pixel value of the crosscut image in the current column at intervals of a first preset distance, comparing the pixel value with a second pixel threshold value, determining that the current column is an effective one-dimensional code image when the pixel value meets the requirement, counting the number of effective one-dimensional codes determined by each column of images in the one-dimensional code region, and determining that the current crosscut image is an effective one-dimensional code when the number value of the effective one-dimensional barcodes in the one-dimensional code region meets the preset requirement.
Further optionally, when the pixel value of the transected image in the current column is greater than the second pixel threshold, it is determined as a bar-space boundary, and the first place where the bar-space boundary appears is the one-dimensional code start boundary; the score count value satisfying a predetermined requirement includes: the count value of the boundary from the occurrence of the one-dimensional code bar to the occurrence of the empty image between the one-dimensional codes is an even number, and the count value from the occurrence of the empty image between the one-dimensional codes to the occurrence of the one-dimensional code bar is an odd number.
Optionally, the first pixel threshold and the second pixel threshold are set as rewritable parameters.
Optionally, the threshold parameter involved in the method is configured by a hardware circuit.
According to a second aspect of the embodiments of the present invention, there is provided a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and the computer program instructions, when executed by a processor, are used for implementing the method for identifying a one-dimensional code image area based on digital image processing according to any one of the first aspect.
According to a third aspect of an embodiment of the present invention, there is provided an electronic apparatus, including: a processor and a memory;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the one-dimensional code image area identification method based on digital image processing according to any one of the first aspect.
In the technical scheme of the one-dimensional code image area identification based on digital image processing, the identification algorithm is simple to realize, and the conditions of horizontal codes, vertical codes and oblique codes are considered, so that the method is comprehensive; therefore, the accuracy of identifying the one-dimensional code image area can be improved under the condition of not increasing the complexity of algorithm identification.
Drawings
Fig. 1 is a schematic diagram of a first one-dimensional code according to an embodiment of the present invention.
Fig. 2 is a schematic diagram of a second one-dimensional code according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of a third one-dimensional code according to an embodiment of the present invention.
Fig. 4 is a flowchart of a one-dimensional code image region identification method based on digital image processing according to an embodiment of the present invention.
Fig. 5 is a diagram illustrating a one-dimensional code according to an embodiment of the present invention.
FIG. 6 is a diagram illustrating a boundary of a one-dimensional code image according to an embodiment of the present invention.
FIG. 7 is a diagram illustrating an example of a cross-cut image in another one-dimensional code according to the present invention.
Fig. 8 is a flowchart of another one-dimensional code image region identification method based on digital image processing according to an embodiment of the present invention.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following detailed description of embodiments of the invention is provided in connection with the accompanying drawings (like numerals represent like elements throughout the several views of the drawings) and examples. The following examples are intended to illustrate the invention, but are not intended to limit the scope of the invention.
It will be understood by those of skill in the art that the terms "first," "second," and the like in the embodiments of the present invention are used merely to distinguish one element, step, device, module, or the like from another element, and do not denote any particular technical or logical order therebetween.
Fig. 1 is a schematic diagram of a first one-dimensional code according to an embodiment of the present invention, where the one-dimensional code corresponds to a bar code placed horizontally; fig. 2 is a schematic diagram of a second one-dimensional code according to an embodiment of the present invention, where the one-dimensional code is a longitudinally-arranged barcode; fig. 3 is a schematic diagram of a third one-dimensional code according to an embodiment of the present invention, where the one-dimensional code is a tilted barcode.
Aiming at least the technical problems that the three barcodes cannot be completely identified, the calculation complexity is high, the calculation amount is large, time is consumed and the like in the technical scheme in the prior art, the embodiment of the invention provides a method for directly obtaining the effective image area of one-dimensional codes by transversely cutting the image, comparing and analyzing the pixel value of each barcode on the transversely cut image column by column, and combining the comparison results of the pixel values in the vertical direction and the horizontal direction of the transversely cut image. And the identification of the one-dimensional barcode image area can be realized through a hardware circuit, for example, a hardware implementation scheme for determining the barcode boundary and positioning the one-dimensional barcode image by finding that the contrast difference value of continuous adjacent pixels is greater than a boundary threshold value is provided.
In order to make the present invention easier for those skilled in the art to understand, the following description is made for the features related to the one-dimensional code, but those skilled in the art should understand that these descriptions are only for the convenience of those skilled in the art to understand the present invention more easily, and not for the limitation:
the one-dimensional code indicates the arrangement rule of the bar code bars and the spaces, and the commonly used one-dimensional code coding system comprises the following steps: EAN code, 39 code, cross 25 code, UPC code, 128 code, 93 code, ISBN code, and Codabar (codebar), etc.
The effective image area of the one-dimensional code may be an image area in which one-dimensional code can be completely recorded.
The one-dimensional code image may be an image in which an effective one-dimensional code is to be recognized. The valid one-dimensional code image may be an image in which it is determined that the current image has a one-dimensional code and an internal valid one-dimensional code needs to be recognized.
The valid one-dimensional bar code is a bar code corresponding to each bar and each space in the one-dimensional code information.
Examples
As shown in fig. 4, the present embodiment provides a method for identifying an image region of a one-dimensional code based on digital image processing, the method comprising:
s110, acquiring a one-dimensional code image to be identified, for example, scanning an image with the one-dimensional code image to be identified by a camera, a scanner, or the like, or retrieving the image with the one-dimensional code image to be identified from a memory of the electronic device. And the image area of the one-dimensional code image in the whole image is analyzed according to the user requirements.
S120, judging the boundary of the one-dimensional code image in the preset direction based on the size of the pixels scribed in the preset direction and the first pixel threshold value; and determining the difference value between the maximum value of the ordinate and the minimum value of the ordinate in the predetermined direction of the transverse image as the first size of the one-dimensional code image in the predetermined direction according to pixel contrast analysis of the transverse image from the predetermined direction within the first boundary of the predetermined direction.
S130, dividing at least one row of transverse cutting images into a plurality of columns in the boundary of the one-dimensional code image along the preset direction, analyzing the pixel value corresponding to each column of images in the at least one row of transverse cutting images on the transverse coordinate column by column, determining whether the transverse cutting images are valid one-dimensional code images according to the size of a second pixel threshold value, judging the transverse boundary of the one-dimensional code images vertical to the preset direction, analyzing the coordinates of the transverse cutting images in the transverse boundary, and determining the second size and the midpoint coordinate of the one-dimensional code images vertical to the preset direction.
And S140, identifying the image area of the one-dimensional code according to the first size, the second size and the midpoint coordinate of the one-dimensional code.
Optionally, the predetermined direction is a vertical direction and/or a horizontal direction; on the basis of the vertical direction, scribing a one-dimensional code image along the vertical direction to obtain a transverse cutting image vertical to the vertical direction; based on the horizontal direction, the one-dimensional code image is scribed along the horizontal direction to obtain a cross-cut image perpendicular to the horizontal direction.
The user can select the bar code according to actual requirements, wherein the bar code which is transversely placed like the bar code in the figure 1 needs to be scanned and identified; or scanning and identifying the bar code longitudinally placed in the similar go-2; secondly, respectively marking the one-dimensional code image along the vertical direction based on the vertical direction to obtain a transverse cutting image vertical to the vertical direction; or on the basis of the horizontal direction, scribing lines along the horizontal direction on the one-dimensional code image to obtain a cross-cut image vertical to the horizontal direction.
Of course, the images in the two directions can be directly and respectively subjected to image recognition, and then the placement direction of the one-dimensional code is automatically recognized according to the data results in the two directions. And denoising the edge data of the one-dimensional code image when the inclination of the one-dimensional code is identified according to the scanning result so as to obtain a more accurate image identification result. For example, according to the number of the one-dimensional codes identified in the vertical direction and the horizontal direction, when the number of the one-dimensional codes identified in the vertical direction is greater than 0 and the number of the one-dimensional codes identified in the horizontal direction is 0, the one-dimensional codes are determined to be transversely placed; when the number of the one-dimensional codes identified in the horizontal direction is more than 0 and the number of the one-dimensional codes identified in the vertical direction is 0, determining that the one-dimensional codes are placed longitudinally; and when the number of the one-dimensional codes identified in the vertical direction is more than 0 and the number of the one-dimensional codes identified in the horizontal direction is more than 0, determining that the one-dimensional codes are obliquely placed.
Specifically, as shown in fig. 5, a transversely placed one-dimensional code is taken as an example. The four points of the ABCD are four points of a one-dimensional code image, and the three transverse tangents are L1, L2 and L3. When a transverse scribe line intersects the image, such as a tangent line moving from CD to AB, three representative tangents L1, L2, L3 appear:
l1: representing that no one-dimensional code is cut;
l2: representing a cut to exactly one-dimensional code;
l3: representing cutting through a one-dimensional code.
Firstly, judging the strip-space boundary of the one-dimensional code:
coordinates are established as in fig. 5, where the horizontal axis is the horizontal coordinate of the image horizontal pixel location; the ordinate represents the pixel value, ranging from 0 to 255(0 represents pure black, 255 represents pure white, in one-dimensional codes, black represents a "bar" and white represents a "null").
From the illustration of fig. 5, it can be seen that the pixel values of the portion transected by the position L2 in the three lateral tangents are shown by the lower dotted line in the coordinates, and the pixel values of the light color portion of the tangent are high, approaching 255; the dark part pixel values are low, close to 0 (only schematic, pixel values are not accurate). Therefore, in the critical "bar" and "empty" positions, the absolute value of the difference between two laterally adjacent pixel points is very large, and a reference for comparison, namely a threshold, is very much needed, and is named as a "pixel difference threshold". So that a value greater than this threshold value is judged as a bar empty boundary.
The first place where the bar-space boundary occurs is the one-dimensional code start boundary.
Then, the boundaries are counted:
the boundary is counted by a counter (Edge _ num) when it occurs, and when this count value is greater than a certain value (Exit _ value), it is considered that the one-dimensional code is present. This is done to prevent image interference; the other is that the number of the one-dimensional codes (or the number of bits) is required (generally greater than 13 bits), so if the number of the boundaries is too small, the interference can be considered, and the one-dimensional codes are not calculated.
Optionally, analyzing, column by column, a pixel value corresponding to each column of images in at least one row of cross-cut images on the lateral coordinate, and a size of the second pixel threshold, determining whether the one-dimensional code image is valid, and determining a lateral boundary of the one-dimensional code image perpendicular to the predetermined direction, includes: and in the direction vertical to the preset direction, determining the pixel value of the crosscut image in the current column at intervals of a first preset distance, comparing the pixel value with a second pixel threshold value, determining that the current column is an effective one-dimensional code image when the pixel value meets the requirement, counting the number of effective one-dimensional bar codes determined by each column of images in the one-dimensional code region, and determining that the current crosscut image is an effective one-dimensional code when the number value of the effective one-dimensional bar codes in the one-dimensional code region meets the preset requirement.
In addition, the counter has a rule that: the boundary count values from "bar" to "empty" are all even; the count values of the empty to bars are all odd.
Therefore, further optionally, when the pixel value of the transecting image in the current column is greater than the second pixel threshold value, the one-dimensional code starting boundary is determined as a bar-space boundary, and the first place where the bar-space boundary appears is the one-dimensional code starting boundary; the score count value satisfying the predetermined requirement includes: the count value of the boundary from the occurrence of the one-dimensional code bar to the occurrence of the empty image between the one-dimensional codes is an even number, and the count value from the occurrence of the empty image between the one-dimensional codes to the occurrence of the one-dimensional code bar is an odd number.
As shown in fig. 6, in the one-dimensional code region cut boundary calculation, it should be noted that: the adjacent boundaries of the one-dimensional code cannot be separated too much, for example, in fig. 6, the middle separation is too large and also does not meet the specification of the one-dimensional code, and the width-to-width ratio is generally 2: 1 or 3: 1, that is to say the maximum width does not exceed 3 times the width of the strip. There is a value to constrain this, namely the adjacent boundary distance threshold. So, according to this threshold, if the next strip boundary is more than the threshold apart, it can be determined as another boundary of the one-dimensional code.
Therefore, optionally, analyzing pixel values corresponding to horizontal coordinates of each column of images in at least one row of transverse images column by column, and the size of the second pixel threshold, determining whether the one-dimensional code image is valid, and determining a horizontal boundary of the one-dimensional code image perpendicular to the predetermined direction, further includes: and judging the spacing distance between two adjacent effective one-dimensional code images according to the threshold comparison result, and determining that the two adjacent effective one-dimensional code images belong to two different one-dimensional code images respectively when the spacing distance is greater than a preset value.
Regarding the height of the one-dimensional code region, as in the corresponding technical solutions provided in fig. 5 and 4, if the image is intersected from top to bottom, the largest and smallest difference value of the vertical coordinates in all the tangents satisfying the one-dimensional code characteristics is the height of the one-dimensional code region.
Regarding the midpoint of the one-dimensional code, as in the corresponding solutions provided in fig. 5 and fig. 4, the start coordinate and the end coordinate of the transverse tangent of the one-dimensional code region can be obtained, so the midpoint coordinate (heng _ x, heng _ y) of each transverse tangent can be calculated.
However, as shown in the figure, the midpoint coordinates of each transverse tangent line are not necessarily on one vertical line, and there is a problem of the angle of the one-dimensional code image, and therefore, it is necessary to calculate the actual midpoint coordinates (pox _ one, poy _ one) of the one-dimensional code image using the midpoint coordinates and the number of each transverse tangent line.
And finally, positioning the one-dimensional code region:
the range of the one-dimensional code region can be determined by obtaining the point coordinates of the one-dimensional code and the width and the height of the one-dimensional code according to the processing. It should be noted that, in the processes, some tolerance and threshold values are implemented by registers in the specific implementation process, and for these parameters to be modified, for example, in fig. 7, the regions L5 to L8 may all be regions satisfying the one-dimensional code condition, but when calculating the midpoint, the values of the upper and lower side edge portions are removed, and only the coordinates L6 to L7 are used for calculation.
Therefore, the first pixel threshold and the second pixel threshold are set as rewritable parameters. And the threshold parameters involved in the above method are configured by hardware circuitry. Of course, the threshold parameter is not limited, and other parameters may be configured by a hardware circuit.
Of course, after the one-dimensional code is located, the parameter value corresponding to the barcode can be automatically determined according to the area pixel value of each bar in the previous one-dimensional code. The parameter values of the one-dimensional code region can also be calculated by other calculation tools according to requirements.
In addition, according to actual requirements, after the one-dimensional code region is located, the image of the one-dimensional code region can be intercepted, and archived and backed up, or associated with other files and data and stored in a binding manner.
Regarding the configuration of the hardware circuit, an alternative implementation is as follows:
the specific realization circuit is as follows:
some parameter settings used in the circuit implementation process are as follows:
a RAM unit: heng _ x, heng _ y, pox _ one, poy _ one.
Value set by register:
1, pixel difference threshold: pix _ value;
2, adjacent boundary distance threshold: dis _ th;
3, satisfying a threshold less than the number of dis _ th: thre _ num;
4, considering that the number of dot _ x _ number needs to be satisfied when the one-dimensional code exists: exit _ value;
the amount used in the calculation process is as follows:
1, counting the number of the boundaries of the black bars in the one-dimensional code: edge _ num;
2, number exceeding thre _ num: dot _ x _ number;
3, starting barcode boundary position: sum _ dis;
and 4, saving the row number corresponding to each dot _ x _ number: heng _ y;
5, saving the column center position corresponding to each dot _ x _ number: heng _ x;
6, the number of suspected one-dimensional code areas: num _ dot _ x.
Circuit implementation process description:
4-2-1, the position of a one-dimensional code in an image can be divided into three cases: transverse, longitudinal, oblique.
4-2-2, first the transverse placement is discussed,
a) assuming that the image has depth row width columns;
as shown in fig. 8, the specific identification method includes:
b) and polling i row and j column, reading pixel values corresponding to j column and j +1 column, and when the difference value of the pixel values of the two columns is greater than pix _ value, considering that a barcode boundary appears, and marking the column number j as heng _ dot _ x. If the boundary count value edge _ num is an odd number, dot _ x _1 is j, and if the boundary count value edge _ num is an even number, dot _ x _0 is j; then adding 1 to edge _ num;
c) if edge _ num >1, or j is width-2,
take dis _01 ═ abs (dot _ x _0-dot _ x _1), if dis _01< dit _ th is true, determine if heng _ number is 0,
if the value is 0, storing the heng _ dot _ x into the start _ x, and adding 1 to the heng _ number by self; if not 0, heng _ number is directly self-incremented by 1. If dis _01< dit _ th is not established, continuously judging whether heng _ number > thre _ num is established or not, if so, executing:
heng _ x [ dot _ x _ number ] (sum _ dis + heng _ dot _ x)/2; heng _ y [ dot _ x _ number ] ═ i; dot _ x _ number + +; if not, executing: dot _ x _0 is 0; dot _ x _1 is 0; heng _ number is 0; heng _ dot _ x is 0; edge _ num is 0;
d) if edge _ num is 1, saving the value of heng _ dot _ x in sum _ dis;
e) if not, continuously judging whether i and j are in the range, if so, continuously polling, if the maximum value is reached, finishing polling, and finishing image polling; the values of dot _ x _ number, heng _ x [ i ], heng _ y [ i ] are obtained.
f) After the image is polled, if dot _ x _ number > exit _ value, g) is carried out, otherwise, the round is directly ended;
g) to reduce interference, the first and last k data of dot _ x _ number are rounded off. K < i < dot _ x _ number-k in order starting with i ═ k, k < j < k +1< j < dot _ x _ number-k +1 in order starting with i +1, and then the sum heng _ x [ j ]: sum _ x + ═ heng _ x [ j ]; summation heng _ y [ j ]: sum _ y + ═ heng _ y [ j ]; sum _ num _ x is added by 1 for each summation. When j is accumulated to dot _ x _ number-k and sum _ num _ x >30, the values of sum _ x/sum _ num _ x are calculated and then stored in the memory pox _ one [ num _ dot _ x ]; also sum _ y/sum _ num _ x are stored in the memory poy _ one [ num _ dot _ y ]. The loop is tripped out, num _ dot _ x is incremented by 1.
It should be noted that, in the above parameter configuration, the analogy between the vertical placement and the horizontal placement is just to invert xy, so as to obtain num _ dot _ y, pox _ one _ y [ i ], poy _ one _ y [ i ].
In addition, there are three cases according to the values of num _ dot _ x and num _ dot _ y:
1) explaining that the one-dimensional code is transversely placed, and obtaining the position of the one-dimensional code according to the coordinate corresponding to the minimum value and the maximum value of dot _ x _ number, wherein num _ dot _ x is greater than 0 and num _ dot _ y is equal to 0;
2) explaining the longitudinal placement of the one-dimensional code, and obtaining the position of the one-dimensional code according to the coordinate corresponding to the minimum value and the maximum value of dot _ y _ number, wherein num _ dot _ x is 0 and num _ dot _ y is more than 0;
3) and num _ dot _ x >0 and num _ dot _ y >0, which are used for indicating that the one-dimensional code is obliquely arranged, and obtaining the position of the one-dimensional code according to the extreme value coordinates corresponding to the minimum value and the maximum value of dot _ x _ number and the minimum value and the maximum value of dot _ y _ number.
Therefore, in the technical scheme provided by the embodiment, the hardware circuit is faster to realize than a software algorithm; the protocol selection is flexible to configure, and the applicability is strong; the implementation is simple, the conditions of horizontal code, longitudinal code and oblique code are considered, and the operation is comprehensive; and the hardware implementation through DMA, a computing unit, RAM storage and the like does not occupy software resources.
The present embodiment also provides an electronic device, which includes: a processor and a memory;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the one-dimensional code image area identification method based on digital image processing according to any one of the first aspect.
According to another aspect of the present embodiment, there is provided a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, which when executed by a processor, are used for implementing the one-dimensional code image region identification method based on digital image processing according to any one of the first aspect.
As shown in fig. 9, the electronic device 900 may include a memory and a processor. In particular, the electronic device 900 includes one or more processors, communication elements, and the like, for example: one or more Central Processing Units (CPUs) 901, and/or one or more business processors (GPUs) 913 and the like, which can perform various appropriate actions and processes according to executable instructions stored in a Read Only Memory (ROM)902 or loaded from a storage section 908 into a Random Access Memory (RAM) 903. The communication elements include a communication component 912 and/or a communication interface 909. Among them, the communication component 912 may include, but is not limited to, a network card, which may include, but is not limited to, an ib (infiniband) network card, the communication interface 909 includes a communication interface of a network interface card such as a LAN card, a modem, or the like, and the communication interface 909 performs communication processing via a network such as the internet.
The processor can communicate with the read-only memory 902 and/or the random access memory 903 to execute the executable instructions, and is connected to the communication component 912 through the communication bus 904 and communicates with other target devices through the communication component 912, thereby completing the operations corresponding to any one-dimensional code identification method provided by the embodiments of the present invention.
In addition, in the RAM 903, various programs and data necessary for the operation of the device can also be stored. The CPU 901 or GPU 913, ROM 902, and RAM 903 are connected to each other through a communication bus 904. The ROM 902 is an optional module in case of the RAM 903. The RAM 903 stores or writes executable instructions into the ROM 902 at runtime, and the executable instructions cause the processor to perform operations corresponding to the above-described communication method. An input/output (I/O) interface 905 is also connected to communication bus 904. The communication component 912 may be integrated or may be configured with multiple sub-modules (e.g., IB cards) and linked over a communication bus.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication interface 909 including a network interface card such as a LAN card, a modem, or the like. A drive 910 is also connected to the I/O interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
It should be noted that the architecture shown in fig. 9 is only an optional implementation manner, and in a specific practical process, the number and types of the components in fig. 9 may be selected, deleted, added or replaced according to actual needs; in different functional component settings, separate settings or integrated settings may also be used, for example, the GPU and the CPU may be separately set or the GPU may be integrated on the CPU, the communication element may be separately set, or the GPU and the CPU may be integrated, and so on. These alternative embodiments are all within the scope of the present invention.
The electronic device according to the embodiment of the present invention may be configured to implement the corresponding one-dimensional code identification method in the above embodiment, and each device in the electronic device may be configured to perform each step in the above method embodiment, for example, the one-dimensional code identification method described above may be implemented by a processor of the electronic device calling a related instruction stored in a memory, and for brevity, no further description is provided here.
In the technical scheme of the one-dimensional code image area identification based on digital image processing, the identification algorithm is simple to realize, and the conditions of horizontal codes, vertical codes and oblique codes are considered, so that the method is comprehensive; therefore, the accuracy of identifying the one-dimensional code image area can be improved under the condition of not increasing the complexity of algorithm identification.
According to an embodiment of the present invention, the process described above with reference to the flowchart may be implemented as a computer program product. For example, embodiments of the invention include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing a method as illustrated in the flow chart, the program code may include instructions corresponding to performing steps of a method as provided by embodiments of the invention, e.g., instructions for receiving authenticated voice data of a user; the voice print identity authentication of the authentication security level corresponding to the current related business operation is carried out on the user according to the authentication voice data, and an identity authentication result is determined; and the instruction is used for executing the service operation of the user according to the identity authentication result indicating that the authentication is passed. In such an embodiment, the computer program may be downloaded and installed from a network via the communication element, and/or installed from the removable medium 911. Which when executed by a processor performs the functions disclosed in the methods of embodiments of the invention.
The method and apparatus, the electronic device and the storage medium of the present invention may be implemented in many ways. For example, the method and apparatus, the electronic device, and the storage medium of the embodiments of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the embodiments of the present invention are not limited to the order specifically described above unless specifically stated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as programs recorded in a recording medium, the programs including machine-readable instructions for implementing methods according to embodiments of the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to an embodiment of the present invention.
The description of the present embodiments has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed, and many modifications and variations will be apparent to those skilled in the art. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.

Claims (10)

1. A one-dimensional code image area identification method based on digital image processing is characterized by comprising the following steps:
acquiring a one-dimensional code image to be identified,
judging the boundary of the one-dimensional code image in the preset direction based on the size of pixels scribed in the preset direction and a first pixel threshold value; determining a difference value between a maximum value of a vertical coordinate and a minimum value of a vertical coordinate of a transverse image in a preset direction as a first size of the one-dimensional code image in the preset direction according to pixel contrast analysis of the transverse image in the preset direction within a first boundary of the preset direction;
dividing at least one row of transverse cutting images into a plurality of columns in the boundary of the one-dimensional code images along the preset direction, analyzing the pixel value corresponding to each column of images in the at least one row of transverse cutting images on the transverse coordinate column by column, determining whether the transverse cutting images are effective one-dimensional code images according to the size of a second pixel threshold value, judging the transverse boundary of the one-dimensional code images vertical to the preset direction, analyzing the coordinates of the transverse cutting images in the transverse boundary, and determining the second size and the midpoint coordinate of the one-dimensional code images vertical to the preset direction;
and identifying the image area of the one-dimensional code according to the first size, the second size and the midpoint coordinate of the one-dimensional code.
2. The method according to claim 1, wherein the predetermined direction is a vertical direction and/or a horizontal direction; scribing the one-dimensional code image along the vertical direction based on the vertical direction to obtain a transverse image perpendicular to the vertical direction; and scribing the one-dimensional code image along the horizontal direction based on the horizontal direction to obtain a transverse cutting image vertical to the horizontal direction.
3. The method according to claim 2, wherein according to the number of the one-dimensional codes identified in the vertical direction and the horizontal direction, when the number of the one-dimensional codes identified in the vertical direction is greater than 0 and the number of the one-dimensional codes identified in the horizontal direction is 0, the one-dimensional codes are determined to be placed horizontally; when the number of the one-dimensional codes identified in the horizontal direction is greater than 0 and the number of the one-dimensional codes identified in the vertical direction is 0, determining that the one-dimensional codes are placed longitudinally; and when the number of the one-dimensional codes identified in the vertical direction is more than 0 and the number of the one-dimensional codes identified in the horizontal direction is more than 0, determining that the one-dimensional codes are obliquely placed.
4. The method according to any one of claims 1-3, wherein analyzing, column by column, a pixel value corresponding to each column image in the at least one row of cross-cut images on a lateral coordinate, and a size of a second pixel threshold value, determining whether the one-dimensional code image is valid, and determining that the one-dimensional code image is perpendicular to a lateral boundary of the predetermined direction, further comprises: and judging the spacing distance between two adjacent effective one-dimensional code images according to the threshold comparison result, and determining that the two adjacent effective one-dimensional code images belong to two different one-dimensional code images respectively when the spacing distance is greater than a preset value.
5. The method according to claim 1, wherein analyzing, column by column, pixel values of each of the at least one row of transverse images corresponding to transverse coordinates, and a size of a second pixel threshold value, to determine whether the one-dimensional code image is valid, and determining a transverse boundary of the one-dimensional code image perpendicular to the predetermined direction comprises: and in the direction perpendicular to the preset direction, determining the pixel value of the crosscut image in the current column at intervals of a first preset distance, comparing the pixel value with a second pixel threshold value, determining that the current column is an effective one-dimensional code image when the pixel value meets the requirement, counting the number of effective one-dimensional bar codes determined by each column of images in the one-dimensional code region, and determining that the current crosscut image is an effective one-dimensional code when the number value of the effective one-dimensional bar codes in the one-dimensional code region meets the preset requirement.
6. The method of claim 5, wherein a bar-space boundary is determined when the pixel value of the transected image in the current column is greater than the second pixel threshold, and the first place where the bar-space boundary appears is a start boundary of the one-dimensional code; the score count value satisfying a predetermined requirement includes: the count value of the boundary from the occurrence of the one-dimensional code bar to the occurrence of the one-dimensional code space is an even number, and the count value from the occurrence of the one-dimensional code space to the occurrence of the one-dimensional code bar is an odd number.
7. The method of claim 1, wherein the first pixel threshold and the second pixel threshold are set as rewritable parameters.
8. The method according to any of claims 1-3 or 5-7, characterized in that the threshold parameters involved in the method are configured by hardware circuits.
9. A computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, which when executed by a processor, are used for implementing the method for identifying one-dimensional code image regions based on digital image processing according to any one of claims 1 to 8.
10. An electronic device, comprising: a processor and a memory;
the memory is used for storing at least one executable instruction which causes the processor to execute the one-dimensional code image area identification method based on digital image processing according to any one of claims 1-8.
CN202111514075.8A 2021-12-10 2021-12-10 One-dimensional code image area identification method based on digital image processing and electronic equipment Pending CN114611540A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111514075.8A CN114611540A (en) 2021-12-10 2021-12-10 One-dimensional code image area identification method based on digital image processing and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111514075.8A CN114611540A (en) 2021-12-10 2021-12-10 One-dimensional code image area identification method based on digital image processing and electronic equipment

Publications (1)

Publication Number Publication Date
CN114611540A true CN114611540A (en) 2022-06-10

Family

ID=81858264

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111514075.8A Pending CN114611540A (en) 2021-12-10 2021-12-10 One-dimensional code image area identification method based on digital image processing and electronic equipment

Country Status (1)

Country Link
CN (1) CN114611540A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115270837A (en) * 2022-09-27 2022-11-01 北京紫光青藤微系统有限公司 One-dimensional code recognition equipment and recognition method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521558A (en) * 2011-11-18 2012-06-27 深圳市宝捷信科技有限公司 Bar code identifying method and device
US20180114323A1 (en) * 2016-10-26 2018-04-26 Datalogic Automation, Inc. Data processing reduction in barcode reading systems with overlapping frames
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111476050A (en) * 2020-04-02 2020-07-31 北京致胜宏达科技有限公司 Bar code identification method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521558A (en) * 2011-11-18 2012-06-27 深圳市宝捷信科技有限公司 Bar code identifying method and device
US20180114323A1 (en) * 2016-10-26 2018-04-26 Datalogic Automation, Inc. Data processing reduction in barcode reading systems with overlapping frames
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111476050A (en) * 2020-04-02 2020-07-31 北京致胜宏达科技有限公司 Bar code identification method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115270837A (en) * 2022-09-27 2022-11-01 北京紫光青藤微系统有限公司 One-dimensional code recognition equipment and recognition method

Similar Documents

Publication Publication Date Title
US8805077B2 (en) Subject region detecting apparatus
CN104951726B (en) Method and device for QR Quick Response Code position sensings
WO2014160433A2 (en) Systems and methods for classifying objects in digital images captured using mobile devices
CN106485183A (en) A kind of Quick Response Code localization method and system
EP3462372B1 (en) System and method for detecting optical codes with damaged or incomplete finder patterns
US8923610B2 (en) Image processing apparatus, image processing method, and computer readable medium
EP2973226A1 (en) Classifying objects in digital images captured using mobile devices
CN108021837B (en) Bar code detection method, bar code detection device and electronic equipment
CN110348264A (en) A kind of QR image in 2 D code bearing calibration and system
CN111259680B (en) Two-dimensional code image binarization processing method and device
US9098764B2 (en) Image-based barcode reader
US20150302236A1 (en) Method and device for identifying a two-dimensional barcode
CN112651953A (en) Image similarity calculation method and device, computer equipment and storage medium
CN118520893B (en) A method, device and storage medium for barcode label recognition applied to AOI
CN117540762A (en) Bar code identification method, device, equipment and readable storage medium
CN108256375A (en) A kind of one-dimensional bar code scan method
CN114611540A (en) One-dimensional code image area identification method based on digital image processing and electronic equipment
JP6144892B2 (en) Image processing apparatus, image processing method, and program
WO2014210317A1 (en) Determining barcode locations in documents
CN115410191A (en) Text image recognition method, device, equipment and storage medium
CN111753573B (en) Two-dimensional code image recognition method and device, electronic equipment and readable storage medium
JP2023046978A (en) Verification device and program
CN109389000B (en) Bar code identification method and computer applying same
CN116503871A (en) Character segmentation preprocessing method, terminal device and computer-readable storage medium
CN112199972A (en) Method for identifying positioning point

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20220610