CN-121985219-A - Automatic focusing method, electronic device, storage medium and program
Abstract
The embodiment of the invention discloses an automatic focusing method, electronic equipment, a storage medium and a program, wherein the method comprises the steps of acquiring a first target image frame acquired by target equipment under a first target focal length and a second target image frame acquired by the target equipment under a second target focal length under the condition that the current equipment state of the target equipment is determined to be in a stable focusing state, calculating the image ambiguity of the first target image frame and the second target image frame, updating a third target focal length and a fourth target focal length of the target equipment according to the image ambiguity of the first target image frame and the second target image frame and the first target focal length and the second target focal length, and taking the fourth target focal length as the current focal length of the target equipment to perform automatic focusing under the condition that the third target focal length and the fourth target focal length are determined to meet an automatic focusing termination condition. The technical scheme of the embodiment of the invention can reduce the hardware cost depending on the focusing method and improve the accuracy and flexibility of the focusing method.
Inventors
- ZHANG XIANFA
- BU XIAOYAN
- Feng Jingxuan
- Cao jialing
- DENG JINGYU
- PANG WEI
Assignees
- 上海飞机制造有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260130
Claims (10)
- 1. A method of auto-focusing a lens of a lens array, characterized by comprising the following steps: under the condition that the current equipment state of target equipment is determined to be a stable focusing state, acquiring a first target image frame acquired by the target equipment under a first target focal length and a second target image frame acquired by the target equipment under a second target focal length, wherein the first target focal length and the second target focal length are two adjacent focal lengths iteratively updated by the target equipment; calculating image blur degree of the first target image frame and the second target image frame; updating a third target focal length and a fourth target focal length of the target device according to the image blur degree of the first target image frame and the second target image frame, the first target focal length and the second target focal length, wherein the third target focal length and the fourth target focal length are used for defining the upper and lower limits of the focal length of the target device; And under the condition that the third target focal length and the fourth target focal length meet the automatic focusing termination condition, taking the fourth target focal length as the current focal length of the target equipment, and carrying out automatic focusing according to the current focal length of the target equipment.
- 2. The auto-focusing method of claim 1, wherein the calculating the image blur level of the first target image frame and the second target image frame comprises: Calculating image definition of the first target image frame and the second target image frame according to the image spectrum information of the image frames respectively; calculating image sharpness according to Laplace transformation information of the image frames for the first target image frame and the second target image frame respectively; And respectively carrying out weighted calculation on the image definition and the image sharpness on the first target image frame and the second target image frame to obtain the image blur degree of the first target image frame and the second target image frame.
- 3. The auto-focusing method according to claim 2, further comprising, prior to said calculating the image blur level of said first target image frame and said second target image frame: Under the condition that the current iteration times are determined to be a first target value, determining the image definition and the weight corresponding to the image sharpness as default values; Under the condition that the current iteration number is determined to be a second target value, calculating index entropy values of the image definition and the image sharpness under the current iteration number according to index evaluation values of the image definition and the image sharpness under the current iteration number; And calculating weights of the image definition and the image sharpness under the current iteration times according to the index entropy values of the image definition and the image sharpness under the current iteration times.
- 4. The auto-focusing method according to claim 1, wherein the updating the third and fourth target focal lengths of the target device according to the image blur degree of the first and second target image frames, the first and second target focal lengths, comprises: maintaining the third target focal length unchanged and updating the fourth target focal length value to the first target focal length under the condition that the image blur degree of the first target image frame is smaller than the image blur degree of the second target image frame; Maintaining the fourth target focal length unchanged and updating the third target focal length value to the second target focal length under the condition that the image ambiguity of the first target image frame is larger than the image ambiguity of the second target image frame; after the updating of the third and fourth target focal lengths of the target device according to the image blur degree of the first and second target image frames, the first and second target focal lengths, further comprises: updating the first target focal length according to the third target focal length and the fourth target focal length; and updating the second target focal length according to the updated first target focal length and the focal length adjustment step length of the target equipment.
- 5. The auto-focusing method according to claim 1, wherein the determining that the current device state of the target device is a stable focusing state comprises: acquiring a first frame image and a second frame image which are continuously acquired by target equipment; detecting the characteristic points of the first frame image, and calculating the positions of the characteristic points of the first frame image in the second frame image; calculating optical flow vectors of the feature points according to the positions of the feature points in the first frame image and the second frame image; performing foreground detection on the second frame image according to the optical flow vector of the feature point to obtain a foreground region feature point; determining background region feature points of the second frame image according to the foreground region feature points of the second frame image; calculating the average motion quantity of the background area characteristic points of the second frame image; And determining that the current device state of the target device is the stable focusing state under the condition that the average motion quantity of the background region feature points of the second frame image is smaller than a set motion quantity threshold value.
- 6. The auto-focusing method according to claim 5, wherein the performing foreground detection on the second frame image according to the optical flow vector of the feature point to obtain a foreground region feature point comprises: Calculating the foreground motion amount of the second frame image according to the optical flow vector of the characteristic point; Calculating an improved learning rate according to the foreground motion amount of the second frame image and a preset reference change value; Calculating the center position and the width of the Gaussian distribution of each pixel point of the second frame image according to the improved learning rate; calculating probability density of each pixel point of the second frame image under Gaussian distribution according to the central position and the width of the Gaussian distribution of each pixel point of the second frame image; updating the foreground judging threshold value of the second frame image according to the foreground judging threshold value of the first frame image, the foreground motion amount of the second frame image and the preset reference change value; And determining that the target pixel point is the foreground region feature point in the second frame image under the condition that the probability density of the target pixel point of the second frame image under the Gaussian distribution is less than or equal to the foreground judging threshold value of the second frame image.
- 7. The auto-focusing method according to claim 6, wherein the calculating an improved learning rate from the foreground motion amount of the second frame image and a preset reference change value comprises: Calculating an improved learning rate according to the foreground motion amount of the second frame image and a preset reference change value based on the following formula: ; Wherein, the Representing an improved learning rate of the second frame image, Representing an improved learning rate of said first frame image, beta representing an adjustment factor, Represents the amount of foreground motion of the second frame image, Representing the preset reference change value; The calculating the center position and width of the gaussian distribution of each pixel point of the second frame image according to the improved learning rate includes: Calculating the center position and width of the gaussian distribution of each pixel point of the second frame image according to the improved learning rate based on the following formula: ; ; Wherein, the Representing the center position of the gaussian distribution of each pixel of the second frame image, Representing the center position of the gaussian distribution of each pixel of the first frame image, A value representing each pixel of the first frame image, Representing the width of the gaussian distribution of each pixel of the second frame image, A width of a gaussian distribution representing each pixel of the first frame image; The calculating the probability density of each pixel point of the second frame image under the gaussian distribution according to the center position and the width of the gaussian distribution of each pixel point of the second frame image comprises the following steps: Calculating the probability density of each pixel point of the second frame image under the Gaussian distribution according to the center position and the width of the Gaussian distribution of each pixel point of the second frame image based on the following formula: ; Wherein, the Representing the probability density of each pixel of the second frame image under a gaussian distribution, A value representing each pixel point of the second frame image; The updating the foreground determination threshold of the second frame image according to the foreground determination threshold of the first frame image, the foreground motion amount of the second frame image and the preset reference change value comprises the following steps: updating the foreground judging threshold value of the second frame image according to the foreground judging threshold value of the first frame image, the foreground motion amount of the second frame image and the preset reference change value based on the following formula: ; Wherein, the A foreground decision threshold representing a second frame image, The foreground determination threshold value of the first frame image is represented, and α represents the adjustment coefficient.
- 8. An electronic device, the electronic device comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores a computer program for execution by the at least one processor to enable the at least one processor to perform the auto-focusing method of any one of claims 1-7.
- 9. A computer readable storage medium, characterized in that the computer readable storage medium stores computer instructions for causing a processor to implement the autofocus method of any one of claims 1-7 when executed.
- 10. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the autofocus method of any one of claims 1-7.
Description
Automatic focusing method, electronic device, storage medium and program Technical Field The embodiment of the invention relates to the technical field of equipment control, in particular to an automatic focusing method, an automatic focusing device, electronic equipment, a storage medium and a program. Background The automatic zooming function is a key technology for enlarging or reducing the shooting range by automatically adjusting the focal length of a lens when camera equipment or equipment (such as a mobile phone) integrated with a camera module shoots, and the camera equipment or equipment combines the cooperative work of zooming and automatic focusing, so that the convenience and quality of camera imaging can be improved. However, some camera devices or devices incorporating camera modules are generally small in size, and have a limited internal space, and it is difficult to accommodate a motor, a gyroscope, and a driving circuit required for a stabilization mechanism such as a three-axis pan/tilt head, and thus automatic zooming cannot be achieved by related hardware. Disclosure of Invention The embodiment of the invention provides an automatic focusing method, an automatic focusing device, electronic equipment, a storage medium and a program, which can reduce the hardware cost depending on the focusing method and improve the accuracy and flexibility of the focusing method. According to an aspect of the present invention, there is provided an auto-focusing method including: Under the condition that the current equipment state of the target equipment is determined to be a stable focusing state, acquiring a first target image frame acquired by the target equipment under a first target focal length and a second target image frame acquired by the target equipment under a second target focal length, wherein the first target focal length and the second target focal length are two adjacent focal lengths iteratively updated by the target equipment; calculating image blur degree of the first target image frame and the second target image frame; updating a third target focal length and a fourth target focal length of the target device according to the image blur degree of the first target image frame and the second target image frame, the first target focal length and the second target focal length, wherein the third target focal length and the fourth target focal length are used for defining the upper and lower limits of the focal length of the target device; And under the condition that the third target focal length and the fourth target focal length meet the automatic focusing termination condition, taking the fourth target focal length as the current focal length of the target equipment, and carrying out automatic focusing according to the current focal length of the target equipment. According to another aspect of the present invention, there is provided an auto-focusing apparatus comprising: The target image frame acquisition module is used for acquiring a first target image frame acquired by the target equipment under a first target focal length and a second target image frame acquired by the target equipment under a second target focal length under the condition that the current equipment state of the target equipment is determined to be a stable focusing state, wherein the first target focal length and the second target focal length are two adjacent focal lengths iteratively updated by the target equipment; An image blur degree calculation module for calculating image blur degrees of the first target image frame and the second target image frame; A target focal length updating module, configured to update a third target focal length and a fourth target focal length of the target device according to the image blur degree of the first target image frame and the second target image frame, the first target focal length and the second target focal length, where the third target focal length and the fourth target focal length are used to define upper and lower focal length limits of the target device; and the automatic focusing module is used for taking the fourth target focal length as the current focal length of the target equipment and carrying out automatic focusing according to the current focal length of the target equipment under the condition that the third target focal length and the fourth target focal length are determined to meet the automatic focusing termination condition. According to another aspect of the present invention, there is provided an electronic apparatus including: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the auto-focusing method of any one of the embodiments of the present invention. According to another aspect of the present invention, there is provided a computer readable storage medium storin