The invention is generally directed to the field of image processing, and more particularly to a method and an apparatus for determining a wavefront of an object, in particular a human eye. The invention discloses a method and an apparatus for real-time wavefront sensing of an optical system utilizing two different algorithms for detecting centroids of a centroid image as provided by a Hartmann-Shack wavefront sensor. A first algorithm detects an initial position of all centroids and a second algorithm detects incremental changes of all centroids detected by said first algorithm.