Pre-decoding method based on image detection, code reader and computer storage medium
By collecting images in real time and predicting user decoding intentions during the standby state of the code reader, and initializing them in advance, the problem of initialization delay of existing code readers is solved, achieving faster response speed and better user experience.
Patent Information
- Application Number
- CN202411911240.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
AI Technical Summary
Existing handheld code readers have initialization delays in the decoding process, which affects the user experience and leads to efficiency bottlenecks in high-frequency, large-scale decoding tasks.
Images are collected in real time during the standby state of the code reader, and the user's decoding intention is predicted through image changes, and the code reader initialization is performed in advance, which shortens the waiting time between the user pressing the decoding key and the decoding start.
It achieves faster response speed, improves user experience, and meets the application needs of high-frequency and large-scale decoding tasks.
Smart Images

Figure CN119850757A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of industrial code readers, and in particular to a pre-decoding method based on image detection, a code reader and a computer storage medium. Background Art
[0002] Barcode readers are commonly used to read barcodes or QR codes that identify and record cargo information, complete computer information collection and input, and are widely used in the field of Internet of Things technology. Existing barcode readers include handheld barcode readers and fixed barcode readers. Among them, handheld barcode readers mainly scan cargo with the user's handheld barcode reader to complete decoding.
[0003] In current handheld barcode readers, the decoding process usually starts with pressing the decoding button. After the decoding button is pressed, the barcode reader must first enter the initialization process, which mainly initializes a series of parameters such as the sensor, lighting system, decoding library, etc., in order to obtain images and perform subsequent decoding. However, this initialization process often takes tens of milliseconds. In applications, this delay not only affects the user experience, but also leads to efficiency bottlenecks in high-frequency, large-volume decoding tasks. Summary of the invention
[0004] The purpose of the present invention is to solve the shortcomings existing in the prior art, and to propose a pre-decoding method based on image detection, a code reader and a computer storage medium, which collect images in real time when the code reader is in standby state, predict the user's decoding intention through image changes, and initialize the code reader in advance, thereby shortening the waiting time between the user pressing the decoding button and the start of decoding, achieving faster response speed, improving user experience, and meeting the application requirements of high-frequency and large-volume decoding tasks.
[0005] To achieve the above object, the present invention adopts the following technical solutions: According to a first aspect of the present invention, a pre-decoding method based on image detection is provided, the pre-decoding method based on image detection comprising the following steps: Step S1: Entering standby mode; Step S2: Acquire a sampling image, sequentially acquire a set number of calibration images, and compare each calibration image with the sampling image, calculate the average value and standard deviation of the difference between the calibration image and the sampling image, and calculate the sampling threshold according to the average value and standard deviation; wherein the sampling threshold = average value + 10 × standard deviation; Step S3: Obtain new images, and compare each new image with the sampled image, calculate the average value of the image differences, then the new image threshold = the average value of the difference between the new image and the sampled image; and compare the new image threshold with the sampled threshold; Step S4: Determine whether the new image threshold is greater than the sampling threshold for three consecutive times. If so, execute step S5; if not, return to step S1; Step S5: configure the sensor parameters, lighting parameters and decoding library parameters under the trigger state, and clear all acquired images, and then execute step S6; Step S6: Determine whether the user triggers the decoding operation within the set time; if not, execute step S7; if triggered, execute step S8; Step S7: Restore the sensor parameters, lighting parameters and decoding library parameters in the standby state, and then return to step S1; Step S8: Acquire the current image and decode it, and output the decoding result after decoding is completed; then return to step S1.
[0006] Preferably, in step S2, the calibration number is set to 4-8.
[0007] Preferably, in step S2, the difference between each calibration image and the sampled image is ; Wherein, each pixel difference value is obtained by subtracting the corresponding pixel value of the calibration image from the sampled image, and n is the total number of pixels.
[0008] Preferably, in step S2, the difference between each calibration image and the sampled image is .
[0009] Preferably, in step S6, the time is set to 0.5 seconds to 3 seconds.
[0010] According to a second aspect of the present invention, a code reader is provided, wherein the code reader is used to execute the above-mentioned image detection-based pre-decoding method.
[0011] According to a third aspect of the present invention, there is provided a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the pre-decoding method based on image detection as described above is implemented.
[0012] Compared with the prior art, the beneficial effects of the present invention are as follows: in the image detection-based pre-decoding method of the present invention, images are collected in real time when the device is in standby state, and the user's decoding intention is predicted by image changes, so that the code reader is initialized in advance, thereby shortening the waiting time between the user pressing the decoding button and the start of decoding, achieving faster response speed, improving user experience, and meeting the application requirements of high-frequency and large-volume decoding tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 The present invention is a flowchart of a pre-decoding method based on image detection. DETAILED DESCRIPTION
[0014] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention. It can be understood that some technical means of the various embodiments described herein can be replaced or combined with each other without conflict.
[0015] In the description of the present invention, if there are terms such as "first", "second", etc., they are only used to distinguish the objects described, and do not have any order or technical meaning. Therefore, the objects defined as "first", "second", etc. may explicitly or implicitly include one or more of the objects. In addition, "one" or "a" and similar words do not indicate a quantity limitation, but indicate the existence of at least one, and "multiple" means not less than two.
[0016] In the description of the present specification, reference to "one embodiment" or "some embodiments" etc. means that one or more embodiments of the present invention include a specific feature, structure or characteristic described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0017] According to a first aspect of the present invention, a pre-decoding method based on image detection is provided, which can be applied to various barcode scanning devices, image detection devices and other devices that need to quickly acquire and decode image information.
[0018] Reference Figure 1 As shown, in some embodiments, the pre-decoding method based on image detection includes the following steps: Step S1: Entering the standby state. At this time, the barcode reader operates according to the sensor parameters, lighting parameters and decoding library parameters in the standby state. The sensor parameters, lighting parameters and decoding library parameters in the standby state can be reasonably set according to actual conditions.
[0019] Step S2: Acquire a sampling image, sequentially acquire a set number of calibration images, and compare each calibration image with the sampling image, calculate the average value and standard deviation of the difference between the calibration image and the sampling image, and calculate the sampling threshold based on the average value and standard deviation. Wherein, the sampling threshold = average value + 10 × standard deviation.
[0020] In step S2, when comparing each calibration image with the sampled image, the corresponding pixel values of the calibration image and the sampled image are subtracted to obtain the corresponding pixel difference value. The absolute values of all pixel difference values are added and then divided by the total number of pixels to obtain the average value of the difference between the calibration image and the sampled image. That is, the difference between the calibration image and the sampled image is , n is the total number of pixels. Each pixel difference value is obtained by subtracting the corresponding pixel value of the calibration image from the sampled image, and n is the total number of pixels.
[0021] The standard deviation of the difference between the calibration image and the sampled image is used to reflect the discreteness of the pixel difference value. The standard deviation is calculated by calculating the square of the difference between each pixel difference value and the average value, then summing it, dividing it by the number of data, and finally taking the square root, that is, the standard deviation of the difference between each calibration image and the sampled image. .
[0022] Furthermore, the sampling threshold is calculated by adding the average value calculated in the above process to ten times the standard deviation, that is, sampling threshold = average value + 10 × standard deviation.
[0023] Step S3: Obtain new images, and compare each new image with the sampled image, calculate the average value of the difference between the new image and the sampled image, then the new image threshold = the average value of the difference between the new image and the sampled image; and compare the new image threshold with the sampled threshold.
[0024] The method for calculating the average value of the difference between the new image and the sampled image can refer to the method for calculating the average value of the difference between the calibration image and the sampled image in step S2. , n is the total number of pixels. Each pixel difference value is obtained by subtracting the corresponding pixel value of the new image from the sampled image, and n is the total number of pixels.
[0025] Step S4: Determine whether the new image threshold is greater than the sampling threshold for three consecutive times. If so, execute step S5; if not, return to step S1. When the new image threshold is greater than the sampling threshold for three consecutive times, it means that the new image has changed relative to the sampling image, which indicates that the field of view of the code reader has changed, and it is determined that the user has picked up the code reader. In this way, the user's decoding intention can be predicted.
[0026] Step S5: configure the sensor parameters, lighting parameters and decoding library parameters in the triggered state, and clear all acquired images, and then execute step S6. The sensor parameters, lighting parameters and decoding library parameters in the triggered state can be reasonably set according to actual conditions.
[0027] Step S6: Determine whether the user triggers the decoding operation within the set time; if not, execute step S7; if triggered, execute step S8.
[0028] Step S7: Restore the sensor parameters, lighting parameters and decoding library parameters in the standby state, and then return to step S1.
[0029] Step S8: Acquire the current image and decode it, and output the decoding result after decoding is completed; then return to step S1.
[0030] In the image detection-based pre-decoding method of the present invention, images are collected in real time when the device is in standby mode, and the user's decoding intention is predicted by image changes, so that the code reader is initialized in advance, thereby shortening the waiting time between the user pressing the decoding button and the start of decoding, achieving faster response speed, improving user experience, and meeting the application requirements of high-frequency and large-volume decoding tasks.
[0031] In some preferred embodiments, the calibration number is set to 4 to 8 in step S2. For example, in one embodiment, the calibration number is set to 6 in step S2. That is, in step S2, after acquiring the sampling image, 6 calibration images are acquired in sequence, and each calibration image is compared with the sampling image, and the average value and standard deviation of the difference between the calibration image and the sampling image are calculated, and the sampling threshold is calculated based on the average value and standard deviation. Wherein, the sampling threshold = average value + 10 × standard deviation.
[0032] Furthermore, in step S6, the time is set to 0.5 seconds to 3 seconds. For example, in one embodiment, the time is set to 1 second in step S6. When the code reader determines that the image has changed, the sensor parameters, lighting parameters and decoding library parameters in the trigger state are configured. At this time, if the user triggers the decoding operation within 1 second, the current image is directly acquired and decoded, and the decoding result is output after the decoding is completed.
[0033] According to a second aspect of the present invention, a code reader is provided, wherein the code reader is used to execute the above-mentioned image detection-based pre-decoding method.
[0034] According to a third aspect of the present invention, there is provided a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the pre-decoding method based on image detection as described above is implemented.
[0035] In the pre-decoding method based on image detection of the present invention, in the standby state, a sampling image and a calibration image are obtained, the calibration image and the sampling image are compared, and a sampling threshold is calculated; a new image is obtained, the new image is compared with the sampling image, and a new image threshold is calculated; the new image threshold is compared with the sampling threshold, and whether the image has changed is judged by the comparison result between the new image threshold and the sampling threshold, and the user's decoding intention is predicted by the image change, so as to initialize parameters in advance, thereby shortening the waiting time between the user pressing the decoding button and the start of decoding, achieving faster response speed, improving user experience, and meeting the application requirements of high-frequency and large-volume decoding tasks.
[0036] The present invention has been described by the above-mentioned relevant embodiments, however, the above-mentioned embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, changes and modifications made without departing from the spirit and scope of the present invention are all within the scope of patent protection of the present invention.
Claims
1. A pre-decoding method based on image detection, characterized in that: The image detection-based pre-decoding method comprises the following steps: Step S1: Entering standby mode; Step S2: Acquire a sampling image, sequentially acquire a set number of calibration images, and compare each calibration image with the sampling image, calculate the average value and standard deviation of the difference between the calibration image and the sampling image, and calculate the sampling threshold according to the average value and standard deviation; wherein the sampling threshold = average value + 10 × standard deviation; Step S3: Obtain new images, and compare each new image with the sampled image, calculate the average value of the image differences, then the new image threshold = the average value of the difference between the new image and the sampled image; and compare the new image threshold with the sampled threshold; Step S4: Determine whether the new image threshold is greater than the sampling threshold for three consecutive times. If so, execute step S5; if not, return to step S1; Step S5: configure the sensor parameters, lighting parameters and decoding library parameters under the trigger state, and clear all acquired images, and then execute step S6; Step S6: Determine whether the user triggers the decoding operation within the set time; if not, execute step S7; if triggered, execute step S8; Step S7: Restore the sensor parameters, lighting parameters and decoding library parameters in the standby state, and then return to step S1; Step S8: Acquire the current image and decode it, and output the decoding result after decoding is completed; then return to step S1.
2. The pre-decoding method based on image detection according to claim 1, characterized in that: In step S2, the calibration number is set to 4-8.
3. The pre-decoding method based on image detection according to claim 1, characterized in that: In step S2, the difference between each calibration image and the sampled image is ; Wherein, each pixel difference value is obtained by subtracting the corresponding pixel value of the calibration image from the sampled image, and n is the total number of pixels.
4. The image detection-based pre-decoding method according to claim 3, characterized in that: In step S2, the difference between each calibration image and the sampled image is .
5. The pre-decoding method based on image detection according to claim 1, characterized in that: In step S6, the time is set to 0.5 seconds to 3 seconds.
6. A code reader, characterized in that: The code reader is used to execute the image detection-based pre-decoding method described in any one of claims 1-5.
7. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image detection-based pre-decoding method described in any one of claims 1 to 5 is implemented.