1. An image forming apparatus for forming an image of an object to be inspected, comprising: a detecting unit for detecting signals relating to a resonance scanner which is set to scan the object to be inspected with measurement light at a first frequency; a determining unit for determining a second frequency which is estimated to be used for the scanning by the resonance scanner, based on a correlation between groups of the detected signals for each cycle of the first frequency; and an image forming unit for forming the image of the object to be inspected based on the determined second frequency.