opencvimage-processingobject-detectionopticalflow

Can we use Lucas Kanade optical flow(opencv) for color based detection or contour object tracking?


From what I have studied, LK optical flow can be achieved in three methods:

  1. cvgoodfeaturestotrack
  2. cvfindcornerSubPix
  3. calcOpticalFlowPyrLK

Is there any possibility to track objects using color or by using contour?


Solution

  • I'm little bit confused about the exact meaning of your question.

    Here are the answers to what I can possibly interpret from you statement:

    Q: Can cvgoodfeaturestotrack, cvfindcornerSubPix, calcOpticalFlowPyrLK methods be used on color image directly?

    A: No. Convert to grayscale first.

    ++++++

    Q: Can Lucas Kanade optical flow be used for tracking a particular color?

    A: No. Possibly not, using the existing library functions/algorithms in openCV. Probably a research topic. Go through http://robots.stanford.edu/cs223b04/algo_tracking.pdf

    The very first line of the paper assumes the two input image are 2D and grayscale. Try going through available literature and see if you can tweak the algorithm to include color information. You may want to consult additional resources like this: http://www.dca.ufrn.br/~adelardo/artigos/SAC08.pdf

    +++++++++++

    Q: Can optical flow be used for tracking a particular color?

    A: Yes. Dense optical flow tracking (unlike sparse optical flow, viz. LK optical flow tracking). You may use openCV method: calcOpticalFlowFarneback

    ++++++

    There are other simpler methods, if you want to implement this from scratch and robustness ain't one of your primary concerns.

    Try thresholding input image for your target color ----> calculate largest blob ----> obtain centroid of that blob ---> check the flow of that centroid across consecutive frames.