Image processing method, electronic device and storage medium

By detecting wrist turning movements in electronic devices and focusing within the preset focus range, it solves the problem of slow focusing speed in electronic device shooting scenes, achieves rapid acquisition of clear images, and improves image recognition rate and user experience.

CN117998203BActive Publication Date: 2024-09-06HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410398184.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2024-09-06
Estimated Expiration
2044-04-03

AI Technical Summary

Technical Problem

It is difficult for electronic equipment to focus quickly in the shooting scene, resulting in the captured images being easily blurred and affecting the image recognition rate.

Method used

By detecting wrist turning movements, the front camera is controlled to focus within the preset focus range, and the contrast detection autofocus mode is used to obtain images and determine the target focus position, thereby improving the autofocus speed and image clarity.

Benefits of technology

It realizes the rapid shooting of clear images in electronic devices, improves the recognition rate of images, simplifies the user's shooting process, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117998203B
    Figure CN117998203B
Patent Text Reader

Abstract

The present application provides an image processing method, an electronic device and a storage medium, and relates to the field of terminal technology. The method includes: in the process of displaying a first interface, a wrist-turning action is detected. In response to the wrist-turning action, the front camera is controlled to focus within a preset focus range, and the preset focus range represents the range of change of the focus position of the front camera, and the preset focus range is within the inherent focus range of the front camera. A first image captured by the front camera at the target focus position is obtained, and the first image is recognized, and a second interface is displayed according to the recognition result of the first image. In this way, the automatic focusing rate of the electronic device can be improved, and the recognition rate of the image can be 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 an image processing method, an electronic device and a storage medium. Background Art

[0002] With the development of electronic devices, more and more functions are provided by electronic devices. The shooting function is one of the frequently used functions in electronic devices. Users can use the shooting function of electronic devices to shoot and obtain images. In order to provide users with a more convenient shooting function, the camera in the electronic device can automatically focus to further simplify the shooting process.

[0003] However, in some shooting scenarios, it is difficult for electronic devices to quickly focus on the subject, and the captured images are easily blurred. Summary of the invention

[0004] The present application provides an image processing method, an electronic device and a storage medium, which are used to improve the autofocus rate of the electronic device and quickly capture clear images.

[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] In a first aspect, an image processing method is provided, the method comprising: in the process of displaying a first interface by an electronic device, if a wrist-turning action is detected, in response to the wrist-turning action, controlling a front camera to focus within a preset focus range, acquiring a first image captured by the front camera at a target focus position, the target focus position being a focus position where the contrast of the image is a maximum value or greater than a preset contrast. Further, the electronic device recognizes the first image, and displays a second interface according to the recognition result of the first image.

[0007] In this method, the preset focus range represents the range of variation of the focus position of the front camera. The preset focus range is within the inherent focus range of the front camera, that is, the preset focus range is a true subset of the inherent focus range of the front camera. For example, the lower limit of the preset focus range is greater than the lower limit of the inherent focus range, and the upper limit of the preset focus range is less than the upper limit of the inherent focus range. By limiting the focus position of the electronic device to the preset focus range, the electronic device only focuses within the preset focus range during the automatic focusing process. In this way, the automatic focusing rate of the electronic device can be improved, so that the electronic device can quickly capture a clear image, thereby improving the image recognition rate.

[0008] In a possible implementation of the first aspect, the electronic device uses a security preview pipeline to control the front camera to focus within a preset focus range. The security preview pipeline is used to provide a contrast detection autofocus mode, and the contrast detection autofocus mode is used to automatically focus according to the contrast of the image.

[0009] In this implementation method, the electronic device controls the focus of the front camera through the contrast detection autofocus mode provided by the security preview pipeline. The security preview pipeline can provide a security preview mode to improve the security of image acquisition. In some examples, due to the limitations of the processing chip of the electronic device, the security preview pipeline only supports the contrast detection autofocus mode and does not support other focus modes. When the security preview pipeline is used, the electronic device focuses through the contrast detection autofocus mode.

[0010] In another possible implementation of the first aspect, the front camera includes a motor and a lens, the motor is connected to the lens, and the motor is used to drive the lens to move. The electronic device uses a security preview pipeline to control the motor of the front camera to drive the lens to move within a preset position interval to obtain multiple second images. When the lens of the front camera moves within the preset position interval, the focus position of the front camera changes within a preset focus range, so that the electronic device achieves a change in the focus position by adjusting the lens position. Further, the electronic device focuses according to the contrast of the multiple second images. For example, the electronic device determines the focus position corresponding to the second image when the contrast in the multiple second images is greater than the preset contrast as the target focus position, and the focus is completed. Alternatively, the electronic device determines the focus position corresponding to the second image when the contrast in the multiple second images is a maximum or maximum value as the target focus position, and the focus is completed.

[0011] In another possible implementation of the first aspect, the electronic device acquires multiple second images in a non-preview state, where the non-preview state indicates that the image captured by the front camera is not displayed. It is understandable that the electronic device uses a secure preview pipeline to control the autofocus of the front camera, and the autofocus process of the front camera will not be presented to the user. In this way, the security of image acquisition can be improved, and the image recognition process can be shielded for the user, thereby improving the user experience.

[0012] In another possible implementation of the first aspect, the preset focus range is 20 cm to 40 cm. In this way, the preset focus range can cover the focus positions that users are accustomed to, thereby providing convenience for users and improving their usage experience.

[0013] In another possible implementation of the first aspect, the first image includes a QR code. The electronic device displays a second interface indicated by the recognition result according to the recognition result of the QR code. In this way, the electronic device can provide a wrist-flip code scanning function.

[0014] In another possible implementation of the first aspect, in response to a wrist-flipping action, intelligent perception information is obtained, and the intelligent perception information is used to indicate a perception function triggered by the wrist-flipping action. When the intelligent perception information indicates a first perception function, the front camera is controlled to focus within a preset focus range. The first perception function is a code scanning function, such as the first perception function is the above-mentioned wrist-flipping code scanning function. By indicating the perception function triggered by the wrist-flipping action through the intelligent perception information, the electronic device can quickly identify the perception function set by the user.

[0015] In another possible implementation of the first aspect, if the electronic device determines a target focus position within a preset focus range, a first image captured by the front camera at the target focus position is acquired, and first prompt information is generated, where the first prompt information is used to indicate that focus has been completed.

[0016] In this implementation, the electronic device sends a prompt message to the user when the front camera focuses on the subject, and reminds the user that the focus has been completed through the prompt message. The user no longer needs to keep the posture of focusing on the subject, which improves the user's experience.

[0017] In another possible implementation of the first aspect, if the target focus position is not determined within the preset focus range, a second prompt message is generated, and the second prompt message is used to prompt the user to move the front camera so that the front camera determines the target focus position within the preset focus range.

[0018] In this implementation, the electronic device sends a prompt message to the user when the front camera fails to focus on the subject, and can remind the user to focus the front camera on the subject by changing the shooting position of the front camera, thereby saving the user's waiting time and improving the user's usage experience.

[0019] In a second aspect, the present application provides an electronic device, comprising: a front camera, a memory, a processor, and a computer program stored in the memory. The front camera and the memory are respectively coupled to the processor. The front camera is a zoom camera for capturing images. When the processor runs the computer program, the electronic device executes the method described in the first aspect and any possible implementation thereof.

[0020] In a third aspect, the present application provides a computer-readable storage medium storing a computer program. When the computer program is executed by an electronic device, the electronic device executes the method described in the first aspect and any possible implementation thereof.

[0021] In a fourth aspect, the present application provides a computer program product including program instructions, including a computer program, which, when executed by an electronic device, enables the computer to execute the method described in the first aspect and any possible implementation thereof. For example, the computer may be the electronic device described above.

[0022] In a fifth aspect, the present application provides a chip system, which is applied to an electronic device. The chip system includes an interface circuit and a processor. The interface circuit and the processor are interconnected by a line. The interface circuit is used to receive a signal from a memory and send a signal to the processor, the signal including a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device executes the method described in the first aspect and any possible implementation thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of a wrist-flipping code scanning scenario provided in an embodiment of the present application;

[0024] Figure 2 A hardware structure block diagram of a mobile phone 100, an example of an electronic device provided in an embodiment of the present application;

[0025] Figure 3 A software structure block diagram of a mobile phone 100, an example of an electronic device provided in an embodiment of the present application;

[0026] Figure 4 A flowchart of an image processing method provided in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of a wrist-flipping code scanning function setting provided in an embodiment of the present application;

[0028] Figure 6 A schematic diagram of a two-dimensional code image clarity comparison provided in an embodiment of the present application;

[0029] Figure 7 A schematic diagram of a comparison of two-dimensional code image recognition rates provided in an embodiment of the present application;

[0030] Figure 8 A flowchart of another image processing method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to provide users with a better user experience, the shooting function of electronic devices is used in a variety of application scenarios. In some application scenarios, the shooting function of electronic devices is combined with the wrist-turning action to enable the wrist-turning action to trigger image recognition. Specifically, when the electronic device detects the wrist-turning action, it calls the front camera, collects images through the front camera, and recognizes the collected images.

[0032] In one example, take the application scenario where a user uses an electronic device to scan a QR code to pay as an example. Figure 1 As shown, the user holds the electronic device and flips it. The electronic device detects the wrist flipping action, starts the front camera, and collects an image including the QR code through the front camera. Further, the electronic device recognizes the QR code in the image and displays the payment interface according to the recognition result. In this way, the wrist flipping action can trigger the code scanning function (which can be referred to as the wrist flipping code scanning function).

[0033] In another example, let's take the application scenario of face unlocking as an example. The user holds the electronic device and flips it. If the electronic device detects the wrist flipping action, it collects the user's face image through the front camera and recognizes the face image. If the recognition result of the face image indicates that the face in the face image is the target face, the electronic device is unlocked. In this way, the wrist flipping action can trigger the face unlocking function (which can be referred to as the wrist flip unlocking function).

[0034] In the application scenario where the wrist-flipping action triggers image recognition, the electronic device uses a front camera to capture images. The front camera configured in the electronic device can be a fixed-focus camera or a zoom camera. The lens and focal length of a fixed-focus camera are fixed, and the user needs to adjust the shooting distance between the electronic device and the subject to enable the electronic device to focus on the subject. The lens position and focal length of a zoom camera are variable, and the electronic device can automatically adjust the lens position to enable the electronic device to automatically focus on the subject.

[0035] Autofocus methods include Contrast Detection Auto Focus (CDAF) and Phase Detection Auto Focus (PDAF).

[0036] Contrast detection autofocus can be referred to as contrast focus or contrast focus. Contrast detection autofocus is a method of autofocusing based on the contrast of an image. The contrast of an image is one of the parameters used to measure image clarity. During the autofocus process, the electronic device gradually moves the lens and obtains the contrast of the image. When the contrast of the image is at a maximum value, the image is clearest, and it can be considered that the subject is in focus.

[0037] Phase detection autofocus can be referred to as phase focus. Phase detection autofocus is a method of automatically focusing based on the phase of light collected by the camera. When light enters the camera lens at different angles, there will be a phase difference. The phase difference of light can reflect the focus of the camera. When the phase difference of light is the smallest, the camera of the electronic device focuses on the subject, and the image captured at this time is the clearest.

[0038] In the application scenario where the wrist-flipping action triggers image recognition, the electronic device controls the front camera's autofocus through the SecurePreview pipeline. The SecurePreview pipeline only supports contrast detection autofocus, not phase detection autofocus. In this case, when the electronic device detects the wrist-flipping action, it calls the front camera through the SecurePreview pipeline and controls the front camera to focus on the subject using contrast detection autofocus to capture a clear shot of the subject.

[0039] However, the focus rate of the contrast detection autofocus method is low, and the electronic device needs to move the lens of the front camera step by step to adjust the focus position of the front camera. During the movement of the lens, the electronic device needs to compare the contrast of the images collected at different focus positions to determine the focus position when the contrast is the maximum value (the focus position is the focus position focused on the subject). The contrast calculation of the image is easily affected by jitter or changes in the lighting of the shooting environment, which makes it difficult for the electronic device to focus on the subject. In the application scenario where the wrist flip action triggers image recognition (which can be referred to as the wrist flip recognition scenario), the electronic device may slow down the focus rate through contrast detection autofocus, and the electronic device is prone to capture blurred images, making the image difficult to recognize. In addition, when the objects in the captured picture correspond to multiple depths of field, the electronic device may focus on distant objects and cause close objects to be out of focus, making it difficult for the electronic device to recognize close objects.

[0040] In view of this, an embodiment of the present application provides a method that can improve the focus rate of contrast detection autofocus of an electronic device in a wrist flip recognition scenario. Specifically, when the electronic device detects a wrist flip action, the electronic device controls the front camera to focus within a preset focus range and determines a target focus position. The target focus position is the focus position when the front camera focuses on the subject. The electronic device obtains a first image captured by the front camera at the target focus position and recognizes the first image. Furthermore, the electronic device displays an interface based on the recognition result of the first image.

[0041] The preset focus range is used to indicate the range of change of the focus position of the front camera. By limiting the focus position of the electronic device to the preset focus range, the electronic device only focuses within the preset focus range during the autofocus process. In this way, the autofocus rate of the electronic device can be improved, so that the electronic device can quickly capture a clear image, thereby improving the image recognition rate.

[0042] For example, the electronic device described in the embodiments of the present application may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) / virtual reality (VR) device, a media player, a wearable device, etc. The embodiments of the present application do not impose any special restrictions on the specific form of the electronic device.

[0043] In the embodiment of the present application, the electronic device is a mobile phone 100 as an example, and the hardware structure of the electronic device is introduced through the mobile phone 100. Figure 2 As shown, the mobile phone 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.

[0044] 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 memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), a driver processor, etc. Different processing units may be independent devices or integrated into one or more processors. The processor 110 may be the nerve center and command center of the mobile phone 100. The processor 110 may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0045] 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 directly called from the memory. In this way, repeated access is avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.

[0046] The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the mobile phone 100 by running the instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 may execute the instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area.

[0047] The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), a configuration file of the motor 191, etc. The data storage area may store data created during the use of the mobile phone 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0048] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. While the charging management module 140 charges the battery 142, it can also power the mobile phone 100 through the power management module 141.

[0049] The wireless communication function of the mobile phone 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor. In some embodiments, the antenna 1 of the mobile phone 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the mobile phone 100 can communicate with the network and other devices through wireless communication technology.

[0050] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the mobile phone 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.

[0051] The wireless communication module 160 can provide wireless communication solutions applied to the mobile phone 100, including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc.

[0052] In some implementations, the mobile phone 100 can access a network, such as a 5G network or a Wi-Fi network, through the mobile communication module 150 or the wireless communication module 160, and display interfaces through the connected network, such as a payment interface, a taxi-hailing interface, etc.

[0053] The mobile phone 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor, etc. For example, music playing, recording, etc. In some implementations, when the front camera of the mobile phone 100 is not focused on the shooting object, the mobile phone 100 can play prompt information to the user through the speaker 170A, such as playing voice prompt information. In this way, the mobile phone 100 can remind the user to adjust the shooting position of the mobile phone 100 through the played prompt information.

[0054] The sensor module 180 may include sensors such as a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a Hall sensor, a touch sensor, an ambient light sensor, and a distance sensor. The mobile phone 100 may collect various data through the sensor module 180 .

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

[0056] The acceleration sensor can detect the magnitude of the acceleration of the mobile phone 100 in various directions (generally three axes). When the mobile phone 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the mobile phone 100 and applied to applications such as horizontal and vertical screen switching and pedometer.

[0057] In some implementations, the mobile phone 100 can detect the wrist turning action through the angular velocity data collected by the gyroscope sensor and the acceleration data collected by the acceleration sensor.

[0058] The distance sensor can be used to measure the distance. The distance sensor can be an infrared distance sensor, an activation distance sensor, etc. The mobile phone 100 can measure the distance by infrared or laser. In some implementations, the mobile phone 100 can use the distance sensor to measure the distance to achieve fast focus. In other implementations, the mobile phone 100 can use the distance sensor to measure the distance from the shooting object to the camera. When the distance is greater than the upper limit of the preset focus range or the camera does not shoot the shooting object, the mobile phone 100 sends a prompt message to the user, reminding the user to adjust the shooting position of the camera through the prompt message.

[0059] The mobile phone 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 that execute program instructions to generate or change display information.

[0060] 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.

[0061] In some implementations, the touch sensor may be disposed in the display screen 194, and the touch sensor and the display panel may form a touch screen, also known as a "touch screen". The touch sensor, also known as a "touch panel", is used to detect touch operations on or near it, such as click operations, sliding operations, etc. The touch sensor may transmit the detected touch operations to the application processor to determine the type of touch event. The mobile phone 100 may provide visual output related to the touch operation through the display screen 194.

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

[0063] The ISP is used to process the data fed back by the camera 193. For example, when the mobile phone 100 takes 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 the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

[0064] 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 transmits 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 mobile phone 100 may include one or more cameras 193. The camera 193 may be a front camera or a rear camera.

[0065] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. In some implementations, when the front camera of the mobile phone 100 focuses on the subject, the motor 191 can generate vibrations to prompt the user that the subject has been focused.

[0066] It is understandable that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device. In other embodiments, the electronic device may also include more or fewer modules than those provided in the above embodiments, and different interface connection methods in the above embodiments may be used between the modules, or a combination of multiple interface connection methods. The hardware structure of the electronic device provided in the embodiments of the present application can also refer to the hardware structure of the mobile phone 100. The methods in the following embodiments can all be implemented in an electronic device having the above hardware structure.

[0067] The software system of the electronic device may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture or a cloud architecture. In the embodiment of the present application, the electronic device is the mobile phone 100, and the software system of the electronic device adopts the layered architecture of the Android system as an example to illustrate the software structure of the electronic device.

[0068] The layered architecture of the mobile phone 100 is divided into several layers, each layer has a clear role and division of labor, and the layers communicate with each other through software interfaces. Figure 3 1 is a software structure diagram of the mobile phone 100 according to an embodiment of the present application. Exemplarily, the Android system may include an application layer, an application framework layer, a hardware abstraction layer (HAL) and a kernel layer.

[0069] The application layer may include a series of applications installed in the mobile phone 100. For example, the application layer of the mobile phone 100 includes applications such as camera applications, smart sensing applications, and payment applications, and the present application embodiment does not impose any limitation on this.

[0070] 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. For example, the application framework layer may include a camera server, a window management service, etc., and the embodiments of the present application do not impose any restrictions on this.

[0071] The hardware abstraction layer encapsulates the Linux kernel driver, provides an interface to the upper layer, and shields the implementation details of the underlying hardware. For example, the hardware abstraction layer may include the camera hardware abstraction layer, etc. The camera hardware abstraction layer includes the camera provider. The camera provider is used to provide a calling interface to the camera server. The camera provider includes an auto focus (AF) module. The auto focus module is used to provide auto focus algorithms such as contrast detection auto focus algorithm and phase detection auto focus algorithm.

[0072] The kernel layer is the layer between hardware and software. The kernel layer includes drivers and system service programs. Drivers include at least camera drivers, video drivers (Video for Linux2, V4L2), sensor drivers, etc. The camera driver is used to provide drivers for the camera. The camera driver includes an image sensor module (which can be recorded as sensor, also known as a photosensitive element), a motor module (which can be recorded as actuator), a storage module (which can be recorded as eeprom), and an optical image stabilizer module (which can be recorded as ois). Among them, the image sensor module is used to control the image sensor of the camera to convert the optical signal received by the camera into an electrical signal. The motor model is used to control the motor of the camera to drive the lens to move to adjust the focus position of the camera. The storage module is used to control the memory of the camera (such as Electrically ErasableProgrammable Read Only Memory (EEPROM)) to store the electrical signal obtained by the image sensor, that is, the image data. The optical image stabilizer module is used to control the optical image stabilizer (OIS) of the camera to compensate for the optical axis offset of the lens.

[0073] It is understandable that the layered architecture illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device. In other embodiments, the electronic device may also include more or fewer software layers than those provided in the above embodiments. For example, the layered architecture of the electronic device may also include an Android runtime and a system library. The Android runtime is responsible for the scheduling and management of the Android system. The system library may include multiple functional modules, such as a surface manager, a media library, and the like.

[0074] For ease of understanding, the following embodiments of the present application are based on the electronic device having Figure 2 and Figure 3 Taking the mobile phone 100 of the structure shown as an example, the software and hardware interaction process of the mobile phone 100 is explained in combination with the application scenario of scanning a code by turning the wrist.

[0075] When the mobile phone 100 detects a wrist-flipping motion based on the angular velocity data collected by the gyroscope sensor and the acceleration data collected by the acceleration sensor while displaying the first interface, the smart perception application responds to the wrist-flipping motion and notifies the camera server of the wrist-flipping code scanning event. In response to the wrist-flipping code scanning event, the camera application transmits the wrist-flipping code scanning event to the camera provider in the camera hardware abstraction layer. In response to the wrist-flipping code scanning event, the camera provider uses the contrast detection autofocus algorithm to call the camera driver through the video driver. The camera module of the mobile phone 100 controls the front camera to start, and uses the contrast detection autofocus algorithm to automatically focus on the QR code to achieve QR code scanning.

[0076] In the following embodiments, the electronic device is a mobile phone 100 as an example, and the method provided by the embodiment of the present application is exemplarily introduced in combination with the wrist scanning scenario. Figure 4 As shown, the method provided in the embodiment of the present application includes the following steps:

[0077] S401, the mobile phone 100 displays a first interface.

[0078] The mobile phone 100 displays a first interface under user operation. For example, the first interface is a desktop interface, a web browsing interface, etc.

[0079] In the wrist scanning scenario, in order to reduce the probability of accidental touches when scanning the code by turning the wrist, in some implementations, the first interface displayed by the mobile phone 100 is a non-lock screen interface. The first interface is different from the lock screen interface. For example, when the mobile phone 100 is locked, it receives the user's unlocking operation. In response to the user's unlocking operation, the mobile phone 100 is unlocked. After unlocking, the mobile phone 100 displays the first interface.

[0080] S402, during the display of the first interface, the mobile phone 100 responds to the wrist flipping action and determines whether the smart perception information indicates a first perception function.

[0081] The wrist-turning action can be understood as the action of flipping the mobile phone 100. For example, the wrist-turning action may include a horizontal flipping action (such as the action of flipping the mobile phone 100 from the display screen facing up to the display screen facing down), a vertical flipping action (such as the action of flipping the mobile phone 100 from the top facing up to the top facing down), etc. In the process of displaying the first interface, the mobile phone 100 can detect the wrist-turning action according to the angular velocity data and acceleration data of the mobile phone 100. The mobile phone 100 collects the angular velocity data of the mobile phone 100 through the gyroscope sensor, and collects the acceleration data of the mobile phone 100 through the acceleration sensor. The angular velocity data collected by the gyroscope sensor may include three-axis (i.e., x-axis, y-axis, and z-axis) angular velocity data. The three-axis angular velocity data is the angular velocity data of the three coordinate axes of the gyroscope sensor's own coordinate system. The acceleration data collected by the acceleration sensor may include three-axis (i.e., x-axis, y-axis, and z-axis) acceleration data. The three-axis acceleration data is the acceleration data of the three coordinate axes of the acceleration sensor's own coordinate system. In order to facilitate the processing of angular velocity data and acceleration data and reflect the posture of the mobile phone 100, in some implementations, the coordinate system of the gyroscope sensor and the coordinate system of the acceleration sensor can be consistent with the coordinate system of the mobile phone 100.

[0082] In some implementations, the mobile phone 100 can use a preset model to detect the wrist-flipping action. The preset model is used to detect the wrist-flipping action. For example, the preset model is a trained machine learning model. The preset model can be obtained by training the machine learning model for multiple rounds based on the positive sample data of the wrist-flipping action (including the angular velocity data and acceleration data collected when the mobile phone 100 is in the wrist-flipping action) and the first label of the positive sample data (such as a label indicating the wrist-flipping action), as well as the negative sample data of the non-wrist-flipping action (including the angular velocity data and acceleration data collected when the mobile phone 100 is in the non-wrist-flipping action) and the second label of the negative sample data (such as a label indicating the non-wrist-flipping action). The mobile phone 100 inputs the angular velocity data and acceleration data collected at the same time or the same time period into the preset model to obtain the detection result output by the preset model. The detection result is used to indicate whether the wrist-flipping action is detected.

[0083] In other implementations, the mobile phone 100 determines whether the change angle of the orientation of the mobile phone 100 within the first preset time length is greater than the preset angle based on the angular velocity data and acceleration data collected within the first preset time length (such as 1 second, 0.5 seconds, etc.). The orientation of the mobile phone 100 is a direction perpendicular to the plane where the display screen of the mobile phone 100 is located. The orientation can be the same as or opposite to the direction of light emitted from the display screen of the mobile phone 100. If the change angle of the orientation of the mobile phone 100 within the first preset time length is greater than the preset angle, such as greater than 90 degrees, it can be considered that the mobile phone 100 has detected a wrist flip action.

[0084] It is understandable that the gyroscope sensor of the mobile phone 100 can continuously collect angular velocity data at a certain frequency. Correspondingly, the acceleration sensor of the mobile phone 100 can also continuously collect acceleration data at a certain frequency. In this way, the mobile phone 100 can detect the wrist-turning action of the mobile phone 100 in real time based on the angular velocity data and the acceleration data. The collection frequency of the angular velocity data and the collection frequency of the acceleration data can be the same or different. In some implementations, the mobile phone 100 needs to scan the QR code only after it is unlocked. The mobile phone 100 can obtain the angular velocity data collected by the gyroscope sensor and the acceleration data collected by the acceleration sensor when it is in the unlocked and bright screen state, and detect the wrist-turning action based on the angular velocity data and the acceleration data.

[0085] In response to the wrist-turning action, the mobile phone 100 obtains the smart perception information and determines whether the smart perception information indicates the first perception function. The smart perception information is used to indicate the perception function triggered by the wrist-turning action. For example, the wrist-turning action of the mobile phone 100 can trigger perception functions such as scanning a code or displaying a QR code (or simply a bright code) of the smart perception application. The smart perception information can be the first information (such as "0") or the second information (such as "1"). The first information and the second information are different. If the smart perception information is the first information, the smart perception information indicates the first perception function. If the smart perception information is the second information, the smart perception information indicates the second perception function.

[0086] The first sensing function is a code scanning function. The first sensing function is a code scanning function triggered by a wrist flipping action, and can also be called a wrist flipping code scanning function. The second sensing function is a sensing function different from the first sensing function. For example, the second sensing function is a code highlighting function. The second sensing function is a code highlighting function triggered by a wrist flipping action, and can also be called a wrist flipping code highlighting function.

[0087] If the smart sensing information indicates the first sensing function, it means that the mobile phone 100 has turned on the wrist scanning function, and the mobile phone 100 executes S403.

[0088] If the smart perception information indicates the second perception function, it means that the mobile phone 100 has turned on other perception functions besides the wrist-flipping code scanning function, such as the wrist-flipping code display function. In this case, the mobile phone 100 executes the process corresponding to the other perception function. Taking the second perception function as the wrist-flipping code display function as an example, the mobile phone 100 further displays the QR code, such as the payment code.

[0089] In some implementations, the mobile phone 100 can set the intelligent perception information according to the user operation. Figure 5As shown, the setting page of the mobile phone 100 includes WLAN options, Bluetooth options, mobile network options and options for the smart perception function (or perception function) (such as the "smart perception" option). In response to the user operation of the user clicking the "smart perception" option, the mobile phone 100 jumps to the smart perception page. The smart perception page includes the switch options of scanning the code by turning the wrist and the switch options of showing the code by turning the wrist. If the mobile phone 100 receives the user operation of clicking the switch option of scanning the code by turning the wrist when the function of scanning the code by turning the wrist is not turned on, the function of scanning the code by turning the wrist is turned on, and the smart perception information is set as the first information. If the mobile phone 100 receives the user operation of clicking the switch option of showing the code by turning the wrist when the function of showing the code by turning the wrist is not turned on, the function of showing the code by turning the wrist is turned on, and the smart perception information is set as the second information. The function of scanning the code by turning the wrist and the function of showing the code by turning the wrist cannot be turned on at the same time.

[0090] In the above example, the mobile phone 100 enters the smart perception page in response to the user operation of the user clicking the "Smart Perception" option in the setting page. In other examples, when the smart perception function is not turned on in the mobile phone 100, the mobile phone 100 can pop up a setting message for the smart perception function in the interface after detecting the wrist flipping action. For example, a setting message for the smart perception function pops up at the top of the interface. The setting message is used to remind the user to turn on the smart perception function. If the mobile phone 100 receives the user operation of the user clicking the setting message, the mobile phone 100 displays the smart perception page. In this way, the mobile phone 100 can provide the user with a shortcut to enter the smart perception page, so that the user can quickly turn on the smart perception function.

[0091] S403, the mobile phone 100 controls the front camera to focus within a preset focus range.

[0092] The mobile phone 100 includes a front camera. The front camera is a camera that is arranged on the same side as the display screen (or main screen) of the mobile phone 100. For example, the front camera is arranged on the side of the mobile phone 100 that displays the first interface. The preset focus range is used to indicate the range of change of the focus position of the front camera. The focus position of the front camera is the position or distance of the focus of the front camera on the optical axis relative to the optical center of the lens. The preset focus range can be set according to the actual application scenario or demand. The preset focus range is from the first focus position to the second focus position. The second focus position is greater than the first focus position. The first focus position is the lower boundary of the preset focus range, and the second focus position is the upper boundary of the preset focus range. For example, in the wrist-flipping code scanning scenario, when the user holds the mobile phone 100 to scan the QR code, the distance between the QR code and the mobile phone 100 is approximately between 20 cm and 40 cm. The first focus position can be set to 20 cm, and the second focus position can be set to 40 cm, that is, the preset focus range can be set to 20 cm to 40 cm. In this way, the preset focus range can cover the focus position that the user is accustomed to, and the mobile phone 100 controls the front camera to automatically focus within 20 cm to 40 cm based on the contrast detection automatic focus algorithm.

[0093] The preset focus range is within the inherent focus range of the front camera. The inherent focus range of the front camera is from the third focus position to the fourth focus position. The fourth focus position is greater than the third focus position. The third focus position is the lower boundary of the inherent focus range, and the fourth focus position is the upper boundary of the inherent focus range. The first focus position of the preset focus range is greater than the third focus position of the inherent focus range, and the second focus position of the preset focus range is less than the fourth focus position of the inherent focus range. The inherent focus range of the front camera is related to the hardware configuration of the front camera. For example, the inherent focus range of the front camera is from 11 cm to infinity. In the embodiment of the present application, the mobile phone 100 controls the front camera to focus within the preset focus range. Compared with focusing within the inherent focus range of the front camera, the movement range of the lens of the front camera can be shortened, and the rate of automatic focusing of the mobile phone 100 can be accelerated.

[0094] It is understandable that the focus of the camera includes the object focus and the image focus. With the optical center of the lens as the midpoint, the optical center divides the optical axis of the lens into two parts, one part is the part of the photographed object, and the other part is the imaging part. The object focus is the focus of the part of the optical axis where the photographed object is located. The image focus is the focus of the imaging part on the optical axis. The focus described in the embodiment of the present application is the object focus. When the front camera is focused, the focus position of the front camera is the position of the object focus on the optical axis. For example, taking the optical center of the lens as the origin and the direction on the optical axis away from the optical center as the positive direction. The focus position of the front camera is the position of the object focus on the optical axis.

[0095] In some implementations, the mobile phone 100 uses a secure preview pipeline to control the front camera to focus within a preset focus range. The secure preview pipeline is used to provide a contrast detection auto focus mode. For example, the camera provider of the mobile phone 100 uses a secure preview pipeline to control the front camera to focus within a preset focus range through a contrast detection auto focus mode.

[0096] In this implementation, the contrast detection autofocus mode is used to automatically focus according to the contrast of the image. The security preview pipeline of the mobile phone 100 controls the front camera to gradually change the focus position with a preset moving step (such as 1 cm) during the autofocus process, and collects the second image at different focus positions. The front camera can collect the second image at different focus positions at a preset frequency (such as 30 frames per second). The focus positions corresponding to the multiple second images collected by the front camera of the mobile phone 100 are different. The mobile phone 100 calculates the contrast of each second image. The mobile phone 100 further performs autofocus according to the contrast of each second image.

[0097] For example, the mobile phone 100 determines the contrast of the second image based on the brightness difference between the maximum brightness value and the minimum brightness value of the second image. The contrast may be equal to the ratio of the brightness difference of the image to the brightness sum. Among them, the brightness difference of an image is the difference between the maximum brightness value and the minimum brightness value of the image; the brightness sum of an image is the sum of the maximum brightness value and the minimum brightness value of the image. Further, the mobile phone 100 compares the contrast of each second image and searches for the focus position corresponding to the second image whose contrast is a maximum value. The focus position corresponding to the second image whose contrast is a maximum value can be considered as the focus position focused on the photographed object, and this focus position can be called the target focus position.

[0098] It is understandable that the secure preview pipeline can provide a secure preview mode. In the secure preview mode, the mobile phone 100 obtains multiple second images captured by the front camera in a non-preview state. The non-preview state can be understood as a state in which the second image captured by the front camera is not displayed. The second image captured by the mobile phone 100 through the front camera will not be presented to the user, and the mobile phone 100 will not display a preview window of the second image on the display screen.

[0099] Of course, in addition to the security preview pipeline, there is also a general preview pipeline (such as PreviewPipeline) in the mobile phone 100. The general preview pipeline is used to obtain multiple images captured by a camera (such as a front camera or a rear camera) in the preview state. The preview state can be understood as the state of displaying the image captured by the camera. The image captured by the mobile phone 100 through the camera will be presented to the user, and the mobile phone 100 will display a preview window of the image on the display screen during the autofocus process. The general preview pipeline supports the phase detection autofocus mode. For example, in the selfie scene, the mobile phone 100 responds to the user operation of the user clicking the camera application, and uses the preview pipeline to control the front camera to focus in the inherent focus range through the phase detection autofocus mode, and displays the image captured by the camera in the preview window. After the front camera focuses on the shooting object (such as a face), the mobile phone 100 can also display a focus frame in the preview window, and indicate the shooting object currently focused on by the focus frame.

[0100] In the embodiment of the present application, the mobile phone 100 uses a security preview pipeline to control the front camera auto focus, and the process of the front camera auto focus will not be presented to the user. In this way, the security of QR code scanning can be improved, and the process of QR code scanning can be shielded for the user, thereby improving the user experience.

[0101] In some implementations, the mobile phone 100 may determine the focus position corresponding to the second image whose contrast is the maximum value among the multiple second images as the target focus position. For example, the focus position is used as the independent variable and the contrast of the image is used as the dependent variable. In the process of controlling the focus of the front camera by the mobile phone 100, the contrast changes as the focus position changes within the preset focus range. The focus position of the front camera increases from the minimum value of the preset focus range. As the focus position gradually increases, if the contrast of the second image first increases and then decreases, the maximum value of the contrast can be determined. The maximum value of the contrast is the maximum value within the interval where the contrast first increases and then decreases. The mobile phone 100 may determine the focus position corresponding to the maximum value of the contrast as the target focus position. After determining the target focus position, the mobile phone 100 may also control the motor of the front camera to push the lens back to the focus position when the contrast is the maximum value. In this implementation, the image captured by the front camera at the target focus position is the clearest. The target focus position can be considered as the focal position for precise focus.

[0102] In order to further improve the focusing speed of the front camera, the mobile phone 100 can determine the focus position corresponding to the second image when the contrast is greater than the preset contrast as the target focus position when the contrast of the second image changes as the focus position gradually increases. In this implementation, the image captured by the front camera at the target focus position may not be the clearest image, but it does not affect the effect of image recognition. The target focus position can be considered as the focal position during rough focus.

[0103] The following is an example of how the mobile phone 100 controls the automatic focus of the front camera through the security preview pipeline. The front camera includes a motor and a lens. The motor of the front camera is connected to the lens to drive the lens to move and change the focus position of the front camera.

[0104] In this example, the camera provider of the mobile phone 100 responds to the wrist scanning event and uses the contrast detection autofocus mode supported by the security preview pipeline to control the front camera to focus within a preset focus range. During the autofocus process, the motor of the front camera drives the lens to move within a preset position interval. The preset position interval represents the range of changes in the lens position. For example, the motor of the front camera starts to push the lens to move from the minimum value of the preset position interval. The lens position gradually increases from the minimum value of the preset position interval. The preset position interval corresponds to a preset focus range. When the lens of the front camera moves in the preset position interval, the focus position of the front camera changes within the preset focus range. The autofocus module of the camera provider determines the target focus position based on the contrast of the second image captured by the front camera at different focus positions.

[0105] It can be understood that the preset position interval is used to indicate the change interval of the lens position. There is a corresponding relationship between the focal position and the lens position. The motor of the front camera drives the lens to move, the lens position changes, and the focal position also changes accordingly. Exemplarily, the lens position can be represented by a position parameter. The preset position interval is from the first position parameter value of the position parameter to the second position parameter value. The second position parameter value is less than the first position parameter value. The first position parameter value is the lower boundary (i.e., the minimum value) of the preset position interval, and the second position parameter value is the upper boundary (i.e., the maximum value) of the preset position interval. For example, taking the first position parameter value as 50 and the first position parameter value as 100 as an example, the preset position interval is the position parameter from 50 to 100. If the preset focus range is 20 cm to 40 cm, the first position parameter value 50 corresponds to the first focus position of 20 cm, and the second position parameter value 100 corresponds to the second focus position of 40 cm.

[0106] S404, the mobile phone 100 determines whether the front camera has completed focusing.

[0107] If the mobile phone 100 finds the target focus position within the preset focus range according to the contrast of the second image, it can be considered that the front camera has completed focusing. For example, if during the process of focusing the front camera, the mobile phone 100 finds the target focus position when the contrast is greater than the preset contrast, it is considered that the front camera has completed focusing. Alternatively, if during the process of focusing the front camera, the mobile phone 100 finds the target focus position when the contrast is a maximum value, it is considered that the front camera has completed focusing.

[0108] If the mobile phone 100 does not find the target focus position within the preset focus range, it can be considered that the front camera has not completed the focus. For example, if during the process of focusing the front camera, the mobile phone 100 does not find the target focus position when the contrast is greater than the preset contrast, it is considered that the front camera has not completed the focus. Alternatively, if during the process of focusing the front camera, the mobile phone 100 does not find the target focus position when the contrast is a maximum value, it is considered that the front camera has not completed the focus.

[0109] If the mobile phone 100 has completed focusing, the mobile phone 100 executes S405.

[0110] If the mobile phone 100 has not completed the focusing, the mobile phone 100 may return to S403 and continue to focus within the preset focusing range to determine the target focusing position.

[0111] In some implementations, if the mobile phone 100 focuses on the photographed object (i.e., the QR code) within the preset focus range, that is, the mobile phone 100 has completed the focus, the mobile phone 100 may also generate a first prompt message. The first prompt message is used to prompt that the photographed object has been focused. The first prompt message may be a voice prompt, a vibration prompt, a text message prompt, etc. For example, if the mobile phone 100 focuses on the photographed object within the preset focus range, the mobile phone 100 sends a vibration prompt to notify the user that the focus has been completed through the vibration prompt.

[0112] By sending a prompt message to the user when the front camera focuses on the subject, the user can be reminded that the focus is completed. The user no longer needs to keep holding the mobile phone 100 and aiming it at the subject, thereby improving the user experience.

[0113] In other implementations, if the mobile phone 100 fails to focus on the photographed object (i.e., the QR code) within the preset focus range, that is, the mobile phone 100 fails to complete the focus, the mobile phone 100 may also generate a second prompt message. The second prompt message is used to prompt the user to move the front camera so that the front camera focuses on the photographed object within the preset focus range. The second prompt message may be a voice prompt, a vibration prompt, a text message prompt, etc. For example, if the focus time of the mobile phone 100 reaches the second preset time and the focus has not been completed, the mobile phone 100 sends a second prompt message.

[0114] In one example of this implementation, the mobile phone 100 may set a position sensor near the front camera, or the mobile phone 100 sets a position sensor in the front camera. The position sensor is used to measure the distance from the photographed object to the front camera. If the distance from the photographed object to the front camera is greater than the upper limit of the preset focus range, that is, the distance from the photographed object to the front camera is greater than the second focus position, the mobile phone 100 sends a second prompt message to the user to prompt to shorten the distance between the photographed object and the front camera. If the distance from the photographed object to the front camera is less than the lower limit of the preset focus range, that is, the distance from the photographed object to the front camera is less than the first focus position, the mobile phone 100 sends a second prompt message to the user to prompt to increase the distance between the photographed object and the front camera.

[0115] By sending a prompt message to the user when the front camera is not focused on the subject, the user can be reminded to change the shooting position of the front camera to make the front camera focus on the subject, thereby saving the user's waiting time and improving the user's usage experience.

[0116] S405, the mobile phone 100 obtains a first image captured by the front camera at the target focus position.

[0117] When the mobile phone 100 completes focusing and determines the target focus position, the camera provider of the mobile phone 100 obtains a first image captured by the front camera at the target focus position, and transmits the first image to the smart perception application.

[0118] In some implementations, after the mobile phone 100 determines the target focus position within the preset focus range, it can control the motor of the front camera to drive the lens to move to the lens position corresponding to the target focus position, and capture an image at the target focus position to obtain a first image. The first image is an image captured by the front camera at the target focus position, and can provide a clearer QR code image.

[0119] S406, the mobile phone 100 recognizes the first image, and displays a second interface according to the recognition result of the first image.

[0120] After acquiring the first image, the mobile phone 100 identifies the photographed object (i.e., the QR code) in the first image and obtains the recognition result of the QR code. For example, the smart perception application of the mobile phone 100 parses the QR code in the first image and obtains the information carried in the QR code (i.e., the recognition result of the QR code). The information carried in the QR code can be text, a URL, a link to an application or a mini-program (such as a link to a shared bicycle mini-program, a link to a payment application), etc. The mobile phone 100 displays the second interface on the display screen according to the information carried in the QR code. For example, taking the example that the information carried in the QR code is a link to a payment application, after parsing the information carried in the QR code, the mobile phone 100 jumps to the payment interface of the payment application.

[0121] In the embodiment of the present application, the wrist-flipping scanning scenario is taken as an example to introduce the process of the mobile phone 100 controlling the front camera to scan the code by triggering the wrist-flipping action. During the front camera scanning process, the focus position of the front camera is limited to a preset focus range, thereby increasing the autofocus rate of the mobile phone 100, allowing the mobile phone 100 to quickly capture a clear QR code and improve the recognition rate of the QR code.

[0122] For example, in terms of image clarity, when the mobile phone 100 does not use the method provided in the embodiment of the present application to shoot a QR code, the mobile phone 100 shoots a QR code image such as Figure 6 When the mobile phone 100 uses the method provided in the embodiment of the present application to shoot a QR code, the mobile phone 100 shoots a QR code image as shown in (1). Figure 6 As shown in (2). It can be seen that the two-dimensional code image captured by the method provided in the embodiment of the present application is clearer.

[0123] In addition, in terms of image recognition rate, when the mobile phone 100 does not use the method provided in the embodiment of the present application to shoot the QR code, the recognition rate of the mobile phone 100 of model 1 that successfully recognizes the QR code image is as follows: Figure 7 As shown in (1). Taking the number of times of scanning the QR code by turning the wrist 20 times as an example, the mobile phone 100 successfully identified the QR code 1 16 times out of 20 times (recorded as 16 / 20), and the recognition rate of QR code 1 was 80%; the mobile phone 100 successfully identified the QR code 2 13 times out of 20 times (recorded as 13 / 20), and the recognition rate of QR code 2 was 65%; the mobile phone 100 successfully identified the QR code 3 10 times out of 20 times (recorded as 10 / 20), and the recognition rate of QR code 3 was 50%. When the mobile phone 100 adopts the method provided in the embodiment of the present application to shoot the QR code, the recognition rate of the model 1 mobile phone 100 that successfully identifies the QR code image is as follows: Figure 7As shown in (2). Taking the number of times of scanning the QR code by turning the wrist 40 times as an example, the mobile phone 100 successfully identified QR code 1 37 times out of 40 times (recorded as 37 / 40), and the recognition rate of QR code 1 was 92.5%; the mobile phone 100 successfully identified QR code 2 38 times out of 40 times (recorded as 38 / 40), and the recognition rate of QR code 2 was 95%; the mobile phone 100 successfully identified QR code 3 38 times out of 40 times (recorded as 38 / 40), and the recognition rate of QR code 3 was 95%. When the mobile phone 100 adopts the method provided in the embodiment of the present application to shoot the QR code, the recognition rate of the model 2 mobile phone 100 that successfully identifies the QR code image is as follows: Figure 7 As shown in (3). Taking the number of times of scanning the QR code by turning the wrist 20 times as an example, the mobile phone 100 successfully recognized QR code 1 20 times (recorded as 20 / 20), and the recognition rate of QR code 1 was 100%; the mobile phone 100 successfully recognized QR code 2 19 times (recorded as 19 / 20), and the recognition rate of QR code 2 was 95%; the mobile phone 100 successfully recognized QR code 3 19 times (recorded as 19 / 20), and the recognition rate of QR code 3 was 95%.

[0124] It can be seen that the method provided in the embodiment of the present application can improve the recognition rate of successful recognition of QR codes.

[0125] Now let’s combine the above Figure 3 The software structure of the mobile phone 100 shown in FIG. 1 is an exemplary introduction to the process of the steps executed by the mobile phone 100 in the wrist scanning scenario. Figure 8 As shown, the method provided in the embodiment of the present application includes:

[0126] S801, the smart perception application obtains smart perception information in response to the wrist flip event.

[0127] A wrist flip event is an event triggered by a wrist flip action. The smart perception application can receive wrist flip events reported by other modules. For example, the sensor driver or sensor hub (or sensor hub) of the mobile phone 100 identifies the wrist flip action based on acceleration data and angular velocity data. When a wrist flip action is identified, the sensor driver or sensor hub of the mobile phone 100 reports the wrist flip event corresponding to the wrist flip action to the smart perception application.

[0128] S802: If the smart perception information indicates the first perception function, the smart perception application notifies the camera server of the wrist-flipping code scanning event corresponding to the first perception function.

[0129] The first perception function is a code scanning function. When the smart perception information indicates the first perception function, the smart perception application determines that the wrist flip event is a wrist flip code scanning event corresponding to the wrist flip code scanning function, and notifies the camera server of the wrist flip code scanning event.

[0130] S803, the camera server notifies the camera provider of the wrist-flip code scanning event.

[0131] The camera server serves as the interface between the smart perception application and the camera provider, and transmits the wrist scanning event notified by the smart perception application to the camera provider.

[0132] S804, in response to the wrist-flipping code scanning event, the camera provider uses the security preview pipeline to control the front camera to focus within a preset focus range, and obtains a first image captured by the front camera at a target focus position.

[0133] The camera provider creates a secure preview use case object (such as UsecaseSecurePreview) in response to the wrist scanning event. The secure preview use case object uses the secure preview pipeline to call the algorithm autofocus module. The autofocus module controls the front camera to focus within the preset focus range based on the contrast detection autofocus algorithm, and determines the target focus position of the front camera to focus on the QR code. The camera provider obtains the first image captured by the front camera at the target focus position.

[0134] S805: The camera provider transmits the first image to the smart perception application.

[0135] S806, the intelligent perception application recognizes the QR code in the first image.

[0136] The smart perception application analyzes the QR code in the first image to obtain a recognition result of the QR code. The recognition result of the QR code can be text, a website, a link to an application or a mini-program (such as a link to a shared bicycle mini-program, a link to a payment application), etc.

[0137] S807, when the recognition result of the QR code indicates a payment application, the smart sensing application calls the payment application, causing the mobile phone 100 to display a payment interface of the payment application.

[0138] When the recognition result of the QR code indicates the payment application, the smart perception application calls the payment application. The payment application further sends a payment interface display request to other processes (such as a display manager) so that the mobile phone 100 displays the payment interface of the payment application.

[0139] It should be noted that the personal information used in the technical solution of this application is limited to information for which the individual's separate consent has been obtained, including but not limited to notifying and reminding the user to read the relevant user agreement (notification) and sign the agreement (authorization) including authorization of relevant user information before the user uses the function.

[0140] In some other embodiments of the present application, an electronic device is provided, including: a front camera, a memory, a processor, and a computer program stored in the memory. The front camera is a zoom camera for capturing images. When the computer program is executed by the processor, the electronic device can perform each function or step in the above method embodiment. Of course, the electronic device can also include other hardware structures. For example, the electronic device also includes hardware structures such as sensors and communication modules. The structure of the electronic device can refer to Figure 2 The structure of the mobile phone 100 is shown.

[0141] The embodiment of the present application also provides a chip system, which is applied to an electronic device. The chip system includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected through lines. For example, the interface circuit can be used to receive signals from other devices (such as memories). For another example, the interface circuit can be used to send signals to other devices (such as processors). Exemplarily, the interface circuit can read a computer program stored in the memory and send the computer program to the processor. When the computer program is executed by the processor, the electronic device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiment of the present application.

[0142] An embodiment of the present application also provides a computer-readable storage medium, which includes a computer program. When the computer program runs on the above-mentioned electronic device, the electronic device executes each function or step in the above-mentioned method embodiment.

[0143] The embodiment of the present application also provides a computer program product, which includes a computer program, and when the computer program is run on a computer, the computer executes each function or step in the above method embodiment. For example, the computer may be the above electronic device.

[0144] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0145] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0146] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0147] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0148] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0149] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered within the protection scope of the present application.

Claims

1. An image processing method, characterized in that: Applied to an electronic device, the electronic device includes a front camera, and the front camera is a zoom camera; the method includes: During the display of the first interface, a wrist-turning action is detected; In response to the wrist-turning action, the front camera is controlled to focus within a preset focus range, wherein the preset focus range represents a range of change of the focus position of the front camera, the preset focus range is within the inherent focus range of the front camera, the preset focus range covers the focus position that users are accustomed to, and the preset focus range is set at 20 cm to 40 cm; the controlling the front camera to focus within the preset focus range includes: using a security preview pipeline to control the focus position of the front camera to change within the preset focus range; acquiring multiple second images captured by the front camera within the preset focus range; and determining a target focus position according to the contrast of the multiple second images; Acquire a first image captured by the front camera at the target focus position, wherein the target focus position is a focus position where the contrast of the image is a maximum value or greater than a preset contrast; identifying the first image; A second interface is displayed according to the recognition result of the first image.

2. The method according to claim 1, characterized in that The front camera includes a motor and a lens, the motor is connected to the lens, and the motor is used to drive the lens to move; Using a security preview pipeline to control the focus position of the front camera to change within the preset focus range includes: A safety preview pipeline is used to control the motor of the front camera to drive the lens to move within a preset position range; wherein, when the lens of the front camera moves within the preset position range, the focus position of the front camera changes within a preset focus range.

3. The method according to claim 1, characterized in that: Acquiring a plurality of second images captured by the front camera within the preset focus range, comprising: The multiple second images are acquired in a non-preview state; wherein the non-preview state indicates that the image captured by the front camera is not displayed.

4. The method according to claim 1, characterized in that: The first image includes a QR code; and according to the recognition result of the first image, a second interface is displayed, including: According to the recognition result of the QR code, a second interface indicated by the recognition result is displayed.

5. The method according to claim 4, characterized in that In response to the wrist-turning action, controlling the front camera to focus within a preset focus range includes: In response to the wrist-turning action, acquiring intelligent perception information, wherein the intelligent perception information is used to indicate a perception function triggered by the wrist-turning action; When the intelligent perception information indicates a first perception function, the front camera is controlled to focus within a preset focus range, wherein the first perception function is a code scanning function.

6. The method according to any one of claims 1 to 5, characterized in that Acquiring a first image captured by the front camera at a target focus position, comprising: If the target focus position is determined within the preset focus range, obtaining a first image captured by the front camera at the target focus position; The method further includes: generating first prompt information, wherein the first prompt information is used to prompt that the focusing has been completed.

7. The method according to claim 6, characterized in that The method further comprises: If the target focus position is not determined within the preset focus range, second prompt information is generated, wherein the second prompt information is used to prompt the user to move the front camera so that the front camera determines the target focus position within the preset focus range.

8. An electronic device, characterized in that: The electronic device comprises a front camera, a memory, a processor and a computer program stored in the memory, wherein the front camera is a zoom camera and is used to capture images; when the processor runs the computer program, the electronic device executes the method described in any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: A computer program is stored, and when the computer program is executed by an electronic device, the electronic device executes the method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by an electronic device, enables the electronic device to execute the method according to any one of claims 1 to 7.