Android: Do I use native library or not?

asked 2013-04-28 12:52:50 -0500

AAZZ gravatar image

I want to use the native libraries for an Android camera app. But I don't know whether my app uses native or java calls.

I've done what's described here at "Native/C++":

ndk-build did well without errors.

And in the Eclipse package explorer I get an obj directory with (X.X.X stands for version, there are a lot of versions in the directory).

At project properties I added Library "OpenCV Library - 2.4.5". If I additionally check "Is Library" and try to start I get error "Android library projects cannot be laucnched.", if I uncheck "Is Library" I can run app.

a) Why that?

My Activity class implements CvCameraViewListener2 and I imported: import; and import;

The app uses this methods:

static { if (!OpenCVLoader.initDebug()) { // Handle initialization error } } private CameraBridgeViewBase mOpenCvCameraView;

//onCreate: mOpenCvCameraView = (CameraBridgeViewBase) findViewById(; mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this);

//onPause/onDestroy if (mOpenCvCameraView != null) mOpenCvCameraView.disableView();

public Mat onCameraFrame(CvCameraViewFrame inputFrame) { return inputFrame.rgba(); }

But I don't know whether my app uses native calls or not.

Is the inputFrame.rgba() a native call of a C++ library method in or is it a call of a java method of one of the imported libs import or import

b) When it's not a native call: How to do a native call of method rgba(), something like this: System.nativecall(inputFrame.rgba(),

c) When it is a native call: Why it's a lot slower than the standard camera app of my smartphone? I get 14 fps with return inputFrame.rgba() as sole method in onCameraFrame and screen picture is delayed when I pan the camera; with standard camera app ther is no delay.

edit retag flag offensive close merge delete