cummon questions for openCv in java-desktop
Hello, I am a beginner in openCv in java-desktop.I used to use openCV for c++ and it was awesome.However, know I am lost.I have some questions because I stuck.
- How can i show/ display an image?
How can i define an image with CvType.CV_8UC1 with out to know the size (Mat next =Mat.ones( ?, >, CvType.CV_8UC1 );) and then i load it from disk.
I am using the following function Video.calcOpticalFlowFarneback(prev,next,flow,0.5,1, 1, 1, 7, 1.5,1); how can i use the flow matrix?
Thanks in advance, Ioanna
for 2. there's an easy answer) :
thanks again for your help! However i am using this String prev_img_path ="C:/Users/user/Desktop/SampleImages/Frame19.jpg"; String next_img_path ="C:/Users/user/Desktop/SampleImages/Frame40.jpg";
and i am getting this 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
see also my question http://answers.opencv.org/question/22367/crach-on-videocalcopticalflowfarneback/
probably wise, to check, if the image was found/loaded: if ( prev.empty() ) { "bwaa!!" }
oh, and you have to load them as grayscale images (imread(path,0)) or convert them (Imgproc.cvtColor)
thanks!! it is empty! :)
where i have to locate my image to find it? in the src directory?
hmm, i'd say, using an absolute path was already a good idea. bit clueless here. check again, if it's really there. drop it onto a webbrowser or on paint, to see if it's maybe broken
Finally, the images are not empty but this error appeared: 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) Video.calcOpticalFlowFarneback(prev,next,flow,0.5,1, 1, 1, 7,1.5 :(