A variational approach for particle tracking velocimetry