Thanks again for the useful advice! I changed the algorithm. When MOSSE function tracks “corner points”, cursor moves much more smoothly. There was a slight issue with discrete movement as the object rectangles moved the same number of pixels at the same time. Cursor moved in leaps. So, I had to use filter on each tracked point. Anyway, as you can see in the video, the CPU load did not increase comparing to Lukas-Kanade optical flow algorithm + filtration only cursor position. In good light, the difference is also very noticeable.
https://www.youtube.com/watch?v=WKwuas0GVkA
- Lucas-Kanade optical flow:
goodFeaturesToTrack(),
cornerSubPix(),
calcOpticalFlowPyrLK(),
cursor EWMA filter
- MOSSE object tracking:
goodFeaturesToTrack(),
cornerSubPix(),
cv::legacy::TrackerMOSSE,
all points EWMA filtration
And of course I had to remember to include the tracking453.lib to Linker when add cv::legacy::Tracker. I spent half a day googling the “unresolved external symbol LNK2001 error”. For some reason including a tracker from the core library (cv::Tracker) does not result such compilation error, so it is confusing.