Ask Your Question

Android : Native OpenCV

asked 2012-09-03 04:56:01 -0600

Bia6969 gravatar image

updated 2012-09-03 05:06:23 -0600

When we are programing for Android and we want to use Opencv in the native code, the api for calling the Opencv structures and methods isn't the same used by c++ for Opencv for Linux,is it? Because i've been trying to compile a cpp (native) file based on one detect.cpp file which i used back when i was running opencv on ubuntu.

Any insight would be welcome. Thanks!

edit retag flag offensive close merge delete


Maybe the version you used on ubuntu is different (older) from the one you are using now? You should post here any errors you have so we can see what is wrong.

Rui Marques gravatar imageRui Marques ( 2012-09-03 13:01:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-03 07:06:23 -0600

Morty gravatar image


the OpenCV Android native api is the same as the standard c++ api. I have a c++ class which is used to create panorama images in real-time. The class uses lots of OpenCV's functions and data structures and can be compiled for Android and my PC without any platform dependent code. Some OpenCV modules, e.g. the gpu module, are not supported on Android. Maybe you are using some of these unsupported modules in your code.

Best regards,


edit flag offensive delete link more


Hi. Thanks for the answer!!

I'm calling all opencv stuff within a function like this: JNIEXPORT cv::Mat JNICALL Java_com_example_display_Display_bee (JNIEnv * env, jobject obj, cv::Mat frame){ ... }

is this the wrong approach? Should i make a class that would be called from that function? Or is it up to me?

Bia6969 gravatar imageBia6969 ( 2012-09-03 08:15:39 -0600 )edit


I would suggest that you have a look at the samples which are included in the OpenCV4Android SDK. I think there are 3 samples included which make calls to JNI. At least for me these samples were a great help. The OpenCV Documentation contains a nice tutorial on how to setup these samples in Eclipse:


Best regards,


Morty gravatar imageMorty ( 2012-09-03 10:12:39 -0600 )edit

Question Tools


Asked: 2012-09-03 04:56:01 -0600

Seen: 605 times

Last updated: Sep 03 '12