sh1r0/caffe-android-demo

Errors in libcaffe.so

x0chen opened this issue · 2 comments

The size of libcaffe.so in caffe-android-demo is 6.9Mb (call it demo:libcaffe.so), and the one build by caffe-android-lib is about 8.8Mb(call it source:libcaffe.so), and I found something different.

Q1:
I tried to edit the CaffeMobile class, so as to support using two or more models (since the original one is singleton). When running the predict function in a new thread using source:libcaffe.so, there was an error:
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x28 in tid 22937 (Thread-1670)
The error disappeared when using demo:libcaffe.so or running the predict function in the main thread of Android(for both libcaffe.so files).

Q2:
So I replaced the source:libcaffe.so with demo:libcaffe.so, the problem in Q1 solved. But a new problem appeared:
When using CascadeClassifier::detectMultiScale function in OpenCV, there was an error in the OpenCV image resize function:
E/cv::error(): OpenCV Error: Bad argument (Unknown interpolation method) in void cv::resize(cv::InputArray, cv::OutputArray, cv::Size, double, double, int), file /Users/shiro/caffe-android-lib/opencv/modules/imgproc/src/imgwarp.cpp, line 3374
There was no such error when using source:libcaffe.so.

I don't know what to do with the files in caffe-android-lib to solve the problem in Q1? Please give me help. Thank you very much~~~

sh1r0 commented

For the size difference, it's basically due to your build environment. In my case, I'm sure the libs in this demo project are the same as the ones built on the dev branch of caffe-android-lib.

A1:
Since I could not have a clear idea about your modification, I might not give you a certain answer.

A2:
As for the OpenCV issues, please ensure that you have objdetect module linked correctly (refer to sh1r0/caffe-android-lib#43). BTW, OpenCV 3.1.0 is used in caffe-android-lib.

Note: I'll recommend this kind of issue to be posted in https://github.com/sh1r0/caffe-android-lib/issues instead.

Thanks.

Thank you very much for reply!

For Q1, I only modified the files in the directory /caffe-android-lib/caffe/android, theoretically libcaffe.so should not be changed. Is this true?
But I rebuild the whole project using OpenBLAS, as you said in caffe-android-lib. The problem disappeared. Is it the difference between Eigen and BLAS which brought the problem? I have found some issues in https://github.com/sh1r0/caffe-android-lib/issues useful to learn about Eigen and BLAS, and I will learn from them.

For Q2, there is no problem using CascadeClassifier::detectMultiScale now.

Your projects and issues gave me a big help, thanks a lot again!