Issue
I am trying to run a sample program with opencv for image acquisition. But I got the build error.
D:\Work\Code\Practice\Android\CornerDetector\app\src\main\jni\opencv2\core\base.hpp
Error:(53, 21) algorithm: No such file or directory
Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include D:\Work\Code\Addons\ZAndroid\OpenCV-android-sdk\sdk\native\jni\OpenCV.mk
LOCAL_MODULE := mCameraSlider
LOCAL_SRC_FILES := src/driver_android_slider.c \
src/driver_android_camera.cpp \
src/driver_android_display.cpp \
src/main.c \
src/mCameraSlider.c \
src/corner/myCorners.c \
LOCAL_C_INCLUDES += $(LOCAL_PATH)\src\include \
$(LOCAL_PATH)\src\corner \
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_PLATFORM :=android-9
Some drivers for android camera is using opencv2/core/core.hpp, therefore opencv2 directory is place under jni.
#include <jni.h>
#include <stdlib.h>
#include <android/log.h>
#include <opencv2/core/core.hpp>
extern JavaVM *cachedJvm;
extern jobject cachedActivityObj;
extern jclass cachedMainActivityCls;
typedef struct _CameraContext
{
jmethodID CameraGetInputBufferID;
jmethodID InitCameraID;
int Width;
int Height;
int Location;
cv::Mat Temp;
cv::Mat Repo;
} CameraContext;
When doing ndk build getting this:
I think I am doing something wrong in using opencv, maybe android.mk but not sure. Kindly help.
UPDATE:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.mohantysolutions.cornerdetector"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile project(':libraries:opencv')
}
Solution
Problem was I missed the configuration in gradle to include jni srcDir. Once I added the below code to gradle, everything works fine.
sourceSets.main{
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
I hope this may prove helpful to someone.
Answered By - MKMohanty
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.