CN110348266B - Method and device for recognizing and reading dot matrix code image - Google Patents

Method and device for recognizing and reading dot matrix code image Download PDF

Info

Publication number
CN110348266B
CN110348266B CN201910655799.0A CN201910655799A CN110348266B CN 110348266 B CN110348266 B CN 110348266B CN 201910655799 A CN201910655799 A CN 201910655799A CN 110348266 B CN110348266 B CN 110348266B
Authority
CN
China
Prior art keywords
dot matrix
image
matrix code
code
code image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910655799.0A
Other languages
Chinese (zh)
Other versions
CN110348266A (en
Inventor
刘燕
刘春祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huiyan Zhixing Technology Co ltd
Original Assignee
Beijing Huiyan Zhixing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Huiyan Zhixing Technology Co ltd filed Critical Beijing Huiyan Zhixing Technology Co ltd
Priority to CN201910655799.0A priority Critical patent/CN110348266B/en
Publication of CN110348266A publication Critical patent/CN110348266A/en
Application granted granted Critical
Publication of CN110348266B publication Critical patent/CN110348266B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30168Image quality inspection

Abstract

The invention discloses a method and a device for recognizing and reading a dot matrix code image, wherein the method comprises the following steps: the preprocessing is carried out on the dot matrix code image, so that the image quality is improved, and the influence of uneven illumination, complex background and noise interference on the dot matrix code identification noise in the prior art is solved; and then, locating the region where the code point is located in the dot matrix code image, improving the accuracy of finding the code point, and finally, reading the region where the code point is located. Therefore, the accuracy of recognizing the dot matrix code image is improved through the method.

Description

Method and device for recognizing and reading dot matrix code image
Technical Field
The present invention relates to the field of image processing, and in particular, to a method and an apparatus for recognizing and reading a dot matrix code image.
Background
With the development of graphic coding technology, optical geometric patterns for recording feature data, which are usually blocks of different colors or are formed of sparse lattices, are regularly arranged on various printing media, and the geometric patterns can be used for recording feature data symbol information, wherein the patterns formed of the sparse lattices are lattice code patterns.
The dot matrix code pattern is similar to the two-dimensional code pattern, and when the dot matrix code pattern is encoded, the dot matrix code pattern contains certain information, and the information of the dot matrix code pattern can be obtained by decoding the dot matrix code pattern.
However, since the code points in the dot matrix code pattern are smaller, the dot matrix code pattern is easily affected by external factors when being identified, so that the identification accuracy of the dot matrix code is low.
Disclosure of Invention
In view of this, the embodiment of the invention discloses a method and a device for recognizing and reading a dot matrix code image, and in this embodiment, the method includes:
acquiring a dot matrix code image to be processed, and preprocessing the dot matrix code image;
detecting the dot matrix code image and positioning the area where the code points are located;
and reading the area where the code point is located.
Optionally, the preprocessing the dot matrix code image includes:
graying the dot matrix code image to generate a gray image;
performing quality evaluation on the gray level image of the dot matrix code image, and determining the definition of the dot matrix code image according to an evaluation result;
under the condition that the definition of the dot matrix code image meets the preset condition, performing illumination compensation on the dot matrix code image;
and morphological filtering is carried out on the dot matrix code image.
Optionally, the morphological filtering of the dot matrix code image includes:
performing binarization processing on the dot matrix code image;
performing open operation processing on the dot matrix code image;
and performing expansion operation on the dot matrix code image.
Optionally, the detecting the dot matrix code image locates an area where the code point is located, including:
traversing the dot matrix code image by adopting a sliding window with a gradient size;
screening sliding windows meeting a first preset condition according to the average gray value of each sliding window to obtain a plurality of first image areas meeting the first preset condition;
dividing each first image region into a plurality of sub-regions for each first image region;
screening out subareas with average gray values meeting a second preset condition;
and merging all screened subareas meeting the second preset condition.
Optionally, the screening the sliding window according to the average gray value of each sliding window to obtain a plurality of first image areas according to the first preset condition includes:
calculating an average gray value of an image area in the sliding window;
screening out an image area with the average gray value between a first upper threshold value and a first lower threshold value;
performing corrosion operation on the image area with the screened average gray value between the first upper threshold value and the first lower threshold value;
and screening out areas with average gray values smaller than a second threshold value from the corroded image areas to obtain a plurality of first image areas.
Optionally, the second preset condition is that the difference between the average gray values of the screened subarea and other subareas is smaller than a preset third threshold value, and the difference between the average gray values of the screened subarea and the first image area is smaller than a preset fourth threshold value.
Optionally, the identifying the area where the code point is located includes:
detecting a data point group in the region where the code point is located;
taking the code points except the data point group in the region where the code points are located as candidate reference point groups, and determining the reference point groups according to the geometric relationship between the reference point groups and the nominal positions;
determining the row and column of each data point group according to the position of the reference point group to obtain a dot matrix code pattern;
and reading the value of each data point group in the dot matrix code graph to obtain the code value of the dot matrix code graph.
Optionally, the detecting the data point group in the area where the code point is located includes:
performing binarization processing on the region where the code points are located to obtain a binary image containing a plurality of connected domains;
acquiring the number of pixel points contained in each connected domain;
screening out connected domains with the number of the pixel points within a preset first range;
taking two connected domains closest to each other as a group, calculating the distance values of the two connected domains in each group, and calculating the average value of all the distance values;
if the distance value of the two connected domains in each group is smaller than the average value of the distance values, the connected domains in the group are used as a code point;
if the connected domain is larger than a preset third threshold value, the connected domain is used as two code points;
the two closest code points are taken as a data point group.
Optionally, the determining the row and the column where each data point group is located according to the position of the reference point group includes:
calculating three nominal positions closest to the nominal position of the reference point;
calculating the width and height of the point pattern sub-block according to the three nominal positions closest to the nominal positions of the reference points;
calculating the distance between the nominal position of each data point group and the nominal position of the reference point, and representing the distance as a reference distance;
calculating a first multiple relation between the reference distance and the width of the dot pattern sub-block, and calculating a second multiple relation between the reference distance and the height of the dot pattern sub-block;
and determining the row and the column where the data point group is located according to the first multiple relation and the second multiple relation.
The embodiment of the invention discloses a dot matrix code image reading device, which comprises:
the preprocessing unit is used for acquiring a dot matrix code image to be processed and preprocessing the dot matrix code image;
the positioning unit is used for detecting the dot matrix code image and positioning the area where the code point is located;
and the reading unit is used for reading the area where the code point is located.
The embodiment of the invention discloses a method and a device for recognizing and reading a dot matrix code image, which improve the image quality by preprocessing the dot matrix code image, and solve the problems of uneven illumination, complex background and noise interference in the prior art; and then, locating the region where the code point is located in the dot matrix code image, improving the accuracy of finding the code point, and finally, reading the region where the code point is located. Therefore, the accuracy of recognizing the dot matrix code image is improved through the method.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a method for reading a dot matrix code image according to an embodiment of the present invention;
FIG. 2 is a flow chart of an area where a positioning code point is located;
FIG. 3 shows a schematic diagram of region division;
fig. 4 shows a schematic diagram of a dot matrix code pattern;
FIG. 5 is a schematic diagram showing a flow of reading a dot matrix code pattern;
fig. 6 shows still another schematic diagram of a dot matrix code pattern;
fig. 7 is a schematic structural diagram of a device for recognizing and reading a dot matrix code image according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a flow chart of a method for recognizing and reading a dot matrix code image according to an embodiment of the present invention is shown, where in this embodiment, the method includes:
s101, acquiring a dot matrix code image to be processed, and preprocessing the dot matrix code image;
in this embodiment, in the generating process of the dot matrix code image, problems such as uneven illumination and noise interference are unavoidable, and the quality of the dot matrix code image is affected by the existence of the problems, and the quality of the dot matrix code image is also affected by the identification of the dot matrix code image. Therefore, in order to improve the accuracy of reading the dot matrix code image, the following operations may be performed on the dot matrix code image:
graying the dot matrix code image to generate a gray image;
performing quality evaluation on the gray level image of the dot matrix code image, and determining the definition of the dot matrix code image according to an evaluation result;
under the condition that the definition of the dot matrix code image meets the preset condition, performing illumination compensation on the dot matrix code image;
and morphological filtering is carried out on the dot matrix code image.
In this embodiment, the gray scale processing may be performed on the dot matrix code image according to the following formula 1):
1)S=(0.299*B+0.587*G+0.114*R);
in this embodiment, there are many methods for evaluating the quality of the gray image of the dot matrix code image, and in this embodiment, the quality of the gray image in S11 may be evaluated by, for example, a classifier composed of thirteen quality evaluation functions such as a Brenner gradient function, tenangrad gradient function, laplacian gradient function, SMD2, variance function, volloth function, entropy, and secondary blurring.
The purpose of the quality evaluation of the dot matrix code image is to determine the sharpness of the dot matrix code image, and if the sharpness of the dot matrix code image is low, it may be that the print quality is problematic, and reading is not required.
The definition may be determined by determining a quality evaluation level, if the image quality level is lower than a preset level, the definition is low, reading is not required, and for an image quality equal to or higher than the preset level, that is, the definition is higher, a subsequent step may be performed.
In this embodiment, there are many methods for performing illumination compensation on an image, for example, retinex enhancement, histogram equalization, and the like, but in order to enhance details of bright places and dark places, the following method may be used to perform illumination compensation on an image:
the details of bright places and dark places in the image are effectively mined and enhanced by using the NLEMD, and the rest components of the NLEMD are enhanced by using a Retinex algorithm.
In this embodiment, a morphological filtering manner may be used to eliminate noise in an image and enhance the significance of code points, which specifically includes:
performing binarization processing on the dot matrix code image;
performing open operation processing on the dot matrix code image;
and performing expansion operation on the dot matrix code image.
In this embodiment, the binary image of the dot matrix code image may include a small amount of noise points, where the noise points are smaller than the code points and distributed irregularly, and a portion of noise may be eliminated by using a one-time open operation, and the code points may be enhanced by using a one-time expansion operation, so that the code points become substantial.
S102: detecting the dot matrix code image and positioning the area where the code points are located;
in this embodiment, in addition to the dot matrix code pattern, an image may further include other information, so that in order to avoid the influence of other information on the reading of the code points, the area where the code points are located may be located first, and then the code points are read, as shown in fig. 2, S102 includes:
s201, traversing the dot matrix code image by adopting a sliding window with a gradient size;
a step-down size is understood to mean that the maximum value of the sliding window size and the minimum value of the sliding window size are determined and the sliding window size is changed in a stepwise decreasing manner each time, for example in a decreasing order of 2 each time.
S202, screening sliding windows meeting a first preset condition according to the average gray value of each sliding window to obtain a plurality of first image areas meeting the first preset condition;
wherein, the screening of the first preset condition may include:
calculating an average gray value of an image area in the sliding window;
screening out an image area with the average gray value between a first upper threshold value and a first lower threshold value;
performing corrosion operation on the image area with the screened average gray value between the first upper threshold value and the first lower threshold value;
and screening out areas with average gray values smaller than a second threshold value from the corroded image areas to obtain a plurality of first image areas.
The first upper threshold and the second threshold may be obtained through experiments, and are not limited in this embodiment.
S203, dividing each first image area into a plurality of subareas for each first image area;
s204: screening out subareas with average gray values meeting a second preset condition;
in this embodiment, the second preset condition may be that the difference between the average gray values of the screened sub-region and the other sub-regions is smaller than a preset third threshold value, and the difference between the average gray values of the screened sub-region and the first image region is smaller than a preset fourth threshold value.
Illustrating: a first image area is divided equally into four sub-areas and the middle cross area is taken as part of five parts as shown in fig. 3. The average gray value of each sub-region (region 1, region 2, region 3, region 4, and region 5) is calculated, and it is determined whether the average gray value between each sub-region is similar, and whether the average gray value of each sub-region is similar to the gray value of the first image region 6. Wherein, for region 1, it is determined whether the difference of the average gray levels of region 1 and region 2 is close, whether the difference of the average gray levels of region 1 and region 3 is close, whether the average gray levels of region 1 and region 4 is close, whether the average gray levels of region 1 and region 5 is close, and whether the gray values of region 1 and first image region 6 are close.
And S205, merging all screened subareas meeting the second preset condition.
In this embodiment, the merging process may include: in the process of screening the sub-regions, marking the screened sub-regions each time when a new sub-region is screened, comparing the screened new sub-region with the screened sub-regions, combining if intersection exists in the horizontal, vertical and inclined directions, recording if the intersection cannot be performed, and comparing again after a new sub-region is screened again.
And S103, identifying and reading the area where the code point is located.
In this embodiment, the dot matrix code pattern includes: a plurality of image sub-blocks, each including a set of data points and a nominal position, as shown in fig. 4. The dot pattern block 100 comprises a plurality of sub-units 101, each sub-unit comprising a data point nominal position 102, two code points being included on both sides of each data point nominal position, two code points on both sides of each data point nominal position being represented as a data point group 103, one reference point group 104 being included directly above a reference point nominal position 104.
The recognition of the dot matrix code pattern can be understood as the recognition of the data point group in each pattern sub-block, specifically as shown in fig. 5, S103 includes:
s501: detecting a data point group in the region where the code point is located;
wherein S501 includes:
performing binarization processing on the region where the code points are located to obtain a binary image containing a plurality of connected domains;
acquiring the number of pixel points contained in each connected domain;
screening out connected domains with the number of the pixel points within a preset first range;
taking two connected domains closest to each other as a group, calculating the distance values of the two connected domains in each group, and calculating the average value of all the distance values;
if the distance value of the two connected domains in each group is smaller than the average value of the distance values, the connected domains in the group are used as a code point;
if the connected domain is larger than a preset third threshold value, the connected domain is used as two code points;
the two closest code points are taken as a data point group.
In this embodiment, each data point group in the dot matrix code pattern is formed in pairs, and the distance between the two data point groups is the nearest, and in this embodiment, the data point groups can be determined by the distance between the code points used for pairing.
First, the first time a code point available for pairing is found, including: counting the number of pixel points contained in each connected domain, and screening out target connected domains with the number of pixel points larger than a preset first range; for any one target connected domain, calculating the distance between the target connected domain and other target connected domains, screening out the target connected domain closest to the target connected domain, and taking the two connected domains closest to the target connected domain as a group. And calculating the distance value of each group of connected domains, and calculating the average value of all the distance values.
Then, according to the selected connected domain, determining all code points in the area where the code points are located, including: judging the relation between the size of each connected domain and a preset third threshold value, taking the connected domain larger than the third threshold value as two code points, for example, dividing the connected domain into two parts, wherein each part is taken as one connected domain, for example, the connected domain can be divided into an upper part and a lower part or can be divided into a left part and a right part; and judging the relation between the distance between the two connected domains in each group and the average value of the distance values, and taking the two connected domains in each group as a code point if the distance between the two connected domains in each group is smaller than the average value of the distance values.
The center distance between each code point and other code points is calculated, wherein the center distance can be understood as the distance from the center of one code point to the center of another code point.
For any one code point, calculating the center distance between the code point and other code points, taking the code point corresponding to the minimum center distance as a matched code point of the code point, taking the two code points as a data point group, namely for any one code point, searching for the other code point closest to the code point, and taking the two code points as a data point group.
S502: taking the code points except the data point group in the region where the code points are located as candidate reference point groups, and determining the reference point groups according to the geometric relationship between the reference point groups and the nominal positions;
in this embodiment, a dot matrix code pattern includes a data point group and a reference point group, and then in the region where the code points are located, other code points than the data point group are possible to be the reference point group, for example, the reference point group indicated as candidates.
In the candidate reference point groups, a reference point group may be included in a dot code pattern, and a plurality of reference point groups may be included, but unlike the data point groups, the reference point groups do not appear in pairs, and each reference point group is located directly above the nominal position, and then the actual reference point group may be determined from the candidate reference point groups according to the relationship between the nominal position and the reference point groups.
Further, when|cd| represents the distance between C, D and |ab| represents the distance between A, B.
After the reference point group is determined, it is also necessary to rotate the dot pattern according to the reference point group so that the dot pattern is in a predetermined positive direction.
S503: determining the row and column of each data point group according to the position of the reference point group to obtain a dot matrix code pattern;
wherein three nominal positions closest to the nominal positions of the reference points are calculated, as shown in fig. 6, and the widths and heights of the dot pattern sub-blocks are calculated from the three nominal positions; calculating the distance between the nominal position of each data point group and the nominal position of the reference point, and representing the distance as a reference distance; calculating a first multiple relation between the reference distance and the width of the dot pattern sub-block, and calculating a second multiple relation between the reference distance and the height of the dot pattern sub-block; and determining the row and the column where the data point group is located according to the first multiple relation and the second multiple relation.
Illustrating: as shown in fig. 6, point D is the reference point nominal position, A, C, B is the three nominal positions closest to the reference point nominal position, thenThe difference between the y-coordinate of a and the y-coordinate of C is equal to high.
S504: and reading the value of each data point group in the dot matrix code graph to obtain the code value of the dot matrix code graph.
In this embodiment, the angle of each data point group is calculated, and the value of the data point group is determined from the angle.
It should be noted that the two code points in each data point group are symmetrically arranged with respect to the nominal position as the center, and the angles of the code points include: 0 degrees, 45 degrees, 90 degrees and 135 degrees, different angles representing different information.
In order to obtain a code value of a more accurate dot matrix code pattern, error correction processing may be performed on the dot matrix code pattern, for example, a Reed-Solomon error correction algorithm may be used to perform error correction, so as to obtain a code value after error correction verification.
In the embodiment, the preprocessing is performed on the dot matrix code image, so that the image quality is improved, and the influence of uneven illumination, complex background and noise interference on the dot matrix code identification noise in the prior art is solved; and then, locating the region where the code point is located in the dot matrix code image, improving the accuracy of finding the code point, and finally, reading the region where the code point is located. Therefore, the accuracy of recognizing the dot matrix code image is improved through the method.
Referring to fig. 7, a schematic structural diagram of a device for reading a dot matrix code image according to an embodiment of the present invention is shown, where in this embodiment, the device includes:
a preprocessing unit 701, configured to obtain a dot matrix code image to be processed, and perform preprocessing on the dot matrix code image;
the positioning unit 702 is configured to detect the dot matrix code image, and position an area where a code point is located;
and the reading unit 703 is configured to read the area where the code point is located.
Optionally, the preprocessing unit is configured to:
graying the dot matrix code image to generate a gray image;
performing quality evaluation on the gray level image of the dot matrix code image, and determining the definition of the dot matrix code image according to an evaluation result;
under the condition that the definition of the dot matrix code image meets the preset condition, performing illumination compensation on the dot matrix code image;
and morphological filtering is carried out on the dot matrix code image.
Optionally, the morphological filtering of the dot matrix code image includes:
performing binarization processing on the dot matrix code image;
performing open operation processing on the dot matrix code image;
and performing expansion operation on the dot matrix code image.
Optionally, the positioning unit is used for:
traversing the dot matrix code image by adopting a sliding window with a gradient size;
screening sliding windows meeting a first preset condition according to the average gray value of each sliding window to obtain a plurality of first image areas meeting the first preset condition;
dividing each first image region into a plurality of sub-regions for each first image region;
screening out subareas with average gray values meeting a second preset condition;
and merging all screened subareas meeting the second preset condition.
Optionally, the screening the sliding window according to the average gray value of each sliding window to obtain a plurality of first image areas according to the first preset condition includes:
calculating an average gray value of an image area in the sliding window;
screening out an image area with the average gray value between a first upper threshold value and a first lower threshold value;
performing corrosion operation on the image area with the screened average gray value between the first upper threshold value and the first lower threshold value;
and screening out areas with average gray values smaller than a second threshold value from the corroded image areas to obtain a plurality of first image areas.
Optionally, the second preset condition is that the difference between the average gray values of the screened subarea and other subareas is smaller than a preset third threshold value, and the difference between the average gray values of the screened subarea and the first image area is smaller than a preset fourth threshold value.
Optionally, the reading unit is configured to:
detecting a data point group in the region where the code point is located;
taking the code points except the data point group in the region where the code points are located as candidate reference point groups, and determining the reference point groups according to the geometric relationship between the reference point groups and the nominal positions;
determining the row and column of each data point group according to the position of the reference point group to obtain a dot matrix code pattern;
and reading the value of each data point group in the dot matrix code graph to obtain the code value of the dot matrix code graph.
Optionally, the detecting the data point group in the area where the code point is located includes:
performing binarization processing on the region where the code points are located to obtain a binary image containing a plurality of connected domains;
acquiring the number of pixel points contained in each connected domain;
screening out connected domains with the number of the pixel points within a preset first range;
taking two connected domains closest to each other as a group, calculating the distance values of the two connected domains in each group, and calculating the average value of all the distance values;
if the distance value of the two connected domains in each group is smaller than the average value of the distance values, the connected domains in the group are used as a code point;
if the connected domain is larger than a preset third threshold value, the connected domain is used as two code points;
the two closest code points are taken as a data point group.
Optionally, the determining the row and the column where each data point group is located according to the position of the reference point group includes:
calculating three nominal positions closest to the nominal position of the reference point;
calculating the width and height of the point pattern sub-block according to the three nominal positions closest to the nominal positions of the reference points;
calculating the distance between the nominal position of each data point group and the nominal position of the reference point, and representing the distance as a reference distance;
calculating a first multiple relation between the reference distance and the width of the dot pattern sub-block, and calculating a second multiple relation between the reference distance and the height of the dot pattern sub-block;
and determining the row and the column where the data point group is located according to the first multiple relation and the second multiple relation.
The device of the embodiment improves the image quality by preprocessing the dot matrix code image, and solves the problems of uneven illumination, complex background and noise interference in the prior art; and then, locating the region where the code point is located in the dot matrix code image, improving the accuracy of finding the code point, and finally, reading the region where the code point is located. Therefore, the accuracy of recognizing the dot matrix code image is improved through the method.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. The method for recognizing and reading the dot matrix code image is characterized by comprising the following steps:
acquiring a dot matrix code image to be processed, and preprocessing the dot matrix code image;
traversing the dot matrix code image by adopting a sliding window with a gradient size;
screening sliding windows meeting a first preset condition according to the average gray value of each sliding window to obtain a plurality of first image areas meeting the first preset condition;
dividing each first image region into a plurality of sub-regions for each first image region;
screening out subareas with average gray values meeting a second preset condition;
combining all screened subareas meeting a second preset condition, wherein the combining process comprises the following steps: in the process of screening the subareas, marking the screened subareas each time when a new subarea is screened, comparing the screened new subarea with the screened subareas, and merging if subareas with intersections in horizontal, vertical and inclined directions exist;
and recognizing and reading the area where the code point is located.
2. The method of claim 1, wherein the preprocessing the dot matrix code image comprises:
graying the dot matrix code image to generate a gray image;
performing quality evaluation on the gray level image of the dot matrix code image, and determining the definition of the dot matrix code image according to an evaluation result;
under the condition that the definition of the dot matrix code image meets the preset condition, performing illumination compensation on the dot matrix code image;
and morphological filtering is carried out on the dot matrix code image.
3. The method of claim 2, wherein morphologically filtering the dot matrix code image comprises:
performing binarization processing on the dot matrix code image;
performing open operation processing on the dot matrix code image;
and performing expansion operation on the dot matrix code image.
4. The method according to claim 1, wherein the step of screening the sliding windows according to the average gray value of each sliding window to obtain a plurality of first image areas according to the first preset condition includes:
calculating an average gray value of an image area in the sliding window;
screening out an image area with the average gray value between a first upper threshold value and a first lower threshold value;
performing corrosion operation on the image area with the screened average gray value between the first upper threshold value and the first lower threshold value;
and screening out areas with average gray values smaller than a second threshold value from the corroded image areas to obtain a plurality of first image areas.
5. The method according to claim 1, wherein the second preset condition is that the difference of the average gray value of the screened sub-area and the other sub-areas is smaller than a preset third threshold value, and the difference of the average gray value of the first image area is smaller than a preset fourth threshold value.
6. The method of claim 1, wherein the identifying the region in which the code point is located comprises:
detecting a data point group in the region where the code point is located;
taking the code points except the data point group in the region where the code points are located as candidate reference point groups, and determining the reference point groups according to the geometric relationship between the reference point groups and the nominal positions;
determining the row and column of each data point group according to the position of the reference point group to obtain a dot matrix code pattern;
and reading the value of each data point group in the dot matrix code graph to obtain the code value of the dot matrix code graph.
7. The method of claim 6, wherein detecting the set of data points in the region where the code point is located comprises:
performing binarization processing on the region where the code points are located to obtain a binary image containing a plurality of connected domains;
acquiring the number of pixel points contained in each connected domain;
screening out connected domains with the number of the pixel points within a preset first range;
taking two connected domains closest to each other as a group, calculating the distance values of the two connected domains in each group, and calculating the average value of all the distance values;
if the distance value of the two connected domains in each group is smaller than the average value of the distance values, the connected domains in the group are used as a code point;
if the connected domain is larger than a preset third threshold value, the connected domain is used as two code points;
the two closest code points are taken as a data point group.
8. The method of claim 6, wherein determining the row and column in which each data point group is located based on the position of the reference point group comprises:
calculating three nominal positions closest to the nominal position of the reference point;
calculating the width and height of the point pattern sub-block according to the three nominal positions closest to the nominal positions of the reference points;
calculating the distance between the nominal position of each data point group and the nominal position of the reference point, and representing the distance as a reference distance;
calculating a first multiple relation between the reference distance and the width of the dot pattern sub-block, and calculating a second multiple relation between the reference distance and the height of the dot pattern sub-block;
and determining the row and the column where the data point group is located according to the first multiple relation and the second multiple relation.
9. A dot matrix code image recognition apparatus, comprising:
the preprocessing unit is used for acquiring a dot matrix code image to be processed and preprocessing the dot matrix code image;
the positioning unit is used for traversing the dot matrix code image by adopting a sliding window with a gradient size; screening sliding windows meeting a first preset condition according to the average gray value of each sliding window to obtain a plurality of first image areas meeting the first preset condition; dividing each first image region into a plurality of sub-regions for each first image region; screening out subareas with average gray values meeting a second preset condition; combining all screened subareas meeting a second preset condition, wherein the combining process comprises the following steps: in the process of screening the subareas, marking the screened subareas each time when a new subarea is screened, comparing the screened new subarea with the screened subareas, and merging if subareas with intersections in horizontal, vertical and inclined directions exist;
and the reading unit is used for reading the area where the code point is located.
CN201910655799.0A 2019-07-19 2019-07-19 Method and device for recognizing and reading dot matrix code image Active CN110348266B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910655799.0A CN110348266B (en) 2019-07-19 2019-07-19 Method and device for recognizing and reading dot matrix code image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910655799.0A CN110348266B (en) 2019-07-19 2019-07-19 Method and device for recognizing and reading dot matrix code image

Publications (2)

Publication Number Publication Date
CN110348266A CN110348266A (en) 2019-10-18
CN110348266B true CN110348266B (en) 2023-10-20

Family

ID=68179385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910655799.0A Active CN110348266B (en) 2019-07-19 2019-07-19 Method and device for recognizing and reading dot matrix code image

Country Status (1)

Country Link
CN (1) CN110348266B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112651259A (en) * 2020-12-29 2021-04-13 芜湖哈特机器人产业技术研究院有限公司 Two-dimensional code positioning method and mobile robot positioning method based on two-dimensional code
CN113392669B (en) * 2021-05-31 2022-09-23 苏州中科华影健康科技有限公司 Image information detection method, detection device and storage medium
CN114707623A (en) * 2022-06-06 2022-07-05 青岛罗博科技有限公司 Lattice code coding method and coding device
CN117725943A (en) * 2024-02-06 2024-03-19 浙江码尚科技股份有限公司 Dot matrix code identification method and system based on digital graph processing

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107545207A (en) * 2017-09-28 2018-01-05 云南电网有限责任公司电力科学研究院 DM two-dimensional code identification methods and device based on image procossing
CN108109120A (en) * 2017-12-18 2018-06-01 凌云光技术集团有限责任公司 A kind of illumination compensation method and device of dot matrix Quick Response Code

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7110604B2 (en) * 2001-06-26 2006-09-19 Anoto Ab Processing of digital images

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107545207A (en) * 2017-09-28 2018-01-05 云南电网有限责任公司电力科学研究院 DM two-dimensional code identification methods and device based on image procossing
CN108109120A (en) * 2017-12-18 2018-06-01 凌云光技术集团有限责任公司 A kind of illumination compensation method and device of dot matrix Quick Response Code

Also Published As

Publication number Publication date
CN110348266A (en) 2019-10-18

Similar Documents

Publication Publication Date Title
CN110348266B (en) Method and device for recognizing and reading dot matrix code image
Azam et al. Automatic license plate detection in hazardous condition
RU2678485C1 (en) Method of character segmentation and recognition
JP6080259B2 (en) Character cutting device and character cutting method
US7062099B2 (en) Image processing method and apparatus using self-adaptive binarization
CN106960208B (en) Method and system for automatically segmenting and identifying instrument liquid crystal number
CN108985305B (en) Laser etching industrial detonator coded image positioning and correcting method
JP4232800B2 (en) Line noise elimination device, line noise elimination method, line noise elimination program
CN109948393B (en) Method and device for positioning one-dimensional bar code
US20130058569A1 (en) Image processing apparatus, image processing method, and non-transitory computer readable medium
JP2016143413A (en) Word segmentation for document image using recursive segmentation
CN108038481A (en) A kind of combination maximum extreme value stability region and the text positioning method of stroke width change
JPH07222000A (en) Copy prevention method of document
JPH04233683A (en) Slef-locking symbol-shape code
JP2002133426A (en) Ruled line extracting device for extracting ruled line from multiple image
CN105469027A (en) Horizontal and vertical line detection and removal for document images
US8588460B2 (en) Electronic watermark embedding device, electronic watermark detecting device, and programs therefor
CN112560538B (en) Method for quickly positioning damaged QR (quick response) code according to image redundant information
CN110569845A (en) test paper image correction method and related device
JPWO2017141802A1 (en) Image processing apparatus, character recognition apparatus, image processing method, and program recording medium
CN111222507A (en) Automatic identification method of digital meter reading and computer readable storage medium
CN108256518B (en) Character area detection method and device
Hesham et al. Arabic document layout analysis
CN115456003A (en) DPM two-dimensional code identification method and storage medium
CN117094975A (en) Method and device for detecting surface defects of steel and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant