1. An imaging device comprising: an imaging processor that captures a plurality of secondary images of a same object at different in-focus positions by driving a photographing lens; a distance information detector that detects distance information of objects captured in each area of an image based on the contrast in each of the areas in each of the secondary images; a primary image capturing processor that, based upon distance information detected by the distance information detector, determines an in-focus position of a primary image and captures the image of the object at the determined in-focus position as a primary image; and an image processor that carries out image processing on the primary image based on the distance information.