Use calcOpticalFlowFarneback java

asked 2013-10-11 12:46:19 -0500

Ioanna gravatar image

I am trying to use calcOpticalFlowFarneback in java. I found this http://docs.opencv.org/java/org/opencv/video/Video.html#calcOpticalFlowFarneback(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int, int, int, int, double, int) which is so helpful but i am trying to define all the variables but i do not know the structure. I used to use openCv for c++ however i did not find any documentation which help me!

edit retag flag offensive close merge delete

Comments

I resolve that issue. i am not sure what it was the problem!! Now have this isseu inside the function... 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) at openCvHello.main(openCvHello.java:48)

Ioanna gravatar imageIoanna ( 2013-10-13 23:58:29 -0500 )edit

this is my code.. import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.net.URL;

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( 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);

   String prev_img_path ="C:/img19.jpg";
   String next_img_path ="C:/Users/user/Desktop/SampleImages/Frame40.jpg";

  File file_prev_img = new File(prev_img_path);
Ioanna gravatar imageIoanna ( 2013-10-13 23:59:12 -0500 )edit

it seems that the problem is on images! there is any sample that it is working?

Ioanna gravatar imageIoanna ( 2013-10-14 00:06:09 -0500 )edit