A Rapid Auto-Focus Method in the Telephoto Lens

A Rapid Auto-Focus Method in the Telephoto Lens

Cuiping Wang 

The College of Information Engineering, Shandong Yingcai University, Shandong Jinan 250104, China.

Corresponding Author Email: 
| |
| | Citation



With the emergence of laser night vision technology, telephoto lenses are widely used in civilian security domain. For the auto-focus problem of the telephoto lens, this paper has developed a set of automatic focusing system by using image processing technology and the embedded platform. First we determine the adjustable range of the telephoto lens, and within this range reach maximum clarity using the large step search value, then adopt small step value into value to clear point location. The definition values of real-time calculation is implemented in the form of hardware IP core in FPGA, and controls the module using SOPC technology.


telephoto lens, auto-focus, FPGA, SOPC

1. Introduction

Video monitoring is the important constituent of the security system. In order to get clear video data, we can tend to focus on the camera. It has good effect on the all-in-one close monitoring of automatic focusing and it basically can avoid manual focusing process. In a few years with the rapid development of laser night vision, telephoto lens is more widely used in civilian monitoring. The lens needs focus manually. Due to long focal length adjustment process is long, focusing accuracy are greatly influenced by personnel of subjective. The problem of the focusing the telephoto lens is solved with the digital image processing technology, thus further improve the measurement precision, measurement speed and the degree of automation and reduce the labor intensity of operators.

According to Fourier optical theory, image clarity or the degree of focus is determined by high frequency distribution of the light distribution. The less high frequency component can blur the image and the rich high frequency component can clear the image. Traditional automatic focusing is  to simulate automatic focusing, namely by filtering the output analog video signal of the sensor suite, extracting out the high frequency component of the reflected image resolution and outputting to the single chip microcomputer and so on. It is to achieve automatic focusing adjusting by regulating the rotation of the stepper motor and making the image reach the maximum value of high frequency component value. This method has a complex hardware circuit, and easily affected unstable by outside noise and interference. It is introduced a new system in this paper.

2. System Composition

The automatic focusing controller adopts field programmable gate array (FPGA) EP3C10 as the host controller. The analog video signal of the camera CCD is first converted into the digital video signal through a composite video decoding chip TVP5150 and is transmitted to the FPGA, FPGA detects Sobel edge of the digital video signal, and the readings is the clarity evaluation value of the current image frames. FPGA adopts the improved algorithm of climbing a hill by comparing the clarity evaluation value of continuous frame, and directly controls the output signal of L293DD.

Motor drive circuit and control the focus motor rotation based on output control signal of FPGA, in order to drive the telephoto lens on the lens movement and maximize the clarity evaluation value of the current image frame, so automatic focusing is achieved. In order to detect the focusing results, this controller divides the analog video signal of the PAL system into two with video distributor opa2354: a way to send a monitor display; the way to do the image processing.

Figure 1. Hardware principle diagram

3. Software Implementation

Automatic focusing software has two main components, the calculation of the focusing evaluation function and the realization of the maximum search strategy. The system uses SOPC technology and collaboratively design through hardware and software. The system realizes the acquisition of video image, the calculation of Sobel edge and the search of maximum energy with the reuse technology of IP resources in Cyclone series of the Altera FPGA. This system is the smallest system of NIOSII. The program is stored in the the chip EPCS4 and runs on a piece of internal RAM. The image acquisition module and Sobel edge energy calculation module adopt hardware programming, and search strategy uses C voice programming. Below is the system based on SOPC.

Figure 2. SOPC architecture of automatic focusing

3.1 Focusing evaluation function

Focusing evaluation function commonly used has several methods: high frequency component method, gray level difference method, Laplace, Robert, Sobel energy function and so on. The following is the matlab simulation curve about the calculation of the per frame definition in the process of a video focusing.

Figure 3. The simulation of three kinds function

Figure 5 is shown 3*3 spatial filtering template in Figure 4 and 3*3 image region convolution schematic diagram in Figure 3. We can find that the operation method greatly simplifies the design using programmable adder altmult_add module and a programmable multichannel parallel adder parallel_add module to implement convolution, comparing the previous literatures using discrete D trigger and adder and multiplier to complete convolution.

Figure 4. Sobel module

Figure 5. Convolution principle diagram

Programmable by adder altmult_and can receive multiple sets of data input, data after the multiplication addition or subtraction results as output. And altmult_add when use multiplier can be set according to need number, input/output data format, pipeline control parameters such as clock, internal displacement functions at the same time it also support the input data. Using programmable multichannel

parallel adder parallel_add module, the user is free to design the input data bit width, number, accumulate data definition accumulative input data types, module automatically generate appropriate bits wide data output in the end. Do add operation, and use parallel_add module can be specified by the clock delay in order to realize the assembly line design, so as to improve the performance of the circuit, improve the working frequency of the whole system.

Operation according to the x direction and y direction gradient operator get pixel level gradient and vertical gradient computation results respectively Pa_x and Pa_y is the Gx combined with Gy value  again by gradient arithmetic formula to calculate the gradient value of the corresponding pixel point, can use in the design of Quartus Ⅱ provides a macro SQRT function module to complete the gradient value is calculated.

SQRT sqrt0 (CLK (iCLK),

Radical (Pa_x + Pa_y Pa_x * * Pa_y),

Q (Abs_mag));

Instantiation module code of altmult_add:

mult_add3_8X8 x0(.clock0(iCLK), .dataa_0(P1),

.dataa_1(P2), .dataa_2(P3), .datab_0(X1),

.datab_1(X2),       .datab_2(X3), .result(Mac_x0));

Instantiation module code of parallel_add:

PA3 pa0 ( .clock(iCLK), .data0x(Mac_x0),

.data1x(Mac_x1), .data2x(Mac_x2),  .result(Pa_x)).

3.2 Auto focus search algorithm

The auto focus search algorithm of the hill-climbing is the most used in the aspect of the current focus search strategies. First, focus lens searches in any direction and determines the focus clear direction. Then the lens to move the “peak” direction, it makes the reverse search focus when found over the “peak”, until it reaches the peak at the same time it stops focusing. But the focus adjustable range of telephoto lens is wide, the simple hill-climbing type often could not find the focus position when the current focus positionis is far away from the focus. If we use a full search, it is bound to cause the focusing time is too long. While the telephoto lens usually outputs a voltage signal with focal length and focal position feedback in general. We should adjust the starting point of the scope and then search the resolution if the current position is not in the scope of this section. The focus range can be measured by the following ways:

(1) Observing 15 meters and setting the lens for the longest, we record the current feedback value for V1 after focusing clearly.

(2) Observing 2 kilometers and setting the lens for the longest, we record the current feedback value for V2 after focusing clearly.

The focusing range of the lens is V1-V2. System focusing flow chart is shown in below.

The hill climbing algorithm is used in the near region search strategy, and the algorithm using the method of the variable step. A telephoto lens adopts generally DC brushless motor, and the speed of the motor is in proportional to the voltage, therefore we can control the variable step size through changing the voltage to adjust the motor speed. The concrete realization is to control enable end of L293DD based on PWM mode, and adjust the duty ratio of output voltage. L represents a big step and l represents a small step.

Figure 6. Search flow chart

Figure 7. Hill climbing search flow chart

4. Test Result

The focus difficulty is greater in the real test, and the tiny change will cause a big change of the definition of the video. After several tests of the error compensation, this paper tests the telephoto focus of the long distance, middle distance and close distance. It can better find the sharpest focus. The middle and short focal end is relatively easy to get clear. Test screenshot is shown below.

The focus effect of the different distance:

The 15 frame

The 30 frame

The 40 frame

The focus effect of the middle distance:

The 20 frame

The 40 frame

The 55 frame

The focus effect of the close distance:

The 4 frame

The 10 frame

The 20 frame


1. ZHOU Xian, Auto-Focus Algorithm Based on Image Edge Energy [J], Optical Technology, 2006, 32(2):213-215, 218.

2. REN Si-gang, Automatic Focusing Technique Based on Gray Scale Difference Method [J], Opto-Elevtronic Engineering: 2003, 30(2):53-55.

3. KANG Zong-ming, Implementation of an Automatic Focusing Algotithm Based on Spatial High Frequency Energy and Entropy [J], ACTA Electronica Sinica, 2003, 31(4):552-555.

4. HU Feng-ping, Development of the Video Automatic Focus Method [J], Acta Photonica Simica, 2010, 39:1901-1906.

5. Li F., Jin H., A Fast Auto-Focusing Method for Digital Still Camera [A], Processing of the Fourth International Conference on Machine Learning and Cybernetics [C], Guangzhou, IEEE 2005:5001-5005. 

6. He J., Rongzhen Zhou R. Z., Modified Fast Climbing Search Auto-Focus Algorithm with Adaptive Step Size Searching Technique for Digital Camera [J], IEEE Transactions on Consumer Electronics, 2003, 49(2):257-262. DOI: 10.1109/TCE.2003.1209511.

7. Kazu shige, Keiji Izumi, Mitsuyuki Nozaki, et al., An Advanced Autofocus System for Video Camera Using Quasi Condition Reasoning [J], IEEE Transations on Consumer Electronics, 1990, 36(3):526-529.

8. Young K. K., June S. L., You Y J et al., An Advanced Camera System Having Fast Auto-focus Control [C], International Conference on Consumer Electronics Los Angles, 2001(1):210-211.

9. WANG Feng-yu, WANG Rui, Auto-focusing system based  on DSP [J], Opto-Electronic Engineering, 2007, 34(8):134-138.

10. Pech-Pachcco J. L., Cristobal G., Chamorro-Martincz J., et al., Diatom Aurofocusing in Brightfield Microscopy: A Comparative Study [A], 15th International Conference on Pattern Recognition [C], Barcclona,Spain: IEEE, 2000, 3:314-317.

11. HUANG Gui-zao, XU Xiang-dong, LU Zu-kang, An Automatic Focusing System for Processing Signal with Single-Chip Microprocessor [J], Opto-electronic Engineering, 2002, 29(20):42-44.

12. LI Li-hong, ZHANG Ming-lu, ZHANG Jian-hua, Research of automatic focus system [J], Journal Of Tianjin Polytechnic University, 2011, 30(6):43-48.

13. XIONG Guo-quan, JIANG Lin, The Design on VIP System Based on RF-SIM Card [J], Sci-Tech Information Development & Economy, 2008, 18(27): 52-59.

14. Jie He, Rongzhen Zhou, Zhiliang Hong, Modified Fast Climbing Search Auto-Focus Algorithm with Adaptive Step Size Searching Technique for Digital Camera [J], IEEE Transactions on Consumer Electronics, 2003, (02):257-262. DOI: 10.1109/TCE.2003.1209511.

15. Cheol Hee Park, Jong Ho Paik, Young Hwan You, Hyoung- Kyu Song, Yong-soo Cho, Auto Focus Design and Implementation Using Correlation between Filter and Auto Focus Criterion [A], 2000:250-251. DOI: 10.1109/ICCE.2000.854611.

16. ZHENG Jing, ZHANG qi-gui, WANG Peng, An Improved Autofocus Searching Algorithm and Its Implementating [J], Computer Development and Application, 2010, 23(1): 26-28.