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 ConnectFX (see Creating ConnectFX).
Tools, then select from the menu (See Accessing Tools).
This node accepts a front clip, and outputs forward and backward vectors.