CN115879488A - DM code decoding method, electronic device, storage medium and program product - Google Patents

DM code decoding method, electronic device, storage medium and program product Download PDF

Info

Publication number
CN115879488A
CN115879488A CN202211276828.0A CN202211276828A CN115879488A CN 115879488 A CN115879488 A CN 115879488A CN 202211276828 A CN202211276828 A CN 202211276828A CN 115879488 A CN115879488 A CN 115879488A
Authority
CN
China
Prior art keywords
code
pixel
point
gradient
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211276828.0A
Other languages
Chinese (zh)
Inventor
王超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kuangshi Robot Technology Co Ltd
Original Assignee
Beijing Kuangshi Robot 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 Kuangshi Robot Technology Co Ltd filed Critical Beijing Kuangshi Robot Technology Co Ltd
Priority to CN202211276828.0A priority Critical patent/CN115879488A/en
Publication of CN115879488A publication Critical patent/CN115879488A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The disclosure provides a DM code decoding method, electronic equipment, a storage medium and a program product, relates to the technical field of computers, and aims to efficiently and accurately identify a DM code region and further decode the DM code. The method comprises the following steps: determining two real edges of the DM code according to the gradient of each pixel point in the original image; determining an image area where the DM code is located according to the two solid edges of the DM code; and decoding the image area where the DM is located to obtain a decoding result of the DM code.

Description

DM code decoding method, electronic device, storage medium and program product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a DM code decoding method, an electronic device, a storage medium, and a program product.
Background
The DM (Datamatrix) code is a matrix two-dimensional code, has the characteristics of large information density, small size, high fault tolerance rate, strong anti-pollution capability and the like, and is widely applied to the industrial field. In order to obtain the information contained in the DM code, it is necessary to identify the image area where the DM code is located, and then decode the identified DM code.
The method for identifying the image area of the DM code in the related technology has the problems of low efficiency and low accuracy. For example, the original image needs to be preprocessed by filtering, binarization and the like, and finally a straight line is searched for the binarized image, wherein the searching and positioning accuracy of the straight line is not high, the binarized image is easy to have a sawtooth phenomenon, a large number of complex processing processes exist, and the efficiency is not high. For another example, it is necessary to extract a feature map of an image, and feature detection is performed in the feature map of the image, which is inefficient. Therefore, a method for quickly and accurately identifying the area where the DM code is located and then decoding the DM code is urgently needed.
Disclosure of Invention
In view of the above problems, the embodiments of the present disclosure provide a method, an electronic device, a storage medium, and a program product for decoding a DM code, so as to overcome or at least partially solve the above problems.
In a first aspect of the embodiments of the present disclosure, a DM code decoding method is provided, including:
determining two real edges of the DM code according to the gradient of each pixel point in the original image;
determining an image area where the DM code is located according to the two solid edges of the DM code;
and decoding the image area where the DM code is located to obtain a decoding result of the DM code.
Optionally, the method further comprises:
detecting a target image area in the original image, wherein the target image area is an image area containing the DM code;
calculating the gradient value and gradient direction of each pixel point in the target image region;
each solid edge of the DM code is determined according to the following steps:
determining a target seed point positioned on each real edge according to the gradient value and the gradient direction of each pixel point in the target image area, wherein the gradient value of the target seed point is greater than the gradient values of the front and the back pixel points in the gradient direction of the target seed point;
aiming at a target seed point positioned on each real edge, searching a plurality of pixel points along the tangential direction of the gradient direction of the target seed point to obtain a pixel chain consisting of the pixel points, wherein the gradient values of the pixel points are greater than a gradient threshold value and belong to a regional extreme value;
and determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point.
Optionally, searching a plurality of pixel points along a tangential direction of the gradient direction of the target seed point to obtain a pixel chain formed by the plurality of pixel points, including:
searching a plurality of pixel points along the tangential direction of the gradient of the target seed point, and acquiring the gradient direction of each searched pixel point;
and stopping searching under the condition that the difference between the gradient direction of the searched pixel point and the gradient direction of the target seed point is greater than or equal to 90 degrees, so as to obtain a pixel chain consisting of the plurality of pixel points.
Optionally, determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point includes:
acquiring a plurality of pixel points which are closest to the target seed point on a pixel chain corresponding to the target seed point;
performing linear fitting on the target seed point and the nearest pixel points to obtain a coarse positioning straight line;
searching a pixel point with a distance from the target seed point in the target image region having a sudden change along a pixel chain corresponding to the target seed point, and determining a previous pixel point of the pixel point as an end point of a real edge where the target seed point is located;
and determining a solid edge of the DM code according to the rough positioning straight line and the end point.
Optionally, the method further comprises:
screening each pixel point on the pixel chain corresponding to the target seed point according to the distance from each pixel point on the pixel chain corresponding to the target seed point to the coarse positioning straight line;
performing linear fitting on the plurality of pixel points which are left after screening to obtain a fine positioning straight line;
determining a real edge of the DM code according to the rough positioning straight line and the end point, comprising:
and determining a solid edge of the DM code according to the fine positioning straight line and the end point.
Optionally, calculating a gradient value and a gradient direction of each pixel point in the target image region includes:
calculating a horizontal gradient value and a vertical gradient value of each pixel point in the target image region;
taking the sum of the horizontal gradient value and the vertical gradient value of each pixel point in the target image area as the gradient value of the pixel point;
and estimating according to the horizontal gradient value and the vertical gradient value of each pixel point in the target image region to obtain the gradient direction of the pixel point.
Optionally, determining a target seed point located on each real edge according to the gradient value and the gradient direction of each pixel point in the target image region, including:
determining a plurality of seed points of which the horizontal gradient value is larger than the horizontal gradient values of the front and rear pixel points in the horizontal direction, and determining a plurality of seed points of which the vertical gradient value is larger than the vertical gradient value of the front and rear pixel points in the vertical direction;
performing edge detection on the target image area to obtain an edge;
and determining the seed point positioned at the edge in all the seed points as the target seed point.
Optionally, determining an image area where the DM code is located according to the two real edges of the DM code includes:
obtaining two virtual edges of the DM code according to a parallelogram rule and the two real edges of the DM code;
and determining an image area surrounded by the two real edges and the two virtual edges of the DM code in the original image as an image area where the DM code is located.
Optionally, decoding an image region where the DM code is located to obtain a decoding result of the DM code, where the decoding result includes:
determining the mode of the DM code according to the respective times of black and white change of two virtual edges enclosing the image area where the DM code is located;
carrying out binarization processing on the image area where the DM code is located to obtain a processed image area;
and decoding the processed image area according to the mode of the DM code to obtain a decoding result of the DM code.
In a second aspect of the embodiments of the present disclosure, an electronic device is provided, which includes a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the method for decoding the DM code disclosed in the embodiments of the present disclosure.
In a third aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, on which a computer program/instruction is stored, which when executed by a processor, implements the method for decoding the DM code as disclosed in the embodiments of the present disclosure.
In a fourth aspect of the embodiments of the present disclosure, a computer program product is provided, which includes computer programs/instructions, and when the computer programs/instructions are executed by a processor, the method for decoding the DM code according to the embodiments of the present disclosure is implemented.
The disclosed embodiments include the following advantages:
in this embodiment, two real edges of the DM code are determined according to the gradient of each pixel point in the original image; determining an image area where the DM code is located according to the two solid edges of the DM code; and decoding the image area where the DM is located to obtain a decoding result of the DM code. The method has the advantages of high efficiency, high precision and the like, and can be used for determining the real edge of the DM code according to the gradient of each pixel point in the original image. Therefore, the image area where the DM code is located is efficiently and accurately decoded, and the decoding result of the DM code is obtained.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments of the present disclosure will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
Fig. 1 is a flowchart illustrating steps of a method for decoding a DM code according to an embodiment of the present disclosure;
fig. 2 illustrates a DM code image and a frame image of a DM code;
FIG. 3 illustrates a digital decoding section of a DM code;
fig. 4 is a flow chart illustrating a method for decoding a DM code according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an apparatus for decoding a DM code according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram of an electronic device in an embodiment of the present disclosure.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, the present disclosure is described in further detail with reference to the accompanying drawings and the detailed description.
In recent years, technical research based on artificial intelligence, such as computer vision, deep learning, machine learning, image processing, and image recognition, has been actively developed. Artificial Intelligence (AI) is an emerging scientific technology for studying and developing theories, methods, techniques and application systems for simulating and extending human Intelligence. The artificial intelligence subject is a comprehensive subject and relates to various technical categories such as chips, big data, cloud computing, internet of things, distributed storage, deep learning, machine learning and neural networks. Computer vision is an important branch of artificial intelligence, particularly a machine is used for identifying the world, and computer vision technologies generally comprise technologies such as face identification, living body detection, fingerprint identification and anti-counterfeiting verification, biological feature identification, face detection, pedestrian detection, target detection, pedestrian identification, image processing, image identification, image semantic understanding, image retrieval, character identification, video processing, video content identification, three-dimensional reconstruction, virtual reality, augmented reality, synchronous positioning and map construction (SLAM), computational photography, robot navigation and positioning and the like. With the research and progress of artificial intelligence technology, the technology is applied to many fields, such as safety control, city management, traffic management, building management, park management, face passage, face attendance, logistics management, warehouse management, robots, intelligent marketing, computational photography, mobile phone images, cloud services, smart homes, wearable equipment, unmanned driving, automatic driving, intelligent medical treatment, face payment, face unlocking, fingerprint unlocking, person certificate verification, smart screens, smart televisions, cameras, mobile internet, live webcasts, beauty treatment, medical beauty treatment, intelligent temperature measurement and the like.
Referring to fig. 1, a flowchart illustrating steps of a method for decoding a DM code in an embodiment of the present disclosure is shown, and as shown in fig. 1, the method for decoding a DM code includes the following steps:
step S11: determining two real edges of the DM code according to the gradient of each pixel point in the original image;
step S12: determining an image area where the DM code is located according to the two solid edges of the DM code;
step S13: and decoding the image area where the DM is located to obtain a decoding result of the DM code.
Fig. 2 shows a DM code image and a frame image of the DM code, wherein the left image is the DM code image and the right image is the frame image of the DM code. The DM code has two real edges and two virtual edges, and the two real edges and the two virtual edges are the frames of the DM code. The solid edges are composed of dark image blocks and the L-shaped pattern of two solid edges, called the alignment pattern, can be used to define the physical size of the DM and to determine the image area where the DM code is located. The dotted edges are composed of alternating dark and light image blocks, and the pattern of two dotted edges, called a clock pattern, can be used to determine the mode of the DM code and to help determine the image area in which the DM code is located.
The gradient is a vector having a direction and a magnitude. The direction of the gradient of one pixel point is: the pixel value of the pixel point changes fastest along the direction; the gradient value of one pixel point is: the rate of change of the pixel value of the pixel along the direction of the gradient.
The more the pixel points at the edge of the DM code are, the larger the gradient value is, so that two real edges of the DM code can be determined according to the gradient of each pixel point in the original image. When two real edges of the DM code are determined according to the gradient of the pixel points, the coordinates of the real edges can be accurate to the next decimal point, so that the accuracy reaches the sub-pixel level. And the accuracy of the image area where the DM code is positioned is determined according to the two solid edges of the DM code, and the accuracy also reaches the sub-pixel level.
Optionally, determining the image area where the DM code is located according to the two real edges of the DM code may be: obtaining two virtual edges of the DM code according to a parallelogram rule and the two real edges of the DM code; and determining an image area surrounded by the two real edges and the two virtual edges of the DM code in the original image as the image area where the DM code is located.
As can be seen from fig. 2, the two real edges and the two imaginary edges of the DM code form a rectangle, so that after the two real edges of the DM code are determined, the two imaginary edges of the DM code can be directly obtained according to the parallelogram rule. And an image area formed by enclosing the two real edges and the two virtual edges of the DM code is the image area where the DM code is located.
Therefore, the virtual edge of the DM code in the original image does not need to be identified, and the virtual edge can be directly and quickly obtained according to the determined real edge, so that the image area where the DM code is located can be quickly determined.
The image area where the DM code is located is determined, and the virtual edge of the DM code is also determined. The image area where the DM code is located can be directly decoded to obtain the decoding result of the DM code. The reason for decoding the image region where the DM code is located is to obtain information included in the DM code, and the decoding result of the DM code may be character string information included in the DM code.
Optionally, the decoding process may comprise the steps of: determining the mode of the DM code according to the respective times of black and white change of two virtual edges enclosing the image area where the DM code is located; carrying out binarization processing on the image area where the DM code is located to obtain a processed image area; and decoding the processed image area according to the mode of the DM code to obtain a decoding result of the DM code.
And the image area where the DM code is located is subjected to binarization processing, so that the subsequent decoding of the DM code is facilitated. The mode of the DM code refers to the kind of the DM code, and may be, for example, ECC000, ECC050, ECC080, ECC200, or the like. The DM codes of different modes may be decoded differently. After the mode of the DM code is determined, the digital decoding area of the DM may be decoded according to the standard protocol of the DM code by using the open source library, so as to obtain a decoding result. The open source library may be ZBar, ZXing, etc. Fig. 3 shows a digital decoding area of the DM code, wherein a lighter area surrounded by a real edge and an imaginary edge is the digital decoding area. In this way, the DM code can be decoded, and the information included in the DM code can be obtained.
By adopting the technical scheme of the embodiment of the disclosure, the original image is directly processed, the method has the advantage of high efficiency, the real edge of the DM code is determined according to the gradient of each pixel point in the original image, and the method has the advantage of high precision. Therefore, the image area where the DM code is located is efficiently and accurately decoded, and the decoding result of the DM code is obtained.
Optionally, on the basis of the above technical solution, a target image area in the original image may be detected first, and then the target image area may be processed. Wherein, the target image area is an image area containing the DM code. And under the condition that the target image area is not detected in the original image, directly exiting the decoding process and returning a result of decoding failure.
The detecting of the target image area in the original image may be by using an image recognition method in the related art. Since the accuracy of detecting the target image area is not high, the target image area cannot be directly used as the image area where the DM code is located.
After the target image area is detected, only the gradient value and the gradient direction of each pixel point in the target image area need to be calculated, and the gradients of other pixel points outside the target image area in the original image do not need to be calculated, so that the calculation resources are saved.
Optionally, calculating the gradient value and the gradient direction of the pixel point may include: calculating a horizontal gradient value and a vertical gradient value of each pixel point in the target image region; taking the sum of the horizontal gradient value and the vertical gradient value of each pixel point in the target image area as the gradient value of the pixel point; and estimating according to the horizontal gradient value and the vertical gradient value of each pixel point in the target image region to obtain the gradient direction of the pixel point.
Since the gradients have directions, one gradient can be decomposed into a horizontal gradient value in the horizontal direction and a vertical gradient value in the vertical direction. The horizontal and vertical gradient values can be calculated using sobel gradient operators, for image coordinates of i, i]V. pixel point of i,i The pixel value of the pixel point at the position is represented, and then the horizontal gradient value and the vertical gradient value can be specifically calculated through the following formula:
Grad i,x =|v i+1,i-1 +2*v i+1,i +v i+1,i+1 -v i-1,i-1 -2*v i-1,i -v i-1,i+1 |
Grad i,y =|v i-1,i+1 +2*v i,i+1 +v i+1,i+1 -v i-1,i-1 -2*v i,i-1 -v i+1,i-1 |
wherein, grad i,x And Grad i,y Representing horizontal and vertical gradient values, respectively.
Because each image block in the DM code is horizontal, flat and vertical and has no round angle, the sum of the horizontal gradient value and the vertical gradient value of one pixel point can be directly used as the gradient value of the pixel point. I.e., grad i =Grad i,x +Grad i,y . Wherein, grad i Representing the gradient values of the pixels.
The gradient direction of a pixel point can be calculated by utilizing a trigonometric function according to the horizontal gradient value and the vertical gradient value of the pixel point, but the speed of calculating the gradient direction according to the trigonometric function is low, and the calculation process is complex. Accordingly, the disclosed embodiments estimate the gradient direction by the horizontal gradient value and the vertical gradient value, wherein the estimation process can be expressed by the following formula:
Figure BDA0003895252280000081
the gradient direction is estimated through the horizontal gradient value and the vertical gradient value, and compared with the method of calculating the direct gradient direction by utilizing a trigonometric function, the calculation performance can be improved by about one hundred times.
After the gradient value and the gradient direction of each pixel point in the target image area are obtained through calculation, each real edge of the DM code can be determined according to the following steps:
step S21: determining a target seed point positioned on each real edge according to the gradient value and the gradient direction of each pixel point in the target image area, wherein the gradient value of the target seed point is greater than the gradient values of the front and rear pixel points in the gradient direction of the target seed point;
step S22: aiming at a target seed point positioned on each solid edge, searching a plurality of pixel points along the tangential direction of the gradient direction of the target seed point to obtain a pixel chain consisting of the pixel points;
step S23: and determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point.
Because the more the pixel points at the edge of the DM code are, the larger the gradient value is, the gradient value of the target seed point on the real edge is larger than the gradient values of the front and rear pixel points in the gradient direction. It is understood that although the solid edge is determined according to the target seed point, the solid edge is objectively present, and thus, although the specific position of the solid edge is not yet determined, the target seed point on the solid edge may be determined first.
Alternatively, in step S21, a plurality of seed points in the target image region may be determined, and then a target seed point located on the real edge may be determined from the plurality of seed points.
Since many edges exist inside the DM code when the image is processed, the seed point can be recognized for other edges. Specifically, the pixel points with the horizontal gradient value larger than the horizontal gradient values of the front and rear two pixel points in the horizontal direction and the pixel points with the vertical gradient value larger than the vertical gradient values of the front and rear two pixel points in the vertical direction are used as seed points.
And performing edge detection on the target image area to obtain the edge of the DM code. The edge of the DM code refers to a position where the real edge is located. The accuracy of edge detection is not high, and only the approximate position of the solid edge can be identified. However, since the other seed points are far from the solid edge, the seed point located at the edge of all the seed points can be determined as the target seed point. Thus, the target seed point located on the solid edge can be obtained.
The target seed point is a pixel point located on the real edge, so the gradient direction of the target seed point is perpendicular to and outward from the real edge. Therefore, the tangential direction of the gradient direction of the target seed point is the direction of the solid edge. Therefore, a plurality of pixel points are searched along the tangential direction of the gradient direction of the target seed point, and the searched pixel points are pixel points of the area where the real edge is located.
In order to ensure that the pixels on the pixel chain are the pixels on the real edge as much as possible, the gradient value of the pixels on the edge is considered to be larger, and therefore, when searching for the pixels, it is required to ensure that the gradient value of the pixels is larger than the gradient threshold and belongs to the local extremum. The gradient value of one pixel belongs to the regional extreme value representation: and comparing the gradient value of each pixel point in the domain area of the pixel point, wherein the gradient value of the pixel point is the maximum value. The gradient threshold may be set as desired.
Optionally, in step S22, when a plurality of pixel points are searched in the tangential direction of the gradient direction of the target seed point, the gradient direction of each searched pixel point may also be obtained. And under the condition that the difference between the gradient direction of one searched pixel point and the gradient direction of the target seed point is greater than or equal to 90 degrees, stopping searching to obtain a pixel chain consisting of a plurality of pixel points.
And under the condition that the difference between the gradient direction of one pixel point and the gradient direction of the target seed point is greater than or equal to 90 degrees, the pixel point is proved not to be positioned on the real edge where the target seed point is positioned, and therefore, the searching is stopped.
Therefore, the pixel chains can ensure that the multiple pixel points of the formed pixel chains are pixel points on the same edge.
Optionally, in step S23, determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point may include:
s231, acquiring a plurality of pixel points which are closest to the target seed point on a pixel chain corresponding to the target seed point;
step S232, performing straight line fitting on the target seed point and the plurality of nearest pixel points to obtain a coarse positioning straight line;
step S233, searching pixel points with the distance from the target seed point in the target image area having mutation along the pixel chain corresponding to the target seed point, and determining the last pixel point of the pixel points as the end point of the real edge where the target seed point is located;
and S234, determining a solid edge of the DM code according to the rough positioning straight line and the end point.
The number of the plurality of pixel points closest to the target seed point on the pixel chain corresponding to the obtained target seed point can be set according to requirements, for example, the number can be ten. By using the target seed point and the plurality of nearest pixel points, a coarse positioning straight line can be obtained by fitting by using a Random sample consensus (RANSAC) algorithm and a straight line fitting method. The rough positioning straight line is the straight line where the solid edge is located.
After the straight line where the solid edge is located is determined, in order to determine the location where the solid edge is located, the end point of the solid edge needs to be determined. The distance from a pixel point in the target image region to the target seed point can be sequentially calculated from near to far along the direction of a pixel chain corresponding to the target seed point, and under the condition that the distance between one pixel point and the target seed point is suddenly changed, the pixel point is proved not to belong to a pixel point on a real edge, so that the previous pixel point of the pixel point can be used as an end point of the real edge.
Therefore, because each pixel point on the pixel chain may not be on a straight line, the rough positioning straight line obtained by fitting is on a straight line according to the target seed point and a plurality of pixel points which are closest to the target seed point on the pixel chain corresponding to the target seed point, and therefore a real edge of the DM code can be determined according to the rough positioning straight line and the end point.
Optionally, on the basis of the above technical solution, it is considered that only part of the pixels in the pixel chain are used for fitting the coarse positioning straight line, and therefore, the accuracy still needs to be improved. If all the pixel points on the pixel chain are used, some pixel points may not be the pixel points really located on the real edge, and therefore, the accuracy also needs to be improved.
Therefore, the coarse positioning straight line can be used for screening the pixel points on the pixel chain, and the screened pixel points are used for performing straight line fitting to obtain the accurate positioning straight line with higher accuracy. Specifically, the distance from each pixel point on the pixel chain corresponding to the target seed point to the coarse positioning line can be calculated, and the pixel points with the distance greater than the set distance are eliminated to obtain a plurality of remaining pixel points of the pixel chain after screening. And performing straight line fitting by using the plurality of screened residual pixel points to obtain a fine positioning straight line.
Thus, when determining the real edge of the DM code, the determination can be made based on the fine positioning line and the end point. The accuracy of the determined solid edge of the DM code is improved.
Theoretically, a straight line has no width, but it is understood that the existence of a straight line in an actual image occupies a certain area. In the related art, the existence of a straight line is represented by a plurality of pixel points located in the same direction. In the embodiment of the present disclosure, the existence of the fitted coarse positioning line/fine positioning line is not represented by a plurality of pixel points, and for each pixel point, the area occupied by the coarse positioning line/fine positioning line is not a complete pixel point. For example, for a pixel, the coarse/fine alignment lines occupy only half the area of the pixel. Therefore, the accuracy of the real edge of the DM code determined by the technical scheme of the embodiment of the disclosure reaches the sub-pixel level.
By adopting the technical scheme of the embodiment of the disclosure, the accuracy of the determined real edge of the DM code is ensured, so that the accuracy of the image area where the DM code is located is also higher based on the real edge. In addition, because of the process of determining the real edge of the DM code, the calculation of the pixel point in the target image area is relatively simple, and does not involve a complicated processing process, thereby having the advantage of high efficiency.
Fig. 4 is a flowchart illustrating a method for decoding a DM code according to an embodiment of the present disclosure, and for an original image, a target image region may be first extracted, and when the target image region is not extracted, information indicating that decoding fails is returned, and when the target image region is extracted, a gradient of each pixel point in the target image region is calculated. The target seed point can be determined according to the gradient of each pixel point in the target image region, so that the pixel chain is positioned according to the target seed point. And fitting to obtain a coarse positioning straight line and a fine positioning straight line according to the target seed point and the pixel points on the pixel chain. The end point of the real edge can be determined by calculating the distance from the pixel point to the target seed point, so that the real edge of the DM code can be determined. According to the real edge of the DM code, the virtual edge of the DM code can be determined, so that the DM code is decoded, a decoding result is obtained, and information of successful decoding is returned.
It is noted that for simplicity of description, the method embodiments are shown as a series of acts or combinations, but those skilled in the art will appreciate that the disclosed embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently with other steps from the disclosed embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the disclosed embodiments.
Fig. 5 is a schematic structural diagram of a DM code decoding apparatus according to an embodiment of the present disclosure, and as shown in fig. 5, the DM code decoding apparatus includes a real edge determining module, a region determining module, and a decoding module, where:
the real edge determining module is used for determining two real edges of the DM code according to the gradient of each pixel point in the original image;
the area determining module is used for determining the image area of the DM code according to the two real edges of the DM code;
and the decoding module is used for decoding the image area where the DM code is located to obtain the decoding result of the DM code.
Optionally, the method further comprises:
a detection module, configured to detect a target image area in the original image, where the target image area is an image area including the DM code;
the calculation module is used for calculating the gradient value and the gradient direction of each pixel point in the target image area;
each solid edge of the DM code is determined according to the following steps:
determining a target seed point positioned on each real edge according to the gradient value and the gradient direction of each pixel point in the target image area, wherein the gradient value of the target seed point is greater than the gradient values of the front and the back pixel points in the gradient direction of the target seed point;
aiming at a target seed point positioned on each real edge, searching a plurality of pixel points along the tangential direction of the gradient direction of the target seed point to obtain a pixel chain consisting of the pixel points, wherein the gradient values of the pixel points are greater than a gradient threshold value and belong to a regional extreme value;
and determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point.
Optionally, searching a plurality of pixel points along a tangential direction of the gradient direction of the target seed point to obtain a pixel chain formed by the plurality of pixel points, including:
searching a plurality of pixel points along the tangential direction of the gradient of the target seed point, and acquiring the gradient direction of each searched pixel point;
and stopping searching under the condition that the difference between the gradient direction of the searched pixel point and the gradient direction of the target seed point is greater than or equal to 90 degrees, so as to obtain a pixel chain consisting of the plurality of pixel points.
Optionally, determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point includes:
acquiring a plurality of pixel points which are closest to the target seed point on a pixel chain corresponding to the target seed point;
performing linear fitting on the target seed point and the nearest pixel points to obtain a coarse positioning straight line;
searching pixel points with the distance from the target seed point in the target image region being suddenly changed along the pixel chain corresponding to the target seed point, and determining the last pixel point of the pixel points as the end point of the real edge where the target seed point is located;
and determining a solid edge of the DM code according to the rough positioning straight line and the end point.
Optionally, the method further comprises:
screening each pixel point on the pixel chain corresponding to the target seed point according to the distance from each pixel point on the pixel chain corresponding to the target seed point to the coarse positioning straight line;
performing linear fitting on the plurality of pixel points which are left after screening to obtain a fine positioning straight line;
determining a real edge of the DM code according to the rough positioning straight line and the end point, comprising:
and determining a solid edge of the DM code according to the fine positioning straight line and the end point.
Optionally, the calculation module comprises:
the calculation unit is used for calculating the horizontal gradient value and the vertical gradient value of each pixel point in the target image area;
a summation unit, configured to take a sum of the horizontal gradient value and the vertical gradient value of each pixel point in the target image region as a gradient value of the pixel point;
and the direction determining unit is used for estimating according to the horizontal gradient value and the vertical gradient value of each pixel point in the target image area to obtain the gradient direction of the pixel point.
Optionally, determining a target seed point located on each real edge according to the gradient value and the gradient direction of each pixel point in the target image region, including:
determining a plurality of seed points of which the horizontal gradient value is larger than the horizontal gradient values of the front and rear pixel points in the horizontal direction, and determining a plurality of seed points of which the vertical gradient value is larger than the vertical gradient value of the front and rear pixel points in the vertical direction;
performing edge detection on the target image area to obtain an edge;
and determining the seed point positioned at the edge in all the seed points as the target seed point.
Optionally, the region determining module includes:
a virtual edge determining unit, configured to obtain two virtual edges of the DM code according to a parallelogram rule and two real edges of the DM code;
and the area determining unit is used for determining an image area surrounded by two real edges and two virtual edges of the DM code in the original image as the image area where the DM code is located.
Optionally, the decoding module comprises:
the mode determining unit is used for determining the mode of the DM code according to the respective times of black and white change of two virtual edges which enclose the image area where the DM code is positioned;
the processing unit is used for carrying out binarization processing on the image area where the DM code is located to obtain a processed image area;
and the decoding unit is used for decoding the processed image area according to the mode of the DM code to obtain the decoding result of the DM code.
It should be noted that the device embodiments are similar to the method embodiments, so that the description is simple, and reference may be made to the method embodiments for relevant points.
The embodiment of the present disclosure also provides an electronic device, and referring to fig. 6, fig. 6 is a schematic diagram of the electronic device provided in the embodiment of the present disclosure. As shown in fig. 6, the electronic apparatus 100 includes: the memory 110 and the processor 120 are connected through a bus communication, the memory 110 and the processor 120 are stored with a computer program, and the computer program can be run on the processor 120, so as to implement the steps in the method for decoding the DM code disclosed in the embodiment of the present disclosure.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program/instruction, which when executed by a processor, implements the method for decoding the DM code as disclosed in the disclosed embodiments.
Embodiments of the present disclosure also provide a computer program product, which includes a computer program/instruction, when executed by a processor, to implement the method for decoding DM codes as disclosed in the embodiments of the present disclosure.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present disclosure may be provided as a method, apparatus, or computer program product. Accordingly, the disclosed embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the disclosed embodiments may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
Embodiments of the present disclosure are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, electronic devices and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the disclosed embodiments have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the disclosure.
Finally, it should also be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrases "comprising one of \ 8230; \8230;" does not exclude the presence of additional like elements in a process, method, article, or terminal device that comprises the element.
The above presents a detailed description of the DM code decoding method, the electronic device, the storage medium, and the program product provided by the present disclosure, and a specific example is applied in this document to explain the principle and the implementation of the present disclosure, and the description of the above embodiments is only used to help understand the method and the core idea of the present disclosure; meanwhile, for a person skilled in the art, according to the idea of the present disclosure, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present disclosure.

Claims (12)

1. A method for decoding a DM code, comprising:
determining two real edges of the DM code according to the gradient of each pixel point in the original image;
determining an image area where the DM code is located according to the two solid edges of the DM code;
and decoding the image area where the DM code is located to obtain a decoding result of the DM code.
2. The method of claim 1, further comprising:
detecting a target image area in the original image, wherein the target image area is an image area containing the DM code;
calculating the gradient value and gradient direction of each pixel point in the target image region;
each solid edge of the DM code is determined according to the following steps:
determining a target seed point positioned on each real edge according to the gradient value and the gradient direction of each pixel point in the target image area, wherein the gradient value of the target seed point is greater than the gradient values of the front and the back pixel points in the gradient direction of the target seed point;
aiming at a target seed point positioned on each real edge, searching a plurality of pixel points along the tangential direction of the gradient direction of the target seed point to obtain a pixel chain consisting of the pixel points, wherein the gradient values of the pixel points are greater than a gradient threshold value and belong to a regional extreme value;
and determining a real edge of the DM code according to a target seed point and a pixel chain corresponding to the target seed point.
3. The method of claim 2, wherein searching for a plurality of pixels along a tangential direction of a gradient direction of the target seed point to obtain a pixel chain formed by the plurality of pixels comprises:
searching a plurality of pixel points along the tangential direction of the gradient of the target seed point, and acquiring the gradient direction of each searched pixel point;
and stopping searching under the condition that the difference between the gradient direction of the searched pixel point and the gradient direction of the target seed point is greater than or equal to 90 degrees, so as to obtain a pixel chain consisting of the plurality of pixel points.
4. The method according to claim 2 or 3, wherein determining a real edge of the DM code according to a target seed point and the pixel chain corresponding to the target seed point comprises:
acquiring a plurality of pixel points which are closest to the target seed point on a pixel chain corresponding to the target seed point;
performing straight line fitting on the target seed point and the plurality of nearest pixel points to obtain a coarse positioning straight line;
searching a pixel point with a distance from the target seed point in the target image region having a sudden change along a pixel chain corresponding to the target seed point, and determining a previous pixel point of the pixel point as an end point of a real edge where the target seed point is located;
and determining a solid edge of the DM code according to the rough positioning straight line and the end point.
5. The method of claim 4, further comprising:
screening each pixel point on the pixel chain corresponding to the target seed point according to the distance from each pixel point on the pixel chain corresponding to the target seed point to the coarse positioning straight line;
performing linear fitting on the plurality of pixel points which are left after screening to obtain a fine positioning straight line;
determining a real edge of the DM code according to the rough positioning straight line and the end point, comprising:
and determining a solid edge of the DM code according to the fine positioning straight line and the end point.
6. The method of any one of claims 2-5, wherein calculating the gradient value and gradient direction for each pixel point in the target image region comprises:
calculating a horizontal gradient value and a vertical gradient value of each pixel point in the target image region;
taking the sum of the horizontal gradient value and the vertical gradient value of each pixel point in the target image area as the gradient value of the pixel point;
and estimating according to the horizontal gradient value and the vertical gradient value of each pixel point in the target image region to obtain the gradient direction of the pixel point.
7. The method of claim 6, wherein determining the target seed point on each real edge according to the gradient value and the gradient direction of each pixel point in the target image region comprises:
determining a plurality of seed points of which the horizontal gradient value is larger than the horizontal gradient values of the front and rear pixel points in the horizontal direction, and determining a plurality of seed points of which the vertical gradient value is larger than the vertical gradient value of the front and rear pixel points in the vertical direction;
performing edge detection on the target image area to obtain an edge;
and determining the seed point positioned at the edge in all the seed points as the target seed point.
8. The method according to any of claims 1-7, wherein determining the image area where the DM code is located according to the two real edges of the DM code comprises:
obtaining two virtual edges of the DM code according to a parallelogram rule and the two real edges of the DM code;
and determining an image area surrounded by the two real edges and the two virtual edges of the DM code in the original image as the image area where the DM code is located.
9. The method according to any of claims 1-8, wherein decoding the image region where the DM code is located to obtain the decoding result of the DM code comprises:
determining the mode of the DM code according to the respective times of black and white change of two virtual edges enclosing the image area where the DM code is located;
carrying out binarization processing on the image area where the DM code is located to obtain a processed image area;
and decoding the processed image area according to the mode of the DM code to obtain a decoding result of the DM code.
10. An electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the method of decoding the DM code of any one of claims 1 to 9.
11. A computer-readable storage medium on which a computer program/instruction is stored, wherein the computer program/instruction, when executed by a processor, implements the method for decoding the DM code according to any one of claims 1 to 9.
12. A computer program product comprising computer programs/instructions, characterized in that the computer programs/instructions, when executed by a processor, implement the method of decoding DM codes according to any of claims 1 to 9.
CN202211276828.0A 2022-10-18 2022-10-18 DM code decoding method, electronic device, storage medium and program product Pending CN115879488A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211276828.0A CN115879488A (en) 2022-10-18 2022-10-18 DM code decoding method, electronic device, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211276828.0A CN115879488A (en) 2022-10-18 2022-10-18 DM code decoding method, electronic device, storage medium and program product

Publications (1)

Publication Number Publication Date
CN115879488A true CN115879488A (en) 2023-03-31

Family

ID=85770484

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211276828.0A Pending CN115879488A (en) 2022-10-18 2022-10-18 DM code decoding method, electronic device, storage medium and program product

Country Status (1)

Country Link
CN (1) CN115879488A (en)

Similar Documents

Publication Publication Date Title
Yang et al. Where is my mirror?
Xie et al. Multilevel cloud detection in remote sensing images based on deep learning
CN111241989B (en) Image recognition method and device and electronic equipment
CN112861776B (en) Human body posture analysis method and system based on dense key points
CN114049512A (en) Model distillation method, target detection method and device and electronic equipment
CN116311214B (en) License plate recognition method and device
CN115147936A (en) Living body detection method, electronic device, storage medium, and program product
CN109523570A (en) Beginning parameter transform model method and device
CN117315263B (en) Target contour device, training method, segmentation method, electronic equipment and storage medium
CN114677330A (en) Image processing method, electronic device and storage medium
CN114359618A (en) Training method of neural network model, electronic equipment and computer program product
CN113704276A (en) Map updating method and device, electronic equipment and computer readable storage medium
CN111767839A (en) Vehicle driving track determining method, device, equipment and medium
CN115984093A (en) Depth estimation method based on infrared image, electronic device and storage medium
CN115879488A (en) DM code decoding method, electronic device, storage medium and program product
CN115223141A (en) Traffic light detection method, electronic device and storage medium
CN116052225A (en) Palmprint recognition method, electronic device, storage medium and computer program product
CN112101139B (en) Human shape detection method, device, equipment and storage medium
CN114648604A (en) Image rendering method, electronic device, storage medium and program product
CN114373071A (en) Target detection method and device and electronic equipment
CN113869367A (en) Model capability detection method and device, electronic equipment and computer readable medium
Jain et al. Discriminability limits in spatio-temporal stereo block matching
CN113705304A (en) Image processing method and device, storage medium and computer equipment
Yang et al. Boundary-guided DCNN for building extraction from high-resolution remote sensing images
CN114882525B (en) Cross-modal pedestrian re-identification method based on modal specific memory network

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