Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well, cv::setNumThreads(1) would be even less than that, obviously. Fortunately, there is a simple method that can get you a middling to large portion of your CPU back without sacrificing time.

Inside calcOpticalFlowPyrLK is two calls to the buildOpticalFlowPyramid function. Since you're using the same frame twice, they pyramid for that frame is built twice. You can instead create the pyramid yourself once, and pass it in place of the images in the arguments.

Second, unless I'm missing something, you only use the values in landmarks once, for the first frame. Instead of creating them every frame and then dropping them, fill landmarks and currPoints once at the beginning.