I’m developing an app with native part which uses embedded OpenCV to extract frames from video file. So far I’m getting this error:
.../jni/ocv.c:12: undefined reference to `cvCreateFileCapture'
My Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ocv
LOCAL_SRC_FILES := ocv.c
include $(BUILD_SHARED_LIBRARY)
Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi
ocv.c:
#include <string.h>
#include <jni.h>
#include <stdio.h>
#include <dlfcn.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
jstring Java_com_ice_salvador_MainActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) {
IplImage* currFrame = 0;
CvCapture* cap = 0;
cap = cvCaptureFromFile("/mnt/sdcard/vvv.3gp"); //test video
return (*env)->NewStringUTF(env, "Hello from native code!");
}
I’m using OpenCV-2.4.3-android-sdk, Android NDK r8b, Eclipse Juno, Windows.
IplImage, CvCapture gets resolved and the code compiles if I remove the line with cvCaptureFromFile – so I assume I’m on the right way. I’m new to JNI and OpenCV. Appreciate your help! Thanks.
Not to leave my own question unanswered..
1) I’ve changed Android.mk to include OpenCV.mk from SDK and to include .so lib into the build:
2) Copied libopencv_java.so to jni/ folder.
3) Changed java code to:
And the error has gone.