Ask Your Question

Problems using libnative_camera on Android

asked 2013-03-18 10:49:42 -0500

alvise gravatar image

Hi all, after a lot of searching and tries I didn't manage to solve my problem. I'm trying to use the native camera module (through cv::VideoCapture initiated in a C++ source file) in an Android 4.1 project using JNI. I'm using Eclipse and everything compile, both "" and "" module are included in the compiled APK inside the lib/armeabi-v7a/ folder. However, I get this message error in the logcat when I try to run it:

03-18 16:33:07.367: W/dalvikvm(18039): No implementation found for native Lorg/opencv/highgui/VideoCapture;.n_VideoCapture:(I)J
03-18 16:33:07.372: W/dalvikvm(18039): threadid=1: thread exiting with uncaught exception (group=0x40e262d0)
03-18 16:33:07.372: E/AndroidRuntime(18039): java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.highgui.VideoCapture.n_VideoCapture:(I)J

I'm quite sure that all the JNI methods defined by me link properly.
Why this error happens before the load of the OpenCV libraries by the OpenCVManager?
This is my file:

LOCAL_PATH  := $(call my-dir)
SDK_DIR     := /home/alvise/android/OpenCV-2.4.4-android-sdk
SDK_JNI_DIR := $(SDK_DIR)/sdk/native/jni

include $(CLEAR_VARS)

include $(SDK_JNI_DIR)/

include $(CLEAR_VARS)
LOCAL_MODULE := camera-prebuilt


LOCAL_MODULE    := NativeCamera
LOCAL_SRC_FILES := CameraRenderer.cpp

The java and C++ part is quite common and I don't think that could help... Thank you in advance for any help!


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-18 12:24:06 -0500

java.lang.UnsatisfiedLinkError: Native method not found exception for any OpenCV class or function means, that you tries to use it or construct object before library initialization. In you case you tries to construct VideoCapture in View constructor, or some other place, when OpenCV is not ready. I recommend you to construct your OpenCV-related view and other related objects in on onManagerConnected callback like it is done in all samples.

edit flag offensive delete link more


yes, you are right...I was misunderstanding the use of the callback. However now I'm facing another problem, I need the onPause() and onResume() methods to call onResume() and onPause() of a GLSurfaceView object, but, since the callback doesn't returned yet (and so the GLSurfaceView has not its renderer), I have some nullPointerException. Is there a way to make the callback a blocking call? Maybe I'm using the wrong approach? Thank you Alexander

alvise gravatar imagealvise ( 2013-03-18 13:06:57 -0500 )edit

You need to create subclass of JavaCameraView or NativeCameraView and implement your own onPause and onResume handlers to start and stop view correctly.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-03-19 04:20:30 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-03-18 10:49:42 -0500

Seen: 2,332 times

Last updated: Mar 18 '13