CN105163036A - Lens automatic focusing method - Google Patents

Lens automatic focusing method Download PDF

Info

Publication number
CN105163036A
CN105163036A CN201510657845.2A CN201510657845A CN105163036A CN 105163036 A CN105163036 A CN 105163036A CN 201510657845 A CN201510657845 A CN 201510657845A CN 105163036 A CN105163036 A CN 105163036A
Authority
CN
China
Prior art keywords
matrix
subgraph
image
fse
coefficient
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
CN201510657845.2A
Other languages
Chinese (zh)
Other versions
CN105163036B (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.)
CHENGDU SANLINGJIA MICROELECTRONIC Co Ltd
Original Assignee
CHENGDU SANLINGJIA MICROELECTRONIC 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 CHENGDU SANLINGJIA MICROELECTRONIC Co Ltd filed Critical CHENGDU SANLINGJIA MICROELECTRONIC Co Ltd
Priority to CN201510657845.2A priority Critical patent/CN105163036B/en
Publication of CN105163036A publication Critical patent/CN105163036A/en
Application granted granted Critical
Publication of CN105163036B publication Critical patent/CN105163036B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Studio Devices (AREA)
  • Automatic Focus Adjustment (AREA)

Abstract

The invention provides a lens automatic focusing method. The method comprises the following steps that: (1) a focusing motor moves step by step in a movable range thereof, a lens collects a plurality of images every time when the focusing motor moves one step, a definition value of each image is calculated, and a mean value is obtained; and (2) all obtained values are compared and judged so as to obtain a maximum image definition value, the focusing motor is moved to the focusing motor position corresponding to the maximum image definition value, and automatic focusing is completed. According to the invention, automatic focusing is realized through software, a fixed algorithm is adopted for carrying out corresponding processing on information contained in digital images, corresponding controlled variables are obtained, and a stepping motor is driven to drive the lens move back and forth until the clearly focused image is obtained, so that the focusing speed is high, and the precision is high.

Description

A kind of self-focusing method of camera lens
Technical field
The present invention relates to technical field of visual measurement, especially relate to a kind of self-focusing method of camera lens.
Background technology
Automatic focus is from general principle, and automatic focus can be divided into two large classes: a class initiatively focuses on, based on the range finding auto-focusing of camera lens and the range measurement between target that is taken; Another kind of is passive focusing, based on the focus detection auto-focusing of imaging clearly on focusing screen.
Initiatively focus on and mainly contain infrared distance measuring method and supersonic sounding method.Infrared distance measuring ratio juris is, initiatively launches infrared ray as range finding light source by camera, and by the geometrical relationship formed between infrared diode, then calculate focusing from; Ultrasonic ranging method is found range the time of propagating between digital camera and object according to ultrasonic wave.Infrared-type and ultrasonic type auto-focusing are that utilization initiatively launches light wave or sound wave is found range, and are referred to as active auto-focusing.Passive focusing mainly contains contrast method and phase method.Contrast method realizes auto-focusing by the contour edge of detected image, and the contour edge of image is more clear, then its brightness step is larger, and the contrast in other words between edge's scenery and background is larger.Otherwise image out of focus, contour edge is smudgy, and brightness step or contrast decline, and out of focus far away, contrast is lower.Phase method is that the side-play amount by detecting picture realizes auto-focusing.
Summary of the invention
The object of the invention is to: for prior art Problems existing, provide a kind of camera lens self-focusing method, the focus method focusing speed solving existing contrast method is slow, and the problem that focusing accuracy is not high.
Goal of the invention of the present invention is achieved through the following technical solutions:
A kind of self-focusing method of camera lens, it is characterized in that, the method comprises the following steps:
(1) focus motor progressively moves in its moveable scope, often moves and moves a step, then camera lens gathers multiple images, and calculates the definition values of often opening image respectively, then averages;
(2) all mean values obtained are compared judgement, obtain maximum image definition values, focus motor is moved to this focus motor position corresponding to maximum image definition values, complete automatic focus.
As further technical scheme, the calculation procedure of often opening the definition values of image is as follows:
(11) Y-component of image is divided into 9 subgraphs of 3x3;
(12) each subgraph is divided into the block of several 8x8 pixels, each piece builds corresponding 8x8 matrix I with the pixel value of its each pixel, integer transform is done to each matrix I, obtain 8x8 the rear coefficient of conversion, square operation is done to each coefficient, obtains the transformation energy matrix B E corresponding to each piece;
(13) to each subgraph, the coefficient of the correspondence position of the transformation energy matrix B E of some pieces that are divided into adds up, each subgraph obtains final subgraph transformation energy matrix PE (i), PE (i) for 8x8 matrix, i value be 0 ~ 8;
(14) be weighted cumulative to the 8x8 coefficient correspondence position of final subgraph transformation energy matrix PE (i) of 9 subgraphs, obtain full images transformation energy matrix E, E is 8x8 matrix;
(15) the 8x8 coefficient of full images transformation energy matrix E is scanned according to Zig-Zag order, be converted to array SE (x), x is 0 ~ 63, wherein SE (0) is called DC energy, SE (1) ~ SE (63) is called interchange data, by SE (1), SE (2), ~ SE (63) is multiplied by 1 respectively, 2, ~ 63, obtain FSE (1), FSE (2), ~ FSE (63), cumulative FX=FSE (1)+FSE (2)+... + FSE (63), FX is called AC energy, AC energy FX is obtained the definition values of image divided by DC energy FSE (0).
As further technical scheme, 9 subgraphs be divided in step (11), wherein center image is comparatively large, and around subgraph is less.
As further technical scheme, the transformation for mula doing integer transform to each matrix I in step (12) is F=I*T 8x8, wherein F is the 8x8 matrix after conversion, and T is that fixed matrix is as follows:
T 8 x 8 = 8 8 8 8 8 8 8 8 12 10 6 3 - 3 - 6 - 10 - 12 8 4 - 4 - 8 - 8 - 4 4 8 10 - 3 - 12 - 6 6 12 3 - 10 8 - 8 - 8 8 8 - 8 - 8 8 6 - 12 3 10 10 - 3 12 - 6 4 - 8 8 - 4 - 4 8 - 8 4 3 - 6 10 - 12 12 - 10 6 - 3 .
As further technical scheme, in step (14) during weighted accumulation, around the weight coefficient of subgraph is less than the weight coefficient of center subgraph.
As further technical scheme, around the weight coefficient of subgraph equals 0.5 ~ 1 times of the weight coefficient of center subgraph.
Compared with prior art, the present invention can pass through software simulating automatic focus, namely by fixing algorithm, respective handling is carried out to the information that digital picture inherence comprises, obtain corresponding controlled quentity controlled variable, Driving Stepping Motor, drives camera lens to move forward and backward, focuses on clearly image until obtain, not only focusing speed is fast, and precision is high.Because passive method does not need extra distance-measuring equipment, therefore adopt the general small volume of this instrument, easy to carry, use flexibly, can be applicable to digital camera, networking makes a video recording in first-class optical system.
Accompanying drawing explanation
Fig. 1 is nine subgraphs being divided into 3X3;
Fig. 2 is the scanning sequency figure of Zig-Zag;
Fig. 3 is automatic focus implementation framework.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail.
Embodiment
The invention provides a kind of self-focusing method of camera lens, belong to the passive focusing of contrast method.The method is by subregion computed image definition, then weighted average regional image definition, obtains final image definition, according to image definition, in the scope limiting focus motor, and mobile focus motor search maximum image definition.
The inventive method realize principle as shown in Figure 3, gather image by lens optical system, receive cmos image sensor pass the video data of coming, then through the process of automatic focus adjusting module, obtain view data clearly.Its specific implementation step is as follows:
(1) the video data YUV that cmos image sensor transmits is received;
(2) Y-component of a two field picture is divided into 9 subgraphs of 3x3, each subgraph all can be divided into the block of several 8x8.As Fig. 1, wherein center image ratio is comparatively large, and around image is smaller, and we are with from left to right, and order is from top to bottom nominally P0, P1, P2, P3, P4, P5, P6, P7, P8, wherein maximum centered by P4 subgraph;
(3) each subgraph is divided into the block of MxN 8x8, each 8x8 block builds corresponding 8x8 matrix I with the pixel value of each point, does integer transform to the block of each 8x8, obtains 8x8 the rear coefficient of conversion, does square operation to each coefficient;
Wherein, integer transform formula is F=I*T 8x8, F is the 8x8 matrix after conversion, and I is input as image 8x8 block, and T is that fixed matrix is as follows:
T 8 x 8 = 8 8 8 8 8 8 8 8 12 10 6 3 - 3 - 6 - 10 - 12 8 4 - 4 - 8 - 8 - 4 4 8 10 - 3 - 12 - 6 6 12 3 - 10 8 - 8 - 8 8 8 - 8 - 8 8 6 - 12 3 10 10 - 3 12 - 6 4 - 8 8 - 4 - 4 8 - 8 4 3 - 6 10 - 12 12 - 10 6 - 3
The formula each coefficient being done to square operation is:
BE (x, y)=F (x, y) * F (x, y), x=0 ~ 7, y=0 ~ 7, BE is transformation energy matrix.
(4) to each subgraph, the coefficient of the correspondence position of the transformation energy matrix B E of MxN the 8x8 block be divided into by subgraph adds up, each subgraph obtains final subgraph transformation energy matrix PE (i), and PE (i) is 8x8 matrix, i=0 ~ 8;
(5) be weighted cumulative to the 8x8 coefficient correspondence position of final subgraph transformation energy matrix PE (i) of 9 subgraphs, the weight coefficient of the subgraph (weight coefficient of around subgraph centered by the weight coefficient 0.5 ~ 1 times of subgraph less of the weight coefficient of center subgraph around, the present embodiment gets 0.6 times), obtain full images transformation energy matrix E, E is 8x8 matrix.
(6) by the scanning sequency of the 8x8 coefficient of full images transformation energy matrix E by Zig-Zag, be converted to array SE (x), x is 0 ~ 63, wherein SE (0) is called DC energy, SE (1) ~ SE (63) is called interchange data, by SE (1), SE (2) ~ SE (63) is multiplied by 1 respectively, 2 ~ 63, obtain FSE (1), FSE (2), ~ FSE (63), cumulative FX=FSE (1)+FSE (2)+... + FSE (63), FX is called AC energy.ZigZag scanning sequency as shown in Figure 2.
(7) AC energy FX is obtained image definition Fc divided by DC energy FSE (0).
(8) according to present convergence motor mobile range, (motor has been determined, moving range is also fixed), with image clarity values Fc for criterion, mobile focus motor in focus motor mobile range, motor is capable further, at multiple images of this station acquisition, calculate the definition values of often opening image respectively, then average; Then all definition mean value is compared judgement, obtain the focus motor position of maximum image definition values Fc, finally motor is moved to this position, then complete automatic focus.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, it should be pointed out that all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.

Claims (6)

1. the self-focusing method of camera lens, it is characterized in that, the method comprises the following steps:
(1) focus motor progressively moves in its moveable scope, often moves and moves a step, then camera lens gathers multiple images, and calculates the definition values of often opening image respectively, then averages;
(2) all mean values obtained are compared judgement, obtain maximum image definition values, focus motor is moved to this focus motor position corresponding to maximum image definition values, complete automatic focus.
2. the self-focusing method of a kind of camera lens according to claim 1, it is characterized in that, the calculation procedure of often opening the definition values of image is as follows:
(11) Y-component of image is divided into 9 subgraphs of 3x3;
(12) each subgraph is divided into the block of several 8x8 pixels, each piece builds corresponding 8x8 matrix I with the pixel value of its each pixel, integer transform is done to each matrix I, obtain 8x8 the rear coefficient of conversion, square operation is done to each coefficient, obtains the transformation energy matrix B E corresponding to each piece;
(13) to each subgraph, the coefficient of the correspondence position of the transformation energy matrix B E of some pieces that are divided into adds up, each subgraph obtains final subgraph transformation energy matrix PE (i), PE (i) for 8x8 matrix, i value be 0 ~ 8;
(14) be weighted cumulative to the 8x8 coefficient correspondence position of final subgraph transformation energy matrix PE (i) of 9 subgraphs, obtain full images transformation energy matrix E, E is 8x8 matrix;
(15) the 8x8 coefficient of full images transformation energy matrix E is scanned according to Zig-Zag order, be converted to array SE (x), x is 0 ~ 63, wherein SE (0) is called DC energy, SE (1) ~ SE (63) is called interchange data, by SE (1), SE (2), ~ SE (63) is multiplied by 1 respectively, 2, ~ 63, obtain FSE (1), FSE (2), ~ FSE (63), cumulative FX=FSE (1)+FSE (2)+... + FSE (63), FX is called AC energy, AC energy FX is obtained the definition values of image divided by DC energy FSE (0).
3. the self-focusing method of a kind of camera lens according to claim 2, is characterized in that, 9 subgraphs be divided in step (11), and wherein center image is comparatively large, and around subgraph is less.
4. the self-focusing method of a kind of camera lens according to claim 2, is characterized in that, the transformation for mula doing integer transform to each matrix I in step (12) is F=I*T 8x8, wherein F is the 8x8 matrix after conversion, and T is that fixed matrix is as follows:
T 8 x × 8 8 8 8 8 8 8 8 8 12 10 6 3 - 3 - 6 - 10 - 12 8 4 - 4 - 8 - 8 - 4 4 8 10 - 3 - 12 - 6 6 12 3 - 10 8 - 8 - 8 8 8 - 8 - 8 8 6 - 12 3 10 10 - 3 12 - 6 4 - 8 8 - 4 - 4 8 - 8 4 3 - 6 10 - 12 12 - 10 6 - 3 .
5. the self-focusing method of a kind of camera lens according to claim 2, is characterized in that, in step (14) during weighted accumulation, around the weight coefficient of subgraph is less than the weight coefficient of center subgraph.
6. the self-focusing method of a kind of camera lens according to claim 5, is characterized in that, around the weight coefficient of subgraph equals 0.5 ~ 1 times of the weight coefficient of center subgraph.
CN201510657845.2A 2015-10-13 2015-10-13 A kind of method that camera lens focuses on automatically Active CN105163036B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510657845.2A CN105163036B (en) 2015-10-13 2015-10-13 A kind of method that camera lens focuses on automatically

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510657845.2A CN105163036B (en) 2015-10-13 2015-10-13 A kind of method that camera lens focuses on automatically

Publications (2)

Publication Number Publication Date
CN105163036A true CN105163036A (en) 2015-12-16
CN105163036B CN105163036B (en) 2018-03-09

Family

ID=54803778

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510657845.2A Active CN105163036B (en) 2015-10-13 2015-10-13 A kind of method that camera lens focuses on automatically

Country Status (1)

Country Link
CN (1) CN105163036B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017054677A1 (en) * 2015-09-30 2017-04-06 努比亚技术有限公司 Mobile terminal photographing system and mobile terminal photographing method
CN107277381A (en) * 2017-08-18 2017-10-20 成都市极米科技有限公司 Camera focusing method and device
CN110411945A (en) * 2019-08-06 2019-11-05 沈阳大学 A kind of Image Acquisition camera for assembly line piece test
CN111654632A (en) * 2020-06-19 2020-09-11 展讯通信(上海)有限公司 Contrast focusing method, apparatus, electronic device and storage medium
CN113938596A (en) * 2020-06-29 2022-01-14 北京字节跳动网络技术有限公司 Method and device for shooting image

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090268172A1 (en) * 2008-04-28 2009-10-29 Hon Hai Precision Industry Co., Ltd. Projector with autofocus device
CN101762232A (en) * 2008-12-23 2010-06-30 鸿富锦精密工业(深圳)有限公司 Multi-surface focusing system and method
CN101782369A (en) * 2009-01-16 2010-07-21 鸿富锦精密工业(深圳)有限公司 Image measurement focusing system and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090268172A1 (en) * 2008-04-28 2009-10-29 Hon Hai Precision Industry Co., Ltd. Projector with autofocus device
CN101762232A (en) * 2008-12-23 2010-06-30 鸿富锦精密工业(深圳)有限公司 Multi-surface focusing system and method
CN101782369A (en) * 2009-01-16 2010-07-21 鸿富锦精密工业(深圳)有限公司 Image measurement focusing system and method

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017054677A1 (en) * 2015-09-30 2017-04-06 努比亚技术有限公司 Mobile terminal photographing system and mobile terminal photographing method
CN107277381A (en) * 2017-08-18 2017-10-20 成都市极米科技有限公司 Camera focusing method and device
CN110411945A (en) * 2019-08-06 2019-11-05 沈阳大学 A kind of Image Acquisition camera for assembly line piece test
CN111654632A (en) * 2020-06-19 2020-09-11 展讯通信(上海)有限公司 Contrast focusing method, apparatus, electronic device and storage medium
CN111654632B (en) * 2020-06-19 2022-02-08 展讯通信(上海)有限公司 Contrast focusing method, apparatus, electronic device and storage medium
CN113938596A (en) * 2020-06-29 2022-01-14 北京字节跳动网络技术有限公司 Method and device for shooting image

Also Published As

Publication number Publication date
CN105163036B (en) 2018-03-09

Similar Documents

Publication Publication Date Title
CN105163036A (en) Lens automatic focusing method
EP3190781B1 (en) Autofocus method, device and electronic apparatus
US9270902B2 (en) Image processing apparatus, image capturing apparatus, image processing method, and storage medium for obtaining information on focus control of a subject
KR101489048B1 (en) Imaging apparatus, image processing method, and recording medium for recording program thereon
CN105744163B (en) A kind of video camera and image capture method based on depth information tracking focusing
US9456141B2 (en) Light-field based autofocus
EP2381419B1 (en) Image capturing apparatus, method of detecting tracking object, and computer program product
US20120147150A1 (en) Electronic equipment
CN103714321B (en) Driver's Face detection system based on range image and intensity image
CN105378534B (en) The method of work of camera device, camera device
KR101455018B1 (en) Image capturing apparatus, image capturing method, and computer-readable recording medium
CN104902182B (en) A kind of method and apparatus for realizing continuous auto-focusing
US8169531B2 (en) System and method for automatically focusing an optical lens of an image measuring machine
JP7079358B2 (en) Target detection methods and devices, computer systems and readable storage media
CN104867125B (en) Obtain the method and device of image
US8855479B2 (en) Imaging apparatus and method for controlling same
CN102981347A (en) Automatic SUSAN focusing method for video monitoring system
CN105376474A (en) Image acquisition device and automatic focusing method thereof
CN104184935A (en) Image shooting device and method
US9158183B2 (en) Stereoscopic image generating device and stereoscopic image generating method
US20160241790A1 (en) Method and apparatus for selecting target image
EP3439286A1 (en) Calibration of pixels for producing super resolution images
CN105446056A (en) Automatic focusing device and method
CN102948142A (en) Auto-focus image system
CN105791666A (en) Automatic focusing device

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