我是OpenCV和Android NDK的新手。首先是一个示例NDK程序,我写了一个具有本机功能的活动并实现了它,它工作正常。 我能够成功构建并运行它。
但是在CPP文件中,我插入以下标题: -
#include <opencv2/core/core.hpp>
我在eclipse上遇到构建错误: - E:/ software \ java \ android_adt \ OpenCV-2.4.3.2-android-sdk / sdk / native / jni / include / opencv2 / core / core.hpp:56:21:致命错误:算法:没有这样的文件或目录 编译终止。 make: [obj / local / armeabi / objs / OpenCVTest / OpenCVTest.o]错误1 *
这是我的java文件: -
package com.example.opencvtest;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
public class OpenCVMain extends Activity {
public final String TAG = "OPENCVLOG";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG,"loading the library OpenCVTest.so");
System.loadLibrary("OpenCVTest");
Log.i(TAG,"Loaded the library successfully");
TextView t = new TextView(this);
t.setText(nativeDemo());
setContentView(t);
//setContentView(R.layout.activity_open_cvmain);
}
public native String nativeDemo();
}
JNI cpp文件: -
#include <jni.h>
#include <opencv2/core/core.hpp>
extern "C"
{
jstring Java_com_example_opencvtest_OpenCVMain_nativeDemo(JNIEnv* env, jobject obj);
}
jstring Java_com_example_opencvtest_OpenCVMain_nativeDemo(JNIEnv* env, jobject obj)
{
return env->NewStringUTF("Hello Native !!!!");
}
Android.mk文件: -
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := OpenCVTest
LOCAL_SRC_FILES := OpenCVTest.cpp
include $(BUILD_SHARED_LIBRARY)
请在导入OpenCV头文件时指导我在哪里犯错误。 此外,“算法”文件,当我在CTR.h +点击core.hpp第56行中的“算法”文件时,我可以在eclipse中访问。