OpenCV4Android 不需要安装OpenCVManager,就可以运行的方法
http://blog.csdn.net/yanzi1225627/article/details/27863615
OpenCV4Android释疑: 透析Android以JNI调OpenCV的三种方式(让OpenCVManager永不困扰)
根据上文中的方法。使用OpenCV3.0.0
Android.mk文件为:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) OpenCV_INSTALL_MODULES:=on OPENCV_CAMERA_MODULES:=off OPENCV_LIB_TYPE:=STATIC //静态没有成功,改为SHARED可以 ifeq ("$(wildcard $(OPENCV_MK_PATH))","") include /home/myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk //为了编译依赖OpenCV的so else include $(OPENCV_MK_PATH) endif LOCAL_MODULE := TestOpenCV //生成so的名 LOCAL_SRC_FILES := jni_part.cpp //jni下的cpp文件名 LOCAL_LDLIBS += -lm -llog include $(BUILD_SHARED_LIBRARY)
出现以下几种形式的错误
(1)OPENCV_LIB_TYPE:=STATIC 报了以下一堆错误
:~/workspace/TestOpenCV$ ndk-build Compile++ thumb : TestOpenCV <= jni_part.cpp SharedLibrary : libTestOpenCV.so Install : libTestOpenCV.so => libs/armeabi-v7a/libTestOpenCV.so lenovo-myc@lenovomyc-Lenovo-Product:~/workspace/TestOpenCV$ ndk-build Install : libTestOpenCV.so => libs/armeabi-v7a/libTestOpenCV.so lenovo-myc@lenovomyc-Lenovo-Product:~/workspace/TestOpenCV$ ndk-build Install : libTestOpenCV.so => libs/armeabi-v7a/libTestOpenCV.so lenovo-myc@lenovomyc-Lenovo-Product:~/workspace/TestOpenCV$ ndk-build Compile++ thumb : TestOpenCV <= jni_part.cpp Prebuilt : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/ SharedLibrary : libTestOpenCV.so Install : libTestOpenCV.so => libs/armeabi-v7a/libTestOpenCV.so lenovo-myc@lenovomyc-Lenovo-Product:~/workspace/TestOpenCV$ ndk-build Compile++ thumb : TestOpenCV <= jni_part.cpp Prebuilt : libopencv_shape.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_stitching.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_objdetect.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_superres.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_ts.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_videostab.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_calib3d.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_features2d.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_highgui.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_videoio.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_imgcodecs.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_androidcamera.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_video.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_photo.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_ml.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_imgproc.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_flann.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_core.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : libopencv_hal.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/armeabi-v7a/ Prebuilt : liblibjpeg.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : liblibwebp.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : liblibpng.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : liblibtiff.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : liblibjasper.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : libIlmImf.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ Prebuilt : libtbb.a <= /home/lenovo-myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/jni/../3rdparty/libs/armeabi-v7a/ SharedLibrary : libTestOpenCV.so /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_features2d.a(fast.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_features2d.a(fast_score.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_features2d.a(feature2d.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_features2d.a(keypoint.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_features2d.a(opencl_kernels_features2d.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_imgproc.a(color.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_imgproc.a(demosaicing.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_imgproc.a(drawing.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_imgproc.a(hershey_fonts.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_imgproc.a(tables.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(algorithm.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(alloc.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(convert.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(copy.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(datastructs.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(mathfuncs.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(matrix.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(opengl.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(parallel.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(persistence.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(stat.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(stl.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(system.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(umatrix.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(arithm.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(array.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(cuda_gpu_mat.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(cuda_host_mem.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(cuda_stream.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(kmeans.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(lapack.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(matmul.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(matop.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(pca.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(rand.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_core.a(tables.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_hal.a(mathfuncs.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_hal.a(matrix.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libopencv_hal.a(stat.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(governor.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(market.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(private_server.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(scheduler.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(task.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(task_group_context.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(tbb_main.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(tbb_misc.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(rml_tbb.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(arena.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(cache_aligned_allocator.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(dynamic_link.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(observer_proxy.cpp.o): Unknown EABI object attribute 34 /home/lenovo-myc/android_developer_tools/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Warning: ./obj/local/armeabi-v7a/libtbb.a(spin_rw_mutex.cpp.o): Unknown EABI object attribute 34 ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::Kernel::set(int, cv::ocl::Image2D const&)': ocl.cpp:(.text._ZN2cv3ocl6Kernel3setEiRKNS0_7Image2DE+0x28): undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::_checkSizeOfReservedEntries()': ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE27_checkSizeOfReservedEntriesEv[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::_checkSizeOfReservedEntries()]+0x22): undefined reference to `std::__detail::_List_node_base::_M_unhook()' ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::setMaxReservedSize(unsigned int)': ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE18setMaxReservedSizeEj[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::setMaxReservedSize(unsigned int)]+0x46): undefined reference to `std::__detail::_List_node_base::_M_unhook()' ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::release(_cl_mem*)': ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE7releaseES5_[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::release(_cl_mem*)]+0x40): undefined reference to `std::__detail::_List_node_base::_M_unhook()' ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE7releaseES5_[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::release(_cl_mem*)]+0xe4): undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::_findAndRemoveEntryFromReservedList(cv::ocl::CLBufferEntry&, unsigned int)': ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE35_findAndRemoveEntryFromReservedListERS3_j[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::_findAndRemoveEntryFromReservedList(cv::ocl::CLBufferEntry&, unsigned int)]+0x54): undefined reference to `std::__detail::_List_node_base::_M_unhook()' ocl.cpp:(.text._ZN2cv3ocl24OpenCLBufferPoolBaseImplINS0_20OpenCLBufferPoolImplENS0_13CLBufferEntryEP7_cl_memE35_findAndRemoveEntryFromReservedListERS3_j[cv::ocl::OpenCLBufferPoolBaseImpl<cv::ocl::OpenCLBufferPoolImpl, cv::ocl::CLBufferEntry, _cl_mem*>::_findAndRemoveEntryFromReservedList(cv::ocl::CLBufferEntry&, unsigned int)]+0x8e): undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' ./obj/local/armeabi-v7a/libopencv_core.a(ocl.cpp.o): In function `cv::ocl::OpenCLBufferPoolImpl::_allocateBufferEntry(cv::ocl::CLBufferEntry&, unsigned int)': ocl.cpp:(.text._ZN2cv3ocl20OpenCLBufferPoolImpl20_allocateBufferEntryERNS0_13CLBufferEntryEj[cv::ocl::OpenCLBufferPoolImpl::_allocateBufferEntry(cv::ocl::CLBufferEntry&, unsigned int)]+0x8a): undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' collect2: ld returned 1 exit status make: *** [obj/local/armeabi-v7a/libTestOpenCV.so] Error 1
没解决
(2)改为 OPENCV_LIB_TYPE:=SHARED之后。编译通过。工程下生成 libs 和 obj目录下的文件
(3)修改Activity文件如下:
package com.example.testopencv; import org.opencv.android.BaseLoaderCallback; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; import org.opencv.android.Utils; import org.opencv.core.Mat; import org.opencv.imgproc.Imgproc; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; /** * 图像灰度化demo * * @author myc * */ public class NoManagerOpenCVActivity extends Activity{ Button btnProcess; Bitmap srcBitmap; Bitmap grayBitmap; ImageView imgHuaishi; private static boolean flag = true; private boolean isFirst = true; private static final String TAG = "NoManagerActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_main); initUI(); btnProcess.setOnClickListener(new ProcessClickListener()); } // OpenCV库加载并初始化成功后的回调函数 private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { // TODO Auto-generated method stub switch (status) { case BaseLoaderCallback.SUCCESS: Log.i(TAG, "成功加载"); break; default: super.onManagerConnected(status); Log.i(TAG, "加载失败"); break; } } }; public void initUI() { btnProcess = (Button) findViewById(R.id.btn_gray_process); imgHuaishi = (ImageView) findViewById(R.id.img_huaishi); Log.i(TAG, "initUI sucess..."); } public void procSrc2Gray() { Mat rgbMat = new Mat(); Mat grayMat = new Mat(); srcBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.nanhuaijin); grayBitmap = Bitmap.createBitmap(srcBitmap.getWidth(), srcBitmap.getHeight(), Config.RGB_565); Utils.bitmapToMat(srcBitmap, rgbMat);// convert original bitmap to Mat, // R G B. Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY);// rgbMat to // gray // grayMat Utils.matToBitmap(grayMat, grayBitmap); // convert mat to bitmap Log.i(TAG, "procSrc2Gray sucess..."); } private class ProcessClickListener implements OnClickListener { @Override public void onClick(View v) { // TODO Auto-generated method stub if (isFirst) { procSrc2Gray(); isFirst = false; } if (flag) { imgHuaishi.setImageBitmap(grayBitmap); btnProcess.setText("查看原图"); flag = false; } else { imgHuaishi.setImageBitmap(srcBitmap); btnProcess.setText("灰度化"); flag = true; } } } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); } public native void FindFeatures(long matAddrGr, long matAddrRgba); }
将OpenCVLoader.initAsync 这句注释掉,因为这句是使用OpenCVManager的。
修改为加载刚生成的库 System.loadLibrary("TestOpenCV");
(4)需要将 /home/myc/Documents/sdk/openCV/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/opencv_java.so 拷到libs路径下
(和LibTestOpenCV.so一起)。如果没有拷过来,会报如下错误:
06-04 16:08:47.956: I/NoManagerActivity(5497): initUI sucess... 06-04 16:08:47.956: I/NoManagerActivity(5497): OpenCV library load! 06-04 16:08:47.956: D/OpenCV/StaticHelper(5497): Trying to get library list 06-04 16:08:47.966: E/OpenCV/StaticHelper(5497): OpenCV error: Cannot load info library for OpenCV 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): Library list: "" 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): First attempt to load libs 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): Trying to init OpenCV libs 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): Trying to load library opencv_java 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): Cannot load library "opencv_java" 06-04 16:08:47.966: W/System.err(5497): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.testopencv-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testopencv-1, /vendor/lib, /system/lib]]]: findLibrary returned null 06-04 16:08:47.966: W/System.err(5497): at java.lang.Runtime.loadLibrary(Runtime.java:355) 06-04 16:08:47.966: W/System.err(5497): at java.lang.System.loadLibrary(System.java:525) 06-04 16:08:47.966: W/System.err(5497): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 06-04 16:08:47.966: W/System.err(5497): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 06-04 16:08:47.966: W/System.err(5497): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 06-04 16:08:47.966: W/System.err(5497): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:72) 06-04 16:08:47.966: W/System.err(5497): at com.example.testopencv.NoManagerActivity.onResume(NoManagerActivity.java:127) 06-04 16:08:47.966: W/System.err(5497): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192) 06-04 16:08:47.966: W/System.err(5497): at android.app.Activity.performResume(Activity.java:5211) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2803) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2842) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2289) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread.access$600(ActivityThread.java:159) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1274) 06-04 16:08:47.966: W/System.err(5497): at android.os.Handler.dispatchMessage(Handler.java:99) 06-04 16:08:47.966: W/System.err(5497): at android.os.Looper.loop(Looper.java:137) 06-04 16:08:47.966: W/System.err(5497): at android.app.ActivityThread.main(ActivityThread.java:5179) 06-04 16:08:47.966: W/System.err(5497): at java.lang.reflect.Method.invokeNative(Native Method) 06-04 16:08:47.966: W/System.err(5497): at java.lang.reflect.Method.invoke(Method.java:525) 06-04 16:08:47.966: W/System.err(5497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) 06-04 16:08:47.966: W/System.err(5497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) 06-04 16:08:47.966: W/System.err(5497): at dalvik.system.NativeStart.main(Native Method) 06-04 16:08:47.966: D/OpenCV/StaticHelper(5497): First attempt to load libs fails 06-04 16:08:47.966: I/NoManagerActivity(5497): OpenCV load not successfully
注:在OpenCV Library - 3.0.0-rc1 工程的 StaticHelper.java 中有如下代码:
// If dependencies list is not defined or empty.
result &= loadLibrary("opencv_java");
即在OpenCVLoader初始化过程中,dependencies list 未定义或者为空的情况下,都会默认加载Libopencv_java.so
因此即使Activity中 System.loadLibrary("opencv_java"); 这句被注释掉,还是会报错。
(5)下边这个错调了半天,发现将 System.loadLibrary("TestOpenCV");写成了 System.loadLibrary("LibTestOpenCV");
应该和 LOCAL_MODULE := TestOpenCV 一致
06-04 15:58:56.206: I/NoManagerActivity(3993): initUI sucess... 06-04 15:58:56.206: I/NoManagerActivity(3993): OpenCV library load! 06-04 15:58:56.206: D/dalvikvm(3993): Trying to load lib /data/app-lib/com.example.testopencv-1/libopencv_java.so 0x41f4ae80 06-04 15:58:56.236: D/dalvikvm(3993): Added shared lib /data/app-lib/com.example.testopencv-1/libopencv_java.so 0x41f4ae80 06-04 15:58:56.236: I/NoManagerActivity(3993): start loading libTestOpenCV 06-04 15:58:56.236: D/AndroidRuntime(3993): Shutting down VM 06-04 15:58:56.236: W/dalvikvm(3993): threadid=1: thread exiting with uncaught exception (group=0x415a9898) 06-04 15:58:56.236: E/AndroidRuntime(3993): FATAL EXCEPTION: main 06-04 15:58:56.236: E/AndroidRuntime(3993): java.lang.UnsatisfiedLinkError: Couldn't load libTestOpenCV from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.testopencv-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testopencv-1, /vendor/lib, /system/lib]]]: findLibrary returned null 06-04 15:58:56.236: E/AndroidRuntime(3993): at java.lang.Runtime.loadLibrary(Runtime.java:355) 06-04 15:58:56.236: E/AndroidRuntime(3993): at java.lang.System.loadLibrary(System.java:525) 06-04 15:58:56.236: E/AndroidRuntime(3993): at com.example.testopencv.NoManagerActivity.onResume(NoManagerActivity.java:132) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.Activity.performResume(Activity.java:5211) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2803) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2842) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2289) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread.access$600(ActivityThread.java:159) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1274) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.os.Handler.dispatchMessage(Handler.java:99) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.os.Looper.loop(Looper.java:137) 06-04 15:58:56.236: E/AndroidRuntime(3993): at android.app.ActivityThread.main(ActivityThread.java:5179) 06-04 15:58:56.236: E/AndroidRuntime(3993): at java.lang.reflect.Method.invokeNative(Native Method) 06-04 15:58:56.236: E/AndroidRuntime(3993): at java.lang.reflect.Method.invoke(Method.java:525) 06-04 15:58:56.236: E/AndroidRuntime(3993): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) 06-04 15:58:56.236: E/AndroidRuntime(3993): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610) 06-04 15:58:56.236: E/AndroidRuntime(3993): at dalvik.system.NativeStart.main(Native Method)
(6)成功的log
06-04 16:01:22.966: I/NoManagerActivity(4301): initUI sucess... 06-04 16:01:22.966: I/NoManagerActivity(4301): OpenCV library load! 06-04 16:01:22.966: D/OpenCV/StaticHelper(4301): Trying to get library list 06-04 16:01:22.966: E/OpenCV/StaticHelper(4301): OpenCV error: Cannot load info library for OpenCV 06-04 16:01:22.966: D/OpenCV/StaticHelper(4301): Library list: "" 06-04 16:01:22.966: D/OpenCV/StaticHelper(4301): First attempt to load libs 06-04 16:01:22.966: D/OpenCV/StaticHelper(4301): Trying to init OpenCV libs 06-04 16:01:22.966: D/OpenCV/StaticHelper(4301): Trying to load library opencv_java 06-04 16:01:22.966: D/dalvikvm(4301): Trying to load lib /data/app-lib/com.example.testopencv-1/libopencv_java.so 0x41f4c9f8 06-04 16:01:22.996: D/dalvikvm(4301): Added shared lib /data/app-lib/com.example.testopencv-1/libopencv_java.so 0x41f4c9f8 06-04 16:01:22.996: D/OpenCV/StaticHelper(4301): Library opencv_java loaded 06-04 16:01:22.996: D/OpenCV/StaticHelper(4301): First attempt to load libs is OK 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): General configuration for OpenCV 3.0.0-rc1 ===================================== 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Version control: 3.0.0-rc1 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Platform: 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Host: Darwin 13.2.0 i386 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Target: Linux 1 armv7-a 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): CMake: 2.8.12.2 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): CMake generator: Ninja 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): CMake build tool: /usr/local/bin/ninja 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Configuration: Release 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): C/C++: 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Built as dynamic libs?: NO 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): C++ Compiler: /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 16:01:22.996: I/OpenCV/StaticHelper(4301): 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=vfpv3-d16 -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 -fvisibility=hidden -fvisibility-inlines-hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): 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=vfpv3-d16 -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 -fvisibility=hidden -fvisibility-inlines-hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): C Compiler: /opt/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): 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=vfpv3-d16 -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 -fvisibility=hidden -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): 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=vfpv3-d16 -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 -fvisibility=hidden -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now 06-04 16:01:22.996: I/OpenCV/StaticHelper(4301): Precompiled headers: YES 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): OpenCV modules: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): 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 16:01:23.006: I/OpenCV/StaticHelper(4301): Disabled: world 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Disabled by dependency: - 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 viz 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Android: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Android ABI: armeabi-v7a 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): STL type: gnustl_static 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Native API level: android-8 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): SDK target: android-14 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Android NDK: /opt/android/android-ndk-r8e (toolchain: arm-linux-androideabi-4.7) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): android tool: /opt/android/android-sdk-macosx/tools/android (Android SDK Tools, revision 24.1.2.) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Google Play package: YES 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Android examples: YES 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): GUI: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): GTK+: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): GThread : NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): GtkGlExt: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): OpenGL support: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): VTK support: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Media I/O: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): ZLib: z (ver 1.2.3) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): JPEG: build (ver 90) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): WEBP: build (ver 0.3.1) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): PNG: build (ver 1.5.12) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): TIFF: build (ver 42 - 4.0.2) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): JPEG 2000: build (ver 1.900.1) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): OpenEXR: build (ver 1.7.1) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): GDAL: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Video I/O: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): AndroidNativeCamera: YES, use prebuilt libraries 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Other third-party libraries: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use IPP: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use Eigen: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use TBB: YES (ver 4.1 interface 6102) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use OpenMP: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use GCD NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use Concurrency NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use C=: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use Cuda: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Use OpenCL: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Python 2: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Interpreter: /usr/bin/python2.7 (ver 2.7.5) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Python 3: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Interpreter: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Python (for build): /usr/bin/python2.7 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Java: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): ant: /usr/local/bin/ant (ver 1.9.4) 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Java wrappers: YES 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Java tests: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Matlab: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): mex: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Documentation: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Doxygen: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): PlantUML: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Tests and samples: 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Tests: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Performance tests: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): C/C++ Examples: NO 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): Install path: /builds/master_pack-android/build/o4a/install 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): cvconfig.h is in: /builds/master_pack-android/build/o4a 06-04 16:01:23.006: I/OpenCV/StaticHelper(4301): ----------------------------------------------------------------- 06-04 16:01:23.006: D/dalvikvm(4301): Trying to load lib /data/app-lib/com.example.testopencv-1/libopencv_java.so 0x41f4c9f8 06-04 16:01:23.006: D/dalvikvm(4301): Shared lib '/data/app-lib/com.example.testopencv-1/libopencv_java.so' already loaded in same CL 0x41f4c9f8 06-04 16:01:23.006: I/NoManagerActivity(4301): start loading libTestOpenCV 06-04 16:01:23.006: D/dalvikvm(4301): Trying to load lib /data/app-lib/com.example.testopencv-1/libTestOpenCV.so 0x41f4c9f8 06-04 16:01:23.006: D/dalvikvm(4301): Added shared lib /data/app-lib/com.example.testopencv-1/libTestOpenCV.so 0x41f4c9f8 06-04 16:01:23.006: D/dalvikvm(4301): No JNI_OnLoad found in /data/app-lib/com.example.testopencv-1/libTestOpenCV.so 0x41f4c9f8, skipping init 06-04 16:01:23.006: I/NoManagerActivity(4301): finish loading libTestOpenCV 06-04 16:01:23.006: I/NoManagerActivity(4301): 成功加载 06-04 16:01:23.046: D/libEGL(4301): loaded /vendor/lib/egl/libEGL_adreno.so 06-04 16:01:23.046: D/libEGL(4301): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so 06-04 16:01:23.056: D/libEGL(4301): loaded /vendor/lib/egl/libGLESv2_adreno.so 06-04 16:01:23.056: I/Adreno-EGL(4301): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_3.2.1.4_RB1.04.03.00.187.021_msm8226_JB_3.2.1.4_RB1__release_AU () 06-04 16:01:23.056: I/Adreno-EGL(4301): OpenGL ES Shader Compiler Version: 20.00.03 06-04 16:01:23.056: I/Adreno-EGL(4301): Build Date: 07/11/14 Fri 06-04 16:01:23.056: I/Adreno-EGL(4301): Local Branch: mybranch3810467 06-04 16:01:23.056: I/Adreno-EGL(4301): Remote Branch: quic/jb_3.2.1.4_rb1 06-04 16:01:23.056: I/Adreno-EGL(4301): Local Patches: NONE 06-04 16:01:23.056: I/Adreno-EGL(4301): Reconstruct Branch: AU_LINUX_ANDROID_JB_3.2.1.4_RB1.04.03.00.187.021 + NOTHING 06-04 16:01:23.086: D/OpenGLRenderer(4301): Enabling debug mode 0
(7)当把
Log.i(TAG,"OpenCV library load!"); if (!OpenCVLoader.initDebug()) { Log.i(TAG,"OpenCV load not successfully"); // OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback); } else { // System.loadLibrary("opencv_java"); Log.i(TAG,"start loading libTestOpenCV"); System.loadLibrary("TestOpenCV");// load other libraries Log.i(TAG,"finish loading libTestOpenCV"); mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS); }
修改为
Log.i(TAG,"OpenCV library load!"); System.loadLibrary("opencv_java"); Log.i(TAG,"start loading libTestOpenCV"); System.loadLibrary("TestOpenCV");// load other libraries Log.i(TAG,"finish loading libTestOpenCV"); mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
即跳过 OpenCVLoader.initDebug()过程,打出的log如下:
06-04 15:59:58.616: I/NoManagerActivity(4126): initUI sucess... 06-04 15:59:58.616: I/NoManagerActivity(4126): OpenCV library load! 06-04 15:59:58.616: D/dalvikvm(4126): Trying to load lib /data/app-lib/com.example.testopencv-2/libopencv_java.so 0x41f4b640 06-04 15:59:58.616: D/dalvikvm(4126): Shared lib '/data/app-lib/com.example.testopencv-2/libopencv_java.so' already loaded in same CL 0x41f4b640 06-04 15:59:58.616: I/NoManagerActivity(4126): start loading libTestOpenCV 06-04 15:59:58.616: D/dalvikvm(4126): Trying to load lib /data/app-lib/com.example.testopencv-2/libTestOpenCV.so 0x41f4b640 06-04 15:59:58.616: D/dalvikvm(4126): Shared lib '/data/app-lib/com.example.testopencv-2/libTestOpenCV.so' already loaded in same CL 0x41f4b640 06-04 15:59:58.616: I/NoManagerActivity(4126): finish loading libTestOpenCV 06-04 15:59:58.616: I/NoManagerActivity(4126): 成功加载
Log少了很多(仅为测试)
(8)调试中发现,官方给的Sample中。只用java层接口,没用jni层的例子。比如 OpenCV Sample - image-manipulations
只需要拷进去一个Libopencv_java.so,然后注释掉onResume函数中的initAsync这句。不用OpenCVManager就可以运行了
(怀疑如果功能增多需要拷进去其他so)
@Override public void onResume() { super.onResume(); if (!OpenCVLoader.initDebug()) { Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization"); // OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback); } else { Log.d(TAG, "OpenCV library found inside package. Using it!"); mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS); } }