【FastCV】FastCV实例1

来源:互联网 发布:类似于皮影客的软件 编辑:程序博客网 时间:2024/05/29 14:57

在上一篇《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-v7aAPP_STL := gnustl_staticAPP_CPPFLAGS := -frtti -fexceptions  

android.mk

# 在编译源文件前先编译出libfastcv.so 库include $(CLEAR_VARS)LOCAL_MODULE := fastcvLOCAL_SRC_FILES := libfastcv.ainclude $(PREBUILT_STATIC_LIBRARY)#编译libfastCVTest.soLOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := fastCVTestLOCAL_CPPFLAGS := -frtti -fexceptionsLOCAL_LDLIBS += -llog -lz#引用libfastcv.soLOCAL_STATIC_LIBRARIES := fastcvLOCAL_SRC_FILES := image.cppinclude $(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 __cplusplusextern "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();@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    test();}

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

4、运行即可看到相关的log。
这里写图片描述

该工程项目源码:

0 0
原创粉丝点击