Ask Your Question

WSMB's profile - activity

2015-04-08 01:47:16 -0500 asked a question initAsync not applicable for the arguments

Hello, I'm trying to statically init my openCV manager as shown here : Async Initialization. I've created a BaseLoaderCallback mLoaderCallback but when trying to use initAsync I get either 2 problems:

  • If I use the code given in the example,

if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback))

Eclipse tells me there is an error because "The method initAsync(String, Context, LoaderCallbackInterface) in the type OpenCVLoader is not applicable for the arguments (String, PFC_AVR, BaseLoaderCallback)" where PFC_AVR is my class

  • If I follow the suggestion and change te code to:

if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, (org.opencv.android.LoaderCallbackInterface) mLoaderCallback))

A fatal error occurs when running my app and Eclipse gives me the log:

04-08 08:21:41.780: E/AndroidRuntime(2076): FATAL EXCEPTION: main
04-08 08:21:41.780: E/AndroidRuntime(2076): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pf/com.example.pf.PFC_AVR}: java.lang.ClassCastException: com.example.pf.PFC_AVR$1 cannot be cast to org.opencv.android.LoaderCallbackInterface
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.os.Looper.loop(Looper.java:137)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread.main(ActivityThread.java:4517)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at java.lang.reflect.Method.invokeNative(Native Method)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at java.lang.reflect.Method.invoke(Method.java:511)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:985)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:752)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at dalvik.system.NativeStart.main(Native Method)
04-08 08:21:41.780: E/AndroidRuntime(2076): Caused by: java.lang.ClassCastException: com.example.pf.PFC_AVR$1 cannot be cast to org.opencv.android.LoaderCallbackInterface
04-08 08:21:41.780: E/AndroidRuntime(2076):     at com.example.pf.PFC_AVR.onCreate(PFC_AVR.java:94)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.Activity.performCreate(Activity.java:4470)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
04-08 08:21:41.780: E/AndroidRuntime(2076):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)

So I don't know what to do. I need to init this library in order to create "Mat" objets and keep on working...

An important note is that my class is a Java class which implements a Cordova Plugin. I've copied all libraries ... (more)

2015-03-25 05:39:45 -0500 commented question No implementation found for native Lcom .n_Mat

I've read a little bit more and this kind of error is very common in people who’s trying to import their native “C” code to an Android project. As my code is written in Java, I don’t really know why I’m getting this error..

2015-03-23 02:22:34 -0500 received badge  Editor (source)
2015-03-23 01:56:21 -0500 commented question No implementation found for native Lcom .n_Mat

@Guanta You are right, the " ** " where only to remark what I was saying. @berak I'll try to put the "CvSVM cvsm = new CvSVM(); //Create machine" before this Mat method... We'll see! the com.opencv.avr.mat is a modification I've made. Because OpenCV brings a lot of methods for image treatment, I don't need them all so I've only brought the ones I need and put them in a package

2015-03-21 06:02:13 -0500 asked a question No implementation found for native Lcom .n_Mat

Hello,

I'm using OpenCV through Cordova for, given some metrics about exercise, predict wich type of exercise you are doing. I've a XML file with trainning information but I'm having problems importing my exercise params.

This is what I'm doing (I've manually put line numbers in brackets after changing the code with @berak comments)

[33]CvSVM cvsm = new CvSVM(); //Create machine
[34]Scalar scalar = new Scalar(metricas);  //metricas is my array with parameters from physical exercise
[35]Mat mat = new Mat(1, 15, 6, scalar); //this is where it crashes, when I try to load my results from physical activity to preassign this values to the matrix "mat"** 
[36]cvsm.load("modeloSVMSinHR.xml", "modeloSinHR"); //load XML with "trained params"
[37]float resultado = cvsm.predict(mat, false);    //predict wich type of activity you're doing

With these changes in the code I'm getting this error

I changed the order of methods and it certainly changed this behaviour. Now I'm getting this error:

03-23 08:13:55.220: W/dalvikvm(2581): No implementation found for native Lcom/opencv/avr/CvSVM;.CvSVM_0 ()J
03-23 08:13:55.220: W/System.err(2581): java.lang.UnsatisfiedLinkError: CvSVM_0
03-23 08:13:55.220: W/System.err(2581):     at com.opencv.avr.CvSVM.CvSVM_0(Native Method)
03-23 08:13:55.220: W/System.err(2581):     at com.opencv.avr.CvSVM.<init>(CvSVM.java:63)
03-23 08:13:55.220: W/System.err(2581):     at com.opencv.avr.OpenCV.execute(OpenCV.java:33)
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65)
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.PluginManager.execHelper(PluginManager.java:242)
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:227)
03-23 08:13:55.220: W/System.err(2581):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:653)
03-23 08:13:55.220: W/System.err(2581):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 08:13:55.220: W/System.err(2581):     at android.os.Looper.loop(Looper.java:137)
03-23 08:13:55.220: W/System.err(2581):     at android.app.ActivityThread.main(ActivityThread.java:4517)
03-23 08:13:55.230: W/System.err(2581):     at java.lang.reflect.Method.invokeNative(Native Method)
03-23 08:13:55.230: W/System.err(2581):     at java.lang.reflect.Method.invoke(Method.java:511)
03-23 08:13:55.230: W/System.err(2581):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:985)
03-23 08:13:55.230: W/System.err(2581):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:752)
03-23 08:13:55.230: W/System.err(2581):     at dalvik.system.NativeStart.main(Native ...
(more)