Android Studio + opencv开发配置
1 下载Android Studio
https://developer.android.com/studio/archive?hl=zh-cn
2 安装Android Studio
安装完成,下载SDK NDK LLIB Cmake
FIle-Setting


3 开始建立工程使用
4 配置



CMakeLists.txt
1 包括三个三方库test1.so test.so gnustl_shared.so
2 加入opencv的支持
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html # Sets the minimum version of CMake required to build the native library. cmake_minimum_required(VERSION 3.4.) #step1 ##################### OpenCV 环境 ############################
#参考https://www.jianshu.com/p/6e16c0429044
#设置OpenCV-android-sdk路径
set(OpenCV_STATIC ON)
set(OpenCV_DIR C:/software/opencv-4.0.-android-sdk/OpenCV-android-sdk/sdk/native/jni ) find_package(OpenCV REQUIRED )
if(OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
else(OpenCV_FOUND)
message(FATAL_ERROR "OpenCV library not found")
endif(OpenCV_FOUND) #set(OpenCV_STATIC ON)
#set( OpenCV_DIR C:/software/opencv-3.4.-android-sdk/OpenCV-android-sdk/sdk/native/jni )
#find_package (OpenCV REQUIRED)
#
#target_link_libraries(native-lib ${OpenCV_LIBS}) #step2 设置so库路径
#参考 https://blog.csdn.net/carryWorld/article/details/75026171
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
set(jnilibs "${CMAKE_SOURCE_DIR}/src/main/jniLibs")
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${jnilibs}/${ANDROID_ABI}) # ###################### 项目原生模块 ###########################
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK. add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp) #step3 加入共享库
add_library(test1 SHARED IMPORTED)
add_library(test2 SHARED IMPORTED)
add_library(gnustl_shared SHARED IMPORTED) # Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build. find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log) # Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries. message($CMAKE_SOURCE_DIR)
set_target_properties(test1
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libtest1.so) set_target_properties(test2
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libtest2.so) set_target_properties(gnustl_shared
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libgnustl_shared.so) target_link_libraries( # Specifies the target library.
native-lib
${OpenCV_LIBS}
jnigraphics
log
test1
test2
gnustl_shared
# Links the target library to the log library
# included in the NDK.
${log-lib})
5 开始编译
Android Studio + opencv开发配置的更多相关文章
- Google Android Studio Kotlin 开发环境配置
Google 近日开发者大会宣布Kotlin成为Android开发的第一级语言,即Android官方开发语言,可见Google对Kotlin的重视,本文就介绍一下Android Studio下的Kot ...
- Android Studio安装、配置教程全 - 安卓开发环境的配置手册
Android Studio的安装.配置 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 一 Downloa ...
- Android Studio JNI开发入门教程
Android Studio JNI开发入门教程 2016-08-29 14:38 3269人阅读 评论(0) 收藏 举报 分类: JNI(3) 目录(?)[+] 概述 在Andorid ...
- 【转】Android studio安装与配置
Android studio安装与配置 1.首先下载Android studio安装包,可以从http://www.android-studio.org/下载最新版本,这里采用3.0版本进行演示,对应 ...
- Android Studio经常使用配置及使用技巧(二)
在<Android Studio经常使用配置及使用技巧(一)>中具体描写叙述了Android Studio的project结构和打开开源project的一些配置方法.本篇将从我个人的使用情 ...
- Android Studio NDK环境配置
本文参考:Android Studio NDK环境配置及JNI使用方法:http://blog.csdn.net/tongseng/article/details/53005123 并添加自己的实践: ...
- Android studio 安装与配置【Android学习入门】
终于下定决心认真学习Android开发了. 之前在很多平台看到很多大牛们学习Android的经验和心得,纸上得来终觉浅. 这里推荐stormzhang老师总结的Android学习之路. 为了防止电脑卡 ...
- Mac下Android studio 之NDK配置教程(一)
Mac下Android studio 之NDK配置教程(一) 1.概述 近期项目全线转移到Mac下使用使用Android studio开发. 遇到关键代码封装到 ***native***层,此时在wi ...
- 【Android】Android Studio NDK 开发
Android Studio NDK 开发 记录在Android Studio中NDK简单开发的步骤 用到的Android Studio版本为3.5. 配置NDK 下载NDK 一般在SDK下已经有自带 ...
随机推荐
- Centos 7 kubernetes集群搭建
一.环境准备 Kubernetes支持在物理服务器或虚拟机中运行,本次使用虚拟机准备测试环境,硬件配置信息如表所示: IP地址 节点角色 CPU Memory Hostname 磁盘 192.168. ...
- javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.qingmu.Customer
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity pas ...
- 使用ArcGIS for Server的Feature Access REST在线编辑图层
如何启用Feature Access可以参考以前写的一篇博客:http://www.cnblogs.com/oceanking/p/3895257.html 本文主要关注一个全是点的图层,我也不知道学 ...
- shell脚本攻略1
换行符 \n echo -n 禁止换行 环境变量声明export export PATH="$PATH:/home/user/bin" 获取字符串的长度 length=${#var ...
- Excel——读取——导出目录
/** * 导出Excel文件到具体的目录 * <一句话功能简述> * <功能详细描述> * @param fileName 导出的文件名 * @param sheetName ...
- You Can Customize Synthesized Instance Variable Names @property
As mentioned earlier, the default behavior for a writeable property is to use an instance variable c ...
- 从Swift桥接文件到Clang-LLVM
http://blog.csdn.net/u014795020/article/details/72514109 前言 今天在Swift工程中不小心创建了一个OC文件,于是乎提示我创建一个桥接文件,那 ...
- OpenCV 学习笔记(9)RGB转换成灰度图像的一个常用公式Gray = R*0.299 + G*0.587 + B*0.114
https://blog.csdn.net/fly_wt/article/details/86432886 RGB转换成灰度图像的一个常用公式是:Gray = R*0.299 + G*0.587 + ...
- 趋势投资tz-proj springcloud (vue redis)
https://github.com/deadzq/tz-test-1 https://github.com/deadzq/tz-test-api-1 https://github.com/deadz ...
- Install Python3.6 on Amazon Linux/EC2 在Amazon Linux实例中安装使用Python3.6
本文转载自 https://gist.github.com/niranjv/f80fc1f488afc49845e2ff3d5df7f83b 由于Amazon Linux中预装的Python版本为2. ...