Use Motion Analysis to analyse image displacement in a frame with respect to the frame before it.

To access the Motion Analysis menu, use:
Timeline, then use Batch FX (See Creating ConnectFX).
This node accepts a front clip, and outputs forward and backward vectors.