Correct OpenCV Manager usage for NDK apps

asked 2012-12-09 02:52:57 -0500

ryan0270 gravatar image

I'm updating an Android application from OpenCV-2.4.1 to the latest (OpenCV-2.4.3) and, of course, the most significant change is using the new OpenCV Manager. Following the examples, I can get the manager started but the only library it loads is opencv_java.

For the NDK side of my app I need it to also load several other libraries (e.g. core, imgproc, ...) but I can't figure out how to get the manager to load those libraries. I can manually copy those libs over by putting them in my libs/armeabi-v7a folder, but that kind of defeats the purpose.

Looking at the logcat output I see:

D/OpenCVEngine( 7275): Trying to load info library "/data/data/org.opencv.engine/lib/libopencv_info.so"
D/OpenCVManager/Helper( 7251): Library list: ""
D/OpenCVManager/Helper( 7251): First attempt to load libs
D/OpenCVManager/Helper( 7251): Trying to init OpenCV libs
D/OpenCVManager/Helper( 7251): Trying to load library /data/data/org.opencv.engine/lib/libopencv_java.so
D/OpenCVManager/Helper( 7251): OpenCV libs init was ok!

Which suggests that the library list is somehow contained in the opencv_info library. But that's automatically generated when building OpenCV so I'm not sure how I'm supposed to tell the manager what native libraries I need it to load.

Also, I'm confused as to when the manager is actually loaded. Following the examples, I put

!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback))

in the java onResume() function. This returns true immediately, but the libraries don't seem to actually load until sometime after the onResume() function ends; I confirmed this by putting log outputs inside the onManagerConnected() callback. How do I make things start sooner than that so I can initialize my own stuff in onResume()?

edit retag flag offensive close merge delete