Here’s a very simple example of combining the usual marker detection algorithm with optical flow.
Basically we’d try to find the candidate marker first, and store its position. When the subsequent call of the method to find the marker fails, we switch to optical flow to predict where the marker has moved.
You can see the sample result here, blue outline indicates that the marker is detected using the usual method. Red indicates that it’s found using lucas kanade’s optical flow.
You can get the source code for this example here: https://github.com/subokita/Sandbox/tree/master/MarkerDetection/MarkerDetection