QR code recognition methods and devices, storage media, and scanning equipment
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-27
- Publication Date
- 2026-08-14
AI Technical Summary
对于屏幕上的二维码,由于屏幕本身会发光,因此扫码设备在扫描设置在屏幕上的二维码时,如果开启补光灯,反而会影响摄像头读取的图像数据,造成解码失败
[0039]本发明实施例提供的二维码识别方法及装置,在对二维码进行扫码识别过程中,针对采集的每帧图像,实时进行变化趋势检测,从而筛选出可以用于升级神经网络模型的图像,对神经网络模型进行升级,基于升级后的神经网络模型确定下一帧图像采集参数,并将其应用于下一帧图像采集中,也就是说,更新设备的图像采集参数,从而使新的图像采集参数与当前环境更适应。利用本发明方案,在扫码识别过程中,通过对采集的图像进行分析,无需使用人员配置,即可实现对扫码设备图像采集参数的智能化调节,进而可以有效提升复杂扫码环境下的图像采集质量,尤其是针对彩色二维码的扫码识别,可以很大程度上提升解码成功率。
Smart Images

Figure CN120562447B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically to a QR code recognition method and apparatus, storage medium, and scanning device. Background Technology
[0002] A QR code is a black-and-white graphic that records data information, arranged according to a specific geometric pattern on a two-dimensional plane. It can be automatically read by image input devices or scanning devices. QR codes are mainly displayed on screens or printed on paper. For QR codes printed on paper, since paper itself does not emit light and does not easily reflect light, scanning devices need to turn on a supplementary light to improve the clarity of the image read by the camera and increase the decoding success rate. For QR codes on screens, since the screen itself emits light, turning on a supplementary light when scanning QR codes on a screen can actually interfere with the image data read by the camera, causing decoding failure.
[0003] Conventional barcode scanners require manual configuration and replacement of their supplementary lighting colors, which is inefficient. Furthermore, many users lack the necessary expertise to optimize the lighting for different environments. Additionally, conventional scanners use a single light color and fixed intensity parameters, and their camera settings are slow, leading to image convergence issues in extreme scenarios. Moreover, the fixed adjustment modes of the camera and supplementary lighting, coupled with the need for manual configuration, fail to adapt to all scanning environments. In complex environments, the images captured by these scanners are of poor quality, frequently exhibiting overexposure or underexposure in certain areas, resulting in recognition and decoding failures, reduced overall scanning smoothness, and a negative impact on the user experience. Summary of the Invention
[0004] This invention provides a QR code recognition method and device, storage medium, and scanning equipment, which enables intelligent adjustment of image acquisition parameters of the scanning equipment, thereby improving the scanning success rate in complex scanning environments.
[0005] Therefore, the embodiments of the present invention provide the following technical solutions:
[0006] On one hand, embodiments of the present invention provide a QR code recognition method, the method comprising:
[0007] The QR code image is acquired frame by frame according to the set image acquisition parameters, and the current frame image is decoded.
[0008] Detect change trends in the current frame image;
[0009] If the trend of change is consistent, the neural network model is iteratively upgraded using the current frame image;
[0010] The upgraded neural network model is used to determine the acquisition parameters for the next frame image and predict the change in the image quality index for the next frame.
[0011] Update the image acquisition parameters to the parameters for the next frame image acquisition.
[0012] Optionally, the image acquisition parameters include: camera and supplementary light adjustment parameters.
[0013] Optionally, the step of detecting the change trend of the current frame image includes:
[0014] Determine the quality index of the current frame image;
[0015] The change in the quality index of the current frame image is determined based on the quality index of the current frame image and the quality index of the previous frame image.
[0016] Based on the change in the quality index of the current frame image and the predicted change in the quality index of the current frame image from the previous frame, determine whether the trends are consistent.
[0017] Optionally, determining the quality index of the current frame image includes:
[0018] Divide the central region of the current frame image into multiple sub-regions;
[0019] The quality parameters of the multiple sub-regions are weighted to obtain the quality index of the current frame image.
[0020] Optionally, the quality parameters include any one or more of the following: image color, average brightness, and contrast.
[0021] Optionally, the iterative upgrade of the neural network model using the current frame image includes:
[0022] Compare the change in quality index of the current frame image with the difference between the change in quality index of the current frame image predicted in the previous frame;
[0023] The neural network model is iteratively upgraded based on the differences.
[0024] Optionally, the method further includes: updating the baseline parameters of the neural network model if the detected change trends are inconsistent and the number of re-detections exceeds a set number.
[0025] On the other hand, embodiments of the present invention also provide a QR code recognition device, the device comprising:
[0026] The image acquisition module is used to acquire QR code images frame by frame according to the set image acquisition parameters;
[0027] The decoding module is used to decode the current frame image;
[0028] The trend detection module is used to detect trends in the current frame image.
[0029] The model training module is used to iteratively upgrade the neural network model using the current frame image when the trend detection module detects a consistent trend.
[0030] The prediction module is used to determine the acquisition parameters of the next frame image and predict the change value of the image quality index of the next frame image using the upgraded neural network model;
[0031] The parameter setting module is used to update the set image acquisition parameters to the image acquisition parameters for the next frame.
[0032] Optionally, the trend detection module includes:
[0033] The quality index determination unit is used to determine the quality index of the current frame image;
[0034] The comparison unit is used to determine the change in the quality index of the current frame image based on the quality index of the current frame image and the quality index of the previous frame image.
[0035] The detection unit is used to determine whether the change trend is consistent based on the change value of the quality index of the current frame image and the change value of the quality index of the current frame image predicted in the previous frame.
[0036] Optionally, the device further includes a baseline parameter update module, used to update the baseline parameters of the neural network model when the trend of change detected by the trend of change detection module is inconsistent and the number of re-detections exceeds a set number.
[0037] On the other hand, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to perform the steps of the aforementioned QR code recognition method.
[0038] On the other hand, embodiments of the present invention also provide a barcode scanning device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the steps of the aforementioned barcode recognition method when running the computer program.
[0039] The QR code recognition method and apparatus provided in this invention perform real-time trend detection on each captured image frame during QR code scanning and recognition. This allows for the selection of images suitable for upgrading the neural network model. The upgraded model is then used to determine the acquisition parameters for the next image frame, which are applied to this upgrade. In other words, the device's image acquisition parameters are updated to better adapt to the current environment. Using this invention, the captured images are analyzed during the scanning and recognition process, enabling intelligent adjustment of the scanning device's image acquisition parameters without the need for manual configuration. This effectively improves image acquisition quality in complex scanning environments, particularly for color QR code scanning and recognition, significantly increasing the decoding success rate.
[0040] Furthermore, baseline parameters for the neural network model can be set to adapt to different scanning environments. If the detected trends are inconsistent and the number of re-detections exceeds a set number, it indicates that the neural network model's parameters are less adaptable to the environment. In this case, updating the baseline parameters of the neural network model and continuing scanning recognition allows for faster and more effective optimization of model parameters, improving model prediction performance, and ultimately enhancing image acquisition quality and scanning success rate. Attached Figure Description
[0041] The accompanying drawings are provided to offer a clearer understanding of the invention and form part of the specification. They are used together with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0042] Figure 1 This is a flowchart of a QR code recognition method provided in an embodiment of the present invention;
[0043] Figure 2 This is a schematic diagram illustrating the adjustment of the fill light color in a scenario with QR codes of multiple background colors, based on the QR code recognition method provided in this embodiment of the invention.
[0044] Figure 3 This is a schematic diagram illustrating the adjustment of the fill light color in a scenario where the QR code recognition method provided in this embodiment of the invention has a red background and the background is partially dirty.
[0045] Figure 4 This is a schematic diagram illustrating the division of the image center region into multiple sub-regions in an embodiment of the present invention;
[0046] Figure 5 This is a schematic diagram of the grayscale value distribution histogram of the central region of an image in a standard scene according to an embodiment of the present invention;
[0047] Figure 6 This is a schematic diagram of the weights of each sub-region of an image in a standard scene according to an embodiment of the present invention;
[0048] Figure 7 This is a schematic diagram of the grayscale value distribution histogram of the central region of the image under a two-polar scene in an embodiment of the present invention;
[0049] Figure 8 This is a schematic diagram of the grayscale value distribution histogram of the central region of an image in a complex scene according to an embodiment of the present invention;
[0050] Figure 9 This is a schematic diagram illustrating the weight and category division of each sub-region of an image in a complex scene according to an embodiment of the present invention;
[0051] Figure 10 This is another flowchart of the QR code recognition method provided in the embodiments of the present invention;
[0052] Figure 11 This is a schematic diagram of a QR code recognition device provided in an embodiment of the present invention;
[0053] Figure 12 This is another structural schematic diagram of the QR code recognition device provided in the embodiments of the present invention;
[0054] Figure 13 This is a schematic diagram of the hardware structure of the barcode scanning device provided in an embodiment of the present invention. Detailed Implementation
[0055] The principles and spirit of the invention will now be described with reference to exemplary embodiments shown in the accompanying drawings. It should be understood that these embodiments are described merely to enable those skilled in the art to better understand and implement the invention, and are not intended to limit the scope of the invention in any way.
[0056] To address the problem that existing QR code scanning devices have limited adjustment methods for cameras and supplementary lights, resulting in poor image quality and affecting recognition and decoding performance, this invention provides a QR code recognition method and apparatus. During the QR code scanning and recognition process, the method performs real-time trend detection on each captured image frame to select images suitable for upgrading the neural network model. The neural network model is then iteratively upgraded, and the parameters for acquiring the next image frame are determined based on the upgraded model and applied to the acquisition of the next image frame.
[0057] like Figure 1 The diagram shown is a flowchart of a QR code recognition method provided in an embodiment of the present invention, which includes the following steps:
[0058] Step 101: Acquire QR code images frame by frame according to the set image acquisition parameters, and decode the current frame image.
[0059] For example, a CMOS camera can be used to capture QR code images. The image acquisition parameters are dynamically adjusted according to changes in the environment to adapt to the current environment and improve the scanning success rate. These image acquisition parameters may specifically include camera and supplementary light adjustment parameters, such as the brightness and color of the supplementary light.
[0060] Existing technologies can be used for image decoding, and this embodiment of the invention does not limit the scope of the invention.
[0061] Step 102: Detect the change trend of the current frame image.
[0062] The purpose of detecting changes in the current frame image is to select image samples that are suitable for iteratively upgrading the neural network model used to determine the acquisition parameters of the next frame image.
[0063] In one non-limiting embodiment, trend detection of the current frame image can be performed from three dimensions: average brightness, contrast, and background color. Taking average brightness as an example:
[0064] If the predicted brightness change of the next frame is level 0, it means that the average brightness of the next frame should remain constant, and the average brightness change should be between (-15, 15).
[0065] If the predicted brightness change of the next frame is -1, it means that the average brightness of the next frame should be darker, and the average brightness change of the next frame should be between (-15, -30).
[0066] If the predicted brightness change of the next frame is -2, it means that the average brightness of the next frame should darken drastically, and the average brightness change of the next frame should be greater than -30.
[0067] If the predicted brightness change of the next frame is level 1, it means that the average brightness of the next frame should increase, and the average brightness change of the next frame should be between (15, 30).
[0068] If the predicted brightness change of the next frame is level 2, it means that the average brightness of the next frame should increase dramatically, and the average brightness change of the next frame should be greater than 30.
[0069] If the average brightness of the next frame does not meet expectations, it will be automatically filtered out and not used as a sample for subsequent neural network model self-upgrade, thus improving the efficiency of the entire process.
[0070] In another non-limiting embodiment, the trend of change in the current frame image can be determined based on changes in the image quality index. Specifically, the trend of change in the current frame image can be detected in the following manner:
[0071] (1) Determine the quality index of the current frame image.
[0072] Specifically, the central region of the current frame image can be divided into multiple sub-regions; then, the quality parameters of the multiple sub-regions are weighted to obtain the quality index of the current frame image.
[0073] For example, for images of different sizes supported by barcode scanning devices on the market (including but not limited to 320×240, 640×480, 1280×800), the middle 9 / 25 area (3 / 5 length × 3 / 5 width) of the captured image can be divided into 9 sub-regions, 25 sub-regions, or 49 sub-regions according to the size. The larger the image size, the more sub-regions are divided.
[0074] If the central region of an image is divided into 9 sub-regions, then the central sub-region will be designated as the primary core region, and the remaining 8 sub-regions will be designated as edge regions. Figure 4 As shown in (a);
[0075] If the central region of an image is divided into 25 sub-regions, then the central sub-region is the primary core block, the outermost 8 sub-regions are secondary core blocks, and the remaining 16 sub-regions are edge blocks. Figure 4 As shown in (b);
[0076] If the central region of an image is divided into 49 sub-regions, then the centralmost sub-region is the primary core region, the outermost 8 sub-regions are secondary core regions, the next outermost 16 sub-regions are tertiary core regions, and the remaining 24 sub-regions are edge regions. Figure 4 As shown in (c).
[0077] The quality parameters may include, but are not limited to, any one or more of the following: image color, average brightness, contrast, etc. The weights of each quality parameter can be set based on different scenarios and application needs, and this embodiment of the invention does not limit this.
[0078] The following is based on Figure 4 Using the sub-region shown in (b) and the three quality parameters mentioned above as examples, the process of determining the image quality index is explained.
[0079] like Figure 4 As shown in (b), the central sub-region is designated as a level 1 block, the middle sub-region as a level 2 block, and the outer sub-region as a level 3 region.
[0080] First, calculate the following three quality parameters:
[0081] The average gray value of each sub-region is used as the average brightness of that sub-region.
[0082] The difference in average gray value between any two adjacent sub-regions is used as the contrast between the two sub-regions.
[0083] The gray value of each sub-region is used as the color of that sub-region to obtain the gray value distribution histogram of the central region of the image (i.e., each sub-region).
[0084] Secondly, for different scanning scenarios, weights are set for each sub-region, and a weighted calculation is performed to obtain the image quality index. The following example uses the average brightness as a quality parameter for illustration.
[0085] For example, for standard scenarios:
[0086] When recognizing a QR code on a piece of paper or against an ideally clean background, because the supplementary light is focused on the central area, the overall brightness of the level 1, level 2, and level 3 areas will gradually change, but this gradual change will be within a certain margin of error. Specifically, this manifests as a gradual change in contrast between adjacent sub-regions with the change values remaining within the error range; and the histogram of grayscale value distribution in the central area tends to be more uniform, such as... Figure 5 As shown in (a) and (b), the gray value distribution histogram is used to describe the probability of occurrence of each gray level in the image. Its horizontal axis represents the gray level, and the vertical axis represents the probability of occurrence of the corresponding gray level pixel, that is, the ratio of the number of pixels of the corresponding gray level to the total number of pixels. Figure 5 The histograms shown in (a) and (b) both show that there are many points in the middle area and few or almost no points in the two side areas, indicating that there are very few extremely bright or dark pixels in the corresponding images, and the overall image brightness is uniform and tends to be flat.
[0087] In this case, the average brightness of each sub-region of the image can be weighted and averaged according to a weight ratio of 8:4:1 for level 1: level 2: level 3. Figure 6 As shown, the final calculated value is used as the quality index of the image.
[0088] For example, regarding extreme scenarios:
[0089] When scanning a QR code in bright sunlight (natural sunlight illuminating the code area) or in low-light conditions at night, some areas of the captured image may be extremely bright and overexposed, while other areas may be almost completely dark. A typical scenario is presenting a payment code at a street-side shop at night. When scanning the payment code, only the area where the phone is located has high brightness, while the surrounding areas are very dark. This type of scenario frequently occurs when using mobile QR code services.
[0090] In this scenario, some of the 25 sub-regions exhibit contrast gradient values within the error range, while others show abrupt changes, far exceeding twice the error value. The grayscale value distribution histogram of the central region shows a pattern of high values at both ends and low values in the middle, such as a distorted V-shape, L-shape, or J-shape. Figure 7 As shown, the grayscale histogram of the image is L-shaped.
[0091] In this scenario, the 25 sub-regions can be divided into two main categories: dark and bright. Dark regions are those with lower average brightness values, while bright regions are those with higher average brightness values. The area percentage score for each category is calculated sequentially: 4 points for level 1 blocks, 2 points for level 2 blocks, and 1 point for level 3 blocks. If the area percentage score of a bright region is higher than that of a dark region, then the image quality parameters are only calculated for the bright sub-regions. In other words, the dark sub-regions are not included in the subsequent weighted calculation, and the weighted average is still calculated using the ratio of level 1:2:3 = 8:4:1, and vice versa.
[0092] For example, in complex scenarios:
[0093] In complex QR code scanning scenarios, such as recognizing QR codes printed on brightly colored posters or advertisements—a scenario that occurs very frequently in real life—using average brightness or the weighted average method described in the standard scenario to calculate quality parameters can lead to an inability to distinguish between primary and secondary areas. The average grayscale value of the sub-region containing the QR code will be affected by other sub-regions. For example, among the 25 sub-regions, some sub-regions may have contrast gradients within the error range, while others may have abrupt contrast changes, such as exceeding the error value but being less than twice the error value. In this case, the grayscale distribution histogram in the central region tends to be uniform, and multiple peaks may appear, such as... Figure 8 As shown.
[0094] In this scenario, the contrast between pairs of adjacent sub-regions can be detected, and sub-regions with contrast differences within a certain range are classified as belonging to the same category. These 25 sub-regions are then divided into N categories (only adjacent, consecutive sub-regions can form a category). Next, the area percentage score of each of these N categories is calculated using the method employed in bipolar scenes, and the categories are sorted from highest to lowest. Each of these N categories is then assigned a weighted value of 2^(N-1), with higher area percentage scores resulting in higher weights. Finally, each of the 25 sub-regions is weighted according to a ratio of 8:4:1 (Level 1:Level 2:Level 3), and then multiplied by the weighted value of its category (2^(N-1)) to obtain the final weighted average, yielding the image quality index.
[0095] for example Figure 9As shown, the 25 sub-regions of the image were divided into three categories based on contrast: namely Figure 9 The area proportions of categories A, B, and C are ranked from highest to lowest as follows: A > B > C. The weighting values for each category are set as A:B:C = 4:2:1. Figure 9 The central sub-region is a Class A Level 1 block, and its weight is 8 × 4 = 32 when participating in the weighted calculation.
[0096] It should be noted that the above-mentioned image region division, category division, and weight values are only illustrative examples. In specific applications, they can be determined as needed, and the implementation of this invention is not limited in this regard.
[0097] In addition, if multiple different quality parameters are considered to determine the image index, the different quality parameters can be normalized and weighted to obtain the quality index of the current frame image.
[0098] (2) Determine the change in quality index of the current frame image based on the quality index of the current frame image and the quality index of the previous frame image.
[0099] The change in the quality index can be the difference between the quality index of the current frame image and the quality index of the previous frame image.
[0100] (3) Determine whether the trends of change are consistent based on the change value of the quality index of the current frame image and the change value of the quality index of the current frame image predicted in the previous frame. For example, suppose the change value of the quality index of the current frame image predicted by the neural network model in the previous frame is 10, while the actual change value of the quality index of the current frame image is 8. If the difference of 2 is within the set error range (e.g., the error range is (-15, +15)), it indicates that the trends of change are consistent; if the difference of the two exceeds the set error range, it indicates that the trends of change are inconsistent.
[0101] It should be noted that the adjustment parameters of the camera and the fill light are usually limited. For example, the maximum exposure parameter of the camera can only be adjusted to 1024. If the calculated exposure parameter required to adjust the average brightness of the image to 120 is 2000, then a neural network model is needed to recalculate the average brightness value of the next frame when the camera's exposure parameter is adjusted to the maximum (i.e., 1024).
[0102] Step 103: If the trend of change is consistent, then use the current frame image to iteratively upgrade the neural network model.
[0103] The neural network model is used to determine the acquisition parameters for the next frame of the image and to predict the change in the quality index of the next frame. The input to the neural network model is the change in the quality index of the current frame and the current image acquisition parameters; the output of the neural network model is the change in the quality index of the next frame and the image acquisition parameters for the next frame.
[0104] In practical applications, QR code images from common scanning scenarios can be collected, and an image quality index can be calculated using pre-defined weighting rules to train a general neural network model.
[0105] The training of a general neural network model can be carried out using conventional training methods, which involve collecting a large number of QR code images and corresponding image acquisition parameters to generate training samples, and then using the training samples to train and obtain the parameters of the neural network model.
[0106] During the QR code scanning and recognition process, based on the detection results of the changing trends of each frame of the collected images, images that can be used to upgrade the neural network model are selected, and the general neural network model is iteratively upgraded.
[0107] The iterative upgrade process of the neural network model is as follows: compare the difference between the quality index change value of the current frame image and the quality index change value predicted in the previous frame; and iteratively upgrade the neural network model based on the difference.
[0108] By iteratively upgrading the neural network model, the weighting values and factors of the mathematical formulas in the neural network model can be corrected, and the size of the calculation results in the mathematical formulas can be controlled.
[0109] Step 104: Use the upgraded neural network model to determine the image acquisition parameters for the next frame and predict the change in the image quality index for the next frame.
[0110] Step 105: Update the set image acquisition parameters to the next frame image acquisition parameters.
[0111] As mentioned earlier, the image acquisition parameters may include camera and supplementary light adjustment parameters, such as the brightness and color of the supplementary light.
[0112] The decoding process converts the acquired image into a grayscale image before proceeding with subsequent decoding output. The image contrast directly affects the quality of the grayscale-converted image, thus influencing the success of the final decoding. Automatically switching the color of the supplementary light based on the background color around the code area can improve the contrast of the acquired image.
[0113] For example, in a scenario involving white QR codes, the fill light will switch to a color other than the background color (but not the natural light color). Figure 2 As shown, the background color is multi-colored. Figure 2 The background colors shown are red and green, and the fill light color is switched to blue. Under the illumination of the blue fill light, the barcode scanner will eventually collect a blue QR code against a black background. Using this invention, multi-colored backgrounds can be unified into a single background color, effectively preventing the phenomenon of background layering in the code area after changes in image grayscale.
[0114] For example, in scenarios involving black QR codes, the fill light will switch to the same color as the background. Figure 3 As shown, Figure 3 The background of the QR code is smudged, revealing a pinkish-white area. During image binarization, the adjacent red portion may be identified as black, leading to image distortion after grayscale transformation. However, under a red fill light, the scanning device will capture a completely black QR code against a red background, ignoring the whitish smudged area and improving the quality of the image after grayscale transformation.
[0115] The QR code recognition method provided in this invention, during the QR code scanning process, obtains image samples that can be used to upgrade the neural network model by filtering each frame of the collected images, upgrades the neural network model, and determines the acquisition parameters of the next frame image based on the upgraded neural network model. This makes the new image acquisition parameters more adaptable to the current environment, realizes intelligent adjustment of the image acquisition parameters of the scanning device, effectively improves the image acquisition quality in complex scanning environments, and thus improves the scanning success rate.
[0116] It should be noted that if the trend detection results for the current frame image are inconsistent, it indicates that a sudden extreme situation has occurred in the scanning scenario. This could include, but is not limited to, situations such as sudden strong light, sudden camera obstruction, or sudden change of scene by the scanning device. In such cases, the current frame image can be considered invalid and not used as a sample for the neural network model's self-upgrade. In other words, in this situation, only the current frame image needs to be decoded and output, without performing steps 104 to 106 above.
[0117] Reference Figure 10 This is another flowchart of the QR code recognition method provided in this embodiment of the invention, including the following steps:
[0118] Step 201: Acquire QR code images frame by frame according to the set image acquisition parameters, and decode the current frame image.
[0119] Step 202: Detect the change trend of the current frame image to determine if the change trend is consistent. If yes, proceed to step 205; otherwise, proceed to step 203.
[0120] Step 203: Determine whether the number of re-inspections exceeds the set number; if so, proceed to step 204; otherwise, proceed to step 201, that is, re-acquire the QR code image for trend detection.
[0121] Step 204: Update the baseline parameters of the neural network model. Then proceed to step 205.
[0122] Because the effects of camera and supplementary light adjustment parameters on image quality can vary depending on the environment.
[0123] For example, when capturing images under strong light or in bright environments, adjusting the intensity of the fill light will not significantly change the overall brightness of the captured image. However, slightly adjusting the camera's exposure parameters will result in a large change in the average brightness of the captured image.
[0124] For example, when capturing images in a darkroom or in a dark outdoor setting, adjusting the intensity of the fill light will cause a significant change in the average brightness of the captured image, while adjusting the exposure and gain will have a relatively weaker impact on the average brightness of the image.
[0125] Therefore, in one non-limiting embodiment, baseline parameters for neural network models corresponding to different environmental parameters can be predetermined. By determining the current environmental parameters and selecting the baseline parameters corresponding to the current environmental parameters, the baseline parameters of the neural network model can be updated. The environmental parameters can be detected by collecting relevant data through corresponding sensors and determining them through certain calculations.
[0126] Step 205: Determine whether to continue scanning; if yes, proceed to step 206; otherwise, end the scanning process.
[0127] Step 206: Iteratively upgrade the neural network model using the current frame image.
[0128] Step 207: Use the upgraded neural network model to determine the image acquisition parameters for the next frame and predict the change in the image quality index for the next frame.
[0129] Step 208: Update the set image acquisition parameters to the parameters for the next frame image acquisition. Then return to step 201 and execute the acquisition operation for the next frame image.
[0130] Repeat the above process until the scanning is complete.
[0131] The QR code recognition method provided in this invention eliminates the need for manual configuration of supplementary lighting and camera parameters. It enables intelligent selection and configuration of image acquisition parameters, improving image quality and thus increasing the success rate of scanning. Furthermore, it automatically switches the baseline parameters of the neural network model, enhancing adaptability to different scanning environments.
[0132] As mentioned earlier, the neural network model is a general neural network model pre-trained by collecting QR code images from common scanning scenarios. In specific applications, general neural network models corresponding to different scenario types can also be trained for various typical application scenarios. Accordingly, before scanning and recognizing a QR code, the current scenario type is determined, and a neural network model suitable for the current scenario type is selected. During the QR code scanning and recognition process, the neural network model is iteratively updated. Moreover, this neural network model can be extended to add new scanning scenario models and undergo subsequent training; this neural network model has almost no scenario blind spots. Accordingly, this embodiment of the invention also provides a QR code recognition device, such as... Figure 11 The diagram shown is a structural schematic of the device.
[0133] The QR code recognition device 110 of this embodiment includes the following modules:
[0134] Image acquisition module 111 is used to acquire QR code images frame by frame according to the set image acquisition parameters;
[0135] Decoding module 112 is used to decode the current frame image;
[0136] The trend detection module 113 is used to detect the trend of change in the current frame image when the trend detection module detects a consistent trend.
[0137] Model training module 114 is used to iteratively upgrade the neural network model using the current frame image;
[0138] Prediction module 115 is used to determine the acquisition parameters of the next frame image and predict the change value of the image quality index of the next frame image using the upgraded neural network model;
[0139] The parameter setting module 116 is used to update the set image acquisition parameters to the next frame image acquisition parameters.
[0140] The image acquisition module 111 can be, for example, a CMOS camera.
[0141] The decoding module 112 can use existing technology to decode the image, and this embodiment of the invention does not limit this.
[0142] One non-limiting implementation example of the trend detection module 113 may include the following units:
[0143] The quality index determination unit is used to determine the quality index of the current frame image;
[0144] The comparison unit is used to determine the change in the quality index of the current frame image based on the quality index of the current frame image and the quality index of the previous frame image.
[0145] The detection unit is used to determine whether the change trend is consistent based on the change value of the quality index of the current frame image and the change value of the quality index of the current frame image predicted in the previous frame.
[0146] The iterative upgrade process of the model training module 114 for the neural network model is similar to the training process of the neural network model, and this embodiment of the invention does not limit it.
[0147] The QR code recognition device provided in this invention, during the QR code scanning process, obtains image samples that can be used to upgrade the neural network model by filtering each frame of the collected images, upgrades the neural network model, and determines the acquisition parameters of the next frame image based on the upgraded neural network model. This makes the new image acquisition parameters more adaptable to the current environment, realizes intelligent adjustment of the image acquisition parameters of the scanning device, effectively improves the image acquisition quality in complex scanning environments, and thus improves the scanning success rate.
[0148] like Figure 12 The diagram shown is another structural schematic of the QR code recognition device provided in an embodiment of the present invention.
[0149] and Figure 11 The difference in the illustrated embodiment is that, in this embodiment, the QR code recognition device 110 further includes: a baseline parameter update module 117, used to update the baseline parameters of the neural network model when the trend of change detected by the trend of change detection module 113 is inconsistent and the number of re-detections exceeds a set number.
[0150] The QR code recognition device provided in this invention eliminates the need for manual configuration of the fill light and camera parameters. It enables intelligent selection and configuration of image acquisition parameters, improving the quality of acquired images and thus increasing the success rate of scanning. Furthermore, it can automatically switch the baseline parameters of the neural network model, enhancing adaptability to different scanning environments. Moreover, it can quickly and accurately correct camera and fill light parameters when the scanning environment changes.
[0151] Furthermore, intelligent analysis and control can be used to automatically control the device to enter a low-power mode when there is no code area, while adjusting and reducing the brightness of the supplementary light to reduce energy consumption and temperature, thereby improving the lifespan of the device.
[0152] In specific implementations, the aforementioned devices may correspond to chips with corresponding functions in network equipment and / or user equipment, such as SOC (System-On-a-Chip), baseband chips, chip modules, etc.
[0153] In specific implementations, the modules / units included in the various devices and products described in the above embodiments can be software modules / units, hardware modules / units, or a combination of both. For example, for various devices and products applied to or integrated into a chip, all of their modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into a chip module, all of their modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The components can be implemented using software programs that run on the processor integrated within the chip module. The remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into the terminal, each of its components / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or in different components within the terminal. Alternatively, at least some modules / units can be implemented using software programs that run on the processor integrated within the terminal, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits.
[0154] This invention also discloses a storage medium, which is a computer-readable storage medium storing a computer program thereon, the computer program being executable during runtime. Figure 2 The method shown may include some or all of the steps. The storage medium may include read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc. The storage medium may also include non-volatile memory or non-transitory memory, etc.
[0155] Accordingly, embodiments of the present invention also provide a barcode scanning device, such as... Figure 13 The image shown is a schematic diagram of one type of hardware structure for this barcode scanning device.
[0156] The barcode scanning device includes a processor 131, a memory 132, and a transceiver 133. Among them:
[0157] Processor 131 can be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program according to the present application. Processor 131 may also include multiple CPUs, and processor 131 can be a single-core processor or a multi-core processor. Here, processor can refer to one or more devices, circuits, or processing cores used to process data (e.g., computer program instructions).
[0158] The memory 132 can be a ROM or other type of static storage device capable of storing static information and instructions, RAM or other type of dynamic storage device capable of storing information and instructions, or it can be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer. This application embodiment does not impose any limitations on this. The memory 132 can exist independently (in this case, the memory 132 can be located outside or inside the device) or it can be integrated with the processor 131. The memory 132 may contain computer program code. The processor 131 is used to execute the computer program code stored in the memory 132 to implement the method provided in this application embodiment.
[0159] The processor 131, memory 132, and transceiver 133 are connected via a bus. The transceiver 133 is used to communicate with other devices or communication networks.
[0160] when Figure 13 The schematic diagram shown illustrates the structure of the barcode scanning device involved in the above embodiments. The processor 131 is used to control and manage the actions of the barcode scanning device. For example, the processor 131 is used to support the barcode scanning device in performing... Figure 2 or Figure 10 The processor 131 can perform all or part of the steps in the process described in the embodiments of this application, and / or other actions performed by the scanning device in other processes. The processor 131 can communicate with other network entities via the transceiver 133. The memory 132 is used to store the program code and data of the scanning device.
[0161] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article indicates that the preceding and following related objects have an "or" relationship.
[0162] In the embodiments of this application, "multiple" refers to two or more.
[0163] The descriptions of "first," "second," etc., appearing in the embodiments of this application are for illustrative purposes and to distinguish the objects being described. They have no order and do not indicate any special limitation on the number of devices in the embodiments of this application, nor do they constitute any limitation on the embodiments of this application.
[0164] In this application, the term "connection" refers to various connection methods, such as direct connection or indirect connection, to achieve communication between devices. This application does not impose any limitations on this.
[0165] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0166] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer program are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means.
[0167] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0168] In the several embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, and systems can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0169] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0170] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can be physically arranged separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0171] The integrated unit implemented as a software functional unit described above can be stored in a computer-readable storage medium. This software functional unit, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute some steps of the methods described in the various embodiments of this application.
[0172] While this application discloses the above information, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of this application; therefore, the scope of protection of this application shall be determined by the scope defined in the claims.
Claims
1. A QR code recognition method, characterized in that, The method includes: The QR code image is acquired frame by frame according to the set image acquisition parameters, and the current frame image is decoded. Detect change trends in the current frame image; If the trends are consistent, then: Iteratively upgrade the neural network model using the current frame image; The upgraded neural network model is used to determine the acquisition parameters for the next frame image and predict the change in the image quality index for the next frame. The image acquisition parameters are updated to the parameters for the next frame image acquisition. The step of detecting the change trend of the current frame image includes: Determine the quality index of the current frame image; The change in the quality index of the current frame image is determined based on the quality index of the current frame image and the quality index of the previous frame image. If the difference between the change in the quality index of the current frame image and the predicted change in the quality index of the current frame image in the previous frame is within the set error range, then the trend of change is determined to be consistent.
2. The QR code recognition method according to claim 1, characterized in that, The image acquisition parameters include: camera and supplementary light adjustment parameters.
3. The QR code recognition method according to claim 1, characterized in that, Determining the quality index of the current frame image includes: Divide the central region of the current frame image into multiple sub-regions; The quality parameters of the multiple sub-regions are weighted to obtain the quality index of the current frame image.
4. The QR code recognition method according to claim 3, characterized in that, The quality parameters include any one or more of the following: image color, average brightness, and contrast.
5. The QR code recognition method according to claim 1, characterized in that, The iterative upgrade of the neural network model using the current frame image includes: Compare the change in quality index of the current frame image with the difference between the change in quality index of the current frame image predicted in the previous frame; The neural network model is iteratively upgraded based on the differences.
6. The QR code recognition method according to any one of claims 1 to 5, characterized in that, The method further includes: If the detected trends are inconsistent and the number of re-detections exceeds the set number, then update the baseline parameters of the neural network model.
7. A QR code recognition device, characterized in that, The device includes: The image acquisition module is used to acquire QR code images frame by frame according to the set image acquisition parameters; The decoding module is used to decode the current frame image; The trend detection module is used to detect trends in the current frame image. The model training module is used to iteratively upgrade the neural network model using the current frame image when the trend detection module detects a consistent trend. The prediction module is used to determine the acquisition parameters of the next frame image and predict the change value of the image quality index of the next frame image using the upgraded neural network model; The parameter setting module is used to update the set image acquisition parameters to the image acquisition parameters for the next frame; The trend detection module includes: The quality index determination unit is used to determine the quality index of the current frame image; The comparison unit is used to determine the change in the quality index of the current frame image based on the quality index of the current frame image and the quality index of the previous frame image. The detection unit is used to determine that the trend of change is consistent if the difference between the change value of the quality index of the current frame image and the change value of the quality index of the current frame image predicted in the previous frame is within a set error range.
8. The QR code recognition device according to claim 7, characterized in that, The device further includes: The baseline parameter update module is used to update the baseline parameters of the neural network model when the trend of change detected by the trend of change detection module is inconsistent and the number of re-detections exceeds a set number.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when run by a processor, performs the steps of the QR code recognition method according to any one of claims 1 to 6.
10. A barcode scanning device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the steps of the QR code recognition method according to any one of claims 1 to 6 when running the computer program.
Citation Information
Patent Citations
Two-dimensional code scanning and recognizing method and device, mobile terminal and storage medium
CN107220578A
Dynamic automatic exposure control method and device, and electronic equipment
CN111246091A