Bar code image super-resolution method, system, device, and medium
By using a lightweight model with parallel convolutional kernels and composite loss functions in the barcode image super-resolution method, the resolution and decoding rate problems of barcode recognition in complex environments are solved, and real-time and efficient processing on edge devices is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN JOYUSING TECHNOLOGY CO LTD
- Filing Date
- 2026-01-22
- Publication Date
- 2026-06-05
AI Technical Summary
Existing barcode recognition technologies suffer from low resolution, blurriness, and excessive noise in complex environments, resulting in low decoding success rates. Furthermore, existing models are difficult to deploy on edge devices and lack real-time performance.
A barcode image super-resolution method is designed, which uses parallel 1x3 and 3x1 convolutional kernel feature extraction and combines a composite loss function of pixel loss, perceptual loss and generative adversarial loss to construct a lightweight super-resolution model suitable for edge devices.
It improves the ability to restore sharp edges and texture details of barcode images, reduces computational load, is suitable for real-time processing on edge devices, and improves decoding success rate and speed.
Smart Images

Figure CN122155946A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and image processing technology, and specifically relates to a method, system, device and medium for barcode image super-resolution. Background Technology
[0002] With the development of logistics, retail, and industrial automation, barcode recognition technology has been widely applied. In ideal environments, commercial barcode recognition devices can acquire high-resolution and clear images. However, in complex industrial settings or mobile scanning scenarios, limitations imposed by shooting distance, device shake, lighting conditions, and the image size of the imaging device itself often result in low resolution, blurriness, and high noise levels in the acquired barcode images, severely impacting the success rate of subsequent decoding. To address these issues, image super-resolution (SR) technology has been introduced into the barcode enhancement field. Super-resolution (SR) refers to the technique of upscaling low-resolution (LR) images to high-resolution (HR) images using algorithms. Its main purpose is to improve image quality and detail, overcoming the problems of blurriness and low quality caused by limitations in the image acquisition system or environment. Early solutions often employed traditional interpolation algorithms, such as bilinear interpolation and bicubic interpolation, but these methods struggle to recover high-frequency details in the image, easily leading to blurred barcode edges. In recent years, deep learning-based super-resolution reconstruction methods have become a research hotspot due to their powerful feature learning capabilities.
[0003] For example, Chinese invention patent application CN118799185A discloses a method, apparatus, device, storage medium, and product for training a one-dimensional barcode super-resolution model. This scheme predicts the first one-dimensional barcode image using an initial reconstruction model, and calculates pixel-level loss values by combining this with a pixel-level ground truth image. Simultaneously, semantic extraction is performed on both the ground truth image and the predicted image to obtain semantic features and calculate semantic feature loss values. Finally, the model parameters are adjusted based on the pixel-level loss and the semantic feature loss. This method, by introducing semantic constraints, improves the usability of the reconstructed image at the decoding level to a certain extent.
[0004] For example, Chinese invention patent application CN117151984A discloses a two-dimensional barcode super-resolution method based on frequency domain constraints and reference map guidance. This method designs a gradient domain-based feature matching module and a multi-scale feature reconstruction backbone network, fusing features from a high-resolution reference map with low-resolution features to synthesize high-resolution features. This scheme utilizes the guiding role of the reference map and frequency domain constraints to address the blurring and degradation problems of two-dimensional barcodes.
[0005] While the aforementioned existing technologies have achieved certain results in their respective specific scenarios, they still have the following shortcomings: First, it is difficult to balance universality and specificity, and there is a lack of a universal enhancement scheme that can uniformly utilize the common features (black and white binary texture, edge information in specific directions) of different types of barcodes; second, the model complexity is high, making it difficult to deploy on edge devices. For edge devices such as industrial barcode scanners and handheld terminals with limited computing resources, the aforementioned models often fail to meet real-time requirements; finally, the feature extraction methods do not fully utilize the structural characteristics of barcodes. Traditional square convolution kernels are difficult to efficiently capture these highly directional texture information with a low number of parameters, which often sacrifices reconstruction effect in the pursuit of lightweight design, resulting in insufficiently sharp barcode edges, which still affects the recognition rate.
[0006] Therefore, designing a lightweight super-resolution model optimized for edge devices that can efficiently capture texture features of barcodes in specific directions is a pressing technical problem that needs to be solved. Summary of the Invention
[0007] This invention provides a barcode image super-resolution method, system, device, and medium, aiming to solve the problems of existing technologies in barcode recognition, such as difficulty in balancing universality and specificity, model complexity, and insufficient recognition rate.
[0008] To address the aforementioned technical problems, this invention proposes a barcode image super-resolution method, comprising the following steps: Obtain a training set containing several pairs of images, each pair containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label; A super-resolution model is constructed, comprising an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence; wherein, the feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data respectively, and the extracted features are superimposed and output; Define an overall loss function, which is a weighted sum of pixel loss function, perceptual loss function and generative adversarial loss function; The training set is input into the super-resolution model, the error is calculated based on the overall loss function, and the model parameters are updated by backpropagation until the model converges. The low-resolution barcode image to be recognized is input into the trained super-resolution model, and the high-resolution barcode image is output.
[0009] Preferably, the method for constructing the training dataset includes: Different types of raw barcode images are generated using a barcode generation library and used as the high-resolution barcode images; The original barcode image is subjected to image quality degradation simulation processing to generate the corresponding low-resolution barcode image; The image quality degradation simulation processing includes at least one of the following: image blurring, poor lighting, image scaling, image compression, and polarizer overlay filter effects.
[0010] Preferably, the input layer is configured to receive a single-channel grayscale image; Before inputting the training set into the super-resolution model, the barcode image is preprocessed to retain only grayscale information, and the dimensions of the input data are adjusted to h×w×1, where h and w are the height and width of the image, respectively.
[0011] Preferably, the deep feature mapping module consists of three densely connected blocks connected in sequence; Each densely connected block contains 5 convolutional layers, with the output channels of the 5 convolutional layers set to 32, 64, 96, 64, and 32 respectively.
[0012] Preferably, the output layer includes a convolutional layer and a subpixel convolutional layer; The feature map output by the deep feature mapping module is processed by the convolutional layer, and the output is feature data with a size of h×w×4. The subpixel convolutional layer upsamples and rearranges the feature data, outputting a high-resolution barcode image with dimensions of 2h×2w×1.
[0013] Preferably, the perceptual loss function is calculated based on a pre-trained VGG network; The calculation method is as follows: input the output image of the super-resolution model and the real image into the pre-trained VGG network, extract the corresponding feature matrices, and calculate the difference between the two feature matrices as the perceptual loss value.
[0014] Preferably, the calculation of the generative adversarial loss function involves a discriminative network; During training, the discriminant network and the super-resolution model alternately update parameters; the discriminant network is used to determine whether the input image is a real image or an image generated by the super-resolution model; the generative adversarial loss function is calculated based on the cross-entropy between the output label of the discriminant network and the real label.
[0015] In a second aspect, the present invention also proposes a barcode image super-resolution system, said system for implementing the super-resolution method as described in the first aspect of the present invention, comprising: The data acquisition module is used to acquire a training set containing several pairs of images, each pair of images containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label. The model building module is used to build a super-resolution model, which includes an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence. The feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data, and then outputs the extracted features by superimposing them. The training module is used to define the overall loss function, which is composed of a weighted sum of the pixel loss function, the perceptual loss function, and the generative adversarial loss function; and to input the training set into the super-resolution model, calculate the error based on the overall loss function, and backpropagate to update the model parameters until the model converges. The inference module is used to input the low-resolution barcode image to be recognized into the trained super-resolution model and output a high-resolution barcode image.
[0016] Thirdly, the present invention also provides an electronic device comprising: One or more processors; Memory, used to store one or more computer programs; One or more computer programs stored in the memory are executed by the one or more processors, causing the one or more processors to implement the super-resolution method as described in the first aspect of the invention.
[0017] Fourthly, the present invention also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the super-resolution method as described in the first aspect of the present invention.
[0018] Compared with the prior art, the present invention has the following technical effects: 1. The super-resolution method proposed in this invention is specifically designed for the structural characteristics of barcodes. By introducing a composite loss function consisting of pixel loss, perceptual loss, and generative adversarial loss, the model not only approximates the true value in pixel values but also recovers the key sharp edges and texture details of the barcode image through perceptual features and adversarial training. This effectively solves the problem of barcode blurring caused by poor lighting, motion blur, or long shooting distance in industrial environments, enabling the decoding algorithm to recognize low-quality barcodes that were originally unreadable.
[0019] 2. The super-resolution method proposed in this invention addresses the limitation of computing power in edge computing devices by optimizing the model structure in multiple ways: At the input end, considering the binarization characteristics of barcodes, only a single-channel grayscale image is used as input, reducing data processing by approximately 67% compared to the traditional RGB three-channel input; structurally, a DenseBlock module with specific channel number variations is designed, combined with sub-pixel convolutional upsampling, avoiding complex deconvolution operations. These improvements result in a smaller model parameter count and faster computation speed, enabling real-time inference on embedded devices such as handheld barcode scanners and industrial assembly line cameras.
[0020] 3. The super-resolution method proposed in this invention uses parallel 1x3 and 3x1 asymmetric convolution kernels instead of traditional square convolution kernels. This design is highly compatible with the vertical line features of one-dimensional barcodes and the grid-like texture features of two-dimensional barcodes, enabling more accurate capture of high-frequency information in the horizontal and vertical directions of the image while reducing the number of parameters, thus improving the structural fidelity of super-resolution reconstruction. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the super-resolution method described in this invention; Figure 2 This is a schematic diagram of the feature extraction module described in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of the deep feature mapping module described in an embodiment of the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments of the present application and with reference to the accompanying drawings.
[0023] In this application, the term barcode refers to an optically readable representation of data, including but not limited to one-dimensional barcodes (or 1D codes, such as UPC, EAN, Code 128), two-dimensional barcodes (or 2D codes, such as QRCode, Data Matrix, PDF417), and dot codes, as well as any binary image symbol composed of dark and light (or reflective and non-reflective) units.
[0024] Example 1 This embodiment describes a barcode image super-resolution method, such as... Figure 1 As shown, it includes the following steps one through five: Step 1: Obtain a training set containing several pairs of images, each pair containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label.
[0025] The method for constructing the training dataset includes: Different types of raw barcode images are generated using barcode generation libraries, serving as the high-resolution barcode images. To ensure the diversity and coverage of training data, this embodiment uses open-source barcode generation libraries, such as Python's python-barcode and qrcode libraries, to generate barcode images of different formats in batches. The generated barcode types cover one-dimensional barcodes, two-dimensional barcodes, and dot-matrix barcodes. Because these raw generated images have high resolution, clear edges, and no noise, they are used as ground truth (GT) images in deep learning training, i.e., the high-resolution barcode images. Considering the unique characteristic of barcode images, which are mainly composed of alternating black and white binary pixel blocks, after image generation, they are converted into single-channel grayscale images (h×w×1) to remove redundant color information and focus on the grayscale texture features of the barcode.
[0026] The original barcode image undergoes image quality degradation simulation processing to generate a corresponding low-resolution barcode image. To enable the model to adapt to complex environmental interference in real-world industrial scenarios, it is necessary to manually simulate various image quality degradation scenarios that may occur during barcode acquisition. This embodiment uses a process of high-resolution image -> degradation processing -> low-resolution input image to construct paired training data.
[0027] The image quality degradation simulation processing includes at least one of the following: image blurring, poor lighting, image scaling, image compression, and polarizer overlay filter effects. The specific simulation implementation methods are as follows: Image scaling: Simulates long-distance shooting or low-resolution sensor imaging. High-resolution barcode images are downsampled using bicubic or bilinear interpolation algorithms, reducing the image size to 1 / 2 or 1 / 4 of the original size. This results in the loss of high-frequency information and generates a basic low-resolution image.
[0028] Image blur: Simulates focus misalignment or motion blur. A Gaussian matrix or motion blur kernel is applied to the image, and different degrees of blur effect are generated by randomly adjusting the size and standard deviation of the Gaussian kernel.
[0029] Poor lighting: Simulates low-light or overexposed environments. By non-linearly adjusting the brightness, contrast, and gamma value of the image, or by superimposing Gaussian and Poisson noise into the image, sensor noise in low-light environments is simulated.
[0030] Image compression: Simulates quality loss during transmission. JPEG compression is applied to the image, with a randomly set compression quality factor, introducing block artifacts and ringing artifacts.
[0031] Polarizing filter effect: To simulate the local grayscale changes or halo effects that may occur after polarizing filter light, specific texture masks or local spectral responses are superimposed on the image to address the specific optical effects that may occur in actual industrial barcode scanning equipment (such as barcode readers equipped with polarizing lenses).
[0032] In constructing actual datasets, a strategy of stacking different degradation methods is adopted to increase the diversity of training data. For example, an original image may be processed simultaneously by downsampling, Gaussian blurring, and Gaussian noise to simulate a harsh working condition that is both blurry and dark.
[0033] After generating the data as described above, the dataset is divided. The resulting paired data sets are divided into training, testing, and validation sets according to a preset ratio (e.g., 8:1:1). The training set is used to optimize model parameters, the validation set is used to monitor model accuracy and adjust hyperparameters during training, and the testing set is used to finally evaluate the model's generalization ability and super-resolution reconstruction performance.
[0034] Step 2: Construct a super-resolution model, which includes an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence; wherein, the feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data respectively, and then outputs the extracted features by superimposing them.
[0035] The model designed in this embodiment (named BarcodeHR) aims to achieve lightweight and efficient barcode image reconstruction for edge computing devices. The specific network structure design is as follows: Input layer: The input layer is configured to receive a single-channel grayscale image; before inputting the training set into the super-resolution model, the barcode image is preprocessed to retain only grayscale information, and the dimension of the input data is adjusted to h×w×1, where h and w are the height and width of the image, respectively.
[0036] In practical processing, since one-dimensional, two-dimensional, and dot-matrix barcodes are essentially composed of black-and-white binary pixel blocks or lines, color information is not a necessary feature for the decoding process. To reduce the computational load and parameter redundancy of the model, this embodiment abandons the RGB three-channel input (h×w×3) commonly used in traditional super-resolution models. Instead, it performs grayscale preprocessing tailored to the characteristics of barcodes, using only the luminance channel (Y channel) or grayscale image as network input. This directly reduces the computational load of the input layer by approximately two-thirds, thereby significantly improving the inference speed on embedded devices.
[0037] Feature extraction module: Following the input layer is a feature extraction module customized for barcode textures. The structure of the feature extraction module is as follows: Figure 2As shown. Traditional convolutional neural networks typically use square kernels, such as 3×3 kernels, but they are inefficient when processing highly directional images like barcodes.
[0038] Therefore, in the feature extraction stage, this embodiment divides the input data into two parallel processing paths: the first path uses a 1×3 long strip convolution kernel, which is specifically used to capture the horizontal texture features of the barcode; the second path uses a 3×1 long strip convolution kernel, which is specifically used to capture the vertical texture features of the barcode.
[0039] After the two convolutional operations are completed, the extracted feature maps are added element-wise or superimposed channel-wise to fuse the feature information in the horizontal and vertical dimensions, which is then used as input for subsequent modules. This asymmetric convolutional design maintains a low number of parameters while also enhancing sensitivity to barcode edges.
[0040] Deep feature mapping module: The deep feature mapping module consists of three densely connected blocks connected in sequence; each densely connected block contains five convolutional layers, and the number of output channels of the five convolutional layers are set to 32, 64, 96, 64 and 32 respectively.
[0041] This module is the core of the model, responsible for learning high-frequency details from shallow features. This embodiment employs three cascaded DenseBlocks. To further compress the model size and improve feature flow efficiency, such as... Figure 3 As shown, each DenseBlock employs a diamond-shaped or bottleneck-shaped channel design strategy: Convolutional layer 1 (conv_x1): Outputs 32 channels; Second convolutional layer (conv_x2): Output channels are expanded to 64; The third convolutional layer (conv_x3): the output channels are further expanded to 96 to capture rich non-linear features; Convolutional layer 4 (conv_x4): The output channels shrink back to 64; The 5th convolutional layer (conv_x5): The output channels eventually shrink back to 32.
[0042] This design, which increases the number of channels first and then decreases them, ensures that the intermediate layers have sufficient width to extract complex features while limiting the amount of data at the module's input and output interfaces, effectively controlling the overall memory usage of the model.
[0043] Output layer: The output layer includes a convolutional layer and a subpixel convolutional layer; the feature map output by the depth feature mapping module is processed by the convolutional layer to output feature data with a size of h×w×4; the subpixel convolutional layer upsamples and rearranges the feature data to output a high-resolution barcode image with a size of 2h×2w×1.
[0044] The output layer is primarily responsible for mapping deep features back to image space and improving resolution. First, a convolutional layer is used to adjust the number of channels in the feature map to a multiple of the scaling factor squared. In this embodiment, the super-resolution scaling factor is set to 2x, so the convolutional layer sets the output channel count to 2×2=4 channels, i.e., the output dimension is h×w×4. Finally, an upsampling operation is performed using the sub-pixel convolution (PixelShuffle) module. PixelShuffle, through periodic rearrangement operations, reassembles the h×w×4 feature map into a high-resolution image with a shape of 2h×2w×1. Compared to deconvolution or interpolation upsampling, PixelShuffle effectively reduces the checkerboard effect, resulting in smoother and clearer edges in the generated barcode image, ultimately completing the super-resolution reconstruction.
[0045] Step 3: Define the overall loss function, which is a weighted sum of the pixel loss function, the perceptual loss function, and the generative adversarial loss function.
[0046] During training, to address the issue that a single loss function (such as mean squared error, MSE) can easily lead to blurred edges in the generated barcode images, making them difficult for the decoder to recognize, this embodiment designs a composite loss function (overall loss function) specifically for the characteristics of barcodes. The formula for the overall loss function L is as follows:
[0047] in, Represents pixel loss, Represents perceived loss, This represents generative adversarial loss. By balancing these three factors, the model can not only approximate the true value in terms of pixel values, but also restore the sharpness of the barcode in terms of visual perception and texture details.
[0048] The pixel loss function is mainly used to constrain the generated image to maintain consistency with the real image in pixel intensity. In this embodiment, the L1 norm is used for calculation, and the formula is as follows:
[0049] Where output represents the super-resolution image output by the BarcodeHR model. This represents the corresponding ground truth image. Compared to L2 loss, L1 loss is more effective at generating sharp edges and reducing over-smoothing.
[0050] The perceptual loss function is calculated based on a pre-trained VGG network. The calculation method is as follows: input the output image of the super-resolution model and the real image into the pre-trained VGG network respectively, extract the corresponding feature matrices, and calculate the difference between the two feature matrices as the perceptual loss value.
[0051] Specifically, a VGG network pre-trained on the ImageNet dataset is used as the feature extractor. Since the feature maps extracted by the deep convolutional layers of the VGG network contain high-level semantic and textural information of the image, calculating the Euclidean distance between these feature maps better reflects the visual similarity of the images than directly calculating pixel differences. The formula is expressed as:
[0052] in, It is the feature matrix output by a specific layer of the VGG network after the generated image has passed through it. It is the feature matrix output by a specific layer of the same VGG network from a real image. By minimizing this loss, the generated image is forced to maintain consistency with the real image in terms of texture structure (such as the black and white stripe boundaries of a barcode).
[0053] To further enhance the realism of the generated images, this embodiment introduces a GAN (Generative Adversarial Network) training mechanism. This loss function involves a discriminator network, which in this embodiment is also built based on the VGG architecture. The discriminator network aims to distinguish whether the input image is real or generated by the model, while the super-resolution model (generator) aims to deceive the discriminator network. The generative adversarial loss function formula is as follows:
[0054] in, It is the true label of the image (e.g., the real image is labeled as 1, and the generated image is labeled as 0). This refers to the probability label output by the discriminant network for the input image. During training, the parameters of the discriminant network are continuously updated. Through this adversarial game, the barcode image generated by the super-resolution model becomes statistically closer to the real image, thereby significantly improving the barcode recognition rate.
[0055] Step 4: Input the training set into the super-resolution model, calculate the error based on the overall loss function, and backpropagate to update the model parameters until the model converges. This step is the core process of the model learning barcode features. In practice, stochastic gradient descent or the Adam optimizer is used to iteratively update the network parameters.
[0056] To achieve high-quality image generation, this embodiment employs a Generative Adversarial Network (GAN) training strategy. In this architecture, the constructed BarcodeHR model serves as the generator, while an auxiliary VGG discriminator network is also built. The calculation of the generative adversarial loss function involves a discriminator network; during training, the discriminator network and the super-resolution model alternately update their parameters; the discriminator network determines whether the input image is a real image or an image generated by the super-resolution model; the generative adversarial loss function is calculated based on the cross-entropy between the output label of the discriminator network and the real label.
[0057] The specific alternating training process is as follows: Fix the generator and update the discriminator network: Input the real high-resolution barcode image (labeled 1) and the super-resolution image generated by the generator (labeled 0) into the discriminator network. Calculate the classification error and update the weights of the discriminator network to enable it to more accurately distinguish between real and fake barcodes.
[0058] With the discriminator network fixed, the generator is updated: the generator generates an image and inputs it into the discriminator network, but the goal here is to deceive the discriminator network into misclassifying the generated image as a real image (marked as 1). The generative adversarial loss, along with the aforementioned pixel loss and perceptual loss, is calculated, and the parameters of the BarcodeHR model are updated through backpropagation.
[0059] Through the aforementioned game process, the realism of the barcode images generated by the model is continuously improved.
[0060] In terms of specific training parameter settings, this embodiment has made the following configurations to ensure the best convergence effect: Initial learning rate: Set to 0.001 to help the model quickly escape local optima.
[0061] Batch size: The size of a single batch of training data is set to 128, which ensures training speed while providing sufficient sample diversity to stabilize the gradient.
[0062] Number of iterations: The number of training data iterations is set to 200,000 to ensure that the model can fully learn the barcode features under different degradation conditions.
[0063] Validation mechanism: During training, the model's accuracy is periodically tested using validation set data (e.g., by using PSNR or SSIM metrics, or by directly testing decoding success rate using barcode decoding software). If the validation set accuracy no longer improves, the learning rate can be appropriately reduced or training can be stopped early to prevent overfitting.
[0064] Step 5: Input the low-resolution barcode image to be recognized into the trained super-resolution model, and output a high-resolution barcode image. Once the model training has converged and its generalization ability has been verified on the test set, it can be deployed in real-world application scenarios.
[0065] In real-world scenarios (such as logistics sorting lines and handheld barcode scanning terminals), cameras capture images of barcodes, QR codes, or dot-matrix codes with poor image quality (blurry, noisy, insufficient resolution). The system first processes the captured images into grayscale and then feeds them as input to the trained BarcodeHR model.
[0066] The model performs rapid inference on the edge device, using the learned feature mapping relationships to reconstruct a 2x resolution image with sharp edges and clear textures. Finally, this high-resolution barcode image is sent to a standard barcode decoding algorithm for recognition. Due to the super-resolution enhancement, the black and white boundaries of the barcode become clearer, and interference noise is suppressed, thus significantly improving the decoding success rate and recognition speed in complex environments. The model designed in this embodiment is small in size and has low computational cost, making it particularly suitable for real-time operation on embedded hardware or mobile edge devices with limited computing resources.
[0067] Example 2 This embodiment is a barcode image super-resolution system, which is used to implement the super-resolution method as described in Embodiment 1, including: The data acquisition module is used to acquire a training set containing several pairs of images, each pair of images containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label. The model building module is used to build a super-resolution model, which includes an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence. The feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data, and then outputs the extracted features by superimposing them. The training module is used to define the overall loss function, which is composed of a weighted sum of the pixel loss function, the perceptual loss function, and the generative adversarial loss function; and to input the training set into the super-resolution model, calculate the error based on the overall loss function, and backpropagate to update the model parameters until the model converges. The inference module is used to input the low-resolution barcode image to be recognized into the trained super-resolution model and output a high-resolution barcode image.
[0068] Example 3 This embodiment is an electronic device, including: One or more processors; Memory, used to store one or more computer programs; One or more computer programs stored in the memory are executed by the one or more processors, causing the one or more processors to implement the super-resolution method as described in Embodiment 1.
[0069] Example 4 This embodiment is a computer-readable storage medium storing a computer program that, when executed by a processor, implements the super-resolution method as described in Embodiment 1.
[0070] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the inventive concept of the present invention, and these all fall within the protection scope of the present invention.
Claims
1. A barcode image super-resolution method, characterized in that, Includes the following steps: Obtain a training set containing several pairs of images, each pair containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label; A super-resolution model is constructed, comprising an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence; wherein, the feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data respectively, and the extracted features are superimposed and output; Define an overall loss function, which is a weighted sum of pixel loss function, perceptual loss function and generative adversarial loss function; The training set is input into the super-resolution model, the error is calculated based on the overall loss function, and the model parameters are updated by backpropagation until the model converges. The low-resolution barcode image to be recognized is input into the trained super-resolution model, and the high-resolution barcode image is output.
2. The method according to claim 1, characterized in that, The method for constructing the training dataset includes: Different types of raw barcode images are generated using a barcode generation library and used as the high-resolution barcode images; The original barcode image is subjected to image quality degradation simulation processing to generate the corresponding low-resolution barcode image; The image quality degradation simulation processing includes at least one of the following: image blurring, poor lighting, image scaling, image compression, and polarizer overlay filter effects.
3. The method according to claim 1, characterized in that, The input layer is configured to receive a single-channel grayscale image; Before inputting the training set into the super-resolution model, the barcode image is preprocessed to retain only grayscale information, and the dimensions of the input data are adjusted to h×w×1, where h and w are the height and width of the image, respectively.
4. The method according to claim 1, characterized in that, The deep feature mapping module consists of three densely connected blocks connected in sequence; Each densely connected block contains 5 convolutional layers, with the output channels of the 5 convolutional layers set to 32, 64, 96, 64, and 32 respectively.
5. The method according to claim 1, characterized in that, The output layer includes convolutional layers and subpixel convolutional layers; The feature map output by the deep feature mapping module is processed by the convolutional layer, and the output is feature data with a size of h×w×4. The subpixel convolutional layer upsamples and rearranges the feature data, outputting a high-resolution barcode image with dimensions of 2h×2w×1.
6. The method according to claim 1, characterized in that, The perceptual loss function is calculated based on a pre-trained VGG network; The calculation method is as follows: input the output image of the super-resolution model and the real image into the pre-trained VGG network, extract the corresponding feature matrices, and calculate the difference between the two feature matrices as the perceptual loss value.
7. The method according to claim 1, characterized in that, The calculation of the generative adversarial loss function involves a discriminative network; During training, the discriminant network and the super-resolution model alternately update parameters; the discriminant network is used to determine whether the input image is a real image or an image generated by the super-resolution model; the generative adversarial loss function is calculated based on the cross-entropy between the output label of the discriminant network and the real label.
8. A barcode image super-resolution system, characterized in that, The system is used to implement the super-resolution method as described in any one of claims 1-7, comprising: The data acquisition module is used to acquire a training set containing several pairs of images, each pair of images containing a low-resolution barcode image and a corresponding high-resolution barcode image as a label. The model building module is used to build a super-resolution model, which includes an input layer, a feature extraction module, a deep feature mapping module, and an output layer connected in sequence. The feature extraction module uses 1x3 convolutional kernels and 3x1 convolutional kernels in parallel to extract features from the input data, and then outputs the extracted features by superimposing them. The training module is used to define the overall loss function, which is composed of a weighted sum of the pixel loss function, the perceptual loss function, and the generative adversarial loss function; and to input the training set into the super-resolution model, calculate the error based on the overall loss function, and backpropagate to update the model parameters until the model converges. The inference module is used to input the low-resolution barcode image to be recognized into the trained super-resolution model and output a high-resolution barcode image.
9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs; The feature is that one or more computer programs stored in the memory are executed by the one or more processors, causing the one or more processors to implement the super-resolution method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the super-resolution method as described in any one of claims 1-7.