Implementation of optical flow