不熟悉 Android NDK Caffe ,我想在我的 Android 项目中使用内置版本。我试图运行 this built sample demo , 但在运行时,它显示以下内容:
03-26 14:46:35.697 2800-3042/com.sh1r0.caffe_android_demo A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 3042 (AsyncTask #1)
(应用程序崩溃)
最佳答案
我可以看到 sigsev 信号是通过 android AsyncTask 抛出的。 问题可能出在这个函数上。
caffeMobile.predictImage(strings[0])[0]; //line 160 of MainActivity
此信号来自 JNI,除非您可以本地(通过 ndk)调试应用程序,否则很难知道问题出在哪里。 caffe-sample 未配置为在 native 方法上进行调试。
尝试这个问题来管理错误:
Ensure that your image path in this string[0] arrays are not empty. and exists.
Ensure that the other caffeMobile functions are able to exec without problems, for example:
caffeMobile = new CaffeMobile();
caffeMobile.setNumThreads(4);
caffeMobile.loadModel("/sdcard/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt", "/sdcard/caffe_mobile/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel");
如果您能够执行其他功能,可能是您的图像路径不正确,请检查。
如果您无法执行 loadModel 或 setNumThreads 函数,可能是 apk 未正确加载 libjni.so 库,或者 jni 桥无法定位 jni 函数。
关于Android caffe 搭建demo 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29274823/