1. Optical apparatus, comprising: an image sensor, which is configured to output a signal responsively to an optical image formed on the image sensor; objective optics, which are configured to focus optical radiation from an object so as to form the optical image on the image sensor, while intentionally superimposing a known and invertible characteristic distortion on the optical image; and a processor, which is coupled to process the signal so as to generate electronic images of the object and to apply an inverse digital warping to the electronic images in order to remove the characteristic distortion, to calibrate an initial distortion of the optical image by matching pairs of points in a first electronic image, each pair comprising an image point in the optical image and a corresponding point in an epipolar plane of the apparatus, to detect a change of the distortion in the optical image relative to the initial distortion using the matched pairs of points in a second electronic image, generated subsequently to the first electronic image, and to identify, responsively to the detected change, a deviation of a spatial or optical relation between the objective optics and the image sensor with respect to an initial alignment of the objective optics relative to the image sensor.