Two-dimensional code generation and application method and device, equipment and storage medium
By configuring the UTF-8 encoding method to generate QR codes and perform data encoding, the problem of garbled codes when identifying QR codes in vehicle diagnosis is solved, ensuring data accuracy and user experience.
Patent Information
- Application Number
- CN202411034909.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-25
AI Technical Summary
During the vehicle diagnosis process, when the QR code generated using the zxing library contains Chinese information, because the default encoding set is not supported, the character encoding method during recognition is inconsistent with the generated encoding method, resulting in garbled codes, which affects data accuracy and vehicle diagnosis functions. .
By obtaining the text information of the vehicle to be detected, configure the target text encoding method as UTF-8, and call the zxing library to generate a QR code to ensure that the correct encoding method is used for data encoding during recognition and solve the garbled code problem.
It effectively solves the problem of garbled text display that cannot be supported by the default encoding set of the zxing library, ensures the accuracy of data during QR code recognition, and improves user experience.
Smart Images

Figure CN118839712A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle diagnostic technology, and in particular to a two-dimensional code generation and application method, device, equipment and storage medium. Background Art
[0002] When using diagnostic equipment to diagnose a vehicle, certain data information needs to be stored as a QR code. The device's camera can then be used to scan or recognize the QR code image when needed. However, when generating a QR code, the zxing library generates the code based on the encoding of the input text. If no encoding is input, a default encoding is used. When the QR code contains Chinese characters, the returned string will be garbled when the character encoding used for recognition is inconsistent with the encoding used to generate the QR code. This can cause incorrect data information and lead to malfunctioning vehicle diagnostics. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a QR code generation and application method, device, equipment and storage medium, which can effectively solve the problem of garbled text display that is not supported by the default encoding set of the zxing library, ensure the accuracy of the data obtained when recognizing the QR code, thereby facilitating users and improving the user experience. The specific solution is as follows:
[0004] In a first aspect, the present application provides a QR code generation and application method, which is applied to the Android system, comprising:
[0005] In a process of performing vehicle diagnosis on a vehicle to be detected based on a diagnostic device, obtaining text information corresponding to the vehicle to be detected;
[0006] Performing a corresponding text encoding configuration operation on the text information to obtain a corresponding target text encoding;
[0007] By calling the zxing library and using the target text encoding method and the text information to perform a corresponding QR code generation operation, a target QR code image corresponding to the vehicle to be detected is obtained;
[0008] When the target QR code image is recognized based on the zxing library, corresponding data encoding is performed according to the obtained QR code recognition result to obtain the corresponding target text and complete the corresponding vehicle diagnostic operation.
[0009] Optionally, performing corresponding data encoding according to the obtained QR code recognition result to obtain the corresponding target text includes:
[0010] When the zxing library successfully recognizes the code, a corresponding QR code recognition result is obtained; wherein the QR code recognition result includes corresponding text data to be processed;
[0011] The corresponding target text encoding method is obtained based on the two-dimensional code recognition result, and corresponding data encoding is performed based on the text data to be processed and the target text encoding method to obtain the corresponding target text.
[0012] Optionally, obtaining the corresponding target text encoding method based on the QR code recognition result includes:
[0013] The encoding method of the text data to be processed is determined based on the two-dimensional code recognition result to obtain the target text encoding method.
[0014] Optionally, performing a corresponding text encoding configuration operation on the text information to obtain a corresponding target text encoding includes:
[0015] For the text information, the corresponding text encoding configuration operation is completed by specifying the zxing character encoding set UTF-8 to obtain the corresponding target text encoding.
[0016] Optionally, after obtaining the text information corresponding to the vehicle to be detected, the method further includes:
[0017] Based on the text information, corresponding QR code generation rules are configured to obtain target QR code generation rules; wherein the target QR code generation rules include corresponding QR code size and fault tolerance level.
[0018] In a second aspect, the present application provides a QR code generation and application device, which is applied to the Android system, including:
[0019] An information acquisition module, configured to acquire text information corresponding to a vehicle to be detected during vehicle diagnosis by a diagnostic device;
[0020] An encoding mode configuration module is used to perform a corresponding text encoding mode configuration operation on the text information to obtain a corresponding target text encoding mode;
[0021] A QR code generation module is used to perform a corresponding QR code generation operation by calling the zxing library and using the target text encoding method and the text information to obtain a target QR code image corresponding to the vehicle to be detected;
[0022] The QR code recognition module is used to perform corresponding data encoding according to the obtained QR code recognition result when recognizing the target QR code image based on the zxing library to obtain the corresponding target text and complete the corresponding vehicle diagnostic operation.
[0023] Optionally, the QR code recognition module includes:
[0024] A QR code recognition result acquisition unit, configured to obtain a corresponding QR code recognition result when the zxing library successfully recognizes the code; wherein the QR code recognition result includes corresponding text data to be processed;
[0025] The data encoding unit is used to obtain the corresponding target text encoding method based on the two-dimensional code recognition result, and perform corresponding data encoding based on the text data to be processed and the target text encoding method to obtain the corresponding target text.
[0026] In a third aspect, the present application provides an electronic device, comprising:
[0027] Memory, used to store computer programs;
[0028] The processor is used to execute the computer program to implement the steps of the aforementioned two-dimensional code generation and application method.
[0029] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the steps of the aforementioned QR code generation and application method.
[0030] As can be seen, in this application, during the process of performing vehicle diagnosis on a vehicle to be detected based on a diagnostic device, text information corresponding to the vehicle to be detected is obtained; a corresponding text encoding method configuration operation is performed on the text information to obtain a corresponding target text encoding method; a corresponding QR code generation operation is performed by calling the zxing library and using the target text encoding method and the text information to obtain a target QR code image corresponding to the vehicle to be detected; when the target QR code image is recognized based on the zxing library, corresponding data encoding is performed based on the obtained QR code recognition result to obtain the corresponding target text, and the corresponding vehicle diagnostic operation is completed. That is, in this application, the corresponding target text encoding method is specified when generating a QR code image to obtain the corresponding target QR code image. When the target QR code image is then recognized, if the recognition is successful, the correct encoding can be performed based on the obtained recognition result. In this way, the problem of garbled text display that is not supported by the default encoding set of the zxing library can be effectively solved, and the accuracy of the data obtained when recognizing the QR code is guaranteed, thereby facilitating users and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0032] Figure 1 A flow chart of a QR code generation and application method provided in this application;
[0033] Figure 2 A schematic diagram of the structure of a QR code generation and application device provided in this application;
[0034] Figure 3 This is a structural diagram of an electronic device provided in this application. DETAILED DESCRIPTION
[0035] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0036] When using diagnostic equipment to diagnose the vehicle being tested, it is necessary to generate a QR code for certain data information for storage. Later, when necessary, the camera provided by the device can be used to scan or identify the QR code image. However, when generating the QR code, the zxing library will generate the QR code according to the encoding method of the incoming text. If no encoding method is incoming, the default encoding method will be used. When the information stored in the QR code contains Chinese, when it is recognized, the character encoding method used for recognition will be inconsistent with the encoding method used to generate the QR code, and garbled characters will appear, making the data information incorrect, and thus causing abnormal vehicle diagnostic functions. To this end, the present application provides a QR code generation and application solution, which can effectively solve the problem of garbled text display that is not supported by the default encoding set of the zxing library, and ensure the accuracy of the data obtained when identifying the QR code, thereby facilitating users and improving user experience.
[0037] See also Figure 1 As shown, the embodiment of the present invention discloses a QR code generation and application method, which is applied to the Android system, including:
[0038] Step S11 : in the process of performing vehicle diagnosis on a vehicle to be detected based on a diagnostic device, obtaining text information corresponding to the vehicle to be detected.
[0039] Specifically, in this embodiment, when using the diagnostic device to diagnose the vehicle to be inspected, it is necessary to generate a QR code for storage of certain data information, and when in use, the camera carried by the diagnostic device itself is used to scan or identify the corresponding QR code image to obtain information. Therefore, in order to generate the corresponding QR code, it is necessary to first obtain the text information to be stored. Afterwards, the QR code size and fault tolerance level are set according to the text content. That is to say, in this embodiment, after obtaining the text information corresponding to the vehicle to be inspected, it can also specifically include: configuring the corresponding QR code generation rules based on the text information to obtain the target QR code generation rules; wherein, the target QR code generation rules include the corresponding QR code size and fault tolerance level.
[0040] Step S12: performing a corresponding text encoding configuration operation on the text information to obtain a corresponding target text encoding.
[0041] It should be understood that in order to avoid the phenomenon of garbled text when recognizing QR codes, a corresponding text encoding method is required. That is, in this embodiment, the corresponding text encoding method configuration operation is performed on the text information to obtain the corresponding target text encoding method, which can specifically include: for the text information, the corresponding text encoding method configuration operation is completed by specifying the zxing character encoding set UTF-8 to obtain the corresponding target text encoding method. It can be seen that in this embodiment, the specified text encoding method is encoding using the character encoding set UTF-8.
[0042] Step S13: Calling the zxing library and performing a corresponding QR code generation operation using the target text encoding method and the text information to obtain a target QR code image corresponding to the vehicle to be detected.
[0043] Specifically, in this embodiment, after obtaining the text information to be stored and configuring the corresponding target QR code generation rules and the target text encoding method, QR code generation can be performed based on the text information, the target QR code generation rules and the target text encoding method to obtain a target QR code image corresponding to the vehicle to be detected, so as to save the text information in the target QR code image.
[0044] Step S14: When the target QR code image is recognized based on the zxing library, corresponding data encoding is performed according to the obtained QR code recognition result to obtain the corresponding target text and complete the corresponding vehicle diagnostic operation.
[0045] It should be understood that when performing QR code recognition, it is necessary to use the zxing library to identify the target QR code image, and after success, obtain the encoding method of the text information stored in the target QR code image through analysis to obtain the final required text content. That is to say, in this embodiment, the corresponding data encoding is performed according to the obtained QR code recognition result to obtain the corresponding target text, which can specifically include: when the zxing library recognizes successfully, the corresponding QR code recognition result is obtained; wherein, the QR code recognition result includes the corresponding text data to be processed; based on the QR code recognition result, the corresponding target text encoding method is obtained, and based on the text data to be processed and the target text encoding method, the corresponding data encoding is performed to obtain the corresponding target text. wherein, the acquisition of the corresponding target text encoding method based on the QR code recognition result can specifically include: judging the encoding method of the text data to be processed based on the QR code recognition result to obtain the target text encoding method.
[0046] It is understandable that if the recognition fails, the subsequent operations are terminated, and when the recognition fails a certain number of times within a certain period of time, the process may jump back to the step of generating a QR code and issue a pre-alarm error to provide a prompt.
[0047] In summary, this embodiment specifies the UTF-8 character encoding when generating a QR code, avoiding the default encoding used by the zxing library. After successfully recognizing the QR code, the original text data recognized by zxing is obtained, the encoding method of the original data is determined, and the correct encoding method is used to encode the original data into the recognized text. This solves the problem of garbled text displayed when the default zxing encoding set is not supported, providing convenience to users and improving the user experience.
[0048] In addition, in a specific implementation, the open source library zxing can be modified to encode the original text data according to the character encoding method of the original QR code data when assigning the result string, so as to solve the problem of garbled text display that is not supported by the default encoding set of zxing, thereby improving the user experience.
[0049] It can be seen that in the embodiment of the present application, in the process of performing vehicle diagnosis on the vehicle to be detected based on the diagnostic device, text information corresponding to the vehicle to be detected is obtained; a corresponding text encoding method configuration operation is performed on the text information to obtain a corresponding target text encoding method; by calling the zxing library and using the target text encoding method and the text information, a corresponding QR code generation operation is performed to obtain a target QR code image corresponding to the vehicle to be detected; when the target QR code image is recognized based on the zxing library, corresponding data encoding is performed according to the obtained QR code recognition result to obtain the corresponding target text, and the corresponding vehicle diagnostic operation is completed. That is, in the present application, the corresponding target text encoding method is specified when generating the QR code image to obtain the corresponding target QR code image. Afterwards, when the target QR code image is recognized, if the recognition is successful, the correct encoding can be performed based on the obtained recognition result. In this way, the problem of garbled text display that is not supported by the default encoding set of the zxing library can be effectively solved, and the accuracy of the data obtained when recognizing the QR code is guaranteed, thereby facilitating users and improving the user experience.
[0050] See also Figure 2 As shown, the embodiment of the present application also discloses a QR code generation and application device, which is applied to the Android system, including:
[0051] The information acquisition module 11 is used to acquire text information corresponding to the vehicle to be detected during the process of performing vehicle diagnosis on the vehicle to be detected based on the diagnostic equipment;
[0052] The encoding mode configuration module 12 is used to perform a corresponding text encoding mode configuration operation on the text information to obtain a corresponding target text encoding mode;
[0053] A QR code generation module 13 is configured to perform a corresponding QR code generation operation by calling the zxing library and using the target text encoding method and the text information to obtain a target QR code image corresponding to the vehicle to be detected;
[0054] The QR code recognition module 14 is used to perform corresponding data encoding according to the obtained QR code recognition result when recognizing the target QR code image based on the zxing library to obtain the corresponding target text and complete the corresponding vehicle diagnosis operation.
[0055] Among them, for more specific working processes of the above modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0056] As can be seen from this, in this application, in the process of performing vehicle diagnosis on a vehicle to be detected based on a diagnostic device, text information corresponding to the vehicle to be detected is obtained; a corresponding text encoding method configuration operation is performed on the text information to obtain a corresponding target text encoding method; by calling the zxing library and using the target text encoding method and the text information to perform a corresponding QR code generation operation to obtain a target QR code image corresponding to the vehicle to be detected; when the target QR code image is recognized based on the zxing library, corresponding data encoding is performed based on the obtained QR code recognition result to obtain the corresponding target text, and the corresponding vehicle diagnostic operation is completed. That is, in this application, the corresponding target text encoding method is specified when generating a QR code image to obtain the corresponding target QR code image. Afterwards, when the target QR code image is recognized, if the recognition is successful, the correct encoding can be performed based on the obtained recognition result. In this way, the problem of garbled text display that is not supported by the default encoding set of the zxing library can be effectively solved, and the accuracy of the data obtained when recognizing the QR code is guaranteed, thereby facilitating users and improving the user experience.
[0057] In some specific embodiments, the two-dimensional code recognition module 14 includes:
[0058] A QR code recognition result acquisition unit, configured to obtain a corresponding QR code recognition result when the zxing library successfully recognizes the code; wherein the QR code recognition result includes corresponding text data to be processed;
[0059] The data encoding unit is used to obtain the corresponding target text encoding method based on the two-dimensional code recognition result, and perform corresponding data encoding based on the text data to be processed and the target text encoding method to obtain the corresponding target text.
[0060] In some specific embodiments, the data encoding unit may specifically include:
[0061] The text encoding method acquisition subunit is used to determine the encoding method of the text data to be processed based on the two-dimensional code recognition result to obtain the target text encoding method.
[0062] In some specific embodiments, the encoding mode configuration module 12 may specifically include:
[0063] The text encoding mode configuration unit is used to complete the corresponding text encoding mode configuration operation for the text information by specifying the zxing character encoding set UTF-8 to obtain the corresponding target text encoding mode.
[0064] In some specific embodiments, the QR code generation and application device may further include:
[0065] The QR code generation rule configuration unit is used to configure the corresponding QR code generation rule based on the text information to obtain the target QR code generation rule; wherein the target QR code generation rule includes the corresponding QR code size and fault tolerance level.
[0066] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.
[0067] Figure 3 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the QR code generation and application method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0068] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0069] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0070] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of implementing the QR code generation and application method disclosed in any of the aforementioned embodiments and executed by the electronic device 20, the computer program 222 may further include a computer program capable of implementing other specific tasks.
[0071] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed method for generating and applying a QR code is implemented. The specific steps of this method can be referred to the corresponding contents disclosed in the aforementioned embodiments and will not be repeated here.
[0072] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0073] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0074] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0075] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0076] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A two-dimensional code generation and application method, characterized in that: Applicable to Android system, including: In the process of performing vehicle diagnosis on the vehicle to be detected based on the diagnostic device, obtaining text information corresponding to the vehicle to be detected; Performing a corresponding text encoding configuration operation on the text information to obtain a corresponding target text encoding; By calling the zxing library and using the target text encoding method and the text information to perform a corresponding two-dimensional code generation operation, a target two-dimensional code image corresponding to the vehicle to be detected is obtained; When the target two-dimensional code image is recognized based on the zxing library, corresponding data encoding is performed according to the obtained two-dimensional code recognition result to obtain the corresponding target text and complete the corresponding vehicle diagnosis operation.
2. The two-dimensional code generation and application method according to claim 1, characterized in that: The corresponding data encoding is performed according to the obtained two-dimensional code recognition result to obtain the corresponding target text, including: When the zxing library recognizes successfully, a corresponding two-dimensional code recognition result is obtained; wherein the two-dimensional code recognition result includes corresponding text data to be processed; The corresponding target text encoding method is obtained based on the two-dimensional code recognition result, and corresponding data encoding is performed based on the text data to be processed and the target text encoding method to obtain the corresponding target text.
3. The two-dimensional code generation and application method according to claim 2, characterized in that: The obtaining the corresponding target text encoding method based on the two-dimensional code recognition result includes: The encoding method of the text data to be processed is determined based on the two-dimensional code recognition result to obtain the target text encoding method.
4. The two-dimensional code generation and application method according to claim 1, characterized in that: The performing a corresponding text encoding configuration operation on the text information to obtain a corresponding target text encoding method includes: For the text information, the corresponding text encoding configuration operation is completed by specifying the zxing character encoding set UTF-8 to obtain the corresponding target text encoding.
5. The two-dimensional code generation and application method according to claim 1, characterized in that: After acquiring the text information corresponding to the vehicle to be detected, the method further includes: Based on the text information, corresponding two-dimensional code generation rules are configured to obtain target two-dimensional code generation rules; wherein the target two-dimensional code generation rules include corresponding two-dimensional code size and fault tolerance level.
6. A two-dimensional code generation and application device, characterized in that: Applicable to Android system, including: An information acquisition module, used for acquiring text information corresponding to the vehicle to be detected during the process of performing vehicle diagnosis on the vehicle to be detected based on the diagnostic device; An encoding mode configuration module is used to perform a corresponding text encoding mode configuration operation on the text information to obtain a corresponding target text encoding mode; A QR code generation module is used to perform a corresponding QR code generation operation by calling a zxing library and using the target text encoding method and the text information to obtain a target QR code image corresponding to the vehicle to be detected; The QR code recognition module is used to perform corresponding data encoding according to the obtained QR code recognition result when recognizing the target QR code image based on the zxing library, so as to obtain the corresponding target text and complete the corresponding vehicle diagnostic operation.
7. The two-dimensional code generation and application device according to claim 6, characterized in that: The two-dimensional code recognition module includes: A two-dimensional code recognition result acquisition unit, used for obtaining a corresponding two-dimensional code recognition result when the zxing library recognizes successfully; wherein the two-dimensional code recognition result includes corresponding text data to be processed; A data encoding unit is used to obtain the corresponding target text encoding method based on the two-dimensional code recognition result, and perform corresponding data encoding based on the text data to be processed and the target text encoding method to obtain the corresponding target text.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, used to execute the computer program to implement the two-dimensional code generation and application method as described in any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the two-dimensional code generation and application method as described in any one of claims 1 to 5.
