CN-119697492-B - Focusing method, device, equipment and readable storage medium
Abstract
The embodiment of the application provides a focusing method, a focusing device, focusing equipment and a readable storage medium, wherein 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 are pre-recorded on electronic equipment, and offset corresponding to different object distances are stored. During shooting, the electronic equipment determines a focusing area of a current frame image in a visual field range of the lens module, determines an offset according to a target object distance query mapping table between a target object corresponding to the focusing area and the lens module, determines a first focusing range according to the offset and a first motor value or a second motor value, adjusts a motor in the first focusing range by a smaller step length, adjusts the motor in a larger step length outside the first range, reduces searching times to a certain extent, shortens focusing time, and achieves the aim of improving focusing speed.
Inventors
- SONG YONGFEI
Assignees
- 广州视源电子科技股份有限公司
- 广州视琨电子科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20230925
Claims (11)
- 1. A focusing method, characterized by comprising: Determining a focusing area of a current frame image, wherein the current frame image is an image in a view range of a lens module of electronic equipment, and the focusing area is a local area of the current frame image; Determining an offset corresponding to a target object distance according to a target object distance query mapping table, determining a first focusing range of a motor according to the offset and a first motor value or a second motor value, wherein the motor is used for driving the lens module, the target object distance is used for indicating the distance between a target object corresponding to the focusing area and the lens module, the mapping table is used for indicating the offset corresponding to different object distances, the first motor value is a motor value corresponding to the furthest object distance of the lens module, the second motor value is a motor value corresponding to the closest object distance of the lens module, the first focusing range is a section of the total focusing range of the motor, and two ends of the total focusing range are respectively the first motor value and the second motor value; And adjusting the motor according to the first focusing range to search the focusing position of the electronic equipment, wherein the step length in the first focusing range is smaller than a preset step length, and the step length outside the first focusing range is larger than or equal to the preset step length.
- 2. The method of claim 1, wherein the querying the mapping table based on the target object distance to determine the first focus range of the motor comprises: Determining 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 nearest object distance, and the target object distance is between the first object distance and the second object distance; and determining the first focusing range according to the offset corresponding to the second object distance and the motor value corresponding to the first object distance.
- 3. The method of claim 1, wherein the adjusting the motor according to the first focus range to search for a focus position of the electronic device comprises: determining a positional relationship between a current position of the motor and a total focusing range of the motor, wherein the total focusing range is used for indicating a minimum position of the motor and a maximum position of the motor, the minimum position is a position of the motor when a motor value of the motor is a first motor value, and the maximum position is a position of the motor when the motor value of the motor is a second motor value; Determining an adjustment starting point from the total focusing range according to the position relation; And adjusting the motor according to the adjustment starting point and the first focusing range so as to search the focusing position of the electronic equipment.
- 4. The method of claim 3, wherein said adjusting the motor to search for a focus position of the electronic device based on the adjustment start point and the first focus range comprises: determining a second focusing range and a third focusing range according to the adjusting starting point and the first end of the first focusing range, wherein the starting point of the second focusing range is the adjusting 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; And starting to adjust the motor from the starting point of the second focusing range to search the focusing position of the electronic equipment, wherein the step sizes of the second focusing range, the third focusing range and the first focusing range are sequentially reduced.
- 5. The method of claim 4, wherein said adjusting the motor from the beginning of the second focus range to search for a focus position of the electronic device comprises: Forward adjusting the motor until three consecutive adjustments meet a first condition indicating that a focus value corresponding to a first two of the three consecutive adjustments rises and a focus value corresponding to a second two of the three consecutive adjustments falls, the forward adjusting driving the motor such that a position of the motor is gradually closer to a second end of the first focus range; When the continuous three-time adjustment meets a first condition, reversely adjusting a motor of the lens until the continuous two-time adjustment meets a second condition, wherein the second condition is used for indicating that a focus value corresponding to the continuous two-time adjustment is increased, and the reverse adjustment means that the motor is driven to enable the motor to leave the second end; Fitting a relation curve between the lens position and the focus value according to the focus values when the lens module is positioned at different positions in the forward regulation and the backward regulation processes; and determining the focusing position of the electronic equipment according to the relation curve.
- 6. The method of claim 5, wherein said determining a focus position of the electronic device from the relationship comprises: Determining whether a peak value of the relationship curve is stable; and when the peak value is stable, taking the lens position corresponding to the peak value as the focusing position of the electronic equipment.
- 7. The method according to any one of claims 1 to 6, wherein 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; and determining the focusing area according to the position information of the target object in the current frame image.
- 8. The method of claim 7, wherein after determining the focus area according to the position information of the target object in the current frame image, further comprising: predicting the moving range of the target object and the moving track of the target object; and adjusting the focusing area according to the moving track and the moving range.
- 9. A focusing device, characterized by comprising: the device comprises a determining module, a focusing module and a focusing module, wherein the determining module is used for determining a focusing area of a current frame image, the current frame image is an image in a visual field range of a lens module of the electronic equipment, and the focusing area is a local area of the current frame image; The processing module is used for determining an offset corresponding to the target object distance according to a target object distance query mapping table, determining a first focusing range of a motor according to the offset and a first motor value or a second motor value, wherein the motor is used for driving the lens module, the target object distance is used for indicating the distance between a target object corresponding to the focusing area and the lens module, the mapping table is used for indicating the offset corresponding to different object distances, the first motor value is a motor value corresponding to the furthest object distance of the lens module, the second motor value is a motor value corresponding to the closest object distance of the lens module, the first focusing range is a section of the total focusing range of the motor, and two ends of the total focusing range are respectively the first motor value and the second motor value; And the focusing module is used for adjusting the motor according to the first focusing range so as to search the focusing position of the electronic equipment, wherein the step length in the first focusing range is smaller than a preset step length, and the step length outside the first focusing range is larger than or equal to the preset step length.
- 10. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, wherein execution of the computer program by the processor causes the electronic device to implement the method of any one of claims 1 to 8.
- 11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method according to any one of claims 1 to 8.
Description
Focusing method, device, equipment and readable storage medium Technical Field The embodiment of the application relates to the technical field of cameras, in particular to a focusing method, a focusing device, focusing equipment and a readable storage medium. Background Focusing refers to a process of adjusting the distance between a lens and an imaging surface according to the object distance by an electronic device so as to enable a photographed object to be imaged clearly. Wherein, the object distance refers to the distance between the lens and the shot object. A maximum Focus Value (FV) search method is a common focusing method. When the lens of the electronic equipment is aligned with the shot object, the motor in the lens module of the electronic equipment drives the lens to gradually move from the bottom to the top and acquire a plurality of images, and in the process, the electronic equipment calculates and records FV corresponding to each image to generate a relation curve between the image FV and the position of the lens. And finally, taking the peak of the relation curve as the focusing position of the electronic equipment. In the above focusing method, the search range is related to the total focusing range of the motor, and the larger the total focusing range is, the larger the search range is, the longer the search time is, resulting in too slow focusing speed and thus too slow shooting speed. Disclosure of Invention The embodiment of the application provides a focusing method, a focusing device, focusing equipment and a readable storage medium, which are used for determining a fine searching first focusing range according to a target object distance, adjusting a motor according to the first focusing range so as to quickly focus, reducing the searching range and simultaneously achieving the purpose of improving the focusing speed. In a first aspect, an embodiment of the present application provides a focusing method, including: determining a focusing area of a current frame image, wherein the current frame image is an image in a view range of a lens module of the electronic equipment; Inquiring a mapping table according to a target object distance to determine a first focusing range of a motor, wherein the motor is used for driving the lens module, the target object distance is used for indicating the distance between a target object corresponding to the focusing area and the lens module, and the mapping table is used for indicating offset corresponding to different object distances; And adjusting the motor according to the first focusing range to search the focusing position of the electronic equipment, wherein the step length in the first focusing range is smaller than a preset step length, and the step length outside the first focusing range is larger than or equal to the preset step length. In a second aspect, an embodiment of the present application provides a focusing device, including: The determining module is used for determining a focusing area of a current frame image, wherein the current frame image is an image in the view range of a lens module of the electronic equipment; The processing module is used for inquiring a mapping table according to the target object distance to determine a first focusing range of the motor, the motor is used for driving the lens module, the target object distance is used for indicating the distance between a target object corresponding to the focusing area and the lens module, and the mapping table is used for indicating offset corresponding to different object distances; And the focusing module is used for adjusting the motor according to the first focusing range so as to search the focusing position of the electronic equipment, wherein the step length in the first focusing range is smaller than a preset step length, and the step length outside the first focusing range is larger than or equal to the preset step length. In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to cause the electronic device to implement the method as described above in the first aspect or the various possible implementations of the first aspect. In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored therein computer instructions which, when executed by a processor, are adapted to carry out the method according to the first aspect or the various possible implementations of the first aspect. In a fifth aspect, embodiments of the present application provide a computer program product comprising a computer program which, when executed by a processor, implements the method as described above in the first aspect or in the various possible implementations of the first aspect. According to the focusing method, the focusing de