initAsync not applicable for the arguments

asked 2015-04-08 01:47:16 -0600

WSMB gravatar image

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)

edit retag flag offensive close merge delete