美文网首页
Android Studio配置OpenCV(无需安装OpenC

Android Studio配置OpenCV(无需安装OpenC

作者: 码农小白two | 来源:发表于2017-11-12 16:56 被阅读0次

Andrioid Stduio 配置OpenCv特别简单:

一、在Android Studio中import module,导入我们需要的OpenCV Library。一直next就行!

2.在openCVLibrary module中修改相关参数。修改参数部分是第二幅图,数字改成和app Module一样就行。然后Sync now!

3、接下来讲OpenCVLibrary中的libs下的东西全部复制到app下的libs中。接着在build.gradle中加入代码(粗体字)!

dependencies {

compile fileTree(include: ['*.jar'],dir:'libs')

compile fileTree(include:'native-libs.jar',dir:"$buildDir/native-libs")

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

excludegroup:'com.android.support',module:'support-annotations'

})

compile project(':openCVLibrary310')

compile'com.android.support:appcompat-v7:26.+'

compile'com.android.support.constraint:constraint-layout:1.0.2'

testCompile'junit:junit:4.12'

}

task nativeLibsTojar(type: Jar,description:'create a jar archive of the native libs') {

destinationDir file("$buildDir/native-libs")

baseName'native-libs'

from fileTree(dir:'libs',include:'**/*.so')

into'lib/'

}

tasks.withType(org.gradle.api.tasks.compile.JavaCompile) {

compileTask -> compileTask.dependsOn(nativeLibsTojar)

}

4、接下来我们就只需要初始化OpenCVLibrary即可!

@Override

protected voidonCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initLoadOpenCVLibs();

}

private voidinitLoadOpenCVLibs() {

booleansuccess= OpenCVLoader.initDebug();

if(success){

Log.d(TAG,"Load Library successfully......");

}

}

相关文章

网友评论

      本文标题:Android Studio配置OpenCV(无需安装OpenC

      本文链接:https://www.haomeiwen.com/subject/fmqomxtx.html