cvCalcOpticalFlowFarneback Error: Assertion failed
I I'm trying to use cvCalcOpticalFlowFarneback. this is my code:
int main( int argc, char* argv ) { CvCapture webcam = cvCreateCameraCapture(0); IplImage *prev=NULL; IplImage *next=NULL;
double pyr_scale=0.5;
int levels=1;
int winsize=3;
int iterations=10;
int poly_n=5;
double poly_sigma=1.1;
int flags=0;
if (!webcam){
puts("error!");
return -1;
}
while (1) {
prev = cvQueryFrame(webcam);
next = cvQueryFrame(webcam);
CvMat* flow = cvCreateMat(prev->height, next->width, CV_32FC2);
cvCalcOpticalFlowFarneback(prev,next,flow,pyr_scale,levels,winsize,iterations,poly_n,poly_sigma,flags);
}
return 0;
}
I get this error: OpenCV Error: Assertion failed (prev0.size() == next0.size() && prev0.channels() == next0.channels() && prev0.channels() == 1 && pyr_scale < 1) in unknown function, file ........\ocv\opencv\src\cv\cvoptflowgf.cpp, line 578
where am I doing wrong? thanks