A variational approach is used to recover fluid motion governed by Stokes and Navier–Stokes equations. Unlike previous approaches where optical flow method is used to track rigid body motion, this new framework aims at investigating incompressible flows using optical flow techniques. We formulate a minimization problem and determine conditions under which unique solution exists. Numerical results using finite element method not only support theoretical results but also show that Stokes flow forced by a potential are recovered almost exactly.