就这几行简单的代码编译都不通过
#include"opencv2/opencv.hpp"
using namespace cv;
int sss()
{
Mat image= imread( "1", CV_LOAD_IMAGE_COLOR);
imwrite("2.bmp",image);
return 1;
}
CMakeLists 文件
cmake_minimum_required(VERSION 3.4.1)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
set(CMAKE_VERBOSE_MAKEFILE on)
set(ocvlibs "C:\\BC\\OpenCV\\sdk\\native\\libs")
# 设置include文件夹的地址
include_directories(C:/BC/lua-5.2.0/src)
include_directories(C:\\BC\\OpenCV\\sdk\\native\\jni\\include)
add_library(native-lib SHARED native-lib.cpp)
# 设置opencv的动态库
add_library(libopencv_java SHARED IMPORTED )
set_target_properties(libopencv_java PROPERTIES IMPORTED_LOCATION "${ocvlibs}/${ANDROID_ABI}/libopencv_java3.so")
find_library(log-lib log)
target_link_libraries(native-lib android log libopencv_java ${log-lib} )
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.opencvtest"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++11", "-frtti", "-fexceptions"
abiFilters 'x86'
}
}
}
sourceSets{
main{
jniLibs.srcDirs = ['C:\\BC\\OpenCV\\sdk\\native\\libs']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}