building android-opencv with dependency on shared opencv libs (built for android) and CVCamera

151 views
Skip to first unread message

Zafer

unread,
Jul 7, 2011, 3:46:14 AM7/7/11
to android-opencv
Hello,
I compiled opencv for android as shared libraries. Then I compiled
android-opencv with these shared libraries.
Afterwards, I built CVCamera sample application with no change in the
configuration files. It builts fine but when I try to run it in the
device. It force closes. I checked the logcat output and observed that
it gives unsatisfied link error when trying to load libandroid-
opencv.so. It says

Caused by: java.lang.UnsatisfiedLinkError: Cannot load library:
link_image[1963]: 242 could not load needed library
'libopencv_contrib.so' for 'libandroid-opencv.so' (load_library[1105]:
Library 'libopencv_contrib.so' not found)

I put all opencv .so files in the libs folder of the project and can
see that they are loaded in the apk. Still, it cannot find the opencv
shared libs.

What is the problem and what kind of configuration change should I
make?

Thanks
Zafer



Andrey Kamaev

unread,
Jul 7, 2011, 4:51:39 AM7/7/11
to android-opencv
Hi,

First of all you should explicitly load all OpenCV libraries not only
libandroid-opencv.so
Second, there are dependencies between OpenCV modules. So try load
libraries in this order:
opencv_core
opencv_flann
opencv_imgproc
opencv_ml
opencv_highgui
opencv_video
opencv_features2d
opencv_calib3d
opencv_objdetect
opencv_legacy
opencv_contrib

I'm not sure which modules are really needed by android-opencv. I
think legacy, contrib and probably some other modules can be omitted.

Any way OpenCV compiled as shared libraries requires more space on
device. So static build is currently recommended for OpenCV for
Android.

Zafer

unread,
Jul 7, 2011, 10:19:52 AM7/7/11
to android-opencv
Thanks for the very useful reply.
Indeed, it worked after loading the libraries in the given order
before libandroid-opencv.so
I modified cvcamera.i file to include these opencv libs before
System.loadlibrary("android-opencv");
It worked this way, I guess it is the way to load them.

Also, thanks for the hint about using shared or static libraries.

Best,
Zafer
Reply all
Reply to author
Forward
0 new messages