Abstract:
A focus detecting apparatus in which light distributions having their relative positional relation varying in conformity with the focus adjusted state of an objective optical system and based on an object are received by a light-receiving device having a plurality of picture elements and the output signal of the light-receiving device is operated in two different processes, and an evaluated values dependent on the contrast is operated in each of the processes and the evaluated values are compared with each other, and the result calculated in the process of better contrast is adopted as a value indicative of the focus adjusted state of the objective optical system.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     This invention relates to improvements in a focus detecting apparatus for detecting the focus state from the relative positional relationship between the two images of an object. 
     2. Related Background Art 
     As one type of the focus detecting apparatus of a camera, there is known the so-called &#34;image deviation type&#34; in which the exit pupil of the photo-taking lens is divided and the relative positional displacement of a pair of images formed by light beams passed through the pupil areas is observed to thereby discriminate the in-focus state. 
     The focus detecting method in the apparatus of this type will hereinafter be described with reference to FIG. 15 of the accompanying drawings A field lens FLD is disposed coaxially with a photo-taking lens FLNS whose focus is to be detected Disposed behind the field lens and at positions symmetric with respect to the optic axis are two secondary imaging lenses FCLA and FCLB. Further rearwardly of the secondary imaging lenses, there are disposed sensor rows SAA and SAB to sense visible or invisible images. Diaphragms DIA and DIB are provided near the secondary imaging lenses FCLA and FCLB. The field lens FLD substantially images the exit pupil of the photo-taking lens FLNS on the pupil surfaces of the two secondary imaging lenses FCLA and FCLB. As a result, light beams entering the secondary imaging lenses FCLA and FCLB are those emitted from regions of an equal area on the exit pupil surface of the photo-taking lens FLNS which correspond to the secondary imaging lenses FCLA and FCLB and do not overlap each other. When aerial images formed near the field lens FLD are re-imaged on the surface of the sensor rows SAA and SAB by the secondary imaging lenses FCLA and FCLB, the two images on the sensor rows SAA and SAB change their positions on the basis of the displacement of the positions of the aerial images in the direction of the optic axis. Accordingly, if the displacement (deviation) of the relative position of the two images is detected, the focus state of the photo-taking lens FLNS can be known. The signal processing method for detecting the amount of image deviation from the image signals output from the sensor rows SAA and SAB is disclosed by the applicant in Japanese Laid-Open Patent Application No. 142306/1983 (corresponding to U.S. Pat. No. 4,559,446), Japanese Laid-Open Patent Application No. 107313/1984 and Japanese Laid-Open Patent Application No. 101513/1985 (corresponding to U.S. Pat. No. 4,618,236). Specifically, when the number of picture elements constituting the sensor row SAA or SAB is N and the image signals from the first (i=0, . . . , N-1) sensor rows SAA, SAB are A(i) and B(i), the following equation is operated with respect to k 1  ≦k≦k 2  : ##EQU1## M is the number of operation picture elements represented by (M=N-|k|-1), k is called the amount of relative displacement, and k 1  and k 2  are often assumed as -N/2 and N/2. The operation max{a, b} represents the extraction of the greater one of a and b, and the operator min{a, b} represents the extraction of the smaller one of a and b. Accordingly, the terms X 1  (k), X 2  (k), Y 1  (k) and Y 2  (k) in equations (1) and (2) above can be regarded as the amounts of correlation in a broad sense. Further, examining equations (1) and (2) in detail, X 1  (k) and Y 1  (k) in reality represent the amounts of correlation in (k-1) displacement as defined above, and X 2  (k) and Y 2  (k) represent the amounts of correlation in (k+1) displacement. Therefore, the evaluated amount X(k) which is the difference between X 1  (k) and X 2  (k) means the amount of variation in the amount of correlation of the image signals A(i) and B(i) in the amount of relative displacement k. 
     The amounts of correlation X 1  (k) and X 2  (k) are smallest when the correlation between the two images is highest, as is apparent from the above definition. Consequently, X(k) which is the amount of variation therein should be &#34;0&#34; and the inclination thereof should be negative when the correlation is highest. However, X(k) is scattered data and therefore, actually, on the assumption that 
     
         X(kp)≧0, X(kp+1)&lt;0                                  (3) 
    
     and that the peak of the amount of correlation exists in the section [kp, kp+1] of relative displacement wherein X(kp)-X(kp+1) is greatest, by effecting an interpolating operation ##EQU2## the amount of image deviation PR below the picture element unit can be detected. 
     Conversely to X 1  (k) and X 2  (k), the amounts of correlation Y 1  (k) and Y 2  (k) become greatest from the foregoing definition when the correlation between the two images is highest. Consequently, Y(k) which is the amount of variation therein should be &#34;0&#34; and the inclination thereof should be positive when the correlation is highest. As regards Y(k) also, like X(k), when 
     
         Y(kp)≦0, Y(kp+1)&gt;0                                  (6) 
    
     and Y(kp)-Y(kp+1) is greatest, by effecting an interpolating operation of ##EQU3## the amount of image deviation PR below the picture element unit can be detected. 
     Now, any of the focus evaluated amounts X(k) and Y(k) which can be found in the manner described above can be used to detect the amount of image deviation PR. However as disclosed in U.S. Pat. No. 4,618,236, there is superiority or inferiority in terms of S/N between the two depending on the signal pattern of an object to be photographed. In the embodiment proposed in U.S. Pat. No. 4,618,236, the determination as to whether the means on the side which operates the focus evaluated amount X(k) or the means on the side which operates the focus evaluated amount Y(k) should be selected in conformity, for example, with the magnitudes of the image signals of the end portions in the operation range (the levels of the image signals from each two picture elements in the end portions) is effected (actually, when the levels of the image signals of the end portions are small, the means which operates Y(k) is selected, and when the levels of the image signals of the end portions are great, the means which operates X(k) is selected), and the amount of image deviation PR is found on the basis of the focus evaluated amount output from one of said two means. Thereby, the reduction in the focus detection accuracy for a special signal pattern caused when the apparatus is constituted by only the one operation means can be eliminated, and the apparatus can be said to be a very effective apparatus. In the aforementioned proposal, &#34;the image signals of the end portions&#34; are the image signals of the end portions when the relative displacement thereof is &#34;k=0&#34;, and the end portions to be operated vary from the fact that the range of operation becomes different depending on the amount of relative displacement k. Consequently, it could not always be said that during the other time than when the relative displacement was &#34;k=0&#34; (near the in-focus), the means superior in terms of S/N was selected, that is, the amount of image deviation was found by the focus evaluated amount superior in terms of S/N. 
     SUMMARY OF THE INVENTION 
     It is a first object of the present invention to solve the above-noted problems and to provide a focus detecting apparatus which can accomplish focus detection with good accuracy even when the deviation of the relative position of two images is great. 
     It is a second object of the present invention to change the signal processing process in conformity with the form of the brightness distribution of an object and accomplish focus detection of good accuracy. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram showing an example of the focus detecting apparatus of a camera which is suitable for carrying out the present invention. 
     FIG. 2 is a flow chart of a portion of the apparatus of FIG. 1. 
     FIG. 3 is also a flow chart of a portion of the apparatus of FIG. 1. 
     FIGS. 4 and 5 show an example of image signals output from sensor rows. 
     FIG. 6 is a flow chart of a portion of the apparatus of FIG. 1. 
     FIGS. 7(a)-7(d) show the relation of correspondence between two images during the focus detection operation. 
     FIG. 8 shows a variation in the evaluated amount. 
     FIG. 9 also shows a variation in the evaluated amount. 
     FIG. 10 shows the positional relation between the range finding frame of the viewfinder and the sensor row. 
     FIG. 11 is a flow chart of a portion of the apparatus of FIG. 1. 
     FIGS. 12(a)-12(d) show the relation of correspondence between two images during the focus detection operation. 
     FIGS. 13(a)-13(c) show a variation in the evaluated amount. 
     FIG. 14 is a flow chart of a portion of the apparatus of FIG. 1. 
     FIG. 15 shows the arrangement of the optical system of a popular secondary imaging type focus detecting apparatus. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     The invention will hereinafter be described in detail with respect to an embodiment thereof illustrated in the drawings. Although the features of the present invention are particularly well represented at steps 130-146 of the flow chart of FIG. 6, the basic construction will first be described herein. 
     FIG. 1 is a block diagram showing an example of the focus adjusting apparatus of a camera which is suitable for carrying out the present invention. PRS designates the control circuit of the camera which is a one-chip microcomputer in which are disposed CPU (central processing unit), RAM, ROM, EEPROM (electrically erasable programmable ROM), input/output ports and an analog input port with A/D converting function. Software for controlling the sequence, AF (auto-focus) and AE (auto-exposure) of the camera are stored in the ROM, and parameters necessary for the control of AF and AE are stored in the EEPROM. SHT denotes a shutter control circuit which receives data input through a data bus DBUS while a control signal CSHT is input from the control circuit PRS, and controls the movement of forward and rearward shutter curtains, not shown, on the basis of said data, APR designates an aperture control circuit which receives data input through the data bus DBUS while a control signal CAPR is input, and controls an aperture mechanism, not shown, on the basis of said data, DSP denotes a display circuit which receives data input through the data bus DBUS while a control signal CDSP is input, and displays various types of photographing information on the basis of said data, and SWS designates a group of switches disposed outside and inside the camera such as a release switch, not shown, and switches for setting various types of information such as the shutter and aperture. 
     SPC denotes a metering circuit An analog metering signal SSPC which is the output of the metering circuit SPC is supplied to the analog input port with the A/D converting function of said control circuit PRS and is A/D-converted for use as metering data for controlling the shutter control circuit SHT and the aperture control circuit APR. LCOM designates a lens communication circuit which receives data input through the data bus DBUS while a control signal CLCOM is input, and effects serial communication with a lens unit to be described, on the basis of said data. The lens communication circuit LCOM transmits data DCL for lens driving indicative of the amount of movement of a photo-taking lens FLNS in the direction of the optic axis to a control circuit in the lens to be described in synchronism with a clock signal LCK and at the same time, lens information DCL such as the coefficient of the amount of non-in-focus of the photo-taking lens FLSS versus the amount of movement of the lens is serial-input from the control circuit in the lens to the lens communication circuit. BSY denotes a signal for informing the camera side as to whether the photo-taking lens FLNS is being moved. When this signal is &#34;H&#34; (high level), said serial communication becomes impossible. 
     LNSU designates a lens unit, LPRS denotes a control circuit in the lens for driving a motor MTR on the basis of the serial-input data DLC and moving the photo-taking lens FLNS in the direction of the optic axis, and ENC designates an encoder circuit which, for example, detects a pulse signal generated with the movement of a lens barrel holding the photo-taking lens FLNS and outputs an encoder pulse signal EPL as the current position information of the photo-taking lens FLNS to the control circuit LPRS in th lens. 
     SDR denotes a sensor driving circuit for controlling a line sensor such as CCD having two sensor rows SAA and SAB in accordance with signals STR and ck input from the control circuit PRS. In FIG. 1, the line sensor SNS is divided into the two sensor rows SAA and SAB, but alternatively, a single sensor row may be electrically divided into two. 
     The operation of the FIG. 1 embodiment will now be described with reference to FIGS. 2 to 14. The operations of the shutter control circuit SHT, the aperture control circuit APR, the display circuit DSP and the metering circuit SPC have no direct relation with the present invention and therefore need not be described in detail herein. Also, the present embodiment assumes a form in which the &#34;AF&#34; flow is called as a subroutine from the sequence flow of the camera. 
     When AF operation is started, two flags RCFLG and NRSDFLG are first rendered into &#34;N&#34; (which means NO) (step 10 of FIG. 2). The functions of the flags RCFLG and NRSDFLG will be described later. Subsequently, image signal reading subroutine &#34;IMAGE&#34; is called (step 11). Here, the line sensor SNS is driven through the sensor driving circuit SDR, and image signals A(i) and (Bi) of two images are obtained. The then operations of the sensor driving circuit SDR, the line sensor SNS, etc. will be briefly described with reference to FIGS. 1 and 3. When an accumulation start signal STR of &#34;H&#34; is output from the control circuit PRS (step 50 of FIG. 3), a clear signal CL is output from the sensor driving circuit SDR to the line sensor SNS, and the charges of the photoelectric converting portions of the sensor rows SAA and SAB are cleared. Thereupon, in the line sensor SNS, photoelectric conversion and charge accumulating operations of optical images formed on the sensor rows SAA and SAB by a secondary imaging lens or the like disposed at the preceding stage (which is disposed in the state as shown in FIG. 15 although not shown in FIG. 1) are started. When a predetermined time elapses after said operations have been started, a transfer signal SH is output from the sensor driving circuit SDR to the line sensor SNS, and charges accumulated in the photoelectric converting portion are transferred to the CCD unit. At the same time, an accumulation end signal IEND of &#34;H&#34; is produced in the sensor driving circuit SDR, and this signal is input to the control circuit PRS (step 51). Thereafter, when a CCD driving clock CK is output from the control circuit PRS, CCD driving signals φ 1  and φ 2  are output from the sensor driving circuit SDR. Thereby, an analog image signal SSNS is output from the line sensor SNS to the control circuit PRS in accordance with these signals, and in response thereto, the control circuit PRS A/D-converts the analog image signal SSNS in synchronism with the CCD driving clock CK, and stores it as the image signals A(i) and B(i) of two images in a predetermined address in the RAM (steps 52-55). It is assumed that the number of picture elements of the sensor rows SAA and SAB is 40. 
     Turning back to FIG. 2, step 12 is a flag VSN in which whether focus detecting operation should be effected with all or some of the picture elements as the object range to be processed depending on the non-in-focus state is determined. That is, the range of the picture elements to be processed for which focus detecting operation is effected is set, and at this step, in the case of &#34;WD&#34; (which means a great amount of non-in-focus), a focus detecting subroutine &#34;WPRED&#34; is called, and in the case of &#34;NR&#34; (which means near the in-focus state), a focus detecting subroutine &#34;NRPRED&#34; is called (step 12). For example, when the image signal greatly deviates from the in-focus state as shown in FIG. 4, the subroutine &#34;WPRED&#34; is adopted, and when the image signal is near the in-focus state as shown in FIG. 5, the subroutine &#34;NRPRED&#34; is adopted. During the closing of the main switch, the flag VSN is set to &#34;WD&#34; (because this is the first point of time at which the non-in-focus state cannot be known), and when AF operation is started, the flag VSN is reset to &#34;WD&#34; or &#34;NR&#34; depending on the focus state at that point of time. This resetting will be described later. 
     The focus detection processing when the subroutine &#34;WPRED&#34; is called will now be described in accordance with the flow of FIG. 6. At steps 100-105, the focus evaluated amount when the amount of relative displacement k has been changed within the range of &#34;-20-20&#34; is found, for example, as X(k). It is because the number of picture elements of the sensor rows SAA and SAB is assumed as &#34;40&#34; as previously described that the amount of relative displacement k is limited to the range of -20 to 20, but this range of picture elements to be processed may be made variable in conformity with the focal length of the photo-taking lens FLNS used. 
     First, at step 101, the number of operation picture elements M is calculated by the equation that M=39-|k|. The number of operation picture elements M is variable in conformity with the amount of relative displacement k and becomes smaller as the absolute value of k becomes greater. This is because the output of the corresponding sensor lacks from the end portion as the amount of relative displacement k becomes greater. At step 102, the sign (positive or negative) of the amount of relative displacement k is examined, and then at step 103 or 104, the positions PA and PB of the leading picture elements for which the operations of images A and B are effected are calculated in conformity with the sign. At step 105, the focus evaluated value X(k) is calculated. 
     The treatment process at the steps 100-105 will now be described with reference to FIG. 7. FIG. 7(a) depicts two image signals A(i) and B(i). FIG. 7(b) depicts the relation of correspondence between the sensor rows for correlated operation when k=-20, and at this time, M=39-|20|=19, and PA is &#34;0&#34; and PB is &#34;20&#34;. That is, the amount of relative displacement k is of a negative value and therefore, the image B is relatively displaced to the left by k picture elements (-20 picture elements). What has been calculated by a relation of correspondence in which the image B has been further displaced by a picture element from said relation of correspondence to the left corresponds to the first term of the equation for finding X(-20). What has been calculated by a relation of correspondence in which the image A has been displaced by a picture element to the left corresponds to the second term of said equation. By the first and second terms, calculations are effected with the images A and B displaced by a picture element each to the left and therefore, when calculating said number of operation picture elements M, use is made of M=39-|k| instead of M=40-|k|. FIG. 7(c) depicts the relation of correspondence when k=0. FIG. 7(d) depicts the relation of correspondence between the correlated operations when k=20, and in this figure, conversely to FIG. 7(b), the image A is displaced by 20 picture elements to the left. 
     FIG. 8 shows an example of the focus evaluated amount X(k) calculated in the manner described previously as it is plotted. 
     Turning back to the flow of FIG. 6, at step 110, the peak value Kp of the amount of image deviation between the picture element units of the two images A and B is detected from the focus evaluated amount X(k). Thereafter, at steps 120-146, the amount of image deviation PR below the picture element unit is found, and at steps 120-135, two focus evaluated amounts X(k) and Y(k) are re-calculated on the basis of the peak value Kp found at the step 110. There are two reasons for this. One of them is that at the aforementioned step for finding Kp, the number of operation picture elements M is variable in conformity with the amount of relative displacement k and if the amount of image deviation PR below the picture element unit is found by interpolating the focus evaluated amount X(k) calculated within such a variable operation range, there is an undesirable possibility that said amount of image deviation PR includes an error attributable to the incoincidence of the number of operation picture elements M. The other reason is that the use of a combination of X(k) and Y(k) is more excellent in terms of S/N as described in Japanese Laid-Open Patent Application No. 101513/1985 than finding the amount of image deviation PR solely by the focus evaluated amount X(k). From what has been described above, at steps 120-135, the number of operation picture elements M is made constant on the basis of Kp (step 120), and the focus evaluated amounts X(k) and Y(k) are found at a time. 
     First, at step 120, the calculation that M=38-|Kp| is effected to determine the value of the number of operation picture elements M. Then at steps 130-135, the focus evaluated amounts X(k) and Y(k) are calculated in the same manner as previously described at three points K=Kp-1, Kp and Kp+1 with the previously found Kp as the center. It is for the purpose of fixing the number of operation picture elements M at the number of operation picture elements M for the amount of relative displacement whose absolute value is greatest among the three points K=Kp-1, Kp and Kp+1 that when finding the number of operation picture elements M, M has been M=38-|Kp|. Subsequently, the amounts of image deviation Kpx and Kpy of the picture element unit by the respective focus evaluated amounts are again detected from the focus evaluated amounts X(k) and Y(k) found in the manner described previously (steps 140 and 141). 
     At this time, XD(XD=X(kpx)-X(kpx+1)) and YD(YD=Y(kpx+1)-Y(kpx)) generally representing the contrast evaluated amounts of the focus evaluated amounts X(k) and Y(k) are also found. This is because in this embodiment, comparing the magnitude of the image signal in the end portion during each relative displacement in accordance with the operation method as disclosed in the aforementioned prior application is not effected (since the operation processing becomes complex). In this embodiment, with attention being paid to the fact that the information as if the image signal in the end portion during each relative displacement was watched is obtained by watching the contrast evaluated amounts XD and YD for which the information of the image signal in the end portion is also taken into account when the amount of non-in-focus is great, said information is used, and this means that the greater the contrast evaluated amounts XD and YD, the more excellent in terms of S/N. Therefore, at step 142, the two contrast evaluated amounts XD and YD are compared and when XD≧YD, the focus evaluated amount X(k) is adopted (step 143), and when XD&lt;YD, the focus evaluated amount Y(k) is adopted (step 144). At steps 145 and 146, by the use of adopted ZD(Z 1  -Z 2 ) and kz, the interpolating operation of 
     
         PR=kz+|Z.sub.1 /ZD| 
    
     is effected to find the amount of image deviation PR below the picture element unit. This process is shown in FIG. 9. In the example as shown in this figure, XD and YD are in the relation that XD&lt;YD and therefore, the focus evaluated amount Y(k) is adopted, and when the amount of image deviation PR below the picture element unit is to be calculated, Kz=Kpy, Z 1  =Y(kp) and Z 2  =Y(kp+1) are used. 
     Steps 150-158 are a process for determining the focus state. First, at step 150, four flags LCFLG, SDFLG, NJFFLG and JFFLG are set to &#34;N&#34;. Qualitatively describing the meanings of the respective flags, &#34;LCFLG&#34; is a flag representing that the object image signal is of low contrast, &#34;SDFLG&#34; is a flag representing that the amount of deviation between two images is relatively small, that is, the amount of non-in-focus of the photo-taking lens FLNS is relatively small, &#34;NJFFLG&#34; is a flag representing that the amount of deviation between two images is considerably small, that is, the photo-taking lens FLNS is substantially in focus, and &#34;JFFLG&#34; is a flag representing that the amount of deviation between two images is almost zero, that is, the photo-taking lens is in focus. 
     Subsequently, the contrast evaluated amount ZD of the adopted focus evaluated amount is compared with a predetermined value LCTH (step 151). When ZD&lt;LCTH as a result, the contrast is regarded as being low and &#34;LCFLG&#34; is set to &#34;Y&#34; (which means YES), and the subroutine &#34;WPRED&#34; is terminated. When ZD≧LCTH, the contrast is regarded as being sufficient to effect focus detection, and an advance is made to the next step 153. At step 153, the absolute value PR of the amount of image deviation PR is compared with a predetermined value &#34;3&#34;, and when PR&gt;3, that is, when the amount of image deviation is three picture elements or more, the subroutine &#34;WPRED&#34; is terminated. When PR≦3, the amount of non-in-focus is relatively small and therefore, &#34;SDFLG&#34; is set to &#34;Y&#34; (step 154), and then PR is compared with a predetermined value &#34;1&#34; (step 155). When PR&gt;1 as a result, that is, when the amount of image deviation is one picture element or more, the subroutine &#34;WPRED&#34; is terminated here. When PR&gt;1, the photo-taking lens is regarded as being substantially in focus and &#34;NJFFLG&#34; is set to &#34;Y&#34; (step 156), and finally PR is compared with a predetermined value JFTH (step 157). The predetermined value JFTH is a value for which the amount of image deviation PR can be regarded as in-focus. When PR&gt;JFTH as a result, the subroutine &#34;WPRED&#34; is terminated here. When PR≦JFTH, the photo-taking lens is regarded as being in focus and &#34;JFFLG&#34; is set to &#34;Y&#34; (step 158), and the subroutine &#34;WPRED&#34; is terminated. The functions of the four flags LCFLG, SDFLG, NJFFLG and JFFLG will be described later. 
     The subroutine &#34;NPRED&#34; will now be described. &#34;NPRED&#34; is a focus detecting process which is applied when the photo-taking lens is near the in-focus state, and of all sensors, the focus detecting process is effected only by the data within a range corresponding to the range finding frame in the viewfinder. This will be described with reference to FIG. 10 showing the positional relation between the viewfinder and the sensor row SA. In FIG. 10, FFRM is the range finding frame on the viewfinder. In the subroutine &#34;NPRED&#34;, the range of the range finding frame FFRM is divided into three areas so as to be shown by R 1 , R 2  and R 3 , and at what picture elements of the sensor row SA the areas R 1 , R 2  and R 3  in the range finding frame FFRM are positioned is pre-examined in the process of adjusting picture element positions NR 1 , NR 2  and NR 3  corresponding to the tops of the respective portions, and is memorized by the EEPROM in the control circuit PRS. NNPX then included in each portion is the same (R 1  =R 2  =R 3 ), and this value NNPX is likewise memorized by the EEPROM. In this embodiment, NNPX=12 and NR 1  , NR 2  and NR 3  are &#34;8&#34;, &#34;14&#34; and &#34;20&#34;, respectively, and (NNPX+K) is the range to be processed in this case (the portion indicated by hatching in FIG. 12). These values may sometimes shift by several picture elements in conformity with the situation in which the focus detecting optical system and the line sensor SNS are mounted, but since they are memorized by the EEPROM as previously described, the range finding frame FFRM and the range of the operation in which the focus detecting process is effected can be made coincident with each other. R 1 , R 2  and R 3  shown for the image signals of FIG. 5 are the divided areas in the above-described subroutine &#34;NPRED&#34; process. 
     The operation when the subroutine &#34;NPRED&#34; is called will now be described in accordance with the flow of FIG. 11. At step 200, the number of operation picture elements M is fixed at NNPX. In the aforedescribed subroutine &#34;WPRED&#34;, the number of operation picture elements M has been variable in conformity with the amount of relative displacement K, whereas in this focus detecting process, it is fixed at NNPX. This is because &#34;WPRED&#34; uses the outputs of all picture elements for the operation, whereas in &#34;NIPRED&#34;, the output of a part of the sensor row SA and therefore the data of the end of the corresponding sensor output does not lack by displacement. Therefore, in &#34;NPRED&#34;, there is not effected the re-operation which was effected at the steps 120-141 of &#34;WPRED&#34; with the number of operation picture elements M being constant. Also, since the re-operation is not effected, the evaluated amounts X(k) and Y(k) are found at a time from first. 
     Steps 210-221 are a focus detecting process for the image data of the area R 1 . In FIG. 11, the same process portion as &#34;WPRED&#34; is given the same step number. In the subroutine &#34;NPRED&#34;, the range of the amount of relative displacement K is -4-4. This is because &#34;NPRED&#34; is applied near the in-focus state and therefore the amount of image deviation is originally small. In this case, as shown in steps 212 and 213, the leading position NR 1  of the area R 1  is taken into account. This treatment process is shown in FIG. 13(a). In this figure, the solid line represents the focus evaluated amount X(k) and the broken line represents the focus evaluated amount Y(k). By the same processing (steps 140-146) as that described with respect to &#34;WPRED&#34;, the amount of image deviation PR 1  in the area R 1  is found. At step 221, the amount of image deviation PR 1  and the contrast evaluated amount ZD 1  are stored in the RAM in the control circuit PRS. Likewise, at steps 230-241, the amount of image deviation PR 2  and the contrast evaluated amount ZD 2  (see FIG. 13(b)) in the area R 2  are found, and at steps 250-261, the amount of image deviation PR 3  and the contrast evaluated amount ZD 3  (see FIG. 13(c)) in the area R 3  are found, and these are also stored in the RAM in the control circuit PRS. 
     At steps 270-278, which of the amounts of image deviation PR 1 , PR 2  and PR 3  in the three areas R 1 , R 2  and R 3  found in the manner described above is the final amount of image deviation PR is judged. That is, in the present embodiment, of the three areas, the amount of image deviation which is sufficiently high in contrast and greatest is adopted. The meaning of the adoption of the greatest amount of image deviation is that when the amount of image deviation is positive, the photo-taking lens is in near focus and the rearest focus object is the object on the closest side and the focus is adjusted to that object. After the final amount of image deviation PR and the contrast evaluated amount ZD have been found, the focus state is determined at step 280. The processing here is similar to the processing described with respect to &#34;WPRED&#34; and therefore need not be described. 
     As described above, when the amount of non-in-focus is great, the then amount of image deviation, i.e., the then amount of non-in-focus of the photo-taking lens FLNS, can be detected by the subroutine &#34;WPRED&#34;, and in the near-the-in-focus state, the then amount of image deviation, i.e., the then amount of non-in-focus of the photo-taking lens FLNS, can be detected by the subroutine &#34;NPRED&#34;. 
     Turning back to FIG. 2, the description of step 15 and so forth will be continued. Step 15 checks the contrast during the focus detecting process of &#34;WPRED&#34; or &#34;NPRED&#34; previously carried out with the flag LCFLG watched. When LCFLG is &#34;Y&#34;, the contrast is regarded as being low and the flag VSN is set to &#34;WD&#34; (step 35) so that the next focus detecting process uses &#34;WPRED&#34;, and a display subroutine &#34;DISP&#34; and a lens control subroutine &#34;LENS&#34; are executed (steps 19 and 20). The display subroutine &#34;DISP&#34; has no direct relation with the present invention and need not be described herein, while the lens control subroutine &#34;LENS&#34; will be described later 
     At step 16, the flag VSN is again checked. When the flag VSN is &#34;WD&#34;, the processing of step 17 and so forth is effected, and when the flag VSN is &#34;NR&#34;, the processing of step 28 and so forth is effected 
     The processing when VSN=&#34;WD&#34; will first be described. VSN=&#34;WD&#34; represents that the previous focus detecting process has been carried out by &#34;WPRED&#34; At step 17, a flag RCFLG is checked. The flag RCFLG becomes &#34;Y&#34; when the focus detecting process is carried out twice within the routine &#34;AF&#34;. In the present embodiment, when the routine &#34;AF&#34; is to be executed, &#34;WPRED&#34; or &#34;NPRED&#34; is executed at first by the flag VSN set by the previous routine &#34;AF&#34; (VSN becomes &#34;WD&#34; at the initial stage whereat release has been effected), but when the amount of image deviation which is the result thereof is not appropriate for respective conditions, VSN is reset and the flag RCFLG is set to &#34;Y&#34; so that a different focus detecting process &#34;NPRED&#34; or &#34;WPRED&#34; is now executed. RCFLG is the flag for that purpose. The resetting of VSN will be described later. 
     When the flag RCFLG is &#34;N&#34;, that is, during the first focus detecting process, the flag SDFLG is checked (step 18). SDFLG is a flag set in &#34;WPRED&#34; or &#34;NPRED&#34; as previously described (the flag SDFLG at this step is set in &#34;WPRED&#34;), and when this flag is &#34;Y&#34; (within three picture elements), it means that the current focus state is relatively approximate to the in-focus state. Accordingly, if VSN is &#34;WD&#34; and SDFLG is &#34;N&#34; (three picture elements or more), &#34;WPRED&#34; is regarded as being appropriate and a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34;. On the other hand, if SDFLG is &#34;Y&#34;, it is considered that it is more appropriate to effect re-operation by &#34;NPRED&#34;, that is, an amount of image deviation PR better in accuracy can be obtained, and VSN is set to &#34;NR&#34; (step 21), the amount of image deviation PR is temporarily stored in a buffer BPR (step 22), RCFLG is set to &#34;Y&#34; (step 23), and a shift is again made to the routines of step 12 and so forth (actually, step 12→step 14→step 15→step 16→step 28→step 33→). The reason why at the aforementioned step 22, the amount of image deviation PR is temporarily stored in the buffer BPR is that when the result of the operation effected in the next subroutine &#34;NPRED&#34; is not appropriate, that is, when SDFLG at step 33 is &#34;N&#34; (three picture elements or more) as a result of the operation effected in &#34;NPRED&#34;, the amount of image deviation PR obtained in the first subroutine &#34;WPRED&#34; is adopted (step 34→step 27→). 
     When at step 17, RCFLG is &#34;Y&#34;, that is, during the second focus detecting process, a shift is made to step 24 where SDFLG is checked. If the result is that SDFLG is &#34;N&#34;, the then focus detecting process is carried out in &#34;WPRED&#34; and thus, that focus detecting process is regarded as being appropriate and a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34; When SDFLG is &#34;Y&#34;, RCFLG is &#34;Y&#34; and VSN is &#34;WD&#34; and therefore, the first focus detecting process is carried out in &#34;NPRED&#34; and the result is not appropriate in &#34;NPRED&#34; As will be described later, in the first &#34;NPRED&#34;, inappropriateness is judged unless the flag NJFFLG is &#34;Y&#34;, that is, unless the photo-taking lens is substantially in focus, but if SDFLG is &#34;Y&#34;, the flag NRSDFLG is set to &#34;Y&#34; (although not in focus, yet within one picture element). That is, if NRSDFLG is &#34;Y&#34;, it means that in the first &#34;NPRED&#34;, the photo-taking lens has been not substantially in focus, but relatively approximate to the in-focus state. At this time, the amount of image deviation PR in &#34;NPRED&#34; is temporarily stored in the buffer BPR. Accordingly, if at step 24, SDFLG is &#34; Y&#34;, the photo-taking lens is relatively approximate to the in-focus state in the second &#34;WPRED&#34; and therefore, at step 25, the flag NRSDFLG is checked up to refer to the result of the first &#34;NPRED&#34;. If NRSDFLG is &#34;N&#34; (one picture element or more), it means that the first &#34;NPRED&#34; is not appropriate, and by the use of the amount of image deviation PR in the second &#34;WPRED&#34;, a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34;. If NRSDFLG is &#34;Y&#34;, in the next &#34;AF&#34;, VSN is set to &#34;NR&#34; to render the first focus detecting process into &#34;NPRED&#34; (step 26), and the amount of image deviation PR in the first &#34;NPRED&#34; already stored in the buffer BPR is taken out (step 27), and a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34;. 
     Going back in the flow, when VSN is judged as &#34;NR&#34; at step 16, the flag RCFLG is checked up at step 28. When RCFLG is &#34;N&#34;, it means the first &#34;NPRED&#34;, and when RCFLG is &#34;Y&#34;, it means the second &#34;NPRED&#34;. When RCFLG is &#34;N&#34;, the flag SDFLG is checked at step 29. When SDFLG is &#34;N&#34;, &#34;NPRED&#34; is regarded as being inappropriate and VSN is set to &#34;WD&#34; to cause the second focus detecting process to be carried out in &#34;WPRED&#34; (step 30), the amount of image deviation PR in &#34;WPRED&#34; is temporarily stored in the buffer BPR (step 22), RCFLG is set to &#34;Y&#34; (step 23), and a shift is again made to the execution of the routine of step 12 and so forth (actually, step 12→step 13→step 15→step 17→step 24→). When at step 29, SDFLG is &#34;Y&#34;, the flag NJFFLG is checked at step 31. As already described with respect to step 25, whether the focus detecting process has been appropriate is determined in the first &#34;NPRED&#34; by NJFFLG If at step 31, NJFFLG is &#34;N&#34; (more than one picture element and less than three picture elements), it means that the photo-taking lens is not substantially in focus, but relatively approximate to the in-focus state, and for use at step 25 which is the second focus detecting process &#34;WPRED&#34; again carried out in preparation for the worst case, the flag NRSDFLG is set to &#34;Y&#34; and a shift is made to step 30. Also, the amount of image deviation PR in the first &#34;NPRED&#34; temporarily stored in the buffer BPR at step 22 is used as required, i.e., at step 27 which is the second &#34;WPRED&#34;. 
     When at the aforementioned step 28, RCFLG is &#34;Y&#34;, it is the second &#34;NPRED&#34;, and as seen from the foregoing description, it means that in the first &#34;WPRED&#34;, the result has been determined as being inappropriate. Also, as previously described, if at step 33, SDFLG is checked and it is &#34;Y&#34;, the second &#34;NPRED&#34; is determined as being appropriate, and with the amount of image deviation PR left as it is, a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34;. If SDFLG is &#34;N&#34;, the second &#34;NPRED&#34; is regarded as being inappropriate, and VSN is set to &#34;WD&#34; to set the focus detecting process in the next &#34;AF&#34; to &#34;WPRED&#34; (step 34), the amount of image deviation PR temporarily stored in the buffer BPR is taken out in the first &#34;WPRED&#34; (step 27), and a shift is made to the execution of the display subroutine &#34;DISP&#34; and the lens control subroutine &#34;LENS&#34;. 
     Briefly summing up the above-described flow of &#34;AF&#34; processing, when &#34;AF&#34; is called, the image signal of the sensor row SA is read in (&#34;IMAGE&#34;) and the focus detecting process &#34;WPRED&#34; or &#34;NPRED&#34; is carried out, and under the premise that &#34;WPRED&#34; is applied when the amount of non-in-focus is great and &#34;NPRED&#34; is applied in the case of near-in-focus, if the detected amount of image deviation is inappropriate for the then processing, the same image signal is re-opera,ted by an appropriate processing system and after all, the amount of image deviation PR adopted for the lens control is calculated by &#34;WPRED&#34; when the amount of non-in-focus is great, and is calculated by &#34;NPRED&#34; in the case of near-in-focus. This is because when the amount of non-in-focus is great, the non-in-focus state can be better known if the focus detecting process is carried out by &#34;WPRED&#34;, and because when this result is judged as being near-in-focus, the focus detection accuracy can be more enhanced if the focus detecting process is carried out by &#34;NPRED&#34;. 
     The subroutine &#34;LENS&#34; will now be described with reference to the flow of FIG. 14. At step 60, the flag LCFLG is checked. As previously described, this flag is &#34;N&#34; when the contrast evaluated amount of the image signal which is the object of the focus detecting process is high. When the flag LCFGG is &#34;N&#34;, the image signal is regarded as having a sufficient contrast for the focus detecting process and the control of the photo-taking lens FLNS is effected on the basis of the amount of image deviation PR which is the result of the processing. First, a signal BSY input to the lens communication circuit LCOM is checked (step 61). During the time this signal BSY is &#34;H&#34;, the lens communication circuit is unable to communicate with the control circuit LPRS in the lens and therefore waits until the signal BSY becomes &#34;L&#34; (low level) When the signal BSY becomes &#34;L&#34;, the coefficient S of the amount of defocus of the photo-taking lens FLNS versus the amount of movement of the lens is input from a signal DLC from the control circuit LPRS in the lens (step 62). Subsequently, the amount of defocus DEF of the photo-taking lens FLNS is calculated from the amount of image deviation PR by an equation DEF=K·PR (step 63). K is a value preset by the focus detecting optical system. Subsequently, the amount of movement FP of th photo-taking lens FLNS is calculated from the amount of defocus DEF and the coefficient S by FP=DEF/S (step 64). FP corresponds to the count number of the encoder circuit ENC. At step 65, the signal BSY is again checked and, when the signal BSY becomes &#34;L&#34;, the amount of lens movement FP (signal DCL) is communicated to the control circuit LPRS in the lens (step 66). On the other hand, when LCFLG is &#34;Y&#34;, the contrast is regarded as being insufficient and the amount of movement FP of the photo-taking lens FLNS is calculated by FP=CDEF/S to effect a searching operation (step 67). CDEF is a result obtained by converting the amount of movement of the lens moved by one searching operation into the amount of defocus, and is preset. 
     When said amount of lens movement FP is input, the control circuit LPRS in the lens controls the driving of the photo-taking lens FLNS. By the photo-taking lens FLNS being stopped, the series of &#34;AF&#34; processings of the focus adjustment started from the inputting of the image signals A(i) and B(i) are terminated. 
     According to the present embodiment, the contrast evaluated amounts XD and YD are compared over all the range of relative displacement and one of them which is greater, i.e., the focus evaluated amount X(k) or Y(k) which is more excellent in terms of S/N, is used for the calculation of the amount of image deviation PR and therefore, the focus state of higher accuracy can be detected. 
     As described above, according to the present embodiment, calculating means for finding, from first and second evaluated amounts, third and fourth evaluated amounts depending on the contrast of first and second signals and selecting means for selecting said first evaluated amount or said second evaluated amount used when the amount of deviation between first and second images, in conformity with the relation in magnitude between said third and fourth evaluated amounts, are provided in operation means, whereby said first evaluated amount and said second evaluated amount are suitably changed over for use over all the range of relative displacement and therefore, even when the deviation of the relative position of the two images is great, focus detection of good accuracy can be accomplished.