OpenCV4Android: calcOpticalFlowPyrLK: exception after toArray() for status
Hey guys,
My Code:
status = new MatOfByte();
err = new MatOfFloat();
Video.calcOpticalFlowPyrLK(previousMatFrame, currentMatFrame, prevuisMatOfPoint2f, pointsWichAreFound, status, err);
byte statusS[] = status.toArray();
//the exception after status.toArray();
08-14 14:00:11.086: E/AndroidRuntime(6639): java.lang.RuntimeException: Native Mat has unexpected type or size: Mat [ 6*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x6c0bb388, dataAddr=0x6c0b3f00 ]
08-14 14:00:11.086: E/AndroidRuntime(6639): at org.opencv.core.MatOfByte.toArray(MatOfByte.java:54)
08-14 14:00:11.086: E/AndroidRuntime(6639): at de.itintouch.mausapp.activitys.MausActivity.onCameraFrame(MausActivity.java:266)
08-14 14:00:11.086: E/AndroidRuntime(6639): at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
08-14 14:00:11.086: E/AndroidRuntime(6639): at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:321)
08-14 14:00:11.086: E/AndroidRuntime(6639): at java.lang.Thread.run(Thread.java:864)
If i delete line 54 for converting the status object into an array, the application runs in normal case without errors. What could it be?? Please help me.
Please, in the future, try to focus on using tags without the hashtags. These hashtags create tons of double tags, which is not interesting if you want to apply filtering on topics. As to your problem, you adapted line 54 of which file or piece of code?
I adapted line 54 of my .java file. My code at the last post is only a piece. In line 54 is only this code: byte statusS[] = status.toArray(); Sorry for my bad english. I hope you understand me..
I dont know exactly if this is intended to be like that, but the error says something of a 2 channel matrix. Most likely its the status Mat. I dont know if toArray works with a 2 channel matrix when copying it into a 1-dimensional array. Im not sure about that though
What is about the return value of the toArray() method? public byte[] toArray() The return value is a 1 dimension Array. It should be correct if i try to copy it into a 1-dimensional array. In some test-runs on a galaxy s2 or nexus 7 I print the status array on the console: Output = [0,1,1,0,1] I think it's a camera problem. The Version 2.4.6 can't connect correctly to the camera of the htc-one or some camera config changes like changing the resolution is the reason.