OpenCV Motion Analysis Documentation lists multiple techniques for motion tracking:

  1. Sparse Optical Flow | calcOpticalFlowPyrLK,
  2. Dense Optical Flow | calcOpticalFlowFarneback, and
  3. Motion History Image | calcMotionGradient, segmentMotion, calcGlobalOrientation.

I need help in understanding their pros and cons. Which ones should be preferred under what circumstances?

Context: I am trying to track lane departure/lane changes. Any abstract/generic response would be good enough. Thanks!


1 Answer 1


Farneback is a dense optical flow algorithm. This means, it outputs the flow vectors per each pixel (which can be tracked). LK is a sparse variant, tracking only certain feature points.

The motion segmentation algorithms generally target estimation of foreground or background and doesn't allow establishing correspondences. Please refer to this post. You will find more details in my response.

  • $\begingroup$ @Tolga: I agree the difference between Farneback and LK. Would Farneback and LK be the same in quality and performance if LK considered all pixels to track? $\endgroup$ Dec 29, 2014 at 1:18
  • $\begingroup$ Could you elaborate on what you mean by "establishing correspondences" $\endgroup$ Dec 29, 2014 at 1:22
  • $\begingroup$ Updated the answer. $\endgroup$ Dec 29, 2014 at 7:39
  • $\begingroup$ I read the other post before posting this. Would like to understand the analysis. Like why do you say "more robust and reliable"? $\endgroup$ Jan 7, 2015 at 1:33
  • $\begingroup$ I guess this is a question for the other post. But, it becomes more robust, because you can easily add rigidity or planarity constraints. In plain optical flow, you assume no motion of pixels but try to get the correspondences relying on a smoothness prior or some regularization. $\endgroup$ Jan 7, 2015 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.