Decoding method, device, equipment, medium and product

The barcode image is processed and decoded through the neural network model, which solves the problem of low decoding rate of traditional decoding algorithms in complex scenarios, and realizes efficient decoding under complex conditions.

CN119129626APending Publication Date: 2024-12-13SHENZHEN YANXIANG JINMA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411294173.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

Traditional barcode decoding algorithms have low decoding rates in complex scenarios, especially in the case of rapid movement and uneven lighting, making it difficult to obtain clear coded images, resulting in decoding failure and low decoding rates.

Method used

Using the decoding method based on neural network model, by loading and initializing the neural network model, performing pre-processing and flip processing, the two-threaded running model is used for inference, generating model inference results, and decoding operations are performed through the encoder to obtain decoding results. .

Benefits of technology

In complex scenarios, the decoding rate of barcodes is significantly improved, and it can effectively deal with problems such as fuzzy, noise and deformation, and improve the accuracy and efficiency of decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129626A_ABST
    Figure CN119129626A_ABST
Patent Text Reader

Abstract

The invention discloses a decoding method and device, equipment, a medium and a product, and relates to the technical field of deep learning technology, and the method comprises the steps: obtaining a to-be-decoded image; based on a preset neural network model, processing the to-be-decoded image to obtain a model reasoning result; and performing decoding operation on the model reasoning result to obtain a decoding result corresponding to the to-be-decoded image, processing the to-be-decoded image through a neural network model to obtain a model reasoning result, and performing decoding operation on the model reasoning result to obtain a decoding result corresponding to the to-be-decoded image. The image to be decoded can be decoded in a complex scene, and the decoding rate in the complex scene is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of deep learning technology, and in particular to a decoding method, device, equipment, medium and product. Background Art

[0002] Barcodes are widely used in our daily life, covering almost all commercial products. With the development of economy, product output is gradually increasing, and the demand for barcode reading speed and accuracy is also gradually increasing.

[0003] At present, there are two traditional barcode decoding algorithms: infrared recognition decoding and image recognition decoding. Infrared recognition decoding distinguishes the reflection wavelengths of the black and white bars of the barcode through the infrared band, and then decodes; image recognition technology distinguishes the bar and space information of the barcode according to the size of the pixel value of the collected image, and then decodes it according to the decoding rules.

[0004] Traditional algorithms translate the decoded content character by character based on the decoding rules of each code system based on a clear code image. Once the code image is blurred, noisy, or deformed, the decoding result will be affected. Although traditional algorithms can quickly decode according to the code system rules, it is difficult to obtain a clear code image in actual application scenarios. Fast movement and uneven lighting will cause the quality of the barcode image to deteriorate, resulting in decoding failure and a low decoding rate.

[0005] Therefore, it is necessary to propose a solution to improve the decoding rate of barcodes in complex scenarios. Summary of the invention

[0006] The main purpose of this application is to provide a decoding method, device, equipment, medium and product, aiming to improve the decoding rate of barcodes in complex scenarios.

[0007] To achieve the above object, the present application provides a decoding method, the method comprising:

[0008] Obtain the image to be decoded;

[0009] Based on a preset neural network model, the image to be decoded is processed to obtain a model inference result;

[0010] Performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded;

[0011] The step of processing the image to be decoded based on a preset neural network model to obtain a model inference result includes:

[0012] Loading the neural network model twice and initializing the model to obtain an initialized neural network model;

[0013] Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image;

[0014] Flipping the pre-processing result image to obtain a flipped result image;

[0015] The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

[0016] In one embodiment, the method is applied to a mobile terminal, and the step of processing the image to be decoded based on a preset neural network model to obtain a model inference result further includes:

[0017] Get the quantized data set and initialize the neural network environment;

[0018] Loading the open neural network exchange model and the quantized data set, performing model conversion through the neural network environment, and obtaining and exporting the neural network model;

[0019] Deploy the neural network model to the mobile terminal.

[0020] In one embodiment, the step of obtaining a quantitative data set includes:

[0021] Generate a code system image based on a preset database;

[0022] Performing scrambling processing on the coded image to obtain a scrambled image, wherein the scrambling processing includes at least one of blurring, adding noise, rotating, and adjusting contrast;

[0023] Pre-processing the scrambled image to obtain a sample image matrix, wherein the pre-processing includes grayscale, cropping and normalization processing;

[0024] The sample image matrix is ​​saved as a single data array format file to form the quantized data set.

[0025] In one embodiment, the step of deriving the neural network model further includes:

[0026] Loading the neural network model, and initializing the neural network chip simulation environment;

[0027] Acquire a verification test image, and input the verification test image into the neural network model for inference decoding to obtain a verification test inference result;

[0028] The verification test inference result is post-processed to obtain a verification test decoding result, and whether to end the verification test process is determined according to the verification test decoding result.

[0029] In one embodiment, the step of determining whether to end the verification test process according to the verification test decoding result includes:

[0030] Determining whether the verification test decoding result is consistent with the content information corresponding to the verification test image;

[0031] If the verification test decoding result is inconsistent with the content information corresponding to the verification test image, determining whether to perform code modification and / or re-execute model conversion by checking whether the code logic of the pre-processing and / or post-processing is correct;

[0032] If the verification test decoding result is consistent with the content information corresponding to the verification test image, the verification test process ends.

[0033] In one embodiment, the model inference result includes a probability sequence, and the step of performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded includes:

[0034] Inputting the probability sequence into a preset encoder;

[0035] The encoder performs character decoding and code classification matching according to a decoding dictionary to obtain a predicted character, and determines code information and decoding content according to the predicted character;

[0036] Performing result verification on the coding information and the decoded content to determine whether the coding information and the decoded content pass the verification;

[0037] If the coding information and the decoded content pass the verification, the coding information and the decoded content are output as the decoding result corresponding to the image to be decoded.

[0038] In addition, to achieve the above purpose, the present application also proposes a decoding device, the decoding device comprising:

[0039] An acquisition module, used for acquiring an image to be decoded;

[0040] An inference module, used to process the image to be decoded based on a preset neural network model to obtain a model inference result;

[0041] A decoding module, used to perform a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded;

[0042] The process of processing the image to be decoded based on the preset neural network model to obtain the model inference result includes:

[0043] Loading the neural network model twice and initializing the model to obtain an initialized neural network model;

[0044] Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image;

[0045] Flipping the pre-processing result image to obtain a flipped result image;

[0046] The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

[0047] In addition, to achieve the above objectives, the present application also proposes a decoding device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the decoding method described above.

[0048] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the decoding method described above are implemented.

[0049] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the decoding method described above are implemented.

[0050] One or more technical solutions proposed in this application have at least the following technical effects:

[0051] By acquiring an image to be decoded; processing the image to be decoded based on a preset neural network model to obtain a model inference result; decoding the model inference result to obtain a decoding result corresponding to the image to be decoded, processing the image to be decoded through a neural network model to obtain a model inference result, and decoding the model inference result to obtain a decoding result corresponding to the image to be decoded, the steps of processing the image to be decoded based on a preset neural network model to obtain a model inference result include: loading the neural network model twice and initializing the model to obtain an initialized neural network model; reading the image to be decoded, pre-processing the image to be decoded to obtain a pre-processing result image; flipping the pre-processing result image to obtain a flipped result image; starting dual threads and running the initialized neural network model, respectively inferring the pre-processing result image and the flipped result image to obtain the model inference result. This solution can decode the image to be decoded in complex scenarios and improve the decoding rate in complex scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0053] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0054] Figure 1 This is a flowchart of the first embodiment of the decoding method of the present application;

[0055] Figure 2 This is a flowchart of a second embodiment of the decoding method of the present application;

[0056] Figure 3 A schematic diagram of a model conversion process according to the second embodiment of the present application;

[0057] Figure 4 A schematic diagram of a verification test process according to the second embodiment of the present application;

[0058] Figure 5 This is a schematic diagram of a model deployment process according to the second embodiment of the present application;

[0059] Figure 6 This is a flowchart of a third embodiment of the decoding method of the present application;

[0060] Figure 7 A schematic diagram of a model compilation deployment prediction process according to the third embodiment of the present application;

[0061] Figure 8 Schematic diagram of the decoding principle of an encoder according to the third embodiment of the present application;

[0062] Fig. 9 This is a schematic diagram of the module structure of a decoding device according to an embodiment of the present application;

[0063] Fig.10 A schematic diagram of the device structure of the hardware operating environment involved in the decoding method in the embodiment of the present application.

[0064] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0065] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0066] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0067] The main solution of the embodiment of the present application is: by acquiring an image to be decoded; based on a preset neural network model, processing the image to be decoded to obtain a model inference result; decoding the model inference result to obtain a decoding result corresponding to the image to be decoded, processing the image to be decoded by the neural network model to obtain a model inference result, and decoding the model inference result to obtain a decoding result corresponding to the image to be decoded. The steps of processing the image to be decoded based on the preset neural network model to obtain the model inference result include: loading the neural network model twice and initializing the model to obtain an initialized neural network model; reading the image to be decoded, pre-processing the image to be decoded to obtain a pre-processing result image; flipping the pre-processing result image to obtain a flipped result image; starting dual threads and running the initialized neural network model, respectively inferring the pre-processing result image and the flipped result image to obtain the model inference result. This solution can decode the image to be decoded in complex scenes and improve the decoding rate in complex scenes.

[0068] In this embodiment, for ease of description, the following description is made with a mobile terminal (eg, a mobile device such as a mobile phone) as the execution entity.

[0069] Technical terms involved in this application:

[0070] CRNN: (Convolutional Recurrent Neural Network) is a deep learning model mainly used in fields such as sequence recognition and speech recognition. CRNN consists of a convolutional neural network (CNN), a recurrent neural network (RNN) and a transcription layer (CTC), and can process input data with sequence characteristics, such as time series signals, text, etc.

[0071] RKNN: (Retina Kernel Neural Network) is an integrated development and operation framework for all stages of deep learning. Its core idea is to replace the fully connected layer in the traditional neural network with a local connection layer to achieve efficient calculation of data. In RKNN, each neuron is only connected to a local area of ​​the input data, which greatly reduces the number of model parameters and improves the generalization ability of the model.

[0072] In the prior art, barcodes are widely used in life, covering almost all commercial products. For example, industrial production records product batch information, records item information during logistics and transportation, payment systems, etc. Barcodes have the characteristics of fast information reading and small space occupation. They are used in commercial and industrial industries for rapid information calibration, product traceability and other operations, and are currently the mainstream information recording and marking method.

[0073] With the development of the economy, product output has gradually increased, and the demand for barcode reading speed and accuracy has gradually increased. Similarly, the development of deep learning has also made image processing capabilities faster and faster, so strategies for AI decoding of barcode images have emerged. Use deep learning to decode barcode AI, extract the bar and space features of the barcode through the text recognition model trained by the CRNN network, and then decode it according to the decoding rules learned by the model. However, the operating environment of the CRNN model cannot meet the requirements of mobile terminals for lightness and speed, so the CRNN model is converted to an RKNN model, and the RKNN model is deployed on a mobile device with an RKNN chip for light and fast AI decoding.

[0074] The RKNN model is obtained by model conversion from the model trained by CRNN. ​​The method of deploying the RKNN model on RKNN mobile devices is to translate the model prediction code trained in Python into C++ and compile it into an executable file. Running the executable file on the RKNN mobile device can call the model to predict the code content image output decoding results.

[0075] There are two traditional barcode decoding algorithms: infrared recognition decoding and image recognition decoding. Infrared recognition decoding distinguishes the reflected wavelengths of the black and white bars of the barcode through the infrared band, thereby decoding; image recognition technology distinguishes the bar and space information of the barcode according to the size of the pixel value of the collected image, and then decodes it according to the decoding rules.

[0076] The traditional algorithm is based on the clear code image and translates each character according to the decoding rules of each code system to obtain the decoded content. Once the code image is blurred, noisy, deformed, etc., it will affect the decoding result. Although the traditional algorithm can quickly decode according to the code system rules, it is difficult to obtain a clear code image in actual application scenarios. Fast movement, uneven lighting, etc. will cause the barcode image quality to deteriorate, resulting in decoding failure and low decoding rate. In addition, the decoding rules of different code systems are different, and in order to decode faster, the code image needs to be processed by multiple threads, which will result in excessive use of computing resources.

[0077] The present application provides a solution to the problem that the traditional algorithm has a low decoding rate in complex scenarios and the CRNN model of AI decoding is difficult to deploy and apply on mobile terminals. The CRNN model operating environment occupies a large number of resources, and the mobile terminal has fewer computing resources and cannot support the operation of large models, resulting in long computing time and long decoding time. The CRNN model is converted into an RKNN model and deployed on the RKNN chip on the mobile terminal. The converted RKNN model can be quantized and the size of the model can be compressed. In addition, the RKNN model operating environment occupies fewer resources and can be accelerated on the RKNN chip. Therefore, image recognition, image processing, decoding verification and other operations can be completed quickly, which can effectively improve the decoding rate of barcodes in complex scenarios and improve the decoding time.

[0078] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, decoding, etc. The following takes a decoding device as an example to illustrate this embodiment and the following embodiments.

[0079] Based on this, the embodiment of the present application provides a decoding method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the decoding method of the present application.

[0080] In this embodiment, the decoding method includes steps S10 to S30:

[0081] Step S10, obtaining an image to be decoded;

[0082] Specifically, the image to be decoded in the embodiment of the present application is a barcode image that needs to be decoded. Barcode is a widely used automatic recognition technology that represents information through a specific arrangement of bars and spaces. Barcode decoding is a process of converting a barcode image into readable text information, and converting the extracted bars and spaces into numbers or characters. Each barcode type has its own specific encoding rules, and the decoding process is to convert the bar and space patterns into corresponding characters according to these rules.

[0083] Optionally, the decoding method in the embodiment of the present application is applied to a mobile terminal, such as a mobile phone, tablet or other mobile device. The image to be decoded can be obtained by photographing or scanning the barcode through the camera of the mobile device, or the image to be decoded can be obtained by pre-storage or other methods.

[0084] Step S20, processing the image to be decoded based on a preset neural network model to obtain a model inference result;

[0085] The step of processing the image to be decoded based on a preset neural network model to obtain a model inference result includes:

[0086] Loading the neural network model twice and initializing the model to obtain an initialized neural network model;

[0087] Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image;

[0088] Flipping the pre-processing result image to obtain a flipped result image;

[0089] The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

[0090] Furthermore, after the image to be decoded is obtained, the image to be decoded can be processed based on a preset neural network model to obtain a model inference result.

[0091] Optionally, in an embodiment of the present application, a CRNN (Convolutional Recurrent Neural Network) model is converted into an RKNN model and deployed on an RKNN chip on a mobile terminal. The converted RKNN model can be quantized, the size of the model can be compressed, and the RKNN model operating environment occupies fewer resources, and accelerated computing processing can be performed on the RKNN chip.

[0092] Optionally, a neural network model for processing the image to be decoded can be obtained through RKNN model conversion and RKNN model verification testing.

[0093] Optionally, the model inference result includes a probability sequence, so the probability sequence obtained by model inference needs to be sent to a custom encoder for decoding.

[0094] Step S30, performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded.

[0095] Furthermore, based on the preset neural network model, the image to be decoded is processed to obtain the model inference result, and then the model inference result can be decoded to obtain the decoding result corresponding to the image to be decoded.

[0096] Optionally, a custom encoder is provided in an embodiment of the present application for performing decoding operations on the model inference results to obtain a decoding result corresponding to the image to be decoded. The encoder may also be referred to as a self-encoder decoder, and the embodiment of the present application does not constitute a specific limitation on the name of the encoder.

[0097] Optionally, the result of RKNN model inference can obtain a string of predicted characters after character decoding according to the dictionary. The predicted characters are sent to the encoder for decoding processing. The code information and decoding content of the current barcode can be obtained from the predicted characters. The index with the highest probability in each row of the probability sequence is used to decode the corresponding character in the dictionary to form the decoding result. The decoding result can also be verified in the encoder to further ensure the accuracy of the obtained decoding result.

[0098] The present embodiment adopts the above scheme, specifically by obtaining an image to be decoded; processing the image to be decoded based on a preset neural network model to obtain a model inference result; decoding the model inference result to obtain a decoding result corresponding to the image to be decoded, processing the image to be decoded through a neural network model to obtain a model inference result, and decoding the model inference result to obtain a decoding result corresponding to the image to be decoded. The steps of processing the image to be decoded based on a preset neural network model to obtain a model inference result include: loading the neural network model twice and initializing the model to obtain an initialized neural network model; reading the image to be decoded, pre-processing the image to be decoded to obtain a pre-processing result image; flipping the pre-processing result image to obtain a flipped result image; starting dual threads and running the initialized neural network model, respectively inferring the pre-processing result image and the flipped result image to obtain the model inference result. The scheme can decode the image to be decoded in complex scenes and improve the decoding rate in complex scenes.

[0099] Based on the first embodiment of the present application, the second embodiment of the present application is proposed. In the second embodiment of the present application, the same or similar contents as those of the above-mentioned embodiment 1 can be referred to the above introduction and will not be repeated later. Figure 2 , before step S20, the decoding method further includes steps S01 to S03:

[0100] Step S01: Obtain a quantized data set and initialize a neural network environment;

[0101] Step S02: loading the open neural network exchange model and the quantized data set, performing model conversion through the neural network environment, and obtaining and exporting the neural network model;

[0102] Step S03: deploying the neural network model to the mobile terminal.

[0103] Optionally, the step of obtaining a quantitative data set includes:

[0104] Generate a code system image based on a preset database;

[0105] Performing scrambling processing on the coded image to obtain a scrambled image, wherein the scrambling processing includes at least one of blurring, adding noise, rotating, and adjusting contrast;

[0106] Pre-processing the scrambled image to obtain a sample image matrix, wherein the pre-processing includes grayscale, cropping and normalization processing;

[0107] The sample image matrix is ​​saved as a single data array format file to form the quantized data set.

[0108] Reference Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a model conversion process according to the second embodiment of the present application. Figure 3 As shown, the RKNN model conversion converts the matrix data obtained from the image pre-processing into a file in .npy format, uses a preset database (such as python+opencv library), generates a coded image, blurs the image, adds noise, rotates, adjusts the contrast, and then grayscales, crops, and normalizes the image to obtain an image matrix, saves the matrix as a single data array format file, i.e., a file in .npy format, and batch processes the images to obtain a quantized data set. To use python to configure the RKNN environment for model conversion, first load the Open Neural Network Exchange (ONNX) model, then load the quantized data, and convert the model through the RKNN environment to obtain an RKNN model that can run on the RKNN chip platform.

[0109] Alternatively, ONNX is an open ecosystem that allows model interoperability between different AI frameworks. In short, ONNX is a format for representing deep learning models that allows models to be easily converted and used between different frameworks and tools. Developers can train a model in one framework and then losslessly convert it to another framework for deployment. Converting the decoded model to the ONNX format can improve the usability and flexibility of the model, making it easier to integrate into different applications and systems.

[0110] Optionally, after the step of deriving the neural network model, the step further includes:

[0111] Loading the neural network model, and initializing the neural network chip simulation environment;

[0112] Acquire a verification test image, and input the verification test image into the neural network model for inference decoding to obtain a verification test inference result;

[0113] Post-processing the verification test reasoning result to obtain a verification test decoding result;

[0114] Determining whether the verification test decoding result is consistent with the content information corresponding to the verification test image;

[0115] If the verification test decoding result is inconsistent with the content information corresponding to the verification test image, determining whether to perform code modification and / or re-execute model conversion by checking whether the code logic of the pre-processing and / or post-processing is correct;

[0116] If the verification test decoding result is consistent with the content information corresponding to the verification test image, the verification test process ends.

[0117] Reference Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a verification test process according to the second embodiment of the present application, as shown in FIG. Figure 4 As shown in the figure, after the RKNN model is exported, it is necessary to verify the availability of the converted RKNN model. During the RKNN model verification test, the RKNN model must first be loaded, and then the simulated RKNN chip environment must be initialized. The image to be decoded must be pre-processed and passed into the RKNN model for inference decoding. After the model inference result is obtained, the decoding process is completed through result post-processing to obtain the one-dimensional code decoding result. If the decoding result corresponds to the code content information of the code image, the RKNN model conversion is successful. If the decoding result of the model inference is inconsistent with the code content information of the code image, it is necessary to check whether the logic of the image pre-processing and post-processing is correct. If the code logic is correct, it is necessary to return to the RKNN model conversion process for re-conversion.

[0118] Reference Figure 5 , Figure 5 FIG. 1 is a schematic diagram of a model deployment process according to the second embodiment of the present application, as shown in FIG. Figure 5 As shown in the figure, after completing the conversion of the ONNX decoding model, a four-in-one decoding RKNN model for decoding EAN8 / EAN13 / UPCA / UPCE four code systems is obtained. The RKNN model is integrated into the mobile terminal for easy and fast decoding of four barcodes. Convert Python pre- and post-processing to C++ language for model compilation and deployment. Compilation and deployment mainly writes processing flow code and compiles C++ programs into executable files. Writing the C++ processing flow includes loading the RKNN decoding model twice in parallel and running two models in parallel to decode the image.

[0119] This embodiment adopts the above scheme, specifically by obtaining a quantized data set, and initializing a neural network environment; loading an open neural network exchange model and the quantized data set, performing model conversion through the neural network environment, obtaining and exporting the neural network model; deploying the neural network model to the mobile terminal, can quickly and automatically generate an RKNN model quantized data set, and while generating a code image, perform enhancement operations such as blurring, contrast, rotation, and adding noise on the code image and then convert it into a quantized file in .npy format; by quantizing the RKNN model, the processing time of the model in the RKNN chip is reduced, the time for the model to process images is reduced, and the barcode AI decoding performance is improved; based on CRNN barcode AI decoding, the ONNX model trained by CRNN is converted into an RKNN model, which can cope with the decoding work of barcodes in complex scenarios and improve the decoding rate of mobile devices in complex backgrounds.

[0120] Based on any of the above embodiments of the present application, a third embodiment of the present application is proposed. In the third embodiment of the present application, the same or similar contents as any of the above embodiments can be referred to the above introduction and will not be repeated later. Figure 6 , step S20 also includes steps S201 to S204:

[0121] Step S201: loading the neural network model twice and initializing the model to obtain an initialized neural network model;

[0122] Step S202: reading the image to be decoded, and performing pre-processing on the image to be decoded to obtain a pre-processing result image;

[0123] Step S203: flipping the pre-processing result image to obtain a flipped result image;

[0124] Step S204: start dual threads and run the initialized neural network model, respectively infer the pre-processing result image and the flipped result image to obtain the model inference result.

[0125] Reference Figure 7 , Figure 7 FIG. 1 is a schematic diagram of a model compilation deployment prediction process according to the third embodiment of the present application, as shown in FIG. Figure 7 As shown, the C++ processing flow written in the embodiment of the present application includes loading the RKNN decoding model twice and running it in parallel, running two models in parallel to decode the image, a barcode image is first divided into a forward image and a flipped image, and then each image is input into the model for inference decoding, the input and output information of the model is queried, the model input structure is set, the model output structure is set, and then the model result is post-processed, the decoding result is verified, and the decoding result is output.

[0126] Optionally, the model inference result includes a probability sequence, and the step of performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded includes:

[0127] Inputting the probability sequence into a preset encoder;

[0128] The encoder performs character decoding and code classification matching according to a decoding dictionary to obtain a predicted character, and determines code information and decoding content according to the predicted character;

[0129] Performing result verification on the coding information and the decoded content to determine whether the coding information and the decoded content pass the verification;

[0130] If the coding information and the decoded content pass the verification, the coding information and the decoded content are output as the decoding result corresponding to the image to be decoded.

[0131] Optionally, the result of model inference is a 15×15 probability sequence based on a decoding dictionary, where the decoding dictionary of the four code systems is a 15-bit sequence of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, #]. The probability sequence obtained by model inference is sent to a custom encoder for decoding.

[0132] Optionally, after writing the C++ processing code, it needs to be cross-compiled into an executable file that can run outside the C++ environment. The cross-compilation process is relatively simple. Configure the cross-compiler in the development environment, compile the .cc related programs into executable files, and you can get the AI ​​decoding program that can run on the RKNN chip.

[0133] Reference Figure 8 , Figure 8 FIG. 4 is a schematic diagram of the decoding principle of an encoder according to the third embodiment of the present application, as shown in FIG. Figure 8As shown in the figure, the result obtained by the RKNN model inference is decoded according to the dictionary to obtain a string of predicted characters. The predicted characters are sent to the self-encoder and decoder for decoding. The code system information and decoding content of the current barcode can be obtained from the predicted characters. The index with the highest probability in each row of the probability sequence is used to decode the corresponding characters in the dictionary to form the decoding result, where a is EAN8 code, b is EAN13 code, c is UPCA code, d is UPCE code, and # is the end bit of the character. The decoding process in the custom encoder is to output characters, classify and match codes, and check the results of four codes according to the dictionary, and check the results of the decoding in the self-encoder and decoder. In the result check, the code system information obtained by the self-encoder and decoder is used to calculate whether the check bit is equal to the last character to complete the correctness check of the current decoding content. After the check is passed, the code system information and decoding content are output. If the check fails or the predicted character does not meet the rules of the self-encoder and decoder, the decoding process is not logical, the first character is not one of abcd, the middle is not a pure number, there is no end bit, etc., it is considered that the decoding failed, and a null value is returned and None is output. At this time, the image quality can be used to determine whether re-decoding is needed. For the RKNN decoding model, even an empty image (an image without a barcode) will output a predicted probability result. At this time, the predicted character obtained does not meet the decoding rules of the self-encoder decoder, and it is judged as a decoding failure and None is output.

[0134] This embodiment adopts the above scheme, specifically by loading the neural network model twice and initializing the model to obtain the initialized neural network model; reading the image to be decoded, pre-processing the image to be decoded to obtain the pre-processing result image; flipping the pre-processing result image to obtain the flipped result image; starting dual threads and running the initialized neural network model, respectively inferring the pre-processing result image and the flipped result image to obtain the model inference result, decoding the model inference result through the encoder to obtain the decoding result corresponding to the image to be decoded, and the barcode AI decoding on the mobile terminal can be completed through model conversion testing and model compilation deployment prediction; the four-in-one model is processed in parallel by dual threads, which can be used to decode EAN8, EAN13, UPCA, and UPCE code systems. Compared with the traditional algorithm that requires four threads to decode one code image in parallel, the dual-thread running RKNN model can save more computing resources on the mobile terminal.

[0135] This application also provides a decoding device, please refer to Fig. 9 , the decoding device comprises:

[0136] An acquisition module, used for acquiring an image to be decoded;

[0137] An inference module, used to process the image to be decoded based on a preset neural network model to obtain a model inference result;

[0138] A decoding module, used to perform a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded;

[0139] The process of processing the image to be decoded based on the preset neural network model to obtain the model inference result includes:

[0140] Loading the neural network model twice and initializing the model to obtain an initialized neural network model;

[0141] Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image;

[0142] Flipping the pre-processing result image to obtain a flipped result image;

[0143] The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

[0144] The decoding device provided by the present application adopts the decoding method in the above embodiment, which can solve the technical problem of barcode decoding. Compared with the prior art, the beneficial effects of the decoding device provided by the present application are the same as the beneficial effects of the decoding method provided by the above embodiment, and other technical features in the decoding device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0145] The present application provides a decoding device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the decoding method in the above-mentioned embodiment one.

[0146] Reference below Fig.10 , which shows a schematic diagram of the structure of a decoding device suitable for implementing an embodiment of the present application. The decoding device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.10The decoding device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0147] like Fig.10 As shown, the decoding device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the decoding device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the decoding device to communicate with other devices wirelessly or by wire to exchange data. Although the decoding device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0148] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0149] The decoding device provided by the present application adopts the decoding method in the above embodiment to solve the technical problem of barcode decoding. Compared with the prior art, the beneficial effects of the decoding device provided by the present application are the same as the beneficial effects of the decoding method provided by the above embodiment, and the other technical features in the decoding device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0150] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0151] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0152] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the decoding method in the above-mentioned embodiment.

[0153] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0154] The computer-readable storage medium may be included in the decoding device; or may exist independently without being assembled into the decoding device.

[0155] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the decoding device, the decoding device enables the decoding device to: obtain an image to be decoded; process the image to be decoded based on a preset neural network model to obtain a model inference result; perform a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded, process the image to be decoded through the neural network model to obtain a model inference result, and perform a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded, so as to decode the image to be decoded in complex scenes and improve the decoding rate in complex scenes.

[0156] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0157] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0158] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0159] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned decoding method, and can solve the technical problems of decoding. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the decoding method provided by the above-mentioned embodiment, and will not be repeated here.

[0160] The present application also provides a computer program product, including a computer program, which implements the steps of the above decoding method when executed by a processor.

[0161] The computer program product provided by the present application can solve the technical problem of decoding. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the decoding method provided by the above embodiment, which will not be repeated here.

[0162] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A decoding method, It is characterized in that The method comprises: Obtain the image to be decoded; Based on a preset neural network model, the image to be decoded is processed to obtain a model inference result; Performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded; The step of processing the image to be decoded based on a preset neural network model to obtain a model inference result includes: Loading the neural network model twice and initializing the model to obtain an initialized neural network model; Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image; Flipping the pre-processing result image to obtain a flipped result image; The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

2. The method according to claim 1, It is characterized in that The method is applied to a mobile terminal, and the step of processing the image to be decoded based on a preset neural network model to obtain a model inference result also includes: Get the quantized data set and initialize the neural network environment; Loading the open neural network exchange model and the quantized data set, performing model conversion through the neural network environment, and obtaining and exporting the neural network model; Deploy the neural network model to the mobile terminal.

3. The method according to claim 2, It is characterized in that The step of obtaining a quantitative data set comprises: Generate a code system image based on a preset database; Performing scrambling processing on the coded image to obtain a scrambled image, wherein the scrambling processing includes at least one of blurring, adding noise, rotating, and adjusting contrast; Pre-processing the scrambled image to obtain a sample image matrix, wherein the pre-processing includes grayscale, cropping and normalization processing; The sample image matrix is ​​saved as a single data array format file to form the quantized data set.

4. The method according to claim 2, It is characterized in that The step of deriving the neural network model further includes: Loading the neural network model, and initializing the neural network chip simulation environment; Acquire a verification test image, and input the verification test image into the neural network model for inference decoding to obtain a verification test inference result; The verification test inference result is post-processed to obtain a verification test decoding result, and whether to end the verification test process is determined according to the verification test decoding result.

5. The method according to claim 4, It is characterized in that The step of determining whether to end the verification test process according to the verification test decoding result includes: Determining whether the verification test decoding result is consistent with the content information corresponding to the verification test image; If the verification test decoding result is inconsistent with the content information corresponding to the verification test image, determining whether to perform code modification and / or re-execute model conversion by checking whether the code logic of the pre-processing and / or post-processing is correct; If the verification test decoding result is consistent with the content information corresponding to the verification test image, the verification test process ends.

6. The method according to claim 1, It is characterized in that The model inference result includes a probability sequence, and the step of performing a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded includes: Inputting the probability sequence into a preset encoder; The encoder performs character decoding and code classification matching according to a decoding dictionary to obtain a predicted character, and determines code information and decoding content according to the predicted character; Performing result verification on the coding information and the decoded content to determine whether the coding information and the decoded content pass the verification; If the coding information and the decoded content pass the verification, the coding information and the decoded content are output as the decoding result corresponding to the image to be decoded.

7. A decoding device, It is characterized in that The device comprises: An acquisition module, used for acquiring an image to be decoded; An inference module, used to process the image to be decoded based on a preset neural network model to obtain a model inference result; A decoding module, used to perform a decoding operation on the model inference result to obtain a decoding result corresponding to the image to be decoded; The process of processing the image to be decoded based on the preset neural network model to obtain the model inference result includes: Loading the neural network model twice and initializing the model to obtain an initialized neural network model; Reading the image to be decoded, performing pre-processing on the image to be decoded, and obtaining a pre-processing result image; Flipping the pre-processing result image to obtain a flipped result image; The dual threads are started and the initialized neural network model is run, and the pre-processing result image and the flipped result image are inferred respectively to obtain the model inference result.

8. A decoding device, It is characterized in that The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the decoding method according to any one of claims 1 to 6.

9. A storage medium, It is characterized in that The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the decoding method according to any one of claims 1 to 6 are implemented.

10. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the decoding method according to any one of claims 1 to 6 are implemented.