Ask Your Question
0

Problems using libnative_camera on Android

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

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 "libnative_camera_r4.1.1.so" and "libNativeCamera.so" 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 android.mk 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)


#OPENCV_CAMERA_MODULES:=on
#OPENCV_INSTALL_MODULES:=on
#OPENCV_LIB_TYPE:=STATIC
include $(SDK_JNI_DIR)/OpenCV.mk

### CAMERA MODULE
include $(CLEAR_VARS)
LOCAL_MODULE := camera-prebuilt
LOCAL_SRC_FILES = build/libs/$(TARGET_ARCH_ABI)/libnative_camera_r4.1.1.so
include $(PREBUILT_SHARED_LIBRARY)
### END CAMERA MODULE

OPENGLES_LIB  := -lGLESv1_CM
OPENGLES_DEF  := -DUSE_OPENGL_ES_1_1

LOCAL_MODULE    := NativeCamera
LOCAL_SRC_FILES := CameraRenderer.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += $(OPENGLES_LIB) -llog -ldl
include $(BUILD_SHARED_LIBRARY)

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

alvise

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

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

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

Comments

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 -0600 )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 -0600 )edit

Question Tools

Stats

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

Seen: 2,834 times

Last updated: Mar 18 '13