Ask Your Question

Revision history [back]

calcOpticalFlowFarneback with JavaCV

I can't get calcOpticalFlowFarneback to work in javacv.

when I compile it says it needs

  required: IplImageArray,IplImageArray,CvArr,   double,int,int,int,int,double,int
  found:    IplImage,     IplImage,     IplImage,double,int,int,int,int,double,int

but the documentation doesn't mention IplImageArray.

if I do put it into IplImageArray,

IplImage image1_gray = cvCreateImage( cvSize(image1.width(),image1.height()), IPL_DEPTH_8U, 1 );

   IplImage image2_gray = cvCreateImage( cvSize(image2.width(),image2.height()), IPL_DEPTH_8U, 1 );
   IplImage flow  = cvCreateImage( cvSize(image1.width(),image1.height()), IPL_DEPTH_32F, 2 );

   cvConvertImage(image1, image1_gray, CV_CVTIMG_FLIP);
   cvConvertImage(image2, image2_gray, CV_CVTIMG_FLIP);     

   IplImageArray image1array = new IplImageArray(image1_gray);
   IplImageArray image2array = new IplImageArray(image2_gray);
   calcOpticalFlowFarneback(image1_gray, image2_gray, flow, 0.5, 1, 1, 1, 7,
                               1.5,OPTFLOW_FARNEBACK_GAUSSIAN);

calcOpticalFlowPyrLK works fine.

javacv 2.4.4

java 1.7.0_17

calcOpticalFlowFarneback with JavaCV

I can't get calcOpticalFlowFarneback to work in javacv.

when I compile it says it needs

  required: IplImageArray,IplImageArray,CvArr,   double,int,int,int,int,double,int
  found:    IplImage,     IplImage,     IplImage,double,int,int,int,int,double,int

but the documentation doesn't mention IplImageArray.

if I do put it into IplImageArray,

IplImage image1_gray = cvCreateImage( cvSize(image1.width(),image1.height()), IPL_DEPTH_8U, 1 );

   IplImage image2_gray = cvCreateImage( cvSize(image2.width(),image2.height()), IPL_DEPTH_8U, 1 );
   IplImage flow  = cvCreateImage( cvSize(image1.width(),image1.height()), IPL_DEPTH_32F, 2 );

   cvConvertImage(image1, image1_gray, CV_CVTIMG_FLIP);
   cvConvertImage(image2, image2_gray, CV_CVTIMG_FLIP);     

   IplImageArray image1array = new IplImageArray(image1_gray);
   IplImageArray image2array = new IplImageArray(image2_gray);
   calcOpticalFlowFarneback(image1_gray, image2_gray, flow, 0.5, 1, 1, 1, 7,
                               1.5,OPTFLOW_FARNEBACK_GAUSSIAN);

then it crashes with

OpenCV Error: Assertion failed (func != 0) in unknown function, file ..\..\..\src\opencv\modules\core\src\convert.cpp, line 1095

calcOpticalFlowPyrLK works fine.

javacv 2.4.4

java 1.7.0_17