1. A method for processing a sequence of images, comprising: obtaining, from an optical sensor, at least two images of the sequence of images, determining an image warping function that at least partially compensates a distortion in at least one of the two images, applying the determined image warping function to the at least one image, at least partially compensating the distortion by modifying the at least one image, and calculating and outputting an optical flow as a displacement vector field from the modified at least one image and another image of the at least two images, wherein the optical flow is corrected by subtracting shifts introduced due to the warping function application.