Focusing method, device and equipment and readable storage medium

By determining the fine first focusing range based on the target object distance and adjusting the motor, the problem of long focusing time in the prior art is solved, and the effect of improving the focus speed is achieved.

CN119697492AActive Publication Date: 2025-03-25GUANGZHOU SHIYUAN ELECTRONICS CO LTD +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202311249219.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-25
Publication Date
2025-03-25
Estimated Expiration
2043-09-25

AI Technical Summary

Technical Problem

In the existing focusing methods, the large overall focus range leads to a large search range, which in turn increases the focus time and reduces the focus speed.

Method used

Fast focus is achieved by determining a fine first focus range based on the target object distance and adjusting the motor according to the range. The step length within the first focus range is smaller than the preset step length, and the step length outside the range is greater than or equal to the preset step length.

Benefits of technology

Reduces search range, shortens focus time, and thus improves focus speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697492A_ABST
    Figure CN119697492A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a focusing method, device and equipment and a readable storage medium, a first motor value corresponding to the farthest object distance of a lens module and a second motor value corresponding to the nearest object distance of the lens module are pre-burnt on electronic equipment, and offsets corresponding to different object distances are stored. During shooting, the electronic equipment determines a focusing area of a current frame image in a view range of a lens module, inquires a mapping table according to a target object distance between a target object corresponding to the focusing area and the lens module to determine an offset, determines a first focusing range according to the offset and a first motor value or a second motor value, and carries out focusing on the current frame image according to the first focusing range and the second focusing range. According to the technical scheme, the motor is adjusted with a small step length in the first focusing range, the motor is adjusted with a large step length outside the first range, the number of searching times is reduced to a certain degree, the focusing time is shortened, and therefore the purpose of improving the focusing speed is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of camera technology, and in particular to a focusing method, device, equipment and readable storage medium. Background Art

[0002] Focusing refers to the process in which an electronic device adjusts the distance between the lens and the imaging surface according to the object distance so that the image of the object is clear. The object distance refers to the distance between the lens and the object.

[0003] The maximum focus value (FV) search method is a common focusing method. When the lens of an electronic device is aimed at the object to be photographed, the motor in the lens module of the electronic device drives the lens to move gradually from the bottom to the top and acquire multiple images. In this process, the electronic device calculates and records the FV corresponding to each image, and generates a relationship curve between the image FV and the lens position. Finally, the peak of the relationship curve is used as the focus position of the electronic device.

[0004] In the above focusing method, the search range is related to the total focusing range of the motor. The larger the total focusing range, the larger the search range and the longer the search time, resulting in a too slow focusing speed, and then a too slow shooting speed. Summary of the invention

[0005] The embodiments of the present application provide a focusing method, apparatus, device and readable storage medium, which determine a first focusing range for fine search according to the target object distance, adjust the motor according to the first focusing range to quickly focus, reduce the search range and achieve the purpose of increasing the focusing speed.

[0006] In a first aspect, an embodiment of the present application provides a focusing method, comprising:

[0007] Determining a focus area of ​​a current frame image, where the current frame image is an image within a field of view of a lens module of the electronic device;

[0008] querying a mapping table according to a target object distance to determine a first focusing range of a motor, wherein the motor is used to drive the lens module, the target object distance is used to indicate a distance between a target object corresponding to the focusing area and the lens module, and the mapping table is used to indicate an offset corresponding to different object distances;

[0009] The motor is adjusted according to the first focus range to search for a focus position of the electronic device, wherein a step length within the first focus range is smaller than a preset step length, and a step length outside the first focus range is greater than or equal to a preset step length.

[0010] In a second aspect, an embodiment of the present application provides a focusing device, comprising:

[0011] A determination module, used to determine a focus area of ​​a current frame image, wherein the current frame image is an image within a field of view of a lens module of the electronic device;

[0012] a processing module, configured to query a mapping table according to a target object distance to determine a first focusing range of a motor, wherein the motor is configured to drive the lens module, the target object distance is configured to indicate a distance between a target object corresponding to the focusing area and the lens module, and the mapping table is configured to indicate an offset corresponding to different object distances;

[0013] A focusing module is used to adjust the motor according to the first focusing range to search for a focusing position of the electronic device, wherein the step length within the first focusing range is less than a preset step length, and the step length outside the first focusing range is greater than or equal to the preset step length.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the method described in the first aspect or various possible implementation methods of the first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the method described in the first aspect or various possible implementation methods of the first aspect.

[0016] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computing program, and when the computer program is executed by a processor, the method described in the first aspect or various possible implementation methods of the first aspect is implemented.

[0017] The focusing method, device, equipment and readable storage medium provided by the embodiments of the present application are characterized in that the electronic device pre-burns the first motor value corresponding to the farthest object distance of the lens module and the second motor value corresponding to the closest object distance, and stores the offsets corresponding to different object distances. When shooting, the electronic device determines the focus area of ​​the current frame image within the field of view of the lens module, determines an offset by querying the mapping table of the target object distance between the target object corresponding to the focus area and the lens module, determines the first focus range according to the offset and the first motor value or the second motor value, adjusts the motor with a smaller step size within the first focus range, and adjusts the motor with a larger step size outside the first range, thereby reducing the number of searches to a certain extent and shortening the focus time, thereby achieving the purpose of increasing the focus speed. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 is an imaging principle diagram applicable to the focusing method provided in the embodiment of the present application;

[0020] Figure 2 is a schematic diagram of an electronic device for executing the focusing method provided in an embodiment of the present application;

[0021] Figure 3 is a flow chart of a focusing method provided in an embodiment of the present application;

[0022] Figure 4 is a flow chart of searching for a focus position in a focusing method provided in an embodiment of the present application;

[0023] Figure 5 is a schematic diagram of the process of rule search in the focusing method provided in an embodiment of the present application;

[0024] Figure 6 A schematic diagram of a focusing device provided in an embodiment of the present application;

[0025] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In scenes such as taking photos, shooting videos, and video conferencing, in order to make the image clear, electronic devices are required to focus on the subject. The maximum FV search method is a common focusing method. In this method, the motor is driven from the minimum position of the motor, and the motor is adjusted in equal steps until the motor reaches the maximum position. During the adjustment of the motor, the motor drives the lens to move gradually from the bottom to the top and acquire multiple images. The electronic device calculates and records the FV corresponding to each image, and generates a relationship curve between the image FV and the lens position. Finally, the peak of the relationship curve is used as the focus position of the electronic device.

[0027] The motor has an adjustable range. When the adjustable range of the motor is relatively large, the time to search for the maximum FV is too long, resulting in a slow focusing speed. Moreover, if only one search is performed, it is easy to search for the wrong maximum FV, resulting in poor focusing quality and poor focusing effect.

[0028] Based on this, the embodiments of the present application provide a focusing method, apparatus, device and readable storage medium, which determines a first focusing range for fine search according to the target object distance, adjusts the motor according to the first focusing range to focus quickly, reduces the search range and achieves the purpose of increasing the focusing speed.

[0029] Figure 1 This is an imaging principle diagram applicable to the focusing method provided in the embodiment of the present application. Figure 1 , there is a big tree in the field of view of the lens module. The distance between the big tree and the lens module is the object distance, the distance from the optical center of the lens module to the image sensor is the image distance, the image sensor is the imaging place, and the plane where the image sensor is located is the image plane. The distance from the optical center of the lens module to the focus is the focal length. Focusing refers to the process of adjusting the distance between the lens module and the imaging plane according to the object distance to make the image of the object clear.

[0030] The focusing method provided in the embodiments of the present application is applied to electronic devices, such as smart interactive tablets, video cameras, cameras, personal computers, tablet computers, wearable devices, vehicle-mounted terminals, monitoring equipment, etc.

[0031] Figure 2 is a schematic diagram of an electronic device for executing the focusing method provided in an embodiment of the present application. Figure 2 The electronic device 200 is provided with a lens module 21. The focusing method described in the embodiment of the present application can be implemented by an application software (application, APP) or a processor in the electronic device 200. The lens module 21 is also called a camera, etc., which can take images or videos.

[0032] Generally, the voice coil motor of an electronic device includes a coil, a magnet group, and a spring, etc. The lens module 21 is locked into the voice coil motor (VCM) to achieve focusing. The position of the spring is controlled by using a permanent magnetic field to change the magnitude of the coil current in the motor, driving the lens to move and change the image distance, thereby achieving automatic focusing. Focusing refers to the process of changing the focal length to make the image clear.

[0033] In the embodiments of the present application, some optimizations are made to the structure of the electronic device, including but not limited to the use of variable zoom length, adaptive adjustment, micro-focus, etc., to achieve more efficient, fast and accurate focusing.

[0034] Variable zoom length refers to the variable zoom length of the lens module to improve the image quality of different focal lengths and make more precise focus adjustments. The switch between different imaging effects can be achieved by changing the structure and magnification of the lens module. When the total focus range needs to be changed, the position of the optical focus can be changed by adjusting the zoom length, thereby achieving more accurate and efficient focus.

[0035] Adaptive adjustment technology automatically adjusts the focus distance of different parts of the target object to achieve a more accurate and efficient focusing effect. By analyzing the shooting environment, the angle and position changes of the object, and combining intelligent algorithms for adaptive adjustment, the focal length can be changed anytime and anywhere, making the focus more accurate and efficient.

[0036] Micro focus technology is a technology that achieves more accurate focusing by slightly adjusting the focus position of the camera lens. Micro focus technology uses the adjustment mechanism of the lens module to slightly move the position of the focusing lens to achieve precise adjustment of the focus point. At the same time, micro focus combines variable zoom length and adaptive adjustment technology to quickly change the focus center point through slight focus adjustments to adapt to various scenarios and requirements.

[0037] Figure 3 : is a flow chart of the focusing method provided by an embodiment of the present application. The execution subject of the embodiment of the present application is an electronic device, which has a lens module, and the motor can be set on the electronic device or on the lens module. This embodiment includes:

[0038] 301. Determine a focus area of ​​a current frame image, where the current frame image is an image within a field of view of a lens module of an electronic device.

[0039] In the embodiment of the present application, the image within the field of view of the lens module is the preview image within the viewfinder of the lens module. The electronic device determines the target object from the current frame image through image segmentation, feature extraction, etc., and determines the focus area for each target object.

[0040] Taking a video conference scene as an example, there are 10 participants in the current frame image, that is, there are 10 target objects in the current frame image. For each target object, the electronic device determines a focus area. For example, the electronic device identifies the area where the heads of each participant are located and obtains 10 rectangular frames, that is, 10 focus areas.

[0041] 302. Query a mapping table according to the target object distance to determine a first focusing range of the motor.

[0042] In which, the motor is used to drive the lens module, the target object distance is used to indicate the distance between the target object corresponding to the focus area and the lens module, and the mapping table is used to indicate the offset corresponding to different object distances and the first motor value corresponding to the farthest object distance of the lens module and the second motor value corresponding to the closest object distance.

[0043] In the embodiment of the present application, the farthest object distance and the closest object distance of the lens modules of different manufacturers and models are different. The farthest object distance refers to the farthest distance that the lens module can shoot; the closest object distance refers to the closest distance that the lens module can shoot.

[0044] The motors of lens modules from different manufacturers and models have different adjustable ranges. For example, the adjustable range is [0,500], [0,600], etc. A motor has a total focus range, which is an interval end of the adjustable range. For example, the adjustable range is [0,500], and the total focus range is [100,460]. A total focus range has two endpoints, which are the minimum position and maximum position of the motor. The minimum position represents the position of the motor when the motor is adjusted to make the image of the object clearest at the farthest object distance, that is, the first motor value. The maximum position represents the position of the motor when the motor is adjusted to make the image of the object clearest at the closest object distance, that is, the second motor value. In the embodiments of the present application, different motor values ​​indicate that the motor is adjusted to different positions.

[0045] For example, the focusing range of the motor of lens module A is 100-460, the minimum position is 100, and the maximum position is 460. That is to say, the first motor value corresponding to the farthest object distance is 100, and the second motor value corresponding to the closest object distance is 460.

[0046] For example, the focusing range of the motor of lens module B is 200-518, the minimum position is 200, and the maximum position is 518. That is to say, the first motor value corresponding to the farthest object distance is 200, and the second motor value corresponding to the closest object distance is 518.

[0047] In the embodiment of the present application, the electronic device pre-burns the first motor value corresponding to the farthest object distance of the lens module and the second motor value corresponding to the closest object distance. In addition, the electronic device pre-stores a mapping table, which is used to indicate the offset corresponding to different object distances and the first motor value and the second motor value of the lens module.

[0048] Below, the mapping table is described in detail by taking the farthest object distance of the lens module as 10 meters, the closest object distance as 0.5 meters, and the electronic device pre-burning the first motor value corresponding to 10 meters and the second motor value corresponding to 0.5 meters as an example. For example, please refer to Table 1.

[0049] Table 1

[0050] Object distance Offset 10 meters 0 5 meters 17 3 meters 39 1.8 m 76 1.2 m 122 0.9m 168 0.7m 222 0.5m 318

[0051] Please refer to Table 1, with 10 meters as the reference standard, that is, the offset corresponding to 10 meters is 0, and different object distances correspond to different offsets. The offsets corresponding to large object distances are not much different, while the offsets corresponding to small object distances are quite different. For example, the offset corresponding to 10 meters is 0, and the offset corresponding to 5 meters is 17. The difference between the two offsets is 17, which is relatively small. The offset corresponding to 0.7 meters is 222, and the offset corresponding to 0.5 meters is 318. The difference between the two is 96, which is relatively large.

[0052] When the electronic device obtains the target object distance, an offset can be determined by looking up the table according to the target object distance.

[0053] For example, if the target object distance is 3 meters, the offset is 39. Assuming that the first motor value corresponding to the farthest object distance of 10 meters is 200, the motor value corresponding to 3 meters is approximately 200+39=239. Afterwards, the electronic device determines a first focus range according to the motor value 239 corresponding to 3 meters. For example, the first focus range is [200, 339]. Among them, 339=239+100.

[0054] For another example, if the target object distance is 4 meters, which is between 3 meters and 5 meters, the electronic device determines a first focus range according to the motor value 239 corresponding to 3 meters. For example, the first focus range is [200, 239].

[0055] 303. Adjust the motor according to the first focusing range to search for a focusing position of the electronic device, wherein a step length within the first focusing range is smaller than a preset step length, and a step length outside the first focusing range is greater than or equal to a preset step length.

[0056] In the embodiment of the present application, the first focusing range is a fine focusing range, that is, when the motor is located in the first focusing range, it is adjusted with a smaller step size. In the process of the electronic device adjusting the motor, the motor is adjusted with a smaller step size within the first focusing range, that is, the step size within the first focusing range is less than the preset step size; outside the first focusing range, it is adjusted with a larger step size, that is, the step size is greater than or equal to the preset step size. For example, the electronic device starts to adjust the motor from the minimum position, and the step size is larger. After a period of time, the motor reaches the first focusing range, and the electronic device adjusts the motor with a smaller step size.

[0057] In the traditional focusing method, when adjusting the motor, it is often started from the minimum position, and the motor is adjusted in equal steps until it reaches the maximum position. In this way, many points are searched. Obviously, in the embodiment of the present application, the adjustment is performed with a smaller step size within the first focusing range, and the adjustment is performed with a larger step size outside the first focusing range, and the equal step size adjustment is not adopted.

[0058] In the focusing method provided by the embodiment of the present application, a first motor value corresponding to the farthest object distance of the lens module and a second motor value corresponding to the closest object distance are pre-burned on the electronic device, and offsets corresponding to different object distances are stored. When shooting, the electronic device determines the focus area of ​​the current frame image within the field of view of the lens module, determines an offset by querying a mapping table based on the target object distance between the target object corresponding to the focus area and the lens module, determines a first focus range based on the offset and the first motor value or the second motor value, adjusts the motor with a smaller step size within the first focus range, and adjusts the motor with a larger step size outside the first range, thereby reducing the number of searches to a certain extent and shortening the focus time, thereby achieving the purpose of increasing the focus speed.

[0059] In the above embodiment, since the first motor value corresponding to the farthest object distance of 10 meters and the second motor value corresponding to the closest object distance are known, when the target object distance is the farthest object distance, the electronic device determines the focus position as the position of the lens module when the motor value is the first motor value.

[0060] When the target object distance is the minimum object distance, the electronic device determines the focus position as: the position of the lens module when the motor value is the second motor value.

[0061] When the target object distance is neither the farthest object distance nor the closest object distance, the electronic device queries the mapping table according to the target object distance to determine the first focus range of the motor. In the process of determining the first focus range, first, the electronic device determines the first object distance and the second object distance according to the target object distance, the first object distance being the farthest object distance or the closest object distance, and the target object distance being between the first object distance and the second object distance. Afterwards, the electronic device determines the first focus range according to the offset corresponding to the second object distance and the motor value corresponding to the first object distance.

[0062] Please refer to Table 1, taking the first object distance as the farthest object distance as an example, when there is a target object distance in Table 1, such as when the target object distance is 5 meters, the electronic device determines that the second object distance is 3 meters, and the offset corresponding to 3 meters is 39. Assuming that the motor value corresponding to the farthest object distance of 10 meters is 200, that is, the first motor value is 200, then the first focus range is [200, 239], 239=200+39.

[0063] When the first object distance is the closest object distance, if there is a target object distance in Table 1, such as 0.7 meters, the electronic device determines that the second object distance is 0.9 meters, and the offset corresponding to 0.9 meters is 168. Assuming that the motor value corresponding to the closest object distance of 0.5 meters is 518, that is, the second motor value is 518, then the first focus range is [350, 518], 350 = 518-168.

[0064] It should be noted that when there is a target object distance in Table 1, although the electronic device is used here to look up the table to determine the first focus range, and then adjust the motor according to the first focus range to search for the focus position as an example. However, the embodiment of the present application is not limited. In other feasible implementations, after the electronic device queries the mapping table to determine the offset corresponding to the target object distance, the motor value of the motor when the object distance is the target object distance can be determined according to the motor value corresponding to the first object distance and the offset corresponding to the target object distance, and the lens position corresponding to the motor value is used as the focus position. For example, the first object distance is 10 meters, the target object distance is 5 meters, the offset corresponding to 5 meters is 17, the first motor value is 200, and the motor value corresponding to 5 meters is 217. The electronic device uses the lens position corresponding to the motor value 217 as the focus position.

[0065] When the target object distance does not exist in Table 1, the electronic device determines the first object distance and the second object distance from Table 1, and the target object distance is between the first object distance and the second object distance. For example, if the target object distance is 7 meters, the first object distance is 10 meters, the second object distance is 5 meters, and the offset corresponding to 5 meters is 17. Assuming that the motor value corresponding to the farthest object distance of 10 meters is 200, that is, the first motor value is 200, then the first focus range is [200, 217], 217=200+17.

[0066] With this solution, the electronic device determines the first object distance and the second object distance based on the target object distance, where the target object distance is between the first object distance and the second object distance. Afterwards, the electronic device determines the first focusing range based on the motor value corresponding to the first object distance and the offset corresponding to the second object distance, thereby achieving the purpose of accurately and quickly determining the first focusing range.

[0067] In the embodiments of the present application, by using pre-set mapping tables, search rules, multi-point fitting equations, etc., it is possible to select a corresponding focus mode according to the scene and needs, thereby achieving accurate and efficient focusing.

[0068] Figure 4 1 is a flow chart of searching for a focus position in a focusing method provided in an embodiment of the present application. This embodiment includes:

[0069] 401. Determine a positional relationship between a current position of the motor and a total focusing range of the motor.

[0070] Among them, the total focusing range is used to indicate the minimum position of the motor and the maximum position of the motor, the minimum position is the position of the motor when the motor value of the motor is a first motor value, and the maximum position is the position of the motor when the motor value of the motor is a second motor value.

[0071] In an embodiment of the present application, two motor values ​​corresponding to object distances are pre-burned on the electronic device, which are a first motor value corresponding to the farthest object distance and a second motor value corresponding to the closest object distance. The first motor value represents: when the distance between the target object and the lens module is the farthest object distance, the position of the motor is adjusted to make the image clearest. The second motor value represents: when the distance between the target object and the lens module is the closest object distance, the position of the motor is adjusted to make the image clearest. The first motor value and the second motor value are the two ends of the total focusing range of the motor. The motor position corresponding to the first motor value is also called the minimum position of the motor, and the motor position corresponding to the second motor value is also called the maximum position of the motor. The middle position is between the maximum position and the minimum position.

[0072] The electronic device determines the relationship between the current position and the total focus range during the process of adjusting the motor to search for the focus position. For example, the electronic device determines whether the current position is between the minimum position and the middle position, or between the middle position and the maximum position.

[0073] 402. Determine an adjustment starting point from the total focus range according to the positional relationship.

[0074] Exemplarily, the method for determining the adjustment starting point is: when the current position is between the minimum position and the middle position, start searching from the minimum position. The current position is between the minimum position and the middle position, which is also called the current position is less than the middle position. For example, the total focus range is [100, 460], the minimum position is 100, the maximum position is 460, and the middle position is 280. If the current position is 150, the motor is reset to 100, and the motor is adjusted from 100, that is, the adjustment starting point is 100. The first focus range is, for example, [200, 217].

[0075] When the current position is between the middle position and the maximum position, start searching from the middle position. The current position is between the middle position and the maximum position, which is also called the current position is greater than the middle position. For example, the total focus range is [100, 460], the minimum position is 100, the maximum position is 460, and the middle position is 280. If the current position is 300, return the motor to 280, and adjust the motor from 280, that is, the adjustment starting point is 280. The first focus range is, for example, [200, 217]. During the adjustment process, when the motor is between 217 and 280, a larger step size is used; when the motor is between 200 and 217, a smaller step size is used.

[0076] 403. Adjust the motor according to the adjustment starting point and the first focusing range to search for a focusing position of the electronic device.

[0077] After the electronic device determines the adjustment starting point, it starts to adjust the motor from the adjustment starting point. During the adjustment process, a larger step length is used from the adjustment starting point to the first end of the first focusing range. A smaller step length is used within the first focusing range.

[0078] For example, if the total focus range is [100, 460], the minimum position is 100, the maximum position is 460, the middle position is 280, and the first focus range is [200, 217]. If the current position is 150, return the motor to 100. After that, for the adjustment starting point between 100 and 200, use a larger step size. For the first focus range, use a smaller step size.

[0079] With this solution, the electronic device determines the adjustment starting point based on the positional relationship between the current position of the motor and the total focusing range, determines the step size and adjusts the motor based on the adjustment starting point and the first focusing range, and then searches for the focusing position, effectively reducing the search amount while achieving the purpose of increasing the focusing speed.

[0080] Optionally, in the above embodiment, in the process of the electronic device adjusting the motor according to the adjustment starting point and the first focusing range to search for the focusing position of the electronic device, first, the electronic device determines the second focusing range and the third focusing range according to the adjustment starting point and the first end of the first focusing range. Afterwards, the electronic device starts adjusting the motor from the starting point of the second focusing range to search for the focusing position of the electronic device. Among them, the starting point of the second focusing range is the adjustment starting point, the end point of the second focusing range is the starting point of the third focusing range, the end point of the third focusing range is the first end of the first focusing range, and the two ends of the first focusing range are the first end and the second end respectively. The step sizes of the second focusing range, the third focusing range and the first focusing range are reduced successively.

[0081] For example, if the total focus range of the motor is [100, 580], the adjustment starting point is 100, the first focus range is [200, 217], and the current position is 150, the first end of the first focus range is 200, and the second end is 217. The electronic device determines that the second focus range is, for example, [100, 150], and the third focus range is, for example, [150, 200].

[0082] Figure 5 This is a schematic diagram of the rule search process in the focusing method provided in the embodiment of the present application. Figure 5, the first focus range, the second focus range and the third focus range are shown as ①, ② and ③ in the figure respectively. Among them, in the second focus range, the focus value does not change significantly with the adjustment of the motor. In the third focus range, the focus value changes more significantly than the first focus range with the adjustment of the motor. In the first focus range, the focus value changes significantly with the adjustment of the motor. Assuming that the step length of the first focus range is step length 1, the step length of the second focus range is step length 2, and the step length of the third focus range is step length 3, then step length 2>step length 3>step length 1. Obviously, Figure 5 When the focus value, that is, FV, does not change significantly, the search step length is increased; when the FV changes significantly, the search step length is reduced.

[0083] With this solution, the electronic device searches for the focus position using a regular search method. When the focus value changes slightly, the search step length is increased, and when the focus value changes significantly, the search step length is reduced. This reduces the search amount while increasing the focus speed.

[0084] Optionally, in the above embodiment, when the electronic device starts to adjust the motor from the starting point of the second focus range to search for the focus position of the electronic device, first, the motor is adjusted in the positive direction until three consecutive adjustments meet the first condition. Then, when the three consecutive adjustments meet the first condition, the motor of the lens is adjusted in the reverse direction until two consecutive adjustments meet the second condition. Among them, the first condition is used to indicate that: the focus values ​​corresponding to the first two adjustments of the three consecutive adjustments increase, and the focus values ​​corresponding to the last two adjustments decrease, and the positive adjustment refers to driving the motor so that the position of the motor gradually approaches the second end of the first focus range; the second condition is used to indicate that: the focus values ​​corresponding to the two consecutive adjustments increase, and the reverse adjustment refers to driving the motor so that the motor leaves the second end. Afterwards, the electronic device fits the relationship curve between the lens position and the focus value according to the focus values ​​when the lens is at different positions during the positive adjustment and the reverse adjustment process, and determines the focus position of the electronic device according to the relationship curve.

[0085] For example, during forward search, if the focus value rises for more than two consecutive times and then drops for two consecutive times or once, it means that the maximum focus value has been exceeded. At this time, the electronic device updates the data for fitting the relationship curve according to the focus values ​​adjusted three times in a row and the positions of the lens modules corresponding to the focus values, where the relationship curve refers to the relationship curve between the lens position and the focus value.

[0086] Afterwards, the electronic device performs a reverse search, and when the focus value rises more than twice in succession, multi-point fitting is started, and after a relationship curve is fitted, the focus position of the electronic device can be determined according to the relationship curve.

[0087] With this solution, the focus position is searched in a forward and reverse search manner, which avoids searching for an incorrect focus position and enhances the robustness and accuracy of the focus position. In addition, the focus time can be shortened.

[0088] Optionally, in the above embodiment, when the electronic device determines the focus position of the electronic device according to the relationship curve, first, it is determined whether the peak value of the relationship curve is stable. When the peak value is stable, the lens position corresponding to the peak value is used as the focus position of the electronic device.

[0089] The embodiment of the present application uses a multi-point fitting equation to solve the position of the maximum focus value. Before solving the maximum focus value, that is, solving the focus position, first determine whether the peak value of the relationship curve is stable. When the relationship curve is unstable, it triggers refocusing, that is, re-executes the forward and reverse search to fit the relationship curve between the lens position and the focus value. If the relationship curve is stable, the multi-point fitting equation is solved, and the coordinates of several search points are input through the multi-point fitting equation. Each search point includes a focus value and a lens position. After fitting the relationship curve, the peak value can be determined, and the lens position corresponding to the peak value is used as the focus position of the electronic device.

[0090] In the embodiment of the present application, the multivariate equation is solved by iteratively solving the quadratic variance. The method for solving the quadratic variance is as follows:

[0091] (1) The quadratic equation is: y = ax 2 +bx+c formula (1).

[0092] (2) Convert the quadratic equation into a linear equation: Ax+By+Cz+D=0 Formula (2)

[0093] (3) Taking the unknowns a, b, and c as the unknowns of the three-variable linear equation, we can get the following equation according to formula (1): 2 ×a+x×b+cy=0 formula (3)

[0094] According to formula (2) and formula (3), we can get: A = x 2 , B=x, C=1, D=-y.

[0095] In order to determine whether the peak value of the relationship curve is stable, in an embodiment of the present application, a threshold interval is pre-set, and the two endpoints of the threshold interval are floating point data, and the threshold interval is, for example, [0.0, 2.0]. After fitting the relationship curve, the electronic device determines the stability value of the relationship curve and compares the stability value and the threshold interval. If the stability value of the relationship curve falls into the threshold interval, it means that the peak value of the relationship curve is stable; if the stability value of the relationship curve does not fall into the threshold interval, it means that the peak value of the relationship curve is unstable, and the focus position determined according to the relationship curve is unreliable, and it is necessary to re-focus. When the stability value falls into the threshold interval, the larger the stability value, the more stable the peak value of the relationship curve. In practice, the range of the threshold interval needs to be set according to the actual lens module.

[0096] In the process of judging whether the peak value of the relationship curve is stable, the electronic device fits the equation and finds the parameters of the equation. After determining the parameters, the equation corresponding to the relationship curve can be obtained. Since in the relationship curve, the horizontal axis represents the motor position and the vertical axis represents the FV value, the value of the vertical axis can be determined by substituting the horizontal axis into the equation. Therefore, by substituting the horizontal axis corresponding to the peak value into the equation, the vertical axis corresponding to the peak value can be obtained, that is, the optimal point coordinate. The optimal point coordinates are the focus value and lens position corresponding to the peak value of the relationship curve. There are several possible situations for the optimal point coordinates:

[0097] A. If the coordinates of the optimal point are outside the interval [first motor value, second motor value], it means that the data interference is large and the data is invalid, and refocusing is required.

[0098] B. The focus value corresponding to the peak value is not in the middle of the interval [first motor value, second motor value], but on both sides, indicating that the data interference is large and invalid data needs to be refocused. The coordinates on the left or right of the focus value corresponding to the peak value need to be refitted.

[0099] C. The focus value corresponding to the peak value is in the middle of the interval [first motor value, second motor value].

[0100] Next, how to determine the stability value of the relationship curve in the above embodiment is described.

[0101] FV mean = sum of FV values ​​of each coordinate / number of coordinates.

[0102] Stability value = regression sum of squares (SSR) / sum of squares for total (SST). Where SST = |FV1-FV mean|^2+|FV2-FV mean|^2+...+|FVx-FV mean|^2. Where FV1, FV2...FVX are the actual calculated coordinate values, that is, the focus values ​​used to fit the relationship curve obtained during the forward and reverse adjustment of the motor.

[0103] SSR = |FV1'-FV mean|^2+|FV2'-FV ​​mean|^2+...+|FVx'-FV mean|^2. Among them, FV1', FV2'...FVX' are the focus values ​​calculated after substituting the horizontal coordinates into the fitted equation.

[0104] When 0<stability value<1, the lens position corresponding to the peak value in the relationship curve is used as the focus position of the electronic device.

[0105] When 1<stability value<2, the symmetric stability value is determined with 1 as the symmetry axis. Symmetric stability value=2-stability value. The interval becomes [0, 1]. At the same time, the lens position corresponding to the peak value in the relationship curve is used as the focus position of the electronic device.

[0106] When the stability value is greater than 2, it means that the peak of the relationship curve is not at the temperature, the fitting fails, and refocusing is required.

[0107] According to the above, when 0<stability value<2, it means that the peak value of the relationship curve is relatively stable. When 0<stability value<1, it means that the peak value fluctuates downward; when 1<stability value<2, it means that the peak value fluctuates upward. Both upward and downward fluctuations are normal.

[0108] With this solution, the stability of the peak value of the relationship curve is judged before determining the focus position. When the peak value is stable, the focus position is determined by a multi-point fitting equation, thereby increasing the accuracy of the focus position.

[0109] In the embodiment of the present application, the electronic device identifies and adjusts the focus area through image segmentation, target detection, feature extraction and other technologies. During the recognition process, the current frame image is analyzed to determine the target object, and the focus area is determined for the target object. After that, the activity range of the target object and the possible movement changes of the target object are predicted, and the focus area and search range are automatically adjusted to quickly adapt to the movement and changes of the target object, thereby reducing incorrect focus and shortening the search time.

[0110] Optionally, in the above embodiment, when the electronic device determines the focus area of ​​the current frame image, it performs target detection on the current frame image to determine the target object in the current frame image. Thereafter, the focus area is determined based on the position information of the target object in the current frame image.

[0111] For example, before determining the focus position, the electronic device first segments the current frame image to determine the target object in the image. This process usually involves target detection, feature extraction and other technologies to classify different object categories.

[0112] In one method, a target object of a preset category is indicated in advance. The electronic device performs target detection on the current frame image to determine whether there is a target object of a preset category in the current frame image. The target objects of the preset category include but are not limited to: people, animals, plants, buildings, etc. For example, in a video conference scene, the target object is the participant. For example, if the lens module of the electronic device captures 10 faces, the focus area is determined for each of the 10 faces.

[0113] In another way, priorities of different types of target objects are preset, such as face priority, landscape priority, animal priority, etc. The electronic device performs target detection on the current frame image according to the priority, thereby determining whether there are target objects of various categories in the current frame image.

[0114] After the electronic device determines the target object, it determines the focus area according to the position information of the target object in the current frame image. The position information of the target object in the current frame image includes but is not limited to: the contour coordinates of the target object, the contour center coordinates of the target object, etc. For example, if the target object is a participant, the position information of the target object refers to the position of the rectangular frame in the current frame image. The rectangular frame contains the face image of the participant.

[0115] It should be noted that when there are multiple target objects in the current frame image, the electronic device can determine multiple focus areas. In the subsequent process of determining the focus position, the electronic device can flexibly determine the focus position. In one embodiment, the electronic device determines a target object that meets certain conditions from multiple target objects, and determines the focus position according to the target object distance of the target object. The target object that meets the conditions is, for example, an object whose difference between the object distance and the preset object distance is small, etc., which is not limited in the embodiments of the present application.

[0116] In another way, the electronic device determines a focus position for each target object, and then weights these focus positions, etc., to determine a final focus position.

[0117] With this solution, the electronic device identifies the target object through target detection, and determines the focus area according to the position information of the target object in the current frame image, thereby achieving the purpose of accurately and quickly determining the focus area.

[0118] Optionally, in the above embodiment, after determining the focus area according to the position information of the target object in the current frame image, the electronic device also predicts the activity range of the target object and the movement trajectory of the target object. Thereafter, the electronic device adjusts the focus area according to the movement trajectory and the activity range.

[0119] For example, when the target object is a dynamic object, such as a human, an animal, or a car, the electronic device combines image processing and machine learning to determine the possible range of movement of the target object and predict the movement trajectory. Based on the range of movement and the movement trajectory, the target object is predicted to move next, thereby adjusting the focus area and the adjustment range of the motor.

[0120] After the electronic device determines the target object and identifies the focus area, the process of adjusting the focus area is as follows:

[0121] First, the electronic device predicts the possible activity range of the target object and predicts the movement trajectory. During the prediction process, the electronic device needs to consider multiple factors such as the type of the target object and the movement speed.

[0122] Second, predict the dynamic changes of the target object.

[0123] After determining the range of activity, the electronic device uses machine learning prediction technology to predict the next possible movement changes of the target object, and automatically adjusts the position of the focus area and the search range according to the changes in the motion state of the target object to adapt to the movement and changes of the target object.

[0124] Finally, the electronics adjust the center point of the focus area and the search range.

[0125] After predicting the movement of the target object, the electronic device automatically adjusts the position of the center point of the focus area and the search range. When determining the center point of the focus area, optimization control based on the object's movement angle and displacement is adopted. As for where to search, the search strategy for different object types can be adjusted by adapting.

[0126] This solution can quickly adapt to the movement and changes of the target object by identifying and adjusting the diagonal area, reduce focus errors, and shorten the search time.

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

[0128] Figure 6 A schematic diagram of a focusing device provided in an embodiment of the present application. The focusing device 600 includes: a determination module 61 , a processing module 62 and a focusing module 63 .

[0129] A determination module 61 is used to determine a focus area of ​​a current frame image, where the current frame image is an image within a field of view of a lens module of the electronic device;

[0130] A processing module 62, configured to query a mapping table to determine a first focusing range of a motor according to a target object distance, wherein the motor is configured to drive the lens module, the target object distance is configured to indicate a distance between a target object corresponding to the focusing area and the lens module, and the mapping table is configured to indicate an offset corresponding to different object distances;

[0131] The focusing module 63 is used to adjust the motor according to the first focusing range to search for the focusing position of the electronic device, wherein the step length within the first focusing range is less than a preset step length, and the step length outside the first focusing range is greater than or equal to the preset step length.

[0132] In a feasible implementation, the processing module 62 is used to determine a first object distance and a second object distance according to the target object distance, wherein the first object distance is the farthest object distance or the closest object distance, and the target object distance is between the first object distance and the second object distance; and determine the first focusing range according to an offset corresponding to the second object distance and a motor value corresponding to the first object distance.

[0133] In a feasible implementation, the focusing module 63 is used to determine the positional relationship between the current position of the motor and the focusing range of the motor, and the total focusing range is used to indicate the minimum position of the motor and the maximum position of the motor, the minimum position is the position of the motor when the motor value of the motor is a first motor value, and the maximum position is the position of the motor when the motor value of the motor is a second motor value; according to the positional relationship, an adjustment starting point is determined from the total focusing range; the motor is adjusted according to the adjustment starting point and the first focusing range to search for the focusing position of the electronic device.

[0134] In a feasible implementation, when the focusing module 63 adjusts the motor according to the adjustment starting point and the first focusing range to search for the focusing position of the electronic device, it is used to determine the second focusing range and the third focusing range according to the adjustment starting point and the first end of the first focusing range, the starting point of the second focusing range is the adjustment starting point, the end point of the second focusing range is the starting point of the third focusing range, the end point of the third focusing range is the first end of the first focusing range, and the two ends of the first focusing range are the first end and the second end respectively; starting from the starting point of the second focusing range, the motor is adjusted to search for the focusing position of the electronic device, and the step sizes of the second focusing range, the third focusing range and the first focusing range are reduced successively.

[0135] In a feasible implementation, the focusing module 63 starts to adjust the motor from the starting point of the second focusing range to search for the focusing position of the electronic device, and is used to positively adjust the motor until three consecutive adjustments meet the first condition, the first condition is used to indicate that the focus values ​​corresponding to the first two adjustments of the three consecutive adjustments increase, and the focus values ​​corresponding to the last two adjustments decrease, and the positive adjustment refers to driving the motor so that the position of the motor gradually approaches the second end of the first focusing range; when the three consecutive adjustments meet the first condition, the motor of the lens is reversely adjusted until two consecutive adjustments meet the second condition, the second condition is used to indicate that the focus values ​​corresponding to the two consecutive adjustments increase, and the reverse adjustment refers to driving the motor so that the motor leaves the second end; according to the focus values ​​when the lens module is at different positions during the forward adjustment and the reverse adjustment process, a relationship curve between the lens position and the focus value is fitted; and the focusing position of the electronic device is determined according to the relationship curve.

[0136] In a feasible implementation, when the focusing module 63 determines the focusing position of the electronic device according to the relationship curve, it is used to determine whether the peak value of the relationship curve is stable; when the peak value is stable, the lens position corresponding to the peak value is used as the focusing position of the electronic device.

[0137] In a feasible implementation, the determination module 61 is used to perform target detection on the current frame image to determine the target object in the current frame image; and determine the focus area according to the position information of the target object in the current frame image.

[0138] In a feasible implementation, after determining the focus area based on the position information of the target object in the current frame image, the determination module 61 is also used to predict the activity range of the target object and the movement trajectory of the target object; and adjust the focus area based on the movement trajectory and the activity range.

[0139] The focusing device provided in the embodiment of the present application can execute the actions of the electronic device in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0140] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 7 The electronic device 700 described in the embodiment of the present application includes: at least one processor 71, at least one network interface 74, a user interface 73, a memory 75, and at least one communication bus 72.

[0141] The communication bus 72 is used to realize the connection and communication between these components.

[0142] The user interface 73 may include a display screen (Display) and a camera (Camera), and the optional user interface 73 may also include a standard wired interface and a wireless interface. The camera includes a lens module, a motor, etc., and is used to capture images within the field of view.

[0143] The network interface 74 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0144] Among them, the processor 71 may include one or more processing cores. The processor 71 uses various interfaces and lines to connect various parts of the entire electronic device 70, and executes various functions and processes data of the electronic device 70 by running or executing instructions, programs, code sets or instruction sets stored in the memory 75, and calling data stored in the memory 75. Optionally, the processor 71 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 71 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 71, and it can be implemented separately through a chip.

[0145] Among them, the memory 75 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 75 includes a non-transitory computer-readable storage medium. The memory 75 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 75 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 75 may also be optionally at least one storage device located away from the aforementioned processor 71. As Figure 7 As shown, the memory 75 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an operating application of the electronic device.

[0146] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0147] The present application is 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 processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0148] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0149] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0150] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0151] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0152] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0153] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0154] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A focusing method, characterized in that: include: Determining a focus area of ​​a current frame image, where the current frame image is an image within a field of view of a lens module of the electronic device; querying a mapping table according to a target object distance to determine a first focusing range of a motor, wherein the motor is used to drive the lens module, the target object distance is used to indicate a distance between a target object corresponding to the focusing area and the lens module, and the mapping table is used to indicate an offset corresponding to different object distances; The motor is adjusted according to the first focus range to search for a focus position of the electronic device, wherein a step length within the first focus range is smaller than a preset step length, and a step length outside the first focus range is greater than or equal to a preset step length.

2. The method according to claim 1, characterized in that The querying of the mapping table according to the target object distance to determine the first focusing range of the motor includes: Determine a first object distance and a second object distance according to the target object distance, wherein the first object distance is the farthest object distance or the closest object distance, and the target object distance is between the first object distance and the second object distance; The first focusing range is determined according to the offset corresponding to the second object distance and the motor value corresponding to the first object distance.

3. The method according to claim 1, characterized in that The step of adjusting the motor according to the first focus range to search for a focus position of the electronic device includes: Determine a positional relationship between a current position of the motor and a total focus range of the motor, the total focus range being used to indicate a minimum position of the motor and a maximum position of the motor, the minimum position being a position of the motor when a motor value of the motor is a first motor value, and the maximum position being a position of the motor when the motor value of the motor is a second motor value; According to the positional relationship, determining an adjustment starting point from the total focus range; The motor is adjusted according to the adjustment starting point and the first focus range to search for a focus position of the electronic device.

4. The method according to claim 3, characterized in that The step of adjusting the motor according to the adjustment starting point and the first focusing range to search for a focusing position of the electronic device includes: Determining a second focus range and a third focus range according to the adjustment starting point and the first end of the first focus range, wherein the starting point of the second focus range is the adjustment starting point, the end point of the second focus range is the starting point of the third focus range, the end point of the third focus range is the first end of the first focus range, and the two ends of the first focus range are the first end and the second end respectively; The motor is adjusted from the starting point of the second focus range to search for a focus position of the electronic device, and the step sizes of the second focus range, the third focus range and the first focus range are reduced in sequence.

5. The method according to claim 4, characterized in that The step of adjusting the motor from a starting point of the second focus range to search for a focus position of the electronic device comprises: positively adjusting the motor until three consecutive adjustments satisfy a first condition, the first condition being used to indicate that the focus values ​​corresponding to the first two adjustments of the three consecutive adjustments increase, and the focus values ​​corresponding to the last two adjustments decrease, the positive adjustment being to drive the motor so that the position of the motor gradually approaches the second end of the first focusing range; When the three consecutive adjustments satisfy the first condition, the motor of the lens is adjusted in the reverse direction until two consecutive adjustments satisfy the second condition, wherein the second condition is used to indicate that the focus values ​​corresponding to the two consecutive adjustments increase, and the reverse adjustment refers to driving the motor so that the motor moves away from the second end; Fitting a relationship curve between the lens position and the focal value according to the focal values ​​when the lens module is at different positions during the forward adjustment and the reverse adjustment; The focus position of the electronic device is determined according to the relationship curve.

6. The method according to claim 5, characterized in that Determining the focus position of the electronic device according to the relationship curve includes: determining whether the peak value of the relationship curve is stable; When the peak value is stable, the lens position corresponding to the peak value is used as the focus position of the electronic device.

7. The method according to any one of claims 1 to 6, characterized in that: Determining the focus area of ​​the current frame image includes: Performing target detection on the current frame image to determine a target object in the current frame image; The focus area is determined according to the position information of the target object in the current frame image.

8. The method according to claim 7, characterized in that After determining the focus area according to the position information of the target object in the current frame image, the method further includes: Predicting the activity range of the target object and the moving trajectory of the target object; The focus area is adjusted according to the movement trajectory and the activity range.

9. A focusing device, characterized in that: include: A determination module, used to determine a focus area of ​​a current frame image, wherein the current frame image is an image within a field of view of a lens module of the electronic device; a processing module, configured to query a mapping table according to a target object distance to determine a first focusing range of a motor, wherein the motor is configured to drive the lens module, the target object distance is configured to indicate a distance between a target object corresponding to the focusing area and the lens module, and the mapping table is configured to indicate an offset corresponding to different object distances; A focusing module is used to adjust the motor according to the first focusing range to search for a focusing position of the electronic device, wherein the step length within the first focusing range is less than a preset step length, and the step length outside the first focusing range is greater than or equal to the preset step length.

10. An electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the electronic device implements the method according to any one of claims 1 to 8.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Method for focusing camera of mobile terminal, and mobile terminal

    CN105939455A

  • Focusing control method and electronic equipment

    CN106961552A

  • Zooming focusing compensation method and device of ball dome camera

    CN108259760A

  • A focusing method and assembly of an imaging device, the imaging device, and a movable object

    CN112136310A

  • High-speed scanner focusing method and device, high-speed scanner and storage medium

    CN116264601A