CN105629628B - Atomatic focusing method and device - Google Patents

Atomatic focusing method and device Download PDF

Info

Publication number
CN105629628B
CN105629628B CN201410603586.0A CN201410603586A CN105629628B CN 105629628 B CN105629628 B CN 105629628B CN 201410603586 A CN201410603586 A CN 201410603586A CN 105629628 B CN105629628 B CN 105629628B
Authority
CN
China
Prior art keywords
contrast
image
focusing
camera lens
lens
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.)
Active
Application number
CN201410603586.0A
Other languages
Chinese (zh)
Other versions
CN105629628A (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.)
Spreadtrum Communications Shanghai Co Ltd
Original Assignee
Spreadtrum Communications Shanghai 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 Spreadtrum Communications Shanghai Co Ltd filed Critical Spreadtrum Communications Shanghai Co Ltd
Priority to CN201410603586.0A priority Critical patent/CN105629628B/en
Publication of CN105629628A publication Critical patent/CN105629628A/en
Application granted granted Critical
Publication of CN105629628B publication Critical patent/CN105629628B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

A kind of Atomatic focusing method and device, method include:The first image that camera lens often moves the long imaging device of the first step obtained correspondence lens location along the first direction is obtained, the focusing direction and first position of camera lens are determined according to the contrast of the first image;Obtaining camera lens, every move since first position corresponds to the second image of lens location obtained by the long imaging device of second step along focusing direction, and the second position is determined according to the contrast of the second image;Determine focusing range, the focusing range is the region centered on the second position;The lens location in the focusing range in each lens location corresponding to the image of contrast maximum acquired in imaging device is determined as the focusing position of camera lens by the moving lens in focusing range.This method can effectively improve the speed and accuracy of auto-focusing, particularly image scene variation be not too greatly in the case of, can quickly and accurately get focusing position.

Description

Atomatic focusing method and device
Technical field
The present invention relates to Autofocus Technology field more particularly to a kind of Atomatic focusing methods and device.
Background technology
Auto-focusing is essential key technology in contemporary optics imaging system, with the hair at full speed of science and technology Exhibition, vernier focusing problem in digital imaging system by people common concern.Auto-focusing refers to by camera Focusing mechanism changes object distance and position apart, makes the process of the imaging clearly of made thing body.With the quick hair of electronic equipment Exhibition, the various electronic equipment uses comprising shooting function are more and more frequent, and requirement of the user to automatic focusing function is also increasingly It is high.
Imaging device clearly image in order to obtain, needs to scheme imageable target by the Focusing module in imaging device As sensor, such as complementary metal oxide semiconductor (CMOS, Complementary Metal-Oxide Semiconductor) Or the imaging of charge coupling device (CCD, Charge Coupled Device) plane is in focusing state, i.e., so that image distance, object Away from and focal length meet 1/u+1/v=1/f, wherein u is apart, v is object distance, and f is focal length.In the process that auto-focusing is realized In, mainly by adjusting the distance between camera lens and imaging sensor, i.e. image distance so that imageable target can be in image sensing Blur-free imaging on device.
During the auto-focusing of imaging device, with the movement of camera lens, the clarity of imaging is led in variation is not stopped Imaging device can obtain maximum contrast in shape library state hypograph in the case of often, and imaging device can be according to image The situation of change of contrast between pixel obtains the focusing position of imaging device, but imaging device is according to single image slices Contrast extracting mode between element is highly susceptible to the influence of picture noise, it is difficult to accurately reflect the focusing of imaging device reality State is easy to cause focusing failure, and during imaging device auto-focusing, imaging device is every under big noise circumstance Secondary focusing is required to restore camera lens to fixed initial position, then starts to push camera lens and samples figure at different lens locations The contrast of picture, and then determine according to acquired contrast the focusing position of imaging device, the above process due to focusing every time Be required to since initial position search for focusing position, there are focusing speed it is slower the problem of.
Invention content
The present invention solves the problems, such as it is the problem of being difficult to accurate focusing and slower focusing speed.
To solve the above problems, technical solution of the present invention provides a kind of Atomatic focusing method, the method includes:
It obtains camera lens and often moves the imaging device obtained correspondence lens location described in the first step-length along the first direction The first image, the focusing direction and first position of the camera lens are determined according to the contrast of described first image;
The camera lens is obtained to move described in the second step-length imaging along the focusing direction is every since the first position and set Second image of the standby obtained correspondence lens location, the second position is determined according to the contrast of second image;
Determine focusing range, the focusing range is the region centered on the second position;
The mobile camera lens in the focusing range, by acquired in the imaging device in the focusing range it is each Lens location in lens location corresponding to the image of contrast maximum is determined as the focusing position of the camera lens.
Optionally, the first direction is perifocus or the over focus movement from camera lens current location to the imaging device Direction.
Optionally, the contrast includes the first contrast and the second contrast, and first contrast is according to described right The luminance difference between pixel in burnt region is determined, and second contrast is according to the image in the focusing area Luminance difference between block is determined.
Optionally, first contrast is determined by equation below:
Wherein, VpFor first contrast, M is the horizontal resolution of the focusing area, and N is the focusing area Vertical resolution, i and j are respectively the horizontal and vertical index value of the pixel in the focusing area, and L (i, j) is described The brightness value of the pixel at (i, j) position in focusing area;
Second contrast is determined by equation below:
Wherein, VbFor second contrast, X is the image block contained by horizontal direction after the focusing area piecemeal Number, numbers of the Y for the image block contained by vertical direction after the focusing area piecemeal, s and t are respectively the focusing area The horizontal and vertical index value of interior image block, LB (s, t) are picture in the image block at (s, t) position in the focusing area The average brightness value of vegetarian refreshments.
Optionally, the focusing direction of the determining camera lens and the process of first position include:
The first contrast and the second contrast of corresponding each first image are obtained respectively;
If the maximum value of the first contrast of each first image and the ratio of minimum value are greater than or equal to first threshold, The focusing direction for then determining the camera lens is the maximum that first contrast is changed to from the minimum value of first contrast The moving direction of the lens location of value, the first position is corresponding to the minimum value of the first contrast of each first image Lens location.
Optionally, the focusing direction of the determining camera lens and the process of first position further include:
If the maximum value of the first contrast of each first image and the ratio of minimum value are less than the first threshold, institute The ratio of maximum value and minimum value for stating the second contrast of each first image is greater than or equal to the first threshold and the first number According to more than the second data, it is determined that the focusing direction of the camera lens is to change to described the from the minimum value of second contrast The moving direction of the lens location of the maximum value of two contrasts, the first position are the second contrast of each first image Minimum value corresponding to lens location, first data are right for the maximum value of the second contrast of each first image First contrast of the first image got at the lens location answered, second data for each first image the First contrast of the first image got at the lens location corresponding to the minimum value of two contrasts.
Optionally, the focusing direction of the determining camera lens and the process of first position include:
The first contrast and the second contrast of corresponding each first image are obtained respectively;
If the maximum value of the second contrast of each first image and the ratio of minimum value are greater than or equal to first threshold And first data be more than the second data, it is determined that the focusing direction of the camera lens is to change from the minimum value of second contrast To the moving direction of the lens location of the maximum value of second contrast, the first position for each first image the Lens location corresponding to the minimum value of two contrasts, first data for each first image the second contrast most The first contrast of the first image got at the corresponding lens location of big value, second data are described each first First contrast of the first image got at the lens location corresponding to the minimum value of the second contrast of image.
Optionally, the focusing direction of the determining camera lens and the process of first position further include:
If the maximum value of the second contrast of each first image and the ratio of minimum value are less than the first threshold, and The maximum value of first contrast of each first image and the ratio of minimum value are greater than or equal to first threshold, determine the mirror The focusing direction of head is the lens location for the maximum value that first contrast is changed to from the minimum value of first contrast Moving direction, the first position for each first image the first contrast minimum value corresponding to lens location.
Optionally, the process of the determining second position includes:
Obtain the first contrast of corresponding each second image;
If the maximum value of the first contrast of each second image and first of the second image acquired in the last time The ratio of contrast is greater than or equal to second threshold, it is determined that the second position is the first contrast of each second image Maximum value corresponding to lens location.
Optionally, the process of the determining second position further includes:
If the maximum value of the first contrast of each second image and first of the second image acquired in the last time The ratio of contrast is less than the second threshold, and the position after camera lens the last time adjustment is not up to the end position of camera lens And the maximum value of the first contrast of each second image and the ratio of minimum value are greater than or equal to third threshold value, it is determined that institute State the lens location corresponding to the maximum value for the first contrast that the second position is each second image.
Optionally, the center of the focusing range is the second position, and the width of the focusing range is described second Step-length.
Optionally, the determination process of the focusing position of the camera lens includes:
Point processing such as carry out to the focusing range;
Each position of halving that the camera lens is adjusted to obtain after decile processing respectively;
Camera lens position in each position of halving acquired in the imaging device corresponding to the image of the first contrast maximum Put the focusing position for being determined as the camera lens.
To solve the above problems, technical solution of the present invention also provides a kind of automatic focusing mechanism, described device includes:
Probe unit often moves the obtained correspondence of imaging device described in the first step-length along the first direction for obtaining camera lens First image of the lens location, according to the contrast of described first image determine the camera lens focusing direction and first It puts;
Coarse scanning unit often moves imaging device institute described in the second step-length for obtaining the camera lens along the focusing direction Obtained the second image of the correspondence lens location determines the second position according to the contrast of second image;
Range determination unit, for determining focusing range, the focusing range is the area centered on the second position Domain;
Position determination unit, will be acquired in the imaging device for the camera lens mobile in the focusing range Lens location in the focusing range in each lens location corresponding to the image of contrast maximum is determined as the camera lens Focusing position.
Compared with prior art, technical scheme of the present invention has the following advantages:
In auto-focusing, the initial position message of detection focusing direction and camera lens first, i.e., by obtaining camera lens along the The first image of the obtained correspondence of imaging device described in the first step-length lens location is often moved in one direction, according to described The contrast of one image determines the focusing direction and first position of the camera lens;So that imaging device enters coarse scanning, with The possible focusing position of camera lens after first successive step is got, that is, obtains the camera lens and often moves second step along the focusing direction The second image of the lens location is corresponded to obtained by the long imaging device, the is determined according to the contrast of second image Two positions;And then focusing range is determined centered on the second position acquired in coarse scanning;Finally in the focusing range, lead to Cross in the focusing range the mobile camera lens, and by acquired in the imaging device in the focusing range each camera lens Lens location in position corresponding to the image of contrast maximum is determined as the focusing position of the camera lens, realizes to imaging device Focusing position be accurately positioned.This method determines the focusing direction of camera lens in the starting stage of auto-focusing so that each When focusing again, lens location after the completion of being focused with last time simultaneously restarts to focus according to focusing direction, without each Again focus and focusing scanned all since fixed initial position, the speed of auto-focusing can be effectively improved, particularly into In the case of not being too big as scene changes, the acquisition speed and accuracy of focusing position can be significantly improved.
Further, it is originally determined focusing direction during, with reference to image the first contrast and the second contrast into Row considers that the second contrast of image is the contrast-data obtained according to the image block of focusing area, the second contrast The process equalized to image data is obtained, acquired contrast in this way can effectively remove picture noise to comparison The influence of degrees of data, and even if in the case where the real focusing position of distance of camera lens is distant, can also keep preferable Contrast sensitivity so that can accurately detect focusing direction, improve the speed and accuracy of auto-focusing.
Description of the drawings
Fig. 1 is the flow diagram for the Atomatic focusing method that technical solution of the present invention provides;
Fig. 2 is the focusing direction of determining camera lens provided in an embodiment of the present invention and the flow diagram of first position;
Fig. 3 is the first contrast of image provided in an embodiment of the present invention and the schematic diagram of the second contrast;
Fig. 4 is the schematic diagram of focusing area provided in an embodiment of the present invention;
Fig. 5 is the division schematic diagram of focusing area provided in an embodiment of the present invention;
Fig. 6 is that another embodiment of the present invention provides the focusing direction of horizontal glass head really and the flow diagram of first position;
Fig. 7 is the flow diagram of the determining second position provided in an embodiment of the present invention;
Fig. 8 is the flow diagram of determining focusing position provided in an embodiment of the present invention;
Fig. 9 is focusing position schematic diagram provided in an embodiment of the present invention;
Figure 10 is the structure diagram of automatic focusing mechanism provided in an embodiment of the present invention.
Specific embodiment
The focusing position and the slow problem of auto-focusing for being difficult to accurately determining auto-focusing exists in the prior art.
To solve the above problems, technical solution of the present invention provides a kind of Atomatic focusing method.Fig. 1 is technical solution of the present invention The flow diagram of the Atomatic focusing method of offer.
As shown in Figure 1, step S1 is first carried out, obtains camera lens and often move imaging device described in the first step-length along the first direction First image of the obtained correspondence lens location, the focusing of the camera lens is determined according to the contrast of described first image Direction and first position.
First to focusing direction detect, it is described focusing direction refer to camera lens from current location to focusing focal position into The mobile direction of row.
Camera lens is moved along the first direction according to the first step-length, for camera lens often after movement once, imaging device can be corresponding Obtain the image at the corresponding position of camera lens after movement, hereon referred to as the first image, i.e. camera lens are often mobile primary, can obtain First image of the lens location after to a corresponding movement.
The situation of change of the contrast of obtained each first image determines focusing side after being moved according to each camera lens To, if for example, during camera lens moves along the first direction, if the contrast of obtained first image is increasing, Show during camera lens moves, becoming for image is more and more clear, you can to determine that the first direction is to focus Direction.
After focusing direction is determined, determined to perform auto-focusing mistake according to the situation of change of the contrast of described first image The initial position of identified focus process behind determining focusing direction in present specification, is known as the by the initial position of journey One position, and then the coarse scanning process of auto-focusing is entered according to focusing direction and first position.
Step S2 is performed, is obtained obtained by the camera lens often moves imaging device described in the second step-length along the focusing direction The correspondence lens location the second image, the second position is determined according to the contrast of second image.
During coarse scanning, camera lens is moved along focusing direction since first position according to second step length, mirror For head often after movement once, imaging device can accordingly obtain the image at the corresponding position of camera lens after movement, hereon referred to as Second image, i.e. camera lens are often mobile primary, can obtain the second image of the lens location after a corresponding movement.
The situation of change of the contrast of obtained each second image primarily determines one after being moved according to each camera lens The position that a second picture contrast peak value occurs, in present specification, by the variation feelings of the contrast according to the second image The position that contrast peak value determined by condition is likely to occur is known as the second position, and the second position is determined by coarse scanning process Focusing position that may be present.After the second position is determined, into fine control process, to obtain accurate focusing position.
Step S3 is performed, determines focusing range, the focusing range is the region centered on the second position.
One smaller focusing range is determined according to the second position, for example, can be using the second position in The heart, and the image-region in certain area coverage is determined as the focusing range.The specific width of the focusing range can be with It is set according to the step-length of the camera lens during coarse scanning, you can be set accordingly according to second step length.
Perform step S4, the mobile camera lens in the focusing range, by acquired in the imaging device described Lens location in focusing range in each lens location corresponding to the image of contrast maximum is determined as the focusing position of the camera lens It puts.
During fine control, with smaller step-length moving lens in the focusing range, and and then each position of acquisition The maximum value in the contrast for the image that place is got is put, the lens location corresponding to the image of contrast maximum is determined as The focusing position of camera lens.
This method determines focusing direction and first position in the detection phase, and the second position is determined in the coarse scanning stage, into And the accurate focusing position of camera lens is obtained in the fine control stage, focusing position can be accurately obtained, improves imaging device focusing position The accuracy put.The focusing direction of camera lens is determined in the starting stage of auto-focusing so that, can be with when focusing again every time Last time focusing after the completion of lens location and according to focusing direction restart to focus, without focusing again every time all from fixed Initial position starts scanning focusing, effectively improves the speed of auto-focusing, is not feelings too greatly particularly in image scene variation Under condition, hence it is evident that improve the speed for getting accurate focusing position;Under the premise of focusing direction is determined, and then according to pair of image The second position after coarse scanning is determined than degree, specific focusing range is determined, and then in the focusing range with the second position Accurate focusing position is got, effectively improves the accuracy of focusing position.
It is understandable for the above objects, features and advantages of the present invention is enable to become apparent, below in conjunction with the accompanying drawings to the present invention Specific embodiment be described in detail.
In specific implementation process, described acquisition camera lens often moves the first step-length institute along the first direction in step sl The first image of the imaging device obtained correspondence lens location is stated, according to determining the contrast of described first image The focusing direction of camera lens and the realization process of first position please refer to Fig.2, and Fig. 2 is the focusing of determining camera lens provided in this embodiment Direction and the flow diagram of first position.
As shown in Fig. 2, during the focusing direction of detecting lenses and first position, step S201 is first carried out, really Surely the initial position detected.
The initial position of detection is the initial position of camera lens when starting auto-focusing of camera lens.
The moving lens since the initial position of detection, to realize to the focusing direction of camera lens and determining for first position. In the present embodiment, the first position refers to after focusing direction is determined, identified to be opened again according to the focusing direction Beginning carries out the initial position of focusing coarse tuning process.
Step S202 is performed, camera lens is moved along the first direction into the first step-length.
When imaging device carries out auto-focusing, for a selected focusing scene, camera lens is in different positions, in image Imaging definition on sensor would also vary from, and the contrast of obtained image would also vary from, if usually camera lens is worked as Front position apart from best end focusing position farther out when, the contrast of image also can be smaller, that is to say, that the position of camera lens away from More remote from focusing position, the contrast of obtained image is smaller, and image also can be than less clear.So according to this rule, it can With focus start when, the shot detection that first makes is moved toward a direction, by shot detection it is mobile it is several compared with Small stepping, and the contrast of imaging device image of corresponding acquisition on each stepping position is obtained, according to the comparison of image The changing rule judgement camera lens of degree can obtain the most clearly direction of lens location, that is, determine focusing direction.
In present specification, the direction that shot detection moves is known as first direction, camera lens is moved along the first direction The length of dynamic stepping is known as the first step-length, and camera lens is often moved to the obtained correspondence of the long imaging device of the first step along the first direction The image of lens location is known as the first image.
In specific selected first direction, if camera lens present position close to the nearly burnt end of imaging system, by first Direction is determined as the direction from nearly burnt end to remote burnt end movement, if conversely, the present position of camera lens is close to imaging system First direction is then determined as the direction from remote burnt end to nearly burnt end movement by remote coke end.
The length of the first step-length that the camera lens moves along the first direction can be according to the system performance of imaging system, focusing Sensitivity, accuracy requirement Binding experiment data set accordingly.
Step S203 is performed, obtains the first image that lens location is corresponded to when camera lens moves along the first direction the first step-length, And record the first contrast and the second contrast of described first image.
When camera lens often moves the first step-length, imaging system can obtain the first image corresponding to current lens position, It obtains herein when camera lens moves along the first direction the first step-length and corresponds to the first image of lens location, and obtain current lens position The contrast of the first corresponding image.
The contrast of image acquired in imaging system can be counted according to the brightness value of the pixel in image It calculates.Specifically, in the present embodiment, in the detection phase, be respectively adopted two methods the contrast of same image is carried out it is true It is fixed, i.e., illustrated so that the contrast of described image respectively includes the first contrast and the second contrast as an example, according to positioned at pair The luminance difference between pixel in burnt region determines the first contrast of image, according between the image block in focusing area Luminance difference determine the second contrast.
The contrast of image is weighed using two ways in the detection phase, mainly it is considered that opening in focusing Stage beginning, before determining focusing direction, the current position potential range imaging of camera lens most clearly focusing position away from From distant, the image at this time acquired in imaging system is more smudgy, and the noise of image can be bigger, if using single The contrast that image is determined according to the luminance difference between pixel, since the interference of noise in image is bigger, lead to figure As the difference between pixel can be smaller, i.e., as shown in Figure 3 in the lens location place apart from focusing position farther out First contrast of the image got can be smaller.If the single luminance difference according between pixel determines the comparison of image The sensitivity of degree can be very low, thus may cause to carry out the determining of focusing state according to this mode to fail, i.e. picture noise Focusing can be caused to fail in the case of bigger.
So in the present embodiment, with reference to the comparison that image is determined by the luminance difference between the block of pixels in image Degree, due to when picture noise is bigger, luminance difference between block of pixels more can accurately, pair of actual response image Than degree situation of change, though lens location apart from focusing position farther out when, can also also keep image contrast it is sensitive Degree, this is highly useful to the detection in the focusing direction at initial stage of focusing.It is shown in Fig. 3 between the block of pixels in image Luminance difference determined by the second contrast change curve, at focusing position lens location farther out, image Second contrast significantly has better sensitivity than the first contrast of image.
In the present embodiment, in the contrast for determining image, according to the pixel being located in image in focusing area Brightness value determines the first contrast and the second contrast of image.
The focusing area can be the central area of whole image range, the signal of focusing area as illustrated in FIG. 4 Figure, the size of the focusing area can be set according to imaging system performance, experimental data etc., not limited specifically herein It is fixed.
First contrast of image can be in focusing area the brightness value of each pixel be determined, in this implementation In example, the first contrast of image is determined according to formula (1).
Wherein, VpFor first contrast, M is the horizontal resolution of the focusing area, and N is the focusing area Vertical resolution, i and j are respectively the horizontal and vertical index value of the pixel in the focusing area, and L (i, j) is described The brightness value of the pixel at (i, j) position in focusing area.
Second contrast of image can be determined according to the luminance difference between the block of pixels in focusing area.
Piecemeal processing is carried out for the pixel in focusing area to image first, the width of focusing area is divided into X Decile is highly divided into Y deciles, as shown in figure 5, then each sub-regions are the block of pixels obtained after dividing.In this implementation In example, the value of X, Y are 32, i.e., focusing area are divided into 32 × 32 block of pixels, according to each pixel pixel in the block Brightness value determine the average brightness value of the block of pixels, will the brightness of pixel all pixels point in the block sum, then Carry out the average brightness of the average acquiring block of pixels.
Second contrast of image is determined according to formula (2).
Second contrast is determined by equation below:
Wherein, VbFor second contrast, X is the image block contained by horizontal direction after the focusing area piecemeal Number, numbers of the Y for the image block contained by vertical direction after the focusing area piecemeal, s and t are respectively the focusing area The horizontal and vertical index value of interior image block, LB (s, t) are picture in the image block at (s, t) position in the focusing area The average brightness value of vegetarian refreshments.
When the first step-length is often moved for camera lens, imaging system is obtained according to formula (1) and formula (2) and obtains current lens First the first contrast of image and the second contrast corresponding to position, and obtained contrast information is recorded, so as to In subsequently determining focusing direction and first position according to the first contrast of recorded each first image and the second contrast information, I.e. after camera lens is often mobile once, the first contrast and second of the first image of a corresponding camera lens current location can be all recorded Contrast.
Perform step S204, the maximum value and minimum value of the first contrast of each first image of acquisition and the second contrast Maximum value and minimum value.
In moving lens each time and record the first contrast and of corresponding first image in current lens position place After two contrasts, in the first contrast and the second contrast of each first image corresponding to each lens location recorded, The first contrast of each first image and maximum value and minimum value in the second contrast are found out respectively, herein by the first image Maximum value in first contrast is denoted as Vp_max, the minimum value in the first contrast of the first image is denoted as Vp_min, by first Maximum value in second contrast of image is denoted as Vb_max, the minimum value in the second contrast of the first image is denoted as Vb_min
Step S205 is performed, judges whether the maximum value of the first contrast and the ratio of minimum value are greater than or equal to the first threshold Value.
The amplitude of variation that first threshold judges the first contrast of the first image is combined first.Preset first threshold, For describing the amplitude of variation of the first contrast of the first image, the first threshold can carry out corresponding according to experimental data Setting.
In the maximum value V of the first contrast of the first imagep_maxWith minimum value Vp_minBetween ratio be greater than or equal to institute When stating first threshold, illustrate the first contrast more apparent change as the variation of the position of camera lens has occurred of the first image Change, then it can be according to the first contrast from minimum value Vp_minTo maximum value Vp_maxThe direction of variation determines final focusing position.
If the ratio between the maximum value and minimum value of the first contrast of the first image is also less than described first at present Threshold value then illustrates to judge what camera lens should adjust according to the data of the first contrast of the first image currently recorded It is correctly oriented, the second contrast that can combine the first image at this time determines the focusing direction of camera lens.
I.e. when step S205 judging results are "Yes", step S210 is performed;Otherwise step S206 is performed.
Step S206, judges whether the maximum value of the second contrast and the ratio of minimum value are greater than or equal to first threshold.
The situation of change of the contrast of the first image is determined according to the situation of change of the brightness value of the block of pixels of image.
If the maximum value V of the second contrast of the first imageb_maxWith minimum value Vb_minBetween ratio be greater than or equal to institute When stating first threshold, although illustrating that contrast changes unobvious determined by the brightness of the pixel of image at this time, according to figure As block of pixels brightness determined by the variation of contrast or obvious, then according to the second contrast from minimum value Vb_minTo maximum value Vb_maxThe direction of variation may can determine final focusing position, in order to direction of focusing determine it is accurate Property, the first comparison of the image at the lens location corresponding when the second contrast obtains maximum value and minimum value can be combined Degree accounts for.If the conversely, maximum value V of the second contrast of the first imageb_maxWith minimum value Vb_minBetween ratio be less than The first threshold then illustrates that the information by current the first acquired image can't determine focusing direction, needs to continue to move Index glass head obtains the first image at the lens location after mobile first step-length, is further judged.
When step S206 judging results are "Yes", step S208 is performed;Otherwise step S207 is performed.
Step S207, the next position of setting camera lens.
According to first direction and the first step-length, next lens location of current lens is determined.After step S207, It returns and performs step S202, moving lens performs subsequent step to corresponding position.
Step S208 determines the second contrast maximum value and the lens location corresponding to minimum value, and obtains the first data With the second data.
Specifically, remember the second contrast maximum value V of the first imageb_maxCorresponding lens location be P0, the first image The second contrast minimum value Vb_minCorresponding lens location is P1, is obtained in recorded the first comparison in lens location P0 The first contrast of the first image corresponding with P1 positions place is put, corresponding first contrast in lens location P0 places is denoted as Vp_p0, corresponding first contrast in lens location P1 positions place is denoted as Vp_p1.In present specification, by described each first The maximum value V of second contrast of imageb_maxFirst comparison of the first image got at corresponding lens location P0 Spend Vp_p0Referred to as the first data, by the minimum value V of the second contrast of each first imageb_minCorresponding lens location P1 First contrast V of the first image that place is gotp_p1Referred to as the second data.
Step S209 is performed, judges whether the first data are more than the second data.
The changing rule of the contrast of the first image is determined with reference to the first data and the second data.
If the judging result of step S209 is "Yes", step S210 is performed;Otherwise it returns and performs step S207.
When the judging result of step S209 is "No", although illustrating currently the first image according to determined by block of pixels Second contrast meets the maximum value V of the second contrastb_maxWith minimum value Vb_minBetween ratio be greater than or equal to described first The condition of threshold value, but the first data are less than the second data, same the first image, the first contrast at different location and the The size variation rule of two contrasts is different, illustrates accurately determine the focusing direction of camera lens, to need to return at present Step S207 continues to set next lens location, continues to detect.
Step S210 determines focusing direction and first position, into the coarse scanning stage.
When step S209 judging results are "Yes", illustrate to meet:The maximum value V of second contrast of the first imageb_max With minimum value Vb_minBetween ratio be greater than or equal to the condition that the first threshold and the first data are more than the second data, then press The second contrast from minimum value Vb_minTo maximum value Vb_maxThe direction of variation can determine final focusing position, can incite somebody to action Camera lens is from minimum value Vb_minTo maximum value Vb_maxMobile direction is determined as final focusing direction.By the second of the first image Lens location corresponding to the minimum value of contrast is determined as the first position, i.e., by the second contrast minimum value Vb_minInstitute Corresponding lens location is as the follow-up initial position into during coarse scanning.
And when being "Yes" if in step S205 judging results, illustrate to meet:First contrast of the first image is most The ratio of big value and minimum value is greater than or equal to first threshold, can be by camera lens from the first contrast from minimum value Vp_minTo maximum Value Vp_maxMobile direction is determined as final focusing direction.By the mirror corresponding to the minimum value of the first contrast of the first image Head location determination is the first position, i.e., by the first contrast minimum value Vp_minCorresponding lens location enters as follow-up Initial position during coarse scanning.
By above-mentioned steps S201 to step S210, during the auto-focusing of image, you can realize as shown in fig. 1 The step S1 gone out.
In another embodiment of the invention, the focusing direction of camera lens can also be determined using method as illustrated in FIG. 6 And first position.
As shown in fig. 6, step S601 is first carried out to step S604.
Step S601 determines the initial position of detection.
Camera lens is moved along the first direction the first step-length by step S602.
Step S603 is obtained when camera lens moves along the first direction the first step-length and is corresponded to the first image of lens location, and remember Record the first contrast and the second contrast of described first image.
Step S604, the maximum value and minimum value of the first contrast of each first image of acquisition and the second contrast are most Big value and minimum value.
The realization process of step S601 to step S604 uses the implementation method shown by step S201 to step S204, This is repeated no more.
Step S605 is performed after step S604, judges whether the maximum value of the second contrast and the ratio of minimum value are more than Or equal to first threshold.
Step S605 please refers to step S206.
If step S605 judging results are "Yes", step S606 is performed;Otherwise step S609 is performed.
Step S606 determines the second contrast maximum value and the lens location corresponding to minimum value, and obtains the first data With the second data.
Step S606 please refers to step S208.
Step S607 is performed after step S606.
Step S607, judges whether the first data are more than the second data.
The changing rule of the contrast of the first image is determined with reference to the first data and the second data.
Step S607 please refers to step S209.
If step S607 judging results are "Yes", step S610 is performed;Otherwise step S608 is performed.
Step S608, the next position of setting camera lens.
According to first direction and the first step-length, next lens location of current lens is determined.
Step S608 please refers to step S207.
It after step S608, returns and performs step S602, moving lens performs subsequent step to corresponding position.
Step S609, judges whether the maximum value of the first contrast and the ratio of minimum value are greater than or equal to first threshold.
Specifically whether the ratio of the maximum value to the first contrast and minimum value is greater than or equal to the judgement of first threshold Journey please refers to step S205.
When step S609 judging results are "Yes", step S610 is performed;Otherwise it returns and performs step S608.
Step S610 determines focusing direction and first position.
During if in step S607 judging results for "Yes", illustrate to meet:The maximum of second contrast of the first image Value Vb_maxWith minimum value Vb_minBetween ratio be greater than or equal to the item that the first threshold and the first data are more than the second data Part, then according to the second contrast from minimum value Vb_minTo maximum value Vb_maxThe direction of variation can determine final focusing position, It can be by camera lens from minimum value Vb_minTo maximum value Vb_maxMobile direction is determined as final focusing direction.By the first image The second contrast minimum value corresponding to lens location, be determined as the first position, i.e., by the second contrast minimum value Vb_minCorresponding lens location is as the follow-up initial position into during coarse scanning.
And when being "Yes" if in step S609 judging results, illustrate to meet:First contrast of the first image is most The ratio of big value and minimum value is greater than or equal to first threshold, can be by camera lens from the first contrast from minimum value Vp_minTo maximum Value Vp_maxMobile direction is determined as final focusing direction.By the mirror corresponding to the minimum value of the first contrast of the first image Head location determination is the first position, i.e., by the first contrast minimum value Vp_minCorresponding lens location enters as follow-up Initial position during coarse scanning.
By above-mentioned steps S601 to step S610, during the auto-focusing of image, can equally realize as in Fig. 1 Shown step S1.
The step S2 shown in Fig. 1 is described in detail with reference to Fig. 7.Step S2 shown in Fig. 1 also may be used To be not understood as through coarse scanning, thick step determines the process of the focusing position of camera lens.During coarse scanning, camera lens is with preset Second step length is moved according to determining focusing direction, and acquired figure during coarse scanning is found during stepping Lens location corresponding to image contrast maximum value, as coarse scanning result.
In specific implementation process, the acquisition camera lens described in step S2 is along the focusing direction from described first Position corresponds to the second image of the lens location obtained by the imaging device when starting every the second step-length of movement, according to described The contrast of second image determines that the realization process of the second position please refers to Fig. 7, and Fig. 7 is determining camera lens provided in this embodiment The flow diagram of the second position.
Step S701 is performed, sets the initial position during coarse scanning.
Using by the first position as acquired in upper type as the initial position during coarse scanning.
Step S702 is performed, camera lens is moved into the second step-length along focusing direction.
In present specification, imaging device obtained corresponding camera lens when camera lens edge focusing direction is moved the second step-length The image of position is known as the second image.
The length of the second step-length that the camera lens is moved along focusing direction can be according to imaging system system performance, focusing Sensitivity, accuracy requirement Binding experiment data set accordingly.
Step S703 is performed, obtains the second image that lens location is corresponded to when camera lens moves the second step-length along focusing direction, And obtain the first contrast of the second image.
In the coarse scanning stage in order to which the true situation of change of the contrast of image can be accurately obtained, according to the picture of image Luminance difference between element determines the contrast of image, i.e., using the first contrast of image to picture contrast situation of change into Row description.
When camera lens often moves the second step-length, imaging system can obtain the second image corresponding to current lens position, It obtains herein when camera lens moves the second step-length along focusing direction and corresponds to the second image of lens location, and obtain current lens position The contrast of the second corresponding image.
First contrast of second image can according to it is as shown above go out formula (1) obtained, herein no longer It repeats.
When the second step-length is often moved for camera lens, imaging system can be obtained according to formula (1) and obtain current lens position The first contrast of the second corresponding image is put, records obtained second contrast, in order to each subsequently according to recording First contrast of the second image determines the second position, i.e., after camera lens is often mobile once, can all record a corresponding camera lens and work as First contrast of the second image of front position.
In present specification, after camera lens is moved the second step-length, imaging system is obtained corresponding to current lens position First contrast of the second image is denoted as Vp_now
Step S704 is performed, obtains the maximum value and minimum value of the first contrast of each second image.
In moving lens each time and after recording the first contrast of corresponding second image in current lens position place, Maximum value and minimum value are found out in first contrast of each second image corresponding to each lens location recorded, herein by Maximum value in first contrast of two images is denoted as Vp2_max, the minimum value in the first contrast of the second image is denoted as Vp2_min
Step S705 is performed, judges whether the maximum value of the first contrast and the ratio of current value are greater than or equal to the second threshold Value.
The current value refers to the first contrast of the second image acquired in imaging device the last time, i.e., as described above Imaging system obtain the first contrast V of the second image corresponding to current lens positionp_now
Second threshold is preset, the second threshold can accordingly be set according to experimental data.
In the maximum value V of the first contrast of the second imagep2_maxWith current value Vp_nowBetween ratio be greater than or equal to the During two threshold values, illustrate the maximum value V of the first contrast of the second imagep2_maxIt may be the thick step to be obtained in the coarse scanning stage Lens location corresponding to the maximum value of first contrast of the second image is known as the second position by focusing position.
When step S705 judging results are "Yes", step S709 is performed;Otherwise step S706 is performed.
Step S706, judges whether camera lens reaches end position.
In the maximum value V of the first contrast of the second imagep2_maxWith current value Vp_nowBetween ratio be less than described second During threshold value, need further to judge whether current lens position reaches end position, the end position refers to that camera lens can be adjusted The maximum position of section.
If current lens reach end position not yet, adjustment lens location is can also continue to, then it is next to set camera lens Position;If current lens have reached end position, the maximum value V of the first contrast according to the second image can be attemptedp2_max With minimum value Vp2_minBetween Relation acquisition coarse scanning result.
When step S706 judging results are "No", step S707 is performed;Otherwise step S708 is performed.
Step S707, the next position of setting camera lens.
According to focusing direction and the second step-length, next lens location of current lens is determined.After step S707, It returns and performs step S702, moving lens performs subsequent step to corresponding position.
Step S708, judges whether the maximum value of the first contrast and the ratio of minimum value are greater than or equal to third threshold value.
Third threshold value is preset, the third threshold value can accordingly be set according to experimental data.
In the maximum value V of the first contrast of the second imagep2_maxWith minimum value Vp2_minBetween ratio be greater than or equal to During the third threshold value, it may also be said to which the peak position in bright coarse scanning stage has been determined;If the first contrast of the second image Maximum value Vp2_maxWith minimum value Vp2_minBetween ratio be less than the third threshold value, then illustrate according to the currently recorded The data of first contrast of two images can't determine the peak position of image during coarse scanning, and camera lens has reached at this time End position can not also continue to move, and also can not just determine the focusing position of camera lens, perform step S710, determine focusing Failure.
Step S709, determines the second position, into smart sweep phase.
It is "Yes" in step S705 judging results, meets the maximum value of the first contrast of the second image and the ratio of current value Value is more than or equal to the condition of the second threshold, then illustrating the peak position in coarse scanning stage can be determined, by the second figure As the first contrast maximum value corresponding to lens location be determined as the second position.
When step S708 judging results are "Yes", meet the maximum value and minimum value of the first contrast of the second image Ratio is greater than or equal to the condition of third threshold value, it may also be said to which the peak position in bright coarse scanning stage can be determined, and can be incited somebody to action Lens location corresponding to the maximum value of first contrast of the second image is determined as the second position.
After the second position is determined, into smart sweep phase.
By above-mentioned steps S701 to step S710, during the auto-focusing of image, can realize as shown in fig. 1 The step S2 gone out.
After the second position is determined by coarse scanning, can according to the second position, determine one for determine finally The focusing range of focusing position, the focusing range is it can be appreciated that be the range for essence scanning.The focusing range can To be the region centered on the second position.
Step S3 shown in Fig. 1:Determine focusing range, the focusing range is centered on the second position Region, in specific implementation, can be centered on the coarse scanning stage obtained second position, each two points before and after the second position One of the second step width region as the focusing range.
Step S4 shown in Fig. 1:The mobile camera lens in the focusing range, will be acquired in the imaging device The lens location in the focusing range in each lens location corresponding to the image of contrast maximum be determined as the camera lens Focusing position, in specific implementation, can be realized according to the flow of determining focusing position as illustrated in FIG. 8.
Determining the second position, and after determining focusing range according to the second position, when determining final focusing position, Step S801 can be first carried out, point processing such as carry out to focusing range.
The focusing range such as is subjected at point processing, the width of specific decile can based on experience value, experimental data etc. into The corresponding setting of row.
Fig. 9 is focusing position schematic diagram provided in an embodiment of the present invention, as shown in figure 9, can will be during coarse scanning It, will be with second in coordinate system determined by the first contrast obtained at obtained lens location and corresponding lens location The focusing range for being set to center such as carries out at point processing, in the present embodiment, is illustrated by taking the quartering as an example.In Fig. 9, solid line institute Corresponding lens location represents the lens location during coarse scanning, and the lens location represented by dotted line is during close scanning etc. Point treated lens location, the wherein second position is the camera lens scan position of coarse scanning and close scanning simultaneously.
Step S802 is performed, camera lens is adjusted to each position of halving obtained after decile processing respectively.
After decile processing, camera lens is pushed on position of halving.
Step S803 is performed, with corresponding to the image of the first contrast maximum in each position of halving acquired in imaging device Lens location be determined as the focusing position of the camera lens.
Camera lens can obtain corresponding to the first contrast of the image of the lens location, obtain on each position of halving The lens location corresponding to the image of the first contrast maximum is taken, which is determined as final as shown in Figure 9 Focusing position.
According to it is as shown above go out step S1, step S2, step S3 and step S4 specific embodiment, automatic right In burnt process, when direction is focused in detection, obtain the first contrast and the second contrast of the first image respectively, according to based on The second contrast that image block obtains can average image data during the focusing direction for determining camera lens Process, this process can effectively remove the influence that picture noise extracts contrast-data, and the second contrast is in mirror Head position from practical focusing position farther out when, preferable location sen-sitivity can also be kept, can still obtain the true of image Real contrast situation, this is highly useful to the focusing orientation detection focused early period, can effectively improve the speed of auto-focusing And accuracy.Focusing early period used focusing orientation detection mode come obtain focusing place value direction, so every time focus just It can start to focus with the position that last time focusing is completed, without scanning focusing since initial position every time, this is in scene changes In the case of not being too big, focusing speed can be effectively improved.
Corresponding above-mentioned Atomatic focusing method, the embodiment of the present invention also provide a kind of automatic focusing mechanism.Figure 10 is the present invention The structure diagram for the automatic focusing mechanism that embodiment provides.
As shown in Figure 10, described device includes:Probe unit U11, coarse scanning unit U12, range determination unit U13 and position Put determination unit U14.
The probe unit U11 is often moved obtained by imaging device described in the first step-length along the first direction for obtaining camera lens The first image of the correspondence lens location arrived determines the focusing direction of the camera lens according to the contrast of described first image And first position.The contrast include the first contrast and the second contrast, first contrast according to image be located at pair The luminance difference between pixel in burnt region is determined, and second contrast is according to the image in the focusing area Luminance difference between block is determined.
The coarse scanning unit U12, for obtain the camera lens along it is described focusing direction often move described in the second step-length into As the second image of the equipment obtained correspondence lens location, second is determined according to the contrast of second image It puts.
The range determination unit U13, for determining focusing range, the focusing range be using the second position in The region of the heart.
The position determination unit U14, for the camera lens mobile in the focusing range, by the imaging device institute The lens location in the focusing range in each lens location corresponding to the image of contrast maximum obtained is determined as described The focusing position of camera lens.
The probe unit U11 includes:First obtains subelement U111 and the first determination subelement U112.
Described first obtains subelement U111, for obtaining the first contrast of corresponding each first image and second pair respectively Degree of ratio.
The first determination subelement U112, in the maximum value and minimum of the first contrast of each first image When the ratio of value is greater than or equal to first threshold, the focusing direction for determining the camera lens is the minimum value from first contrast The moving direction of the lens location of the maximum value of first contrast is changed to, the first position is each first image The first contrast minimum value corresponding to lens location.
The probe unit U11 is further included:Second determination subelement U113, in the first couple of each first image It is less than the first threshold, the maximum value of the second contrast of each first image than the maximum value of degree and the ratio of minimum value It is greater than or equal to the first threshold with the ratio of minimum value and the first data is more than the second data, it is determined that pair of the camera lens Burnt direction is the movement of the lens location for the maximum value that second contrast is changed to from the minimum value of second contrast Direction, the first position are the lens location corresponding to the minimum value of the second contrast of each first image, described the One data are by the first figure for being got at the lens location corresponding to the maximum value of the second contrast of each first image First contrast of picture, second data are the camera lens position corresponding to the minimum value of the second contrast of each first image Put the first contrast of the first image that place is got.
The probe unit U11 is further included:Third determination subelement U114, in the second couple of each first image When being greater than or equal to first threshold and the first data than the maximum value of degree and the ratio of minimum value and being more than the second data, determine described The focusing direction of camera lens is the camera lens position for the maximum value that second contrast is changed to from the minimum value of second contrast The moving direction put, the first position are the camera lens position corresponding to the minimum value of the second contrast of each first image It puts, first data at the lens location corresponding to the maximum value of the second contrast of each first image by getting The first image the first contrast, second data for each first image the second contrast minimum value corresponding to Lens location at the first contrast of the first image for being got.
The probe unit U11 is further included:4th determination subelement U115, if the second couple for each first image It is less than the first threshold, and the maximum of the first contrast of each first image than the maximum value of degree and the ratio of minimum value When the ratio of value and minimum value is greater than or equal to first threshold, the focusing direction for determining the camera lens is from first contrast Minimum value change to first contrast maximum value lens location moving direction, the first position is described each Lens location corresponding to the minimum value of first contrast of the first image.
The coarse scanning unit U12 includes:Second obtains subelement U121 and the 5th determination subelement U122.
Described second obtains subelement U121, for obtaining the first contrast of corresponding each second image;
The 5th determination subelement U122, in the maximum value of the first contrast of each second image and recently When the ratio of first contrast of primary the second acquired image is greater than or equal to second threshold, determine that the second position is Lens location corresponding to the maximum value of first contrast of each second image.
The coarse scanning unit U12 is further included:6th determination subelement U123, for the first of each second image The ratio of first contrast of the second image acquired in the maximum value of contrast and the last time is less than the second threshold, institute State end position and the first contrast of each second image that the position after the adjustment of camera lens the last time is not up to camera lens When the ratio of maximum value and minimum value is greater than or equal to third threshold value, the of the second position for each second image is determined Lens location corresponding to the maximum value of one contrast.
The position determination unit U14 includes:Wait subdivisions U141, mobile unit U142 and focusing unit U143.
It is described to wait subdivisions U141, for point processing such as carrying out to the focusing range.
The mobile unit U142, for each the decile position for being adjusted to obtain after decile processing respectively by the camera lens It puts.
The focusing unit U143, it is maximum for the first contrast in each position of halving acquired in the imaging device Image corresponding to lens location be determined as the focusing position of the camera lens.
Although present disclosure is as above, present invention is not limited to this.Any those skilled in the art are not departing from this It in the spirit and scope of invention, can make various changes or modifications, therefore protection scope of the present invention should be with claim institute Subject to the range of restriction.

Claims (20)

1. a kind of Atomatic focusing method, which is characterized in that including:
Obtain the first figure that camera lens often moves the long imaging device of the first step obtained correspondence lens location along the first direction Picture determines the focusing direction and first position of the camera lens according to the contrast of described first image;
Obtaining the camera lens, direction is every since the first position moves imaging device institute described in the second step-length along the focusing Obtained the second image of the correspondence lens location determines the second position according to the contrast of second image;
Determine focusing range, the focusing range is the region centered on the second position;
The mobile camera lens in the focusing range, by acquired in the imaging device in the focusing range each camera lens Lens location in position corresponding to the image of contrast maximum is determined as the focusing position of the camera lens.
2. Atomatic focusing method as described in claim 1, which is characterized in that the first direction be from camera lens current location to The direction of perifocus or the over focus movement of the imaging device.
3. Atomatic focusing method as described in claim 1, which is characterized in that the contrast includes the first contrast and second Contrast, first contrast are determined according to the luminance difference between the pixel in the focusing area, and described Two contrasts are determined according to the luminance difference between the image block in the focusing area.
4. Atomatic focusing method as claimed in claim 3, which is characterized in that first contrast is true by equation below It is fixed:
Wherein, VpFor first contrast, M is the horizontal resolution of the focusing area, and N is the vertical of the focusing area Resolution ratio, i and j are respectively the horizontal and vertical index value of the pixel in the focusing area, and L (i, j) is the focusing The brightness value of the pixel at (i, j) position in region;
Second contrast is determined by equation below:
Wherein, VbFor second contrast, X is the number of the image block contained by horizontal direction after the focusing area piecemeal, Numbers of the Y for the image block contained by vertical direction after the focusing area piecemeal, s and t are respectively in the focusing area The horizontal and vertical index value of image block, LB (s, t) are pixel in the image block at (s, t) position in the focusing area Average brightness value.
5. Atomatic focusing method as claimed in claim 3, which is characterized in that the focusing direction of the determining camera lens and first The process put includes:
The first contrast and the second contrast of corresponding each first image are obtained respectively;
If the maximum value of the first contrast of each first image and the ratio of minimum value are greater than or equal to first threshold, really The focusing direction of the fixed camera lens is the maximum value that first contrast is changed to from the minimum value of first contrast The moving direction of lens location, the first position are the mirror corresponding to the minimum value of the first contrast of each first image Head position.
6. Atomatic focusing method as claimed in claim 5, which is characterized in that the focusing direction of the determining camera lens and first The process put further includes:
If the maximum value of the first contrast of each first image and the ratio of minimum value are less than the first threshold, described each The maximum value of second contrast of the first image and the ratio of minimum value are greater than or equal to the first threshold and the first data are big In the second data, it is determined that the focusing direction of the camera lens is to change to described second pair from the minimum value of second contrast Than the moving direction of the lens location of the maximum value of degree, the first position for each first image the second contrast most Lens location corresponding to small value, first data is corresponding to the maximum values of the second contrast of each first image First contrast of the first image got at lens location, second data are the second couple of each first image The first contrast than the first image got at the lens location corresponding to the minimum value of degree.
7. Atomatic focusing method as claimed in claim 3, which is characterized in that the focusing direction of the determining camera lens and first The process put includes:
The first contrast and the second contrast of corresponding each first image are obtained respectively;
If the maximum value of the second contrast of each first image and the ratio of minimum value are greater than or equal to first threshold and the One data are more than the second data, it is determined that the focusing direction of the camera lens is changes to institute from the minimum value of second contrast The moving direction of the lens location of the maximum value of the second contrast is stated, the first position is the second couple of each first image Than the lens location corresponding to the minimum value of degree, maximum value of first data for the second contrast of each first image First contrast of the first image got at corresponding lens location, second data are each first image The second contrast minimum value corresponding to lens location at the first contrast of the first image for being got.
8. Atomatic focusing method as claimed in claim 7, which is characterized in that the focusing direction of the determining camera lens and first The process put further includes:
If the maximum value of the second contrast of each first image and the ratio of minimum value are less than the first threshold, and described The maximum value of first contrast of each first image and the ratio of minimum value are greater than or equal to first threshold, determine the camera lens Focusing direction is the shifting of the lens location for the maximum value that first contrast is changed to from the minimum value of first contrast Dynamic direction, the first position are the lens location corresponding to the minimum value of the first contrast of each first image.
9. Atomatic focusing method as claimed in claim 3, which is characterized in that the process of the determining second position includes:
Obtain the first contrast of corresponding each second image;
If the first comparison of the second image acquired in the maximum value of the first contrast of each second image and the last time The ratio of degree be greater than or equal to second threshold, it is determined that the second position for each second image the first contrast most The corresponding lens location of big value.
10. Atomatic focusing method as claimed in claim 9, which is characterized in that the process of the determining second position further includes:
If the first comparison of the second image acquired in the maximum value of the first contrast of each second image and the last time The ratio of degree is less than the second threshold, and the position after camera lens the last time adjustment is not up to end position and the institute of camera lens The ratio of maximum value and minimum value for stating the first contrast of each second image is greater than or equal to third threshold value, it is determined that described the Two positions are the lens location corresponding to the maximum value of the first contrast of each second image.
11. Atomatic focusing method as described in claim 1, which is characterized in that the center of the focusing range is described second Position, the width of the focusing range is second step-length.
12. Atomatic focusing method as described in claim 1, which is characterized in that the determination process of the focusing position of the camera lens Including:
Point processing such as carry out to the focusing range;
Each position of halving that the camera lens is adjusted to obtain after decile processing respectively;
Lens location in each position of halving acquired in the imaging device corresponding to the image of the first contrast maximum is true It is set to the focusing position of the camera lens.
13. a kind of automatic focusing mechanism, which is characterized in that including:
Probe unit often moves the long imaging device of the first step obtained correspondence camera lens along the first direction for obtaining camera lens First image of position determines the focusing direction and first position of the camera lens according to the contrast of described first image;
Coarse scanning unit, for obtaining obtained by the camera lens often moves imaging device described in the second step-length along the focusing direction The correspondence lens location the second image, the second position is determined according to the contrast of second image;
Range determination unit, for determining focusing range, the focusing range is the region centered on the second position;
Position determination unit, for the camera lens mobile in the focusing range, by acquired in the imaging device in institute State the focusing that the lens location in focusing range in each lens location corresponding to the image of contrast maximum is determined as the camera lens Position.
14. automatic focusing mechanism as claimed in claim 13, which is characterized in that the contrast includes the first contrast and the Two contrasts, first contrast is determined according to the luminance difference between the pixel in the focusing area, described Second contrast is determined according to the luminance difference between the image block in the focusing area;The probe unit includes:
First obtains subelement, for obtaining the first contrast and the second contrast of corresponding each first image respectively;
First determination subelement, for being more than in the maximum value of the first contrast of each first image and the ratio of minimum value Or during equal to first threshold, the focusing direction that determines the camera lens is to change to described the from the minimum value of first contrast The moving direction of the lens location of the maximum value of one contrast, the first position are the first contrast of each first image Minimum value corresponding to lens location.
15. automatic focusing mechanism as claimed in claim 14, which is characterized in that the probe unit further includes:Second determines Subelement, for being less than first threshold in the ratio of the maximum value of the first contrast of each first image and minimum value Value, the maximum value of the second contrast of each first image and the ratio of minimum value are greater than or equal to the first threshold and the One data are more than the second data, it is determined that the focusing direction of the camera lens is changes to institute from the minimum value of second contrast The moving direction of the lens location of the maximum value of the second contrast is stated, the first position is the second couple of each first image Than the lens location corresponding to the minimum value of degree, maximum value of first data for the second contrast of each first image First contrast of the first image got at corresponding lens location, second data are each first image The second contrast minimum value corresponding to lens location at the first contrast of the first image for being got.
16. automatic focusing mechanism as claimed in claim 14, which is characterized in that the probe unit further includes:
Third determination subelement, for being more than in the maximum value of the second contrast of each first image and the ratio of minimum value Or when equal to first threshold and the first data being more than the second data, the focusing direction for determining the camera lens is from the described second comparison The minimum value of degree changes to the moving direction of the lens location of the maximum value of second contrast, and the first position is described Lens location corresponding to the minimum value of second contrast of each first image, first data are each first image First contrast of the first image got at the lens location corresponding to the maximum value of the second contrast, second number According to the first image got at the lens location corresponding to the minimum value of the second contrast by each first image First contrast.
17. automatic focusing mechanism as claimed in claim 16, which is characterized in that the probe unit further includes:
4th determination subelement, if the maximum value of the second contrast and the ratio of minimum value for each first image are less than The first threshold, and the ratio of the maximum value of the first contrast of each first image and minimum value is greater than or equal to first During threshold value, the focusing direction for determining the camera lens is to change to first contrast from the minimum value of first contrast The moving direction of the lens location of maximum value, minimum value institute of the first position for the first contrast of each first image Corresponding lens location.
18. automatic focusing mechanism as claimed in claim 17, which is characterized in that the coarse scanning unit includes:
Second obtains subelement, for obtaining the first contrast of corresponding each second image;
5th determination subelement, for acquired in the maximum value of the first contrast of each second image and the last time When the ratio of first contrast of the second image is greater than or equal to second threshold, it is each second figure to determine the second position As the first contrast maximum value corresponding to lens location.
19. automatic focusing mechanism as claimed in claim 18, which is characterized in that the coarse scanning unit further includes:
6th determination subelement, for acquired in the maximum value of the first contrast of each second image and the last time The ratio of first contrast of the second image is less than the second threshold, and the position after camera lens the last time adjustment is not up to The maximum value of first contrast of the end position of camera lens and each second image and the ratio of minimum value are greater than or equal to the During three threshold values, the camera lens position corresponding to the maximum value for the first contrast that the second position is each second image is determined It puts.
20. automatic focusing mechanism as claimed in claim 13, which is characterized in that the position determination unit includes:
Subdivisions are waited, for point processing such as carrying out to the focusing range;
Mobile unit, for each position of halving for being adjusted to obtain after decile processing respectively by the camera lens;
Focusing unit, for corresponding to the image of the first contrast maximum in each position of halving acquired in the imaging device Lens location be determined as the focusing position of the camera lens.
CN201410603586.0A 2014-10-30 2014-10-30 Atomatic focusing method and device Active CN105629628B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410603586.0A CN105629628B (en) 2014-10-30 2014-10-30 Atomatic focusing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410603586.0A CN105629628B (en) 2014-10-30 2014-10-30 Atomatic focusing method and device

Publications (2)

Publication Number Publication Date
CN105629628A CN105629628A (en) 2016-06-01
CN105629628B true CN105629628B (en) 2018-06-22

Family

ID=56044717

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410603586.0A Active CN105629628B (en) 2014-10-30 2014-10-30 Atomatic focusing method and device

Country Status (1)

Country Link
CN (1) CN105629628B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106226975B (en) * 2016-07-20 2019-03-19 成都微晶景泰科技有限公司 Atomatic focusing method, equipment and imaging device
CN106501917B (en) * 2016-12-07 2019-12-27 歌尔科技有限公司 Lens auxiliary focusing method and device
CN109752831B (en) * 2017-11-02 2022-01-14 山东颐泽天泰医疗科技有限公司 Automatic focusing method, system and device for microscope with controllable focusing time
CN110062150B (en) * 2018-01-19 2020-12-04 上海富瀚微电子股份有限公司 Automatic focusing method and device
CN109085695B (en) * 2018-08-08 2021-06-18 杭州上池科技有限公司 Method for quickly focusing and photographing plane sample
CN111050061B (en) * 2018-10-12 2021-06-29 杭州易现先进科技有限公司 Focusing method, focusing device, medium and computing equipment
CN110426375A (en) * 2019-07-30 2019-11-08 中国海洋大学 A kind of deep-sea LIBS in-situ detector
CN110336951A (en) * 2019-08-26 2019-10-15 厦门美图之家科技有限公司 Contrast formula focusing method, device and electronic equipment
CN112640425A (en) * 2020-04-14 2021-04-09 深圳市大疆创新科技有限公司 Focusing control method, device, equipment, movable platform and storage medium
CN112099217B (en) * 2020-08-18 2022-10-28 宁波永新光学股份有限公司 Automatic focusing method for microscope
CN111901531A (en) * 2020-08-31 2020-11-06 浙江水晶光电科技股份有限公司 Focusing method, device and equipment during lens assembly
CN114827392B (en) * 2021-01-29 2024-02-13 北京小米移动软件有限公司 Optical component adjusting method, device, terminal and storage medium
CN113438414B (en) * 2021-06-11 2022-10-11 深圳市道通智能航空技术股份有限公司 Focusing method, focusing device and unmanned aerial vehicle

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1940699A (en) * 2005-09-26 2007-04-04 宾得株式会社 Camera having automatic lens system
CN101222585A (en) * 2002-09-03 2008-07-16 佳能株式会社 Autofocus method and apparatus
CN101290464A (en) * 2007-04-20 2008-10-22 展讯通信(上海)有限公司 Lens automatic focusing device and automatic focusing method
CN101324693A (en) * 2007-06-12 2008-12-17 展讯通信(上海)有限公司 Optical zoom lens control device
JP2014145808A (en) * 2013-01-28 2014-08-14 Olympus Corp Imaging apparatus and method for controlling imaging apparatus

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101222585A (en) * 2002-09-03 2008-07-16 佳能株式会社 Autofocus method and apparatus
CN1940699A (en) * 2005-09-26 2007-04-04 宾得株式会社 Camera having automatic lens system
CN101290464A (en) * 2007-04-20 2008-10-22 展讯通信(上海)有限公司 Lens automatic focusing device and automatic focusing method
CN101324693A (en) * 2007-06-12 2008-12-17 展讯通信(上海)有限公司 Optical zoom lens control device
JP2014145808A (en) * 2013-01-28 2014-08-14 Olympus Corp Imaging apparatus and method for controlling imaging apparatus

Also Published As

Publication number Publication date
CN105629628A (en) 2016-06-01

Similar Documents

Publication Publication Date Title
CN105629628B (en) Atomatic focusing method and device
CN105659580B (en) A kind of Atomatic focusing method, device and electronic equipment
EP2622840B1 (en) Continuous autofocus based on face detection and tracking
US5877809A (en) Method of automatic object detection in image
CN107005655B (en) Image processing method
EP2141537A1 (en) Image pickup apparatus, method of controlling the same, computer program code, and storage medium
EP3089449A1 (en) Method for obtaining light-field data using a non-light-field imaging device, corresponding device, computer program product and non-transitory computer-readable carrier medium
CN101995733B (en) Imaging apparatus and control method thereof
CN101095340A (en) Focal length detecting for image capture device
CN105007420A (en) Focusing method and mobile terminal
CN103986877A (en) Image acquiring terminal and image acquiring method
US20140307054A1 (en) Auto focus method and auto focus apparatus
CN105744152B (en) Subject tracing equipment, picture pick-up device and subject method for tracing
CN104079837B (en) A kind of focusing method and device based on imaging sensor
JP5392198B2 (en) Ranging device and imaging device
JP6685823B2 (en) Subject tracking device, control method thereof, imaging device, and program
KR20160079106A (en) Imaging device and method for automatic focus in an imaging device as well as a corresponding computer program
EP3218756B1 (en) Direction aware autofocus
JP2007328360A (en) Automatic focusing camera and photographing method
JP4871691B2 (en) Imaging apparatus and control method thereof
JP5454392B2 (en) Ranging device and imaging device
JP2014027436A (en) Subject tracking device and imaging apparatus
CN108734065B (en) Gesture image acquisition equipment and method
CN107783250A (en) Picture pick-up device quick focusing method with automatic focusing function
KR101599434B1 (en) Space detecting apparatus for image pickup apparatus using auto focusing and the method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20190313

Address after: 101399 Building 8-07, Ronghui Garden 6, Shunyi Airport Economic Core Area, Beijing

Patentee after: Xin Xin finance leasing (Beijing) Co.,Ltd.

Address before: 201203 Shanghai Pudong New Area Pudong Zhangjiang hi tech park, 2288 Chong Nong Road, exhibition center, 1 building.

Patentee before: SPREADTRUM COMMUNICATIONS (SHANGHAI) Co.,Ltd.

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20160601

Assignee: SPREADTRUM COMMUNICATIONS (SHANGHAI) Co.,Ltd.

Assignor: Xin Xin finance leasing (Beijing) Co.,Ltd.

Contract record no.: X2021110000008

Denomination of invention: Auto focusing method and device

Granted publication date: 20180622

License type: Exclusive License

Record date: 20210317

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20221014

Address after: 201203 Shanghai city Zuchongzhi road Pudong New Area Zhangjiang hi tech park, Spreadtrum Center Building 1, Lane 2288

Patentee after: SPREADTRUM COMMUNICATIONS (SHANGHAI) Co.,Ltd.

Address before: 101399 Building 8-07, Ronghui Garden 6, Shunyi Airport Economic Core Area, Beijing

Patentee before: Xin Xin finance leasing (Beijing) Co.,Ltd.