Can anyone point me to an example of how to use this addon?

I declare my object:

ofxCvOpticalFlowPyrLK     flow;  

I initialize in setup():

flow.init(mVideoSizeWidth, mVideoSizeHeight, mWindowSizeWidth, mWindowSizeHeight);  

I try to calculate the optical flow with two ofxCvGrayscaleImages grabbed from a webcam:

flow.calc(mOldImage, mNewImage);  

This is where it fails. I keep getting the following errors:

OpenCV ERROR: Incorrect size of input array ()  
	in function cvFindCornerSubPix  

Any ideas?

Can you zip+post up the rest of it? I’m wondering if the images are getting populated correctly? I’ve used it before w/o problems but that was a little while ago.


Zipped and posted my entire Xcode project.

It’s here:


Hi astellato

I looked through your project and found the problem was when initializing the optical flow


The last 2 parameters define the size of the search window in each pyramid level.
Setting the window to be as big as your images is what is crashing your application.
Setting a bigger search window will result in a more precise analysis but will slow things down.
The default value is 5, so try experimenting with these values until you get something that works for you.



That was it. Thanks so much for you help!