Two-dimensional code image recognition method and device, electronic equipment and storage medium
Through the binarization prediction method of sliding window of the full convolution network, the accuracy problem of QR code image recognition in noise and complex scenarios is solved, achieving higher recognition accuracy and lower computing complexity.
Patent Information
- Application Number
- CN202411052580.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
AI Technical Summary
The existing QR code image recognition methods are prone to misjudgment in the case of severe noise, blurred boundaries or overprinting, resulting in a decrease in recognition accuracy.
Using the sliding window binary prediction method based on a full convolutional network, the sliding window binary prediction of the QR code image is performed through the trained preset network model, and the virtual sliding window is dynamically updated to realize multi-point sampling prediction, replacing the traditional single point sampling method.
The accuracy of QR code image recognition is improved, especially in complex scenarios, such as overprint codes, blur codes and uneven light codes, reducing the computational complexity and time-consuming.
Smart Images

Figure CN119006836A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image recognition technology, and in particular, relates to a two-dimensional code image recognition method, device, electronic device and storage medium. Background Art
[0002] In daily life, QR code has become one of the most convenient means of information dissemination due to its advantages of large information capacity, strong fault tolerance and low cost. It is widely used in various fields such as e-commerce and product traceability. QR code is a black and white graphic composed of certain specific geometric shapes distributed in a plane according to a certain pattern to record data symbol information.
[0003] The existing method for recognizing two-dimensional code images extracts the grayscale pixel value of the center point of the cell during the black and white judgment process, compares it with a certain threshold, and then determines whether the cell is 0 or 1. This method will cause sampling errors for cells with severe noise, or cells with blurred boundaries, overprinting, etc., and will cause misjudgment when binarizing the image. Therefore, how to improve the recognition accuracy of two-dimensional code images is a problem currently faced. Summary of the invention
[0004] The embodiments of the present application provide a two-dimensional code image recognition method, device, electronic device and storage medium, which can improve the accuracy of two-dimensional code image recognition.
[0005] In a first aspect, an embodiment of the present application provides a two-dimensional code image recognition method, comprising the steps of:
[0006] Get the QR code image to be identified;
[0007] Determining version information of the two-dimensional code image to be identified;
[0008] According to the version information and the trained preset network model, a sliding window binarization prediction is performed on the two-dimensional code image to be identified to obtain a binarization sequence; the preset network model is constructed based on a full convolutional network;
[0009] The binary sequence is decoded to obtain corresponding decoding information.
[0010] In a possible implementation manner of the first aspect, obtaining the to-be-recognized two-dimensional code image includes:
[0011] Get the target image;
[0012] The two-dimensional code image to be identified contained in the target image is determined based on the image positioning model.
[0013] In a possible implementation manner of the first aspect, performing sliding window binarization prediction on the to-be-recognized two-dimensional code image according to the version information and the trained preset network model to obtain a binarized sequence includes:
[0014] A virtual sliding window is established based on the two-dimensional code image to be identified; the window of the virtual sliding window covers part of the cells in the two-dimensional code image to be identified;
[0015] Determining a window size of the virtual sliding window according to the version information and a first preset condition;
[0016] In the process of performing sliding window binarization prediction on the to-be-recognized two-dimensional code image by using the trained preset network model, dynamically updating the virtual sliding window according to the window size;
[0017] Until all cells in the to-be-identified two-dimensional code image are predicted, a binarized sequence corresponding to all cells is obtained; the values in the binarized sequence correspond to the cells one-to-one.
[0018] In a possible implementation manner of the first aspect, the method is applied to an embedded device; and determining the window size of the virtual sliding window according to the version information and the first preset condition includes:
[0019] The window size of the virtual sliding window is determined according to the version information, the first preset condition and the computing power of the embedded device.
[0020] In a possible implementation of the first aspect, the fully convolutional network includes multiple first set operation modules and one second set operation module, the first set operation modules are used to extract features, the second set operation modules are used to reduce dimensionality, and the second set operation module is located between two of the first set operation modules; the first set operation modules and the second set operation modules both include a depthwise separable convolutional layer, and the size of the convolution kernel in the depthwise separable convolutional layer of the first set operation module and the second set operation module is 3×3.
[0021] In a possible implementation manner of the first aspect, the sliding step of the second set operation module is greater than the sliding step of the first set operation module.
[0022] In a possible implementation of the first aspect, the first set operation module also includes a first convolutional layer, a second convolutional layer and a summation layer, the first convolutional layer is connected to the input layer, the first convolutional layer, the depth-separable convolutional layer, the second convolutional layer and the summation layer are connected in sequence, and the summation layer is used to add the output result of the second convolutional layer and the data of the input layer and output them.
[0023] In a second aspect, an embodiment of the present application provides a two-dimensional code image recognition device, comprising:
[0024] A two-dimensional code image acquisition module is used to acquire a two-dimensional code image to be identified;
[0025] A version information determination module, for determining the version information of the two-dimensional code image to be identified;
[0026] A binarization prediction module performs sliding window binarization prediction on the to-be-recognized two-dimensional code image according to the version information and a trained preset network model to obtain a binarization sequence; the preset network model is constructed based on a fully convolutional network;
[0027] The binary sequence decoding module decodes the binary sequence to obtain corresponding decoding information.
[0028] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the two-dimensional code image recognition method described in any one of the first aspects above when executing the computer program.
[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the two-dimensional code image recognition method described in any one of the first aspects above is implemented.
[0030] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0031] The embodiment of the present application performs binary prediction on the cells in the two-dimensional code image to be identified based on a trained fully convolutional network, that is, a convolutional neural network model with the fully connected layer removed performs binary prediction on the cells in the two-dimensional code image to be identified, so that in the cell sampling process, multi-point sampling prediction can be achieved instead of single-point sampling prediction, which can improve the accuracy of cell sampling prediction in the two-dimensional code image, thereby improving the accuracy of two-dimensional code image recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 It is a flowchart of a two-dimensional code image recognition method provided by an embodiment of the present application;
[0034] Figure 2 is a flowchart of a two-dimensional code image recognition method provided by another embodiment of the present application;
[0035] Figure 3 It is a schematic diagram of a virtual sliding window moving process in a two-dimensional code image recognition method provided in an embodiment of the present application;
[0036] Figure 4 It is a schematic diagram of the structure of a fully convolutional network provided in one embodiment of the present application;
[0037] Figure 5 It is a structural diagram of a first set operation module in a fully convolutional network provided in an embodiment of the present application;
[0038] Figure 6 It is a structural diagram of a second set operation module in a fully convolutional network provided in an embodiment of the present application;
[0039] Figure 7 It is a structural schematic diagram of a two-dimensional code image recognition device provided in an embodiment of the present application;
[0040] Figure 8 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0042] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0043] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0044] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0045] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0046] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0047] like Figure 1 As shown, the embodiment of the present application discloses a two-dimensional code image recognition method. Among them, the embodiment of the present application is applied to a two-dimensional code of the type of data matrix code (Data Matrix). The above method includes the following steps:
[0048] S110, obtaining a two-dimensional code image to be identified, that is, locating the two-dimensional code image to be identified in an image.
[0049] S120, determine the version information of the two-dimensional code image to be identified. Specifically, in the above-mentioned image positioning process, the coordinates of the four corner points of the two-dimensional code image can be obtained. Since all the types of version information are limited, this embodiment can calculate the target value of each type of version information based on a preset objective function, and then the version information corresponding to the maximum target value is used as the version information of the two-dimensional code image to be identified. Among them, the above-mentioned four corner point coordinates and each type of version information are used as input parameters of the preset objective function.
[0050] The selection of the above-mentioned preset objective function can be implemented by referring to the existing methods. For example, the sum of the pixels of the odd points of the image cells can be subtracted from the sum of the pixels of the even points, and then divided by the currently calculated version size, and the absolute value is taken as the calculation result. The above-mentioned odd and even points are the center points of the cells at odd positions and the center points of the cells at even positions in the row direction. According to the version information and the length of the side of the image, the width of the cell in the image can be calculated, where the cell width is the ratio between the length of the side and the number of cells on the side. The number of cells on the side can be determined according to the version information. For example, if the version information is 18×18, it means that the number of cells on the side is 18. The length of the side of the image can be calculated based on the coordinates of the two corresponding corner points on the side.
[0051] The version information of the to-be-identified two-dimensional code image may also be determined by other existing methods, which will not be described in detail in this embodiment.
[0052] S130, according to the version information and the trained preset network model, the two-dimensional code image to be identified is predicted by sliding window binarization to obtain a binary sequence. The preset network model is built based on a fully convolutional network (FCN). In this embodiment, since there is no fully connected layer in the fully convolutional network model, that is, the fully connected layer is removed in the preset network model, it is convenient to realize multi-point sampling prediction in the cell. The above preset network model can accurately identify each cell in the two-dimensional code image to be identified, and then make a black and white judgment on the cell, and convert it into a binary value according to the color of the cell, so that all cell grids are sampled and extracted to obtain a binary sequence. In one possible implementation, white corresponds to the binary value 1, and black corresponds to the binary value 0.
[0053] In this embodiment, compared with the scheme of comparing and judging black and white based on a single sampling point and a fixed threshold, the full convolution network can take into account the pixels of the entire cell and compare with the surrounding cells to judge black and white. Therefore, the sampling method based on the full convolution network can achieve better results in complex scenes. In addition, the full convolution network is also a kind of convolutional neural network, which can extract deeper features than traditional manually extracted features for sampling prediction through the stacking operation of multi-level convolution kernels, so it has better prediction performance, which is conducive to improving the accuracy of two-dimensional code image recognition.
[0054] Among them, during the training process of the above-mentioned fully convolutional network, the training data size is a 40*40*1 picture, in which the size of each cell is 5*5 pixels, so the 40*40 picture can represent the black and white information of 64 cells, and the corresponding annotation information is annotated for each training sample, white cells represent 1, and black cells represent 0. During training, the output of the network needs to be adjusted. The result of the network output is a number from negative infinity to positive infinity. The sigmoid activation function is required to map the data to between 0 and 1. It can be iterated through the loss function and gradient back propagation. After multiple iterations, the network model with the best test effect is selected for output. In a possible implementation, the sigmoid activation function is shown in formula (1):
[0055]
[0056] Among them, x represents the network output result before transformation, and sigmoid(x) represents the network output result after transformation.
[0057] S140, decoding the binary sequence to obtain corresponding decoding information.
[0058] This embodiment performs binary prediction on the cells in the two-dimensional code image to be identified based on the trained full convolutional network, that is, the convolutional neural network model with the fully connected layer removed performs binary prediction on the cells in the two-dimensional code image to be identified, so that in the cell sampling process, multi-point sampling prediction can be achieved instead of single-point sampling prediction, which can improve the accuracy of cell sampling prediction in the two-dimensional code image, thereby improving the accuracy of two-dimensional code image recognition. This method can improve the sampling accuracy in complex scenes such as overprinted codes, fuzzy codes, and uneven illumination codes, thereby improving the decoding ability.
[0059] In addition, the fully convolutional network provided in this embodiment only involves downsampling, and no upsampling, in the process of sampling cells of the QR code. Compared with the traditional convolutional neural network, which uses a combination of downsampling and upsampling in the process of repairing the QR code image, it leads to the problems of high time consumption and large amount of calculation. Since this embodiment only has downsampling, it means that the network focuses on feature extraction and dimensionality reduction, rather than generating an output with the same resolution as the input. It has a simpler structure, lower model complexity, smaller amount of calculation, and less time consumption.
[0060] In some optional embodiments, in the above Figure 1 Based on the corresponding embodiment, step S110 specifically includes:
[0061] S1101, acquiring a target image.
[0062] S1102, determining the two-dimensional code image to be identified contained in the target image based on the image positioning model. Specifically, this step includes: determining the edge of the two-dimensional code image to be identified, identifying the corner points of the two-dimensional code image to be identified based on the edge, and obtaining the coordinates of the corner points. The two-dimensional code image to be identified can be located based on the corner points. The corner points are the four intersection points where the edge straight lines of the two-dimensional code image to be identified intersect.
[0063] The two-dimensional code image to be identified is subjected to perspective transformation according to the coordinates of the corner points. The edge of the two-dimensional code image to be identified can be determined based on an edge detection algorithm. The corner point detection can be implemented based on a corner point detection algorithm (such as Harris corner point detection). Based on the perspective transformation, the tilted or distorted two-dimensional code image to be identified can be corrected to make it straight.
[0064] In other optional embodiments, before locating the QR code image to be identified, the target image can be repaired, such as grayscale processing of the target image, because the positioning and identification of the QR code usually does not require color information; for example, a filter can be applied to remove noise to improve image quality.
[0065] Another embodiment of the present application discloses another two-dimensional code image recognition method. Figure 2 As shown, this embodiment is Figure 1 Based on the corresponding embodiment, step S130 specifically includes:
[0066] S1301, establish a virtual sliding window based on the two-dimensional code image to be identified. The window of the virtual sliding window covers part of the cells in the two-dimensional code image to be identified. In a possible implementation, the window of the virtual sliding window is a square, but the present application is not limited thereto.
[0067] S1302, determine the window size of the virtual sliding window according to the version information and the first preset condition. The first preset condition is that the window size is greater than the first preset threshold. Because in the process of black and white judgment, i.e., binary prediction of a cell, this embodiment needs to refer to the information of other cells in the window of the virtual sliding window for comprehensive determination, this embodiment is based on the setting that the window size is greater than the first preset threshold, which can avoid the situation where the window size is set too small, resulting in less reference information provided by the surrounding cells, that is, it can ensure that in the process of binary prediction of a cell, the surrounding cells can provide sufficient reference information, which is conducive to ensuring the accuracy of two-dimensional code image recognition.
[0068] According to the version information, the number of cells on each side boundary of the two-dimensional code image to be identified can be known. The window size of the virtual sliding window must be smaller than the number of cells on each side boundary. Therefore, that is, the above version information can represent the upper limit value of the window size, the first preset condition can represent the lower limit value of the window size, and the window size of the virtual sliding window is greater than the above lower limit value and less than the above upper limit value. As an example and not a limitation, the above first preset threshold value can be 2. The above window size can be a window width. This application is not limited to this.
[0069] S1303, in the process of performing sliding window binarization prediction on the two-dimensional code image to be recognized by the trained preset network model, the virtual sliding window is dynamically updated according to the window size, that is, the virtual sliding window is first moved horizontally and then moved vertically according to the window size.
[0070] S1304, until all cells in the two-dimensional code image to be identified are predicted, and the binarized sequences corresponding to all cells are obtained. The values in the binarized sequence correspond to the cells one by one. That is, each cell is converted into binary 0 or binary 1 according to its corresponding black or white. After each prediction, the binary sequence corresponding to all cells contained in each sliding window is obtained, and then the binary sequences corresponding to all sliding windows are spliced and repeated, that is, when there are repeated sampling predictions for some cells, the last prediction result is taken to obtain the final binary sequence corresponding to all cells in the two-dimensional code image to be identified.
[0071] Because the full convolutional network usually recognizes a two-dimensional code image to be recognized of a specific version size, for example, only 8*8 cells can be predicted at a time, and the two-dimensional code image to be recognized has different version information (such as 10*10, 12*12, 14*14, 16*16, 18*18, 20*20, etc.), that is, the number of cells to be predicted is variable, then the conventional convolutional neural network cannot meet this requirement. Therefore, in this embodiment, the full convolutional network is combined with a sliding window to sample and predict the two-dimensional code image to be recognized. After one prediction, the sliding window is used to predict the position that has not been predicted before again until all predictions are completed. In this way, the recognition of two-dimensional code images of different version sizes can be realized, thereby improving the versatility and generalization of the two-dimensional code image recognition method.
[0072] refer to Figure 3, which corresponds to a two-dimensional code of the data matrix code type with version information of 18*18. The two-dimensional code can represent the black and white information of 324 cells. The size of each cell is 5*5 pixels, so the data size of the two-dimensional code is 90*90*1. That is, the network regards 5x5 pixels as a cell, corresponding to one output point. The window size of the virtual sliding window is the width of 8 cells, that is, the window of the virtual sliding window can only accommodate 8*8 cells, and only 8*8 cells are predicted each time. After predicting an area, slide 8 cells to the right in the direction of the horizontal arrow, that is, 40 pixels, to predict the next area. When the boundary is expected to be less than 8 cells, the area with the width of the last 8 cells is taken for prediction. At this time, there will be repeated prediction areas. In this case, the last prediction result can be taken for the repeated prediction area. Repeat the above steps, move down 8 cells after completing a horizontal area, such as Figure 3 As shown by the vertical arrow, and then move horizontally. Repeat this process until the entire QR code area of the version is predicted. The final 18*18 version of the QR code requires 9 predictions (as shown in Figure 3 That is, in this example, the virtual sliding window slides 3 times along the width direction and 3 times along the height direction, and the number of operations of the network model is (3*3) times, that is, 9 times.
[0073] In some optional embodiments, in the above Figure 2 On the basis of the corresponding embodiment, the above method is applied to an embedded device. In addition, step S1302 is replaced by the following steps:
[0074] The window size of the virtual sliding window is determined according to the version information, the first preset condition and the computing power of the embedded device.
[0075] Specifically, in this embodiment, the window size of the virtual sliding window satisfies: being larger than the lower limit value represented by the first preset condition and smaller than the upper limit value determined by the version information, and ensuring that the computing power of the embedded device can support it. Because the two-dimensional code image recognition method is usually applied to embedded devices such as code readers and edge devices, and because the computing power of these devices is usually small, the window size determined by the method provided in this embodiment can ensure the reliability of the system.
[0076] As an example but not limitation, the computing power of the embedded device may be, for example, the number of floating-point operations that can be performed per second.
[0077] In some other optional embodiments, Figure 4 As shown, based on any of the above embodiments, the full convolutional network includes multiple first set operation modules (i.e. Figure 4 s1 module in the example) and a second set operation module (i.e. Figure 4The first set operation module is used to extract features, and the second set operation module is used to reduce the dimension, that is, reduce the image size. The second set operation module is located between the two first set operation modules. The first set operation module and the second set operation module both include depthwise separable convolution (Depthwise separable convolution, i.e. Figure 5 and Figure 6 The Dwise layer in the first set operation module and the size of the convolution kernel in the depthwise separable convolution layer of the second set operation module are both 3×3. Depthwise separable convolution is an algorithm obtained by improving the standard convolution calculation in convolutional neural networks. It reduces the number of parameters required for convolution calculation by splitting the correlation between spatial dimension and channel (depth) dimension.
[0078] refer to Figure 4 In this embodiment, the full convolutional network also includes multiple convolutional layers, CONV 3×3×32 means that the convolution kernel size is 3×3×32. CONV 1×1×1 means that the convolution kernel size is 1×1×1. C represents the number of channels, and the number of channels refers to the depth dimension of each convolution layer or input data in the network. Pad represents the boundary filling pixel value, Relu represents the nonlinear function, and the Relu layer is used for nonlinear transformation. S represents the sliding stride, S=2, which means that the sliding stride is 2, that is, 2 cells are slid each time. Input: 40*40*1 means that the size of the input image is 40*40*1, where the size of each cell is 5*5 pixels, so the output image size is 8*8*1.
[0079] refer to Figure 5 In this embodiment, the first set operation module also includes a first convolution layer 51, a second convolution layer 52 and an addition layer (i.e., an ADD layer). The first convolution layer is connected to the input layer. The first convolution layer 51, the depthwise separable convolution layer 53, the second convolution layer 52 and the addition layer are connected in sequence. The addition layer is used to add the output result of the second convolution layer and the data of the input layer and then output them. Dwise 3×3 means that the size of the convolution kernel in the depthwise separable convolution layer is 3×3. pad=1 means that the boundary padding pixel value is 1. The depthwise separable convolution layer 53 of the first set operation module is located between the two convolution layers.
[0080] refer to Figure 6 In this embodiment, the sliding stride of the second set operation module is greater than the sliding stride of the first set operation module. The second set operation module also includes two convolutional layers (i.e., the third convolutional layer 61 and the fourth convolutional layer 62). In the second set operation module, the depthwise separable convolutional layer 63 of the second set operation module is located between the third convolutional layer 61 and the fourth convolutional layer 62.
[0081] First, the above-mentioned embodiment of the present application performs binary prediction on the cells in the two-dimensional code image to be identified based on the trained full convolutional network, that is, the convolutional neural network model with the fully connected layer removed performs binary prediction on the cells in the two-dimensional code image to be identified, so that in the cell sampling process, multi-point sampling prediction can be achieved instead of single-point sampling prediction, which can reduce the impact of environmental factors on two-dimensional code recognition, improve the accuracy of cell sampling prediction in two-dimensional code images, and thus improve the accuracy of two-dimensional code image recognition. This method can improve the sampling accuracy in complex scenes such as overprinted codes, fuzzy codes, and uneven illumination codes, thereby improving decoding capabilities.
[0082] Second, the fully convolutional network provided in the above embodiment of the present application only involves downsampling and no upsampling in the cell sampling process of the QR code, which allows the network to focus on feature extraction and dimensionality reduction rather than generating an output with the same resolution as the input. It has a simpler structure, lower model complexity, smaller computational complexity, and less time consumption.
[0083] Third, the above-mentioned embodiment of the present application sets the window width to be greater than the first preset threshold value, which can avoid the situation where the window width is set too small, resulting in less reference information provided by the surrounding cells. That is, it can ensure that during the binary prediction process of a cell, the surrounding cells can provide sufficient reference information, which is beneficial to ensure the accuracy of QR code image recognition.
[0084] Fourth, the above-mentioned embodiment of the present application uses a fully convolutional network combined with a sliding window to perform sampling prediction on the QR code image to be recognized. After one prediction, the sliding window is used to predict again the positions that have not been predicted before, until all predictions are completed. In this way, the recognition of QR code images of different version sizes can be realized, thereby improving the versatility and generalization of the QR code image recognition method.
[0085] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0086] It should be noted that the above-mentioned method embodiments disclosed in the present application can be freely combined, and the technical solutions obtained after the free combination are also within the protection scope of the present application.
[0087] Corresponding to the two-dimensional code image recognition method described in the above embodiment, Figure 7 A structural block diagram of a two-dimensional code image recognition device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0088] Reference Figure 7 , the two-dimensional code image recognition device comprises:
[0089] The two-dimensional code image acquisition module 71 acquires the two-dimensional code image to be identified.
[0090] The version information determination module 72 determines the version information of the two-dimensional code image to be identified.
[0091] The binary prediction module 73 performs sliding window binary prediction on the two-dimensional code image to be recognized according to the version information and the trained preset network model to obtain a binary sequence. The preset network model is constructed based on a full convolutional network.
[0092] The binary sequence decoding module 74 decodes the binary sequence to obtain corresponding decoding information.
[0093] The embodiment of the present application performs binary prediction on the cells in the two-dimensional code image to be identified based on a trained fully convolutional network, that is, a convolutional neural network model with the fully connected layer removed performs binary prediction on the cells in the two-dimensional code image to be identified, so that in the cell sampling process, multi-point sampling prediction can be achieved instead of single-point sampling prediction, which can improve the accuracy of cell sampling prediction in the two-dimensional code image, thereby improving the accuracy of two-dimensional code image recognition.
[0094] In some optional embodiments, the two-dimensional code image acquisition module 71 includes:
[0095] The first unit is used to obtain a target image.
[0096] The second unit determines the to-be-recognized two-dimensional code image contained in the target image based on the image positioning model.
[0097] In some optional embodiments, the binarization prediction module 73 includes:
[0098] A virtual sliding window establishing unit is configured to establish a virtual sliding window based on the two-dimensional code image to be identified; the window of the virtual sliding window covers part of the cells in the two-dimensional code image to be identified;
[0099] A sliding window size determining unit, which determines the window size of the virtual sliding window according to the version information and a first preset condition;
[0100] A virtual sliding window updating unit, which dynamically updates the virtual sliding window according to the window size during the process of performing sliding window binarization prediction on the to-be-recognized two-dimensional code image through the trained preset network model;
[0101] The binary sequence updating unit is configured to complete the prediction of all cells in the two-dimensional code image to be identified, thereby obtaining the binary sequences corresponding to all cells; the values in the binary sequence correspond to the cells one by one.
[0102] In some optional embodiments, the above apparatus is applied to an embedded device. The sliding window size determination unit includes:
[0103] The first subunit is used to determine the window size of the virtual sliding window according to the version information, the first preset condition and the computing power of the embedded device.
[0104] In some optional embodiments, the fully convolutional network includes multiple first set operation modules and one second set operation module, the first set operation module is used to extract features, the second set operation module is used to reduce dimensionality, and the second set operation module is located between two of the first set operation modules; the first set operation module and the second set operation module both include a depthwise separable convolutional layer, and the size of the convolution kernel in the depthwise separable convolutional layer of the first set operation module and the second set operation module is both 3×3.
[0105] In some optional embodiments, the sliding step of the second set operation module is greater than the sliding step of the first set operation module.
[0106] In some optional embodiments, the first set operation module also includes a first convolutional layer, a second convolutional layer and a summation layer, the first convolutional layer is connected to the input layer, the first convolutional layer, the depth-separable convolutional layer, the second convolutional layer and the summation layer are connected in sequence, and the summation layer is used to add the output result of the second convolutional layer and the data of the input layer and output them.
[0107] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0108] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0109] The present application also provides an electronic device, such as Figure 8 As shown, the electronic device 80 includes: at least one processor 801, a memory 802, and a computer program 803 stored in the memory and executable on the at least one processor, and the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0110] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0111] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0112] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0113] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0114] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0115] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0116] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0117] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A two-dimensional code image recognition method, characterized in that: Includes steps: Get the QR code image to be identified; Determining version information of the two-dimensional code image to be identified; According to the version information and the trained preset network model, a sliding window binarization prediction is performed on the two-dimensional code image to be identified to obtain a binarization sequence; The preset network model is constructed based on a fully convolutional network; The binary sequence is decoded to obtain corresponding decoding information.
2. The two-dimensional code image recognition method according to claim 1, characterized in that: The step of obtaining a two-dimensional code image to be identified includes: Get the target image; The two-dimensional code image to be identified contained in the target image is determined based on the image positioning model.
3. The two-dimensional code image recognition method according to claim 1, characterized in that: The step of performing sliding window binarization prediction on the to-be-recognized two-dimensional code image according to the version information and the trained preset network model to obtain a binarized sequence includes: A virtual sliding window is established based on the two-dimensional code image to be identified; the window of the virtual sliding window covers part of the cells in the two-dimensional code image to be identified; Determining a window size of the virtual sliding window according to the version information and a first preset condition; In the process of performing sliding window binarization prediction on the to-be-recognized two-dimensional code image by using the trained preset network model, dynamically updating the virtual sliding window according to the window size; Until all cells in the to-be-identified two-dimensional code image are predicted, a binarized sequence corresponding to all cells is obtained; the values in the binarized sequence correspond to the cells one-to-one.
4. The two-dimensional code image recognition method according to claim 3, characterized in that: The method is applied to an embedded device; determining the window size of the virtual sliding window according to the version information and the first preset condition includes: The window size of the virtual sliding window is determined according to the version information, the first preset condition and the computing power of the embedded device.
5. The two-dimensional code image recognition method according to any one of claims 1 to 4, characterized in that: The fully convolutional network includes multiple first set operation modules and one second set operation module, the first set operation module is used to extract features, the second set operation module is used to reduce dimensionality, and the second set operation module is located between two of the first set operation modules; the first set operation module and the second set operation module both include a depthwise separable convolution layer, and the size of the convolution kernel in the depthwise separable convolution layer of the first set operation module and the second set operation module is both 3×3.
6. The two-dimensional code image recognition method according to claim 5, characterized in that: The sliding step of the second set operation module is greater than the sliding step of the first set operation module.
7. The two-dimensional code image recognition method according to claim 5, characterized in that: The first set operation module also includes a first convolutional layer, a second convolutional layer and a summation layer, the first convolutional layer is connected to the input layer, the first convolutional layer, the depth-separable convolutional layer, the second convolutional layer and the summation layer are connected in sequence, and the summation layer is used to add the output result of the second convolutional layer and the data of the input layer and output them.
8. A two-dimensional code image recognition device, characterized in that: include: A two-dimensional code image acquisition module is used to acquire a two-dimensional code image to be identified; A version information determination module, for determining the version information of the two-dimensional code image to be identified; A binarization prediction module, which performs sliding window binarization prediction on the to-be-recognized two-dimensional code image according to the version information and the trained preset network model to obtain a binarization sequence; The preset network model is constructed based on a fully convolutional network; The binary sequence decoding module decodes the binary sequence to obtain corresponding decoding information.
9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
