Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CalcOpticalFlowFarneback error with C, Eclipse

I'm trying to compare two images this is my code:

include <stdio.h>

include <cv.h>

include <highgui.h>

int main(){

CvCapture* webcam = cvCreateCameraCapture(0); IplImageprev=NULL; IplImagenext=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);

CvSize isize = cvSize(80,80); IplImage *flow = cvCreateImage(isize, IPL_DEPTH_32F, 1); if ((prev) && (next)) {

cvCalcOpticalFlowFarneback(prev,next,flow,pyr_scale,levels,winsize,iterations,poly_n,poly_sigma,flags);

}

}

return 0; }

but I get this error:

OpenCV Error: Assertion failed (flow.size() == prev.size() && flow.type() == CV_32FC2) in unknown function, file ........\ocv\opencv\src\cv\cvoptflowgf.cpp, line 656

where am I doing wrong?

click to hide/show revision 2
retagged

updated 2013-11-30 10:03:21 -0600

berak gravatar image

CalcOpticalFlowFarneback error with C, Eclipse

I'm trying to compare two images this is my code:

include <stdio.h>

include <cv.h>

include <highgui.h>

int main(){

CvCapture* webcam = cvCreateCameraCapture(0); IplImageprev=NULL; IplImagenext=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);

CvSize isize = cvSize(80,80); IplImage *flow = cvCreateImage(isize, IPL_DEPTH_32F, 1); if ((prev) && (next)) {

cvCalcOpticalFlowFarneback(prev,next,flow,pyr_scale,levels,winsize,iterations,poly_n,poly_sigma,flags);

}

}

return 0; }

but I get this error:

OpenCV Error: Assertion failed (flow.size() == prev.size() && flow.type() == CV_32FC2) in unknown function, file ........\ocv\opencv\src\cv\cvoptflowgf.cpp, line 656

where am I doing wrong?