OpenCV 官方工程报错(1) Couldn't load mixed_sample from loader
openCV/OpenCV-android-sdk/samples/tutorial-2-mixedprocessing 工程
06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): Trying to get library list 06-04 10:38:17.984: E/OpenCV/StaticHelper(6081): OpenCV error: Cannot load info library for OpenCV 06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): Library list: "" 06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): First attempt to load libs 06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): Trying to init OpenCV libs 06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): Trying to load library opencv_java 06-04 10:38:17.984: D/OpenCV/StaticHelper(6081): Cannot load library "opencv_java" 06-04 10:38:17.994: 06-04 10:38:17.994: W/System.err(6081): at java.lang.Runtime.loadLibrary(Runtime.java:355) 06-04 10:38:17.994: W/System.err(6081): at java.lang.System.loadLibrary(System.java:525) 06-04 10:38:17.994: W/System.err(6081): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 06-04 10:38:17.994: W/System.err(6081): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 06-04 10:38:17.994: W/System.err(6081): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 06-04 10:38:17.994: W/System.err(6081): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:72) 06-04 10:38:17.994: W/System.err(6081): at org.opencv.samples.tutorial2.Tutorial2Activity.onResume(Tutorial2Activity.java:100) 06-04 10:38:17.994: W/System.err(6081): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192) 06-04 10:38:17.994: W/System.err(6081): at android.app.Activity.performResume(Activity.java:5211) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2803) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2842) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2289) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread.access$600(ActivityThread.java:159) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1274) 06-04 10:38:17.994: W/System.err(6081): at android.os.Handler.dispatchMessage(Handler.java:99) 06-04 10:38:17.994: W/System.err(6081): at android.os.Looper.loop(Looper.java:137) 06-04 10:38:17.994: W/System.err(6081): at android.app.ActivityThread.main(ActivityThread.java:5179) 06-04 10:38:17.994: W/System.err(6081): at java.lang.reflect.Method.invokeNative(Native Method) 06-04 10:38:17.994: W/System.err(6081): at java.lang.reflect.Method.invoke(Method.java:525) 06-04 10:38:17.994: W/System.err(6081): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) 06-04 10:38:17.994: W/System.err(6081): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) 06-04 10:38:17.994: W/System.err(6081): at dalvik.system.NativeStart.main(Native Method) 06-04 10:38:17.994: D/OpenCV/StaticHelper(6081): First attempt to load libs fails 06-04 10:38:17.994: D/OCVSample::Activity(6081): Internal OpenCV library not found. Using OpenCV Manager for initialization 06-04 10:38:18.004: D/OpenCVManager/Helper(6081): Service connection created 06-04 10:38:18.004: D/OpenCVManager/Helper(6081): Trying to get library path 06-04 10:38:18.034: D/OpenCVManager/Helper(6081): Trying to get library list 06-04 10:38:18.054: D/OpenCVManager/Helper(6081): Library list: "" 06-04 10:38:18.054: D/OpenCVManager/Helper(6081): First attempt to load libs 06-04 10:38:18.054: D/OpenCVManager/Helper(6081): Trying to init OpenCV libs 06-04 10:38:18.054: D/OpenCVManager/Helper(6081): Trying to load library /data/app-lib/org.opencv.engine3-1/libopencv_java.so 06-04 10:38:18.054: D/dalvikvm(6081): Trying to load lib /data/app-lib/org.opencv.engine3-1/libopencv_java.so 0x41f4beb0 06-04 10:38:18.084: D/dalvikvm(6081): Added shared lib /data/app-lib/org.opencv.engine3-1/libopencv_java.so 0x41f4beb0 06-04 10:38:18.084: D/OpenCVManager/Helper(6081): OpenCV libs init was ok! 06-04 10:38:18.084: D/OpenCVManager/Helper(6081): First attempt to load libs is OK 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): General configuration for OpenCV 3.0.0-rc1 ===================================== 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Version control: 3.0.0-rc1 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Platform: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Host: Darwin 13.2.0 i386 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Target: Linux 1 armv7-a 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): CMake: 2.8.12.2 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): CMake generator: Ninja 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): CMake build tool: /usr/local/bin/ninja 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Configuration: Release 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C/C++: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Built as dynamic libs?: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C++ Compiler: /usr/local/bin/ccache /opt/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ (ver 4.7) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C++ flags (Release): -fexceptions -frtti -fpic -Wno-psabi --sysroot=/opt/android/android-ndk-r8e/platforms/android-8/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -fomit-frame-pointer -mfpu=neon -fvisibility=hidden -fvisibility-inlines-hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C++ flags (Debug): -fexceptions -frtti -fpic -Wno-psabi --sysroot=/opt/android/android-ndk-r8e/platforms/android-8/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -fomit-frame-pointer -mfpu=neon -fvisibility=hidden -fvisibility-inlines-hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C Compiler: /usr/local/bin/ccache /opt/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C flags (Release): -fexceptions -fpic -Wno-psabi --sysroot=/opt/android/android-ndk-r8e/platforms/android-8/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -mfpu=neon -fvisibility=hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): C flags (Debug): -fexceptions -fpic -Wno-psabi --sysroot=/opt/android/android-ndk-r8e/platforms/android-8/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -mfpu=neon -fvisibility=hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Precompiled headers: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): OpenCV modules: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): To be built: hal core flann imgproc ml photo video androidcamera imgcodecs shape videoio highgui objdetect superres ts features2d calib3d java stitching videostab 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Disabled: world 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Disabled by dependency: - 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 viz 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Android: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Android ABI: armeabi-v7a with NEON 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): STL type: gnustl_static 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Native API level: android-8 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): SDK target: android-14 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Android NDK: /opt/android/android-ndk-r8e (toolchain: arm-linux-androideabi-4.7) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): android tool: /opt/android/android-sdk-macosx/tools/android (Android SDK Tools, revision 24.1.2.) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Google Play package: YES 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Android examples: YES 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): GUI: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): GTK+: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): GThread : NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): GtkGlExt: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): OpenGL support: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): VTK support: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Media I/O: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): ZLib: z (ver 1.2.3) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): JPEG: build (ver 90) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): WEBP: build (ver 0.3.1) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): PNG: build (ver 1.5.12) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): TIFF: build (ver 42 - 4.0.2) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): JPEG 2000: build (ver 1.900.1) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): OpenEXR: build (ver 1.7.1) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): GDAL: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Video I/O: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): AndroidNativeCamera: YES, use prebuilt libraries 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Other third-party libraries: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use IPP: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use Eigen: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use TBB: YES (ver 4.1 interface 6102) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use OpenMP: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use GCD NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use Concurrency NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use C=: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use Cuda: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Use OpenCL: NO 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Python 2: 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Interpreter: /usr/bin/python2.7 (ver 2.7.5) 06-04 10:38:18.084: I/OpenCVManager/Helper(6081): Python 3: 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Interpreter: NO 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Python (for build): /usr/bin/python2.7 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Java: 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): ant: /usr/local/bin/ant (ver 1.9.4) 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Java wrappers: YES 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Java tests: YES 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Matlab: 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): mex: NO 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Documentation: 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Doxygen: NO 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): PlantUML: NO 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Tests and samples: 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Tests: YES 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Performance tests: YES 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): C/C++ Examples: NO 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): Install path: /builds/master_pack-android/build/o4a/install 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): cvconfig.h is in: /builds/master_pack-android/build/o4a 06-04 10:38:18.094: I/OpenCVManager/Helper(6081): ----------------------------------------------------------------- 06-04 10:38:18.094: D/OpenCVManager/Helper(6081): Init finished with status 0 06-04 10:38:18.094: D/OpenCVManager/Helper(6081): Unbind from service 06-04 10:38:18.094: D/OpenCVManager/Helper(6081): Calling using callback 06-04 10:38:18.094: I/OCVSample::Activity(6081): OpenCV loaded successfully 06-04 10:38:18.094: D/AndroidRuntime(6081): Shutting down VM 06-04 10:38:18.094: W/dalvikvm(6081): threadid=1: thread exiting with uncaught exception (group=0x415a9898)
里边有warning:
W/System.err(6081): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.tutorial2-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.tutorial2-2, /vendor/lib, /system/lib]]]: findLibrary returned null
是获取本地liabrary失效,改为通过OpenCVManager获取opencv_java 库。成功
以下error是OpenCV初始化成功以后,又加载了mixed_sample库。报错。
06-04 10:38:18.104: E/AndroidRuntime(6081): FATAL EXCEPTION: main 06-04 10:38:18.104: E/AndroidRuntime(6081): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.tutorial2-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.tutorial2-2, /vendor/lib, /system/lib]]]: findLibrary returned null 06-04 10:38:18.104: E/AndroidRuntime(6081): at java.lang.Runtime.loadLibrary(Runtime.java:355) 06-04 10:38:18.104: E/AndroidRuntime(6081): at java.lang.System.loadLibrary(System.java:525) 06-04 10:38:18.104: E/AndroidRuntime(6081): at org.opencv.samples.tutorial2.Tutorial2Activity$1.onManagerConnected(Tutorial2Activity.java:49) 06-04 10:38:18.104: E/AndroidRuntime(6081): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:319) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1106) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1123) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.os.Handler.handleCallback(Handler.java:730) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.os.Handler.dispatchMessage(Handler.java:92) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.os.Looper.loop(Looper.java:137) 06-04 10:38:18.104: E/AndroidRuntime(6081): at android.app.ActivityThread.main(ActivityThread.java:5179) 06-04 10:38:18.104: E/AndroidRuntime(6081): at java.lang.reflect.Method.invokeNative(Native Method) 06-04 10:38:18.104: E/AndroidRuntime(6081): at java.lang.reflect.Method.invoke(Method.java:525) 06-04 10:38:18.104: E/AndroidRuntime(6081): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) 06-04 10:38:18.104: E/AndroidRuntime(6081): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) 06-04 10:38:18.104: E/AndroidRuntime(6081): at dalvik.system.NativeStart.main(Native Method)
case LoaderCallbackInterface.SUCCESS: { Log.i(TAG, "OpenCV loaded successfully"); // Load native library after(!) OpenCV initialization System.loadLibrary("mixed_sample"); //如果注释了这个加载。会导致菜单功能的最后一项不可用。 mOpenCvCameraView.enableView(); } break;
在目录下执行ndk-build。生成了obj文件夹。并且在libs/armeabi-v7a/目录下生成了libmixed_sample.so
再运行工程。成功
06-04 11:10:16.054: D/dalvikvm(10433): Trying to load lib /data/app-lib/org.opencv.samples.tutorial2-1/libmixed_sample.so 0x41f52568
06-04 11:10:16.054: D/dalvikvm(10433): Shared lib '/data/app-lib/org.opencv.samples.tutorial2-1/libmixed_sample.so' already loaded in same CL 0x41f52568