CalcOpticalFlowFarneback error with C, Eclipse

asked 2013-11-30 08:48:05 -0600

Ricio91 gravatar image

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

berak gravatar image

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?

edit retag flag offensive close merge delete

Comments

the flow image must have the same size as the prev/next image

btw, if #include "highgui.h" works for you, you must be using a version from the stone age.

berak gravatar imageberak ( 2013-11-30 09:58:18 -0600 )edit

well, how do I set them to the same size? thanks again

Ricio91 gravatar imageRicio91 ( 2013-11-30 10:50:02 -0600 )edit

cvSize(next); probably.

again, why even bother with opencv1.0 ? (and the c-api in general)

berak gravatar imageberak ( 2013-11-30 11:16:41 -0600 )edit

I'm using opencv2.1, I don't know why but for now I need opencv only for a exercise:)

Ricio91 gravatar imageRicio91 ( 2013-11-30 11:42:16 -0600 )edit