1

我正在尝试在 android 上使用 OpenCV

我创建了我的 android 项目,添加javacv.jariavacpp.jar构建路径,创建了文件lib夹并将*.so文件从javacv-arm.jar.libs/armeabi

所有jar&*.so文件都是 2.4.2 版本。

当我运行应用程序时,我创建了一个测试按钮。单击它时,我正在调用此行:

IplImage image = cvLoadImage("file:///android_asset//"+"pic1.jpg");

并得到以下崩溃

03-12 19:22:12.189: E/AndroidRuntime(4524): FATAL EXCEPTION: main
03-12 19:22:12.189: E/AndroidRuntime(4524): java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.myapp.MainActivity.runTest(MainActivity.java:260)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.myapp.MainActivity$3.onClick(MainActivity.java:174)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.view.View.performClick(View.java:4084)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.view.View$PerformClick.run(View.java:16966)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.os.Handler.handleCallback(Handler.java:615)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.os.Looper.loop(Looper.java:137)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at android.app.ActivityThread.main(ActivityThread.java:4745)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.reflect.Method.invokeNative(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.reflect.Method.invoke(Method.java:511)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at dalvik.system.NativeStart.main(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
03-12 19:22:12.189: E/AndroidRuntime(4524):     ... 13 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
03-12 19:22:12.189: E/AndroidRuntime(4524):     ... 17 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]:   124 could not load needed library 'libopencv_core.so' for 'libjniopencv_core.so' (load_library[1093]: Library 'libopencv_core.so' not found)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.Runtime.loadLibrary(Runtime.java:370)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at java.lang.System.loadLibrary(System.java:535)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:444)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacpp.Loader.load(Loader.java:368)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacpp.Loader.load(Loader.java:315)
03-12 19:22:12.189: E/AndroidRuntime(4524):     at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
03-12 19:22:12.189: E/AndroidRuntime(4524):     ... 21 more
03-12 19:22:12.243: D/dalvikvm(4524): GC_CONCURRENT freed 2368K, 16% free 16864K/20039K, paused 12ms+3ms, total 50ms

我失踪了libopencv_core.so吗?如果是这样,我在哪里可以找到它为 2.4.2 版构建的?

谢谢!

4

1 回答 1

1

我敢肯定,现在你已经想通了。下载javacv-0.5-cppjars.zip,里面解压opencv-2.4.5-android-arm.jar的内容。你会在那里找到 libopencv_core.so 和其他几个 .so 文件

于 2013-04-29T16:01:39.970 回答