A two-dimensional code recognition method and device

By realizing the key event processing of virtual key values ​​on Android devices, the information in the QR code is recognized, which solves the problem that the device cannot recognize multiple languages ​​in the QR code, and realizes the recognition ability of multiple languages.

CN114299521BActive Publication Date: 2025-03-11FEITIAN TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111678577.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-03-11
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

Currently, Android devices that can connect to external code scan guns cannot recognize the multi-language languages ​​in the QR code.

Method used

Obtain the virtual key value through the key press event to determine whether it is a preset operation. If so, perform the corresponding steps to identify the information in the QR code. The specific steps include determining whether the virtual key value falls into the target value range, cumulative number of targets to convert them into target characters, and determining the end of the QR code recognition based on the end character.

Benefits of technology

It realizes the recognition of letters, numbers, symbols and multiple languages ​​in the QR code by Android devices that can connect to the QR code, solving the problem that the device cannot recognize multiple languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299521B_ABST
    Figure CN114299521B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a two-dimensional code recognition method and device, wherein the method comprises: obtaining a virtual key value through a key event, determining whether the key event is a preset operation, and if so, determining whether the virtual key value falls within a target value range, and if so, continuing to determine whether the current cumulative number of virtual key values ​​that fall within the target value range reaches the target number, and if so, converting the target number of virtual key values ​​into target characters and clearing the current cumulative number of virtual key values ​​that fall within the target value range, and continuing to obtain virtual key values; if the virtual key value does not fall within the target value range, determining whether the virtual key value is an end character, and if not, converting the virtual key value into a non-target character, and if so, determining that the two-dimensional code recognition is completed, and generating a two-dimensional code recognition result according to all the target characters and non-target characters obtained by the conversion. The method can realize the recognition of letters, numbers, symbols and multiple languages ​​in two-dimensional codes by an Android device that can be externally connected to a barcode scanner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a two-dimensional code recognition method and device. Background Art

[0002] A QR code is a method of recording data symbol information in a certain pattern on a plane distributed in black and white geometric figures. It is widely popular due to its advantages such as large information capacity, wide coding range, small space occupation, low cost and easy production.

[0003] A QR code can represent various types of data, including but not limited to letters, numbers, symbols, and multiple languages. After scanning the QR code, the device can obtain the information contained therein.

[0004] Currently, Android devices that can be connected to an external barcode scanner cannot recognize multiple languages ​​in QR codes. Summary of the invention

[0005] The present application embodiment provides a two-dimensional code recognition method and device. The technical solution is as follows:

[0006] In a first aspect, an embodiment of the present application provides a two-dimensional code recognition method, which is applied to an Android device that can be connected to an external barcode scanner, and includes:

[0007] Step S1: obtaining a virtual key value through a key event, and determining whether the key event is a preset operation, if so, executing step S2, otherwise, continuing to obtain a virtual key value through the key event;

[0008] Step S2: Determine whether the virtual key value falls within the target value range, if so, execute step S3, otherwise, execute step S5;

[0009] Step S3: Determine whether the current cumulative number of virtual key values ​​falling within the target value range reaches the target number, if so, execute step S4, if not, return to step S1;

[0010] Step S4: converting the target number of virtual key values ​​into target characters, and clearing the current cumulative number of virtual key values ​​falling within the target value range, and returning to step S1;

[0011] Step S5: Determine whether the virtual key value is an end character, if not, execute step S6, if yes, determine that the QR code recognition is finished, and execute step S7;

[0012] Step S6: convert the virtual key value into a non-target character, wherein the non-target character includes letters, numbers and symbols, and return to step S1;

[0013] Step S7: Generate a two-dimensional code recognition result according to all target characters and non-target characters obtained by conversion.

[0014] In a second aspect, an embodiment of the present application provides a two-dimensional code recognition device, which is applied to an Android device that can be connected to an external barcode scanner, including:

[0015] A key value acquisition module is used to acquire a virtual key value through a key event, and determine whether the key event is a preset operation. If so, the key value determination module is triggered; otherwise, the virtual key value is continuously acquired through the key event;

[0016] A key value judgment module, used to judge whether the virtual key value falls into the target value range, if so, trigger the first judgment module, otherwise, trigger the second judgment module;

[0017] A first judgment module is used to judge whether the current cumulative number of virtual key values ​​falling into the target value range reaches the target number, and if so, trigger the first conversion module; if not, trigger the key value acquisition module;

[0018] A first conversion module, configured to convert the target number of virtual key values ​​into target characters, and clear the number of virtual key values ​​currently accumulated within the target value range, to trigger a key value acquisition module;

[0019] A second judging module is used to judge whether the virtual key value is an end character, if not, trigger the second converting module, if not, trigger the recognition result generating module;

[0020] A second conversion module, used to convert the virtual key value into a non-target character, wherein the non-target character includes letters, numbers and symbols, and trigger a key value acquisition module;

[0021] The recognition result generation module is used to generate a QR code recognition result based on all target characters and non-target characters obtained by conversion.

[0022] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.

[0023] In a fourth aspect, an embodiment of the present application provides an Android device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the program.

[0024] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:

[0025] The QR code recognition method provided in the embodiment of the present application can enable an Android device that can be connected to an external barcode scanner to recognize letters, numbers, symbols and multiple languages ​​in a QR code. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 It is a flowchart of a two-dimensional code recognition method provided in an embodiment of the present application;

[0028] Figure 2 It is a flowchart of a two-dimensional code recognition method provided in an embodiment of the present application;

[0029] Figure 3 It is a structural schematic diagram of a two-dimensional code recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0031] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0032] In the description of the present application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0033] The following will be combined with the attached Figure 1 -Attached Figure 2 , the two-dimensional code recognition method provided in the embodiment of the present application is introduced in detail.

[0034] See also Figure 1 , which is a flow chart of a two-dimensional code recognition method provided in an embodiment of the present application.

[0035] like Figure 1 As shown, the method of the embodiment of the present application may include the following steps:

[0036] Step S1: obtain a virtual key value through a key event, and determine whether the key event is a preset operation. If so, execute step S2; otherwise, continue to obtain a virtual key value through the key event.

[0037] The QR code recognition method provided in this application is applied to an Android device that can be connected to an external barcode scanner.

[0038] The present application does not limit the content of the QR code image. For example, the QR code image may contain only one language information, or may contain multiple language information (such as Chinese + Japanese), letters, numbers, and symbols at the same time.

[0039] The preset operation in this application is specifically a press operation or a release operation, that is:

[0040] When the key event is a press operation, the virtual key value is processed; when the key event is a release operation, the virtual key value is not processed and the next virtual key value is obtained; or,

[0041] When the key event is a release operation, the virtual key value is processed; when the key event is a press operation, the virtual key value is not processed and the next virtual key value is obtained.

[0042] Step S2: Determine whether the virtual key value falls within the target value range, if so, execute step S3, otherwise, execute step S5.

[0043] The target value range is determined according to the value range of virtual key values ​​of different languages. For example, for Chinese information, the virtual key values ​​corresponding to all Chinese characters are between 144 and 153, and the target value range is 144-153 (including the endpoint values).

[0044] Step S3: Determine whether the current cumulative number of virtual key values ​​falling within the target value range has reached the target number. If so, execute step S4; if not, return to step S1.

[0045] Different languages ​​have different structures, and the target number depends on the language. For example, for Chinese information, one Chinese character corresponds to 5 virtual key values, and the target number is 5.

[0046] Step S4: convert the target number of virtual key values ​​into target characters, and clear the current cumulative number of virtual key values ​​that fall within the target value range, and return to step S1.

[0047] The target characters may be, for example, Chinese characters, Japanese characters, German characters, etc.

[0048] Step S5: Determine whether the virtual key value is an end character, if not, execute step S6, if yes, determine that the QR code recognition is completed, and execute step S7.

[0049] Step S6: convert the virtual key value into a non-target character, where the non-target character includes letters, numbers and symbols, and return to step S1.

[0050] When factory test machines and other equipment do not have strict requirements on the recognition results of certain information (such as English) in the QR code, the case status of non-target characters may not be considered.

[0051] Step S7: Generate a two-dimensional code recognition result according to all target characters and non-target characters obtained by conversion.

[0052] The QR code recognition method provided in the embodiment of the present application can enable an Android device that can be connected to an external barcode scanner to recognize letters, numbers, symbols and multiple languages ​​in a QR code.

[0053] See also Figure 2 , is a flow chart of a two-dimensional code recognition method provided in an embodiment of the present application. This embodiment provides a recognition process for a two-dimensional code containing letters, numbers, symbols and Chinese information.

[0054] like Figure 2 As shown, the recognition of the QR code containing Chinese information may include the following steps:

[0055] Step S1-1: Create a code scanning service and register the boot-up self-start broadcast component with the code scanning service.

[0056] Step S1-2: monitor the system broadcast and determine whether the power-on broadcast is monitored. If so, execute step S1-3; otherwise, continue to monitor the system broadcast.

[0057] Step S1-3: Start the code scanning service.

[0058] Step S1: obtain a virtual key value through a key event, and determine whether the key event is a preset operation. If so, execute step S2; otherwise, continue to obtain a virtual key value through the key event.

[0059] The preset operation in this embodiment is a pressing operation.

[0060] For example, the complete virtual key values ​​of a QR code containing only the Chinese message "I love programming" are as follows:

[0061] 146, 149, 145, 144, 149, 146, 153, 146, 147, 147, 147, 146, 149, 147, 148, 147, 145, 146, 148, 147, KEYCODE_NUM, KEYCODE_ENTER.

[0062] Through the key event (KeyEvent), one virtual key value is obtained at a time from all the above virtual key values ​​for judgment.

[0063] Step S2: Determine whether the virtual key value falls within the range of 144 to 153. If so, determine that the virtual key value is a virtual key value corresponding to the Chinese information and execute step S3; otherwise, execute step S5.

[0064] It is particularly noted that when the virtual key value is 144 or 153, it is a virtual key value corresponding to Chinese information.

[0065] In an optional embodiment, before step S2, the following steps may also be included:

[0066] Step S2': determine whether the virtual key value is KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT, if so, determine whether the uppercase state is turned on / off, and return to step S1, otherwise, execute step S2.

[0067] In an optional embodiment, the letters, symbols and certain languages ​​contained in the QR code may be case-sensitive. This step can make the recognition results of letters, symbols and other information more accurate by determining whether the keyboard is in uppercase.

[0068] If the virtual key value obtained this time is KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT, and KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT has not been obtained before, it is determined that the uppercase state is on; if KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT has been obtained multiple times before, the uppercase state is determined to be on / off based on the cumulative number of KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT obtained. For example, if KEYCODE_SHIFT_RIGHT is obtained once and KEYCODE_SHIFT_LEFT is obtained once, it is determined that the uppercase state is off. If KEYCODE_SHIFT_RIGHT is obtained twice, it is determined that the uppercase state is off. If KEYCODE_SHIFT_RIGHT is obtained once and KEYCODE_SHIFT_LEFT is obtained twice, it is determined that the uppercase state is off. If KEYCODE_SHIFT_RIGHT is obtained once and KEYCODE_SHIFT_LEFT is obtained twice, it is determined that the uppercase state is on.

[0069] After determining the uppercase state, continue to obtain the next virtual key value through the key event for judgment.

[0070] Step S3: Determine whether the current cumulative number of virtual key values ​​falling within the range of 144 to 153 has reached the target number. If so, execute step S4; if not, return to step S1.

[0071] For example, the target number is specifically 5.

[0072] For Chinese information, when the number of virtual key values ​​in the range of 144-153 reaches 5, a data conversion can be performed to obtain a Chinese character.

[0073] If the number of virtual key values ​​currently acquired in the range of 144-153 does not reach 5, the process returns to step S1 to continue acquiring the next virtual key value through a key event and making a judgment until the target number is reached.

[0074] Step S4: convert the target number of virtual key values ​​into target characters, and clear the number of virtual key values ​​currently falling within the range of 144 to 153, and return to step S1.

[0075] Specifically, step S4 may include:

[0076] Step S41: Obtain the hexadecimal number corresponding to the target number of virtual key values.

[0077] For the above QR code containing only Chinese information, the hexadecimal number corresponding to the virtual key values ​​146, 149, 145, 144, and 149 is 6211.

[0078] Step S42: Convert the hexadecimal number into Chinese characters, and clear the number of virtual key values ​​currently falling within the range of 144 to 153, and return to step S1.

[0079] For the above-mentioned QR code containing only Chinese information, after converting the hexadecimal number 6211 corresponding to "146, 149, 145, 144, 149" into Chinese characters, the number of virtual key values ​​currently acquired that fall within the range of 144-153 is cleared, and the next virtual key value is acquired for judgment.

[0080] Similarly, character conversion is performed on the virtual key values ​​"146, 153, 146, 147, 147", "147, 146, 149, 147, 148", and "147, 145, 146, 148, 147" respectively. After clearing the current cumulative number of virtual key values ​​falling within the range of 144-153, the next virtual key value is obtained through the key event for judgment.

[0081] In an alternative embodiment, when the Android device with an externally connectable barcode scanner has format requirements for Chinese characters, step S42 specifically includes:

[0082] Convert the hexadecimal number into Chinese characters in a specified format, clear the number of virtual key values currently accumulated within the range of 144 to 153, and return to step S1.

[0083] The specified formats include: UTF-8, GBK, GB2312, etc.

[0084] Step S5: Determine whether the virtual key value is an end character. If not, execute step S6. If so, determine that the QR code recognition is completed and execute step S7.

[0085] Specifically, step S5 includes:

[0086] Step S51: Determine whether the virtual key value is an end character. If so, execute step S52. If not, execute step S6.

[0087] Step S52: Determine whether the virtual key value is KEYCODE_NUM. If so, return to step S1. Otherwise, determine that the virtual key value is KEYCODE_ENTER, the QR code recognition is completed, and execute step S7.

[0088] When the virtual key value KEYCODE_NUM is obtained, the character conversion of the virtual key values corresponding to consecutive Chinese characters has been completed. For example, for "tree / flowers and plants", there is an end character KEYCODE_NUM after the 5 virtual key values corresponding to the character "tree", and for the consecutive Chinese characters "flowers and plants", there is an end character KEYCODE_NUM after the 5 virtual key values corresponding to the character "grass".

[0089] For the above QR code containing only Chinese information, when the character conversion of "147, 145, 146, 148, 147" is completed, the next virtual key value obtained through the key event is KEYCODE_NUM, and continue to return to step S1 to obtain the next virtual key value.

[0090] When the virtual key value KEYCODE_ENTER is obtained, the character conversion of all virtual key values in the QR code has been completed, and execute step S7.

[0091] In an alternative embodiment, when it is determined in step S5 that the virtual key value is not an end character, it further includes:

[0092] Check whether the number of virtual key values currently accumulated within the range of 144 to 153 is zero. If so, execute step S6. Otherwise, report an error.

[0093] When one or more virtual key values ​​corresponding to non-Chinese information are mixed in the 5 virtual key values ​​corresponding to Chinese information, an error is reported. For example, currently three virtual key values ​​152, 144, and 148 are accumulated, and the next virtual key value obtained through the key event is VK_A (not a virtual key value corresponding to Chinese information), an error is reported, and further processing operations are to clear the currently accumulated virtual key values ​​152, 144, 148 and VK_A.

[0094] Step S6: convert the virtual key value into a non-target character, where the non-target character includes letters, numbers and symbols, and return to step S1.

[0095] In an optional embodiment, step S6 specifically includes:

[0096] Based on the uppercase state being on / off, the virtual key value is converted into a non-target character of a corresponding state, the non-target character including letters, numbers and symbols, and the process returns to step S1.

[0097] For example, the virtual key value obtained through the key event is VK_H. When the uppercase state is turned on, the character corresponding to the virtual key value is H; when the uppercase state is turned off, the character corresponding to the virtual key value is h.

[0098] Step S7: Generate a QR code recognition result based on all the converted Chinese characters and non-target characters.

[0099] For the above QR code containing only Chinese information, the QR code recognition result generated based on all the converted Chinese characters is: I love programming.

[0100] In the embodiment of the present invention, a QR code containing numbers, letters and Chinese information "Enjoy9855 Tutorial" is used as an example to illustrate the above steps S1 to S7. All virtual key values ​​of the QR code are as follows:

[0101] 33, 42, 38, 43, 53, 16, 15, 12, 12, 148, 152, 149, 152, 152, 148, 150, 144, 146, 152, KEY_NUM, KEYCODE_ENTER.

[0102] In this example, the preset operation is a press operation.

[0103] Get one virtual key value at a time from the above 21 virtual key values ​​through a key event:

[0104] Get the first virtual key value 33, and determine whether it is a press operation. If so, continue to determine whether the uppercase state is on / off when the virtual key value 33 is pressed. When it is determined that the uppercase state is on, perform a key value size judgment on the virtual key value 33. The virtual key value is less than 144 and does not belong to the virtual key value corresponding to the Chinese information. Perform an end character judgment on the virtual key value 33, determine that the virtual key value 33 is not an end character, perform character conversion on the virtual key value 33, and combine the uppercase state to turn on, and the character conversion result of the virtual key value 33 is E.

[0105] Continue to obtain the second virtual key value 42, and determine whether it is a press operation. If so, continue to determine whether the uppercase state is on / off when the virtual key value 42 is pressed. When it is determined that the uppercase state is off, perform a key value size judgment on the virtual key value 42. The virtual key value is less than 144 and does not belong to the virtual key value corresponding to the Chinese information. Perform an end character judgment on the virtual key value 42, determine that the virtual key value 42 is not an end character, perform character conversion on the virtual key value 42, and combine the uppercase state to be off, and obtain the character conversion result of the virtual key value 33 as n; ......

[0106] Continue to obtain the sixth virtual key value 16, and determine whether it is a press operation. If so, continue to determine whether the uppercase state is on / off when the virtual key value 16 is pressed. When it is determined that the uppercase state is off, perform a key value size judgment on the virtual key value 16. The virtual key value is less than 144 and does not belong to the virtual key value corresponding to the Chinese information. Perform an end character judgment on the virtual key value 16, determine that the virtual key value 16 is not an end character, perform character conversion on the virtual key value 16, and combine the uppercase state to be off, and the character conversion result of the virtual key value 16 is 9;

[0107] Continue to obtain the seventh virtual key value 15, repeat the processing steps of virtual key value 16, and obtain the character conversion result of virtual key value 15 as 8; ......

[0108] Continue to obtain the tenth virtual key value 148, and determine whether it is a press operation. If so, continue to determine whether the uppercase state is on / off when the virtual key value 148 is pressed. When it is determined that the uppercase state is off, perform key value size judgment on the virtual key value 148. The virtual key value falls within the range of 144-153, which belongs to the virtual key value corresponding to the Chinese information. The virtual key value 148 is the first virtual key value currently obtained that falls within the range of 144-153. The cumulative number does not reach the target number 5, and the next virtual key value 152 continues to be obtained through the key event.

[0109] Similar to the processing of virtual key value 148, virtual key value 152 is the second virtual key value currently obtained that falls within the range of 144-153. The cumulative number does not reach the target number 5, and the next virtual key value 149 is obtained through the key event. ......

[0110] The same processing process as the virtual key value 148, when the fourteenth virtual key value 152 is obtained, the virtual key values ​​falling into the range of 144-153 have accumulated to 5, and the virtual key values ​​148, 152, 149, 152, 152 are converted into hexadecimal to obtain: BDCC, and then BDCC is converted into Chinese characters and the number of virtual key values ​​currently accumulated and falling into the range of 144-153 is cleared, and the next virtual key value 148 is obtained;

[0111] Similarly, the hexadecimal numbers corresponding to the virtual key values ​​148, 150, 144, 146, and 152 are: B3CC. B3CC is then converted into Chinese characters and the number of virtual key values ​​currently acquired that fall within the range of 144-153 is cleared to zero, and the next virtual key value KEYCODE_NUM is acquired.

[0112] Consistent with the above virtual key value processing flow, after judgment, the twentieth virtual key value KEYCODE_NUM obtained by the key event is the end character, and it is determined that the character conversion of the virtual key values ​​corresponding to the consecutive Chinese characters has been completed, and the next virtual key value KEYCODE_ENTER continues to be obtained.

[0113] When the virtual key value obtained by the key event is KEYCODE_ENTER, the QR code recognition is completed, and the recognition result "Enjoy9855 Tutorial" of the QR code containing numbers, letters and Chinese information is generated according to all the alphabetic characters, numeric characters and Chinese characters generated by the above process.

[0114] The QR code recognition method provided in the embodiment of the present application can enable an Android device that can be externally connected to a barcode scanner to recognize letters, numbers, symbols and Chinese information in a QR code.

[0115] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0116] See also Figure 3 , which is a structural diagram of a two-dimensional code recognition device provided by an exemplary embodiment of the present application.

[0117] The two-dimensional code recognition device can be implemented as all or part of an Android device through software, hardware, or a combination of both. The two-dimensional code recognition device in the embodiment of the present application is applied to an Android device that can be connected to an external barcode scanner. The device includes:

[0118] The key value acquisition module 11 is used to acquire the virtual key value through the key event, and determine whether the key event is a preset operation. If so, the key value determination module 12 is triggered; otherwise, the virtual key value is continuously acquired through the key event;

[0119] A key value judgment module 12 is used to judge whether the virtual key value falls into a target value range, and if so, trigger the first judgment module 13, otherwise, trigger the second judgment module 15;

[0120] A first judging module 13 is used to judge whether the current cumulative number of virtual key values ​​falling into the target value range reaches the target number, and if so, trigger the first converting module 14, and if not, trigger the key value acquiring module 11;

[0121] A first conversion module 14 is used to convert the target number of virtual key values ​​into target characters, and clear the number of virtual key values ​​currently accumulated within the target value range, thereby triggering the key value acquisition module 11;

[0122] A second judging module 15 is used to judge whether the virtual key value is an end character, and if not, trigger the second converting module 16, and if not, trigger the recognition result generating module 17;

[0123] A second conversion module 16, configured to convert the virtual key value into a non-target character, wherein the non-target character includes letters, numbers and symbols, and trigger the key value acquisition module 11;

[0124] The recognition result generating module 17 is used to generate a two-dimensional code recognition result according to all target characters and non-target characters obtained by conversion.

[0125] In an optional embodiment, the key value determination module 12 is specifically used for:

[0126] It is determined whether the virtual key value falls within the range of 144 to 153. If so, it is determined that the virtual key value is a virtual key value corresponding to the Chinese information, and the first judgment module 13 is triggered. Otherwise, the second judgment module 15 is triggered.

[0127] In an optional embodiment, the first conversion module 14 includes:

[0128] A first conversion unit, used for obtaining a hexadecimal number corresponding to the virtual key value of the target number;

[0129] The second conversion unit is used to convert the hexadecimal number into Chinese characters, and clear the number of virtual key values ​​currently falling into the range of 144 to 153, thereby triggering the key value acquisition module 11.

[0130] In an optional embodiment, the second conversion unit is specifically configured to:

[0131] The hexadecimal number is converted into Chinese characters in a specified format, and the number of virtual key values ​​currently falling into the range of 144 to 153 is cleared to trigger the key value acquisition module 11.

[0132] In an optional embodiment, when it is determined that the virtual key value is not a terminator, the second determination module 15 is further configured to:

[0133] Check whether the current cumulative number of virtual key values ​​falling into the target value range is zero, if so, trigger the second conversion module 16, otherwise report an error.

[0134] In an optional embodiment, when it is determined that the virtual key value is an end character, the second determination module 15 is further configured to:

[0135] It is determined whether the virtual key value is KEYCODE_NUM. If so, the key value acquisition module 11 is triggered. Otherwise, it is determined that the virtual key value is KEYCODE_ENTER, the two-dimensional code recognition is completed, and the recognition result generation module 17 is triggered.

[0136] In an optional embodiment, the device further includes:

[0137] The state judgment module is used to judge whether the virtual key value is KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT. If so, determine whether the uppercase state is turned on / off and trigger the key value acquisition module 11. Otherwise, trigger the key value judgment module 12.

[0138] In an optional embodiment, the second conversion module 16 is specifically configured to:

[0139] Based on the uppercase state being on / off, the virtual key value is converted into a non-target character of a corresponding state, the non-target character including letters, numbers and symbols, and the key value acquisition module 11 is triggered.

[0140] In an optional embodiment, the device further includes:

[0141] The broadcast component registration module is used to create a code scanning service and register the boot-up self-start broadcast component with the code scanning service;

[0142] A broadcast receiving module is used to monitor the system broadcast based on the broadcast component to determine whether the power-on broadcast is received;

[0143] The service startup module is used to start the code scanning service if the startup broadcast is monitored.

[0144] It should be noted that the two-dimensional code recognition device provided in the above embodiment only uses the division of the above functional modules as an example when executing the two-dimensional code recognition method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the two-dimensional code recognition device provided in the above embodiment and the two-dimensional code recognition method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.

[0145] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0146] The QR code recognition device provided in the embodiment of the present application can enable an Android device that can be externally connected to a barcode scanner to recognize letters, numbers, symbols and multiple languages ​​in a QR code.

[0147] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the method of any of the above embodiments are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.

[0148] An embodiment of the present application also provides an Android device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-mentioned method embodiments when executing the program.

[0149] In the embodiment of the present application, the processor is the control center of the computer system, which can be the processor of a physical machine or the processor of a virtual machine. The processor may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state.

[0150] The memory may include one or more computer-readable storage media, which may be non-transitory. The memory may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments of the present application, the non-transitory computer-readable storage medium in the memory is used to store at least one instruction, and the at least one instruction is used to be executed by the processor to implement the method in the embodiment of the present application.

[0151] In some embodiments, the Android device further comprises: a peripheral device interface and at least one peripheral device. The processor, the memory and the peripheral device interface may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface via a bus, a signal line or a circuit board. Specifically, the peripheral device comprises: at least one of a display screen, a camera and an audio circuit.

[0152] The peripheral device interface can be used to connect at least one peripheral device related to I / O (Input / Output) to the processor and the memory. In some embodiments of the present application, the processor, the memory, and the peripheral device interface are integrated on the same chip or circuit board; in some other embodiments of the present application, any one or two of the processor, the memory, and the peripheral device interface can be implemented on a separate chip or circuit board. The embodiments of the present application are not specifically limited to this.

[0153] The display screen is used to display the UI (User Interface). The UI may include graphics, text, icons, videos and any combination thereof. When the display screen is a touch display screen, the display screen also has the ability to collect touch signals on the surface or above the surface of the display screen. The touch signal can be input to the processor as a control signal for processing. At this time, the display screen can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments of the present application, the display screen can be one, and the front panel of the Android device is set; in other embodiments of the present application, the display screen can be at least two, which are respectively set on different surfaces of the Android device or are folded; in some other embodiments of the present application, the display screen can be a flexible display screen, which is set on the curved surface or folded surface of the Android device. Even, the display screen can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode) and the like.

[0154] The camera is used to capture images or videos. Optionally, the camera includes a front camera and a rear camera. Usually, the front camera is set on the front panel of the Android device, and the rear camera is set on the back of the Android device. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments of the present application, the camera may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0155] The audio circuit may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor for processing. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, which are respectively arranged in different parts of the Android device. The microphone may also be an array microphone or an omnidirectional collection microphone.

[0156] The power source is used to power various components in the Android device. The power source can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When the power source includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged through a wired line, and a wireless rechargeable battery is a battery that is charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0157] The structural block diagram of the Android device shown in the embodiment of the present application does not constitute a limitation on the Android device. The Android device may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.

[0158] In this application, the terms "first", "second", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or order; the term "plurality" refers to two or more, unless otherwise expressly defined. The terms "installed", "connected", "connected", "fixed", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; "connected" can be a direct connection or an indirect connection through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances.

[0159] In the description of the present application, it is necessary to understand that the terms "upper", "lower", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or unit referred to must have a specific direction, be constructed and operated in a specific orientation. Therefore, it should not be understood as a limitation on the present application.

[0160] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A two-dimensional code recognition method, characterized in that: The method is applied to an Android device that can be connected to an external barcode scanner, including: Step S1: obtaining a virtual key value through a key event, and determining whether the key event is a preset operation, if so, executing step S2, otherwise, continuing to obtain a virtual key value through the key event; Step S2: Determine whether the virtual key value falls within the target value range, if so, execute step S3, otherwise, execute step S5; Step S3: Determine whether the current cumulative number of virtual key values ​​falling within the target value range reaches the target number, if so, execute step S4, if not, return to step S1; Step S4: converting the target number of virtual key values ​​into target characters, and clearing the current cumulative number of virtual key values ​​falling within the target value range, and returning to step S1; Step S5: Determine whether the virtual key value is an end character, if not, execute step S6, if yes, determine that the QR code recognition is finished, and execute step S7; Step S6: convert the virtual key value into a non-target character, wherein the non-target character includes letters, numbers and symbols, and return to step S1; Step S7: generating a QR code recognition result according to all target characters and non-target characters obtained by conversion; The step S2 comprises: Determine whether the virtual key value falls within the range of 144 to 153, if so, determine that the virtual key value is a virtual key value corresponding to Chinese information, and execute step S3, otherwise, execute step S5; The step S4 comprises: Step S41: Obtain the hexadecimal number corresponding to the virtual key value of the target number; Step S42: convert the hexadecimal number into Chinese characters, and clear the number of virtual key values ​​currently falling within the range of 144 to 153, and return to step S1.

2. The method according to claim 1, characterized in that: The step S42 comprises: The hexadecimal number is converted into Chinese characters in a specified format, and the number of virtual key values ​​currently falling within the range of 144 to 153 is cleared, and the process returns to step S1.

3. The method according to claim 1, characterized in that If it is determined in step S5 that the virtual key value is not a terminator, the step further includes: Check whether the current cumulative number of virtual key values ​​falling within the target value range is zero. If so, execute step S6, otherwise report an error.

4. The method according to claim 1, characterized in that: If it is determined in step S5 that the virtual key value is a terminator, the step further includes: Determine whether the virtual key value is KEYCODE_NUM. If so, return to step S1. Otherwise, determine that the virtual key value is KEYCODE_ENTER, the QR code recognition is completed, and execute step S7.

5. The method according to claim 1, characterized in that Before step S2, the method further includes: Step S2': determine whether the virtual key value is KEYCODE_SHIFT_RIGHT or KEYCODE_SHIFT_LEFT, if so, determine whether the uppercase state is turned on / off, and return to step S1, otherwise, execute step S2.

6. The method according to claim 5, characterized in that The converting the virtual key value into a non-target character comprises: Based on the uppercase state being on / off, the virtual key value is converted into a non-target character of a corresponding state.

7. The method according to claim 1, characterized in that Before step S1, the method further includes: Step S1-1: Create a code scanning service and register a boot-up self-start broadcast component with the code scanning service; Step S1-2: monitor the system broadcast and determine whether the power-on broadcast is monitored. If so, execute step S1-3; otherwise, continue to monitor the system broadcast; Step S1-3: Start the code scanning service.

8. A two-dimensional code recognition device, characterized in that: The device is applied to an Android device that can be connected to an external barcode scanner, including: A key value acquisition module is used to acquire a virtual key value through a key event, and determine whether the key event is a preset operation. If so, the key value determination module is triggered; otherwise, the virtual key value is continuously acquired through the key event; A key value judgment module, used to judge whether the virtual key value falls into the target value range, if so, trigger the first judgment module, otherwise, trigger the second judgment module; A first judgment module is used to judge whether the current cumulative number of virtual key values ​​falling into the target value range reaches the target number, and if so, trigger the first conversion module; if not, trigger the key value acquisition module; A first conversion module, configured to convert the target number of virtual key values ​​into target characters, and clear the number of virtual key values ​​currently accumulated within the target value range, to trigger a key value acquisition module; A second judging module is used to judge whether the virtual key value is an end character, if not, trigger the second converting module, if not, trigger the recognition result generating module; A second conversion module, used to convert the virtual key value into a non-target character, wherein the non-target character includes letters, numbers and symbols, and trigger a key value acquisition module; A recognition result generation module is used to generate a QR code recognition result based on all target characters and non-target characters obtained by conversion; The key value judgment module is specifically used for: Determine whether the virtual key value falls within the range of 144 to 153, if so, determine that the virtual key value is a virtual key value corresponding to Chinese information, and trigger the first determination module, otherwise, trigger the second determination module; The first conversion module comprises: A first conversion unit, used for obtaining a hexadecimal number corresponding to the virtual key value of the target number; The second conversion unit is used to convert the hexadecimal number into Chinese characters, and clear the number of virtual key values ​​currently falling into the range of 144 to 153, thereby triggering the key value acquisition module.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.

10. An Android device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Two-dimensional code recognition method and device

    CN104102892A

  • Code scanning recognition method and device, electronic equipment and readable storage medium

    CN111950233A