這是我得到error.I加載正確的opencv庫,但我得到這個錯誤。如果我去在ximgproc所有本地方法紅色標記爲「無法解析相應的jni函數name_function」。我該如何解決?無法解析相應的Jni函數opencv Android
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri uri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
//Log.i("prova",uri.toString());
ImageView imageView = (ImageView) findViewById(R.id.imageView);
// imageView.setImageBitmap(bitmap);
Mat g=new Mat(bitmap.getHeight(),bitmap.getWidth(), CvType.CV_8UC1);
Utils.bitmapToMat(bitmap,g,true);
SuperpixelSLIC x=Ximgproc.createSuperpixelSLIC(g,Ximgproc.SLIC,100,3);
} catch (IOException e) {
e.printStackTrace();
}
}
}
,這是我的錯誤:
06-07 19:24:01.370 21090-21090/com.example.jt1995.provaemo E/art: No implementation found for long org.opencv.ximgproc.Ximgproc.createSuperpixelSLIC_0(long, int, int, float) (tried Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10 and Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10__JIIF)
06-07 19:24:01.370 21090-21090/com.example.jt1995.provaemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jt1995.provaemo, PID: 21090
java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.ximgproc.Ximgproc.createSuperpixelSLIC_0(long, int, int, float) (tried Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10 and Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10__JIIF)
at org.opencv.ximgproc.Ximgproc.createSuperpixelSLIC_0(Native Method)
at org.opencv.ximgproc.Ximgproc.createSuperpixelSLIC(Ximgproc.java:452)
at com.example.jt1995.provaemo.MainActivity.onActivityResult(MainActivity.java:108)
at android.app.Activity.dispatchActivityResult(Activity.java:6303)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3818)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3865)
at android.app.ActivityThread.access$1700(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5569)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:931)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:726)
這是我得到的「getContext()。getApplicationInfo()。nativeLibraryDir」:/data/app/com.example.jt1995.provaemo-1/lib/arm – Jt1995
另一個問題,你寫了關於「Ximgproc-native .so「,在我的文件夾項目中,我有」libnincv_ximgproc.a「libs文件夾的」jniLibs「文件夾,但我寫了」.so「,我的是」.a「@AlexCohn – Jt1995
最後,你需要一個*共享庫*這是「.so」。您可以使用*靜態庫*(「.a」)來構建共享庫,但通常這些靜態庫是造成混淆的原因。如果您使用'ndk-build'構建「libopencv_ximgproc.a」,則可以在** Android.mk **文件中將$(BUILD_STATIC_LIBRARY)更改爲$(BUILD_SHARED_LIBRARY)。 –