Skip to content

Commit a6f4dfc

Browse files
Revert "chore:Replace openCV module with openCV aar (#2837)"
This reverts commit 8436203.
1 parent 8436203 commit a6f4dfc

File tree

138 files changed

+40288
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+40288
-2
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ dependencies {
225225
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.0'
226226

227227
//opencv
228-
implementation 'com.github.iamareebjamal:opencv-android:4.1.0'
228+
implementation project(':openCV')
229229

230230
//pdk
231231
implementation 'com.github.forkerknights:android-pdk:1.2b'

openCV/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.opencv"
4+
android:versionCode="4010"
5+
android:versionName="4.0.1">
6+
7+
<uses-permission android:name="android.permission.CAMERA" />
8+
9+
</manifest>

openCV/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 26
5+
//buildToolsVersion "x.y.z" // not needed since com.android.tools.build:gradle:3.0.0
6+
7+
defaultConfig {
8+
minSdkVersion 21
9+
targetSdkVersion 26
10+
}
11+
12+
lintOptions {
13+
disable 'LongLogTag'
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
20+
}
21+
}
22+
compileOptions {
23+
sourceCompatibility JavaVersion.VERSION_1_6
24+
targetCompatibility JavaVersion.VERSION_1_6
25+
}
26+
27+
sourceSets {
28+
main {
29+
jniLibs.srcDirs = ['../../jni']
30+
java.srcDirs = ['src'] // TODO Use original files instead of copied into build directory
31+
aidl.srcDirs = ['src']
32+
res.srcDirs = ['res']
33+
manifest.srcFile 'AndroidManifest.xml'
34+
}
35+
}
36+
}

openCV/res/values/attrs.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<declare-styleable name = "CameraBridgeViewBase" >
4+
<attr name="show_fps" format="boolean"/>
5+
<attr name="camera_id" format="integer" >
6+
<enum name="any" value="-1" />
7+
<enum name="back" value="99" />
8+
<enum name="front" value="98" />
9+
</attr>
10+
</declare-styleable>
11+
</resources>

openCV/src/org/opencv/android/AsyncServiceHelper.java

Lines changed: 391 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package org.opencv.android;
2+
3+
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.Context;
6+
import android.content.DialogInterface;
7+
import android.content.DialogInterface.OnClickListener;
8+
import android.util.Log;
9+
10+
/**
11+
* Basic implementation of LoaderCallbackInterface.
12+
*/
13+
public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
14+
15+
public BaseLoaderCallback(Context AppContext) {
16+
mAppContext = AppContext;
17+
}
18+
19+
public void onManagerConnected(int status)
20+
{
21+
switch (status)
22+
{
23+
/** OpenCV initialization was successful. **/
24+
case LoaderCallbackInterface.SUCCESS:
25+
{
26+
/** Application must override this method to handle successful library initialization. **/
27+
} break;
28+
/** OpenCV loader can not start Google Play Market. **/
29+
case LoaderCallbackInterface.MARKET_ERROR:
30+
{
31+
Log.e(TAG, "Package installation failed!");
32+
AlertDialog MarketErrorMessage = new AlertDialog.Builder(mAppContext).create();
33+
MarketErrorMessage.setTitle("OpenCV Manager");
34+
MarketErrorMessage.setMessage("Package installation failed!");
35+
MarketErrorMessage.setCancelable(false); // This blocks the 'BACK' button
36+
MarketErrorMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
37+
public void onClick(DialogInterface dialog, int which) {
38+
finish();
39+
}
40+
});
41+
MarketErrorMessage.show();
42+
} break;
43+
/** Package installation has been canceled. **/
44+
case LoaderCallbackInterface.INSTALL_CANCELED:
45+
{
46+
Log.d(TAG, "OpenCV library installation was canceled by user");
47+
finish();
48+
} break;
49+
/** Application is incompatible with this version of OpenCV Manager. Possibly, a service update is required. **/
50+
case LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION:
51+
{
52+
Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!");
53+
AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create();
54+
IncomatibilityMessage.setTitle("OpenCV Manager");
55+
IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.");
56+
IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button
57+
IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
58+
public void onClick(DialogInterface dialog, int which) {
59+
finish();
60+
}
61+
});
62+
IncomatibilityMessage.show();
63+
} break;
64+
/** Other status, i.e. INIT_FAILED. **/
65+
default:
66+
{
67+
Log.e(TAG, "OpenCV loading failed!");
68+
AlertDialog InitFailedDialog = new AlertDialog.Builder(mAppContext).create();
69+
InitFailedDialog.setTitle("OpenCV error");
70+
InitFailedDialog.setMessage("OpenCV was not initialised correctly. Application will be shut down");
71+
InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
72+
InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
73+
74+
public void onClick(DialogInterface dialog, int which) {
75+
finish();
76+
}
77+
});
78+
79+
InitFailedDialog.show();
80+
} break;
81+
}
82+
}
83+
84+
public void onPackageInstall(final int operation, final InstallCallbackInterface callback)
85+
{
86+
switch (operation)
87+
{
88+
case InstallCallbackInterface.NEW_INSTALLATION:
89+
{
90+
AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create();
91+
InstallMessage.setTitle("Package not found");
92+
InstallMessage.setMessage(callback.getPackageName() + " package was not found! Try to install it?");
93+
InstallMessage.setCancelable(false); // This blocks the 'BACK' button
94+
InstallMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new OnClickListener()
95+
{
96+
public void onClick(DialogInterface dialog, int which)
97+
{
98+
callback.install();
99+
}
100+
});
101+
102+
InstallMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "No", new OnClickListener() {
103+
104+
public void onClick(DialogInterface dialog, int which)
105+
{
106+
callback.cancel();
107+
}
108+
});
109+
110+
InstallMessage.show();
111+
} break;
112+
case InstallCallbackInterface.INSTALLATION_PROGRESS:
113+
{
114+
AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create();
115+
WaitMessage.setTitle("OpenCV is not ready");
116+
WaitMessage.setMessage("Installation is in progress. Wait or exit?");
117+
WaitMessage.setCancelable(false); // This blocks the 'BACK' button
118+
WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() {
119+
public void onClick(DialogInterface dialog, int which) {
120+
callback.wait_install();
121+
}
122+
});
123+
WaitMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "Exit", new OnClickListener() {
124+
public void onClick(DialogInterface dialog, int which) {
125+
callback.cancel();
126+
}
127+
});
128+
129+
WaitMessage.show();
130+
} break;
131+
}
132+
}
133+
134+
void finish()
135+
{
136+
((Activity) mAppContext).finish();
137+
}
138+
139+
protected Context mAppContext;
140+
private final static String TAG = "OpenCVLoader/BaseLoaderCallback";
141+
}

0 commit comments

Comments
 (0)