Bar code identification method based on WeChat applet

By using the camara component in the WeChat applet to continuously scan the code and perform business logic verification, the problems of low barcode recognition efficiency and inaccurate results in the existing technology are solved, and efficient and accurate barcode recognition and verification are achieved.

CN119721089APending Publication Date: 2025-03-28LUZHOU LAOJIAO CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411785504.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, barcode identification efficiency is low, and the scanning results are inaccurate, especially when multiple barcodes are processed, the ambient light is unstable, and the barcode is prone to damage or contamination.

Method used

The barcode recognition method based on WeChat applet is adopted, and the camera camera is called by calling the camara component of WeChat applet, and the code is continuously scanned and multiple barcode images are collected. Listen to each frame of barcode image, parse and determine whether it complies with encoding rules, call the background interface asynchronously for business logic verification, and use the multi-level cache layer and Guava-retrying components to improve efficiency and reliability.

Benefits of technology

It realizes continuous and fast code scanning, improves the efficiency of code scanning, and improves the accuracy of business logic verification and system performance through multi-level cache layer and retry mechanism.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention mainly relates to the technical field of barcode recognition. The invention provides a WeChat applet-based bar code recognition method, and solves the problems of low bar code recognition efficiency and inaccurate code scanning result in the prior art. The core of the method comprises the following steps: calling a camera assembly of a WeChat applet to call a camera, continuously scanning codes, and collecting images of a plurality of bar codes; monitoring each frame of bar code image collected by a camera, extracting each frame of bar code image according to a set period, analyzing each frame of bar code image, judging whether the current bar code accords with a set coding rule or not according to an analysis result, and if the current bar code accords with the set coding rule, executing the step 2; according to the method, the business logic verification rule stored in the background interface cache library is called to perform business logic verification on the bar code, and the business logic verification result is cached through the Pinia state library, so that the bar code is continuously scanned, the next code scanning action is executed in the state that the bar code result is not returned, and the code scanning efficiency can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the field of barcode recognition technology, and in particular to a barcode recognition method based on WeChat applet. Background Art

[0002] At present, the industry's recognition of barcodes such as QR codes and barcodes is mainly for static graphics, and when recognizing static images, it depends on the light source, image clarity and the stability of the viewfinder; and after recognizing a single image, it is necessary to block and wait for the recognition result, and when recognizing the current target, if you need to obtain historical recognition results, you need to re-execute the code scanning operation.

[0003] In addition, the scanning results involve a large amount of data such as products, logistics links, and supply relationships. In the process of verifying the scanning results, a large amount of logical judgment is required. With billions of data volumes, facing high-traffic and high-concurrency requests, and relying on traditional services that interact with a single database, the efficiency and accuracy of scanning result verification need to be improved.

[0004] In actual barcode scanning scenarios, there are often many physical objects to be scanned, which are large in size and inconvenient to move. Therefore, users need to scan the barcodes quickly in batches and perform logical checks. In some environments, barcodes are easily damaged and contaminated, and the light source is unstable, requiring users to repeatedly identify the barcodes diagonally. Both the scanning efficiency and the accuracy of the recognition results are relatively poor. Summary of the invention

[0005] Technical Problems to be Solved by the Invention

[0006] A barcode recognition method based on WeChat applet is provided to solve the problems of low barcode recognition efficiency and inaccurate scanning results in the prior art.

[0007] The technical solution adopted by the present invention to solve the above technical problems

[0008] The barcode recognition method based on WeChat applet includes:

[0009] Call the camara component of the WeChat applet to wake up the camera, scan the barcode continuously, and collect images of multiple barcodes;

[0010] Monitor each barcode image frame collected by the camera, extract each barcode image frame according to the set period, parse each barcode image frame, and determine whether the current barcode meets the set encoding rules based on the analysis results. If it meets the set encoding rules, call the business logic verification rules stored in the background interface cache library to perform business logic verification on the barcode, and cache the business logic verification results through the Pinia state library; if the barcode does not meet the set encoding rules, the barcode is determined to be an abnormal code and no business logic verification is performed.

[0011] Furthermore, the cache library includes a JVM cache layer, a Redis cache layer and a database layer;

[0012] The JVM cache layer is used to cache data in business logic data whose data volume is less than a set value and which changes infrequently;

[0013] The Redis cache layer is used to cache data with a high probability of being used in business logic verification;

[0014] The database layer is used to store all the data required for business logic verification;

[0015] When performing business logic verification, the data in the JVM cache layer, Redis cache layer, and database layer are queried in sequence to perform business logic verification.

[0016] Furthermore, the method also includes, when calling the business logic verification rules stored in the background interface cache library to perform business logic verification on the barcode, if a query fails, retrying the query through the Guava-retrying configuration.

[0017] Further, the retry query includes:

[0018] Retry strategy: any of fixed interval retry, exponential backoff strategy, or result-based retry;

[0019] Retry time: when a specific exception occurs;

[0020] Retry stop condition: When the number of retries reaches the maximum number of retries or the maximum waiting time, the retry stops;

[0021] Monitoring mechanism: log the query retry process.

[0022] Furthermore, the method also includes, when a damaged barcode appears, taking a photo of the damaged barcode, and calling the WeChat scan API to scan the taken photo of the damaged barcode.

[0023] Furthermore, the method also includes: connecting the WeChat applet and the barcode scanning gun based on Bluetooth communication.

[0024] Furthermore, the method also includes, if there are multiple business logics to be verified for a barcode when verifying the business logic of the barcode, decomposing the business logic based on Kafka and the thread pool, and verifying each single business logic after the decomposition.

[0025] Beneficial effects of the present invention

[0026] (1) The barcode recognition method based on WeChat applet described in the present invention invokes the camara component of WeChat applet to wake up the camera, continuously scan the barcode, and collect images of multiple barcodes; monitors each frame of barcode image collected by the camera, and extracts each frame of barcode image according to a set period, parses each frame of barcode image, and determines whether it complies with the encoding rules based on the parsing result. If it does not comply with the encoding rules, it prompts that the barcode is abnormal. If it complies with the encoding rules, it asynchronously calls the business logic verification rules stored in the background interface to perform business logic verification, so as to realize continuous scanning of barcodes. When the barcode result is not returned, the next scanning action is executed, which can effectively improve the scanning efficiency.

[0027] (2) Business logic verification rules are stored in a multi-level cache layer. By searching for business logic rules in different levels of cache, the number of database queries can be reduced, thereby improving system performance. Moreover, if a cache layer fails, caches or databases in other layers can still provide data, ensuring system availability. In addition, Redis can be easily expanded to accommodate a large number of concurrent requests, and JVM cache can provide near real-time responses.

[0028] (3) Interface retry technology is used in the process of verifying business logic. The Guava-retrying component is used to formulate a retry strategy and retry exceptions in specific states, which can improve the success rate of business logic number verification rules.

[0029] (4) If there are multiple business logics when performing business logic verification, the business logic can be decomposed based on Kafka and thread pool, and then a single business logic can be verified, so as not to block the main process business and improve the efficiency of barcode verification. DETAILED DESCRIPTION

[0030] Call the camara component of the WeChat applet to wake up the camera, scan codes continuously, and collect images of multiple barcodes.

[0031] Preferably, when calling the camara component to scan the barcode, for some contaminated code numbers or when the code cannot be scanned in time due to various reasons, take a photo of the barcode and use the WeChat scan API to scan the code to compensate for the abnormal scene.

[0032] In addition, the barcode scanner and the mini program are connected via Bluetooth, using Bluetooth low energy technology (BLE) to achieve the interconnection between the mini program and the barcode scanner hardware. When necessary, the user can call the Bluetooth barcode scanner to scan the code.

[0033] During the scanning process of the camera component, you can call the flash property of the camera component to automatically turn on the flash when the light is insufficient, thereby improving the scanning success rate.

[0034] During the scanning process, each barcode image frame collected by the camera is monitored, and each barcode image frame is extracted according to the set period. Each barcode image frame is analyzed, and whether it conforms to the encoding rules is determined according to the analysis result. If it does not conform, it will prompt that the barcode is abnormal. If it conforms to the encoding rules, the business logic verification rules stored in the background interface are asynchronously called to perform business logic verification, and the business logic verification results are cached through the Pinia state library.

[0035] The business logic verification rules are stored in a multi-level cache layer library, which includes a JVM cache layer, a Redis cache layer and a database layer. The JVM cache layer is used to cache data in the business logic data whose data volume is less than the set value and which changes infrequently, such as enterprise parameters, etc.; the Redis cache layer is used to cache data with a high probability of being used in business logic verification, such as customer objects, product objects, in-and-out warehouse objects, etc.; the database layer is used to store the full amount of data required for business logic verification.

[0036] The process of business logic verification in the multi-level cache layer specifically includes: first query the local JVM cache; if it hits, return the data directly, which is the fastest; if it misses, enter the Redis cache to query the Redis cache, if it hits, return the data and update the local JVM cache (usually through asynchronous refresh); if it misses, enter the database layer for query, and finally obtain the business logic verification result from the database layer, return the business logic verification result to the Pinia state library, and write it to the Redis and JVM cache at the same time, so that future queries will be faster.

[0037] When calling the backend interface to query the complete information of the barcode for business logic verification, if there is a query failure, retry the query through Guava-retrying configuration. The retry query includes: retry strategy: can be set to any of fixed interval retry, exponential backoff strategy or result-based retry; retry time: when a specific exception occurs; retry stop condition: stop retrying when the number of retries reaches the maximum number of retries or the maximum waiting time; monitoring mechanism: log the query retry process.

[0038] If there are multiple business logics to be verified for a single barcode during business logic verification, the business logic will be decomposed based on Kafka and thread pool, and each business logic will be verified separately.

Claims

1. A barcode recognition method based on WeChat applet, characterized in that: include: Call the camara component of the WeChat applet to wake up the camera, scan the barcode continuously, and collect images of multiple barcodes; Monitor each barcode image frame collected by the camera, extract each barcode image frame according to the set period, parse each barcode image frame, and determine whether the current barcode meets the set encoding rules based on the parsing results. If it meets the set encoding rules, call the business logic verification rules stored in the background interface cache library to perform business logic verification on the barcode, and cache the business logic verification results through the Pinia state library; If the barcode does not conform to the set encoding rules, the barcode will be judged as an abnormal code and no business logic verification will be performed.

2. The barcode recognition method based on WeChat applet according to claim 1, characterized in that: The cache library includes a JVM cache layer, a Redis cache layer and a database layer; The JVM cache layer is used to cache data in business logic data whose data volume is less than a set value and which changes infrequently; The Redis cache layer is used to cache data with a high probability of being used in business logic verification; The database layer is used to store all the data required for business logic verification; When performing business logic verification, the data in the JVM cache layer, Redis cache layer, and database layer are queried in sequence to perform business logic verification.

3. The barcode recognition method based on WeChat applet according to claim 2, characterized in that: The method also includes, when calling the business logic verification rules stored in the background interface cache library to perform business logic verification on the barcode, if a query fails, retrying the query through Guava-retrying configuration.

4. The barcode recognition method based on WeChat applet according to claim 3, characterized in that: The retry query includes: Retry strategy: any of fixed interval retry, exponential backoff strategy, or result-based retry; Retry time: when a specific exception occurs; Retry stop condition: When the number of retries reaches the maximum number of retries or the maximum waiting time, the retry stops; Monitoring mechanism: log the query retry process.

5. The barcode recognition method based on WeChat applet according to any one of claims 1 to 4, characterized in that: The method also includes, when a damaged barcode appears, taking a photo of the damaged barcode, and calling the WeChat scan API to scan the taken photo of the damaged barcode.

6. The barcode recognition method based on WeChat applet according to any one of claims 1 to 4, characterized in that: The method also includes: connecting the WeChat applet and the barcode scanning gun based on Bluetooth communication.

7. The barcode recognition method based on WeChat applet according to any one of claims 1 to 4, characterized in that: The method also includes, if there are multiple business logics to be verified for a barcode when verifying the business logic of the barcode, decomposing the business logic based on Kafka and the thread pool, and verifying each of the decomposed business logics respectively.