Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Crach on Video.calcOpticalFlowFarneback

Hello, i am running the follwing code.

public static void main( String[] args ) { System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); Mat mat = Mat.eye( 800, 600, 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);

   //URL img_url = getClass().getResource("C:/Users/user/Desktop/Master Thesis/Sample images/Frame19.jpg"); 
   //String img_path = img_url.getPath();
   String prev_img_path ="C:/Users/user/Desktop/SampleImages/Frame19.jpg";
   String next_img_path ="C:/Users/user/Desktop/SampleImages/Frame40.jpg";

   prev = Highgui.imread(prev_img_path);
   next = Highgui.imread(next_img_path);

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

}

and I am getting the following error OpenCV Error: Assertion failed (ssize.area() > 0) in unknown function, file ......\src\opencv\modules\imgproc\src\imgwarp.cpp, line 1723 Exception in thread "main" CvException [org.opencv.core.CvException: ......\src\opencv\modules\imgproc\src\imgwarp.cpp:1723: error: (-215) ssize.area() > 0 ] at org.opencv.video.Video.calcOpticalFlowFarneback_0(Native Method) at org.opencv.video.Video.calcOpticalFlowFarneback(Video.java:293) at openCvHello.main(openCvHello.java:29)

After debugging i found out the the issue is on this two rows prev = Highgui.imread(prev_img_path); next = Highgui.imread(next_img_path);

I do not know how to fix it I am so desperate. Also how can i show the image to know that i have the correct one?

Thanks in advance