If a position of a focus lens is greatly displaced from a focus state when automatic focusing is started, and pattern recognition cannot be performed, the process proceeds to step S3. In step S3, the lens is sequentially driven until pattern recognition can be performed. If it is determined that the pattern recognition can be performed in step S2, a focus detection range is determined in S4. In step S5, an AF evaluation value of the range is calculated, and the value is stored in step S6.