Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assertion failed in Video.java class

I am running my code : import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.highgui.Highgui; import org.opencv.video.Video;

public class openCvHello { public static void main( String[] args ) { System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); Mat mat = Mat.eye( 600, 800, CvType.CV_8UC1 ); Mat prev=Mat.ones( 800, 600, CvType.CV_8UC1 ); Mat next =Mat.ones( 800, 600, CvType.CV_8UC1 ); Mat flow=Mat.ones( 800, 600, CvType.CV_32FC2);

   String prev_img_path ="C:/Users/user/Desktop/SampleImages/Frame19.tif";
   String next_img_path ="C:/Users/user/Desktop/SampleImages/Frame20.tif";

  File file_prev_img = new File(prev_img_path);

  if (file_prev_img.exists()) { // This is true
          prev = Highgui.imread(file_prev_img.getAbsolutePath());  //file.getPath() also same
         if ( prev.empty() ) 
         { System.out.println( "prev image does not exist!!"); }
     }
  File file_next_img = new File(next_img_path);
  if (file_next_img.exists()) { // This is true
      next = Highgui.imread(file_next_img.getAbsolutePath());  //file.getPath() also same
     if ( next.empty() ) 
     { System.out.println( "next image does not exist!!"); }
 }


   Video.calcOpticalFlowFarneback(prev,next,flow,0.5,1, 1, 1, 7,1.5,Video.OPTFLOW_USE_INITIAL_FLOW );
  System.out.println( "flow = " + flow.dump() );

} } this error occur OpenCV Error: Assertion failed (prev0.size() == next0.size() && prev0.channels() == next0.channels() && prev0.channels() == 1 && pyr_scale < 1) in unknown function, file ......\src\opencv\modules\video\src\optflowgf.cpp, line 579 Exception in thread "main" CvException [org.opencv.core.CvException: ......\src\opencv\modules\video\src\optflowgf.cpp:579: error: (-215) prev0.size() == next0.size() && prev0.channels() == next0.channels() && prev0.channels() == 1 && pyr_scale < 1 ] at org.opencv.video.Video.calcOpticalFlowFarneback_0(Native Method) at org.opencv.video.Video.calcOpticalFlowFarneback(Video.java:293)

I already ask many questions for the calcOpticalFlowFarneback(). I am wondering if you can not help me who i have to ask?