Focusing method and related equipment

By dividing the inclination angle of the electronic device and setting a compensation value threshold, adjusting the motor position to compensate for the inclination angle, the problem of blurred imaging during the electronic device when shooting upward or shooting downward is solved, and the accuracy of the focus position and shooting experience are improved.

CN118474538BActive Publication Date: 2025-03-21HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311155726.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-07
Publication Date
2025-03-21
Estimated Expiration
2043-09-07

AI Technical Summary

Technical Problem

When the electronic device is shooting upward or downward, the camera cannot display clear imaging, which affects the shooting experience.

Method used

By dividing the inclination angle of the electronic device, setting multiple preset intervals, and setting a compensation value threshold for each interval, adjusting the motor position to compensate for the inclination angle, and improving the accuracy of the focus position.

Benefits of technology

Improves the accuracy of focus position, reduces blurry scenes of camera imaging, and improves the shooting experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118474538B_ABST
    Figure CN118474538B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a focusing method and related equipment. The method includes: at a first moment, the electronic device starts a camera application, the inclination angle of the electronic device is a first inclination angle, the motor is located at a first position, the electronic device displays a first image, and the first position corresponds to a first focus value; at a second moment, the electronic device adjusts the motor to a second position, and the electronic device displays a second image; the clarity of the second image is higher than the clarity of the first image; wherein the first inclination angle belongs to a first preset interval, the electronic device is provided with a first threshold corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with the first compensation value, the first compensation value is positively correlated with the first inclination angle, and the first compensation value is less than the first threshold. In this way, any preset interval is provided with a corresponding compensation value threshold, which improves the accuracy of the compensation value threshold and the accuracy of the compensation value, thereby reducing the scene of blurred camera imaging.
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 focusing method and related equipment. Background Art

[0002] Electronic devices may be configured with cameras, and users may use the electronic devices to perform activities such as taking photos and recording videos.

[0003] In a possible implementation, when a user uses an electronic device to take a photo, the electronic device can focus on an object in the picture so that the image of the photographed object is clear.

[0004] However, in some scenarios, the electronic device may not be able to display clear images. For example, when a user uses an electronic device to shoot an object from above or below, the image of the object in the picture displayed by the electronic device is blurred, affecting the user's shooting experience. Summary of the invention

[0005] The embodiments of the present application provide a focusing method and related equipment, which are applied to the field of terminal technology. When the electronic device is in a tilted state and takes a photo, the electronic device can compensate the focus value according to the compensation value of the tilt angle or the compensation value threshold of a preset interval to improve the accuracy of the focus position.

[0006] In a first aspect, an embodiment of the present application proposes a focusing method, which is applied to an electronic device provided with a camera and a motor, wherein the motor is used to drive the position of the camera to move, and the method includes: at a first moment, the electronic device starts a camera application, the tilt angle of the electronic device is a first tilt angle, the motor is located at a first position, the electronic device displays a first image, and the first position corresponds to a first focus value; at a second moment, the electronic device adjusts the motor to a second position, and the electronic device displays a second image; the clarity of the second image is higher than the clarity of the first image; wherein the first tilt angle belongs to a first preset interval, the electronic device is provided with a first threshold corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with the first compensation value, the first compensation value is positively correlated with the first tilt angle, and the first compensation value is less than the first threshold; the first moment is earlier than the second moment; at a third moment, the electronic device is adjusted to a second tilt angle, the motor is located at a third position, the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; the second moment is earlier than the third moment; at a fourth moment, the electronic device adjusts the motor to a second position, and the motor is located at a third position, and the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; When the electronic device reaches the fourth position, the fourth image is displayed, and the clarity of the fourth image is higher than that of the third image; wherein the second tilt angle belongs to the first preset interval, the distance between the fourth position and the third position is positively correlated with the second compensation value, the second compensation value is positively correlated with the second tilt angle, and the second compensation value is less than the first threshold value; the third moment is earlier than the fourth moment; at the fifth moment, the electronic device is adjusted to the third tilt angle again, the motor is located at the fifth position, the electronic device displays the fifth image, the fifth position corresponds to the third focus value, and the fourth moment is earlier than the fifth moment; at the sixth moment, the electronic device adjusts the motor to the sixth position, the electronic device displays the sixth image, and the clarity of the sixth image is higher than that of the fifth image; wherein the third tilt angle belongs to the second preset interval, the value in the second preset interval does not overlap with the value in the first preset interval, the electronic device is also provided with a second threshold value corresponding to the second preset interval, the second threshold value is different from the first threshold value, the distance between the sixth position and the fifth position is positively correlated with the third compensation value, the third compensation value is positively correlated with the third tilt angle, and the third compensation value is less than the second threshold value; the fifth moment is earlier than the sixth moment.

[0007] Thus, in the embodiment of the present application, the electronic device divides the tilt angle into regions to obtain a plurality of preset intervals. Each preset interval is provided with a compensation value threshold value under the preset interval, which improves the accuracy of the compensation value threshold value. When the compensation value is less than the compensation value threshold value, the compensation value obtained by the electronic device is more accurate, thereby improving the accuracy of the compensation value, and further reducing the scene of blurred camera imaging.

[0008] In a possible implementation, the electronic device also includes a motor drive, and before the electronic device adjusts the motor to the second position, it also includes: the electronic device searches for a first threshold corresponding to a first preset interval according to a first tilt angle; the electronic device calculates a first compensation value using the first tilt angle; the first compensation value is positively correlated with the sine value of the first tilt angle; when the first compensation value is less than the first threshold, the electronic device obtains a second position based on the first compensation value and the first focus value; the second position is positively correlated with the sum of the first compensation value and the first focus value; the electronic device sends the second position to the motor drive. In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate position of the motor to be adjusted, thereby improving the accuracy of the focus position.

[0009] In a possible implementation, the first compensation value satisfies the following formula:

[0010] offset=sinθ×offset0

[0011] Wherein, offset is the first compensation value, θ is the first tilt angle, and offset0 is the preset compensation value threshold. In this way, the electronic device can use the compensation value calculation formula to obtain the compensation value, so as to use the value in the subsequent focusing process to improve the focusing accuracy.

[0012] In a possible implementation, it also includes: at the seventh moment, the electronic device is adjusted to the fourth tilt angle again, the motor is located at the seventh position, the electronic device displays the seventh image, the seventh position corresponds to the fourth focus value, and the sixth moment is earlier than the seventh moment; at the eighth moment, the electronic device adjusts the motor to the eighth position, the electronic device displays the eighth image, and the clarity of the eighth image is higher than that of the seventh image; wherein the fourth tilt angle belongs to the third preset interval, the value in the third preset interval does not overlap with the value in the second preset interval, the electronic device is also provided with a third threshold corresponding to the third preset interval, the third threshold is different from the second threshold, the distance between the eighth position and the seventh position is positively correlated with the third threshold, the fourth compensation value is greater than or equal to the third threshold, the fourth compensation value is positively correlated with the fourth tilt angle, and the seventh moment is earlier than the eighth moment. In this way, the electronic device measures the accuracy of the compensation value by the compensation value threshold, and when the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large, and the compensation value cannot be used to correct the calculated focus value; at this time, the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the position to be adjusted by the motor.

[0013] In a possible implementation, before the electronic device adjusts the motor to the eighth position, it also includes: the electronic device searches for the third threshold corresponding to the third preset interval according to the fourth tilt angle; the electronic device calculates the fourth compensation value using the fourth tilt angle; the fourth compensation value is positively correlated with the sine value of the fourth tilt angle; when the fourth compensation value is greater than or equal to the third threshold, the electronic device obtains the eighth position based on the third threshold and the fourth focus value; the eighth position is positively correlated with the sum of the third threshold and the fourth focus value; the electronic device sends the eighth position to the motor driver. In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate position of the motor to be adjusted, thereby improving the accuracy of the focus position.

[0014] In a possible implementation, it also includes: at the ninth moment, the electronic device is adjusted to the fifth tilt angle again, the motor is located at the ninth position, the electronic device displays the ninth image, the ninth image includes a preset target object, the target object is an object whose distance from the electronic device exceeds the distance threshold, the ninth position corresponds to the fifth focus value, and the eighth moment is earlier than the ninth moment; at the tenth moment, the electronic device adjusts the motor to the tenth position, the electronic device displays the tenth image, the tenth image includes the target object, and the clarity of the tenth image is higher than the clarity of the ninth image; the electronic device is also provided with a fourth threshold value of the target object at the fifth tilt angle, the distance between the tenth position and the ninth position is positively correlated with the fifth compensation value, the fifth compensation value is positively correlated with the fifth tilt angle, and the fifth compensation value is less than the fourth threshold value; wherein the fifth tilt angle belongs to the fourth preset interval, the electronic device is also provided with a threshold value corresponding to the fourth preset interval, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth moment is earlier than the tenth moment. In this way, when shooting the target object, the electronic device can adjust the compensation value threshold value at any tilt angle according to the required accuracy, improve the accuracy of the compensation value threshold value, and thus improve the accuracy of the focus position.

[0015] In a possible implementation, before the electronic device adjusts the motor position to the tenth position, it also includes: the electronic device obtains the ninth image and determines whether the photographed object in the ninth image is the target object; when the photographed object in the ninth image is the target object, the electronic device searches for the fourth threshold value according to the target object and the fifth tilt angle; the electronic device calculates the fifth compensation value using the fifth tilt angle; when the fifth compensation value is less than the fourth threshold value, the electronic device obtains the tenth position based on the fifth compensation value and the fifth focus value; the tenth position is positively correlated with the sum of the fifth compensation value and the fifth focus value; the electronic device sends the tenth position to the motor drive. In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

[0016] In a possible implementation, it also includes: at the eleventh moment, the electronic device is adjusted to the sixth tilt angle again, the motor is located at the eleventh position, the electronic device displays the eleventh image, the eleventh image includes the target object, the eleventh position corresponds to the sixth focus value, and the tenth moment is earlier than the eleventh moment; at the twelfth moment, the electronic device adjusts the motor to the twelfth position, the electronic device displays the twelfth image, the twelfth image includes the target object, and the clarity of the twelfth image is higher than the clarity of the eleventh image; the electronic device is also provided with a fifth threshold corresponding to the target object at the sixth tilt angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold, the sixth compensation value is greater than or equal to the fifth threshold, and the sixth compensation value is positively correlated with the sixth tilt angle; wherein the sixth tilt angle belongs to the fourth preset interval, the fifth threshold is different from the threshold corresponding to the fourth preset interval, and the fifth threshold is different from the fourth threshold; the eleventh moment is earlier than the twelfth moment. In this way, when shooting the target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy to improve the accuracy of the compensation value threshold; the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value; the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

[0017] In a possible implementation, before the electronic device adjusts the motor position to the twelfth position, it also includes: the electronic device obtains the eleventh image and determines whether the photographed object in the eleventh image is the target object; when the photographed object in the eleventh image is the target object, the electronic device searches for the fifth threshold value according to the target object and the sixth tilt angle; the electronic device calculates the sixth compensation value using the sixth tilt angle; when the sixth compensation value is greater than or equal to the fifth threshold value, the electronic device obtains the twelfth position based on the fifth threshold value and the sixth focus value; the twelfth position is positively correlated with the sum of the fifth threshold value and the sixth focus value; the electronic device sends the twelfth position to the motor drive. In this way, when the compensation value is greater than or equal to the compensation value threshold value, the electronic device can use the compensation value threshold value and the calculated focus value to obtain a more accurate position of the motor to be adjusted, thereby improving the accuracy of the focus position.

[0018] In a possible implementation, the first tilt angle is related to inertial measurement unit IMU data, where the IMU data is obtained by the electronic device based on a gyroscope sensor;

[0019] The first inclination angle satisfies any of the following formulas:

[0020]

[0021] or;

[0022]

[0023] or;

[0024]

[0025] Among them, gSensor.x is the angular velocity of the electronic device in the x-axis direction when the electronic device is at the first tilt angle, gSensor.y is the angular velocity of the electronic device in the y-axis direction when the electronic device is at the first tilt angle, and gSensor.z is the angular velocity of the electronic device in the z-axis direction when the electronic device is at the first tilt angle. In this way, the electronic device can use the tilt angle calculation formula to obtain the current tilt angle, so that the value can be used in the subsequent focusing process to improve the accuracy of focusing.

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

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

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

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

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

[0031] 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

[0032] Figure 1 A focusing method in a possible implementation;

[0033] Figure 2 A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;

[0034] Figure 3 A software structure block diagram of the electronic device 100 provided in an embodiment of the present application;

[0035] Figure 4 A schematic diagram of a shooting scene provided in an embodiment of the present application;

[0036] Figure 5 A schematic diagram of an electronic device 100 in a non-tilted state provided by an embodiment of the present application;

[0037] Figure 6 A schematic diagram of an electronic device 100 in a tilted state provided by an embodiment of the present application;

[0038] Figure 7 A flowchart of a focusing method provided in an embodiment of the present application;

[0039] Figure 8 A schematic diagram of the tilt angle provided in the embodiment of the present application;

[0040] Fig. 9 A schematic diagram of dividing a preset interval provided in an embodiment of the present application;

[0041] Fig.10 A schematic diagram of a flow chart of another focusing method provided in an embodiment of the present application;

[0042] Fig.11 A flowchart of a focusing method provided in an embodiment of the present application;

[0043] Fig.12 This is a schematic diagram of the device structure shown in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:

[0045] 1. Focus

[0046] Focusing refers to the process of adjusting the object distance and focal length of the camera to make the image of the object clear. The electronic device obtains the highest frequency component of the picture by adjusting the position of the focusing lens to obtain a higher picture contrast. Among them, focusing is a continuous accumulation process. The electronic device compares the contrast of the pictures taken by the lens at different positions to obtain the position of the lens when the contrast of the picture is the largest, and then determines the focal length for focusing.

[0047] In the process of shooting with electronic devices, focusing mainly involves the camera, which can also be called a camera module. The camera module includes components such as a lens, a motor, a motor driver chip, and an image sensor. The lens is used to receive light, and an electronic device may include one or more lenses. The lens can generally be composed of one or more lenses. The image sensor can convert the light passing through the lens into an electrical signal, and then convert the electrical signal into a digital signal. The motor is used to push the lens to adjust its position. The motor drive is used to determine the position of the motor to push the lens during autofocus.

[0048] Among them, the lens and photosensitive chip are the main components for imaging, and the motor and motor driver chip are the main components for focusing. When the object is in the long view and the close view, the corresponding imaging position is different. It is necessary to adjust the distance between the lens and the photosensitive chip so that a clear imaging effect can always be obtained on the photosensitive chip. For the camera module of an electronic device, the electronic device needs to push the lens through a motor to change the distance between the lens and the photosensitive chip (focal length), and the distance between the lens and the object being photographed (object distance).

[0049] 2. Motor

[0050] The motor can be used to push the lens to adjust its position and achieve focusing. The motor may include an open loop motor (open loop VCM) and a closed loop motor (closed loop VCM). The open loop motor can be understood as a process in which the input of the motor is a current parameter, the output is a displacement parameter, and there is no feedback between the input and output. The open loop motor has certain defects. Under the influence of gravity, the open loop motor has a posture difference. The closed loop motor integrates Hall elements. The closed loop motor can accurately measure the position of the lens in the x-axis, y-axis, and z-axis directions and lock the lens, so that the motor is not affected by its own gravity and the shooting posture. However, the closed loop motor has a complex structure of parts, a cumbersome manufacturing process, and a high cost, which makes the closed loop motor have no advantage over the open loop motor in terms of cost. In the embodiment of the present application, the motor may be an open loop motor.

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

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

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

[0054] The electronic device may be equipped with a camera, and the user may take photos and record videos based on the electronic device. In a possible implementation, when the user uses the electronic device to take photos, the electronic device may focus on the object in the picture so that the image of the photographed object is clear.

[0055] However, in some scenarios, the electronic device may not be able to display clear images. For example, when a user uses an electronic device to shoot an object from above or below, the image of the object in the picture displayed by the electronic device is blurred, affecting the user's shooting experience.

[0056] It is understandable that the electronic device realizes the shooting function based on the camera module, which includes a lens, a motor and a sensor, etc. The motor can be used to push the lens to adjust its position to achieve focusing. Among them, the motor can be an open-loop motor; for an open-loop motor, when the electronic device is tilted, it is affected by its own gravity, and the motor produces a posture difference, which reduces the accuracy of the motor position. In a possible implementation, in order to reduce the influence of the posture difference, a preset tilt angle and a calibration value corresponding to the preset tilt angle are set in the electronic device, and the electronic device can calculate the compensation value corresponding to the measured angle based on the difference between the measured tilt angle and the preset tilt angle.

[0057] Specifically, Figure 1 FIG. 1 is a flow chart of a focusing method in a possible implementation. Figure 1 As shown:

[0058] S101: The electronic device obtains a measured tilt angle.

[0059] When an electronic device is tilted, a gyroscope sensor of the electronic device can measure the tilt angle.

[0060] S102: The electronic device obtains a compensation value corresponding to the measured tilt angle according to the measured tilt angle, the preset tilt angle and a calibration value of the preset tilt angle.

[0061] In a possible implementation, the electronic device may calculate the compensation value corresponding to the measured tilt angle based on the following formula:

[0062]

[0063] Among them, x is the measured tilt angle, y is the compensation value corresponding to the measured tilt angle, (x0, y0) can be a set of preset tilt angles and the calibration value corresponding to the preset tilt angle; (x1, y1) can be another set of preset tilt angles and the calibration value corresponding to the preset tilt angle.

[0064] Two preset tilt angles and calibration values ​​corresponding to the preset tilts are set in the electronic device. For example, when the preset tilt angle is 30°, the calibration value corresponding to the preset tilt angle is a; when the preset tilt angle is 60°, the calibration value corresponding to the preset tilt angle is b. The electronic device can derive compensation values ​​at other tilt angles based on the given preset tilt angles and calibration values. For example, when the measured tilt angle is 45°, the electronic device calculates the compensation value corresponding to 45° based on the data of the preset tilt angles 30° and 60°. Specifically:

[0065]

[0066] The compensation value y=(a+b) / 2 is obtained when the measured tilt angle is 45°.

[0067] S103, the electronic device outputs the motor position.

[0068] The electronics adjust the motor position based on a compensation value for the measured tilt angle.

[0069] It is found that when the tilt angle is small, the error between the calculated compensation value and the actual compensation value is small; when the tilt angle is large, the error between the calculated compensation value and the actual compensation value is large, and there is no linear relationship between the tilt angle and the compensation value. However, it can be seen from the derivation of formula 1 that The difference between the calculated compensation value and the actual compensation value is a constant; in a possible implementation, the difference between the calculated compensation value and the actual compensation value is calculated as a linear relationship. When the measured tilt angle is larger, the difference between the compensation value calculated by formula 1 and the actual compensation value is larger. Therefore, in a possible implementation, the more vertical the posture of the electronic device is, the larger the error of the compensation value is, and the problem of inaccurate compensation may occur.

[0070] In addition, in a possible implementation, the electronic device will calibrate a compensation value threshold, which is generally the difference between the hyperfocal position and the minimum position of the motor that can clearly display the photographed object when the object distance is infinite. The electronic device can verify the accuracy of the calculation result by determining whether the calculated compensation value is greater than the compensation value threshold, but because the same compensation value threshold needs to be used at all angles, the compensation value threshold is often greater than the calculated compensation value. The compensation value threshold setting range is too large, and the inspection effect can be small.

[0071] Therefore, in a possible implementation, when the electronic device is shooting upward or downward, the compensation value calculated by the electronic device is less accurate, and the motor fails to push the lens to a more accurate position, causing the electronic device to be unable to display clear images and the photos taken are blurry.

[0072] In view of this, the embodiment of the present application provides a focusing method, which obtains multiple preset intervals by refining the angle interval, and obtains the compensation value threshold corresponding to any preset interval; during the focusing process, the electronic device can find the compensation value threshold corresponding to the current tilt angle, and use the compensation value threshold to measure the accuracy of the compensation value; if the compensation value is less than the compensation value threshold, the electronic device can use the compensation value to complete the focus. In this way, after the tilt angle is divided into regions, the accuracy of the compensation value threshold of the preset region is higher than the compensation value threshold corresponding to the full angle calibrated in the possible implementation, and the compensation value that meets the condition of being less than the compensation value threshold is more accurate, thereby improving the accuracy of the motor compensation value, thereby reducing the scene of blurred camera imaging.

[0073] In the embodiments of the present application, the electronic device may also be referred to as: terminal device, 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.

[0074] Among them, wearable devices can also be called wearable smart devices, which are a general term for the intelligent design and development of wearable devices for daily wear using wearable technology, such as glasses, gloves, watches, clothing and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also realize powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and independent of smartphones to achieve complete or partial functions, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

[0075] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection. The embodiments of the present application do not limit the specific technology and specific device form used by the electronic device.

[0076] In an embodiment of the present application, the electronic device may include a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system may be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0077] In order to better understand the embodiments of the present application, the structure of the electronic device in the embodiments of the present application is introduced below:

[0078] Figure 2 The structure diagram of the electronic device 100 is shown. The electronic 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, a subscriber identification module (SIM) card interface 195, an embedded secure element (eSE) chip 196, etc.

[0079] Among them, 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.

[0080] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic 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.

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

[0082] In the embodiment of the present application, the electronic device may use the processor 110 to execute the focusing process.

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

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

[0085] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor.

[0086] In the embodiment of the present application, the electronic device can display the captured image based on the display screen 194.

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

[0088] 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 electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0089] In the embodiment of the present application, the electronic device can detect the shooting scene based on the image recognition algorithm in the NPU, etc. For example, when the electronic device shoots a target object such as the moon or clouds, the electronic device can set a compensation value threshold corresponding to the specific scene.

[0090] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, 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.), etc. The data storage area may store data created during the use of the electronic device 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. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.

[0091] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic 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 electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0092] In the embodiment of the present application, the electronic device 100 can calculate the tilt angle of the electronic device according to the angular velocity data reported by the gyroscope sensor, so as to set the compensation value threshold according to the tilt angle later.

[0093] 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. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0094] In the embodiment of the present application, the motor is used to push the lens to a focusing position to improve the clarity of the captured image.

[0095] The software system of the electronic 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 electronic device 100.

[0096] Figure 3 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0097] 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 Android system may include: application layer (applications), application framework layer (application framework), hardware abstract layer (HAL) and kernel layer (kernel), where the kernel layer may become a driver layer.

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

[0099] like Figure 3 As shown, an application package can include applications such as settings, calendar, maps, phone, music, camera, mailbox, video and social.

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

[0101] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a resource manager, a view system, a notification manager, a camera access interface, and the like.

[0102] The camera access interface enables applications to manage cameras and access camera devices, such as managing cameras to capture images.

[0103] The hardware abstraction layer can contain multiple library modules. The Android system can load the corresponding library modules for the device hardware, thereby enabling the application framework layer to access the device hardware.

[0104] In the embodiment of the present application, the hardware abstraction layer may include a focus algorithm module and a detection module. The focus algorithm module is used to calculate the focus position of the lens; the detection module can be used to detect objects in the image, and when the photographed object is a target object, the focus position is set according to the target object.

[0105] The kernel layer is a layer between hardware and software. The kernel layer is used to drive the hardware to make the hardware work. The kernel layer may include sensor driver, camera driver, motor driver, etc., which is not limited in the embodiments of the present application.

[0106] The hardware layer may include various types of hardware devices. For example, the hardware layer includes sensors, cameras, and motors. The sensor may be a gyroscope sensor.

[0107] Combine the following Figure 3 The following describes possible implementations of the focusing method of the embodiment of the present application.

[0108] In one possible implementation, after the electronic device starts the camera application, the electronic device can call the camera access interface of the application framework layer through the camera application. The camera access interface manages the focus algorithm module of the hardware abstraction layer so that the kernel layer can obtain frame images and IMU data. The acquired frame images and IMU data are further calculated by the focus algorithm of the embodiment of the present application in the focus algorithm module, and then output a more accurate focus value to the motor driver. The motor driver adjusts the motor position according to the focus value to achieve camera focus. After completing the focus, the camera can report the captured focused frame image to the camera application through the kernel layer, the hardware abstraction layer and the application framework layer in sequence, and the display screen of the electronic device displays the focused frame image.

[0109] Optionally, the focusing method in the embodiment of the present application may involve a shooting scene of a target object, and the focusing algorithm module may call the detection module to perform image recognition on the object being shot in the frame image. When the object being shot is the target object, the focusing algorithm module may send a focus value corresponding to the target object to the motor driver and control the lens to achieve focusing. The display screen of the subsequent electronic device can display the object being shot more clearly.

[0110] Let's combine Figure 4 The scenarios to which the focusing method provided in the embodiments of the present application is applicable are described. Figure 4A schematic diagram of a scene of a focusing method provided by an embodiment of the present application is shown. Figure 4 As shown:

[0111] The electronic device starts the camera application. When the electronic device Figure 4 When placed as shown, the electronic device can shoot high objects and achieve upward shooting. At this time, the electronic device is in a tilted state, and the electronic device can use the focusing method provided in the embodiment of the present application to obtain a compensation value for the motor position, so that the electronic device can obtain a more accurate motor position and improve the clarity of the film.

[0112] Take the horizontal placement of electronic devices as an example. Figure 5 FIG. 1 shows an electronic device 100 in a non-tilted state. Figure 5 In the figure a, the plane where the electronic device 100 is located is parallel to the direction of gravity, and one edge of the electronic device is parallel to the direction of gravity, and one edge is perpendicular to the direction of gravity. The electronic device 100 is in a non-tilted state; wherein the Z axis is parallel to the direction of gravity; the X axis is perpendicular to the direction of gravity, and the X axis is coplanar with the display screen of the electronic device 100; the Y axis is perpendicular to the direction of gravity, and the Y axis is perpendicular to the display screen of the electronic device 100.

[0113] Specifically, Figure 5 Figure b shows the projection of the electronic device 100 in the X-axis direction. In the YZ coordinate system, the rectangle can be understood as the projection of the electronic device 100 in the X-axis direction, and the Y value of the rectangle can be the thickness of the electronic device. The electronic device 100 is provided with a camera 193, and the camera 193 can be a rear camera or a front camera.

[0114] from Figure 5 It can be seen from Figure b that in the non-tilted state, the direction of the Y axis can be the direction in which the lens of the camera 193 extends, that is, the angle between the extension straight line L of the camera 193 and the Y axis is 0, and the tilt angle can be regarded as 0 at this time.

[0115] It is understandable that when the electronic device 100 is in a non-tilted state, the motor is little affected by gravity or not affected by gravity when pushing the lens to move, so when the angle between the lens extension direction and the horizontal y-axis is 0, it is set to a non-tilted state.

[0116] The electronic device is placed horizontally, and the electronic device 100 is in Figure 4 Take the upward shooting scene shown as an example. Figure 6Figure a in the figure shows an electronic device 100 in a tilted state. For example, in the YZ coordinate system, the user tilts the electronic device 100 so that the electronic device 100 can capture a scene at a high place. The electronic device is in a tilted state, and the tilt angle can be the angle θ between the lens extension direction L of the camera 193 and the Y axis, wherein when the electronic device is shooting upward, the value range of θ can be 0-90°.

[0117] For example, the electronic device is placed horizontally and the electronic device 100 is in a top-down shooting scene. Figure 6 FIG. b in FIG. 1 shows another electronic device 100 in a tilted state. For example, in the YZ coordinate system, the user tilts the electronic device 100 so that the electronic device 100 can capture a scene at a lower position. The electronic device is in a tilted state, and the tilt angle may be an angle θ between the lens extension direction L of the camera 193 and the y-axis, wherein when the electronic device is shooting from above, the value range of θ may be -90°-0°.

[0118] The focusing method provided in the embodiment of the present application can be applied to non-horizontal shooting scenes such as overhead shooting and upward shooting, and the embodiment of the present application is not limited to this.

[0119] It should be noted that the present application embodiment uses a camera application as an example to illustrate the use scenario of the focusing method. In the present application embodiment, the method can also be applied to other scenarios, for example, an electronic device starts a camera based on a social application. The present application embodiment does not limit this.

[0120] The above embodiments describe the tilt state and tilt angle of the electronic device. Figure 7 The process of the focusing method provided in the embodiment of the present application is described. Figure 7 A schematic diagram of a focusing method provided in an embodiment of the present application is shown. Figure 7 As shown:

[0121] S701. The electronic device starts a camera application.

[0122] After the electronic device starts the camera application, the electronic device can use the camera to capture images.

[0123] In the embodiment of the present application, the electronic device may also use other applications to start the camera, for example, a social application, which is not limited in the embodiment of the present application.

[0124] S702: A focus algorithm module of the electronic device obtains a calculated focus value.

[0125] The focus algorithm module may be an automatic focus (AF) algorithm module, wherein the AF algorithm may be laser focus (time of flight, TOF), contrast automatic focus (CAF) and phase detection automatic focus (PDAF), etc. The focus algorithm module may calculate the focus value based on the AF algorithm. For example, taking the PDAF algorithm as an example, when the electronic device photographs the photographed object, the sensor of the focus algorithm module may collect one or more images; if the number of images is one, it means that the position of the current lens is the focus position; if the number of images is two, the focus algorithm module may adjust the focus position according to the phase difference between the two images.

[0126] The calculated focus value may be the focus position when the electronic device is in a non-tilted state; the calculated focus value may be calculated by the focus algorithm module based on the AF algorithm; the electronic device may control the motor according to the calculated focus value so that the motor pushes the lens to a position where it can clearly capture an image. It is understandable that the calculated focus value is the focus position of the electronic device in a non-tilted state, and in the embodiment of the present application, after the motor controls the lens to move the calculated focus value, since the electronic device is in a tilted state, the motor will be affected by gravity, resulting in an error between the calculated focus value and the optimal focus position (real focus position). Therefore, in the embodiment of the present application, the electronic device may subsequently correct the calculated focus value through steps S703-S711 to improve the accuracy of the motor position.

[0127] It is understandable that in step S702, the electronic device may use an algorithm such as TOF, CAF or DAF to calculate the calculated focus value, and the embodiment of the present application does not limit the calculated focus value. In the embodiment of the present application, the calculated focus value may be a focus position obtained by the electronic device based on an AF algorithm, and in step S702, the motor may be at the calculated focus value.

[0128] S703: The gyroscope sensor of the electronic device collects inertial measurement unit (IMU) data and reports it to the focus algorithm module.

[0129] The gyroscope sensor can reflect the tilt state of the electronic device through IMU data; wherein the IMU data may include the angular velocity in the x-axis direction, the angular velocity in the y-axis direction, and the angular velocity in the z-axis direction. For example, the IMU data may be gSensor.x, gSensor.y, and gSensor.z. The gyroscope sensor in the hardware layer can collect IMU data, and then report the IMU data to the focus algorithm module in the hardware abstraction layer. The focus algorithm module processes the IMU data.

[0130] It should be noted that after the electronic device starts the target application, the electronic device may execute step S702 and step S703 simultaneously, or may execute step S702 and step S703 sequentially, and the embodiment of the present application does not limit the order of step S702 and step S703.

[0131] S704: The focus algorithm module of the electronic device obtains IMU data, and obtains a tilt angle of the electronic device based on the IMU data.

[0132] The focus algorithm module can calculate the tilt angle based on IMU data.

[0133] Take the overhead shooting scene as an example, the electronic device is in a tilted state, such as Figure 8 For example, in one possible implementation, the tilt angle θ may satisfy the following formula:

[0134]

[0135] Among them, b is the angular velocity in the vertical direction; c is the angular velocity in the horizontal direction, for example, b is the angular velocity in the z-axis direction, and c is the angular velocity obtained by superimposing the angular velocity in the x-axis direction and the angular velocity in the y-axis direction.

[0136] Specific:

[0137]

[0138] In another possible implementation, the focus algorithm module can also calculate the θ value based on the formula θ=arcsin(b / a) or θ=arccos(c / a), etc., which is not limited in the embodiment of the present application. Wherein, a is the angular velocity of the x-axis direction, the angular velocity of the y-axis direction, and the angular velocity of the z-axis direction.

[0139] in,

[0140] Specific:

[0141]

[0142] or

[0143]

[0144] The focusing algorithm module obtains the tilt angle θ based on the above method.

[0145] S705: The focus algorithm module of the electronic device searches for a compensation value threshold corresponding to a preset interval according to the tilt angle.

[0146] The value in the preset interval includes the tilt angle, and the preset interval corresponds to a compensation value threshold.

[0147] Exemplarily, a preset list is provided in the electronic device, and the preset list includes different preset intervals and compensation value thresholds corresponding to different preset intervals. In the embodiment of the present application, the tilt angle can be divided to obtain multiple preset intervals, for example: preset interval 1, preset interval 2, preset interval 3... preset interval N, etc. The preset list includes a correspondence between the preset intervals and the compensation value thresholds. For example, preset interval 1 corresponds to compensation value threshold 1, preset interval 2 corresponds to compensation value threshold 2, preset interval 3 corresponds to compensation value threshold 3... preset interval N corresponds to compensation value threshold N, etc.

[0148] The values ​​of the inclination angles in any preset interval do not overlap.

[0149] The embodiments of the present application will later describe the division rules of the preset intervals in the preset list and the method for setting the compensation value threshold, which will not be described in detail here.

[0150] S706: The focus algorithm module of the electronic device calculates a compensation value using the tilt angle.

[0151] In a possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

[0152] offset=sinθ×offset0 (7)

[0153] Among them, offset0 is a default compensation value, and offset0 can be a compensation value when the tilt angle is ±90°.

[0154] In another possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

[0155]

[0156] After the electronic device calculates the tilt angle, it can obtain the compensation value at the tilt angle based on formula (7) or formula (8).

[0157] S707: When the compensation value is less than the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value and the calculated focus value.

[0158] The motor position to be adjusted may be a focus value for indicating the motor push position. The motor position to be adjusted may be a relatively accurate focus value obtained by the electronic device after correcting the calculated focus value according to the tilt angle. When the lens is located at the motor position to be adjusted, the camera of the electronic device can obtain a clear image.

[0159] It can be understood that the compensation value is less than the compensation value threshold, which means that when the electronic device is at this tilt angle, the error between the corrected focus position of the electronic device (the motor position to be adjusted) and the actual focus position is small. When the lens is in the motor position to be adjusted, the electronic device can capture the object more clearly.

[0160] S708: The focus algorithm module of the electronic device sends the motor position to be adjusted to the motor driver.

[0161] S709: The motor driver of the electronic device adjusts the motor position according to the motor position to be adjusted.

[0162] S710: The electronic device displays the focused image in the interface of the target application.

[0163] The motor driver chip can adjust the motor position according to the motor position to be adjusted, so that the lens reaches the corrected focus position. In this way, after the electronic device adjusts the lens position, the lens is located at the focus position, so that the camera can obtain a clear imaging effect.

[0164] Alternatively, after step S706, the method further includes:

[0165] S711: When the compensation value is greater than or equal to the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value threshold and the calculated focus value.

[0166] It is understandable that if the compensation value is greater than the compensation value threshold, it is possible that the current tilt angle is large. At this tilt angle, the error between the compensation value and the optimal compensation value (true compensation value) of the electronic device is large. If the electronic device still uses the compensation value to correct the focus position, the error between the obtained focus position and the true focus position will also be large. To reduce the error, the electronic device can reduce the compensation value. In one possible implementation, the compensation value threshold is less than or equal to the compensation value, so the error between the compensation value threshold and the true compensation value is smaller than the error between the compensation value and the true compensation value.

[0167] When the electronic device calculates the position to be adjusted of the motor by using the compensation value threshold, the error between the calculated focus position and the actual focus position can be reduced.

[0168] Afterwards, the electronic device may execute steps S708-S710.

[0169] Optionally, in an embodiment of the present application, the preset interval in the preset list may be set according to the following method.

[0170] a) Calculate the compensation value for any tilt angle.

[0171] The tilt angle can range from -90° to 90°.

[0172] In a possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

[0173] offset=sinθ×offset0 (9)

[0174] Among them, offset0 is the default compensation value.

[0175] In another possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

[0176]

[0177] In an embodiment of the present application, the first electronic device can calculate the compensation value corresponding to the tilt angle θ according to formula (9) or formula (10), wherein formula (9) can be understood as a simplified formula of formula (10), and the formula principles of the above two formulas are the same.

[0178] b) Get the true compensation value for any tilt angle.

[0179] The first electronic device can obtain the real focus value through measurement experiments, and obtain the real compensation value through the difference between the real focus value and the calculated focus value. The real focus value can be understood as: the theoretical focus value of the lens (or motor) when the lens can form a clear image. The calculated focus value can be understood as: the focus value in a non-tilted state obtained by the first electronic device based on the focusing algorithm. The difference between the two can be the real compensation value.

[0180] The focusing algorithm may include: a contrast focusing algorithm and a phase detection (PD) focusing algorithm.

[0181] c) Count the difference between the actual compensation value and the calculated compensation value at any tilt angle.

[0182] The first electronic device can calculate the difference between the actual compensation value and the calculated compensation value at any tilt angle, and draw a curve of the compensation value error based on the difference at each tilt angle.

[0183] in, Fig. 9 The error curve between the actual compensation value and the calculated compensation value at any tilt angle is shown. Fig. 9 As shown:

[0184] Take the tilt angle θ of 0-90° as an example:

[0185] Fig. 9In the figure, the horizontal axis is the tilt angle θ, and the vertical axis is the error between the real compensation value and the calculated compensation value. It can be seen that when the tilt angle is small, the error between the real compensation value and the calculated compensation value can be regarded as a linear growth with the change trend of the tilt angle; for example, at 0-40°, the tilt angle and the error are linearly related. As the tilt angle gradually increases, the growth trend of the error slows down and presents a nonlinear growth trend; for example, at 40°-90°, the tilt angle and the error are nonlinearly related.

[0186] The embodiment of the present application exemplarily shows the relationship between the difference between the actual compensation value and the calculated compensation value and the tilt angle, but the data in the curve does not limit the embodiment of the present application.

[0187] d) Calculate the maximum error and obtain each preset interval according to the depth of field (DOF).

[0188] The depth of field refers to the range of distances in front and behind the object being photographed measured when the camera lens can obtain a clear image. In the embodiment of the present application, the angle intervals can be divided according to the depth of field.

[0189] It is understandable that in a shooting scene, when the lens is within a certain range of the actual focus position, the camera can capture a clear image, and the range can be a depth of field. The error between the calculated compensation value and the actual compensation value in step c) can also be approximated as the error between the calculated focus value and the actual focus value. When the error is small, for example, the error is within one depth of field, the camera can capture a clear image; and when the error increases to the length of two depths of field, the clarity of the image captured by the camera is less than the clarity of the image when the error = 1 depth of field, and so on. The clarity of the image when the error is N depths of field is less than the clarity of the image when the error is N-1 depths of field. Therefore, the embodiment of the present application can measure the clarity of the captured image under the error of the length by the length of the depth of field.

[0190] In the embodiment of the present application, the number N of preset intervals may satisfy the following formula:

[0191]

[0192] Where Δoffset max It can be the maximum error between the real compensation value and the calculated compensation value in the tilt angle, and d can be the length of the depth of field, for example, the depth of field is 7.

[0193] For example, in Fig. 9, the N value is 7, among which, when the tilt angle is 0-9°, the error is within 1 depth of field; when the tilt angle is 9°-18°, the error is within 2 depths of field; when the tilt angle is 18°-28°, the error is within 3 depths of field; when the tilt angle is 28°-38°, the error is within 4 depths of field; when the tilt angle is 38°-51°, the error is within 5 depths of field; when the tilt angle is 51°-70°, the error is within 6 depths of field; when the tilt angle is 70°-90°, the error is within 7 depths of field.

[0194] The above examples of range parameters of the preset interval do not limit the preset interval in the embodiments of the present application.

[0195] e) Obtain the compensation value threshold corresponding to each angle interval.

[0196] In a possible implementation, the compensation value threshold corresponding to any interval may be obtained through experimental measurement results.

[0197] Exemplarily, taking a preset interval as an example, multiple numerical values ​​can be set; the numerical values ​​are respectively used as compensation value thresholds to enter steps S701-S711 to obtain multiple images captured by the camera under the compensation value threshold; the clarity of the multiple images is compared, and the numerical value corresponding to the image with the highest clarity is used as the compensation value threshold under the angle interval.

[0198] By analogy, the compensation value threshold corresponding to any preset interval can be obtained.

[0199] The first electronic device may preset the correspondence between the preset interval and the compensation value threshold in a preset list of the electronic device for use by the electronic device.

[0200] It should be noted that step a) to step e) are a back-end testing process, and the first electronic device in this process is not the same electronic device as the electronic device in steps S701-S711, which is explained in the embodiments of the present application.

[0201] In the embodiment of the present application, the second focus value obtained by the electronic device based on the focusing method of steps S701-S711 may not be applicable to some telephoto shooting scenes. The electronic device can set the motor position to be adjusted for the target object in the specific scene so that the electronic device can accurately focus in the scene. Fig.10 A schematic diagram of a focusing method provided in an embodiment of the present application is shown. Fig.10 As shown:

[0202] S1001. The electronic device starts a target application.

[0203] S1002: A focus algorithm module of the electronic device obtains a calculated focus value.

[0204] S1003: The gyroscope sensor of the electronic device collects IMU data and reports it to the focus algorithm module.

[0205] S1004: The focus algorithm module of the electronic device obtains IMU data, and obtains a tilt angle of the electronic device based on the IMU data.

[0206] For steps S1001-S1004, reference may be made to the relevant descriptions in steps S701-S704, which will not be repeated here.

[0207] S1005: The camera of the electronic device collects an image of the photographed object and uploads the image of the photographed object to the detection module.

[0208] In some embodiments, the detection module may obtain an image reported by the camera; in other embodiments, the AF module may obtain an image reported by the camera and transmit the image to the detection module.

[0209] It should be noted that after step S1001, the electronic device may execute step S1002, step S1003 and step S1005 simultaneously, or may execute step S1002, step S1003 and step S1005 in sequence, and the embodiment of the present application does not limit the order of step S1002, step S1003 and step S1005.

[0210] S1006: The detection module obtains an image of the photographed object and determines whether the photographed object in the image is a target object.

[0211] The detection module can be used to detect whether the photographed object is a target object. The target object can be an object whose distance from the electronic device exceeds a distance threshold. For example, the target object can be the moon, clouds, and distant buildings. The target object can be a pre-set target object.

[0212] For example, when an electronic device takes a photo of the moon, the electronic device may trigger the focusing method of an embodiment of the present application.

[0213] S1007: When the photographed object is a target object, the electronic device searches for a compensation value threshold according to the target object and the tilt angle.

[0214] The preset list may include target objects and compensation value thresholds corresponding to the target objects at different tilt angles. When the photographed object is the target object, the electronic device may obtain the compensation value threshold according to the correspondence between the target object and the compensation value threshold in the preset list.

[0215] It is understandable that in the embodiment of the present application, a focusing method in a specific scene is provided. When the photographed object is not the target object, the electronic device can use steps S701-S711 to achieve focusing of the photographed object. When the photographed object is the target object, the angle interval and compensation value threshold in the preset list are not applicable to the target object. Therefore, in a specific shooting scene, the electronic device can set the corresponding compensation value threshold according to the target object.

[0216] Among them, for specific shooting scenes, the electronic device may preset a more precise compensation value threshold. For example, the electronic device may preset a compensation value threshold when shooting a target object at any tilt angle. Exemplarily, the specific shooting scene may be a telephoto shooting scene, and the target object may be the moon, the sky, the sunset, and distant buildings. For example, when the electronic device performs telephoto shooting, the position of the lens may be placed at the hyperfocal position, and the electronic device may capture distant scenes more clearly; and the compensation value threshold obtained according to the preset interval may not be able to satisfy the requirement that the motor position to be adjusted at any tilt angle is controlled near the hyperfocal position. Therefore, it is necessary to set corresponding compensation value thresholds for the target object and tilt angle.

[0217] In one possible implementation, the compensation value threshold of the target object may be different from the compensation value threshold of the preset interval; for example, the electronic device may preset the compensation value threshold of the target object at each tilt angle, and when the electronic device detects the target object, the electronic device may use the compensation value threshold corresponding to the target object.

[0218] In another possible implementation, the electronic device may set a compensation value threshold for the target object at a certain tilt angle or in a certain angle interval; when the tilt angle is within the above-preset tilt angle, the electronic device may use the compensation value threshold corresponding to the target object; when the tilt angle is not within the above-preset tilt angle, the electronic device may use the compensation value threshold in the preset interval. This embodiment of the application is not limited to this.

[0219] S1008: The focus algorithm module of the electronic device calculates a compensation value using the tilt angle.

[0220] S1009: When the compensation value is less than the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value and the calculated focus value.

[0221] S1010: A focus algorithm module of the electronic device sends the motor position to be adjusted to the motor driver.

[0222] S1011 , the motor driver of the electronic device adjusts the motor position according to the motor position to be adjusted.

[0223] S1012: The electronic device displays the focused image in the interface of the target application.

[0224] For steps S1008-S1012, reference may be made to the relevant descriptions of steps S706-S710, which will not be repeated here.

[0225] Alternatively, after step S1008, the method further includes:

[0226] S1013: When the compensation value is greater than or equal to the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value threshold and the calculated focus value.

[0227] For step S1013, reference may be made to the relevant description of step S711, which will not be repeated here.

[0228] Afterwards, the electronic device may execute steps S1010 - S1012 .

[0229] Optionally, after step S1006, the following may be included: S1014: when the photographed object is not the target object, the focus algorithm module of the electronic device searches for a compensation value threshold corresponding to a preset interval according to the tilt angle.

[0230] It is understandable that when the photographed object is not the target object, the electronic device may execute step S1014 to achieve Figure 7 The focusing method in the present application will not be described in detail in the present embodiment.

[0231] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0232] Based on the above embodiments, the present application provides a focusing method. For example, Fig.11 A flowchart of a focusing method provided in an embodiment of the present application.

[0233] like Fig.11 As shown, the focusing method can be applied to an electronic device provided with a camera and a motor, the motor is used to drive the position of the camera to move, and the focusing method may include the following steps:

[0234] S1101. At a first moment, the electronic device starts a camera application, the tilt angle of the electronic device is a first tilt angle, the motor is located at a first position, the electronic device displays a first image, and the first position corresponds to a first focus value.

[0235] Wherein, step S1101 may correspond to step S702. The first focus value may be a calculated focus value obtained by the electronic device based on an AF algorithm, and the calculated focus value may be a focus position when the electronic device is in a non-tilted state. After obtaining the first focus value, the electronic device adjusts the motor to a first position corresponding to the first focus value.

[0236] It is understandable that at the first moment, there is no obvious correspondence between the first position and the first tilt angle, and the motor is affected by its own gravity, resulting in a difference between the first focus value and the actual focus position. Therefore, when the camera is at the first position, the electronic device is not accurately focused, and the clarity of the first image captured by the camera is not high.

[0237] S1102. At the second moment, the electronic device adjusts the motor to the second position, and the electronic device displays the second image; the clarity of the second image is higher than that of the first image; wherein the first tilt angle belongs to the first preset interval, the electronic device is provided with a first threshold value corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with the first compensation value, the first compensation value is positively correlated with the first tilt angle, and the first compensation value is less than the first threshold value; the first moment is earlier than the second moment.

[0238] Among them, step S1102 may correspond to steps S705-S710. The second position may be a focus position after the electronic device corrects the calculated focus value (first focus value) using the compensation value (first compensation value); the difference between the focus value corresponding to the second position and the actual focus position is small, so the clarity of the second image is higher than the clarity of the first image.

[0239] Specifically, S1101 and S1102 can be regarded as the first scenario in which the electronic device adjusts the motor position at the first tilt angle; at the first moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the second moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the first tilt angle belongs to the first preset area, in the preset list, the first preset area corresponds to the first threshold, the first compensation value is the compensation value calculated based on the first tilt angle, and the first compensation value is less than the first threshold, which can correspond to the process corresponding to step S707.

[0240] S1103. At a third moment, the electronic device is adjusted to a second tilt angle, the motor is located at a third position, the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; the second moment is earlier than the third moment.

[0241] Among them, step S1103 may correspond to step S702, and this step may refer to the relevant description of step S1101, which will not be repeated here.

[0242] S1104. At the fourth moment, the electronic device adjusts the motor to the fourth position, and the electronic device displays a fourth image, and the clarity of the fourth image is higher than that of the third image; wherein the second tilt angle belongs to the first preset interval, the distance between the fourth position and the third position is positively correlated with the second compensation value, the second compensation value is positively correlated with the second tilt angle, and the second compensation value is less than the first threshold value; the third moment is earlier than the fourth moment.

[0243] Among them, step S1104 may correspond to steps S705-S710, and this step may refer to the relevant description of step S1102, which will not be repeated here.

[0244] Specifically, S1103 and S1104 can be regarded as the second scenario in which the electronic device adjusts the motor position at the second tilt angle; at the third moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the fourth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the second tilt angle belongs to the first preset area, in the preset list, the first preset area corresponds to the first threshold, the second compensation value is the compensation value calculated based on the second tilt angle, and the second compensation value is less than the first threshold, which can correspond to the process corresponding to step S707.

[0245] It can be understood that, by comparing the first scene with the second scene, it can be found that the first tilt angle and the second tilt angle both belong to the first preset interval. In the focusing process of the two scenes, the compensation value threshold is the first threshold corresponding to the first tilt angle. For multiple tilt angles in the same preset interval, the compensation value threshold used by the electronic device is the same; for example, Fig. 9 For example, in the preset interval of 18°-28°, the compensation value threshold used for the tilt angle of 20° and the tilt angle of 25° is the same. In a possible implementation, in the first scene and the second scene, the compensation value is less than the first threshold, so the electronic device obtains the motor position to be adjusted based on the compensation value and the calculated focus value.

[0246] S1105. At the fifth moment, the electronic device is adjusted to the third tilt angle again, the motor is located at the fifth position, the electronic device displays the fifth image, the fifth position corresponds to the third focus value, and the fourth moment is earlier than the fifth moment.

[0247] Among them, step S1105 may correspond to step S702, and this step may refer to the relevant description of step S1101, which will not be repeated here.

[0248] S1106. At the sixth moment, the electronic device adjusts the motor to the sixth position, and the electronic device displays the sixth image, and the clarity of the sixth image is higher than that of the fifth image; wherein, the third tilt angle belongs to the second preset interval, and the value in the second preset interval does not overlap with the value in the first preset interval, and the electronic device is also provided with a second threshold corresponding to the second preset interval, and the second threshold is different from the first threshold, and the distance between the sixth position and the fifth position is positively correlated with the third compensation value, and the third compensation value is positively correlated with the third tilt angle, and the third compensation value is less than the second threshold; the fifth moment is earlier than the sixth moment.

[0249] Among them, step S1106 may correspond to steps S705-S710. This step may refer to the relevant description of step S1102 and will not be repeated here.

[0250] Specifically, S1105 and S1106 can be regarded as the third scenario in which the electronic device adjusts the motor position at the third tilt angle; at the fifth moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the sixth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the third tilt angle belongs to the second preset area, in the preset list, the second preset area corresponds to the second threshold, the third compensation value is the compensation value calculated based on the third tilt angle, and the third compensation value is less than the second threshold, which can correspond to the process corresponding to step S707.

[0251] It can be understood that, by comparing the first scene with the third scene, it can be found that the first tilt angle and the third tilt angle belong to the first preset interval and the second preset interval respectively. In the focusing process of the two scenes, the compensation value thresholds are the first threshold and the second threshold respectively. For multiple tilt angles in different preset intervals, the compensation value thresholds used by the electronic device are different; for example, Fig. 9 For example, the compensation value threshold used for the tilt angle 20° in the preset interval 18°-28° and the tilt angle 30° in the preset interval 28°-38° is different. In a possible implementation, in the first scenario, the first compensation value is less than the first threshold, and the electronic device obtains the motor position to be adjusted according to the first compensation value and the first focus value; in the third scenario, the third compensation value is less than the second threshold, and the electronic device obtains the motor position to be adjusted according to the third compensation value and the third focus value.

[0252] In the embodiment of the present application, the electronic device divides the tilt angle into regions to obtain a plurality of preset intervals. Each preset interval is provided with a compensation value threshold value under the preset interval, which improves the accuracy of the compensation value threshold value. When the compensation value is less than the compensation value threshold value, the compensation value obtained by the electronic device is more accurate, thereby improving the accuracy of the compensation value, and further reducing the scene of blurred camera imaging.

[0253] Optionally, the electronic device also includes a motor drive, and before the electronic device adjusts the motor to the second position, it also includes: the electronic device searches for a first threshold corresponding to a first preset interval based on the first tilt angle; the electronic device calculates a first compensation value using the first tilt angle; the first compensation value is positively correlated with the sine value of the first tilt angle; when the first compensation value is less than the first threshold, the electronic device obtains a second position based on the first compensation value and the first focus value; the second position is positively correlated with the sum of the first compensation value and the first focus value; and the electronic device sends the second position to the motor drive.

[0254] Among them, the first preset interval can be any preset interval, for example, the first preset interval can be any preset interval in preset interval 1, preset interval 2...preset interval N, and the first preset interval does not specifically refer to preset interval 1; the first inclination angle can be any inclination angle under the first preset interval.

[0255] This step may correspond to steps S705-S708, and the second position may be the position of the motor to be adjusted. This step may refer to the relevant descriptions of steps S705-S708, which will not be repeated here.

[0256] In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

[0257] Optionally, the first compensation value satisfies the following formula:

[0258] offset=sinθ×offset0

[0259] Wherein, offset is the first compensation value, θ is the first tilt angle, and offset0 is the preset compensation value threshold.

[0260] It should be noted that the embodiment of the present application takes the first compensation value as an example to illustrate the method for calculating the compensation value. The embodiment of the present application may also use the formula to calculate the second compensation value, the third compensation value, the fourth compensation value, etc., which will not be described in detail in the embodiment of the present application. In addition, the electronic device may also calculate the compensation value threshold based on a modified formula of the formula. For example, the electronic device may also use formula (8) to calculate the compensation value.

[0261] In this way, the electronic device can use the compensation value calculation formula to obtain the compensation value, so as to use the value in the subsequent focusing process to improve the focusing accuracy.

[0262] Optionally, the focusing method further includes:

[0263] (1) At the seventh moment, the electronic device is adjusted to the fourth tilt angle again, the motor is located at the seventh position, the electronic device displays the seventh image, the seventh position corresponds to the fourth focus value, and the sixth moment is earlier than the seventh moment.

[0264] Among them, this step may correspond to step S702, and this step may refer to the relevant description at step S1101, which will not be repeated here.

[0265] (2) At the eighth moment, the electronic device adjusts the motor to the eighth position, and the electronic device displays the eighth image, and the clarity of the eighth image is higher than that of the seventh image; wherein the fourth tilt angle belongs to the third preset interval, and the value in the third preset interval does not overlap with the value in the second preset interval. The electronic device is also provided with a third threshold corresponding to the third preset interval, and the third threshold is different from the second threshold. The distance between the eighth position and the seventh position is positively correlated with the third threshold, the fourth compensation value is greater than or equal to the third threshold, and the fourth compensation value is positively correlated with the fourth tilt angle. The seventh moment is earlier than the eighth moment.

[0266] Among them, this step may correspond to steps S705, S706, S711, S708-S710, and the fourth position may be the focus position after the electronic device uses the compensation value threshold (third threshold) to correct the calculated focus value (fourth focus value); the focus value corresponding to the fourth position has a smaller difference with the actual focus value, so the clarity of the fourth image is higher than the clarity of the third image.

[0267] Specifically, step (1) and step (2) can be regarded as the fourth scenario in which the electronic device adjusts the motor position at the fourth tilt angle; at the seventh moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the eighth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the fourth tilt angle belongs to the third preset area, in the preset list, the third preset area corresponds to the third threshold value, the fourth compensation value is the compensation value calculated based on the fourth tilt angle, and the fourth compensation value is greater than or equal to the third threshold value, which can correspond to the process corresponding to step S711.

[0268] It is understandable that by comparing the third scene with the fourth scene, it can be found that: the third tilt angle belongs to the second preset interval, the fourth tilt angle belongs to the third preset interval, and the value of the third preset interval does not overlap with the value of the second preset interval. In the third scene, the third compensation value is less than the second threshold value, so the electronic device uses the third compensation value to correct the third focus value. In the fourth scene, the fourth compensation value is greater than or equal to the third threshold value, so the electronic device uses the third threshold value to correct the fourth focus value.

[0269] In this way, the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value. At this time, the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

[0270] Optionally, before the electronic device adjusts the motor to the eighth position, the method further includes:

[0271] The electronic device searches for the third threshold value corresponding to the third preset interval according to the fourth tilt angle; the electronic device calculates the fourth compensation value using the fourth tilt angle; the fourth compensation value is positively correlated with the sine value of the fourth tilt angle; when the fourth compensation value is greater than or equal to the third threshold value, the electronic device obtains the eighth position based on the third threshold value and the fourth focus value; the eighth position is positively correlated with the sum of the third threshold value and the fourth focus value; the electronic device sends the eighth position to the motor drive.

[0272] Among them, the third preset interval can be any preset interval, for example, the third preset interval can be any preset interval in preset interval 1, preset interval 2...preset interval N, and the third preset interval does not specifically refer to preset interval 3; the fourth inclination angle can be any inclination angle under the third preset interval.

[0273] This step may correspond to steps S705, S706, S711, and S708. The eighth position may be the position of the motor to be adjusted. This step may refer to the relevant descriptions of steps S705, S706, S711, and S708, and will not be repeated here.

[0274] In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

[0275] Optionally, also include:

[0276] (1) At the ninth moment, the electronic device is adjusted to the fifth tilt angle again, the motor is located at the ninth position, and the electronic device displays a ninth image. The ninth image includes a preset target object. The target object is an object whose distance from the electronic device exceeds a distance threshold. The ninth position corresponds to the fifth focus value. The eighth moment is earlier than the ninth moment.

[0277] Among them, this step may correspond to step S1002. The fifth focus value may be a calculated focus value obtained by the electronic device based on the AF algorithm, and the calculated focus value may be a focus position when the electronic device is in a non-tilted state. After obtaining the fifth focus value, the electronic device adjusts the motor to a ninth position corresponding to the fifth focus value. The target object is an object whose distance from the electronic device exceeds a distance threshold, for example, the target object is related to telephoto shooting, such as clouds, the moon, distant buildings, etc.

[0278] It is understandable that at the ninth moment, there is no obvious correspondence between the ninth position and the fifth tilt angle, and the motor is affected by its own gravity, resulting in a difference between the fifth focus value and the actual focus position. Therefore, when the camera is at the ninth position, the electronic device does not focus accurately, and the clarity of the ninth image captured by the camera is not high.

[0279] (2) At the tenth moment, the electronic device adjusts the motor to the tenth position, and the electronic device displays the tenth image, which includes the target object, and the clarity of the tenth image is higher than that of the ninth image; the electronic device is also provided with a fourth threshold value of the target object at the fifth tilt angle, the distance between the tenth position and the ninth position is positively correlated with the fifth compensation value, the fifth compensation value is positively correlated with the fifth tilt angle, and the fifth compensation value is less than the fourth threshold value; wherein, the fifth tilt angle belongs to the fourth preset interval, and the electronic device is also provided with a threshold value corresponding to the fourth preset interval, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth moment is earlier than the tenth moment.

[0280] This step may correspond to steps S1005-S1012. The tenth position may be the focus position after the electronic device corrects the calculated focus value (fifth focus value) using the compensation value (fifth compensation value); the difference between the focus value corresponding to the tenth position and the actual focus position is small, so the clarity of the tenth image is higher than that of the ninth image.

[0281] Specifically, step (1) and step (2) can be regarded as the fifth scenario in which the electronic device adjusts the motor position at the fifth tilt angle; at the ninth moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the tenth moment, the electronic device corrects the calculated focus value based on the compensation value. In step (2), since the photographed object is the target object, the electronic device can use the compensation value threshold (fourth threshold) corresponding to the target object at the fifth tilt angle instead of the threshold corresponding to the preset interval, so the fourth threshold is different from the threshold corresponding to the fourth preset interval.

[0282] In this way, when photographing a target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy, thereby improving the accuracy of the compensation value threshold and thus improving the accuracy of the focus position.

[0283] Optionally, before the electronic device adjusts the motor position to the tenth position, the method further includes:

[0284] The electronic device obtains a ninth image, and determines whether the photographed object in the ninth image is a target object; when the photographed object in the ninth image is a target object, the electronic device searches for a fourth threshold value according to the target object and a fifth tilt angle; the electronic device calculates a fifth compensation value using the fifth tilt angle; when the fifth compensation value is less than the fourth threshold value, the electronic device obtains a tenth position based on the fifth compensation value and the fifth focus value; the tenth position is positively correlated with the sum of the fifth compensation value and the fifth focus value; the electronic device sends the tenth position to the motor drive.

[0285] For this step, please refer to the relevant description in steps S1005-S1010, which will not be repeated here.

[0286] In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

[0287] Optionally, also include:

[0288] (1) At the eleventh moment, the electronic device is adjusted to the sixth tilt angle again, the motor is located at the eleventh position, the electronic device displays the eleventh image, the eleventh image includes the target object, the eleventh position corresponds to the sixth focus value, and the tenth moment is earlier than the eleventh moment.

[0289] For this step, please refer to the relevant description in the step shown at the ninth moment, which will not be repeated here.

[0290] (2) At the twelfth moment, the electronic device adjusts the motor to the twelfth position, and the electronic device displays the twelfth image, which includes the target object, and the clarity of the twelfth image is higher than that of the eleventh image; the electronic device is also provided with a fifth threshold value corresponding to the target object at a sixth tilt angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold value, the sixth compensation value is greater than or equal to the fifth threshold value, and the sixth compensation value is positively correlated with the sixth tilt angle; wherein the sixth tilt angle belongs to the fourth preset interval, the fifth threshold value is different from the threshold value corresponding to the fourth preset interval, and the fifth threshold value is different from the fourth threshold value; the eleventh moment is earlier than the twelfth moment.

[0291] Among them, this step may correspond to steps S1005-S1008, S1013, S1010-S1012.

[0292] Specifically, step (1) and step (2) can be regarded as the sixth scene in which the electronic device adjusts the motor position at the sixth tilt angle; at the eleventh moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the twelfth moment, the electronic device corrects the calculated focus value based on the compensation value threshold. In step (2), since the photographed object is the target object, the electronic device can use the compensation value threshold (fifth threshold) corresponding to the target object at the sixth tilt angle instead of the threshold corresponding to the preset interval, so the fifth threshold is different from the threshold corresponding to the fourth preset interval.

[0293] It is understandable that by comparing the fifth scene with the sixth scene, it can be found that the fifth tilt angle and the sixth tilt angle both belong to the fourth preset interval, but when the electronic device photographs the target object, the electronic device uses the compensation value threshold of the target object at a specific tilt angle, rather than the threshold corresponding to the preset interval, so the fourth threshold and the fifth threshold are irrelevant to the threshold corresponding to the fourth preset interval. At the same time, the compensation value thresholds corresponding to the same target object at different tilt angles are also different, for example, the fourth threshold is different from the fifth threshold.

[0294] In this way, when shooting the target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy to improve the accuracy of the compensation value threshold; the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value; the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

[0295] Optionally, before the electronic device adjusts the motor position to the twelfth position, it also includes: the electronic device obtains the eleventh image, and determines whether the photographed object in the eleventh image is the target object; when the photographed object in the eleventh image is the target object, the electronic device searches for the fifth threshold according to the target object and the sixth tilt angle; the electronic device calculates the sixth compensation value using the sixth tilt angle; when the sixth compensation value is greater than or equal to the fifth threshold, the electronic device obtains the twelfth position based on the fifth threshold and the sixth focus value; the twelfth position is positively correlated with the sum of the fifth threshold and the sixth focus value; the electronic device sends the twelfth position to the motor drive.

[0296] For this step, please refer to the relevant descriptions in steps S1005-S1008, S1013, and S1010, which will not be repeated here.

[0297] In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

[0298] Optionally, the first tilt angle is related to inertial measurement unit IMU data, where the IMU data is obtained by the electronic device based on a gyroscope sensor; the first tilt angle satisfies any of the following formulas:

[0299]

[0300] or;

[0301]

[0302] or;

[0303]

[0304] Among them, gSensor.x is the angular velocity of the electronic device in the x-axis direction when the electronic device is at the first tilt angle, gSensor.y is the angular velocity of the electronic device in the y-axis direction when the electronic device is at the first tilt angle, and gSensor.z is the angular velocity of the electronic device in the z-axis direction when the electronic device is at the first tilt angle.

[0305] It should be noted that the embodiment of the present application takes the first tilt angle as an example to illustrate the calculation method of the tilt angle. The embodiment of the present application can also use the formula to calculate the second tilt angle, the third tilt angle, the fourth tilt angle, etc., which will not be described in detail in the embodiment of the present application. In addition, the electronic device can also calculate the compensation value threshold based on a modified formula of the formula, which will not be listed one by one in the embodiment of the present application.

[0306] In this way, the electronic device can use the tilt angle calculation formula to obtain the current tilt angle, so as to use this value in the subsequent focusing process to improve the focusing accuracy.

[0307] The focusing method of the embodiment of the present application has been described above, and the device for executing the above focusing method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the relevant device provided by the embodiment of the present application can execute the steps in the above focusing method.

[0308] like Fig.12 As shown, the focusing device 1200 can be used in a communication device, a circuit, a hardware component or a chip, and the focusing device includes: a display unit 1201 and a processing unit 1202. The display unit 1201 is used to support the display step performed by the focusing device 1200; the processing unit 1202 is used to support the focusing device 1200 to perform the information processing step.

[0309] In a possible implementation, the focusing device 1200 may also include a communication unit 1203. Specifically, the communication unit is used to support the focusing device 1200 to perform the steps of sending and receiving data. The communication unit 1203 may be an input or output interface, a pin or a circuit.

[0310] In a possible embodiment, the focusing device may further include: a storage unit 1204. The processing unit 1202 and the storage unit 1204 are connected via a line. The storage unit 1204 may include one or more memories, and the memory may be a device used to store programs or data in one or more devices or circuits. The storage unit 1204 may exist independently and be connected to the processing unit 1202 of the focusing device via a communication line. The storage unit 1204 may also be integrated with the processing unit 1202.

[0311] The storage unit 1204 can store computer-executable instructions of the method in the terminal device so that the processing unit 1202 executes the method in the above embodiment. The storage unit 1204 can be a register, a cache, or a RAM, etc. The storage unit 1204 can be integrated with the processing unit 1202. The storage unit 1204 can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, and the storage unit 1204 can be independent of the processing unit 1202.

[0312] The focusing 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 devices can refer to the above related descriptions, which will not be repeated here.

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

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

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

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

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

[0318] 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 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0319] 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 focusing method, characterized in that: Applicable to an electronic device provided with a camera and a motor, wherein the motor is used to drive the camera to move, comprising: At a first moment, the electronic device starts a camera application, the tilt angle of the electronic device is a first tilt angle, the motor is located at a first position, the electronic device displays a first image, the first position corresponds to a first focus value, the tilt angle is an angle between an extension direction L of the camera lens and the Y axis, the Y axis is perpendicular to the gravity direction of the electronic device, and the plane where the lens extension direction L and the Y axis are located is parallel to the gravity direction of the electronic device; At a second moment, the electronic device adjusts the motor to a second position, and the electronic device displays a second image; the clarity of the second image is higher than that of the first image; wherein the first tilt angle belongs to a first preset interval, the electronic device is provided with a first threshold corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with a first compensation value, the first compensation value is positively correlated with the first tilt angle, and the first compensation value is less than the first threshold; the first moment is earlier than the second moment; At a third moment, the electronic device is adjusted to a second tilt angle, the motor is located at a third position, the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; the second moment is earlier than the third moment; At a fourth moment, the electronic device adjusts the motor to a fourth position, and the electronic device displays a fourth image, the clarity of the fourth image is higher than the clarity of the third image; wherein the second tilt angle belongs to the first preset interval, the distance between the fourth position and the third position is positively correlated with the second compensation value, the second compensation value is positively correlated with the second tilt angle, and the second compensation value is less than the first threshold value; the third moment is earlier than the fourth moment; At a fifth moment, the electronic device is adjusted to a third tilt angle again, the motor is located at a fifth position, the electronic device displays a fifth image, the fifth position corresponds to a third focus value, and the fourth moment is earlier than the fifth moment; At a sixth moment, the electronic device adjusts the motor to a sixth position, and the electronic device displays a sixth image, the clarity of the sixth image being higher than that of the fifth image; wherein the third tilt angle belongs to a second preset interval, the value in the second preset interval does not overlap with the value in the first preset interval, a second threshold corresponding to the second preset interval is further provided in the electronic device, the second threshold is different from the first threshold, the distance between the sixth position and the fifth position is positively correlated with a third compensation value, the third compensation value is positively correlated with the third tilt angle, and the third compensation value is less than the second threshold; the fifth moment is earlier than the sixth moment; The compensation value is used to adjust the motor position.

2. The method according to claim 1, characterized in that The electronic device further includes a motor drive, and before the electronic device adjusts the motor to the second position, further includes: The electronic device searches for the first threshold corresponding to the first preset interval according to the first tilt angle; The electronic device calculates the first compensation value using the first tilt angle; the first compensation value is positively correlated with the sine value of the first tilt angle, and the value range of the first tilt angle is -90°-90°; When the first compensation value is less than the first threshold, the electronic device obtains the second position based on the first compensation value and the first focus value; the second position is positively correlated with the sum of the first compensation value and the first focus value; The electronic device sends the second position to the motor driver.

3. The method according to claim 1 or 2, characterized in that: The first compensation value satisfies the following formula: in, is the first compensation value, is the first tilt angle, is the preset compensation value threshold.

4. The method according to claim 2, characterized in that: Also includes: At the seventh moment, the electronic device is adjusted to the fourth tilt angle again, the motor is located at the seventh position, the electronic device displays the seventh image, the seventh position corresponds to the fourth focus value, and the sixth moment is earlier than the seventh moment; At the eighth moment, the electronic device adjusts the motor to the eighth position, and the electronic device displays an eighth image, and the clarity of the eighth image is higher than that of the seventh image; wherein, the fourth inclination angle belongs to a third preset interval, and the value in the third preset interval does not overlap with the value in the second preset interval. A third threshold corresponding to the third preset interval is also provided in the electronic device, and the third threshold is different from the second threshold. The distance between the eighth position and the seventh position is positively correlated with the third threshold, the fourth compensation value is greater than or equal to the third threshold, and the fourth compensation value is positively correlated with the fourth inclination angle, and the seventh moment is earlier than the eighth moment.

5. The method according to claim 4, characterized in that Before the electronic device adjusts the motor to the eighth position, the method further includes: The electronic device searches for the third threshold corresponding to the third preset interval according to the fourth tilt angle; The electronic device calculates the fourth compensation value using the fourth tilt angle; the fourth compensation value is positively correlated with the sine value of the fourth tilt angle, and the value range of the fourth tilt angle is -90°-90°; When the fourth compensation value is greater than or equal to the third threshold, the electronic device obtains the eighth position based on the third threshold and the fourth focus value; the eighth position is positively correlated with the sum of the third threshold and the fourth focus value; The electronic device sends the eighth position to the motor driver.

6. The method according to claim 2 or 5, characterized in that: Also includes: At a ninth moment, the electronic device is adjusted to the fifth tilt angle again, the motor is located at a ninth position, the electronic device displays a ninth image, the ninth image includes a preset target object, the target object is an object whose distance from the electronic device exceeds a distance threshold, the ninth position corresponds to the fifth focus value, and the eighth moment is earlier than the ninth moment; At the tenth moment, the electronic device adjusts the motor to the tenth position, and the electronic device displays the tenth image, the tenth image includes the target object, and the clarity of the tenth image is higher than that of the ninth image; the electronic device is also provided with a fourth threshold value of the target object at the fifth tilt angle, the distance between the tenth position and the ninth position is positively correlated with the fifth compensation value, the fifth compensation value is positively correlated with the fifth tilt angle, and the fifth compensation value is less than the fourth threshold value; wherein, the fifth tilt angle belongs to the fourth preset interval, and the electronic device is also provided with a threshold value corresponding to the fourth preset interval, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth moment is earlier than the tenth moment.

7. The method according to claim 6, characterized in that Before the electronic device adjusts the motor position to the tenth position, the method further includes: The electronic device obtains the ninth image, and determines whether the photographed object in the ninth image is the target object; When the photographed object in the ninth image is the target object, the electronic device searches for the fourth threshold value according to the target object and the fifth tilt angle; The electronic device calculates the fifth compensation value using the fifth tilt angle; When the fifth compensation value is less than the fourth threshold, the electronic device obtains the tenth position based on the fifth compensation value and the fifth focus value; the tenth position is positively correlated with the sum of the fifth compensation value and the fifth focus value; The electronic device sends the tenth position to the motor driver.

8. The method according to any one of claims 2, 5 and 7, characterized in that: Also includes: At the eleventh moment, the electronic device is adjusted to the sixth tilt angle again, the motor is located at the eleventh position, the electronic device displays the eleventh image, the eleventh image includes the target object, the eleventh position corresponds to the sixth focus value, and the tenth moment is earlier than the eleventh moment; At the twelfth moment, the electronic device adjusts the motor to the twelfth position, and the electronic device displays a twelfth image, the twelfth image includes the target object, and the clarity of the twelfth image is higher than that of the eleventh image; the electronic device is also provided with a fifth threshold value corresponding to the target object at the sixth tilt angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold value, the sixth compensation value is greater than or equal to the fifth threshold value, and the sixth compensation value is positively correlated with the sixth tilt angle; wherein, the sixth tilt angle belongs to the fourth preset interval, the fifth threshold value is different from the threshold value corresponding to the fourth preset interval, and the fifth threshold value is different from the fourth threshold value; the eleventh moment is earlier than the twelfth moment.

9. The method according to claim 8, characterized in that Before the electronic device adjusts the motor position to the twelfth position, the method further includes: The electronic device obtains the eleventh image, and determines whether the photographed object in the eleventh image is the target object; When the photographed object in the eleventh image is the target object, the electronic device searches for the fifth threshold value according to the target object and the sixth tilt angle; The electronic device calculates the sixth compensation value using the sixth tilt angle; When the sixth compensation value is greater than or equal to the fifth threshold, the electronic device obtains the twelfth position based on the fifth threshold and the sixth focus value; the twelfth position is positively correlated with the sum of the fifth threshold and the sixth focus value; The electronic device sends the twelfth position to the motor driver.

10. 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 9.

11. 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 9 is implemented.

12. A computer program product, characterized in that The method comprises a computer program, which, when being executed, enables a computer to execute the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Automatic focusing method and device

    CN102902132A

  • Adjustment and application method for tilting compensation control of lens of automatic focusing camera module

    CN103984199A