From:https://blog.csdn.net/lldbuaa/article/details/80333718

I must be crazy!

when I promise someone that I will finish an app with Opencv&ZXing in 2 weeks ,I didnot know what an activity is!

cause I got a lot from web,many people gave advice for other people and I got something right and something wrong…

So If this blog help you,I will be happy and give me five.

1.OpenCV Environment WITHOUT OPENCV_Manager

this link
Opencv4Android doc
Opencv4Android Environment doc

Cause I use Android Studio so I fellow the steps below

(1).Import Module->”opencv/sdk/java”->then get the model like this

(2).Add depends->


There, I need to say,when I use Opencv in ZXing(Modify),I will add the depends to ZXing Module,and you will read more.

(3).Modify the build.gradle(openCVLibrary330)& (app)->

//build gradle(opencv)apply plugin: 'com.android.library'android {    compileSdkVersion 27         //Need to Modify    buildToolsVersion "27.0.3"   //Need to Modify    //The actual version depends on your build.gradle(app) fellowed    defaultConfig {        minSdkVersion 23        //Need to Modify        targetSdkVersion 27     //Need to Modify        //Same with the app build.gradle(app)    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'        }    }}
//build.gradle(app)apply plugin: 'com.android.application'android {    compileSdkVersion 27    buildToolsVersion "27.0.3"    defaultConfig {        applicationId "com.example.lld.hellowopencv"        minSdkVersion 23        targetSdkVersion 27        versionCode 1        versionName "1.1"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}dependencies {    implementation fileTree(include: ['*.jar'], dir: 'libs')    implementation fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')    implementation 'com.android.support:appcompat-v7:27.1.1'    implementation 'com.android.support.constraint:constraint-layout:1.1.0'    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'    implementation project(':openCVLibrary330')}//Add the fellow codetask nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {    destinationDir file("$buildDir/native-libs")  //native-libs is the neme of jar    baseName 'native-libs'                        //same with the up    from fileTree(dir: 'libs', include: '**/*.so')    into 'lib/'}tasks.withType(JavaCompile) {    compileTask -> compileTask.dependsOn(nativeLibsToJar)}

(4).Copy opencv/sdk/native 2 libs(IF you do not have JNI)

Opencv4Android Environment doc

(5).Init OpenCV static

static {    if (!OpenCVLoader.initDebug()) {        // Handle initialization error    } else {        System.loadLibrary("my_jni_lib1");        System.loadLibrary("my_jni_lib2");    }}

Maybe you will find No Wrong with your code.
When your Module which depends OpenCV is the app,It will work,you will GET the OpenCV Load like this:

But when your Module which depends OpenCV is the other app, it will not work,and you will GET Cannot load Opencv/Opencv Info/…
You need
create the jniLibs folder and copy opencv/sdk/native to the folder

you will get

It means you get the OpenCV environment.

2.ZXing Environment

(1)New Module ->ZXing

(2)Copy files into ZXing/src/main/java/com/

like the fellowing

and modify the res folder

(3)Add depends to App Module

(4)Cover the Mainfiest(app)

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.lld.checkapp">    <uses-permission android:name="android.permission.CAMERA"/>    <uses-permission android:name="android.permission.FLASHLIGHT"/>    <uses-feature android:name="android.hardware.camera"/>    <uses-feature android:name="android.hardware.camera.autofocus"/>    <uses-permission android:name="android.permission.VIBRATE"/>    <uses-permission android:name="android.permission.WAKE_LOCK"/>    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:roundIcon="@mipmap/ic_launcher_round"        android:supportsRtl="true"        android:theme="@style/AppTheme">        <activity            android:name=".main"            android:configChanges="orientation|keyboardHidden|screenSize"            android:label="@string/app_name"            android:theme="@style/Theme.AppCompat.Light.NoActionBar">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            intent-filter>        activity>        <activity android:name="com.lld.zxing.Activity.CaptureActivity">//register the next Activity        activity>    application>manifest>

(5).Add core-3.3.0.jar to zxing/libs/

(6).You Get the ZXing environment (Modify for scan QR code)

3.The Test Pic



4.The download link

OpenCV Environment Only密码: uncv
ZXing Environment Only 密码cn5a
Two Environment in One 密码bdhm

5.If the blog helps you,please make something for others

Maybe Give Me Five is a Good Thing.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 【前端】一道算法题,有会的可以一起讨论下
  2. 校园生活服务平台小程序系统具备哪些功能
  3. 服务器防火墙如何开放端口?常见的服务器端
  4. 使用函数封装一个动态表格,自行写5个系统
  5. foreach循环
  6. 1. 循环省市区 2. print_f打印其中一个
  7. 疯狂自定义函数(动态表格)
  8. 运算符以及函数的使用
  9. 第十三课 PHP常用运算符、函数
  10. 初识 php 数值运算符与字符串运算符、字