Two-dimensional code identification method and device

By monitoring the wrist flip event in the terminal device and synchronously performing the operation of identifying and starting the code scanning service module, the problem of low QR code recognition efficiency in the prior art is solved, and fast code recognition and efficient recognition are achieved.

CN119312824APending Publication Date: 2025-01-14HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310854841.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-12
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

Existing terminal devices require users to perform a series of operations when scanning QR codes, resulting in low efficiency and long time to identify QR codes.

Method used

By monitoring the wrist-turning event of the terminal device, synchronously perform operations to identify whether there is a QR code and start the QR code scanning service module, save the time to start the QR code scanning service module, improve the processing efficiency of wrist-turning code recognition, and determine the existence of a QR code. When coding, the code scanning process is performed to realize the identification of the QR code.

Benefits of technology

It effectively improves the efficiency of QR code recognition, reduces user operation steps, shortens code recognition time, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312824A_ABST
    Figure CN119312824A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a two-dimensional code recognition method and device.The method comprises the steps that if a code scanning intention module monitors a wrist turning event, first operation and second operation are executed synchronously, and the first operation comprises the steps that a first front-facing camera of terminal equipment is called to obtain an image, and whether a two-dimensional code exists in the image or not is recognized; the second operation comprises the step of sending a starting instruction to the code scanning service module so as to start the code scanning service module. And if the code scanning intention module determines that the two-dimensional code exists in the image according to the first operation, a code existence notification message is sent to the code scanning service module. The code scanning service module responds to the code notification message and executes a code scanning process, and the code scanning process comprises the steps that a second front-facing camera of the terminal equipment is called to obtain an image, and two-dimensional code information in the image is recognized. According to the technical scheme, the recognition efficiency of the two-dimensional code can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of terminal technology, terminal devices have become important tools in people's lives and can provide users with a variety of functions.

[0003] The functions provided by current terminal devices include a QR code scanning function. In the prior art, the terminal devices usually respond to a series of operations by the user to scan the QR code, thereby completing life and work purposes.

[0004] However, in the process of the terminal device scanning the QR code, the user needs to perform a series of operations on the terminal device to trigger the terminal device to scan the QR code. The triggering process takes a certain amount of time, resulting in low QR code recognition efficiency. Summary of the invention

[0005] The embodiments of the present application provide a two-dimensional code recognition method and device, which are applied in the field of terminal technology.

[0006] In a first aspect, an embodiment of the present application provides a two-dimensional code recognition method. The method includes:

[0007] If the code scanning intention module monitors the wrist turning event, the first operation and the second operation are synchronously executed, wherein the first operation includes: calling the first front camera of the terminal device to acquire an image and identifying whether there is a QR code in the image; the second operation includes: sending a start instruction to the code scanning service module to start the code scanning service module;

[0008] If the code scanning intention module determines that there is a QR code in the image according to the first operation, a coded notification message is sent to the code scanning service module;

[0009] The code scanning service module executes a code scanning process in response to the coded notification message, and the code scanning process includes: calling the second front camera of the terminal device to obtain an image and identifying the two-dimensional code information in the image.

[0010] In this implementation, when the scanning intention module monitors the wrist turning event, the operations of identifying whether there is a QR code and starting the scanning service module are synchronously executed, thereby saving the time spent on starting the scanning service module and improving the processing efficiency of identifying the code by turning the wrist. When the subsequent scanning intention module determines that a QR code exists, it informs the scanning service module of the code. The scanning service module executes the scanning process to realize the analysis of the QR code information. Therefore, it is possible to effectively trigger the recognition of the QR code by turning the wrist, thereby effectively improving the recognition efficiency of the QR code.

[0011] In some implementations, the code scanning intention module includes a state machine, and the state machine is used to record the common execution state of the code scanning intention module and the code scanning service module;

[0012] After sending the start instruction to the code scanning service module, the method further includes:

[0013] The code scanning service module modifies the state recorded in the state machine to binding;

[0014] If the code scanning intention module monitors a new wrist turning event, the new wrist turning event is ignored.

[0015] In some implementations, after sending a start instruction to the code scanning service module, the method further includes:

[0016] The code scanning intention module obtains the binding result of starting the code scanning service module;

[0017] If the binding result indicates that the binding is successful, the code scanning intention module modifies the state recorded in the state machine to binding completed.

[0018] In some implementations, before sending the coded notification message to the code scanning service module, the method further includes:

[0019] The code scanning intention module obtains the state recorded in the state machine;

[0020] The sending of a coded notification message to the code scanning service module includes:

[0021] If the state recorded in the state machine is binding completed, the code scanning intention module sends a coded notification message to the code scanning service module.

[0022] In some implementations, the method further includes:

[0023] If the state recorded in the state machine is binding, the code scanning intention module resends a start instruction to the code scanning service module;

[0024] The code scanning intention module obtains the binding result of starting the code scanning service module;

[0025] If the binding result indicates that the binding is successful, the code scanning intention module modifies the state recorded in the state machine to binding completed;

[0026] The code scanning intention module sends a coded notification message to the code scanning service module.

[0027] In some implementations, the method further includes:

[0028] When the code scanning service module starts to execute the code scanning process, the code scanning service module sends a code scanning start message to the code scanning intention module;

[0029] The code scanning intention module modifies the state recorded in the state machine to code scanning according to the code scanning start message.

[0030] In the above-mentioned various implementations, the common status of the code scanning intention module and the code scanning service module in various situations is recorded by the state machine in the code scanning intention module, so that the changes and sequence of the status can be maintained and coordinated in an orderly manner to ensure that the wrist flip code recognition process can be executed correctly and orderly.

[0031] In some implementations, the method further includes:

[0032] When the status recorded in the barcode scanner is scanning, the barcode scanning intention module monitors any of the following events: wrist turning event, code event, no code event, and ignores the monitored event.

[0033] This implementation avoids the problem that when the code scanning service module has been started, the code scanning intention module monitors the code event, and the code scanning intention module is not sure whether to notify the code scanning service module to execute the code scanning process.

[0034] In some implementations, after the code scanning service module executes the code scanning process in response to the coded notification message, the method further includes:

[0035] The code scanning service module determines that the code scanning is successful, and sends a code scanning success message to the code scanning intention module; or,

[0036] The code scanning service module determines that the code scanning process has timed out and sends a timeout notification message to the code scanning intention module.

[0037] In some implementations, the method further includes:

[0038] The code scanning intention module modifies the state recorded in the state machine to an idle state in response to the code scanning success message or the timeout notification message.

[0039] In some implementations, the method further includes:

[0040] If the code scanning intention module determines that there is no QR code in the image according to the first operation, then obtaining the state recorded in the state machine;

[0041] If the state recorded in the state machine is binding completed, the code scanning intention module sends a code-free notification message to the code scanning service module;

[0042] The code scanning service module responds to the code-free notification message, ends the life cycle of the code scanning service module, and sends an end notification message to the code scanning intention module;

[0043] The code scanning intention module modifies the state recorded in the state machine to an idle state according to the end notification message.

[0044] In some implementations, the method further includes:

[0045] If the state recorded in the state machine is binding, the code scanning intention module modifies the state recorded in the state machine to idle state.

[0046] In some implementations, the method further includes:

[0047] When the state recorded in the state machine is binding, if the code scanning intention module monitors a target event, the target event is cached and timed, and the target event is a coded event or an uncoded event;

[0048] When the timing of the target event reaches a preset duration, obtaining the state recorded in the state machine;

[0049] If the state recorded in the state machine is that the binding is completed, a coded notification message or a non-coded notification message is sent to the code scanning service module;

[0050] If the state recorded in the state machine is binding, determine whether the number of rotations for the target event is greater than or equal to the preset number. If so, discard the target event and modify the state recorded in the state machine to the idle state. If not, add 1 to the number of rotations and restart the timing, and repeat the operation of obtaining the state recorded in the state machine when the timing for the target event reaches the preset duration, until the state recorded in the state machine is binding completed, or the number of rotations for the target event is greater than or equal to the preset number.

[0051] In this implementation, it is ensured that the coded notification message or the uncoded notification message is sent when the code scanning intention module and the code scanning service module can interact, so as to avoid the problem that the coded event or the uncoded event cannot be notified to the code scanning service module and becomes invalid. And when the number of rotations is greater than or equal to the preset number of times, the coded event or the uncoded event is discarded, so as to effectively avoid the state of binding lasting for a long time, resulting in the problem that the subsequent coded event and the overall process of wrist flip code recognition cannot be processed.

[0052] In some implementations, monitoring the wrist turning event includes:

[0053] If it is determined that the value represented by the posture change information is greater than or equal to a first preset threshold and the screen direction is a direction other than the first direction, it is determined that a wrist turning event is monitored, wherein the first direction is the positive direction of the z-axis of the world coordinate system.

[0054] In a second aspect, an embodiment of the present application provides a terminal device, which may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc.

[0055] The terminal device comprises: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method of the first aspect.

[0056] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method of the first aspect is implemented.

[0057] In a fourth aspect, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the method of the first aspect.

[0058] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor, the processor being used to call a computer program in a memory to execute the method described in the first aspect.

[0059] It should be understood that the second to fifth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 Schematic diagram of the scenario applicable to the two-dimensional code recognition method of the embodiment of the present application Figure 1 ;

[0061] Figure 2 Schematic diagram of the scenario applicable to the two-dimensional code recognition method of the embodiment of the present application Figure 2 ;

[0062] Figure 3 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0063] Figure 4 A software structure block diagram of a terminal device according to an embodiment of the present application;

[0064] Figure 5 The processing flow diagram of wrist-turning code recognition provided in the embodiment of the present application is as follows Figure 1 ;

[0065] Figure 6 A flowchart of the QR code recognition method provided by this application;

[0066] Figure 7 The processing flow diagram of wrist-turning code recognition provided in the embodiment of the present application is as follows Figure 2 ;

[0067] Figure 8 An interactive flow chart of a two-dimensional code recognition method provided in an embodiment of the present application;

[0068] Fig. 9 Interaction process provided for the embodiment of this application Figure 2 ;

[0069] Fig.10 A schematic diagram of a flow chart of a two-dimensional code recognition method provided in an embodiment of the present application;

[0070] Fig.11 A schematic diagram of an interface of a two-dimensional code recognition method provided in an embodiment of the present application Figure 1 ;

[0071] Fig.12 A schematic diagram of an interface of a two-dimensional code recognition method provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION

[0072] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0073] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" 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, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0074] It should be noted that the "at..." in the embodiment of the present application can be the instant when a certain situation occurs, or a period of time after a certain situation occurs, and the embodiment of the present application does not specifically limit this. In addition, the display interface provided in the embodiment of the present application is only an example, and the display interface can also include more or less content.

[0075] In order to better understand the technical solution of the present application, the relevant technologies involved in the present application are further introduced in detail below.

[0076] With the development of terminal technology, terminal devices have become an important tool in people's lives. Terminal devices provide users with a variety of functions. For example, terminal devices can respond to a series of operations of users, scan QR codes, and thus complete life and work purposes.

[0077] With the popularity of QR code applications, people often encounter scenarios that require code scanning in their daily lives and work, such as scanning to pay, picking up express deliveries, unlocking shared bicycles, ordering food, etc. The key experience of code scanning is to be "fast". Currently, whether it is the system code scanning function that comes with the interrupt device or the third-party code scanning function developed by third-party applications, most of them require users to manually start the code scanning application, and the scanning steps are cumbersome and lengthy.

[0078] For example, when a user uses a terminal device to scan a QR code, the user usually triggers the terminal device's application or applet first, and then triggers the terminal device's QR code recognition function based on the application or applet's entry. Then, the terminal device can call the camera to obtain an image and recognize the QR code based on the obtained image.

[0079] It can be seen that in the process of terminal equipment recognizing QR codes, users are required to perform a series of operations on the terminal equipment to achieve the purpose of code recognition. Both triggering code recognition and the actual code recognition process take a certain amount of time, resulting in low QR code recognition efficiency.

[0080] In view of this, an embodiment of the present application provides a QR code recognition method, wherein the method can monitor wrist-turning events through the posture change information and screen direction of the terminal device, and then directly call the front camera of the terminal device to capture images and recognize QR codes based on the monitored wrist-turning events, thereby avoiding a series of tedious operations for triggering code recognition, saving time for recognizing QR codes, improving QR code recognition efficiency, and enhancing user experience.

[0081] Figure 1 Schematic diagram of the scenario applicable to the two-dimensional code recognition method of the embodiment of the present application Figure 1 .like Figure 1 As shown in (a) of FIG. 1 , the user holds the terminal device 100, and the terminal device 100 is in a bright screen unlocked state. Figure 1 As shown in (b), the user flips the terminal device 100, that is, the user has a wrist-turning action; then based on the QR code recognition method of the embodiment of the present application, the terminal device 100 calls the front camera of the terminal device to obtain the image on the desktop and recognizes the QR code information in the image. Based on the recognized QR code information, the terminal device 100 calls the interface of the application corresponding to the QR code information.

[0082] Figure 2 Schematic diagram of the scenario applicable to the two-dimensional code recognition method of the embodiment of the present application Figure 2 .like Figure 2 As shown, the user holds a terminal device 100; based on the QR code recognition method of the embodiment of the present application, the terminal device 100 calls the rear camera of the terminal device to obtain an image on the wall and recognizes the QR code information in the image. Based on the recognized QR code information, the terminal device 100 calls the interface of the application corresponding to the QR code information.

[0083] The terminal device 100 may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiments of the present application do not limit the specific technology and specific device form adopted by the terminal device.

[0084] The terminal device 100 has a function of displaying an interface and a function of acquiring an image.

[0085] In order to better understand the embodiment of the present application, the structure of the terminal device in the embodiment of the present application is introduced below:

[0086] Figure 3A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. The terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0087] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0088] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0089] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0090] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0091] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuits sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0092] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is a schematic illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0093] The terminal device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0094] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0095] The terminal device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0096] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0097] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the terminal device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0098] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the terminal device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0099] Video codecs are used to compress or decompress digital videos. The terminal device 100 may support one or more video codecs. Thus, the terminal device 100 may play or record videos in various coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0100] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the terminal device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0101] The gyroscope sensor 180B can be used to determine the motion posture of the terminal device 100. In some embodiments, the angular velocity of the terminal device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the terminal device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the terminal device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and somatosensory game scenes.

[0102] Gyro sensor 180B is used to collect angle change data. Gyro sensor 180B is used to collect angle data.

[0103] The acceleration sensor 180E can detect the magnitude of the acceleration of the terminal device 100 in all directions (generally three axes). When the terminal device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the terminal device and applied to applications such as horizontal and vertical screen switching and pedometers.

[0104] The acceleration change data is collected based on the acceleration sensor 180E. The terminal device determines the posture change information of the terminal device based on the acceleration change data collected by the acceleration sensor 180E.

[0105] The terminal device determines the screen direction based on the angle data collected by the gyro sensor 180B.

[0106] The terminal device determines the posture change information of the terminal device based on the angle change data collected by the gyroscope sensor 180B. Alternatively, the terminal device determines the posture change information of the terminal device based on the acceleration change data collected by the acceleration sensor 180E. Alternatively, the terminal device determines the posture change information of the terminal device based on the angle change data collected by the gyroscope sensor 180B and the acceleration change data collected by the acceleration sensor 180E.

[0107] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The terminal device 100 emits infrared light outward through the light emitting diode. The terminal device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the terminal device 100. When insufficient reflected light is detected, the terminal device 100 can determine that there is no object near the terminal device 100. The terminal device 100 can use the proximity light sensor 180G to detect that the user holds the terminal device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode, and pocket mode automatically unlocks and locks the screen.

[0108] The proximity light sensor 180G collects proximity light data. The terminal device determines proximity light information based on the proximity light data collected by the light sensor 180G.

[0109] The ambient light sensor 180L is used to sense the ambient light brightness. The terminal device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the terminal device 100 is in a pocket to prevent accidental touch.

[0110] The ambient light sensor 180L collects ambient light data. The terminal device determines ambient light information based on the ambient light data collected by the ambient light sensor 180L.

[0111] The software system of the terminal device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, etc. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the terminal device 100.

[0112] Figure 4 This is a software structure block diagram of the terminal device 100 according to an embodiment of the present application.

[0113] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the several layers are, from top to bottom, the application layer, the application framework layer, the system library (native layer) and the Android runtime (Android runtime), the HAL (Hardware Abstraction Layer, hardware abstraction) layer, the kernel layer, and the hardware layer.

[0114] The application layer can include a series of application packages.

[0115] like Figure 4 As shown, the application package may include camera, calendar, phone, map, phone, music, settings, email, video, code recognition and other applications. Among them, the code recognition APP (Application) is used to process the code scanning process.

[0116] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0117] like Figure 4 As shown, the application framework layer may include an activity manager, a window manager, a content provider, a resource manager, a view system, a notification manager, a camera service, a system service, a perception service, and the like.

[0118] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, touch the screen, drag the screen, capture the screen, etc.

[0119] Content providers are used to store and retrieve data and make it accessible to applications. The data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0120] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0121] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0122] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, the terminal device vibrates, the indicator light flashes, etc.

[0123] Among them, the camera service is a unit in the framework layer used to handle camera scheduling, and the system service is used to transmit data between the code recognition APP and the perception service.

[0124] And reference Figure 4 In the perception service, subscription management and AO (Always On) management are further deployed. The subscription management in the perception service is used to monitor the screen unlocking, wrist flip events, and code event management. The AO management in the perception service is used to trigger image capture and identify the code.

[0125] like Figure 4 As shown, the system library may include multiple functional modules, such as a surface manager, a media library, a 3D graphics processing library (such as OpenGL ES), a 2D graphics engine (such as SGL), a QR code recognition algorithm engine, etc.

[0126] Among them, the QR code recognition algorithm engine is the processing engine of the scanning process in this application, which is used to parse the QR code information in the image.

[0127] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0128] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0129] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0130] like Figure 4As shown, the AP camera HAL layer service is deployed in the HAL layer, wherein the AP camera HAL layer service is a unit in the HAL layer for processing camera scheduling, and AP is an Application Processor.

[0131] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver. Among them, the camera driver is the unit in the framework layer used to handle camera scheduling.

[0132] And reference Figure 4 , the hardware layer is deployed with a camera and HIAON (Honor Intelligent Always-ON algorithm platform, intelligent AO algorithm platform), and the HIAON is deployed with an AON (Always-ON) camera and a primary code judgment unit. Among them, the camera can be understood as the second front camera with a higher frame rate introduced in the above embodiment, and the AON camera in HIAON can be understood as the first front camera with lower power consumption introduced in the above embodiment, and the primary code judgment unit in HIAON is used to identify whether there is a QR code in the image.

[0133] It should also be noted that the code scanning intention module introduced in each embodiment of the present application corresponds to the perception service and HIAON in the software architecture, which can be understood as the two modules abstracting the code scanning intention module. And the code scanning service module introduced in each embodiment of the present application corresponds to the code recognition APP in the software architecture.

[0134] based on Figure 4 The software architecture provided, in this application, the wrist-flip event can be managed through subscription management. When the wrist-flip event is monitored, the AO management can synchronously perform the following two operations: trigger HIAON to capture the image and identify whether there is a code (which can be understood as the first operation), and launch the code recognition APP through the system service (which can be understood as the second operation).

[0135] Afterwards, the AON camera (low-power first front camera) in the HIAON platform can capture the first image, and then the primary code judgment unit determines whether there is a QR code in the first image, and then transmits the judgment result back to the AO management.

[0136] After receiving the judgment result of whether there is a QR code, AO management sends the judgment result to the code recognition APP through the system service. If the judgment result indicates that the QR code is recognized, the code recognition APP can send an instruction to obtain the image to the camera service unit, and then pass through the camera service, AP camera HAL layer service, and camera driver units in sequence, and call the camera in the hardware layer (the second front camera with a high frame rate) to capture the second image.

[0137] For example, the captured second image can be transmitted back to the code recognition APP via the transmission link of the camera, camera driver, AP camera HAL layer service, and camera service. The code recognition APP then schedules the QR code recognition algorithm engine in the native layer to perform the scanning process on the captured second image to parse the QR code information in the second image.

[0138] If the analysis is successful, the code recognition APP can pull up the service interface corresponding to the QR code information based on the analyzed QR code information.

[0139] The following is an illustrative description of the software and hardware workflow of the terminal device 100 in conjunction with a scenario where an application is started or an interface switch occurs in an application.

[0140] The following is a detailed description of the operation process of the two-dimensional code recognition provided by the embodiment of the present application and the display process of the interface during the two-dimensional code recognition process in conjunction with the accompanying drawings. It should be noted that the "at..." in the embodiment of the present application can be the instant when a certain situation occurs, or it can be a period of time after a certain situation occurs, and the embodiment of the present application does not make specific limitations on this.

[0141] Based on the above introduction, it can be determined that in the technical solution of the present application, the terminal device can realize wrist-flipping code recognition. Specifically, the terminal device monitors the wrist-flipping event, and then calls the front camera of the terminal device to capture images and recognize QR codes, thereby improving the recognition efficiency of QR codes.

[0142] For example, you can refer to Figure 5 Understand the processing flow of wrist flip code recognition. Figure 5 The processing flow diagram of wrist-turning code recognition provided in the embodiment of the present application is as follows Figure 1 .

[0143] like Figure 5 As shown, the terminal device's wrist-flipping code recognition can be decomposed into the following four steps: monitoring wrist-flipping events, identifying whether there is a code (identifying whether there is a QR code in the image obtained by the front camera), starting the code scanning service, and executing the code scanning process (the code scanning service module performs QR code recognition on the image obtained by the front camera).

[0144] In a possible implementation, the above four steps are respectively executed in the two process modules of the terminal device, namely, the code scanning intention module and the code scanning service module. Among them, the code scanning intention module is a resident process, which is responsible for monitoring whether there is a wrist flip event, identifying whether there is a QR code, and starting the code scanning service module after the code scanning intention module finds a code. The code scanning service module is a non-resident process, which is pulled up by the code scanning intention module. When there is a code, it executes the code scanning process and actively exits the process after completing the code scanning; when there is no code, the code scanning intention module notifies the process to exit.

[0145] Therefore, refer to Figure 5 It can be understood that the four steps described above are executed in series, that is, the code scanning intention module will identify whether there is a QR code in the image only after it monitors the wrist flip event. And the code scanning intention module will pull up the code scanning service module only after it finds the code, and then the code scanning service module will execute the code scanning process.

[0146] However, after the code is found, the scanning service module is pulled up to execute the scanning process. This will cause the step of pulling up the scanning service module to be executed separately, which adds more than 100 milliseconds of delay. Therefore, it will inevitably increase the end-to-end delay from the user triggering the wrist flip to the successful scanning of the code, which also increases the user's waiting time for scanning.

[0147] The delay problem of this possible implementation scheme can be solved by a two-dimensional code recognition method proposed in this application. The two-dimensional code recognition method provided by this application is introduced in combination with specific embodiments. It should be noted that the technical solutions introduced in each embodiment of this application are applied to terminal devices, and the terminal device may include a code scanning intention module and a code scanning service module, wherein the code scanning intention module is used to monitor wrist flip events, identify whether there is a code, and pull up the code scanning service module, and the code scanning service module is used to execute the code scanning process.

[0148] Combine the following Figure 6 and Figure 7 First of all, let me explain. Figure 6 A flowchart of the two-dimensional code recognition method provided in this application, Figure 7 The processing flow diagram of wrist-turning code recognition provided in the embodiment of the present application is as follows Figure 2 .

[0149] like Figure 6 As shown, the method includes:

[0150] S601. If the code scanning intention module monitors the wrist turning event, the first operation and the second operation are executed synchronously. The first operation includes: calling the first front camera of the terminal device to obtain an image and identifying whether there is a QR code in the image; the second operation includes: sending a startup instruction to the code scanning service module to start the code scanning service module.

[0151] The code scanning intention module can monitor the wrist turning event. When the code scanning intention module monitors the wrist turning event, the code scanning intention module synchronously executes two operations. In this embodiment, the two operations executed synchronously are called the first operation and the second operation.

[0152] Among them, the first operation that the code scanning intention module needs to perform includes: calling the first front camera of the terminal device to obtain an image, and identifying whether there is a QR code in the obtained image.

[0153] And, the second operation that the code scanning intention module needs to perform includes: sending a startup instruction to the code scanning service module to start the code scanning service module.

[0154] In this embodiment, in addition to pulling up the code scanning service module, the start instruction is also used to establish a binding relationship between the code scanning intention module and the code scanning service module. When the binding is successful, the code scanning intention module and the code scanning service module can exchange data.

[0155] You can refer to Figure 7 Further understanding of the parallel execution of the first operation and the second operation currently introduced, such as Figure 7 As shown, after executing the first step to monitor the wrist turning event, the first operation 2.1 (identifying whether there is a code) and the second operation 2.2 (starting the code scanning service module) are synchronously executed.

[0156] Because it takes a certain amount of time for the scanning intention module to identify whether there is a QR code in the image, the scanning service module is started while identifying whether there is a QR code. Therefore, during the entire wrist-flipping code recognition process, the time required to identify whether there is a QR code can cover the time required to start the scanning service module, thereby shortening the overall processing time of wrist-flipping code recognition.

[0157] And in a possible implementation, the first front camera in this embodiment is a relatively low-power camera, and the image frame rate captured by the first front camera is low. Therefore, when identifying whether there is a QR code, calling the first front camera to obtain the image and perform identification can effectively reduce the power consumption of the terminal device.

[0158] S602: If the code scanning intention module determines that there is a QR code in the image according to the first operation, a coded notification message is sent to the code scanning service module.

[0159] The code scanning intention module will execute the first operation to identify whether there is a QR code in the image. If the code scanning intention module determines that there is a QR code in the image obtained by the front camera according to the first operation introduced above, the code scanning intention module can send a coded notification message to the code scanning service module, where the coded notification message is used to notify the code scanning service module that a coded event is currently being monitored, and the coded event means that a QR code is recognized based on the image obtained by the first front camera.

[0160] Based on the above introduction, it can be determined that when the code scanning service module is started, a binding relationship will be established between the code scanning intention module and the code scanning service module, so that data interaction can be carried out. Therefore, as long as the code scanning intention module pulls up the code scanning service module, the code scanning intention module can directly send a coded notification message to the code scanning service module.

[0161] S603, the code scanning service module executes a code scanning process in response to the code notification message, and the code scanning process includes: calling the second front camera of the terminal device to obtain an image and identifying the QR code information in the image.

[0162] After receiving the coded notification message, the code scanning service module can respond to the coded notification message and execute the code scanning process. The code scanning process in this embodiment includes: calling the second front camera of the terminal device to obtain an image, identifying the QR code information in the image, and correspondingly Figure 7 Step 3 shown in the figure.

[0163] In a possible implementation, the second front camera in this embodiment is a relatively high power camera, and the image frame rate captured by the second front camera is relatively high. Specifically, the power consumption of the second front camera is higher than that of the first front camera, and the image frame rate captured by the second front camera is also higher than that of the first front camera. Therefore, performing QR code parsing based on the image acquired by the second front camera to obtain QR code information can effectively improve the recognition success rate and efficiency.

[0164] The QR code recognition method provided in this embodiment includes: if the code scanning intention module monitors the wrist turning event, the first operation and the second operation are synchronously executed, and the first operation includes: calling the first front camera of the terminal device to obtain an image and identifying whether there is a QR code in the image; the second operation includes: sending a startup instruction to the code scanning service module to start the code scanning service module. If the code scanning intention module determines that there is a QR code in the image according to the first operation, a coded notification message is sent to the code scanning service module. In response to the coded notification message, the code scanning service module executes the code scanning process, and the code scanning process includes: calling the second front camera of the terminal device to obtain an image and identifying the QR code information in the image. By synchronously executing the operations of identifying whether there is a QR code and starting the scanning service module when the scanning intention module listens to the wrist turning event, the time spent on starting the scanning service module can be saved, and the processing efficiency of wrist turning code recognition can be improved. When the subsequent scanning intention module determines that a QR code exists, it will inform the scanning service module of the code. The scanning service module executes the scanning process to realize the analysis of the QR code information. Therefore, it can effectively realize that the user can trigger the recognition of the QR code by turning his wrist, thereby effectively improving the recognition efficiency of the QR code.

[0165] On the basis of the above content, it is also necessary to explain that when the various steps in wrist-flipping code recognition are executed serially as described above, the states of the code scanning intention module and the code scanning service module are relatively few, and the relationship between the two modules is relatively simple. It can be understood that as long as the code scanning service module is started, the state of the code scanning intention module and the code scanning service module must be scanning, so no additional state maintenance is required.

[0166] Also, because the code scanning intention module and the code scanning service module are executed in two separate processes, when the code scanning service module is executing the code scanning process, the code scanning intention module can continue to monitor the wrist flip event and the code event. However, in the serial execution mode, as long as the code scanning intention module is successfully bound to the code scanning service module (the code scanning service module is started), the code scanning service module will start to execute the code scanning process, so the code scanning intention module will no longer process new wrist flip events or code events until the code scanning service module actively unbinds the code scanning process, or the code scanning intention module times out and notifies the code scanning service to unbind.

[0167] When serial execution becomes parallel execution, the startup of the code scanning service module does not necessarily mean that the code scanning process must be executed. Therefore, the number of states of the code scanning intention module and the code scanning service module will increase, and the relationship will become relatively complicated. In this case, if the states of the code scanning intention module and the code scanning service module are not maintained, it will cause confusion in the wrist flip code recognition logic, and at least the following situations may occur:

[0168] Case 1: When the code scanning service module has been started, the code scanning intention module monitors the code event, and the code scanning intention module is not sure whether it needs to notify the code scanning service module to execute the code scanning process.

[0169] Case 2: When the scanning intention module is triggered by the wrist flip to bind with the scanning service module, but the binding has not yet been successful, the scanning service module and the scanning intention module are actually unable to interact with each other. If a coded event is detected at this time, but the scanning intention module does not record the current status of the two modules (binding), the message of the coded event will be sent out, but in fact the message of the coded event cannot be sent to the scanning service module, so the coded event cannot be processed, which in turn causes the wrist flip code recognition to be invalid or fail.

[0170] Therefore, when the scanning intention module executes the steps of pulling up the scanning service module and identifying whether a QR code exists in parallel, it is also necessary to maintain the status of the scanning intention module and the scanning service module to ensure that the wrist-turning code recognition process can be executed correctly and orderly. When the number of states and the changing relationships between states increases, it is necessary to maintain and coordinate the changes and sequence of states.

[0171] In one possible implementation, a state machine is included in the code scanning intention module, which is used to record the common execution status of the code scanning intention module and the code scanning service module. It should be emphasized that the execution status here is an overall status common to the two modules. For example, if the status recorded by the execution machine is binding, it means that the current code scanning intention module and the code scanning service module are both performing binding operations.

[0172] In a possible implementation, the states that can be recorded in the state machine include the following: idle, binding, binding completed, and scanning.

[0173] Combine the following Figure 8 This chapter introduces the related execution process and state changes between the code scanning intention module and the code scanning attachment module. Figure 8 An interactive flow chart of the QR code recognition method provided in an embodiment of the present application.

[0174] like Figure 8 As shown, the method includes:

[0175] S801. The code scanning intention module monitors a wrist turning event.

[0176] The code scanning intention module can monitor wrist-turning events. In one possible implementation, if it is determined that the numerical value represented by the posture change information of the terminal device is greater than or equal to a first preset threshold and the screen direction is a direction other than the first direction, it is determined that a wrist-turning event is monitored, wherein the first direction is the positive direction of the z-axis of the world coordinate system.

[0177] In one example, an accelerometer and a gyroscope sensor are provided in the terminal device, and the acceleration sensor collects acceleration change data within a preset time period, and the gyroscope sensor collects angle change data within a preset time period; wherein the preset time period is a time period before the current moment. Then, the posture change information of the terminal device can be determined in the following manner: obtaining the acceleration change data collected by the accelerometer in the terminal device within the preset time period, and / or obtaining the angle change data collected by the gyroscope sensor in the terminal device within the preset time period; determining the posture change information according to the acceleration change data and / or the angle change data. wherein the posture change information represents the posture change angle of the terminal device, or the posture change information represents the rotation change angle of the terminal device.

[0178] In one example, when determining the screen direction of a terminal device, the following method can be used: obtain the angle data collected by the gyroscope sensor in the terminal device at the current moment; determine the screen direction of the terminal device based on the angle data. For example, the gyroscope sensor collects xyz axis data (that is, angle data) at the current moment; the terminal device obtains the xyz axis data collected by the gyroscope sensor, and then the terminal device determines the screen direction of the terminal device based on the xyz axis data, whether it is not facing the positive direction of the z axis of the world coordinate system, that is, whether the screen direction of the terminal device is not facing upward.

[0179] The “upward” direction of the screen of the terminal device means that the screen of the terminal device faces the “positive direction of the z-axis of the world coordinate system”; and the first direction refers to the positive direction of the z-axis of the world coordinate system.

[0180] The “downward” direction of the screen of the terminal device means that the screen of the terminal device faces the “negative direction of the z-axis of the world coordinate system”; and the second direction refers to the negative direction of the z-axis of the world coordinate system.

[0181] Based on the above principle, the terminal device determines that the terminal device has flipped over according to the value represented by the obtained posture change information, which is greater than or equal to the first preset threshold value; it can be known that the user holding the terminal device flips the wrist to flip the screen of the terminal device. In addition, the terminal device determines that the screen direction is a direction other than the first direction, and then determines that the screen direction of the terminal device is not facing upward. Then, the terminal device determines that a wrist flip event is monitored.

[0182] Therefore, in the present embodiment, when the terminal device determines that the terminal device is flipped over and the screen direction of the terminal device is not facing upward, it can determine that a wrist-flipping event has been monitored, and then adjust the front camera of the terminal device to capture an image and identify the QR code in the image, thereby avoiding the drawback that multiple human-computer interactions between the user and the terminal device are required to trigger the terminal device to identify the QR code, reducing the number of user operations, speeding up the efficiency of identifying the QR code, and improving the user experience.

[0183] S802, the code scanning intention module monitors whether there is a QR code.

[0184] After monitoring the wrist turning event, the code scanning intention module can start monitoring whether there is a QR code. Referring to the introduction of the above embodiment, the code scanning intention module can call the first front camera of the terminal device to obtain an image and identify whether there is a QR code in the image.

[0185] S803, the code scanning intention module sends a start instruction to the code scanning service module.

[0186] After monitoring the wrist turning event, the code scanning intention module can also send a startup instruction to the code scanning service module, where the startup instruction is used to pull up the code scanning service module and also to establish a binding relationship between the code scanning intention module and the code scanning service module.

[0187] Reference Figure 8 It can be confirmed that after the code scanning intention module monitors the wrist turning event, steps S802 and S803 are synchronously executed in parallel.

[0188] S804. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is binding.

[0189] After the scanning intention module sends a start instruction to the scanning service module, the scanning intention module can confirm that it is currently establishing a binding relationship with the scanning service module. Therefore, the scanning intention module can directly send a state modification instruction to the state machine in the scanning intention module. The state included in the state modification instruction is binding.

[0190] When the status recorded in the barcode scanner is binding, if the barcode scanning intention module monitors a new wrist flip event, the new wrist flip event will be ignored.

[0191] S805. The state machine changes the state of the record to binding.

[0192] The state machine responds to the state modification instruction in step S804 and modifies the state of the record to binding.

[0193] S806. The code scanning intention module obtains the binding result with the code scanning service module.

[0194] The code scanning intention module can obtain the binding result with the code scanning service module by callback, or the code scanning intention module can also receive the binding result sent by the code scanning service module. The binding result can be a successful binding or a failed binding.

[0195] S807, the code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is binding completed.

[0196] In one possible implementation, if the binding result received by the scanning intention module in S806 is a successful binding, the scanning intention module can confirm that the binding with the scanning service module is successful, so the scanning intention module can send a state modification instruction to the state machine, and the state included in the state modification instruction is binding completed.

[0197] Alternatively, if the binding result received by the scanning intention module in S806 is a binding failure, the scanning intention module can confirm that the binding with the scanning service module is not successful. At this time, the scanning intention module does not change the state in the state machine, and the state recorded in the state machine remains binding.

[0198] Afterwards, the scanning intention module can, for example, start the scanning service module again when it monitors a coded event, or the scanning intention module can also start the service module periodically within the preset maximum number of startup times until the scanning service module is successfully started or the state machine remains in the binding for more than the maximum time.

[0199] S808. The state machine changes the recorded state to binding completed.

[0200] The state machine responds to the state modification instruction in step S807 and modifies the state of the record to binding completed.

[0201] Based on the above description, it can be determined that steps S807 and S808 are executed only when the binding result is successful. Therefore, steps S807 and S808 are optional and are not steps that must be executed.

[0202] S809: The code scanning intention module monitors the code event.

[0203] After executing step S802, the code scanning intention module may obtain two results, one of which is introduced in the current S809. The code scanning intention module monitors the coded event. The coded event means that the code scanning intention module calls the first front camera of the terminal device to obtain an image and recognizes that there is a QR code in the image.

[0204] S810. The code scanning intention module obtains the status recorded in the state machine.

[0205] After the code scanning intention module monitors the code event, it needs to notify the code scanning service module that the code event is currently being monitored. Then it is necessary to ensure that the code scanning service module has been successfully started before it can send relevant notification messages.

[0206] Therefore, after the code scanning intention module monitors the code event, it can first obtain the status recorded in the state machine to confirm whether the code scanning service module has been started.

[0207] S811. The code scanning intention module determines whether the code scanning service module is started according to the status recorded in the state machine. If so, execute S816; if not, execute S812.

[0208] In a possible implementation, if the status recorded in the state machine is binding completed, it can be determined that the code scanning service module has been started, and then step S816 can be executed, that is, the code scanning intention module sends a coded notification message to the code scanning service module.

[0209] In another possible implementation, if the state recorded in the state machine is binding, it can be determined that the code scanning service module is not started, and then the following step S812 can be executed to start the code scanning service module again.

[0210] S812. The code scanning intention module sends a start instruction to the code scanning service module.

[0211] S813. The code scanning intention module obtains the binding result with the code scanning service module.

[0212] S814. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is binding completed.

[0213] S815. The state machine changes the recorded state to binding completed.

[0214] S812~S814 here are similar to the implementation methods of S803, S806, S807, and S808 introduced above. The specific implementation methods here are not repeated here. The difference is that the steps introduced in S812~S814 are operations performed again to start the scanning service module after monitoring the coded event and the scanning service module has not yet been started.

[0215] S816. The code scanning intention module sends a coded notification message to the code scanning service module.

[0216] After the code scanning service module is started, the code scanning intention module can send a coded notification message to the code scanning service module, where the coded notification message is used to inform the code scanning service module that a coded event has been monitored.

[0217] S817: The code scanning service module executes the code scanning process.

[0218] The code scanning service module executes the code scanning process in response to the code notification message.

[0219] S818. The code scanning service module sends a code scanning start message to the code scanning intention module.

[0220] When the code scanning service module starts to execute the code scanning process, it can send a code scanning start message to the code scanning intention module. The code scanning start message is used to inform the code scanning service module that the current code scanning service module has started the code scanning process.

[0221] S819. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is scanning code.

[0222] After receiving the code scanning start message, the code scanning intention module can confirm that the code scanning service module is already executing the code scanning process, so it can send a state modification instruction to the state machine, and the state included in the state modification instruction is scanning.

[0223] S820: The state machine changes the recorded state to scanning code.

[0224] The state machine responds to the state modification instruction in step S819 and modifies the recorded state to scanning code.

[0225] S821. The code scanning intention module monitors a new wrist flip event, a code event, or a no-code event.

[0226] S822: The code scanning intention module ignores the newly monitored event.

[0227] When the state recorded in the state machine is scanning code, if the scanning code intention module monitors new wrist flip events, code events or no code events, the scanning code intention module can directly ignore these newly monitored events because there is currently a scanning code process of a wrist flip event being executed.

[0228] In one possible implementation, when the code scanning intention module monitors a wrist flip event, a coded event, or an uncoded event, the state recorded in the state machine can be obtained. If the state recorded in the state machine is scanning a code, the code scanning intention module ignores the newly monitored event.

[0229] This can avoid the problem caused by situation 1 described above, that is, when the code scanning service module has been started, the code scanning intention module monitors the code event, and the code scanning intention module is not sure whether it needs to notify the code scanning service module to execute the code scanning process.

[0230] It is understandable that, because new events may not be monitored while scanning a code, steps S821 and S822 are also optional.

[0231] S823. The code scanning service module sends a code scanning success message or a timeout notification message to the code scanning intention module.

[0232] When the code scanning service module executes the code scanning process, there will be two results. One result is that the code scanning service module successfully parses the QR code information after executing the code scanning process. In this case, the code scanning service module can determine that the code scanning is successful and send a scanning success message to the code scanning intention module.

[0233] Another result is that the code scanning service module still fails to successfully parse the QR code information after the code scanning process times out. In this case, the code scanning service module can determine that the code scanning has failed and send a timeout notification message to the code scanning intent module.

[0234] In a possible implementation, if the code scanning service module still fails to successfully parse the QR code information after the code scanning process times out, the life cycle of the code scanning service module will also end.

[0235] Alternatively, in other implementations, the scanning intent module may monitor whether the scanning process of the scanning service module has timed out. If so, the scanning intent module sends a timeout notification message to the scanning service module, and then the scanning service module ends its life cycle.

[0236] S824. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is the idle state.

[0237] Regardless of whether the scanning intention module receives the scanning success message described above or the timeout notification message, it can be determined that the scanning service module has completed the scanning process for the wrist flip event monitored this time. Therefore, it is necessary to end the processing process for this wrist flip event and then send a state modification instruction to the state machine. The state contained in the state modification instruction is the idle state.

[0238] Or in an optional implementation, if the scanning intent module introduced above monitors whether the scanning process of the scanning service module has timed out, if it has timed out, the scanning intent module sends a timeout notification message to the scanning service module, and then the scanning service module ends its life cycle. In this case, the scanning intent module can send a state modification instruction to the state machine after sending the timeout notification message to the scanning service module, and the state included in the state modification instruction is the idle state.

[0239] S825. The state machine changes the recorded state to an idle state.

[0240] The state machine responds to the state modification instruction in step S825 and modifies the recorded state to an idle state.

[0241] S826: The code scanning intention module detects a no-code event.

[0242] As described above, after the scanning intention module executes step S802, two results may be obtained, and the other result is what is currently introduced in S826. The scanning intention module monitors the no-code event. The no-code event means that the scanning intention module calls the first front camera of the terminal device to obtain an image and recognizes that there is no QR code in the image.

[0243] S827. The code scanning intention module obtains the status recorded in the state machine.

[0244] After the code scanning intention module detects the no code event, it needs to notify the code scanning service module to end its life cycle. If notification is required, it is necessary to ensure that the code scanning service module has been successfully started before sending relevant notification messages.

[0245] Therefore, after the code scanning intention module monitors the no-code event, it can first obtain the status recorded in the state machine to confirm whether the code scanning service module has been started.

[0246] S828. The code scanning intention module determines whether the code scanning service module is started according to the status recorded in the state machine. If so, execute S829; if not, execute S823.

[0247] In one possible implementation, if the status recorded in the state machine is binding completed, it can be determined that the code scanning service module has been started, and then step S829 can be executed, that is, the code scanning intention module sends a code-free notification message to the code scanning service module.

[0248] In another possible implementation, if the state recorded in the state machine is binding, it can be determined that the code scanning service module is not started, and then the following step S832 can be executed.

[0249] S829. The code scanning intention module sends a code-free notification message to the code scanning service module.

[0250] Among them, the no-code notification message is used to inform the code scanning service module that no QR code has been recognized based on the image captured by the front camera.

[0251] S830: The scanning service module ends its life cycle.

[0252] The code scanning service module can end the life cycle of the code scanning service module in response to the no code notification message.

[0253] S831. The code scanning service module sends an end notification message to the code scanning intention module.

[0254] In a possible implementation, when the code scanning service module begins to end the life cycle, it can send an end notification message to the code scanning intent module to inform the code scanning intent module that the code scanning service module is performing an operation to end the life cycle.

[0255] Alternatively, the code scanning intention module can also obtain the end notification message of the code scanning service module through callback.

[0256] S832. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is the idle state.

[0257] There are two situations in the execution of the current step. One situation is that the code scanning intention module determines that the code scanning service module has ended its life cycle based on the end notification message, and then a state modification instruction can be sent to the state machine. The state contained in the state modification instruction is the idle state.

[0258] Another situation is that the state recorded in the state machine is binding. Then it is determined that the code scanning service module has not been started, and there is no need for the code scanning service module to end its life cycle. Therefore, a state modification instruction can be sent directly to the state machine, and the state contained in the state modification instruction is idle state.

[0259] S833. The state machine changes the recorded state to an idle state.

[0260] The state machine responds to the state modification instruction in step S825 and modifies the recorded state to an idle state.

[0261] In this embodiment, the state machine in the code scanning intention module records the common status of the code scanning intention module and the code scanning service module in various situations, so that the changes and sequence of the status can be maintained and coordinated in an orderly manner to ensure that the wrist flip code recognition process can be executed correctly and orderly.

[0262] Based on the content introduced in the above embodiment, when the code scanning intention module sends a start instruction to the code scanning service module, and before the binding is unsuccessful and has not timed out, the state recorded in the state machine remains in binding. Based on the above introduction, it can be determined that if a coded event or an uncoded event is monitored in the binding state, but the code scanning intention module does not record the current status of the two modules (binding), the code scanning intention module will send out a message of the coded event or the uncoded event, but in fact the message of the coded event cannot be sent to the code scanning service module, so it will cause the coded event to be unable to be processed, and then cause the wrist flip code recognition to fail or fail. The message situation of the uncoded event is similar, because it cannot be sent to the code scanning service module, resulting in the fact that the QR code is not recognized, but the code scanning intention module and the code scanning service module continue to maintain the binding state.

[0263] To solve this problem, this application also proposes a solution. Fig. 9 Make an introduction, Fig. 9 Interaction process provided for the embodiment of this application Figure 2 .

[0264] like Fig. 9 As shown, the method includes:

[0265] S901. The state recorded by the state machine is binding, and the code scanning intention module monitors the target event.

[0266] The situation described in this embodiment is that when the state recorded by the state machine is binding, the code scanning intention module monitors the target event, and the target event is a coded event or an uncoded event.

[0267] Based on the introduction of the above embodiments, it can be determined that in the process of wrist-flipping code recognition, there are many different situations that may cause the state machine to record the state as binding. Therefore, this embodiment does not limit whether the situation occurs before or after which step. In short, as long as the state recorded in the state machine is binding, the code scanning intention module monitors the target event, the technical solution introduced in this embodiment can be adopted.

[0268] In one possible implementation, after the code scanning intention module monitors the target event, it first obtains the status of the current record in the state machine. When it is determined that the status recorded in the state machine is binding, it is confirmed that it meets the conditions described in this embodiment, and then the operations described in the subsequent steps can be performed.

[0269] S902, the code scanning intention module caches the target event.

[0270] After monitoring the target event, the code scanning intention module in this embodiment can cache the monitored target event.

[0271] S903, the code scanning intention module times the cached target event.

[0272] After the caching is completed, the code scanning intention module starts timing the cached target event. The timing here specifically indicates the cache duration of the target event.

[0273] S904: When the timing reaches the preset duration, the code scanning intention module obtains the status recorded in the state machine.

[0274] The code scanning intention module continuously times the cached target event. When the timing of the target event reaches the preset duration, the code scanning intention module can obtain the current state recorded in the state machine. For example, the preset duration can be set to 50ms, and the specific preset duration can be set according to actual needs.

[0275] S905. The code scanning intention module determines whether the status is binding completed according to the status recorded in the state machine. If so, execute S906; if not, execute S907.

[0276] After that, it can be determined whether the current recorded state in the state machine is binding completed. In fact, it is to determine whether the code scanning service module is successfully started, that is, whether the binding between the code scanning intent module and the code scanning service module is successful.

[0277] S906. The code scanning intention module sends a coded notification message or a non-coded notification message to the code scanning service module.

[0278] In one possible implementation, if the current state recorded in the state machine is binding completion, it can be determined that the scanning service module is successfully started, then the scanning service module and the scanning intention module can interact with data, so the scanning intention module can inform the scanning service module of the cached target event, so that the scanning service module can perform the scanning process for the target event.

[0279] If the target event is a coded event, the code scanning intention module sends a coded notification message to the code scanning service module. In this case, step S906 in this embodiment and the above Figure 8 Step S816 in the embodiment is actually the same, so the subsequent related implementation after the code scanning intention module sends the coded notification message to the code scanning service module can refer to the introduction of the above embodiment, which will not be repeated here.

[0280] If the target time is a no-code event, the code scanning intention module sends a no-code notification message to the code scanning service module. In this case, step S906 in this embodiment and the above Figure 8 Step S829 in the embodiment is actually the same, so the subsequent related implementation after the code scanning intention module sends the code-free notification message to the code scanning service module can refer to the introduction of the above embodiment, which will not be repeated here.

[0281] In this embodiment, when the code scanning intention module determines that the state recorded in the state machine is binding completed, it sends a coded notification message or a non-coded notification message to the code scanning service module, thereby ensuring that the corresponding notification message can be sent to the code scanning service module, avoiding the problem of sending a coded notification message when the code scanning service module and the code scanning intention module have not established a binding relationship, causing the coded event to be invalid or invalid. Similarly, it avoids the problem of sending a non-coded notification message when the code scanning service module and the code scanning intention module have not established a binding relationship, causing the code scanning intention module and the code scanning service module to continue to maintain a binding state when the QR code is not recognized.

[0282] S907, the code scanning intention module determines whether the rotation number corresponding to the cached target event is greater than or equal to the preset number, if not, execute S908, if yes, execute S909.

[0283] In another possible implementation, if the current state recorded in the state machine is binding, it can be determined that the code scanning service module is still not started, so the code scanning service module and the code scanning intention module cannot interact with each other. In this embodiment, a certain number of rounds of waiting and judgment can be performed for a cached target event. Therefore, when the state recorded in the state machine is still binding, the code scanning intention module can determine whether the number of rotations corresponding to the cached target event is the preset number. For example, the preset number can be set to 10 times, and the specific preset number can be set according to actual needs.

[0284] S908: Increase the number of rotations by 1, and repeat the operations starting from S903.

[0285] If the number of rotations corresponding to the cache event is less than the preset number, the number of rotations corresponding to the cache event can be increased by 1, and the operation starting from S903 can be repeated, that is, the cache time is re-timed, and when the timing reaches the preset time, it is determined whether the state in the state machine is binding completed, thereby realizing a new round of judgment on the cache event.

[0286] Among them, the initial value of the rotation number of the cache event can be set to 1, for example, and the current plus 1 operation is executed once after each subsequent round of processing until the state in the state machine is binding completed, or until the rotation number of the cache event is greater than or equal to the preset number.

[0287] S909: The code scanning intention module discards the target event.

[0288] If the number of rotations corresponding to the cached event is greater than or equal to the preset number, it can be determined that enough rounds have been judged for the cached event. Then, considering a series of issues such as code recognition efficiency and system power consumption, the code scanning intention module can discard the target event.

[0289] S910. The code scanning intention module sends a state modification instruction to the state machine, and the state included in the state modification instruction is the idle state.

[0290] After the code scanning intention module discards the target event, it can send a state modification instruction to the state machine. The state included in the state modification instruction is the idle state.

[0291] S911. The state machine changes the recorded state to an idle state.

[0292] Afterwards, the state machine responds to the state modification instruction in S910 and changes the recorded state to the idle state, thereby avoiding the problem that the state of the code scanning intention module and the code scanning service module is in the binding state for a long time, but the binding cannot be completed, resulting in the inability to process subsequent target events.

[0293] In an embodiment of the present application, when the status recorded in the state machine is binding, if the scanning intent module monitors the target event, it will first cache and time the target event. When the timing reaches the preset time, it will determine whether the status recorded in the state machine is binding completed. When it is determined that the status is binding completed, a coded notification message or an uncoded notification message is sent to the scanning service module. This can ensure that the coded notification message or the uncoded notification message is sent when the scanning intent module and the scanning service module are able to interact, thereby avoiding the problem of the target event not being able to be notified to the scanning service module and becoming invalid, and avoiding the problem of the scanning intent module and the scanning service module continuing to remain in a bound state even if the QR code is not recognized. And when the state in the state machine is still in binding, it is further determined whether the number of rotations of the target event has reached the preset number. If not, the number of rotations can be increased by 1 before the next round of judgment. If it has reached the preset number, the target event is directly discarded, and the state recorded in the state machine is modified to the idle state, thereby effectively avoiding the long-term continuation of the binding state, which leads to the problem that subsequent target events and the overall process of wrist flip code recognition cannot be handled.

[0294] Based on the above introduction, the following does not consider the module interaction, combined with Fig.10 Simply give a further detailed introduction to the processing flow of wrist flip code recognition. Fig.10 A flowchart of a two-dimensional code recognition method provided in an embodiment of the present application.

[0295] like Fig.10 As shown, the process includes:

[0296] S1001. Determine whether the screen status of the terminal device is in a bright screen unlocked state. If so, execute S1002; if not, execute S1001.

[0297] In one example, the terminal device can obtain screen parameters through a software interface; since the screen parameters indicate that the terminal device is in a black screen state, a bright screen and unlocked state, or a bright screen and unlocked state, the terminal device can obtain the screen status according to the obtained screen parameters, and then determine whether the terminal device is in a bright screen and unlocked state according to the screen status.

[0298] If the screen status of the terminal device is in the bright screen and unlocked state, execute the subsequent steps. Otherwise, you can start from step S1001 again to ensure that when the terminal device is in the black screen state or the bright screen and unlocked state, the front camera will not be triggered to capture images, thereby avoiding meaningless triggering actions.

[0299] S1002, determine whether the terminal device is in the desktop state, if so, execute S1003, if not, execute S1001.

[0300] In one example, the terminal device can obtain the operating parameters through the software interface; since the operating parameters indicate that the terminal device is in the desktop state or the application running state, the terminal device can determine whether the terminal device is in the desktop state according to the operating parameters. Among them, being in the desktop state means that the terminal device currently has no other applications in the foreground.

[0301] If it is determined that the running status of the terminal device indicates that the terminal device is in a desktop state, the subsequent steps are executed. Otherwise, the execution can be started again from step S1001 to ensure that subsequent actions are performed only when the terminal device is in a desktop state, so as to avoid directly interrupting the operation of other applications when the terminal device is running other applications based on the foreground, causing abnormalities in other applications or the terminal device.

[0302] Exemplarily, step S1002 in this embodiment is an optional step. When the current judgment of S1002 is not performed, the subsequent steps can be implemented regardless of the operating state of the terminal device.

[0303] S1003, determine whether the terminal device detects a wrist-turning action, if so, execute S1004, if not, execute S1001.

[0304] In one example, the terminal device may obtain acceleration change data collected by an acceleration sensor in the terminal device within a preset period of time, and / or obtain angle change data collected by a gyroscope sensor in the terminal device within a preset period of time; determine posture change information based on the acceleration change data and / or the angle change data. If the value represented by the posture change information is greater than or equal to a first preset threshold, it is determined whether the terminal device detects a wrist flip action.

[0305] If it is determined that the terminal device detects the wrist turning action, the subsequent steps are executed, otherwise, the process can start from step S1001 again.

[0306] S1004, determining whether the current location information of the terminal device indicates that the terminal device is within a preset geographic fence, if so, executing S1005, if not, executing S1001.

[0307] Exemplarily, the terminal device may also obtain the current location information of the terminal device. The terminal device detects whether the terminal device is within the preset geographic fence according to the current location information. If it is determined that the terminal device is within the preset geographic fence, it is determined that the terminal device has entered the preset location, and the subsequent step S1005 is executed; if it is determined that the terminal device is not within the preset geographic fence, step S1001 is executed again.

[0308] Exemplarily, step S1004 is an optional step.

[0309] S1005. Determine whether the screen of the terminal device is facing upward. If so, execute S1006; if not, execute S1001.

[0310] In one example, the terminal device may obtain angle data collected by a gyroscope sensor in the terminal device at the current moment; and determine the screen direction of the terminal device based on the angle data.

[0311] If it is determined that the screen of the terminal device is facing upward, the subsequent steps are executed; otherwise, the process may start again from step S1001.

[0312] S1006: Determine whether the ambient light information of the terminal device is greater than or equal to a second preset threshold, if so, execute S1007, if not, execute S1001.

[0313] In one example, an ambient light sensor is provided in the terminal device, and the ambient light sensor can obtain ambient light data of the terminal device. Then, the terminal device obtains ambient light information based on the ambient light data at the current moment, and the ambient light information represents the ambient light value of the terminal device at the current moment.

[0314] If the value represented by the ambient light information is greater than or equal to the second preset threshold, it can be determined that the environment in which the terminal device is located is not a relatively dark environment, and it is possible to ensure that the front camera of the terminal device can capture a clear image, so the subsequent step S1008 can be executed. If the value represented by the ambient light information is less than the second preset threshold, step S1001 can be executed again. For example, the second preset threshold is 10 lux.

[0315] Exemplarily, step S1006 is an optional step.

[0316] And, in one example, if the terminal device determines that the value represented by the ambient light information is less than a second preset threshold, the terminal device can also automatically increase the screen brightness of the terminal device, thereby increasing the ambient light for the terminal device; at this time, the terminal device can increase the screen brightness of the terminal device to a brightness greater than or equal to the brightness indicated by the second preset threshold, and then execute the subsequent step S1008.

[0317] S1007: Access a first front camera of the terminal device to capture a first image at a first frame rate.

[0318] After the judgment of the above steps, if the judgment results of each step are all yes, it can be determined that the current processing scenario meets the wrist flip code recognition. In a possible implementation, the order of the above-mentioned judgment steps can be changed according to actual needs.

[0319] After that, the first front camera of the terminal device can be called to obtain a low frame rate image. In this embodiment, the first front camera is a low-power front camera. For example, the terminal device can call a low-power driver to drive the first front camera, and then capture the first image at the first frame rate. The first frame rate is less than the second frame rate described later; the first frame rate can also be set to be less than a preset frame rate threshold.

[0320] When the terminal device captures the first image at a low frame rate, the power consumption of the terminal device is relatively small, thereby reducing the power consumption of the device.

[0321] S1008. Determine whether there is a suspected two-dimensional code image in the first image. If so, execute S1009; if not, execute S1001.

[0322] Exemplarily, a neural network classification model (i.e., a first-level model) is deployed in the terminal device; the terminal device classifies and identifies the first image based on the neural network classification model to obtain a first recognition result, and the first recognition result indicates whether the target in the first image is a QR code; that is, the first recognition result indicates whether there is a suspected QR code image in the first image.

[0323] If the terminal device determines that there is a suspected two-dimensional code image in the first image, it executes subsequent steps; otherwise, it executes step S1101 again after a preset time interval.

[0324] The neural network classification model is obtained by training based on a first training set. The first training set includes a plurality of first training images, and the first training images are images marked with a QR code.

[0325] If it is determined that there is a suspected two-dimensional code image in the first image, the subsequent step S1009 is executed. If it is determined that there is no suspected two-dimensional code image, step S1001 can be executed again.

[0326] S1009: Determine the distance information between the terminal device and the suspected two-dimensional code image.

[0327] Exemplarily, if the terminal device determines that there is a suspected QR code image in the first image, the terminal device can measure the distance information between the terminal device and the suspected QR code image in the first image based on the time of flight (Time of Flight, referred to as tof) technology. If the terminal device determines that there is no suspected QR code image in the first image, step S1001 is performed again after a preset time interval.

[0328] S1010. Determine whether the distance information is less than or equal to a preset distance. If so, execute S1012; if not, execute S1011.

[0329] S1011. Generate and issue a first prompt message, where the first prompt message is used to prompt the front camera of the terminal device to be close to the suspected QR code image.

[0330] Exemplarily, if the terminal device determines that the distance information between the terminal device and the suspected QR code image in the first image is greater than a preset distance, it is determined that the terminal device is far away from the suspected QR code image; the terminal device needs to prompt the user to move the front camera of the terminal device close to the suspected QR code image, and the terminal device can generate and send a first prompt information, and the first prompt information includes one or more of the following: voice prompt, vibration prompt, and light prompt.

[0331] For example, the preset distance is a value range, and the value range is 15 cm to 40 cm. The viewing angle (FOV) of the camera in this application is 100.

[0332] S1012. Call the front camera of the terminal device to capture a second image at a second frame rate; wherein the first frame rate is lower than the second frame rate.

[0333] Exemplarily, after step S1010, or if it is determined that there is a suspected QR code image in the first image, step S1012 is performed. The terminal device calls the second front camera of the terminal device to acquire the second image at a second frame rate. The second frame rate is greater than the first frame rate; the second frame rate can also be set to be greater than or equal to a preset frame rate threshold.

[0334] After determining that there is a suspected QR code image in the first image, the terminal device can acquire a clear second image by capturing the second image at a high frame rate through the second front camera; and thus can effectively and accurately identify the QR code in the second image.

[0335] S1013: Execute a code scanning process for the acquired second image.

[0336] After the second image is acquired, a code scanning process is performed on the second image to parse the two-dimensional code information of the two-dimensional code in the second image.

[0337] Exemplarily, when executing the code scanning process, the terminal device can first detect the target on the second image based on the QR code recognition algorithm (i.e., the secondary model), then use the super-resolution method to enlarge the second image (based on the neural network to achieve), and then perform QR code decoding to obtain the second recognition result. Among them, the QR code decoding includes the following process: extracting the QR code area image, recognizing the QR code area image to obtain the second recognition result.

[0338] The two-dimensional code recognition algorithm is obtained by training based on a second training set. The second training set includes a plurality of second training images, and the second training images are high frame rate images with two-dimensional codes marked on them.

[0339] S1014: Determine whether the QR code information is recognized, if so, execute S1015, if not, execute S1001.

[0340] After the scanning process is completed, it can be determined whether the QR code information of the QR code in the second image is parsed. If the parsing is successful, the terminal device can, for example, pull up the interface of the application corresponding to the QR code information based on the deep link technology; and the terminal device can also send a notification prompt information, indicating that the service interface corresponding to the QR code information has been automatically pulled up. If the QR code information is not parsed, step S1001 can be performed again.

[0341] For example, for a QR code of a public account, the terminal device obtains a link (that is, QR code information) after recognizing the second image; the terminal device can display the article of the public account in the application based on the link.

[0342] against Fig.10 The process introduced below is combined with Fig.11 and Fig.12 Taking a specific application scenario as an example, the changes in the interface are explained exemplarily. Fig.11 A schematic diagram of an interface of a two-dimensional code recognition method provided in an embodiment of the present application Figure 1 , Fig.12 A schematic diagram of an interface of a two-dimensional code recognition method provided in an embodiment of the present application Figure 2 .

[0343] First, let’s introduce Fig.11 ,like Fig.11 As shown in (a), the terminal device is in the desktop state, that is, the terminal device does not run an application in the front end; at this time, the screen direction of the terminal device is upward (upward refers to the positive direction of the z-axis of the world coordinate system). Fig.11As shown in (b) in the figure, the user holding the terminal device turns his wrist, and the user turns the screen of the terminal device downward (the negative direction of the z-axis of the world coordinate system). Furthermore, according to the method provided in this embodiment, if it is determined that the terminal device is in a bright screen unlocked state, the terminal device is in a desktop state, the proximity light is not blocked (not a necessary condition), the screen direction is not facing upward, there is a wrist turn, the terminal device is within a preset geographic fence (not a necessary condition), and the value represented by the ambient light information is greater than or equal to a third preset threshold value (not a necessary condition), then the front camera is turned on to capture images and recognize the QR code. Then, as Fig.11 As shown in (c), the terminal device will not change Fig.11 The interface (a) in the figure still displays the desktop of the terminal device, but the terminal device uses the front camera of the terminal device to obtain the image in the background and recognizes the QR code information in the image in the background. Then, after the terminal device recognizes the QR code information, Fig.11 As shown in (d) in the figure, the terminal device directly calls up the interface corresponding to the QR code information, for example, the transfer interface of application A is displayed.

[0344] Again Fig.12 To introduce, such as Fig.12 As shown in (a), the terminal device is in the desktop state, that is, the terminal device does not run an application in the front end; at this time, the screen direction of the terminal device is upward (upward refers to the positive direction of the z-axis of the world coordinate system). Fig.12 As shown in (b), the user holding the terminal device turns his wrist, and the user turns the screen of the terminal device downward (the negative direction of the z-axis of the world coordinate system). Furthermore, according to the method provided in this embodiment, if it is determined that the terminal device is in a bright screen unlocked state, the terminal device is in a desktop state, the proximity light is not blocked (not a necessary condition), the screen direction is not facing upward, there is a wrist turn, the terminal device is within a preset geographic fence (not a necessary condition), and the value of the ambient light information is greater than or equal to a third preset threshold (not a necessary condition), then the front camera is turned on to capture images and recognize the QR code. Fig.12 As shown in (c) of the figure, the terminal device calls the front camera of the terminal device to obtain an image and recognize the QR code information in the image. The terminal device can display a code scanning interface. Then, after the terminal device recognizes the QR code information, Fig.12 As shown in (d) in the figure, the terminal device directly calls up the interface corresponding to the QR code information, for example, the transfer interface of application A is displayed.

[0345] Fig.11 and Fig.12The situations described above are all triggered when the terminal device is in desktop state. However, based on the above description, it can be determined that the terminal device being in desktop state is optional, that is, the wrist flip code recognition can also be triggered when the terminal device is not in desktop state. For example, Fig.11 and Fig.12 In the example, if a video playback application is running in the foreground, the figure (a) corresponds to the video playback interface, which can also trigger subsequent related operations. Its implementation method is similar to that described above and will not be repeated here.

[0346] Therefore, in the technical solution of the present application, it is possible to directly determine to call the front camera to collect images and identify the QR code information according to the operating status and posture information of the terminal device. It is no longer necessary for the user to perform a series of touch operations on the terminal device to trigger the terminal device to scan the QR code. This saves the time of identifying the QR code and improves the efficiency of QR code recognition.

[0347] The two-dimensional code recognition method provided in the embodiment of the present application can be applied to electronic devices with communication functions. The electronic devices include terminal devices, and the specific device form of the terminal device can refer to the above related descriptions, which will not be repeated here.

[0348] An embodiment of the present application provides a terminal device, which includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the above method.

[0349] The embodiment of the present application provides a chip. The chip includes a processor, and the processor is used to call a computer program in a memory to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.

[0350] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. The above method is implemented when the computer program is executed by the processor. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

[0351] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the required program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave) is used to transmit software from a website, server or other remote source, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVD), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer-readable media.

[0352] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.

[0353] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0354] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.

Claims

1. A two-dimensional code recognition method, characterized in that: Applied to a terminal device, the terminal device includes a code scanning intention module and a code scanning service module, and the method includes: If the code scanning intention module monitors the wrist turning event, the first operation and the second operation are synchronously executed, wherein the first operation includes: calling the first front camera of the terminal device to acquire an image and identifying whether there is a QR code in the image; the second operation includes: sending a start instruction to the code scanning service module to start the code scanning service module; If the code scanning intention module determines that there is a QR code in the image according to the first operation, a coded notification message is sent to the code scanning service module; The code scanning service module executes a code scanning process in response to the coded notification message, and the code scanning process includes: calling the second front camera of the terminal device to obtain an image and identifying the two-dimensional code information in the image.

2. The method according to claim 1, characterized in that: The code scanning intention module includes a state machine; After sending the start instruction to the code scanning service module, the method further includes: The code scanning service module modifies the state recorded in the state machine to binding; If the code scanning intention module monitors a new wrist turning event, the new wrist turning event is ignored.

3. The method according to claim 2, characterized in that After sending the start instruction to the code scanning service module, the method further includes: The code scanning intention module obtains the binding result of starting the code scanning service module; If the binding result indicates that the binding is successful, the code scanning intention module modifies the state recorded in the state machine to binding completed.

4. The method according to claim 2 or 3, characterized in that: Before sending the coded notification message to the code scanning service module, the method further includes: The code scanning intention module obtains the state recorded in the state machine; The sending of a coded notification message to the code scanning service module includes: If the state recorded in the state machine is binding completed, the code scanning intention module sends a coded notification message to the code scanning service module.

5. The method according to claim 4, characterized in that The method further comprises: If the state recorded in the state machine is binding, the code scanning intention module resends a start instruction to the code scanning service module; The code scanning intention module obtains the binding result of starting the code scanning service module; If the binding result indicates that the binding is successful, the code scanning intention module modifies the state recorded in the state machine to binding completed; The code scanning intention module sends a coded notification message to the code scanning service module.

6. The method according to any one of claims 2 to 5, characterized in that: The method further comprises: When the code scanning service module starts to execute the code scanning process, the code scanning service module sends a code scanning start message to the code scanning intention module; The code scanning intention module modifies the state recorded in the state machine to code scanning according to the code scanning start message.

7. The method according to claim 6, characterized in that The method further comprises: When the status recorded in the barcode scanner is scanning, the barcode scanning intention module monitors any of the following events: wrist turning event, code event, no code event, and ignores the monitored event.

8. The method according to any one of claims 2 to 7, characterized in that: After the code scanning service module executes the code scanning process in response to the coded notification message, the method further includes: The code scanning service module determines that the code scanning is successful, and sends a code scanning success message to the code scanning intention module; or, The code scanning service module determines that the code scanning process has timed out and sends a timeout notification message to the code scanning intention module.

9. The method according to claim 8, characterized in that The method further comprises: The code scanning intention module modifies the state recorded in the state machine to an idle state in response to the code scanning success message or the timeout notification message.

10. The method according to any one of claims 2 to 9, characterized in that: The method further comprises: If the code scanning intention module determines that there is no QR code in the image according to the first operation, then obtaining the state recorded in the state machine; If the state recorded in the state machine is binding completed, the code scanning intention module sends a code-free notification message to the code scanning service module; The code scanning service module responds to the code-free notification message, ends the life cycle of the code scanning service module, and sends an end notification message to the code scanning intention module; The code scanning intention module modifies the state recorded in the state machine to an idle state according to the end notification message.

11. The method according to claim 10, characterized in that The method further comprises: If the state recorded in the state machine is binding, the code scanning intention module modifies the state recorded in the state machine to idle state.

12. The method according to any one of claims 2 to 11, characterized in that: The method further comprises: When the state recorded in the state machine is binding, if the code scanning intention module monitors a target event, the target event is cached and timed, and the target event is a coded event or an uncoded event; When the timing of the target event reaches a preset duration, obtaining the state recorded in the state machine; If the state recorded in the state machine is that the binding is completed, a coded notification message or a non-coded notification message is sent to the code scanning service module; If the state recorded in the state machine is binding, determine whether the number of rotations for the target event is greater than or equal to the preset number. If so, discard the target event and modify the state recorded in the state machine to the idle state. If not, add 1 to the number of rotations and restart the timing, and repeat the operation of obtaining the state recorded in the state machine when the timing for the target event reaches the preset duration, until the state recorded in the state machine is binding completed, or the number of rotations for the target event is greater than or equal to the preset number.

13. The method according to any one of claims 1 to 12, characterized in that: The monitoring of the wrist turning event includes: If it is determined that the value represented by the posture change information is greater than or equal to a first preset threshold and the screen direction is a direction other than the first direction, it is determined that a wrist flip event is monitored, wherein the first direction is the positive direction of the z-axis of the world coordinate system.

14. A terminal device, characterized in that: include: Processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method according to any one of claims 1 to 13.

15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.