CN113347335A - Focusing method, device, electronic equipment and storage medium - Google Patents

Focusing method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113347335A
CN113347335A CN202110600744.7A CN202110600744A CN113347335A CN 113347335 A CN113347335 A CN 113347335A CN 202110600744 A CN202110600744 A CN 202110600744A CN 113347335 A CN113347335 A CN 113347335A
Authority
CN
China
Prior art keywords
focusing
object distance
determining
variation
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110600744.7A
Other languages
Chinese (zh)
Other versions
CN113347335B (en
Inventor
陈天钧
杨熙丞
詹建华
潘润发
况璐
李准
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202110600744.7A priority Critical patent/CN113347335B/en
Publication of CN113347335A publication Critical patent/CN113347335A/en
Application granted granted Critical
Publication of CN113347335B publication Critical patent/CN113347335B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/50Constructional details
    • H04N23/54Mounting of pick-up tubes, electronic image sensors, deviation or focusing coils
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/671Focus control based on electronic image sensor signals in combination with active ranging signals, e.g. using light or sound signals emitted toward objects

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Automatic Focus Adjustment (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The invention discloses a focusing method, a focusing device, electronic equipment and a storage medium, wherein the method comprises the following steps: performing standard Fourier transform on a gray level image acquired by image acquisition equipment to obtain a diffuse speckle spectrum image; determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum; determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the gray image; and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor. According to the embodiment of the invention, the position of the target motor in focusing can be directly determined according to the image acquired in defocusing, and the focusing is performed without performing multiple adjustment attempts of the motor position, so that the time consumption of the focusing process of the focusing method provided by the embodiment of the invention is short, and the focusing process is accelerated.

Description

Focusing method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of focusing technologies, and in particular, to a focusing method and apparatus, an electronic device, and a storage medium.
Background
During the use of the image acquisition device, the focus of the image acquisition device is the key to acquiring high-quality video or images. At present, when the image acquisition equipment carries out focusing, a hill climbing method is generally adopted. The specific process comprises the steps of determining a focusing adjustment direction, adjusting the position of a motor in the focusing adjustment direction, determining a definition evaluation value of a currently acquired image at each motor position, and determining the motor position with the maximum definition evaluation value as the motor position when focusing is finished.
In the prior art, a hill climbing method is adopted for focusing, because the motor position needs to be adjusted for many times, and the definition evaluation value of the image collected at each motor position is compared to determine the final motor position when focusing is finished, the time consumption of the whole focusing process is long.
Disclosure of Invention
The embodiment of the invention provides a focusing method, a focusing device, electronic equipment and a storage medium, which are used for solving the problem that the time consumption of the focusing method in the prior art is long.
The embodiment of the invention provides a focusing method, which comprises the following steps:
performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image;
and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
Further, determining the object distance in focusing according to the diffusion radius, the focal length, the aperture and the object distance in defocusing when the image acquisition device acquires the gray level image comprises:
determining a focusing adjustment direction, determining a corresponding focusing object distance determining formula according to the focusing adjustment direction, bringing the diffusion radius, the focal length when the image acquisition equipment acquires the gray-scale image, the aperture and the defocusing object distance into the focusing object distance determining formula, and determining the focusing object distance.
Further, the determining the focus adjustment direction includes:
and controlling the motor to rotate in a preset adjusting direction for a preset number of step lengths, acquiring a definition evaluation value of an image acquired by the image acquisition equipment after each rotation is finished, and determining a focusing adjusting direction according to the variation trend of the acquired definition evaluation value.
Further, the motor is controlled to rotate in the preset adjusting direction for a preset number of step lengths, and after each rotation is finished, the method further comprises the following steps:
acquiring an object distance of the image acquisition equipment during defocusing;
determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the determining the target motor position according to the object distance in focusing comprises:
determining the variation of the object distance in focusing and the variation of the object distance in defocusing, and determining the target variation of the motor position according to the variation of the object distance in focusing and the variation of the object distance in defocusing and the linear variation relation between the variation of the object distance and the variation of the motor position;
and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
Further, the determining the variation of the object distance in focus and the variation of the object distance in defocus includes:
controlling a motor to rotate in a preset adjusting direction for a preset number of step lengths, determining the object distance during focusing after each rotation is finished, and determining the average value of the object distances during focusing;
and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
In another aspect, an embodiment of the present invention provides a focusing apparatus, where the apparatus includes:
the device comprises a first determining module, a second determining module and a third determining module, wherein the first determining module is used for performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
the second determination module is used for determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
the third determining module is used for determining the object distance in focusing according to the diffusion radius, the focal length, the aperture and the object distance in defocusing when the image acquisition equipment acquires the image;
and the focusing module is used for determining the position of a target motor according to the object distance during focusing and focusing according to the position of the target motor.
Further, the third determining module is specifically configured to determine a focus adjustment direction, determine a corresponding focusing object distance determining formula according to the focus adjustment direction, bring the dispersion radius, the focal length when the image acquisition device acquires the grayscale image, the aperture, and the defocusing object distance into the focusing object distance determining formula, and determine the focusing object distance.
Further, the third determining module is specifically configured to control the motor to rotate in a preset adjusting direction for a preset number of step lengths, acquire a definition evaluation value of an image acquired by the image acquisition device after each rotation is finished, and determine the focus adjusting direction according to a change trend of the acquired definition evaluation value.
Further, the apparatus further comprises:
the fourth determining module is used for acquiring the object distance of the image acquisition equipment during the defocusing; determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the focusing module is specifically configured to determine the variation of the object distance in focusing and the variation of the object distance in defocusing, and determine the target variation of the motor position according to the variation of the object distance in focusing and the variation of the object distance in defocusing and a linear variation relationship between the variation of the object distance and the variation of the motor position; and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
Further, the focusing module is specifically configured to control the motor to rotate in a preset adjustment direction for a preset number of step lengths, determine an object distance during focusing after each rotation is finished, and determine an average value of the object distances during focusing; and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
On the other hand, the embodiment of the invention provides electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
a processor for implementing any of the above method steps when executing a program stored in the memory.
In another aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps of any one of the above.
The embodiment of the invention provides a focusing method, a focusing device, electronic equipment and a storage medium, wherein the method comprises the following steps: performing standard Fourier transform on a gray level image acquired by image acquisition equipment to obtain a diffuse speckle spectrum image; determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum; determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the gray image; and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
The technical scheme has the following advantages or beneficial effects:
according to the focusing method provided by the embodiment of the invention, the image acquired by the image acquisition equipment is subjected to standard Fourier transform to obtain a diffuse spot spectrum image, the dispersion radius is further determined based on the radial average distribution of the diffuse spot spectrum, the object distance during focusing is determined according to the dispersion radius, the focal distance, the aperture and the object distance during defocusing when the image is acquired by the image acquisition equipment, and the position of a target motor is finally determined and focused. According to the embodiment of the invention, the position of the target motor in focusing can be directly determined according to the image acquired in defocusing, and the focusing is performed without performing multiple adjustment attempts of the motor position, so that the time consumption of the focusing process of the focusing method provided by the embodiment of the invention is short, and the focusing process is accelerated.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a focusing process provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of a focusing method provided by an embodiment of the present invention;
FIG. 3 is a cross-sectional view of a spectral image of a diffuse spot according to an embodiment of the present invention;
FIG. 4 is a flow chart of focusing provided by an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a focusing device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the attached drawings, and it should be understood that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1:
fig. 1 is a schematic diagram of a focusing process provided by an embodiment of the present invention, where the process includes the following steps:
s101: performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
s102: determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
s103: determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image;
s104: and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
The focusing method provided by the embodiment of the invention is applied to electronic equipment, and the electronic equipment can be image acquisition equipment, and can also be equipment such as a PC (personal computer), a tablet computer and the like. If the electronic equipment is image acquisition equipment, the image acquisition equipment acquires the image and then performs standard Fourier transform on the image to obtain a diffuse spot spectrum image, and a subsequent focusing process is performed. If the electronic equipment is equipment such as a PC (personal computer) and a tablet personal computer, after the image acquisition equipment acquires the image, the image is firstly sent to the electronic equipment, then the electronic equipment performs standard Fourier transform on the image to obtain a diffuse spot spectrum image, and a subsequent focusing process is performed.
After the electronic equipment determines the diffuse spot spectrum image, the radial average distribution of the diffuse spot spectrum is determined according to the diffuse spot spectrum image, and then the dispersion radius is determined according to the radial average distribution of the diffuse spot spectrum. And the radial distance corresponding to the first minimum value point in the radial average distribution of the diffuse spot spectrum is the dispersion radius. And then acquiring the focal length, the aperture and the object distance out-of-focus when the image acquisition equipment acquires the image, and determining the object distance in focus according to the diffusion radius, the focal length, the aperture and the object distance out-of-focus when the image acquisition equipment acquires the image. And finally, determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor. The electronic device can preset the corresponding relation between the object distance and the target motor position during focusing, and the target motor position corresponding to the object distance during focusing is determined according to the corresponding relation.
According to the focusing method provided by the embodiment of the invention, the image acquired by the image acquisition equipment is subjected to standard Fourier transform to obtain a diffuse spot spectrum image, the dispersion radius is further determined based on the radial average distribution of the diffuse spot spectrum, the object distance during focusing is determined according to the dispersion radius, the focal distance, the aperture and the object distance during defocusing when the image is acquired by the image acquisition equipment, and the position of a target motor is finally determined and focused. According to the embodiment of the invention, the position of the target motor in focusing can be directly determined according to the image acquired in defocusing, and the focusing is performed without performing multiple adjustment attempts of the motor position, so that the time consumption of the focusing process of the focusing method provided by the embodiment of the invention is short, and the focusing process is accelerated.
Example 2:
in order to make the object distance in focus more accurate, on the basis of the above embodiment, in an embodiment of the present invention, the determining the object distance in focus according to the diffusion radius, the focal length when the image acquisition device acquires the grayscale image, the aperture, and the object distance in defocus includes:
determining a focusing adjustment direction, determining a corresponding focusing object distance determining formula according to the focusing adjustment direction, bringing the diffusion radius, the focal length when the image acquisition equipment acquires the gray-scale image, the aperture and the defocusing object distance into the focusing object distance determining formula, and determining the focusing object distance.
In order to ensure that the object distance determination formula during focusing is more accurate, in the embodiment of the invention, the focusing adjustment direction is determined firstly, then the corresponding object distance determination formula during focusing is determined according to the focusing adjustment direction, and further the object distance determination formula during focusing is determined according to the corresponding object distance determination formula during focusing. The diffusion radius, the focal length when the image acquisition equipment acquires the gray level image, the aperture and the object distance when the image acquisition equipment is out of focus are brought into the object distance determination formula when the image acquisition equipment is focused, and the object distance when the image acquisition equipment is focused is determined.
The determining a focus adjustment direction includes:
and controlling the motor to rotate in a preset adjusting direction for a preset number of step lengths, acquiring a definition evaluation value of an image acquired by the image acquisition equipment after each rotation is finished, and determining a focusing adjusting direction according to the variation trend of the acquired definition evaluation value.
The preset adjustment direction may be any one of clockwise rotation adjustment and counterclockwise rotation adjustment of the motor, and the preset adjustment direction is rotated by a step length of a preset number of times, for example, 3 times. And after each rotation is finished, acquiring a definition evaluation value of the image acquired by the image acquisition equipment, and determining a focusing adjustment direction according to the variation trend of the acquired definition evaluation value. Specifically, if the change trend of the acquired sharpness evaluation value is gradually decreased, the focus adjustment direction is opposite to the preset adjustment direction, and if the change trend of the acquired sharpness evaluation value is gradually increased, the focus adjustment direction is the same as the preset adjustment direction.
Example 3:
in order to determine the position of the target motor more accurately according to the object distance during focusing, on the basis of the above embodiments, in an embodiment of the present invention, the motor is controlled to rotate in a preset adjustment direction for a preset number of step lengths, and after each rotation is finished, the method further includes:
acquiring an object distance of the image acquisition equipment during defocusing;
determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the determining the target motor position according to the object distance in focusing comprises:
determining the variation of the object distance in focusing and the variation of the object distance in defocusing, and determining the target variation of the motor position according to the variation of the object distance in focusing and the variation of the object distance in defocusing and the linear variation relation between the variation of the object distance and the variation of the motor position;
and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
In the embodiment of the invention, the linear change relationship is determined firstly in consideration of the linear change relationship between the object distance change amount and the motor position change amount. The method comprises the steps of controlling a motor to rotate in a preset adjusting direction for a preset number of times, obtaining the object distance of the image acquisition equipment during defocusing after each rotation is finished, determining the variation of the object distance and the variation of the motor position during defocusing before and after the motor rotates, and determining the linear variation relation between the variation of the object distance and the variation of the motor position according to the variation of the object distance and the variation of the motor position during defocusing.
When the target motor position is determined according to the object distance during focusing, firstly, the object distance during focusing and the variation of the object distance during defocusing corresponding to the current motor position are determined, and then the target variation of the motor position is determined according to the linear corresponding relation. And then on the basis of the current position of the motor of the image acquisition equipment, the target variable quantity of the motor position is adjusted in the focusing adjustment direction to obtain the final target motor position.
The determining the variation of the object distance in focus and the variation of the object distance in defocus includes:
controlling a motor to rotate in a preset adjusting direction for a preset number of step lengths, determining the object distance during focusing after each rotation is finished, and determining the average value of the object distances during focusing;
and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
In order to ensure that the position of the target motor is determined more accurately and the variation of the determined object distance during focusing and the variation of the determined object distance during defocusing needs to be more accurate, in the embodiment of the invention, the motor is controlled to rotate in the preset adjusting direction for the step length of the preset times, after each rotation is finished, the object distance during focusing can be determined according to the object distance determining formula during focusing, and then the average value of the object distances during focusing is determined. And acquiring the object distance in the defocusing process after the step of rotating the motor for the preset times in the preset adjusting direction is finished, wherein the preset times is three times, and acquiring the object distance in the defocusing process after the step of rotating the motor for the preset times in the preset adjusting direction is finished. And then determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
The principle and process of the focusing method provided by the embodiment of the invention are described below with reference to the accompanying drawings.
Fig. 2 is a schematic diagram of a focusing method according to an embodiment of the present invention, in fig. 3, (a) is a schematic diagram of a diffuse speckle, (b) is a spectral image of a diffuse speckle, and (c) is a radial average distribution of the spectral image of the diffuse speckle.
As shown in FIG. 2, first, the Gaussian imaging formula
Figure BDA0003092844540000091
To obtain
Figure BDA0003092844540000092
When u is0<=u1Similar according to the triangle:
Figure BDA0003092844540000093
to obtain
Figure BDA0003092844540000094
Substituting to obtain
Figure BDA0003092844540000095
When u is0>u1Obtained by the same way
Figure BDA0003092844540000096
In the formula, D is the aperture, f is the focal length, u is the object distance, v is the image distance, R is the dispersion radius, v is the dispersion radius1Is the image distance u at defocus1Is the object distance v at defocus0For image distance in focus, u0Is the object distance at focus.
From the above derivation, it can be seen that if the R value can be measured, u1Knowing F and F, then u0The focus for focusing can be found.
So the second step of the principle is to find the R value, and the embodiment of the present invention chooses the principle understanding based on the diffraction limited system, an imaging system can be regarded as a linear system, and thus the out-of-focus process for the target object is the image degradation process. The point spread function PSF of the system is a uniformly distributed circular spot with radius R and satisfies: integral multiple of reaction1(x, y) dxdy ═ 1, so that the imaging system is understood to be a degenerate process model, Ii(xi,yi)=KIg(x,y)*h1(x,y),Ig(x, y) is the intensity distribution at ideal imaging, Ii(xiY is the actual intensity distribution after degradation, transformed into frequency analysis Gi(ξ,η)=Gg(ξ,η)*H1(ξ, η), the frequency domain composition of the target object is generally a continuous function, H1The zero point and the size change of (xi, eta) are reflected to G by multiplicationi(ξ, η). Wherein h is1Represents the entity of the point spread function, x and y are the coordinates under a two-dimensional coordinate system, and the integral multiple h1(x, y) dxdy ═ 1 indicates that the integrated value is 1. h is1The change to the frequency domain is H1The change of x and y to the frequency domain becomes η and ζ, only the coordinate symbols are different.
As shown in fig. 3, the extremum positions can be observed on the spectral image of the diffuse spot. The size of the diffuse spot radius R of any out-of-focus image is determined by the first minimum point of the radial average distribution of the out-of-focus images. And the radial distance corresponding to the first minimum value point in the radial average distribution of the diffuse spot spectrum is R. Since the imaging system is generally circularly symmetric, the relationship of the R size to the first minima point of the spectrum can be obtained by only discussing one dimension. The diffuse spot is actually a rectangular function on the horizontal axis and has the expression
Figure BDA0003092844540000101
The frequency domain processing results in that,
Figure BDA0003092844540000102
finally, as long as the first extreme point is found, R can be calculated. Where H represents a point spread function, corresponds to a rectangular function in horizontal abstraction, each value is a circle area branch 1, which becomes a rectangle after circle projection, and H(s), sinc (rs) represent the transformation of a spatial domain to a frequency domain one-dimensional function.
Fig. 4 is a flowchart of focusing according to an embodiment of the present invention.
Firstly, a minimum step length is taken 3 times in the same direction (Far or Near)), data such as the definition evaluation value FV and the object distance, F and F when out of focus are recorded each time, and simultaneously, the linear change relationship between the object distance change amount and the motor position change amount is obtained, wherein Δ u is K × Δ p, Δ u is the object distance change amount, K is a coefficient constant, and Δ p is the motor position change amount, and the next step is carried out.
Secondly, judging the relation between the object distance at the time of defocusing and the actually required object distance at the time of focusing according to the FV value and the initial direction of the first step, wherein a situation is taken as an example, if a minimum step length is taken to a first point for recording when the Far end is first reached, and then a minimum step length is taken to a second point for recording, at the moment, if the FV value is decreased all the time, the actually focused object distance is judged to be closer than the recorded two object distances at the time of defocusing, and the relation is in accordance with u0<=u1And proceeds to the next step.
Thirdly, selecting a reverse thrust u according to the conclusion of the second step0The corresponding formula simultaneously acquires a gray scale image corresponding to the YUV image, then performs standard Fourier transform, and moves the center of the changed original point, namely, the direct current component of the image to the center of a circle, so that the whole image is displayed from the center of the circle to the outside, the frequency is sequentially increased, finally the radial average distribution of the diffuse spot spectrum image and the diffuse spot spectrum is acquired, and then the next step is carried out.
Step four, substituting the conclusion of the step three into a corresponding formula, and calculating three u according to the formula because the corresponding minimum step length is calculated for three times0And taking the average value of the object distances when three focuses are calculated, and then entering the next step.
The fifth step, focusing the object according to the previous stepAverage value of distance, and u after the current, i.e. third, minimum step length1And combining the linear relation delta u-K-delta p obtained in the first step to obtain delta p, and finally driving the motor to move to the target position in the correct direction.
Example 4:
fig. 5 is a schematic structural diagram of a focusing apparatus according to an embodiment of the present invention, where the apparatus includes:
the first determining module 51 is configured to perform standard fourier transform on an image acquired by an image acquisition device to obtain a diffuse spot spectrum image;
the second determining module 52 is configured to determine a radial average distribution of a diffuse spot spectrum according to the diffuse spot spectrum image, and determine a dispersion radius according to the radial average distribution of the diffuse spot spectrum;
a third determining module 53, configured to determine an object distance in focusing according to the diffusion radius, a focal length, an aperture, and an object distance in defocusing when the image is acquired by the image acquisition device;
and the focusing module 54 is used for determining the position of a target motor according to the object distance during focusing and carrying out focusing according to the position of the target motor.
The third determining module 53 is specifically configured to determine a focus adjustment direction, determine a corresponding focusing object distance determining formula according to the focus adjustment direction, bring the dispersion radius, the focal length when the image acquisition device acquires the grayscale image, the aperture, and the defocusing object distance into the focusing object distance determining formula, and determine the focusing object distance.
The third determining module 53 is specifically configured to control the motor to rotate in a preset adjusting direction for a preset number of step lengths, acquire a definition evaluation value of an image acquired by the image acquisition device after each rotation is finished, and determine the focus adjusting direction according to a change trend of the acquired definition evaluation value.
The device further comprises:
a fourth determining module 55, configured to obtain an object distance of the image capturing device during the defocus; determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the focusing module 54 is specifically configured to determine the variation of the object distance during focusing and the variation of the object distance during defocusing, and determine a target variation of the motor position according to the variation of the object distance during focusing and the variation of the object distance during defocusing and a linear variation relationship between the variation of the object distance and the variation of the motor position; and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
The focusing module 54 is specifically configured to control the motor to rotate in a preset adjustment direction for a preset number of step lengths, determine an object distance during focusing after each rotation is finished, and determine an average value of the object distances during focusing; and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
Example 5:
on the basis of the foregoing embodiments, an embodiment of the present invention further provides an electronic device, as shown in fig. 6, including: the system comprises a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 complete mutual communication through the communication bus 304;
the memory 303 has stored therein a computer program which, when executed by the processor 301, causes the processor 301 to perform the steps of:
performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image;
and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
Based on the same inventive concept, the embodiment of the present invention further provides an electronic device, and as the principle of the electronic device for solving the problem is similar to the focusing method, the implementation of the electronic device may refer to the implementation of the method, and repeated details are not repeated.
The electronic device provided by the embodiment of the invention can be a desktop computer, a portable computer, a smart phone, a tablet computer, a Personal Digital Assistant (PDA), a network side device and the like.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface 302 is used for communication between the above-described electronic apparatus and other apparatuses.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a central processing unit, a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like.
When the processor executes the program stored in the memory, the image acquired by the image acquisition equipment is subjected to standard Fourier transform to obtain a diffuse speckle spectrum image; determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum; determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image; and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor. According to the embodiment of the invention, the position of the target motor in focusing can be directly determined according to the image acquired in defocusing, and the focusing is performed without performing multiple adjustment attempts of the motor position, so that the time consumption of the focusing process of the focusing method provided by the embodiment of the invention is short, and the focusing process is accelerated.
Example 6:
on the basis of the foregoing embodiments, an embodiment of the present invention further provides a computer storage readable storage medium, in which a computer program executable by an electronic device is stored, and when the program is run on the electronic device, the electronic device is caused to execute the following steps:
performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image;
and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
Based on the same inventive concept, embodiments of the present invention further provide a computer-readable storage medium, and since the principle of solving the problem when the processor executes the computer program stored on the computer-readable storage medium is similar to the focusing method, the implementation of the computer program stored on the computer-readable storage medium by the processor may refer to the implementation of the method, and repeated details are not repeated.
The computer readable storage medium may be any available medium or data storage device that can be accessed by a processor in an electronic device, including but not limited to magnetic memory such as floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc., optical memory such as CDs, DVDs, BDs, HVDs, etc., and semiconductor memory such as ROMs, EPROMs, EEPROMs, non-volatile memory (NAND FLASH), Solid State Disks (SSDs), etc.
The computer program is stored in the computer readable storage medium provided by the embodiment of the invention, and when being executed by the processor, the computer program realizes the standard Fourier transform of the gray level image acquired by the image acquisition equipment to obtain a diffuse spot spectrum image; determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum; determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the gray image; and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor. According to the embodiment of the invention, the position of the target motor in focusing can be directly determined according to the image acquired in defocusing, and the focusing is performed without performing multiple adjustment attempts of the motor position, so that the time consumption of the focusing process of the focusing method provided by the embodiment of the invention is short, and the focusing process is accelerated.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (12)

1. A focusing method, characterized in that the method comprises:
performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image, and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
determining an object distance in focusing according to the diffusion radius, the focal distance, the aperture and an object distance in defocusing when the image acquisition equipment acquires the image;
and determining the position of a target motor according to the object distance during focusing, and focusing according to the position of the target motor.
2. The method of claim 1, wherein determining the object distance in focus from the diffusion radius, the focal length at which the image acquisition device acquires the grayscale image, the aperture, and the object distance out of focus comprises:
determining a focusing adjustment direction, determining a corresponding focusing object distance determining formula according to the focusing adjustment direction, bringing the diffusion radius, the focal length when the image acquisition equipment acquires the gray-scale image, the aperture and the defocusing object distance into the focusing object distance determining formula, and determining the focusing object distance.
3. The method of claim 2, wherein the determining a focus adjustment direction comprises:
and controlling the motor to rotate in a preset adjusting direction for a preset number of step lengths, acquiring a definition evaluation value of an image acquired by the image acquisition equipment after each rotation is finished, and determining a focusing adjusting direction according to the variation trend of the acquired definition evaluation value.
4. The method of claim 3, wherein the motor is controlled to rotate a predetermined number of steps in a predetermined adjustment direction, and wherein after each rotation, the method further comprises:
acquiring an object distance of the image acquisition equipment during defocusing;
determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the determining the target motor position according to the object distance in focusing comprises:
determining the variation of the object distance in focusing and the variation of the object distance in defocusing, and determining the target variation of the motor position according to the variation of the object distance in focusing and the variation of the object distance in defocusing and the linear variation relation between the variation of the object distance and the variation of the motor position;
and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
5. The method of claim 4, wherein said determining the amount of change in the object distance at focus and the object distance at defocus comprises:
controlling a motor to rotate in a preset adjusting direction for a preset number of step lengths, determining the object distance during focusing after each rotation is finished, and determining the average value of the object distances during focusing;
and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
6. A focusing device, characterized in that the device comprises:
the device comprises a first determining module, a second determining module and a third determining module, wherein the first determining module is used for performing standard Fourier transform on an image acquired by image acquisition equipment to obtain a diffuse spot spectrum image;
the second determination module is used for determining the radial average distribution of the diffuse spot spectrum according to the diffuse spot spectrum image and determining the dispersion radius according to the radial average distribution of the diffuse spot spectrum;
the third determining module is used for determining the object distance in focusing according to the diffusion radius, the focal length, the aperture and the object distance in defocusing when the image acquisition equipment acquires the image;
and the focusing module is used for determining the position of a target motor according to the object distance during focusing and focusing according to the position of the target motor.
7. The apparatus according to claim 6, wherein the third determining module is specifically configured to determine a focus adjustment direction, determine a corresponding focus object distance determining formula according to the focus adjustment direction, and determine the focus object distance by substituting the diffusion radius, the focal length when the image capturing device captures the grayscale image, the aperture, and the defocus object distance into the focus object distance determining formula.
8. The apparatus according to claim 7, wherein the third determining module is specifically configured to control the motor to rotate in a preset adjusting direction by a step length for a preset number of times, acquire a sharpness evaluation value of an image acquired by the image acquisition device after each rotation is completed, and determine the focus adjusting direction according to a variation trend of the acquired sharpness evaluation value.
9. The apparatus of claim 8, wherein the apparatus further comprises:
the fourth determining module is used for acquiring the object distance of the image acquisition equipment during the defocusing; determining a linear change relation between the object distance variation and the motor position variation according to the variation of the object distance and the motor position variation in the defocusing process;
the focusing module is specifically configured to determine the variation of the object distance in focusing and the variation of the object distance in defocusing, and determine the target variation of the motor position according to the variation of the object distance in focusing and the variation of the object distance in defocusing and a linear variation relationship between the variation of the object distance and the variation of the motor position; and determining the position of a target motor according to the current position of the motor of the image acquisition equipment and the target variable quantity.
10. The apparatus according to claim 9, wherein the focusing module is specifically configured to control the motor to rotate a preset number of step lengths in a preset adjustment direction, determine an object distance during focusing after each rotation is completed, and determine an average value of the object distances during focusing; and determining the average value of the object distances in focusing and the variation of the object distances in defocusing acquired after the step length of the preset times of rotation in the preset adjusting direction is finished.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1-5.
CN202110600744.7A 2021-05-31 2021-05-31 Focusing method, device, electronic equipment and storage medium Active CN113347335B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110600744.7A CN113347335B (en) 2021-05-31 2021-05-31 Focusing method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110600744.7A CN113347335B (en) 2021-05-31 2021-05-31 Focusing method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113347335A true CN113347335A (en) 2021-09-03
CN113347335B CN113347335B (en) 2022-08-30

Family

ID=77472728

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110600744.7A Active CN113347335B (en) 2021-05-31 2021-05-31 Focusing method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113347335B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114359191A (en) * 2021-12-23 2022-04-15 浙江大华技术股份有限公司 Particle uniformity detection system, method, device, equipment and medium
CN114979472A (en) * 2022-05-13 2022-08-30 杭州联吉技术有限公司 Automatic focusing method, device, equipment and readable storage medium

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571953A (en) * 2009-05-20 2009-11-04 深圳泰山在线科技有限公司 Object detection method, system and stereoscopic vision system
DE602007013347D1 (en) * 2006-12-20 2011-05-05 Canon Kk Optical device comprising a unit for correcting the blurring of a picked-up image caused by displacement of the optical device in the direction of the optical axis
JP2014191184A (en) * 2013-03-27 2014-10-06 Canon Inc Imaging device, imaging device control method and control program
CN104202518A (en) * 2014-08-25 2014-12-10 深圳市菲特数码技术有限公司 Zooming method and system of integrated video camera
CN107664899A (en) * 2017-10-19 2018-02-06 广东顺德工业设计研究院(广东顺德创新设计研究院) The method, apparatus and system of auto-focusing
CN108200344A (en) * 2018-01-23 2018-06-22 江苏冠达通电子科技有限公司 The adjustment Zooming method of video camera
EP3477355A1 (en) * 2017-10-31 2019-05-01 Canon Kabushiki Kaisha Lens control apparatus, imaging apparatus including lens control apparatus, and lens control method
CN110278382A (en) * 2019-07-22 2019-09-24 浙江大华技术股份有限公司 A kind of focus method, device, electronic equipment and storage medium
CN110381261A (en) * 2019-08-29 2019-10-25 重庆紫光华山智安科技有限公司 Focus method, device, computer readable storage medium and electronic equipment
CN110392201A (en) * 2018-04-20 2019-10-29 杭州海康威视数字技术股份有限公司 A kind of the focus motor location determining method and device of thermal imaging system
CN110913129A (en) * 2019-11-15 2020-03-24 浙江大华技术股份有限公司 Focusing method, device, terminal and storage device based on BP neural network
CN111526286A (en) * 2020-04-20 2020-08-11 苏州智感电子科技有限公司 Method and system for controlling motor motion and terminal equipment
WO2021077270A1 (en) * 2019-10-21 2021-04-29 深圳市大疆创新科技有限公司 Method for obtaining target distance, and control device and mobile platform

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE602007013347D1 (en) * 2006-12-20 2011-05-05 Canon Kk Optical device comprising a unit for correcting the blurring of a picked-up image caused by displacement of the optical device in the direction of the optical axis
CN101571953A (en) * 2009-05-20 2009-11-04 深圳泰山在线科技有限公司 Object detection method, system and stereoscopic vision system
JP2014191184A (en) * 2013-03-27 2014-10-06 Canon Inc Imaging device, imaging device control method and control program
CN104202518A (en) * 2014-08-25 2014-12-10 深圳市菲特数码技术有限公司 Zooming method and system of integrated video camera
CN107664899A (en) * 2017-10-19 2018-02-06 广东顺德工业设计研究院(广东顺德创新设计研究院) The method, apparatus and system of auto-focusing
EP3477355A1 (en) * 2017-10-31 2019-05-01 Canon Kabushiki Kaisha Lens control apparatus, imaging apparatus including lens control apparatus, and lens control method
CN108200344A (en) * 2018-01-23 2018-06-22 江苏冠达通电子科技有限公司 The adjustment Zooming method of video camera
CN110392201A (en) * 2018-04-20 2019-10-29 杭州海康威视数字技术股份有限公司 A kind of the focus motor location determining method and device of thermal imaging system
CN110278382A (en) * 2019-07-22 2019-09-24 浙江大华技术股份有限公司 A kind of focus method, device, electronic equipment and storage medium
CN110381261A (en) * 2019-08-29 2019-10-25 重庆紫光华山智安科技有限公司 Focus method, device, computer readable storage medium and electronic equipment
WO2021077270A1 (en) * 2019-10-21 2021-04-29 深圳市大疆创新科技有限公司 Method for obtaining target distance, and control device and mobile platform
CN110913129A (en) * 2019-11-15 2020-03-24 浙江大华技术股份有限公司 Focusing method, device, terminal and storage device based on BP neural network
CN111526286A (en) * 2020-04-20 2020-08-11 苏州智感电子科技有限公司 Method and system for controlling motor motion and terminal equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114359191A (en) * 2021-12-23 2022-04-15 浙江大华技术股份有限公司 Particle uniformity detection system, method, device, equipment and medium
CN114979472A (en) * 2022-05-13 2022-08-30 杭州联吉技术有限公司 Automatic focusing method, device, equipment and readable storage medium
CN114979472B (en) * 2022-05-13 2023-11-24 杭州联吉技术有限公司 Automatic focusing method, device, equipment and readable storage medium

Also Published As

Publication number Publication date
CN113347335B (en) 2022-08-30

Similar Documents

Publication Publication Date Title
CN113347335B (en) Focusing method, device, electronic equipment and storage medium
US20210383148A1 (en) Automatic data enhancement expansion method, recognition method and system for deep learning
CN112164032B (en) Dispensing method and device, electronic equipment and storage medium
CN105578048B (en) A kind of quick focusing method and device, mobile terminal
US20150279056A1 (en) High-quality post-rendering depth blur
WO2015100105A1 (en) Improving plenoptic camera resolution
CN103235397B (en) A kind of Atomatic focusing method and equipment
CN104580879A (en) Image processing apparatus, image pickup apparatus and image processing method
CN110278382A (en) A kind of focus method, device, electronic equipment and storage medium
CN104102068A (en) Automatic focusing method and automatic focusing device
CN110572577B (en) Method, device, equipment and medium for tracking and focusing
CN112669429A (en) Image distortion rendering method and device
Han et al. A novel training based auto-focus for mobile-phone cameras
JP2011153905A (en) Optical aberration correction for machine vision inspection system
CN110121068B (en) Point selection method and device of zoom following curve and storage medium
CN111147737A (en) Automatic focusing method and device based on RBF neural network
WO2016161734A1 (en) Autofocusing method and device
CN110418068B (en) Focusing method, device, electronic equipment and storage medium
CN116614620B (en) High-pixel optical lens assembly equipment and control method
CN107085843B (en) System and method for estimating modulation transfer function in optical system
CN112637485B (en) Vision-assisted lens automatic focusing method, system, equipment and storage medium
CN111669573B (en) Motor stability detection method and device
CN111741218B (en) Focusing method, device, electronic equipment and storage medium
US8571403B2 (en) Autofocus system
CN113420604A (en) Multi-person posture estimation method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant