您的位置:首页 > 其它

【FastCV】FastCV实例1

2016-04-20 23:48 330 查看
在上一篇《FastCV环境搭建》中已经描述了如何搭建FastCV及其导入FastCV SDK自带的demo,这篇文章将讲述如何自己创建一个FastCV项目。

1、创建一个新的安卓工程 fastCVTest。

2、在工程目录下新建jni文件夹,把fastcv.h及libfastcv.a拷贝到jni文件夹下,并且在文件夹下创建android.mk application.mk image.cpp 文件,编辑以下内容:

application.mk

APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions


android.mk

# 在编译源文件前先编译出libfastcv.so 库
include $(CLEAR_VARS)
LOCAL_MODULE := fastcv
LOCAL_SRC_FILES := libfastcv.a
include $(PREBUILT_STATIC_LIBRARY)

#编译libfastCVTest.so
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := fastCVTest

LOCAL_CPPFLAGS := -frtti -fexceptions
LOCAL_LDLIBS += -llog -lz

#引用libfastcv.so
LOCAL_STATIC_LIBRARIES := fastcv

LOCAL_SRC_FILES := image.cpp
include $(BUILD_SHARED_LIBRARY)


image.cpp

#include "fastcv.h"
#include "jni.h"
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "FASTCV"
#endif

#define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void Java_com_example_fastcvtest_MainActivity_test(JNIEnv* env,jobject thiz){

char sVersion[32];
fcvGetVersion(sVersion, 32);
LOGD("FastCV version %s", sVersion);
}
#ifdef  __cplusplus
}
#endif


在MainActivity.java中添加:

static{
System.loadLibrary("fastCVTest");
}
native void test();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
test();
}


3、设置自动编译,具体参照上一篇文章中的操作。

4、运行即可看到相关的log。



该工程项目源码:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: