Abstract:
A method for automatically focusing a camera comprising an image sensor, at least one lens configured to project an image onto the sensor and an actuator configured to modify a focusing parameter of the lens, comprises: a first phase of controlling the actuator in an open loop so the focusing parameter successively takes a plurality of predefined values, images being acquired for each value of the focusing parameter and a sharpness indicator being calculated on the basis of each image; and a second phase of controlling the actuator in a closed loop to maximize the sharpness indicator, the second closed-loop control phase being implemented by making use of a control law and starting conditions determined on the basis of the sharpness indicators calculated during the first phase. A system for automatically focusing a camera for implementing the method, and a camera equipped with such a system is provided.

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
       [0001]    This application claims priority to foreign French patent application No. FR 1552334, filed on Mar. 20, 2015, the disclosure of which is incorporated by reference in its entirety. 
       FIELD OF THE INVENTION 
       [0002]    The invention pertains to a method for automatically focusing a camera, or to an autofocus. The invention also pertains to an automatic focusing system implementing such a method, and to a camera—and more specifically a digital camera—equipped with such a system. 
       BACKGROUND 
       [0003]    In the literature and on the market, many automatic focusing methods exist, which may be grouped into two big families: open-loop and the closed-loop approaches. 
         [0004]    Open-loop approaches require a distance sensor, for example a time-of-flight sensor; for this reason they are also known as “active” approaches. An open-loop controller receives, as input, a signal issued from this sensor, representing the distance of a subject to be imaged, and uses it to generate a signal for controlling an actuator that acts upon a focusing parameter of the camera. The latter may be the distance between a lens and an image sensor, or indeed the vergence of the lens if the latter is deformable. Typically, the controller merely applies a predefined lookup table matching a distance measured by the sensor to a voltage or current level, delivered to the actuator. One advantage of this approach is that it is very fast. However, it has many drawbacks: the extra cost linked to the use of an active distance sensor, the need for a calibration to be carried out in order to construct the lookup table of the open-loop controller and for it to be repeated periodically in order to compensate for the drift of the optical module and of the actuator, and sensitivity to non-measurable disturbances that prevent a level of precision from being guaranteed (lack of robustness). An exemplary open-loop, or active, autofocus is given in the document U.S. Pat. No. 6,292,256. 
         [0005]    Closed-loop approaches do not make use of a distance sensor (they are therefore known as “passive” approaches), but rather of a module for estimating quality, which extracts a quality metric—typically sharpness—from the obtained image. This estimation is compared to a reference value in order to deliver an error signal; a closed-loop controller acts upon an actuator in such a way as to minimize this error signal. Among the advantages of this approach, mention may be made of the absence of an active distance sensor, and the fact that disturbances and drift are taken into account without the need for calibration. In contrast, if the performance of the system is to be robust in the face of uncertainties in optical module performance (for example linked to technological variability), the control law must be chosen wisely, this requiring a certain level of expertise on the part of the designer. Furthermore, speed is reduced with respect to open-loop systems. 
         [0006]    There are a wide variety of closed-loop approaches. 
         [0007]    One conventional solution consists in carrying out a search for a maximum sharpness (an indicator of the image quality) using a so-called “climbing” method on a sharpness curve. For this, the image sharpness estimator receives a matrix of signals from the image sensor and uses it to calculate a sharpness indicator “n” according to a chosen metric. Next (considering, for the sake of simplicity, the single case of a system with a variable focus lens), the value y=∂n/∂f of the sharpness gradient is calculated with respect to the focal length of the lens f; this makes it possible to determine the direction of the control to be applied. An integral-type control law is subsequently used, this allowing the lens to be deformed in such a way as to approach the maximum of the sharpness. This solution has a certain number of drawbacks. First of all, the calculation of the sharpness gradient is, by nature, very sensitive to noise. Furthermore, the signal for controlling the actuator is typically quantized, implying that all of the focal lengths in a given continuous interval [f min , f max ] are not actually attainable, leading to a degradation of the focusing precision. Decreasing the quantization step size allows focusing precision to be improved, but at the cost of increasing convergence time and power consumption. Parasitic oscillations may also occur about the optimum sharpness value. 
         [0008]    The paper by Jie He et al. “ Modified Fast Climbing Search Auto - focus Algorithm with Adaptive Step Size Searching Technique for Digital Camera ”, IEEE Transaction on Consumer Electronics, 49(2): 257-262 (2003) describes a refinement of this approach, in which the quantization step size is chosen depending on the proximity to the maximum (larger far away from the maximum, and increasingly small as proximity thereto increases). This makes it possible, at least in principle, to improve response time and power consumption. However, reliably determining the proximity of the maximum is not simple: specifically, the sharpness gradient is generally low both close to the optimum focusing conditions and far away therefrom. In practice, the rules for readapting the gain are chosen assuming a priori knowledge of the behaviour of the optical module, whereas in cases of actual use, this behaviour is often different from that modelled—owing to, for example, technological variability and temperature drift—thereby leading to a loss of focusing performance. 
         [0009]    Another possibility consists in using a PID (proportional-integral-derivative) controller with two additional degrees of freedom with respect to the purely integral control considered above. One advantage of this approach is that many proven methods for designing PID controllers are described in the literature. However, this type of control is worth considering only when the digital image sensor and the block for analyzing image sharpness operate at a speed comparable to or greater than that of the actuator of the lens (“slow lens”). Moreover, the model for which the PID controller has been setup does not allow the response time of the focusing system to be minimized because the model of the optical module changes depending on the scene in question. Furthermore, technological variability or even temperature drift implies that the actual module follows a model that is different to that used to set up the controller. 
         [0010]    Yet another possibility consists in adopting a predictive approach, see, for example, the paper by L.I.-C. Chiu et al. “ An efficient auto focus method for digital still camera based on focus value curve prediction model ”, Journal of Information Science and Engineering, 26(4): 1261-1272, (2010). In this approach, the sharpness as a function of the position of the lens given by a sum of bell curves is assumed to be mathematically modelled, the parameters of which must be identified. The presented results suggest that this method allows a very fast convergence to be obtained, at least in the presence of a single sharpness peak—this, typically, corresponding to the presence of a single object in the imaged scene. However, in the presence of a plurality of objects, the identification of the parameters of the model is a non-linear and, in general, non-convex problem, the computational complexity of which risks becoming prohibitive. 
         [0011]    The invention aims to overcome, entirely or in part, at least some of the aforementioned drawbacks. More precisely, the invention aims to provide an automatic focusing method that is both robust and fast and that does not require the use of an active distance sensor. The invention aims in particular to provide such a method that is well suited to the case of a “fast lens”, i.e. to a camera in which the response time of the actuator and of the optical module is less than the time required for the acquisition of the images and for the calculation of a sharpness metric. 
       SUMMARY OF THE INVENTION 
       [0012]    One subject of the invention, allowing this aim to be achieved, is a method for automatically focusing a camera comprising an image sensor, at least one lens configured to project an image onto said sensor and an actuator configured to modify a focusing parameter of the lens, the method comprising: 
         [0013]    a first phase comprising:
       an open-loop control of said actuator, so that said focusing parameter successively takes a plurality of predefined values;   the acquisition of a plurality of images by means of said sensor, each corresponding to one said predefined value of the focusing parameter; and   the calculation of a sharpness indicator on the basis of each of said images;       
 
         [0017]    and 
         [0018]    a second phase of controlling, in a closed loop, said actuator so as to maximize said sharpness indicator; 
         [0019]    said second closed-loop control phase being implemented by making use of a control law and starting conditions determined on the basis of the sharpness indicators calculated during said first phase. 
         [0020]    Another subject of the invention is a system for automatically focusing a camera comprising: 
         [0021]    an actuator configured to modify a focusing parameter of a lens of the camera; and 
         [0022]    a processor configured to receive, as input, a signal representative of an image acquired by an image sensor of the camera and to produce, at its output, a signal for controlling said actuator; 
         [0023]    characterized in that said processor is configured or programmed to implement such a method. 
         [0024]    Yet another subject of the invention is a camera comprising an image sensor, at least one lens configured to project an image onto said sensor and such an automatic focusing system the actuator of which is configured to modify a focusing parameter of said lens and the processor of which is configured to receive, as input, a signal representative of an image acquired by said sensor. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0025]    Other features, details and advantages of the invention will be brought to light upon reading the description given with reference to the appended drawings which are given by way of example and which show, respectively: 
           [0026]      FIG. 1 , the block diagram of a camera according to one embodiment of the invention; 
           [0027]      FIG. 2 , a flow diagram of a method according to one embodiment of the invention; 
           [0028]      FIG. 3 , a block diagram illustrating a control law according to one embodiment of the invention; 
           [0029]      FIGS. 4 a , 4 b  and 4 c   , graphs illustrating three possible embodiments of the first open-loop control phase. 
           [0030]      FIGS. 5 a  and 5 b   , illustrations of the implementation of the second closed-loop control phase according to two alternative embodiments of the invention; and 
           [0031]      FIGS. 6 a , 6 b , 7 a , 7 b , 8 a  and 8 b   , graphs illustrating the technical result of the invention. 
       
    
    
     DETAILED DESCRIPTION 
       [0032]      FIG. 1  shows a simplified block diagram of a digital camera with closed-loop automatic focusing, able to be adapted to the implementation of the invention. This camera essentially comprises an optical module MO, a matrix image sensor CMI and a processor PR. As for the optical module, it comprises at least one lens L and an actuator AC that allows at least one optical parameter of the module to be modified. In the example of the figure, the lens L is deformable and the actuator AC allows the vergence thereof to be modified; in other embodiments, the actuator could move the lens along its focal axis with respect to the sensor CMI. The lens forms an image on the sensor CMI, which produces an electronic signal I(x,y), where x and y are discrete indices identifying the pixels of the sensor. This signal is delivered to the processor PR which uses it, among other things, to generate a signal V for controlling the actuator, in accordance with the closed-loop autofocus principle. The camera may be integrated in another device, such as a mobile phone. 
         [0033]    The idea on which the invention is based consists in using an automatic focusing method comprising two phases: a first open-loop phase not using an active distance sensor, and a second closed-loop phase. The first phase consists in a summary exploration of a space of focusing configurations; typically, it is a question of trialling a series of predefined values of the vergence of the lens, the position thereof or any other parameter representative of the focusing conditions. An image is acquired for each of these focusing configurations, and its sharpness value is calculated by the processor. This makes it possible: 
         [0034]    1) to determine a starting condition sufficiently close to the optimum sharpness; 
         [0035]    2) to determine an optimum control law. 
         [0036]      FIG. 2  shows a flow diagram of a method implementing this principle. In the discussion of this flow diagram, the case will be considered in which focusing is achieved by moving the lens, but this is only a predefined example. 
         [0037]    Step i consists in positioning the lens in a first predetermined position (or in adjusting its vergence to a first predetermined value). Next (ii), an image corresponding to this position of the lens is acquired and the sharpness value thereof is calculated. Multiple sharpness metrics that may be applied to the invention are described in the paper by S. Pertuz et al. “ Analysis of focus measure operators for shape - from - focus ” Pattern Recognition, 46(5): 1415-1432, 2013. Next (iii), a counter i, initially set at 1, is incremented, and these operations are iterated for as long as its value does not exceed a predefined maximum N (iv). Typically, the number of iterations is between 3 and 7, or even 10. At the end of this first open-loop phase, N sharpness measurements corresponding to as many different lens positions, have therefore been obtained. It is therefore possible to determine the maximum of the measured sharpness values (vi), thereby allowing a starting condition V max , i.e. the value attributed to the signal for controlling the actuator at the start of the closed-loop control phase (vi), to be calculated. 
         [0038]    It is worth noting that, during the open-loop phase, the sampling of the space of focusing parameters is not necessarily uniform. By way of example, a still camera may be considered in which the user may select a “landscape” mode, a “macro” mode and a “portrait” mode. In “landscape” mode (cf.  FIG. 4A ), the region of low focal lengths “f” is very roughly sampled, and the majority of the predefined values tested are close to infinity, where, in all likelihood, the maximum sharpness n will be found. Stated otherwise, the rate of advance of the lens gradually decreases. In contrast in “macro” mode low focal lengths are preferentially sampled ( FIG. 4B ). In “portrait” mode ( FIG. 4C ) the majority of the sampled focal lengths have intermediate values. In  FIGS. 4A-4C , the sharpness n may equally be expressed as a function of the focal length f or of the control signal V FF  (“FF” for “feed-forward”), these two quantities being linked by a (not necessarily linear) relationship specific to the actuator. The expression “focusing parameter” will be used below to signify, either an optical parameter such as the vergence of a lens or its distance from the image sensor, or the corresponding value of the signal for controlling the actuator. 
         [0039]    If, for example, the case in  FIG. 4C  is considered, it will be noted that 9 focal length values are sampled (N=9); they are considered to be sampled in order, from the lowest focal length (for i=1) to the highest (i=N=9). The maximum sharpness corresponds to the case i=5. In order to get there from the end condition i=N=9, it would be necessary to move the lens backwards (i.e. in a direction opposite to that of the movement carried out during the open-loop phase). However, some actuators exhibit hysteresis; it may therefore be preferable, from the point of view of precision, to bring the lens back to its starting position (i=1), which typically corresponds to an end stop, and to move it forward to the optimum position. This approach to reducing the influence of hysteresis is of interest only if the lens has a response time much shorter than the operating rate of the imager, as the time limitation will come from the time required to position the lens in a stable state (i.e. after the transitional states). Nowadays, camera imagers generally operate at a speed of 60 frames per second (fps), corresponding to an interval between image acquisitions that is equal to 17 ms. 
         [0040]    Next begins the closed-loop control phase. Returning to  FIG. 2 , it may be seen that the first step of this second phase is the calculation of the “optimum” gain of the closed-loop control law (vi) on the basis of the “focusing parameter/image sharpness” pairs acquired beforehand. The implementation of this step according to one advantageous embodiment of the invention will be described in detail below with reference to  FIG. 5 . Next, the lens is moved (viii) depending on the gain calculated in the preceding step, an image is acquired and the corresponding sharpness is calculated (ix). If the maximum sharpness is reached (which is typically determined by verifying that the last movement was smaller than a threshold), the method is stopped; otherwise, a new iteration is started (x). It is important to note that, during iterations other than the first, the calculation of the gain (step vii) is performed while also taking into account the sharpness measurements carried out during the closed-loop phase. 
         [0041]      FIG. 3  illustrates a block diagram of an automatic focusing system implementing the method of  FIG. 2 . The assembly composed of the optical module and the image sensor receives, as input, a spatial light intensity distribution I 0 , a noise br, and a control signal V that determines at least one focusing parameter; at its output it delivers an electronic signal I, representative of an image. 
         [0042]    A switch makes it possible to choose between open-loop control (position 1) and closed-loop control (position 2). The open-loop controller corresponds to a static gain block K FF  receiving, as input, a ladder signal, which allows the lens L of the optical module MO to be moved in a predetermined manner. The closed-loop controller is much more complex. It comprises a quality evaluation module EQ, which receives, as input, the signal I generated by the image sensor, and, at its output, delivers a sharpness measurement n. The closed-loop control block K FB  first comprises a block for calculating the sharpness gradient ∇n (more precisely, the derivative of the sharpness with respect to the focusing parameter used for the control), a “sign” block for determining the sign of this gradient, a gain k i  that changes from one iteration to another depending on the value of the gradient and an integrator. 
         [0043]    In the figure, “V FF ” is the open-loop control signal, “V FB ” the closed-loop control signal and “V” the control signal actually applied to the actuator AC; V is equal to V FF  or to V FB  depending on the position of the switch. Typically, the processor PR, programmed in an appropriate manner, performs the functions of the closed-loop and open-loop controllers and of the switch: these elements therefore do not necessarily correspond to identifiable hardware elements: this is referred to as a software implementation. As a variant, the controllers may be implemented as hardware, using dedicated programmable logic circuits and/or integrated circuits. A hybrid software/hardware implementation is also possible. 
         [0044]    The steps for calculating the closed-loop gain will now be described in detail with the aid of  FIGS. 5 a    and  5   b.    
         [0045]    One advantageous aspect of the invention is the use of a quadratic approximation to locally model the sharpness characteristic in the vicinity of the maximum, this allowing the calculations to be performed during the closed-loop phase to be simplified most considerably. 
         [0046]    The sharpness n is then modelled by: 
         [0000]        n ( V )= a·V   2   +b·V+c   (1)
 
         [0047]    where a, b, c are the parameters of the model. It will be assumed below—although this in no way constitutes a limitation—that the control signal V (or V FB , as it is the closed-loop control phase that is under consideration) represents a voltage applied to an AC actuator that modifies the vergence or the position of the lens L. 
         [0048]    This hypothesis as to the shape of the sharpness curve in the vicinity of the maximum is not been rigorously verified in the general case. Nonetheless, it makes it possible to obtain an effective and easy-to-implement method allowing the maximum sharpness to be rapidly converged upon once the control loop is closed. Specifically, the parameters a, b and c of the quadratic model of the sharpness curve may be obtained analytically from three sharpness measuring points acquired during the open-loop phase. 
         [0049]    As a variant, it is possible to choose a more complex model, but, taking account of the limited number of measuring points obtained in the open-loop phase, this runs the risk of over-parameterization. In order to limit this risk, it is possible, by making use of all of the sharpness measurements acquired in the open-loop phase, to determine a cubic spline type model (which may or may not be constrained). However, this alternative embodiment entails an additional computational cost. The retained quadratic model also has the appeal of being determinable analytically from the judicious choice of three measuring points obtained in the open-loop phase. Alternatively, and in particular if more measurements are taken during the open-loop phase, it is possible to make use of a least squares-type method to determine the model of the sharpness curve, although this is computationally more costly. 
         [0050]    Another advantageous aspect of the invention is the use of an adaptive closed-loop control law in which the gain of the integrator of the closed-loop controller (or corrector) and, consequently, the step size of the actuator, vary depending on the proximity to the maximum sharpness. More precisely, in one embodiment of the invention, the information measured in the closed-loop phase is used to initialize the gain of the controller. This information is found in the gradient of the sharpness curve, the latter being modelled by the quadratic function of equation 1. This gradient is given by: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       ∂ 
                       
                         n 
                          
                         
                           ( 
                           V 
                           ) 
                         
                       
                     
                     
                       ∂ 
                       V 
                     
                   
                   = 
                   
                     
                       2 
                        
                       aV 
                     
                     + 
                     b 
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
         [0051]    It is apparent that there is only one voltage V* corresponding to a zero gradient: 
         [0000]    
       
         
           
             
               
                 
                   
                     V 
                     * 
                   
                   = 
                   
                     - 
                     
                       b 
                       
                         2 
                          
                         a 
                       
                     
                   
                 
               
               
                 
                   ( 
                   3 
                   ) 
                 
               
             
           
         
       
     
         [0052]    Applying this voltage to the actuator allows it to be moved to the theoretical maximum sharpness, assuming a quadratic sharpness variation. 
         [0053]    In practice, the parameters a and b of the quadratic model are unknown; in contrast, a few measuring points of the sharpness acquired for predefined voltages (open-loop phase) are available. Thus, in order to find the parameters a and b, it is possible to use a standard least squares type identification method. This method entails a non-negligible computational cost. However, the aim is to roughly determine the voltage range in which the voltage corresponding to the actual maximum sharpness is located. For this reason, as a first approximation, it is proposed to dispense with a least squares type of technique for identifying parameters. For this, three measuring points of the sharpness obtained in the open-loop phase, n max , n left , n Right , are retained, these points respectively being the open-loop measuring point having maximum sharpness, the point directly to the left and the point directly to the right (see the top part of  FIG. 5 a   , in which the voltage V* calculated by equation 3 is denoted by V 0 * for reasons that will be explained below). These three points are enough to define a parabola in a unique manner. This approach is very simple, but it does not allow measurement noise to be filtered out. 
         [0054]    It is known that the abscissa for which the derivative of a parabola is equal to zero is located at the overall maximum (minimum). Knowing that the function that describes the sharpness is upwardly convex, then the term “a” in equation 1 is smaller than zero. In this case, it is known that the zero gradient corresponds to the overall maximum because the second derivative is negative. H is questionable whether it would be better to use the sharpness gradient (∇n, in  FIGS. 5 a  and 5 b   ) instead of measuring the sharpness (n) directly. The problem with measuring the sharpness directly is that the absolute values are completely unpredictable and necessarily depend on the environment of the shot, whereas the absolute values of the gradient always converge towards zero when the voltage approaches the voltage corresponding to maximum sharpness. This advantage opens up the possibility of applying systematic determination methods for closed-loop control. 
         [0055]    The first problem to be solved to implement the closed-loop control therefore consists in determining the voltage corresponding to the maximum sharpness, given three points measuring absolute sharpness, and under the assumption that the sharpness, curve as a function of the voltage applied to the actuator is quadratic. 
         [0056]    This problem may be resolved by turning to Lagrange&#39;s theorem on the mean of a function: namely a continuous function fε          defined over the interval [x 1 , x 2 ]ε         ; there then exists a point x*ε[X 1 , x 2 ] such that: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                          
                         
                           f 
                            
                           
                             ( 
                             x 
                             ) 
                           
                         
                       
                       
                          
                         x 
                       
                     
                      
                     
                       | 
                       
                         x 
                         * 
                       
                     
                   
                   = 
                   
                     
                       
                         f 
                          
                         
                           ( 
                           
                             x 
                             2 
                           
                           ) 
                         
                       
                       - 
                       
                         f 
                          
                         
                           ( 
                           
                             x 
                             1 
                           
                           ) 
                         
                       
                     
                     
                       
                         x 
                         2 
                       
                       - 
                       
                         x 
                         1 
                       
                     
                   
                 
               
               
                 
                   ( 
                   4 
                   ) 
                 
               
             
           
         
       
     
         [0057]    More precisely, the following corollary of this theorem is employed: let f(x)=ax 2 +bx+c, where x,a,b,cε         ; then 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                          
                         
                           f 
                            
                           
                             ( 
                             x 
                             ) 
                           
                         
                       
                       
                          
                         x 
                       
                     
                      
                     
                       | 
                       
                         x 
                         * 
                       
                     
                   
                   = 
                   
                     
                       
                         f 
                          
                         
                           ( 
                           
                             x 
                             2 
                           
                           ) 
                         
                       
                       - 
                       
                         f 
                          
                         
                           ( 
                           
                             x 
                             1 
                           
                           ) 
                         
                       
                     
                     
                       
                         x 
                         2 
                       
                       - 
                       
                         x 
                         1 
                       
                     
                   
                 
               
               
                 
                   ( 
                   5 
                   ) 
                 
               
             
           
         
       
     
         [0058]    if and only if 
         [0000]    
       
         
           
             
               
                 
                   
                     x 
                     * 
                   
                   = 
                   
                     
                       
                         x 
                         2 
                       
                       + 
                       
                         x 
                         1 
                       
                     
                     2 
                   
                 
               
               
                 
                   ( 
                   
                     5 
                     ′ 
                   
                   ) 
                 
               
             
           
         
       
     
         [0059]    In the context of finding the zero gradient, this corollary is very useful as it makes it possible to obtain the voltages corresponding to levels of the gradients calculated from the sharpness measurement under the quadratic assumption. The three points measuring sharpness transform into two gradient points: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                        
                       left 
                     
                     = 
                     
                       
                         
                           
                             ∂ 
                             n 
                           
                           
                             ∂ 
                             V 
                           
                         
                          
                         
                           | 
                           
                             V 
                             = 
                             
                               V 
                               grad 
                               left 
                             
                           
                         
                       
                       = 
                       
                         
                           
                             n 
                             max 
                           
                           - 
                           
                             n 
                             left 
                           
                         
                         
                           
                             V 
                             max 
                           
                           - 
                           
                             V 
                             left 
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     
                        
                       right 
                     
                     = 
                     
                       
                         
                           
                             ∂ 
                             n 
                           
                           
                             ∂ 
                             V 
                           
                         
                          
                         
                           | 
                           
                             V 
                             = 
                             
                               V 
                               grad 
                               right 
                             
                           
                         
                       
                       = 
                       
                         
                           
                             n 
                             right 
                           
                           - 
                           
                             n 
                             max 
                           
                         
                         
                           
                             V 
                             right 
                           
                           - 
                           
                             V 
                             max 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
           
         
       
     
         [0000]    where the voltages V grad   left  and V grad   right  are determined by applying the corollary: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       V 
                       grad 
                       left 
                     
                     = 
                     
                       
                         
                           V 
                           max 
                         
                         + 
                         
                           V 
                           left 
                         
                       
                       2 
                     
                   
                    
                   
                     
 
                   
                    
                   
                     
                       V 
                       grad 
                       right 
                     
                     = 
                     
                       
                         
                           V 
                           max 
                         
                         + 
                         
                           V 
                           right 
                         
                       
                       2 
                     
                   
                 
               
               
                 
                   ( 
                   
                     6 
                     ′ 
                   
                   ) 
                 
               
             
           
         
       
     
         [0060]    The estimated “zero” gradient is therefore located on a straight line defined by the voltages calculated to generate the gradients of the measurement. This straight line is defined by: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                         
                           ∂ 
                           n 
                         
                         
                           ∂ 
                           V 
                         
                       
                       - 
                       
                         
                           ∂ 
                           
                             n 
                              
                             
                               ( 
                               
                                 V 
                                 grad 
                                 left 
                               
                               ) 
                             
                           
                         
                         
                           ∂ 
                           V 
                         
                       
                     
                     
                       
                         
                           ∂ 
                           
                             n 
                              
                             
                               ( 
                               
                                 V 
                                 grad 
                                 right 
                               
                               ) 
                             
                           
                         
                         
                           ∂ 
                           V 
                         
                       
                       - 
                       
                         
                           ∂ 
                           
                             n 
                              
                             
                               ( 
                               
                                 V 
                                 grad 
                                 left 
                               
                               ) 
                             
                           
                         
                         
                           ∂ 
                           V 
                         
                       
                     
                   
                   = 
                   
                     
                       V 
                       - 
                       
                         V 
                         grad 
                         left 
                       
                     
                     
                       
                         V 
                         grad 
                         right 
                       
                       - 
                       
                         V 
                         grad 
                         left 
                       
                     
                   
                 
               
               
                 
                   ( 
                   7 
                   ) 
                 
               
             
           
         
       
     
         [0061]    In order to simplify the notation, 
         [0000]    
       
         
           
              
             = 
             
               
                 ∂ 
                 
                   n 
                    
                   
                     ( 
                     V 
                     ) 
                   
                 
               
               
                 ∂ 
                 V 
               
             
           
         
       
     
         [0000]    is posited and the following is obtained: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                        
                       - 
                       
                          
                         left 
                       
                     
                     
                       
                          
                         right 
                       
                       - 
                       
                          
                         left 
                       
                     
                   
                   = 
                   
                     
                       V 
                       - 
                       
                         V 
                         grad 
                         left 
                       
                     
                     
                       
                         V 
                         grad 
                         right 
                       
                       - 
                       
                         V 
                         grad 
                         left 
                       
                     
                   
                 
               
               
                 
                   ( 
                   
                     7 
                     ′ 
                   
                   ) 
                 
               
             
           
         
       
     
         [0062]    It follows that the voltage V* corresponding to this zero gradient (and therefore to the estimated maximum sharpness) is given by: 
         [0000]    
       
         
           
             
               
                 
                   
                     V 
                     * 
                   
                   = 
                   
                     
                       V 
                       grad 
                       left 
                     
                     - 
                     
                       
                         
                            
                           left 
                         
                         
                           
                              
                             right 
                           
                           - 
                           
                              
                             left 
                           
                         
                       
                        
                       
                         ( 
                         
                           
                             V 
                             grad 
                             right 
                           
                           - 
                           
                             V 
                             grad 
                             left 
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   8 
                   ) 
                 
               
             
           
         
       
     
         [0063]    By eliminating intermediate variables, the following is obtained: 
         [0000]    
       
         
           
             
               
                 
                   
                     V 
                     * 
                   
                   = 
                   
                     
                       1 
                       2 
                     
                      
                     
                       ⌈ 
                       
                         
                           V 
                           max 
                         
                         + 
                         
                           V 
                           left 
                         
                         - 
                         
                           
                             
                               
                                 
                                   ( 
                                   
                                     
                                       n 
                                       max 
                                     
                                     - 
                                     
                                       n 
                                       left 
                                     
                                   
                                   ) 
                                 
                               
                             
                             
                               
                                 
                                   
                                     ( 
                                     
                                       
                                         V 
                                         right 
                                       
                                       - 
                                       
                                         V 
                                         left 
                                       
                                     
                                     ) 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         V 
                                         right 
                                       
                                       - 
                                       
                                         V 
                                         max 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     
                                       n 
                                       left 
                                     
                                      
                                     
                                       ( 
                                       
                                         
                                           V 
                                           right 
                                         
                                         - 
                                         
                                           V 
                                           max 
                                         
                                       
                                       ) 
                                     
                                   
                                   + 
                                 
                               
                             
                             
                               
                                 
                                   
                                     
                                       n 
                                       max 
                                     
                                      
                                     
                                       ( 
                                       
                                         
                                           V 
                                           left 
                                         
                                         - 
                                         
                                           V 
                                           right 
                                         
                                       
                                       ) 
                                     
                                   
                                   + 
                                 
                               
                             
                             
                               
                                 
                                   
                                     n 
                                     right 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         V 
                                         max 
                                       
                                       - 
                                       
                                         V 
                                         left 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                       ⌉ 
                     
                   
                 
               
               
                 
                   ( 
                   9 
                   ) 
                 
               
             
           
         
       
     
         [0064]    This is illustrated by the graphs in the top part of  FIG. 5 a   , in which the value V* given by the equations (8) and (9) is denoted by V 0 *. 
         [0065]    Returning to  FIG. 3 , it will be recalled that the closed-loop control block K FB  comprises an integrator (symbol “f”) and a variable gain k 1 , adjusted at each instant “i” of sampling. The control law implemented by the block K FB  may therefore be written: 
         [0000]    
       
         
           
             
               
                 K 
                 FB 
               
                
               
                 : 
               
                
               
                   
               
                
               
                 V 
                 FB 
               
             
             = 
             
               
                 k 
                 i 
                 int 
               
                
               
                 
                   ∑ 
                   
                     l 
                     = 
                     0 
                   
                   i 
                 
                  
                 
                     
                 
                  
                 
                   
                     sign 
                      
                     
                       ( 
                       
                          
                         l 
                       
                       ) 
                     
                   
                    
                   Δ 
                    
                   
                       
                   
                    
                   t 
                 
               
             
           
         
       
     
         [0066]    where k i   int  is the value of the adjusted gain at the instant i, G l  is the gradient calculated from two neighbouring voltages at the input of the optical module and corresponding sharpness values n and Δt is the temporal step size sampling. As operation is in discrete time, the integration is in fact a sum weighted by Δt. 
         [0067]    As the quadratic assumption is not always realistic, it is proposed, in accordance with one advantageous embodiment of the invention, to use a gain k i   int  that is modified at each instant of sampling (i.e. each time the sharpness indicator is calculated in closed-loop operation) while taking into account all of the measurements carried out over the course of the closed-loop phase, in which the sharpness gradient may be considered to be linear. This approach is radically different from the adaptive control methods known from the prior art, as the gain k i   int  is chosen in such a way as to cancel out the gradient calculated from direct measurements, under the assumption of a quadratic sharpness variation. 
         [0068]    Thus, the adaptive gain k i   int  for closed-loop operation is calculated using the approach of searching for the zero gradient using the approach presented in  FIG. 5 a   . It will be noted that in this figure, the measured sharpness values are represented by stars, whereas the calculated values of the gradients and the estimated sharpness values corresponding to these gradients are represented by circles, and that a triangle represents the estimation of the voltage value corresponding to the maximum sharpness. 
         [0069]    The starting condition of the closed-loop phase is given by the voltage V max  tested in the open-loop phase, that maximizes the sharpness. Next, applying equation 9 allows the voltage value V 0 *=V*, which corresponds to a zero sharpness gradient, and therefore to the theoretical maximum sharpness under the quadratic assumption, to be found. 
         [0070]    Thus, the optimum integrator gain, which cancels out the theoretical gradient for the first step of advance in the closed-loop phase, is defined by: 
         [0000]        k   0   int   =|V   0   *−V   FF   end |  (10)
 
         [0000]    where V 0 * is given by 
         [0000]    
       
         
           
             
               V 
               0 
               * 
             
             = 
             
               
                 1 
                 2 
               
                
               
                 [ 
                 
                   
                     V 
                     max 
                   
                   + 
                   
                     V 
                     left 
                   
                   - 
                   
                     
                       
                         
                           
                             ( 
                             
                               
                                 n 
                                 max 
                               
                               - 
                               
                                 n 
                                 left 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               ( 
                               
                                 
                                   V 
                                   right 
                                 
                                 - 
                                 
                                   V 
                                   left 
                                 
                               
                               ) 
                             
                              
                             
                               ( 
                               
                                 
                                   V 
                                   right 
                                 
                                 - 
                                 
                                   V 
                                   max 
                                 
                               
                               ) 
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               
                                 n 
                                 left 
                               
                                
                               
                                 ( 
                                 
                                   
                                     V 
                                     right 
                                   
                                   - 
                                   
                                     V 
                                     max 
                                   
                                 
                                 ) 
                               
                             
                             + 
                           
                         
                       
                       
                         
                           
                             
                               
                                 n 
                                 max 
                               
                                
                               
                                 ( 
                                 
                                   
                                     V 
                                     left 
                                   
                                   - 
                                   
                                     V 
                                     right 
                                   
                                 
                                 ) 
                               
                             
                             + 
                           
                         
                       
                       
                         
                           
                             
                               n 
                               right 
                             
                              
                             
                               ( 
                               
                                 
                                   V 
                                   max 
                                 
                                 - 
                                 
                                   V 
                                   left 
                                 
                               
                               ) 
                             
                           
                         
                       
                     
                   
                 
                 ] 
               
             
           
         
       
     
         [0000]    (cf. equation 9), whereas V FF   end  is the control voltage at the end of the open-loop phase. If the quadratic assumption were rigorously verified, and if the sharpness measurements were not affected by noise, then the method according to the invention could stop here; however, this is generally not the case. 
         [0071]    By applying the voltage V 0 * to the actuator, it is possible to acquire a new sharpness value. Four sharpness measurements are thus available, allowing three gradient values and the corresponding voltages given by the corollary of Lagrange&#39;s theorem (equation 5′) to be calculated; these gradient values are those determined previously (G left , G right ), plus a new value denoted by G 2 . In theory, these three gradient points should be located on the straight line given by equation 7, but that is not the case in practice (as the quadratic assumption is only an approximation and the measurements are affected by noise). As shown by the graphs in the bottom-right part of  FIG. 5 a   , three unaligned gradient points make it possible to identify three straight lines the mean of which (shown by the dotted line) is chosen as the “straight line of the gradients” for the 2 e  iteration of the closed-loop phase. V 1 * denotes the voltage value at which this mean straight line intercepts the axis of the abscissae: this constitutes a new approximation of the zero-sharpness gradient point (and hence maximum sharpness). The new value of the gain of the controller is given by: 
         [0000]        k   1   int   =|V   1   *−V   0 *|  (10′)
 
         [0072]    By applying the voltage V 1 * to the actuator, it is possible to acquire a new sharpness value. Five sharpness measurements are thus available, allowing four gradient values and the corresponding voltages given by the corollary of Lagrange&#39;s theorem (equation 5′) to be calculated. As in the preceding iteration, these four points (V, ∇n) are not aligned, and allow six different gradient straight lines to be identified, the mean of which is taken in order to determine a new approximation of the zero-sharpness gradient point (and hence maximum sharpness), denoted by V 3 * and so on. The bottom-right part of  FIG. 5 a    illustrates the situation after the third iteration. 
         [0073]    Generally speaking, the gain on the i th  iteration (where i≧1) is given by: 
         [0000]        k   i   int   =|V   i   *−V   i-1 *|  (11)
 
         [0000]    where V i * is the voltage value V that cancels out the mean gradient Ĝ. 
         [0074]    It is possible to give a general analytic expression for the straight line of the mean gradient Ĝ for each iteration of the closed-loop phase, and hence also for V i * for all cases where i≧0. To do this, it is first necessary to define the vector V l =(V 0  V 1 , . . . , V i ), the elements V l  of which are the values of the control voltage calculated during the preceding iterations of the closed-loop phase, and the “starting” voltages V max , V left  and V right  obtained during the open-loop phase; it will be understood that the size of the vector V l  increases throughout the closed-loop phase. Thus, during the first iteration (i=1): (V 0 =V left ; V 1 =V max ; V 2 =V 0 * ; V 3 =V right ); these data make it possible to calculate V 1 *, which will be integrated into the vector V l  (its elements being reorganised in order to retain the ascending order), and so on. 
         [0075]    Thus 
         [0000]    
       
         
           
             
               
                 
                   
                      
                     ^ 
                   
                   = 
                   
                     
                       1 
                       
                         i 
                         + 
                         1 
                       
                     
                      
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           0 
                         
                         i 
                       
                        
                       
                         ( 
                         
                           
                              
                             l 
                           
                           - 
                           
                             
                               V 
                               l 
                             
                              
                             
                               
                                 
                                    
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                                 - 
                                 
                                    
                                   l 
                                 
                               
                               
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                                 - 
                                 
                                   V 
                                   l 
                                 
                               
                             
                           
                           + 
                           
                             V 
                              
                             
                               
                                 
                                    
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                                 - 
                                 
                                    
                                   l 
                                 
                               
                               
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                                 - 
                                 
                                   V 
                                   l 
                                 
                               
                             
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   12 
                   ) 
                 
               
             
           
         
       
     
         [0000]    where 
         [0000]    
       
         
           
             
                
               l 
             
             = 
             
               
                 
                   n 
                   
                     l 
                     + 
                     1 
                   
                 
                 - 
                 
                   n 
                   l 
                 
               
               
                 
                   V 
                   
                     l 
                     + 
                     1 
                   
                 
                 - 
                 
                   V 
                   l 
                 
               
             
           
         
       
     
         [0000]    in which n l =n(V l ). 
         [0076]    Thus, the averaged slopes are those of the straight lines that link measurements of sharpness corresponding to adjacent voltage values. This may be seen in the bottom part of  FIG. 5   a.    
         [0077]    The sum that appears in equation 12 carries out a low-pass filtering which reduces the influence of the noise affecting the sharpness measurements. 
         [0078]    If the expression for the gradient mean straight line is written as: 
         [0000]        Ĝ=â   i   V+{circumflex over (b)}   i ; 
         [0000]    then the mean slope â i  is given by: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       a 
                       ^ 
                     
                     i 
                   
                   = 
                   
                     
                       
                         2 
                         
                           i 
                           + 
                           1 
                         
                       
                        
                       
                         
                           ∑ 
                           
                             l 
                             = 
                             0 
                           
                           i 
                         
                          
                         
                           
                             
                                
                               
                                 l 
                                 + 
                                 1 
                               
                             
                             - 
                             
                                
                               l 
                             
                           
                           
                             
                               V 
                               
                                 l 
                                 + 
                                 1 
                               
                             
                             - 
                             
                               V 
                               l 
                             
                           
                         
                       
                     
                     = 
                     
                       
                         2 
                         
                           i 
                           + 
                           1 
                         
                       
                        
                       
                         
                           ∑ 
                           
                             l 
                             = 
                             0 
                           
                           i 
                         
                          
                         
                           
                             
                               
                                 
                                   
                                     ( 
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         V 
                                         l 
                                       
                                     
                                     ) 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         n 
                                         
                                           l 
                                           + 
                                           2 
                                         
                                       
                                       - 
                                       
                                         n 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                             
                               
                                 
                                   
                                     ( 
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           2 
                                         
                                       
                                       - 
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                     
                                     ) 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         n 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         n 
                                         l 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               
                                 
                                   
                                     ( 
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           2 
                                         
                                       
                                       - 
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                     
                                     ) 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         V 
                                         l 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                             
                               
                                 
                                   ( 
                                   
                                     
                                       V 
                                       
                                         l 
                                         + 
                                         2 
                                       
                                     
                                     - 
                                     
                                       V 
                                       l 
                                     
                                   
                                   ) 
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   13 
                   ) 
                 
               
             
           
         
       
     
         [0000]    and the y-intercept {circumflex over (b)} i  by: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                         
                           
                             b 
                             ^ 
                           
                           i 
                         
                         = 
                           
                          
                         
                           
                             1 
                             
                               i 
                               + 
                               1 
                             
                           
                            
                           
                             
                               ∑ 
                               
                                 l 
                                 = 
                                 0 
                               
                               i 
                             
                              
                             
                               ( 
                               
                                 
                                    
                                   l 
                                 
                                 - 
                                 
                                   
                                     V 
                                     l 
                                   
                                    
                                   
                                     
                                       
                                          
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                          
                                         l 
                                       
                                     
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         V 
                                         l 
                                       
                                     
                                   
                                 
                               
                               ) 
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                           
                          
                         
                           
                             1 
                             
                               i 
                               + 
                               1 
                             
                           
                            
                           
                             
                               ∑ 
                               
                                 l 
                                 = 
                                 0 
                               
                               i 
                             
                              
                             
                               ( 
                               
                                 
                                   
                                     
                                       n 
                                       
                                         l 
                                         + 
                                         1 
                                       
                                     
                                     - 
                                     
                                       n 
                                       l 
                                     
                                   
                                   
                                     
                                       V 
                                       
                                         l 
                                         + 
                                         1 
                                       
                                     
                                     - 
                                     
                                       V 
                                       l 
                                     
                                   
                                 
                                 - 
                                 
                                   ( 
                                   
                                     
                                       V 
                                       l 
                                     
                                     + 
                                     
                                       V 
                                       
                                         l 
                                         + 
                                         1 
                                       
                                     
                                   
                                   ) 
                                 
                               
                             
                           
                         
                       
                     
                   
                   
                     
                       
                           
                          
                         
                           
                             
                               
                                 
                                   
                                     
                                       ( 
                                       
                                         
                                           V 
                                           
                                             l 
                                             + 
                                             1 
                                           
                                         
                                         - 
                                         
                                           V 
                                           l 
                                         
                                       
                                       ) 
                                     
                                      
                                     
                                       ( 
                                       
                                         
                                           n 
                                           
                                             l 
                                             + 
                                             2 
                                           
                                         
                                         - 
                                         
                                           n 
                                           
                                             l 
                                             + 
                                             1 
                                           
                                         
                                       
                                       ) 
                                     
                                   
                                   - 
                                 
                               
                             
                             
                               
                                 
                                   
                                     ( 
                                     
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           2 
                                         
                                       
                                       - 
                                       
                                         V 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                     
                                     ) 
                                   
                                    
                                   
                                     ( 
                                     
                                       
                                         n 
                                         
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         n 
                                         l 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                           
                             
                               ( 
                               
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     2 
                                   
                                 
                                 - 
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                               
                               ) 
                             
                              
                             
                               ( 
                               
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     1 
                                   
                                 
                                 - 
                                 
                                   V 
                                   l 
                                 
                               
                               ) 
                             
                              
                             
                               ( 
                               
                                 
                                   V 
                                   
                                     l 
                                     + 
                                     2 
                                   
                                 
                                 - 
                                 
                                   V 
                                   l 
                                 
                               
                               ) 
                             
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   14 
                   ) 
                 
               
             
             
               
                 and 
               
               
                 
                     
                 
               
             
             
               
                 
                   
                     V 
                     i 
                     * 
                   
                   = 
                   
                     - 
                     
                       
                         
                           b 
                           ^ 
                         
                         i 
                       
                       
                         
                           a 
                           ^ 
                         
                         i 
                       
                     
                   
                 
               
               
                 
                   ( 
                   15 
                   ) 
                 
               
             
           
         
       
     
         [0079]    Equation 15, and equations 13 and 14, makes it possible to calculate the values of V i * for all cases where i≧0; specifically, equation 9 is obtained as a special case of equation 15 for i=0. 
         [0080]    It is worth noting that in general the mean gradient straight line (equations 12 to 14) does not coincide exactly with the linear approximation of the gradient in the sense of the least squares method. Nevertheless, it has empirically been found that the greater the number of measurements, the closer the mean straight line gets to that calculated by the least squares method, thereby justifying the proposed method. 
         [0081]    In order to reduce the influence of the small number of measurements on the proximity of the mean straight line to the linear estimation of the conventional least squares type, one alternative embodiment proposes the use of the median straight line, the slope of which may be estimated using the following equation: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       a 
                       ^ 
                     
                     i 
                   
                   = 
                   
                     
                       1 
                       M 
                     
                      
                     
                       
                         ∑ 
                         
                           
                             ( 
                             
                               i 
                               , 
                               j 
                             
                             ) 
                           
                           ∈ 
                           Ω 
                         
                       
                        
                       
                         
                           
                              
                             i 
                           
                           - 
                           
                              
                             j 
                           
                         
                         
                           
                             V 
                             i 
                           
                           - 
                           
                             V 
                             j 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   16 
                   ) 
                 
               
             
           
         
       
     
         [0082]    and the median bias by 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       b 
                       ^ 
                     
                     i 
                   
                   = 
                   
                     
                       1 
                       
                         N 
                         - 
                         1 
                       
                     
                      
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           1 
                         
                         
                           N 
                           - 
                           1 
                         
                       
                        
                       
                           
                       
                        
                       
                         
                           ( 
                           
                             
                                
                               l 
                             
                             - 
                             
                               
                                 a 
                                 ^ 
                               
                                
                               
                                 V 
                                 l 
                               
                             
                           
                           ) 
                         
                         . 
                       
                     
                   
                 
               
               
                 
                   ( 
                   
                     16 
                     ′ 
                   
                   ) 
                 
               
             
           
         
       
     
         [0083]    M being the number of lines connecting N points in an “each to every other” manner defined by M=i(i−1)/2 and Ω is the set of all of the non-repeated pairs of indices i and j. 
         [0084]    The control may be considered as having reached the point of optimum functioning (i.e. the optimum focus where reached) in the case the increment of the voltage V* is negligible from one instant of sampling to another, or else this increment is smaller than the discretization used for the supply voltages of the lens actuator. 
         [0085]    It is now necessary to consider two cases in which the implementation of the invention may prove to be problematic. 
         [0086]    The first—seemingly favourable—is that in which the voltage corresponding to the maximum sharpness measured during the open-loop phase, V max , is close to (or even identical to, taking account of the fact that the voltages are discretized) that calculated during the first application of the quadratic model, V 0 *. Since the behaviour of the sharpness curve in real cases is highly sensitive to noise, the calculated gradient may be heavily disrupted and the position of the zero gradient sought may be heavily skewed. One possible solution in order to overcome this problem is to apply a control V 0 +ΔV for the initialization of the closed loop, where ΔV would be a minimum applicable voltage to the left or right of the voltage V 0 *=V max . Stated otherwise, if the calculated voltage V 0 * proves to be too close to V max , then it is changed slightly. The sign of ΔV is defined as: 
         [0000]      sign(Δ V )=sign( V   max   −V   0 *).
 
         [0087]    In the event that the quadratic assumption for the sharpness is confirmed, i.e. if the sharpness measured for a control voltage V 0 *+ΔV is sufficiently close to that measured in relation to V 0 *, the closed-loop control phase is stopped. Otherwise, the previously described iterative process is applied in order to find the voltage that corresponds to a sharpness gradient of (approximately) zero. 
         [0088]    The second case is that in which the quadratic assumption is not verified, even in an approximative manner. This may be the case not only because of a particular configuration of the scene or of the optical module, but also when objects present in the area of interest are moving. In this case, the variation of the sharpness as a function of the voltage applied to the actuator, modelled by a parabola (quadratic curve), does not make it possible to converge towards the maximum sharpness in an efficient manner, as the choice of the gain in the closed-loop phase is made so that the peak of mean sharpness is moved towards, which implies a weak bias (movement) of the parabola for each measurement. This implies that the focal power that will ultimately be chosen for the focus will not be that which maximizes the sharpness. 
         [0089]    In order to avoid this situation, it is suggested that the closed-loop gain be chosen as a moving average, i.e. to take into consideration only the L last measurements that were carried out during the closed-loop phase. This approach makes it possible to achieve a low-pass filtering effect on the modification of the voltage V i * from one instant to another. The measurements that were carried out outside the preceding L instants are not taken into account for the calculation of the gain k i   int . The calculation of the gain is therefore performed in the following manner (for the embodiment using one mean straight line for the gradients, cf.  FIG. 5 a    and equations 13 to 15): 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                         
                             
                         
                          
                         
                           
                             
                               a 
                               ^ 
                             
                             i 
                           
                           = 
                             
                            
                           
                             
                               
                                 2 
                                 
                                   L 
                                   + 
                                   1 
                                 
                               
                                
                               
                                 
                                   ∑ 
                                   
                                     l 
                                     = 
                                     0 
                                   
                                   L 
                                 
                                  
                                 
                                     
                                 
                                  
                                 
                                   
                                     
                                        
                                       
                                         i 
                                         - 
                                         l 
                                         + 
                                         1 
                                       
                                     
                                     - 
                                     
                                        
                                       
                                         i 
                                         - 
                                         l 
                                       
                                     
                                   
                                   
                                     
                                       V 
                                       
                                         i 
                                         - 
                                         l 
                                         + 
                                         1 
                                       
                                     
                                     - 
                                     
                                       V 
                                       
                                         i 
                                         - 
                                         l 
                                       
                                     
                                   
                                 
                               
                             
                             = 
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                           
                          
                         
                           
                             2 
                             
                               L 
                               + 
                               1 
                             
                           
                            
                           
                             
                               ∑ 
                               
                                 l 
                                 = 
                                 0 
                               
                               L 
                             
                              
                             
                               
                                 
                                   
                                     
                                       ( 
                                       
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                         - 
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                           
                                         
                                       
                                       ) 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         ( 
                                         
                                           
                                             n 
                                             
                                               i 
                                               - 
                                               l 
                                               + 
                                               2 
                                             
                                           
                                           - 
                                           
                                             n 
                                             
                                               i 
                                               - 
                                               l 
                                               + 
                                               1 
                                             
                                           
                                         
                                         ) 
                                       
                                       - 
                                     
                                   
                                 
                                 
                                   
                                     
                                       ( 
                                       
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             2 
                                           
                                         
                                         - 
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                       
                                       ) 
                                     
                                   
                                 
                                 
                                   
                                     
                                       ( 
                                       
                                         
                                           n 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                         - 
                                         
                                           n 
                                           
                                             i 
                                             - 
                                             l 
                                           
                                         
                                       
                                       ) 
                                     
                                   
                                 
                               
                               
                                 
                                   
                                     
                                       ( 
                                       
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             2 
                                           
                                         
                                         - 
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                       
                                       ) 
                                     
                                   
                                 
                                 
                                   
                                     
                                       
                                         ( 
                                         
                                           
                                             V 
                                             
                                               i 
                                               - 
                                               l 
                                               + 
                                               1 
                                             
                                           
                                           - 
                                           
                                             V 
                                             
                                               i 
                                               - 
                                               l 
                                             
                                           
                                         
                                         ) 
                                       
                                        
                                       
                                         ( 
                                         
                                           
                                             V 
                                             
                                               i 
                                               - 
                                               l 
                                               + 
                                               2 
                                             
                                           
                                           - 
                                           
                                             V 
                                             
                                               i 
                                               - 
                                               l 
                                             
                                           
                                         
                                         ) 
                                       
                                     
                                   
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   17 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       
                         
                           
                             b 
                             ^ 
                           
                           i 
                         
                         = 
                           
                          
                         
                           
                             
                               1 
                               
                                 L 
                                 + 
                                 1 
                               
                             
                              
                             
                               
                                 ∑ 
                                 
                                   l 
                                   = 
                                   0 
                                 
                                 L 
                               
                                
                               
                                 ( 
                                 
                                   
                                      
                                     
                                       i 
                                       - 
                                       l 
                                     
                                   
                                   - 
                                   
                                     
                                       V 
                                       
                                         i 
                                         - 
                                         l 
                                       
                                     
                                      
                                     
                                       
                                         
                                            
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                         - 
                                         
                                            
                                           
                                             i 
                                             - 
                                             l 
                                           
                                         
                                       
                                       
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                             + 
                                             1 
                                           
                                         
                                         - 
                                         
                                           V 
                                           
                                             i 
                                             - 
                                             l 
                                           
                                         
                                       
                                     
                                   
                                 
                                 ) 
                               
                             
                           
                           = 
                         
                       
                     
                   
                   
                     
                       
                         = 
                           
                          
                         
                           
                             1 
                             
                               L 
                               + 
                               1 
                             
                           
                            
                           
                             
                               ∑ 
                               
                                 l 
                                 = 
                                 0 
                               
                               L 
                             
                              
                             
                               ( 
                               
                                 
                                   
                                     
                                       
                                         n 
                                         
                                           i 
                                           - 
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         n 
                                         
                                           i 
                                           - 
                                           l 
                                         
                                       
                                     
                                     
                                       
                                         V 
                                         
                                           i 
                                           - 
                                           l 
                                           + 
                                           1 
                                         
                                       
                                       - 
                                       
                                         V 
                                         
                                           i 
                                           - 
                                           l 
                                         
                                       
                                     
                                   
                                   -- 
                                 
                                  
                                 
                                   ( 
                                   
                                     
                                       V 
                                       
                                         i 
                                         - 
                                         l 
                                       
                                     
                                     + 
                                     
                                       V 
                                       
                                         i 
                                         - 
                                         l 
                                         + 
                                         1 
                                       
                                     
                                   
                                   ) 
                                 
                                  
                                 
                                   
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 1 
                                               
                                             
                                             - 
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                     
                                       
                                         
                                           
                                             ( 
                                             
                                               
                                                 n 
                                                 
                                                   i 
                                                   - 
                                                   l 
                                                   + 
                                                   2 
                                                 
                                               
                                               - 
                                               
                                                 n 
                                                 
                                                   i 
                                                   - 
                                                   l 
                                                   + 
                                                   1 
                                                 
                                               
                                             
                                             ) 
                                           
                                           - 
                                         
                                       
                                     
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 2 
                                               
                                             
                                             - 
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 1 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               n 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 1 
                                               
                                             
                                             - 
                                             
                                               n 
                                               
                                                 i 
                                                 - 
                                                 l 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                   
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 2 
                                               
                                             
                                             - 
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 1 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 1 
                                               
                                             
                                             - 
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                     
                                       
                                         
                                           ( 
                                           
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                                 + 
                                                 2 
                                               
                                             
                                             - 
                                             
                                               V 
                                               
                                                 i 
                                                 - 
                                                 l 
                                               
                                             
                                           
                                           ) 
                                         
                                       
                                     
                                   
                                 
                               
                               ) 
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   18 
                   ) 
                 
               
             
             
               
                 
                   
                       
                   
                    
                   
                     
                       V 
                       i 
                       * 
                     
                     = 
                     
                       - 
                       
                         
                           
                             b 
                             ^ 
                           
                           i 
                         
                         
                           
                             a 
                             ^ 
                           
                           i 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   19 
                   ) 
                 
               
             
           
         
       
     
         [0000]    where 1&lt;L&lt;i defines the size of the moving window in terms of number of samples. The choice of L makes it possible to impose a bandwidth of greater or lesser size (and hence to modulate the effect of the low-pass filtering) depending on the optical module used (noise level of the image sensor, optical characteristics of the lenses). The use of this improvement in the choice of the closed-loop gain allows the method to be made more robust with respect to the behaviour of the sharpness when the quadratic assumption is not satisfied. 
         [0090]    It may be noted that equations 13 to 15 may be considered to be a special case of equations 17 to 19, corresponding to the case L=i. 
         [0091]    The use of a moving window is also possible for the embodiment using a median straight line for the gradients, cf.  FIG. 5 b    and equations 16, 16′. In this case: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       a 
                       ^ 
                     
                     i 
                   
                   = 
                   
                     
                       1 
                       M 
                     
                      
                     
                       
                         ∑ 
                         
                           
                             ( 
                             
                               i 
                               , 
                               j 
                             
                             ) 
                           
                           ∈ 
                           Ω 
                         
                       
                        
                       
                         
                           
                              
                             i 
                           
                           - 
                           
                              
                             j 
                           
                         
                         
                           
                             V 
                             i 
                           
                           - 
                           
                             V 
                             j 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   20 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       b 
                       ^ 
                     
                     i 
                   
                   = 
                   
                     
                       1 
                       
                         L 
                         - 
                         1 
                       
                     
                      
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           1 
                         
                         
                           L 
                           - 
                           1 
                         
                       
                        
                       
                           
                       
                        
                       
                         ( 
                         
                           
                              
                             l 
                           
                           - 
                           
                             
                               a 
                               ^ 
                             
                              
                             
                               V 
                               l 
                             
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   
                     20 
                     ′ 
                   
                   ) 
                 
               
             
           
         
       
     
         [0092]    Ω henceforth being defined as the set of all the non-repeated pairs of indices, while considering only the L last indices (indices between “i−L” and “i” for i&gt;L, and all of the indices for i≦L). 
         [0093]    The technical result of the invention will now be illustrated with the aid of  FIGS. 6 a    to  8   b.    
         [0094]      FIG. 6 a    shows the sharpness curve (relative sharpness, normalized to 1, as a function of the analogue control voltage of the actuator) of a camera, measured by moving the lens at a very fine rate of advance. The black dots correspond to the acquisitions carried out during the open-loop control phase and the grey dots to the various iterations of the closed-loop phase. Due to noise, these dots are not located exactly on the curve.  FIG. 6 b    shows the gradient of the sharpness, obtained by taking the derivative of the sharpness curve (continuous curve) and calculated during the closed-loop phase on the basis of the quadratic assumption (broken line). It will be noted that even though the approximation of the gradient is relatively rough, the estimation of the voltage that cancels out ∇n is remarkably good. 
         [0095]      FIG. 7 a    shows how the sharpness of an image varies over time (the edge of a door at a distance of 3.5 m from the lens of the camera) during the focusing method of the invention (black lines) and a method known from the prior art (grey lines) known as binary search, in which the rate of advance is divided by two each time the sharpness peak is exceeded: see N. Kehtarnavaz and H.-J. Oh “ Development and real - time implementation of a rule - based auto - focus algorithm ” Real-Time Imaging, 9(3): 197-203, 2003.  FIG. 7 b    shows the variation of the analogue control voltage of the actuator for these two cases in point. It may be seen that, in the case of the method according to the invention, the 5 first clock ticks correspond to the open-loop phase, over the course of which the lens moves in one direction. At the time t=6, the lens is positioned at the “provisional” maximum identified during the open-loop phase; 6 closed-loop iterations follow. Focusing was repeated multiple times with the two methods; a lesser degree of variability may be noted in the case of the invention, which translates into a decreased sensitivity to noise. 
         [0096]      FIGS. 8 a  and 8 b    correspond to the case where the imaged object is a test card located 5 m away from the lens. In this case it may be noted that the method of the invention leads to a much quicker convergence than that known from the prior art (binary search, as in the case of  FIGS. 7 a , 7 b   ). 
         [0097]    In order to produce  FIGS. 7 a  to 8 b   , a sharpness measurement based on the Haar transform and on the concept of local contrast was used. See, for example, the paper by M. Trivedi, A. Jaiswal and V. Bhateja “ A no - reference image quality index for contrast and sharpness measurement ”, 3rd International Advance Computing Conference (IACC), 2013 IEEE, pages 1234-1239, February 2013.