No implementation found for native Lcom .n_Mat

asked 2015-03-21 05:47:15 -0500

WSMB gravatar image

updated 2015-03-23 02:22:59 -0500


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>(
03-23 08:13:55.220: W/System.err(2581):     at com.opencv.avr.OpenCV.execute(
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.CordovaPlugin.execute(
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.PluginManager.execHelper(
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.PluginManager.exec(
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.ExposedJsApi.exec(
03-23 08:13:55.220: W/System.err(2581):     at org.apache.cordova.CordovaChromeClient.onJsPrompt(
03-23 08:13:55.220: W/System.err(2581):     at android.webkit.CallbackProxy.handleMessage(
03-23 08:13:55.220: W/System.err(2581):     at android.os.Handler.dispatchMessage(
03-23 08:13:55.220: W/System.err(2581):     at android.os.Looper.loop(
03-23 08:13:55.220: W/System.err(2581):     at
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(
03-23 08:13:55.230: W/System.err(2581):     at$
03-23 08:13:55.230: W/System.err(2581):     at
03-23 08:13:55.230: W/System.err(2581):     at dalvik.system.NativeStart.main(Native ...
edit retag flag offensive close merge delete


Sry if my comment is totally off-topic since I don't know what cordova is, but this: **Mat mat = new Mat(1, 15, 6, scalar) looks strange to me, if it would be c++ than Mat *mat = new Mat(...) would be correct or just Mat mat(...) since it doesn't need to be on the heap. In java it would probably be Mat mat = new Mat(...) Also the initialization with scalar, I doubt that this will work this way.

Guanta gravatar imageGuanta ( 2015-03-21 07:49:54 -0500 )edit

"java.lang.UnsatisfiedLinkError: n_Mat" - this happens, when you execute opencv code, before the opencv native so's are loaded.

berak gravatar imageberak ( 2015-03-21 10:06:07 -0500 )edit

also, com.opencv.avr.Mat does not look like opencv's java api. what kind of wrappers are you using there ?

berak gravatar imageberak ( 2015-03-21 10:10:00 -0500 )edit

@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

WSMB gravatar imageWSMB ( 2015-03-23 01:56:21 -0500 )edit

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..

WSMB gravatar imageWSMB ( 2015-03-25 05:39:45 -0500 )edit

again, it does not find the native (c++) implementation of anything from opencv. usually, on android you call the opencvmanager class to load the libs on startup, or do a System.loadLibrary(in the static linking case)

now, the fact, that you're trying to use cordova, and even tried to hack opencv's modules/interfaces, does not make it easier ;(

berak gravatar imageberak ( 2015-03-25 05:54:57 -0500 )edit