CN112800797B - Region positioning method and system for DM code - Google Patents

Region positioning method and system for DM code Download PDF

Info

Publication number
CN112800797B
CN112800797B CN202011612973.2A CN202011612973A CN112800797B CN 112800797 B CN112800797 B CN 112800797B CN 202011612973 A CN202011612973 A CN 202011612973A CN 112800797 B CN112800797 B CN 112800797B
Authority
CN
China
Prior art keywords
code
point
edge
dotted line
neighborhood
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
CN202011612973.2A
Other languages
Chinese (zh)
Other versions
CN112800797A (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.)
Luster LightTech Co Ltd
Original Assignee
Luster LightTech 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 Luster LightTech Co Ltd filed Critical Luster LightTech Co Ltd
Priority to CN202011612973.2A priority Critical patent/CN112800797B/en
Publication of CN112800797A publication Critical patent/CN112800797A/en
Application granted granted Critical
Publication of CN112800797B publication Critical patent/CN112800797B/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/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges
    • G06T3/02
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/10Image enhancement or restoration by non-spatial domain filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20061Hough transform
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]

Abstract

The application provides a region positioning method of a DM code, which comprises the following steps: acquiring a picture to be detected; positioning an ROI (region of interest) containing a DM code in a picture to be detected through a YoloV3-Tiny target detection model; and traversing the ROI area containing the DM code in a crossing way according to the preset track to obtain the effective boundary of the DM code in the ROI area. The application also provides a region positioning system of the DM code. The method and the device utilize the YoloV3-Tiny target detection model to rapidly locate the ROI region containing the DM codes in the picture to be detected, circularly traverse the ROI region which is not subjected to accurate location processing, and accurately locate the DM codes in the ROI region through the DM code location algorithm, so that a large number of invalid detection operations are avoided, the accuracy of locating the DM codes is improved, and the time of rapidly locating the ROI regions of a plurality of DM codes by the YoloV3-Tiny target detection model is consistent with the time of a single DM code, and the efficiency is higher.

Description

Region positioning method and system for DM code
Technical Field
The present disclosure relates to the field of DM code positioning technologies, and in particular, to a method and system for positioning a DM code area.
Background
The DM (Data Matrix) code is a graph consisting of two color modules alternating between black and white. The DM code shown in fig. 11 is a DM code with specification of 24 x 24, and is composed of a data area formed by regularly arranged square modules, a positioning pattern and a dead zone, wherein the positioning pattern is a boundary of the data area, specifically, a module width, and two adjacent sides in the DM code are black solid lines. As shown in fig. 1, two adjacent edges are connected to form an L-shaped edge, and the L-shaped edge is mainly used for limiting the physical size of the DM code, positioning the DM code and correcting distortion of the DM code; the other two adjacent sides of the DM code consist of alternating black modules and white modules, forming a dotted line side which is mainly used for limiting the bar code specification of the DM code and the physical size of the unit modules in the DM code. When it is desired to accurately find a target DM code from a picture containing a plurality of DM codes or a plurality of different bar codes other than the DM code, it is necessary to accurately locate the target DM code area to acquire information data contained in the target DM code.
In the prior art, the DM code positioning of a picture to be detected containing DM codes is generally carried out by firstly carrying out expansion corrosion on the whole picture containing the DM codes to be positioned, screening out candidate areas containing the DM codes to be positioned, then traversing the candidate areas line by line and point by point directly, consuming longer time, and when a plurality of DM codes are contained in the whole picture, the time for positioning the DM codes to be positioned needs longer; and because a whole picture may contain other bar codes except the DM code, such as QR code and bar code, when the DM code area to be positioned is positioned, the other bar codes will seriously interfere with the positioning of the DM code, resulting in lower positioning efficiency of the DM code area.
Disclosure of Invention
The application provides a method and a system for locating a region of a DM code, which are used for solving the problems of long time consumption and low locating efficiency of locating the region of the DM code in the prior art.
In one aspect, the present application provides a method for locating a region of a DM code, which specifically includes the following steps:
obtaining a picture to be detected, wherein the picture to be detected is a preprocessed picture containing a DM code;
positioning an ROI (region of interest) containing a DM code in the picture to be detected through a YoloV3-Tiny target detection model, wherein the YoloV3-Tiny target detection model is obtained by training a standard YoloV3-Tiny model and configuring parameters;
and traversing the ROI area containing the DM code in a crossing way according to a preset track to obtain the effective boundary of the DM code in the ROI area.
In a preferred embodiment of the present application, the cross traversal is performed on the ROI area containing the DM code according to a preset track, so as to obtain the effective boundary of the DM code in the ROI area, which specifically includes the following steps:
acquiring track point coordinates on a preset track;
if the track point coordinates are effective track points, detecting a DM code boundary;
and if the DM code boundary is a valid boundary, outputting the valid boundary of the DM code.
In a preferred embodiment of the present application, if the coordinates of the track point are valid track points, detecting a DM code boundary includes:
judging whether the effective track point is a strong edge point or not;
if the effective track point is a strong edge point, detecting an L-shaped edge of the DM code;
if the L-shaped edge is an effective L-shaped edge, detecting a dotted line edge of the DM code;
and if the dotted line edge is a valid dotted line edge, outputting a valid L-shaped edge and a valid dotted line edge of the DM code.
In the above technical solution, if the traversal is performed completely according to the deducing direction in which the dotted line edge is located or only in a single traversal direction, it may not be possible to completely traverse all the black-and-white modules on the dotted line edge, and if all the black-and-white modules on the dotted line edge can be accurately traversed, reasonable traversal starting points and traversal directions are required.
In a preferred embodiment of the present application, the specific determining process is as follows:
calculating the gradient of the current effective track point according to the sobel operator;
if the gradient of the current effective track point meets the requirement of a first preset threshold value, calculating the gradient of the current effective track point vertical gradient forward direction neighborhood point and the gradient of the reverse direction neighborhood point;
if the gradients of the normal direction neighborhood point and the reverse direction neighborhood point of the vertical gradient of the current effective track point meet the requirement of a second preset threshold value, judging whether the current effective track point is a common neighborhood point of the normal direction neighborhood point and the reverse direction neighborhood point of the vertical gradient;
and if the current effective track point is a common neighborhood point of the vertical gradient forward direction neighborhood point and the vertical gradient reverse direction neighborhood point, judging that the current effective track point is a strong edge point.
In a preferred embodiment of the present application, if the effective track point is a strong edge point, the L-shaped edge of the DM code is detected, and the specific detection process is as follows:
acquiring a first neighborhood point of the current effective track point in the positive direction of the vertical gradient and a second neighborhood point of the first neighborhood point in the positive direction of the vertical gradient;
when the acquired neighborhood point gradient is smaller than a third preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the positive direction of the vertical gradient is not acquired any more;
acquiring a first neighborhood point of the current effective track point in the opposite direction of the vertical gradient and a second neighborhood point of the first neighborhood point in the opposite direction of the vertical gradient;
when the acquired neighborhood point gradient is smaller than a fourth preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the opposite direction of the vertical gradient is not acquired;
and connecting the neighborhood points to obtain L-shaped edges passing through the current effective track points.
In a preferred embodiment of the present application, connecting the neighboring points to obtain an L-shaped edge passing through the current effective track point, and specifically further includes:
acquiring a first right-angle side and a second right-angle side of the L-shaped side through Hough straight line detection;
calculating an included angle between the first right-angle side and the second right-angle side;
judging whether the included angle meets a preset included angle of a DM code or not;
if the included angle meets a preset included angle, calculating a vector product of the first right-angle side and the second right-angle side;
and determining the left side and the bottom side of the DM code according to the vector product, and outputting an L-shaped edge detection result of the DM code.
In a preferred embodiment of the present application, if the L-shaped edge is an effective L-shaped edge, a dashed line edge of the DM code is detected, and a specific detection process is as follows:
judging the straight line and the direction of the dotted line side according to the effective L-shaped side;
detecting an upper dotted line side and a right dotted line side of the dotted line side according to the straight line and the direction of the dotted line side;
respectively carrying out Hough transformation on the upper dotted line side and the right dotted line side to obtain a first straight line and a second straight line;
obtaining an affine transformation matrix between a DM code and a unit square DM code according to the effective L-shaped edge, the first straight line and the second straight line;
violently enumerating the DM code specification, and sampling a DM code image by combining the affine transformation matrix;
obtaining the most matched DM code specification according to the average color difference value of the black-and-white module in the DM code image obtained by sampling;
taking the first straight line and the second straight line as traversing tracks respectively, and counting the total number of black-and-white modules on the first straight line or the second straight line and the total number of black-and-white modules of a broken line side in the DM code specification which are most matched;
and if the total number of the black-and-white modules on the first straight line or the second straight line is consistent with the total number of the black-and-white modules of the broken line side in the DM code specification which is matched best or the error is within a preset error range, judging that the detection of the broken line side is finished.
In a preferred embodiment of the present application, the dotted line edge is obtained by dividing the dotted line edge into multiple segments of sub-edges and traversing straight lines of the multiple segments of sub-edges with different angles generated by Bresenham algorithm, wherein the dotted line edge includes the upper dotted line edge and the right dotted line edge.
On the other hand, the application also provides a DM code area positioning system adopting the DM code area positioning method.
Compared with the prior art, the method and the system for positioning the DM code area have the following beneficial effects:
(1) According to the method, false detection caused by irrelevant bar codes or scene interference in the picture to be detected can be avoided by combining the deep learning model with the DM code positioning algorithm, limited ROI (region of interest) areas containing DM codes in the picture to be detected are obtained by utilizing the YoloV3-Tiny target detection model to be rapidly positioned, then all the ROI areas which are not subjected to precise positioning processing are circularly traversed, the DM codes in the ROI areas are precisely positioned through the DM code positioning algorithm, a large number of invalid detection operations on areas without the DM codes are avoided, the accuracy and efficiency of positioning the DM codes are effectively improved, and when other bar codes are contained in the picture to be detected, the time for rapidly positioning the ROI areas of a plurality of DM codes by the YoloV3-Tiny target detection model is basically consistent with the time only containing single DM codes, so that the overall positioning efficiency is ensured.
(2) The traversal adopted in the method is selective and sequential cross traversal, so that the actual traversal times are greatly reduced, and the positioning efficiency of the DM codes in the ROI area is effectively improved.
(3) According to the method and the device, the broken line edge detection in DM boundary detection is changed from single-angle detection to multi-angle detection, so that the adaptability of a DM code positioning algorithm is stronger, and the detection rate of the DM code in the ROI is further improved.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the embodiments will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flow chart of a method for locating a DM code area of the present application;
fig. 2 is a schematic diagram of a picture to be detected containing a DM code in embodiment 1;
FIG. 3 is a diagram of the region of the ROI with DM code in example 1;
FIG. 4 is a diagram showing the effective boundary of the DM code in the ROI area in the embodiment 1;
FIG. 5a is a schematic diagram of the first cross-walk trajectory of the ROI area in the embodiment 1;
FIG. 5b is a schematic diagram of the second cross-walk trajectory of the ROI area in the embodiment 1;
FIG. 5c is a schematic diagram of the third cross-walk trajectory of the ROI area in the embodiment 1;
FIG. 5d is a schematic diagram of the mth cross-walk trajectory of the ROI area in the embodiment 1;
fig. 6 is a schematic diagram illustrating the principle of determining the strong edge point in embodiment 1;
FIG. 7 is a schematic diagram illustrating the judgment principle of the L-shaped edge in the embodiment 1;
fig. 8 is a schematic diagram of the principle of detecting the right angle edge of the L-shaped edge in the embodiment 1;
FIG. 9 is a schematic diagram of the detection principle of the dotted line side in the present embodiment 1;
FIG. 10 is a schematic diagram showing the derivation of the optimal traversing direction of the dotted line edge in the present embodiment 1;
fig. 11 is a schematic diagram of a DM code with a specification of 24×24.
Detailed Description
For purposes of clarity, embodiments and advantages of the present application, the following description will make clear and complete the exemplary embodiments of the present application, with reference to the accompanying drawings in the exemplary embodiments of the present application, it being apparent that the exemplary embodiments described are only some, but not all, of the examples of the present application.
Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In the description of the embodiments of the present application, it should be noted that, directions or positional relationships indicated by terms such as "upper", "lower", "bottom", "left", "right", and "forward direction", "reverse direction", etc., are based on directions or positional relationships shown in the drawings, or are directions or positional relationships that are conventionally put in use of the inventive product, are merely for convenience of description of the present application and for simplification of description, and are not indicative or implying that the apparatus or element to be referred to must have a specific direction, be configured and operated in a specific direction, and therefore should not be construed as limiting the present application.
In the description of the embodiments of the present application, the descriptions of "first," "second," "third," etc. are only for distinguishing between similar concepts, so as to facilitate describing a technical solution of the present application and simplifying the description, rather than indicating or implying that the descriptions must have a specific order, without any actual meaning, and therefore should not be construed as limiting the present application.
Based on the exemplary embodiments described herein, all other embodiments that may be obtained by one of ordinary skill in the art without making any inventive effort are within the scope of the claims appended hereto. Furthermore, while the disclosure is presented in the context of an exemplary embodiment or embodiments, it should be appreciated that the various aspects of the disclosure may, separately, comprise a complete embodiment.
It should be noted that the brief description of the terms in the present application is only for convenience in understanding the embodiments described below, and is not intended to limit the embodiments of the present application. Unless otherwise indicated, these terms should be construed in their ordinary and customary meaning.
Example 1
As shown in fig. 1, the present application provides a method for locating a region of a DM code, which specifically includes the following steps:
s101, obtaining a picture to be detected, wherein the picture to be detected is a preprocessed picture containing a DM code;
s102, positioning an ROI (region of interest) containing a DM code in the picture to be detected through a YoloV3-Tiny target detection model, wherein the YoloV3-Tiny target detection model is obtained by training a standard YoloV3-Tiny model and configuring parameters;
s103, traversing the ROI area containing the DM code in a crossing mode according to a preset track to obtain the effective boundary of the DM code in the ROI area.
Yolo is another framework presented by Ross Girsrack for the DL target detection speed problem following RCNN, fast-RCNN and fast-RCNN. The Yolov3-Tiny network is a lightweight target detection network based on the Yolov3 algorithm, has few network layers and few parameter amounts, and can ensure real-time operation on an embedded platform.
Because of the advantages of small calculation amount and high speed of the Yolov3-Tiny model, in the embodiment 1, a standard Yolov3-Tiny model is selected to detect the DM code, and then the Yolov3-Tiny model is trained and parameters are finely adjusted on the basis, so that a detection model for the DM code, namely a Yolov3-Tiny target detection model, is formed.
In this example 1, the specific construction procedure of the YoloV3-Tiny target detection model is as follows:
firstly, labeling a picture sample to be detected containing a DM code by using LabelImage software to obtain a training set test set of the DM code for subsequent operation.
Then, configuring a standard YoloV3-Tiny model, namely modifying cfg/voc. Data, data/voc. Names and cfg/YoloV3-Tiny. Cfg files, wherein the cfg/YoloV3-Tiny. Cfg files specifically comprise: the network resolution is adjusted from 416 x 416 to 704 x 704 to improve accuracy and to improve accuracy in detecting small objects.
Through the training and the file parameter modification, the standard YoloV3-Tiny model is matched with a DM code, the standard YoloV3-Tiny model after the matching is trained through a DM code training set test set, namely the YoloV3-Tiny target detection model, the test set is utilized for evaluation, and the evaluation result shows that the recognition rate of the YoloV3-Tiny target detection model to the DM code reaches 99%.
It should be noted that, in embodiment 1, the configuration of the parameter file of the standard YoloV3-Tiny model is only one technical solution shown in the application, and those skilled in the art can modify the parameter file to be configured according to the actual positioning needs, which should not be construed as limiting the protection scope of the application.
The specific technical scheme of this embodiment 1 is described below by using a picture to be detected containing a DM code.
As shown in fig. 2, in the pre-processed picture to be detected containing the DM code obtained in step S101, as shown in fig. 2, the picture to be detected only contains one DM code, and further includes a QR code and a 128 bar code, as shown in fig. 3, in the step S102, the ROI area containing the DM code in the picture to be detected containing the DM code is located by using the YoloV3-Tiny target detection model, in fig. 3, the rectangular frame around the DM code is the ROI area containing the DM code obtained after the positioning by using the YoloV3-Tiny target detection model, and as shown in fig. 3, the located ROI area only contains the DM code, and the position of the DM code in the ROI area is basically centered, and meanwhile, the two interference bar codes of the QR code and the 128 bar code in the picture to be detected in fig. 2 are not recognized and output by using the YoloV3-Tiny target detection model; as shown in fig. 4, in step S103, the ROI area containing the DM code in fig. 3 is traversed according to the preset track to obtain an effective boundary diagram of the DM code in the ROI area, and the right side of fig. 4 is an enlarged view of the effective boundary of the DM code, and the irregular frame next to the DM code is the effective boundary of the DM code.
In this embodiment 1, the specific procedure of step S103 is as follows:
acquiring track point coordinates on a preset track;
if the track point coordinates are effective track points, detecting a DM code boundary;
and if the DM code boundary is a valid boundary, outputting the valid boundary of the DM code.
It should be noted that, in embodiment 1, the specific trajectory of the cross traversal of step S103 is shown in fig. 5a, 5b, 5c and 5d, and the ROI area obtained after positioning by the YoloV3-Tiny object detection model only contains one DM code, and the occupation ratio of the DM code in the ROI area is relatively large. Therefore, it is unnecessary to traverse each pixel of the ROI area, excluding the region a of one quarter of the ROI area from being traversed, and the ROI area boundary other than a is subjected to bisection as shown in fig. 5a, and pixel traversal is sequentially performed from the ROI boundary to the inside of the ROI area in the track order of 1, 2, 3, 4 until the DM code boundary is found or the traversing track reaches the diagonal between the region a boundary and the ROI area; taking the four bisectors shown in fig. 5b from the second traversing track, excluding the four bisectors which are repeated with the bisectors shown in fig. 5a, and traversing the rest of the bisectors according to the track sequence of 1, 2, …, 7 and 8 shown in fig. 5b and the traversing rules; taking the eighth bisector shown in fig. 5c as the third traversing track, excluding the eighth bisector repeated with the bisector shown in fig. 5a and the fourth bisector shown in fig. 5b, and traversing the rest of the bisectors according to the track sequence of 1, 2, …, 15 and 16 shown in fig. 5c according to the first traversing track and the traversing rule; the m-th traversing track takes the N-bisection line shown in fig. 5d, N is the m-th power of 2, taking the track numbers in the left dashed line frame in fig. 5d as examples, specifically, 1, 9, 17, … and 1+n, and the traversing track numbering rules after the third traversing track are 1+8×0, 1+8×1, 1+8×2, … and 1+8×k, where k=n/8, and the numbering rules of other series are the same.
In this embodiment 1, if the coordinates of the track point in step S103 are valid track points, the DM code boundary is detected, which specifically includes:
judging whether the effective track point is a strong edge point or not;
if the effective track point is a strong edge point, detecting an L-shaped edge of the DM code;
if the L-shaped edge is an effective L-shaped edge, detecting a dotted line edge of the DM code;
and if the dotted line edge is a valid dotted line edge, outputting a valid L-shaped edge and a valid dotted line edge of the DM code.
In the above technical solution, if the traversal is performed completely according to the deducing direction in which the dotted line edge is located or only in a single traversing direction, it may not be possible to completely traverse all the black-and-white modules on the dotted line edge, and if all the black-and-white modules on the dotted line edge can be accurately traversed, reasonable traversing starting points and traversing directions are required, and in this embodiment 1, the deducing process of the optimal traversing direction of the dotted line edge is shown in fig. 10.
As shown in fig. 6, the specific judgment process of the strong edge point in the present embodiment 1 is as follows:
calculating the gradient of the current effective track point A according to a sobel operator;
if the gradient of the current effective track point A meets the requirement of a first preset threshold value, calculating the gradient of a neighbor point B in the positive direction and the gradient of a neighbor point C in the negative direction of the vertical gradient of the current effective track point;
if the gradients of the neighboring point B in the positive direction and the neighboring point C in the negative direction of the vertical gradient of the current effective track point a meet the requirement of the second preset threshold, judging whether the current effective track point a is a common neighboring point in the vertical gradient direction of B, C, if so, judging that the current track point a is a strong edge point, wherein the positive direction and the negative direction of the vertical gradient are shown by arrows in a left graph in fig. 6, and the right graph in fig. 6 is the position of the current track point a in the DM code.
As shown in fig. 7, the arrow direction of the left graph of fig. 7 shows the positive direction of the vertical gradient and the opposite direction of the vertical gradient of the current effective track point a, the right graph of fig. 7 shows the position of the current track point a in the DM code, and the edge L formed by an irregular line passing through the current track point a, and the specific detection process of the L-shaped edge of the DM code in the embodiment 1 is as follows:
acquiring a first neighborhood point B of the current effective track point A in the positive direction of the vertical gradient and a second neighborhood point D of the first neighborhood point B in the positive direction of the vertical gradient;
when the acquired gradient of the neighborhood point in the positive direction is smaller than a third preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the positive direction of the vertical gradient is not acquired;
acquiring a first neighborhood point C in the opposite direction of the vertical gradient of the current effective track point A and a second neighborhood point E in the opposite direction of the vertical gradient of the first neighborhood point C in the opposite direction;
when the acquired gradient of the neighborhood point in the opposite direction is smaller than a fourth preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the opposite direction of the vertical gradient is not acquired;
and connecting the neighborhood points to obtain an L-shaped edge passing through the current effective track point A, as shown in the right diagram of FIG. 7.
In this embodiment 1, as shown in fig. 8, obtaining an L-shaped edge passing through the current effective track point, further requires right-angle edge detection, including:
performing Hough transformation on the edge L by taking the current effective track point A as a reference to obtain an optimal straight line L1 close to the point A, traversing other points on the edge L from the forward direction and the reverse direction by taking the point A as a starting point until the included angle between the straight line formed by the point A and the edge L1 exceeds a tolerance range, and obtaining a sub-edge K taking two points B, C as end points; traversing other points on the edge L from the positive direction by taking the point B as a starting point until the edge L is traversed, and obtaining a sub-edge M; traversing other points on the edge L from the opposite direction by taking the point C as a starting point until the edge L is traversed to obtain a sub-edge N; performing Hough transform on the sub-edge M to obtain an optimal straight line L2, and performing Hough transform on the sub-edge N to obtain an optimal straight line L3; taking the L1 and the L2 and L3 with the largest number of edge points as two right-angle sides of the L-shaped side for output;
calculating an included angle between the first right-angle side L1 and the second right-angle side L2;
judging whether the included angle meets a preset included angle of a DM code or not;
if the included angle meets a preset included angle, calculating a vector product of the first right-angle side L1 and the second right-angle side L2;
and determining the left side and the bottom side of the DM code according to the vector product, and outputting an L-shaped side detection result of the DM code, wherein in the embodiment 1, two right-angle sides of the L-shaped side are respectively a first right-angle side L1 and a second right-angle side L2 as shown in FIG. 8, L1 is the left side, and L2 is the bottom side.
As shown in fig. 9, the dashed line edge of the DM code in this embodiment 1 is obtained by dividing the dashed line edge into multiple segments of sub-edges in fig. 9, where the AB segment sub-edge is obtained by using the L-shaped edge detection principle, the point a is on the L-shaped edge, the BC segment sub-edge is obtained by traversing rays generated by using Bresenham's algorithm to generate different angles, a ray having one angle can pass through the next black module within a certain distortion range, the angle coefficient of the deriving direction of the dashed line edge is set to be 1.0, and three correction coefficients 0.6,0.9 and 1.2 represent the degree of deviation of the actual traversing direction from the deriving direction, where, the correction coefficient is greater than 1.0 represents the outward deviation, the greater the deviation angle is, the correction coefficient is smaller than 1.0 represents the inward deviation, and the smaller deviation angle is greater. Because three correction coefficients can be set on the upper dotted line side and the right dotted line side, the combination of the coefficients of the upper dotted line side and the right dotted line side can obtain nine combinations of traversing directions.
The algorithm module adopts a violence enumeration strategy to sequentially try combinations of all traversal directions by using correction coefficients in a mode (upper dotted line side coefficient, right dotted line side coefficient) represented as (0.6), (0.6,0.9), (0.6, 1.2), (0.9,0.6), (0.9 ), (0.9,1.2), (1.2,0.6), (1.2,0.9) and (1.2), and the specific detection process is as follows:
judging the straight line and the direction of the dotted line side according to the effective L-shaped side;
detecting an upper dotted line side and a right dotted line side of the dotted line side according to the straight line and the direction of the dotted line side;
the specific process for detecting the upper dotted line edge is as follows: taking a point A on the edge of the L-shaped edge as a starting point, traversing the neighborhood points one by one towards the positive direction of the vertical gradient of the point A, starting to record the point number of the neighborhood points in the opposite direction when the positive direction of the vertical gradient of the continuous neighborhood points is opposite to the positive direction of the vertical gradient of the point A in the traversing process, and stopping traversing the edge points if the point number of the neighborhood points in the opposite direction exceeds a set threshold value, so as to obtain an edge end point B of the section; generating a ray taking the point B as a starting point according to the traversing direction of the dotted line edge in the current traversing direction combination, and traversing point by taking the ray as a traversing track until a strong edge point is found or the accumulated traversing length exceeds a length threshold; assuming that the traversal track in the traversal direction can find a strong edge point C, a line segment BC can be obtained, and the line segment BC is taken as a part of a dotted line edge, so that a complete sub-edge curve AC can be obtained; similarly, traversing is carried out by taking the point C as a starting point, so that a sub-edge CD can be obtained, and as shown in the left diagram of fig. 9, iteration is circulated until the accumulated traversing length exceeds a length threshold value, so that a complete upper dotted line edge can be obtained; the right dotted edge is similarly available; the resulting upper and right dashed edges are shown in the right-hand diagram of fig. 9;
respectively performing Hough transformation on the upper dotted line side and the right dotted line side to obtain a first straight line L3 and a second straight line L4 in the right diagram of FIG. 9;
obtaining an affine transformation matrix between a DM code and a unit square DM code according to the effective L-shaped edge, namely a first right-angle edge L1, a second right-angle edge L2, a first straight line L3 and a second straight line L4;
violently enumerating the DM code specification, and sampling a DM code image by combining the affine transformation matrix;
obtaining the best matching DM code specification according to the average color difference value of the black-and-white module in the DM code image obtained by sampling, wherein the best matching DM code specification is the DM code specification with the largest average color difference value of the black-and-white module;
taking the first straight line L3 and the second straight line L4 as traversing tracks respectively, and counting the total number of black-and-white modules on the first straight line L3 or the second straight line L4 and the total number of black-and-white modules of a broken line side in the DM code specification which are most matched;
if the total number of black and white modules on the first straight line L3 or the second straight line L4 is consistent with the total number of black and white modules of the broken line side in the most matched DM code specification or the error is within a preset error range, judging that the detection of the broken line side is completed.
If the total number of black-and-white modules on the first straight line L3 or the second straight line L4 is inconsistent with the total number of black-and-white modules on the broken line side in the DM code specification which is the best match, and the error is not within the preset error range, continuing the broken line side detection attempt of the next traversal direction combination until all the combination attempts are completed or the broken line side detection is completed under a certain traversal combination.
It should be noted that, in embodiment 1, all preset values or threshold values may be determined according to specific situations, the application does not limit the preset values or threshold values, and the correction coefficients may also be set to different values according to actual detection, and the correction coefficients in embodiment 1 are only set to better illustrate the technical solution of the application, and are not to be construed as limiting the protection scope of the application.
Example 2
The present embodiment 2 provides a region locating system of DM codes employing the region locating method of DM codes in the present embodiment 1.
The foregoing detailed description of the embodiments is merely illustrative of the general principles of the present application and should not be taken in any way as limiting the scope of the invention. Any other embodiments developed in accordance with the present application without inventive effort are within the scope of the present application for those skilled in the art.

Claims (7)

1. The method for positioning the area of the DM code is characterized by comprising the following steps:
obtaining a picture to be detected, wherein the picture to be detected is a preprocessed picture containing a DM code;
positioning an ROI (region of interest) containing a DM code in the picture to be detected through a YoloV3-Tiny target detection model, wherein the YoloV3-Tiny target detection model is obtained by training a standard YoloV3-Tiny model and configuring parameters;
traversing the ROI region containing the DM code in a crossing way according to a preset track to obtain an effective boundary of the DM code in the ROI region, wherein the method comprises the steps of obtaining track point coordinates on the preset track; if the track point coordinates are effective track points, detecting a DM code boundary; outputting the effective boundary of the DM code if the DM code boundary is the effective boundary;
if the track point coordinates are effective track points, detecting a DM code boundary, including judging whether the effective track points are strong edge points or not;
the cross traversal comprises the steps of excluding a region A of one quarter of an ROI region from being traversed, equally dividing the rest ROI region except the region A for a plurality of times, wherein the number N of the equal dividing lines of the mth time is m times of 2, and sequentially carrying out pixel traversal on the region equally divided each time from the boundary of the ROI region to the inside of the ROI region until the DM code boundary or traversal track is found to reach the diagonal between the boundary of the region A and the ROI region;
judging whether the effective track point is a strong edge point or not, wherein the judging comprises calculating the gradient of the current effective track point according to a sobel operator; if the gradient of the current effective track point meets the requirement of a first preset threshold value, calculating the gradient of the current effective track point vertical gradient forward direction neighborhood point and the gradient of the reverse direction neighborhood point; if the gradients of the normal direction neighborhood point and the reverse direction neighborhood point of the vertical gradient of the current effective track point meet the requirement of a second preset threshold value, judging whether the current effective track point is a common neighborhood point of the normal direction neighborhood point and the reverse direction neighborhood point of the vertical gradient; and if the current effective track point is a common neighborhood point of the vertical gradient forward direction neighborhood point and the vertical gradient reverse direction neighborhood point, judging that the current effective track point is a strong edge point.
2. The method for locating a DM code according to claim 1, wherein if the track point coordinates are valid track points, detecting the DM code boundary comprises:
judging whether the effective track point is a strong edge point or not;
if the effective track point is a strong edge point, detecting an L-shaped edge of the DM code;
if the L-shaped edge is an effective L-shaped edge, detecting a dotted line edge of the DM code;
and if the dotted line edge is a valid dotted line edge, outputting a valid L-shaped edge and a valid dotted line edge of the DM code.
3. The method for locating a DM code according to claim 2, wherein if the effective track point is a strong edge point, detecting an L-shaped edge of the DM code comprises the following steps:
acquiring a first neighborhood point of the current effective track point in the positive direction of the vertical gradient and a second neighborhood point of the first neighborhood point in the positive direction of the vertical gradient;
when the acquired neighborhood point gradient is smaller than a third preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the positive direction of the vertical gradient is not acquired any more;
acquiring a first neighborhood point of the current effective track point in the opposite direction of the vertical gradient and a second neighborhood point of the first neighborhood point in the opposite direction of the vertical gradient;
when the acquired neighborhood point gradient is smaller than a fourth preset threshold value or the acquired neighborhood point is the traversed neighborhood point, the neighborhood point in the opposite direction of the vertical gradient is not acquired;
and connecting the neighborhood points to obtain L-shaped edges passing through the current effective track points.
4. The method for locating a region of a DM code according to claim 3, wherein connecting the neighboring points to obtain an L-shaped edge passing through the current effective trace point, further comprises:
acquiring a first right-angle side and a second right-angle side of the L-shaped side through Hough straight line detection;
calculating an included angle between the first right-angle side and the second right-angle side;
judging whether the included angle meets a preset included angle of a DM code or not;
if the included angle meets a preset included angle, calculating a vector product of the first right-angle side and the second right-angle side;
and determining the left side and the bottom side of the DM code according to the vector product, and outputting an L-shaped edge detection result of the DM code.
5. The method for locating a DM code area according to claim 2, wherein if the L-shaped edge is a valid L-shaped edge, detecting a broken line edge of the DM code comprises the following steps:
judging the straight line and the direction of the dotted line side according to the effective L-shaped side;
detecting an upper dotted line side and a right dotted line side of the dotted line side according to the straight line and the direction of the dotted line side;
respectively carrying out Hough transformation on the upper dotted line side and the right dotted line side to obtain a first straight line and a second straight line;
obtaining an affine transformation matrix between a DM code and a unit square DM code according to the effective L-shaped edge, the first straight line and the second straight line;
violently enumerating the specification of the DM code, and sampling a DM code image by combining the affine transformation matrix;
obtaining the specification of the most matched DM code according to the average color difference value of the black-and-white module in the DM code image obtained by sampling;
taking the first straight line and the second straight line as traversing tracks respectively, and counting the total number of black-and-white modules on the first straight line or the second straight line and the total number of black-and-white modules of a broken line side in the specification of the most matched DM code;
and if the total number of the black-and-white modules on the first straight line or the second straight line is consistent with the total number of the black-and-white modules of the broken line side in the specification of the most matched DM code or the error is within a preset error range, judging that the detection of the broken line side is completed.
6. The method for locating the area of a DM code according to claim 5, wherein,
and obtaining the dotted line edge by dividing the dotted line edge into a plurality of sections of sub-edges and traversing straight lines of the sections of sub-edges with different angles generated by a Bresenham algorithm, wherein the dotted line edge comprises the upper dotted line edge and the right dotted line edge.
7. A DM code area locating system, characterized by employing a DM code area locating method as set forth in any one of claims 1-6.
CN202011612973.2A 2020-12-30 2020-12-30 Region positioning method and system for DM code Active CN112800797B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011612973.2A CN112800797B (en) 2020-12-30 2020-12-30 Region positioning method and system for DM code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011612973.2A CN112800797B (en) 2020-12-30 2020-12-30 Region positioning method and system for DM code

Publications (2)

Publication Number Publication Date
CN112800797A CN112800797A (en) 2021-05-14
CN112800797B true CN112800797B (en) 2023-12-19

Family

ID=75805871

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011612973.2A Active CN112800797B (en) 2020-12-30 2020-12-30 Region positioning method and system for DM code

Country Status (1)

Country Link
CN (1) CN112800797B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI827423B (en) * 2022-12-28 2023-12-21 大陸商信揚科技(佛山)有限公司 Scanning method and related devices

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101398895A (en) * 2007-09-26 2009-04-01 杨高波 Image preprocess method based on data matrix two-dimension bar code identification
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN108648205A (en) * 2018-05-07 2018-10-12 广州大学 A kind of sub-pixel edge detection method
WO2019227615A1 (en) * 2018-06-01 2019-12-05 平安科技(深圳)有限公司 Method for correcting invoice image, apparatus, computer device, and storage medium
CN110941970A (en) * 2019-12-05 2020-03-31 深圳牛图科技有限公司 High-speed dimension code positioning and identifying system based on full convolution neural network
CN111080661A (en) * 2019-12-09 2020-04-28 Oppo广东移动通信有限公司 Image-based line detection method and device and electronic equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106062824B (en) * 2014-03-05 2018-05-11 三菱电机株式会社 edge detecting device and edge detection method
CN105138943B (en) * 2015-09-02 2017-10-24 福建联迪商用设备有限公司 Coding/decoding method and system when QR code positions detection figure is damaged

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101398895A (en) * 2007-09-26 2009-04-01 杨高波 Image preprocess method based on data matrix two-dimension bar code identification
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN108648205A (en) * 2018-05-07 2018-10-12 广州大学 A kind of sub-pixel edge detection method
WO2019227615A1 (en) * 2018-06-01 2019-12-05 平安科技(深圳)有限公司 Method for correcting invoice image, apparatus, computer device, and storage medium
CN110941970A (en) * 2019-12-05 2020-03-31 深圳牛图科技有限公司 High-speed dimension code positioning and identifying system based on full convolution neural network
CN111080661A (en) * 2019-12-09 2020-04-28 Oppo广东移动通信有限公司 Image-based line detection method and device and electronic equipment

Also Published As

Publication number Publication date
CN112800797A (en) 2021-05-14

Similar Documents

Publication Publication Date Title
US10438038B2 (en) Decoding method and system for QR code with one damaged position detection pattern
CN105184801B (en) It is a kind of based on multi-level tactful optics and SAR image high-precision method for registering
EP0669593B1 (en) Two-dimensional code recognition method
CN108182383B (en) Vehicle window detection method and device
US10528781B2 (en) Detection method and system for characteristic patterns of Han Xin codes
CN106529537A (en) Digital meter reading image recognition method
CN106778737A (en) A kind of car plate antidote, device and a kind of video acquisition device
CN104990926A (en) TR element locating and defect detecting method based on vision
CN109376740A (en) A kind of water gauge reading detection method based on video
CN113177959B (en) QR code real-time extraction method in rapid movement process
CN107748855B (en) Detection method for two-dimensional code image finding graph
CN109583365A (en) Method for detecting lane lines is fitted based on imaging model constraint non-uniform B-spline curve
CN104318559A (en) Quick feature point detecting method for video image matching
CN109190742A (en) A kind of coding/decoding method of the coding characteristic point based on gray feature
CN112800797B (en) Region positioning method and system for DM code
CN111914845A (en) Character layering method and device in license plate and electronic equipment
CN113506276B (en) Marker and method for measuring structural displacement
CN105654042B (en) The proving temperature character identifying method of glass-stem thermometer
JP3372419B2 (en) Object recognition method
CN104240269A (en) Video target tracking method based on spatial constraint coding
CN110969612B (en) Two-dimensional code printing defect detection method
CN114926817B (en) Method and device for identifying parking space, electronic equipment and computer readable storage medium
JP3460356B2 (en) Method and apparatus for detecting circle or ellipse
CN111191759A (en) Two-dimensional code generation method and positioning and decoding method based on GPU
CN114037705B (en) Metal fracture fatigue source detection method and system based on moire lines

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