Two-dimensional code detection method, device and equipment and readable storage medium
Technical Field
The invention relates to the technical field of computer vision, in particular to a two-dimensional code detection method, a device, equipment and a readable storage medium.
Background
The two-dimensional bar code/two-dimensional code records data symbol information by using black and white patterns which are distributed on a plane (two-dimensional direction) according to a certain rule by using a certain specific geometric figure. The two-dimensional code is widely applied to scenes such as information acquisition, website skip, advertisement push, mobile phone e-commerce, anti-counterfeiting tracing, preferential promotion, member management, mobile phone payment and the like.
However, a two-dimensional code image shot in a real application scene often includes a background part of a non-two-dimensional code, which further causes a problem of difficulty in recognition. In the prior art, a large amount of parameters which are manually adjusted are needed for detecting the two-dimension codes of the images containing the two-dimension codes, the actual pictures are relatively complex, the parameters need experience when the two-dimension codes are subjected to size difference, position difference, background difference and picture difference, the recovery accuracy is low, and the two-dimension code detection accuracy is further low.
In summary, how to effectively improve the accuracy rate of two-dimensional code detection and the like is a technical problem that needs to be solved urgently by those skilled in the art at present.
Disclosure of Invention
The invention aims to provide a two-dimensional code detection method, a device and equipment and a readable storage medium, so as to improve the accuracy of two-dimensional code detection.
In order to solve the technical problems, the invention provides the following technical scheme:
a two-dimensional code detection method comprises the following steps:
acquiring an original image to be detected, and carrying out size adjustment on the original image to obtain a target image;
inputting the target image into a target detection network based on deep learning, and performing two-dimensional code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value;
and determining the position parameters of the two-dimensional codes in the target image by using the detection values.
Preferably, the performing two-dimensional code detection on the target image by using the detection parameters obtained in the target detection network training process to obtain a detection value includes:
dividing the target image into S-S grids with the same size by using a target detection network, and predicting B preselected frames and a detection value of each preselected frame for each grid by using the detection parameters; and the S and the B are positive integers, and the detection values comprise credibility, two-dimensional code category probability values, center point coordinates and preselected frame sizes.
Preferably, the determining the position parameter of the two-dimensional code in the target image by using the detection value includes:
judging whether a target pre-selection frame with the reliability higher than a preset reliability threshold value and the two-dimensional code class probability value higher than a preset class detection error threshold value exists in the S, S and B pre-selection frames;
if yes, reading a target detection value of the target preselection frame, and taking the center point coordinate and the size of the preselection frame in the target detection value as the position parameters.
Preferably, calculating the detection value of each of the preselected boxes includes:
acquiring a center point coordinate of the preselected frame, and adding the center point coordinate to the detection value;
acquiring the area size of the pre-selection frame, and taking the area size as the size of the pre-selection frame;
and calculating the probability that the center of the two-dimensional code is positioned in the preselected frame, and taking the probability as the credibility.
Preferably, the training process of the target detection network includes:
acquiring a training set, and initializing the detection parameters of a preset convolution network;
performing two-dimensional code detection training on the preset convolutional network by using the training set to optimize the detection parameters, and calculating a detection loss value of the preset convolutional network after each training;
and when the variation difference of the detection loss value is smaller than a preset threshold value, stopping training to obtain the target convolutional network.
Preferably, when the training set includes training input data and detection reference data, the acquiring the training set includes:
acquiring a real image with a two-dimensional code and position marking information of the two-dimensional code in the real image;
and taking the position mark information as the detection reference data, and performing image data enhancement processing on the real image to obtain the training input data.
Preferably, when the reliability is denoted conf, the coordinates are denoted (x, y), and the size is denoted w × h, calculating a detection loss value of the preset convolutional network includes:
using L as Lx+Ly+Lw+Lh+Lconf+LclsCalculating the detection loss value; wherein L isxAs a difference value of x coordinates, LyAs a difference value of y-coordinates, LwAs a value of width difference, LhAs a height difference value, LconfIs a confidence difference value, LclsTo detect the class difference value.
A two-dimensional code detection device includes:
the target image acquisition module is used for acquiring an original image to be detected and carrying out size adjustment on the original image to obtain a target image;
the two-dimension code detection module is used for inputting the target image into a target detection network based on deep learning, and performing two-dimension code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value;
and the two-dimensional code position determining module is used for determining the position parameters of the two-dimensional code in the target image by using the detection values.
A two-dimensional code detection device includes:
a memory for storing a computer program;
and the processor is used for realizing the steps of the two-dimensional code detection method when executing the computer program.
A readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the two-dimensional code detection method described above.
By applying the method provided by the embodiment of the invention, the original image to be detected is obtained, and the size of the original image is adjusted to obtain the target image; inputting a target image into a target detection network based on deep learning, and performing two-dimensional code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value; and determining the position parameters of the two-dimensional codes in the target image by using the detection values.
Because the network used in the two-dimensional code detection process is the target detection network based on deep learning, the detection parameters required in the two-dimensional code detection process can be obtained in the process of training the target detection network. No manual setting by a technician is required. That is, after an original image to be detected is obtained, the original image is first resized to obtain a target image. And then, carrying out two-dimensional code detection on the target image by using the detection parameters obtained in the network training process to obtain a detection value. And then the position parameters of the two-dimensional code in the target image can be determined by using the detection value. Based on the learning ability of the target detection network, the detection parameters required in the two-dimensional code detection process can be obtained in the training process, and the detection effect can be improved by increasing the training rounds and enriching the training set. Therefore, the method can avoid manual setting of detection parameters, and the detection accuracy can be improved under the condition of increasing training rounds or enriching training sets.
Correspondingly, the embodiment of the invention also provides a two-dimensional code detection device, equipment and a readable storage medium corresponding to the two-dimensional code detection method, which have the technical effects and are not described herein again.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart illustrating an implementation of a two-dimensional code detection method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a two-dimensional code detection device according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a two-dimensional code detection device in an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a two-dimensional code detection device in an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment is as follows:
referring to fig. 1, fig. 1 is a flowchart of a two-dimensional code detection method according to an embodiment of the present invention, where the method includes the following steps:
s101, obtaining an original image to be detected, and carrying out size adjustment on the original image to obtain a target image.
The original image to be detected may be an image with one or more two-dimensional codes or an image without two-dimensional codes. The mode of acquiring the original image to be detected can directly read the image data in the storage medium, and can also be acquired by using image acquisition equipment. In order to facilitate the two-dimensional code detection, the size of the original image needs to be adjusted, and the image after the size adjustment is called a target image. The resizing may specifically fix the size of the original image to a specified size, and the specified size should be specifically a size that can be divided into a plurality of grids of the same size by the target convolutional network. For example, if the grid size is 32 × 32, the specified picture side length may be S × 32, where S is a positive integer.
S102, inputting the target image into a target detection network based on deep learning, and carrying out two-dimensional code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value.
The target detection network is a deep learning-based network, so that detection parameters required in the two-dimensional code detection process can be obtained in the process of training the target detection network, and a specific detection parameter obtaining mode is that in the training process, after a detection value output in the training process is continuously compared with a standard value, a comparison result is fed back to the detection network, and the detection network is determined and optimized based on a deep learning algorithm.
The detection process may specifically be: dividing the target image into S-S grids with the same size by using a target detection network, and predicting B preselected frames and the detection value of each preselected frame for each grid by using detection parameters; and S and B are positive integers, and the detection values comprise the reliability, the two-dimensional code category probability value, the center point coordinate and the size of a preselected frame. In the embodiment of the invention, a detection network (such as a common convolutional neural network) can be preset, and then the convolutional network is trained based on a training set to obtain the detection parameters for detecting the two-dimensional code. The training process of the target detection network comprises the following steps:
acquiring a training set, and initializing detection parameters of a preset convolutional network;
performing two-dimensional code detection training on the preset convolutional network by using a training set to optimize detection parameters, and calculating a detection loss value of the preset convolutional network after each training round is finished;
and step three, stopping training when the variation difference of the detection loss value is smaller than a preset threshold value, and obtaining the target convolutional network.
For convenience of description, the above three steps will be described in combination.
The training set may specifically include training input data and detection reference data, and acquiring the training set includes acquiring the training input data and the detection reference data. Specifically, when the training set includes training input data and detection reference data, the training set is obtained, which may be a real image with a two-dimensional code and position marking information of the two-dimensional code in the real image; and taking the position mark information as detection reference data, and performing image data enhancement processing on the real image to obtain training input data. That is, in order to make the detection result more accurate, a real image having the two-dimensional code and position mark information of the two-dimensional code in the real image may be acquired. The position mark information includes at least a size (which may be expressed in width and height) and coordinates (which may be expressed in a coordinate value in a rectangular coordinate system, such as (x, y), but may also be expressed in a planar polar coordinate system). The position mark information can be directly saved in an xml format file for quick reading. In order to improve the diversity of the convolution network, data enhancement processing can be carried out on the real image. Data enhancement can be performed on each real image by at least one of the following enhancement processing modes including but not limited to:
1. rotating: the method can be obtained by firstly amplifying an image on an original image and then cutting the image;
2. translation: firstly, amplifying an image, and then horizontally or vertically shifting and cutting;
3. zooming: zooming the image;
4. horizontally overturning: the vertical axis of the image center is taken as a symmetry axis, and pixels on the left side and the right side are exchanged;
5. filling mode: carrying out image filling in a nearest neighbor mode;
6. color differences (adjustment of color differences such as saturation, brightness, contrast, and sharpness).
After the training set is obtained, the predetermined convolutional network may be initialized, and an initial learning rate may be set, for example, the initial learning rate may be 0.001.
Then, inputting the training set into a preset convolution network, wherein the preset convolution network divides the real image into S-S grids with the same size, and predicts B preselected frames and the detection value of each preselected frame for each grid by using the detection parameters at the current moment. And taking nB S B two-dimensional code detection parameters as output data, wherein nB (number of Batchsize) is the size of the Batchsize in the batch processing process. And then calculating a difference value between the output data and the reference detection data, and feeding back the difference value to a preset convolution network to adjust the detection parameters. Meanwhile, after the training input data in the training set is detected by one wheel, the loss function is used for calculating the detection loss value of the current preset convolution network. And when the variation difference of the detection loss value is smaller than a preset threshold value, stopping training to obtain the target convolutional network.
Calculating a detection loss value of the convolutional network, acquiring output data of the convolutional network, and calculating a total difference value between the output data and detection reference data; the overall difference value is taken as the detection loss value. When the reliability is expressed as conf, the coordinates are expressed as (x, y), and the size is expressed as w × h, the detection loss value of the preset convolution network is calculated, specifically, L is L ═ Lx+Ly+Lw+Lh+Lconf+LclsCalculating a detection loss value; wherein L isxAs a difference value of x coordinates, LyAs a difference value of y-coordinates, LwAs a value of width difference, LhAs a height difference value, LconfIs a confidence difference value, LclsTo detect the class difference value. Wherein,
detection reference data, x, for the jth preselected frame of the ith grid of the real imagei,yi,wi,hi,confi,pi(c) And outputting data, namely detection values, for the detection of the jth preselected frame of the ith grid of the real image. The detection category error is represented by a difference between category probabilities, that is, a probability p of a category c (c is specifically a two-dimensional code). Wherein S may be 13 and B may be 3, i.e. the number of preselected frames is 13 × 3 — 507.
Inputting a target image into a target convolution network, dividing the target image into S-S grids with the same size by using the target convolution network, presetting B pre-selection frames for each grid by using detection parameters obtained in a training process, and calculating a detection value of each pre-selection frame. Wherein, the taking of SThe value is related to the size of the target image, the size of the grid, in particular, the image size is equal to the product of the number of grids and the size of the grid. B is the number of preselected frames for mesh prediction, and may be set to 3 preselected frames of different sizes, for example. The detection value for the ith pre-selected box includes confidence level (e.g., conf)i) Coordinates (e.g., (x)i,yi) Size (e.g., "w")i*hi"), two-dimensional code class probability values (e.g., p)i(c))。
Wherein calculating the detection value for each preselected frame comprises:
step one, obtaining a center point coordinate of the pre-selection frame, and adding the center point coordinate to the detection value;
step two, acquiring the area size of the preselection frame, and taking the area size as the size of the preselection frame;
and thirdly, calculating the probability that the center of the two-dimensional code is positioned in the preselected frame, and taking the probability as the reliability.
For convenience of description, the above three steps will be described in combination.
In the embodiment of the invention, the center point coordinate of the preselected frame can be acquired, and the center point coordinate is taken as the coordinate in the detection value. Of course, in other embodiments of the present invention, other coordinates of the preselected frame may be selected as the coordinates in the detection values. Then, the area size of the pre-selection frame is acquired and taken as the size in the detection value. For example, since most of the two-dimensional codes are rectangular, the size can be represented by using the length and height of the preselected frame, and certainly, if the two-dimensional codes are square, the size can be represented by using only one side length of the preselected frame; in the case of a circular two-dimensional code, the radius of the preselected box may be used for representation. And calculating the probability that the center of the two-dimensional code is positioned in the preselected frame by using the detection parameters, and taking the probability as the reliability.
And S103, determining the position parameters of the two-dimensional codes in the target image by using the detection values.
The position parameter is the size of the position coordinate and the occupied area of the two-dimensional code in the target image. When the detection value comprises the detection type and the position of the corresponding preselection frame (the position coordinate and the area size of the preselection frame), the preselection frame with the detection type as the two-dimensional code is screened out firstly, and then the position of the preselection frame is directly used as the position parameter of the two-dimensional code. When the reliability, the two-dimension code category probability value, the center point coordinate and the size of the preselected frame are satisfied, the position parameters of the two-dimension code in the target image are determined by using the detection values, and the method specifically comprises the following steps:
step one, judging whether a target pre-selection frame with the reliability higher than a preset reliability threshold value and the two-dimensional code class probability value higher than a preset class detection error threshold value exists in S, S and B pre-selection frames;
and step two, if so, reading a target detection value of the target preselection frame, and taking the center point coordinate in the target detection value and the size of the preselection frame as position parameters.
For convenience of description, the above two steps will be described in combination.
And judging whether a target pre-selection frame with the reliability higher than a preset reliability threshold value and the two-dimensional code class probability value higher than a preset class detection error threshold value exists in the S, S and B pre-selection frames.
After the detection value is obtained, whether the two-dimensional code exists in the target image can be combined with the reliability and the two-dimensional code class probability value in the detection value. Specifically, when the reliability is high and the probability value of the two-dimensional code category is high, it is determined that the two-dimensional code exists. Therefore, in the embodiment of the present invention, a confidence threshold and a two-dimensional code detection category error threshold may be preset, and specific values of the two thresholds may be learned and determined when training the convolutional network. Based on the above, whether the two-dimension code exists or not is determined, whether a target pre-selection frame with the reliability higher than a preset reliability threshold value exists or not can be judged, and the two-dimension code class probability value is higher than a preset class detection error threshold value; if so, determining that the target image has the two-dimensional code; and if not, determining that the target image has no two-dimensional code. In the embodiment of the present invention, the number of the two-dimensional codes included in the same target image is not limited, that is, one target image may not have a two-dimensional code, and may have one two-dimensional code or a plurality of two-dimensional codes. That is, the number of target preselection boxes may be 0, or may be greater than or equal to 1.
And then, executing subsequent operation according to the judgment result. Specifically, if yes, further determining a position parameter of the two-dimensional code; and if not, no operation is carried out or the detection result that the two-dimensional code is not detected is output. That is, when no target pre-selection frame exists in the S × B pre-selection frames, a detection result that the target image has no two-dimensional code is output. And when the judgment result is yes, directly reading the target detection value of the target preselection frame, and taking the coordinates and the size in the target detection value as the position parameters of the two-dimensional code. And obtaining the position parameters of the two-dimensional code, namely completing the detection task of the two-dimensional code.
By applying the method provided by the embodiment of the invention, the original image to be detected is obtained, and the size of the original image is adjusted to obtain the target image; inputting a target image into a target detection network based on deep learning, and performing two-dimensional code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value; and determining the position parameters of the two-dimensional codes in the target image by using the detection values.
Because the network used in the two-dimensional code detection process is the target detection network based on deep learning, the detection parameters required in the two-dimensional code detection process can be obtained in the process of training the target detection network. No manual setting by a technician is required. That is, after an original image to be detected is obtained, the original image is first resized to obtain a target image. And then, carrying out two-dimensional code detection on the target image by using the detection parameters obtained in the network training process to obtain a detection value. And then the position parameters of the two-dimensional code in the target image can be determined by using the detection value. Based on the learning ability of the target detection network, the detection parameters required in the two-dimensional code detection process can be obtained in the training process, and the detection effect can be improved by increasing the training rounds and enriching the training set. Therefore, the method can avoid manual setting of detection parameters, and the detection accuracy can be improved under the condition of increasing training rounds or enriching training sets.
Example two:
in order to facilitate better understanding of the two-dimensional code detection method provided by the embodiment of the invention for a person skilled in the art, the two-dimensional code detection method provided by the embodiment of the invention is described in detail below by taking detection of a two-dimensional code in an express bill of an express sorting site as an example.
In order to enable the target convolutional network to better perform two-dimensional code detection on the express bill, a training set for training the target convolutional network can be constructed. Specifically, about 8000 pictures from an express sorting site can be collected, due to the particularity of the pictures, background packages of the pictures are mainly gray black, and express sheets are white, so that the express surface sheets (the size of the express surface sheets is about 30 ten thousand pixels) in original pictures of 1000 ten thousand pixels are cut out in a threshold segmentation and connected domain detection mode, a new data set is obtained, the size of the pictures input into a deep learning network, namely a preset convolution network is reduced, and invalid backgrounds are removed.
And manually labeling the image obtained after the clipping, and saving the labeling information in a file with a format such as xml, json and txt. The labeling information mainly comprises the position of the two-dimensional code, namely the coordinate of the center point of the two-dimensional code and the size of a preselected frame. Then, 80% of the images can be randomly selected as a training set, and another 20% can be used as a test set.
And performing data enhancement on the picture input into the network, including operations of size conversion, brightness, contrast, saturation distortion, random clipping and sampling and the like to obtain final input data.
Under a classic PyTorch deep learning framework, based on the idea of YOLOv3, the multi-scale prediction can be reduced and the detection speed can be increased by considering the invariance of the detection target two-dimensional code scale, namely, only the position of the two-dimensional code is predicted or detected. The detection target is only one type, namely two-dimensional code, and has larger category difference with the traditional data set, a Dense Convolutional Network (DenseConvolutional Network) which is easier to train from the beginning can be selected as a main body, and the number of layers of the Convolutional layer can be reduced in order to improve the detection speed. Specifically, the parameter growth _ rate in the DenseNet is set to be 16, the parameter block _ config is set to be (6, 12, 24), and finally, the network output is fixed to be nB 18 13 by one convolution of 1 by 1.
Loss boxNumber, expressed as: l ═ L
x+L
y+L
w+L
h+L
conf+L
clsCalculating a total difference value; wherein Lx is an x coordinate difference value, Ly is a y coordinate difference value, Lw is a width difference value, Lh is a height difference value, Lconf is a reliability difference value, and Lcls is a detection category difference value. Wherein,
specifically, the mean square sum error under the deep learning frame can be selected to calculate a position loss function, and the cross entropy loss is used to calculate a reliability difference value and a detection category difference value.
The training process comprises the following steps:
step A, preprocessing the established picture data set and then reading the picture data set according to a format of Bacthsize 16 (namely nB);
b, writing the modified DenseNet model structure into a model file under a PyTorch framework;
step C, adding a loss function into the source code, setting the initial learning rate to be 0.001, reducing the learning rate to be 0.8 in each 10 rounds, and recompiling;
and D, training the model by using the training set data, and detecting the overall effect of the model on the test set data, wherein the training is performed for 50 rounds in total. Of course, the training round may also be other numerical values, and when the variation difference of the detected loss value calculated by the loss function is smaller, the training can be regarded as being completed. Specifically, whether the difference value is smaller or not can be compared with a preset threshold value.
After the model training is completed, the picture to be detected can be input into the network, and then the detection value with the size of 18 × 13 is output to indicate the prediction of the network on the position of the two-dimensional code in the picture.
Example three:
corresponding to the above method embodiment, an embodiment of the present invention further provides a two-dimensional code detection apparatus, and the two-dimensional code detection apparatus described below and the two-dimensional code detection method described above may be referred to in a mutually corresponding manner.
Referring to fig. 2, the apparatus includes the following modules:
a target image obtaining module 101, configured to obtain an original image to be detected, and perform size adjustment on the original image to obtain a target image;
the two-dimension code detection module 102 is used for inputting a target image into a target detection network based on deep learning, and performing two-dimension code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value;
and the two-dimensional code position determining module 103 is used for determining the position parameters of the two-dimensional code in the target image by using the detection values.
By applying the device provided by the embodiment of the invention, the original image to be detected is obtained, and the size of the original image is adjusted to obtain the target image; inputting a target image into a target detection network based on deep learning, and performing two-dimensional code detection on the target image by using detection parameters obtained in the training process of the target detection network to obtain a detection value; and determining the position parameters of the two-dimensional codes in the target image by using the detection values.
Because the network used in the two-dimensional code detection process is the target detection network based on deep learning, the detection parameters required in the two-dimensional code detection process can be obtained in the process of training the target detection network. No manual setting by a technician is required. That is, after an original image to be detected is obtained, the original image is first resized to obtain a target image. And then, carrying out two-dimensional code detection on the target image by using the detection parameters obtained in the network training process to obtain a detection value. And then the position parameters of the two-dimensional code in the target image can be determined by using the detection value. Based on the learning ability of the target detection network, the detection parameters required in the two-dimensional code detection process can be obtained in the training process, and the detection effect can be improved by increasing the training rounds and enriching the training set. Therefore, the device can avoid manual setting of detection parameters, and the detection accuracy can be improved under the condition of increasing training rounds or enriching training sets.
In an embodiment of the present invention, the two-dimensional code detection module 102 is specifically configured to divide the target image into S × S grids with the same size by using a target detection network, and predict B preselected frames and a detection value of each preselected frame for each grid by using the detection parameters; and S and B are positive integers, and the detection values comprise the reliability, the two-dimensional code category probability value, the center point coordinate and the size of a preselected frame.
In a specific embodiment of the present invention, the two-dimensional code position determining module 103 is specifically configured to determine whether there is a target pre-selection frame in the S × B pre-selection frames, where the reliability is greater than a preset reliability threshold and the two-dimensional code category probability value is greater than a preset category detection error threshold; if yes, reading a target detection value of the target preselection frame, and taking the center point coordinate in the target detection value and the size of the preselection frame as position parameters.
In a specific embodiment of the present invention, the two-dimensional code detection module 102 is specifically configured to obtain a center point coordinate of the preselected frame, and add the center point coordinate to the detection value; acquiring the area size of the pre-selection frame, and taking the area size as the size of the pre-selection frame; and calculating the probability that the center of the two-dimensional code is positioned in the preselected frame, and taking the probability as the credibility.
In one embodiment of the present invention, the method further comprises:
the network training module is used for acquiring a training set and initializing the detection parameters of the preset convolutional network; carrying out two-dimensional code detection training on the preset convolutional network by utilizing a training set to optimize detection parameters, and calculating a detection loss value of the preset convolutional network after each training round is finished; and when the variation difference of the detection loss value is smaller than a preset threshold value, stopping training to obtain the target convolutional network.
In a specific embodiment of the present invention, the network training module is specifically configured to obtain a real image with a two-dimensional code and position marking information of the two-dimensional code in the real image; and taking the position mark information as detection reference data, and performing image data enhancement processing on the real image to obtain training input data.
In an embodiment of the present invention, the network training module is specifically configured to utilize L ═ L when the confidence level is denoted conf, the coordinates are denoted (x, y), and the size is denoted w × hx+Ly+Lw+Lh+Lconf+LclsCalculating a detection loss value; wherein L isxAs a difference value of x coordinates, LyAs a difference value of y-coordinates, LwAs a value of width difference, LhAs a height difference value, LconfIs a confidence difference value, LclsTo detect the class difference value.
Example four:
corresponding to the above method embodiment, an embodiment of the present invention further provides a two-dimensional code detection device, and a two-dimensional code detection device described below and a two-dimensional code detection method described above may be referred to in a mutually corresponding manner.
Referring to fig. 3, the two-dimensional code detecting apparatus includes:
a memory D1 for storing computer programs;
and a processor D2, configured to implement the steps of the two-dimensional code detection method of the foregoing method embodiment when executing the computer program.
Specifically, referring to fig. 4, fig. 4 is a schematic diagram of a specific structure of a two-dimensional code detection device provided in this embodiment, which may generate relatively large differences due to different configurations or performances, and may include one or more processors (CPUs) 322 (e.g., one or more processors) and a memory 332, and one or more storage media 330 (e.g., one or more mass storage devices) storing an application 342 or data 344. Memory 332 and storage media 330 may be, among other things, transient storage or persistent storage. The program stored on the storage medium 330 may include one or more modules (not shown), each of which may include a series of instructions operating on a data processing device. Further, the central processor 322 may be configured to communicate with the storage medium 330, and execute a series of instruction operations in the storage medium 330 on the two-dimensional code detection device 301.
The two-dimensional code detection device 301 may also include one or more power sources 326, one or more wired or wireless network interfaces 350, one or more input-output interfaces 358, and/or one or more operating systems 341. For example, Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeB SDTM, etc.
The steps in the two-dimensional code detection method described above may be implemented by the structure of a two-dimensional code detection apparatus.
Example five:
corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium, and a readable storage medium described below and a two-dimensional code detection method described above may be referred to in a mutually corresponding manner.
A readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the two-dimensional code detection method of the above-mentioned method embodiment.
The readable storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various other readable storage media capable of storing program codes.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.