Expose native C++ OpenCV code to Android - but clever (== less work) way!

asked 2016-06-16 06:55:04 -0500

przemulala gravatar image

Hi fellow coders!

I've written desktop OpenCV-based C++ app that can be described as following blackbox sequence:

Image from camera -> A LOT OF PROCESSING HERE -> std::tuple<std::vector<double> eyesPosition, bool leftEyeClosed, bool rightEyeClosed>

My goal is to re-use this C++ code in an Android app. I've started my research and found some basic stuff on OpenCV Android NDK development and JNI + some samples (namely "Tutorial 2 - Mixed processing). But it isn't still clear to me, if (and how!) I could use my C++ code as aboved descrived blackbox sequence. I still have a lot of work on an app, so I'd like to write as little JNI code as possible. Namely, the perfect solution for me is to expose to JNI only this one C++ function that I've written, which takes in an image and returns tuple - this function call a lot of other functions, creates classes and so on, but maybe I could provide the rest of my C++ code as a dynamic library or sth similar? Sadly, I don't know the answer and haven't found anything like that (samples provided - for ex. face detection - expose the whole C++ code to JNI and I'd be grateful to avoid this).

If you have any ideas, sample code, tutorials that answer my needs - I'd be thankful for providing this resources :)

edit retag flag offensive close merge delete