aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Android_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-04-10 20:34:37 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-04-10 20:34:37 +0300
commit10a60c85181ba12f7cc1d84f23f6d6771faaae3d (patch)
treefac4d39f297fbfefda39cc670931a0d16237e86f /Software/Android_Studio
parente96ac0051590493eb23760aff71e3242fd88adf1 (diff)
downloadTango-10a60c85181ba12f7cc1d84f23f6d6771faaae3d.tar.gz
Tango-10a60c85181ba12f7cc1d84f23f6d6771faaae3d.zip
Working on TCC...
Diffstat (limited to 'Software/Android_Studio')
-rw-r--r--Software/Android_Studio/ColorCapture/app/build.gradle15
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml1
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp3
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp141
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/App.java3
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java13
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java4
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java64
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java3
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java18
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/WebModule.java29
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/opencv/ImageProcessor.java11
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/BitmapUtils.java25
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java118
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java54
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java16
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java25
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java76
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java101
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionRequest.java5
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java105
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java38
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionRequest.java27
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java27
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginRequest.java49
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginResponse.java16
26 files changed, 836 insertions, 151 deletions
diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle
index 83ed47583..6f56df4f6 100644
--- a/Software/Android_Studio/ColorCapture/app/build.gradle
+++ b/Software/Android_Studio/ColorCapture/app/build.gradle
@@ -21,10 +21,20 @@ android {
}
}
buildTypes {
+
+ debug {
+ buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://192.168.1.86:45455/api/\""
+ buildConfigField "String", "WEB_SERVICE_APP_ID", "\"Tdf793i4ughsiduf8749509237885ehgfdlkghlT\""
+ }
+
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+
+ buildConfigField "String", "WEB_SERVICE_ADDRESS", "\"http://twinetcc.azurewebsites.net/api/\""
+ buildConfigField "String", "WEB_SERVICE_APP_ID", "\"Tdf793i4ughsiduf8749509237885ehgfdlkghlT\""
}
+
}
dataBinding {
@@ -67,4 +77,9 @@ dependencies {
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
compile 'com.yanzhenjie.zbar:zbar:1.0.0'
+ compile 'com.squareup.retrofit2:retrofit:2.3.0'
+ compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
+ compile 'com.squareup.retrofit2:converter-gson:2.1.0'
+ implementation 'com.github.yoanngoular:bitmapconverter:0.2.0'
+
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml b/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml
index df39e776f..a03d65975 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml
+++ b/Software/Android_Studio/ColorCapture/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="com.twine.colorcapture">
<uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:name="android.hardware.camera"
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp b/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp
index 3a97b4911..7437923f2 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp
+++ b/Software/Android_Studio/ColorCapture/app/src/main/cpp/ColorCaptureLib/ColorCaptureLib.cpp
@@ -733,13 +733,14 @@ vector<Point> ColorCaptureLib::GetArcusVertices(Mat image)
aruco::DetectorParameters* params = new aruco::DetectorParameters();
params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
params->perspectiveRemovePixelPerCell = 50;
+ params->minDistanceToBorder = 0;
Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::DICT_4X4_50);
aruco::detectMarkers(image, dictionary, corners, ids, &(*params));
if (corners.size() == 4)
{
- aruco::drawDetectedMarkers(image, corners, ids);
+ //aruco::drawDetectedMarkers(image, corners, ids);
vertices =
{
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp b/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp
index 62d702b7f..c2bee04e8 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp
+++ b/Software/Android_Studio/ColorCapture/app/src/main/cpp/native-lib.cpp
@@ -8,47 +8,67 @@
using namespace cv;
-enum RotateFlags {
+enum RotateFlags
+{
ROTATE_90DEG_CLOCKWISE = 0, //Rotate 90 degrees clockwise
ROTATE_180DEG = 1, //Rotate 180 degrees clockwise
ROTATE_90_DEFCOUNTERCLOCKWISEDEG = 2, //Rotate 270 degrees clockwise
};
-void rot90(cv::Mat &matImage, int rotflag) {
+void rot90(cv::Mat &matImage, int rotflag)
+{
//1=CW, 2=CCW, 3=180
- if (rotflag == 1) {
+ if (rotflag == 1)
+ {
transpose(matImage, matImage);
flip(matImage, matImage, 1); //transpose+flip(1)=CW
- } else if (rotflag == 2) {
+ }
+ else if (rotflag == 2)
+ {
transpose(matImage, matImage);
flip(matImage, matImage, 0); //transpose+flip(0)=CCW
- } else if (rotflag == 3) {
+ }
+ else if (rotflag == 3)
+ {
flip(matImage, matImage, -1); //flip(-1)=180
- } else if (rotflag != 0) { //if not 0,1,2,3:
+ }
+ else if (rotflag != 0)
+ { //if not 0,1,2,3:
cout << "Unknown rotation flag(" << rotflag << ")" << endl;
}
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_twine_colorcapture_opencv_ImageProcessor_ProcessImage(
- JNIEnv *env, jobject instance, jint frameWidth,
- jint frameHeight, jint correctedWidth, jint correctedHeight, jbyteArray NV21FrameData,
- jintArray outPixels, jintArray wrapedOutPixels) {
- jbyte *pNV21FrameData = env->GetByteArrayElements(NV21FrameData, 0);
- jint *poutPixels = env->GetIntArrayElements(outPixels, 0);
- jint *pwrapedPixels = env->GetIntArrayElements(wrapedOutPixels, 0);
+ JNIEnv *env,
+ jobject instance,
+ jint frameWidth,
+ jint frameHeight,
+ jint sampleWidth,
+ jint sampleHeight,
+ jint histogramMethod,
+ jdouble similarityTolerance,
+ jboolean enableDoubleChecking,
+ jbyteArray frameData,
+ jintArray frameOutPixels,
+ jintArray sampleOutPixels)
+{
+
+ jbyte *pFrameData = env->GetByteArrayElements(frameData, 0);
+ jint *pFrameOutPixels = env->GetIntArrayElements(frameOutPixels, 0);
+ jint *pSampleOutPixels = env->GetIntArrayElements(sampleOutPixels, 0);
- ////
jboolean has_result = jboolean(false);
- try {
+ try
+ {
ColorCaptureLib capture;
Mat yuv(frameHeight + frameHeight / 2, frameWidth, CV_8UC1,
- (unsigned char *) pNV21FrameData);
+ (unsigned char *) pFrameData);
Mat rgb;
- Mat result(frameWidth, frameHeight, CV_8UC4, (unsigned char *) poutPixels);
+ Mat result(frameWidth, frameHeight, CV_8UC4, (unsigned char *) pFrameOutPixels);
cvtColor(yuv, rgb, COLOR_YUV2RGB_NV21);
Mat gray;
@@ -56,82 +76,65 @@ Java_com_twine_colorcapture_opencv_ImageProcessor_ProcessImage(
cvtColor(rgb, gray, CV_RGB2GRAY);
cv::Laplacian(gray, dst, CV_64F);
- cv::Scalar mu, sigma;
- cv::meanStdDev(dst, mu, sigma);
-
- double focusMeasure = sigma.val[0] * sigma.val[0];
+// cv::Scalar mu, sigma;
+// cv::meanStdDev(dst, mu, sigma);
- __android_log_print(ANDROID_LOG_ERROR, "FOCUS", "\n Focus measure is %f \n", focusMeasure);
+// double focusMeasure = sigma.val[0] * sigma.val[0];
+//
+// __android_log_print(ANDROID_LOG_ERROR, "FOCUS", "\n Focus measure is %f \n", focusMeasure);
rot90(rgb, ROTATE_180DEG);
- //resize(src, dst, dst.size(), 0, 0, interpolation);
-
-/* Point2f src_center(rgb.cols / 2.0F, rgb.rows / 2.0F);
- Mat rot_mat = getRotationMatrix2D(src_center, -90, 1.0);
- warpAffine(rgb, rgb, rot_mat, rgb.size());*/
-
vector<Point> vertices = capture.GetArcusVertices(rgb);
- for (size_t i = 0; i < vertices.size(); i++) {
- circle(rgb, vertices[i], 2, CV_RGB(0, 0, 255), -1);
- }
+ int w = sampleWidth;
+ int h = sampleHeight;
- int w = correctedWidth;
- int h = correctedHeight;
+ Mat sampleMat(h, w, CV_8UC4, (unsigned char *) pSampleOutPixels);
- Mat wraped(h, w, CV_8UC4, (unsigned char *) pwrapedPixels);
+ if (vertices.size() == 4)
+ {
+ Mat detectedMat = capture.ApplyHomography(rgb, vertices, Size(w, h));
- if (vertices.size() == 4) {
+ bool passed_double_checking = true;
- has_result = jboolean(true);
+ if (enableDoubleChecking)
+ {
+ vertices = capture.GetArcusVertices(detectedMat);
+ if (vertices.size() == 4)
+ {
+ passed_double_checking = true;
+ }
+ else
+ {
+ passed_double_checking = false;
+ }
+ }
- Mat m = capture.ApplyHomography(rgb, vertices, Size(w, h));
+ if (passed_double_checking)
+ {
+ has_result = jboolean(true);
+ }
- //Draw Blocks!
- BhBlocks b(m, w / 10, h / 11);
- b.drawBlocks(m, Scalar(255, 0, 0), 1);
-
- cvtColor(m, wraped, COLOR_RGB2BGRA);
- m.release();
+ cvtColor(detectedMat, sampleMat, COLOR_RGB2BGRA);
+ detectedMat.release();
}
cvtColor(rgb, result, COLOR_RGB2BGRA);
-/* vector<Point> vertices = capture.GetQRVertices4(image);
-
- for (size_t i = 0; i < vertices.size(); i++)
- {
- circle(image, vertices[i], 2, CV_RGB(0, 0, 255), -1);
- }
-
- int w = 330;
- int h = 300;
- int columns = 11;
- int rows = 10;
-
- if (vertices.size() == 4)
- {
- capture.ApplyHomography(image, vertices, Size(w, h));
- BhBlocks b(image, w / columns, h / rows);
- b.drawBlocks(image, Scalar(0, 0, 0), 1);
- }*/
-
-
- jsize size = env->GetArrayLength(outPixels);
-
- env->ReleaseByteArrayElements(NV21FrameData, pNV21FrameData, 0);
- env->ReleaseIntArrayElements(outPixels, poutPixels, 0);
- env->ReleaseIntArrayElements(wrapedOutPixels, pwrapedPixels, 0);
+ env->ReleaseByteArrayElements(frameData, pFrameData, 0);
+ env->ReleaseIntArrayElements(frameOutPixels, pFrameOutPixels, 0);
+ env->ReleaseIntArrayElements(sampleOutPixels, pSampleOutPixels, 0);
yuv.release();
rgb.release();
result.release();
- wraped.release();
+ sampleMat.release();
dst.release();
gray.release();
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
env->ThrowNew(env->FindClass("java/lang/NullPointerException"), ex.what());
}
return has_result;
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/App.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/App.java
index d703526e2..335b4fe52 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/App.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/App.java
@@ -7,6 +7,7 @@ import android.content.Context;
import com.twine.colorcapture.dagger.ApplicationComponent;
import com.twine.colorcapture.dagger.ApplicationModule;
import com.twine.colorcapture.dagger.DaggerApplicationComponent;
+import com.twine.colorcapture.web.WebApiFactory;
import net.danlew.android.joda.JodaTimeAndroid;
@@ -53,7 +54,7 @@ public class App extends Application
//TangoDB.init();
//MessageFactory.init();
- //WebApiFactory.init("http://10.0.2.2:45455/api/");
+ WebApiFactory.init(BuildConfig.WEB_SERVICE_ADDRESS);
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java
index a5faab0d1..f19571b06 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/AnimationsHelper.java
@@ -6,6 +6,8 @@ import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.ScaleAnimation;
+import java.io.IOException;
+
/**
* Contains helper methods related to animations.
*/
@@ -34,7 +36,16 @@ public class AnimationsHelper
@Override
public void onAnimationEnd(Animation animation)
{
- if (onCompleted != null) onCompleted.invoke();
+ if (onCompleted != null)
+ {
+ try
+ {
+ onCompleted.invoke();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
}
@Override
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java
index 5766f6cf3..35cf21cc4 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/IAction.java
@@ -1,5 +1,7 @@
package com.twine.colorcapture.core;
+import java.io.IOException;
+
/**
* Represents an void Action delegate.
*/
@@ -8,5 +10,5 @@ public interface IAction
/**
* Invokes the action.
*/
- void invoke();
+ void invoke() throws IOException;
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java
index 2858fbc3c..407de37d3 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/core/Task.java
@@ -2,33 +2,72 @@ package com.twine.colorcapture.core;
import android.os.AsyncTask;
-public class Task extends AsyncTask<String, Integer, String> {
+import java.io.IOException;
+
+public class Task extends AsyncTask<String, Integer, String>
+{
private IAction action;
private IAction continueWithAction;
+ private IAction1<Exception> errorAction;
+ private boolean hasError;
+ private Exception error;
+
- public Task(IAction action) {
+ public Task(IAction action)
+ {
this.action = action;
}
- public Task(IAction action, IAction continueWithAction) {
+ public Task(IAction action, IAction continueWithAction)
+ {
this.action = action;
this.continueWithAction = continueWithAction;
}
+ public Task(IAction action, IAction continueWithAction, IAction1<Exception> errorAction)
+ {
+ this.action = action;
+ this.continueWithAction = continueWithAction;
+ this.errorAction = errorAction;
+ }
+
@Override
- protected String doInBackground(String... strings) {
- action.invoke();
+ protected String doInBackground(String... strings)
+ {
+ try
+ {
+ action.invoke();
+ } catch (Exception ex)
+ {
+ hasError = true;
+ error = ex;
+ }
return null;
}
@Override
- protected void onPostExecute(String s) {
+ protected void onPostExecute(String s)
+ {
super.onPostExecute(s);
- if (continueWithAction != null)
+ if (continueWithAction != null && !hasError)
+ {
+ try
+ {
+ continueWithAction.invoke();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ if (hasError)
{
- continueWithAction.invoke();
+ if (errorAction != null)
+ {
+ errorAction.invoke(error);
+ }
}
}
@@ -42,6 +81,7 @@ public class Task extends AsyncTask<String, Integer, String> {
private Task task;
private IAction action;
private IAction continueWithAction;
+ private IAction1<Exception> errorAction;
public TaskBuilder setAction(IAction action)
{
@@ -55,9 +95,15 @@ public class Task extends AsyncTask<String, Integer, String> {
return this;
}
+ public TaskBuilder setError(IAction1<Exception> action)
+ {
+ this.errorAction = action;
+ return this;
+ }
+
public Task build()
{
- return new Task(action,continueWithAction);
+ return new Task(action, continueWithAction, errorAction);
}
}
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java
index 7f97483b6..f52f30a53 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java
@@ -5,7 +5,6 @@ import com.twine.colorcapture.views.capture.CaptureFragment;
import com.twine.colorcapture.views.mycolors.MyColorsFragment;
import com.twine.colorcapture.views.loading.LoadingActivity;
import com.twine.colorcapture.views.main.MainActivity;
-import com.twine.colorcapture.views.main.MainActivityVM;
import javax.inject.Singleton;
@@ -16,7 +15,7 @@ import dagger.Component;
*/
@Singleton
-@Component(modules = {ApplicationModule.class, ViewModelsModule.class, EventBusModule.class, NotificationModule.class, NavigationModule.class})
+@Component(modules = {ApplicationModule.class, ViewModelsModule.class, EventBusModule.class, NotificationModule.class, NavigationModule.class, WebModule.class})
public interface ApplicationComponent
{
void inject(MainActivity view);
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java
index 1a017a7fc..188089553 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java
@@ -8,6 +8,8 @@ import com.twine.colorcapture.views.capture.CaptureFragmentVM;
import com.twine.colorcapture.views.loading.LoadingActivityVM;
import com.twine.colorcapture.views.mycolors.MyColorsFragmentVM;
import com.twine.colorcapture.views.main.MainActivityVM;
+import com.twine.colorcapture.web.ITCCService;
+import com.twine.colorcapture.web.IWebServiceAPI;
import javax.inject.Singleton;
@@ -21,33 +23,33 @@ import dagger.Provides;
@Module
public class ViewModelsModule
{
-
+
@Provides
@Singleton
public MainActivityVM provideMainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider)
{
return new MainActivityVM(eventBus, notificationProvider, navigationProvider);
}
-
+
@Provides
@Singleton
- public LoadingActivityVM provideLoadingFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider)
+ public LoadingActivityVM provideLoadingFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService)
{
- return new LoadingActivityVM(eventBus, notificationProvider, navigationProvider);
+ return new LoadingActivityVM(eventBus, notificationProvider, navigationProvider, tccService);
}
-
+
@Provides
@Singleton
public MyColorsFragmentVM provideMyColorsFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider)
{
return new MyColorsFragmentVM(navigationProvider);
}
-
+
@Provides
@Singleton
- public CaptureFragmentVM provideCaptureFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider)
+ public CaptureFragmentVM provideCaptureFragmentVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService)
{
- return new CaptureFragmentVM();
+ return new CaptureFragmentVM(tccService, navigationProvider);
}
@Provides
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/WebModule.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/WebModule.java
new file mode 100644
index 000000000..755f7b19c
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/WebModule.java
@@ -0,0 +1,29 @@
+package com.twine.colorcapture.dagger;
+
+import com.twine.colorcapture.web.ITCCService;
+import com.twine.colorcapture.web.IWebServiceAPI;
+import com.twine.colorcapture.web.TCCService;
+import com.twine.colorcapture.web.WebApiFactory;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class WebModule
+{
+ @Provides
+ @Singleton
+ public IWebServiceAPI providerWebServiceAPI()
+ {
+ return WebApiFactory.getWebServiceApi();
+ }
+
+ @Provides
+ @Singleton
+ public ITCCService provideTCCService(IWebServiceAPI webServiceAPI)
+ {
+ return new TCCService(webServiceAPI);
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/opencv/ImageProcessor.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/opencv/ImageProcessor.java
index 373f1009a..49f61c7a3 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/opencv/ImageProcessor.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/opencv/ImageProcessor.java
@@ -2,5 +2,14 @@ package com.twine.colorcapture.opencv;
public class ImageProcessor
{
- public native boolean ProcessImage(int width, int height,int correctedWidth,int correctedHeight, byte[] NV21FrameData, int[] pixels,int[] wpixels);
+ public native boolean ProcessImage(int frameWidth,
+ int frameHeight,
+ int sampleWidth,
+ int sampleHeight,
+ int histogramMethod,
+ double similarityTolerance,
+ boolean enableDoubleChecking,
+ byte[] frameData,
+ int[] frameOutPixels,
+ int[] sampleOutPixels);
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/BitmapUtils.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/BitmapUtils.java
new file mode 100644
index 000000000..7f53974b8
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/utils/BitmapUtils.java
@@ -0,0 +1,25 @@
+package com.twine.colorcapture.utils;
+
+import android.graphics.Bitmap;
+import android.util.Base64;
+
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+
+public class BitmapUtils
+{
+ public static byte[] getBitmapBytes(Bitmap bitmap)
+ {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
+ byte[] byteArray = stream.toByteArray();
+ return byteArray;
+ }
+
+ public static String getBitmapBase64String(Bitmap bitmap)
+ {
+ byte[] data = getBitmapBytes(bitmap);
+ String encoded = Base64.encodeToString(data, Base64.DEFAULT);
+ return encoded;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
index b434b9dfb..3f173c530 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
@@ -2,43 +2,61 @@ package com.twine.colorcapture.views.capture;
import android.graphics.Bitmap;
import android.util.Log;
-import android.util.Size;
import com.twine.colorcapture.core.Task.TaskBuilder;
import com.twine.colorcapture.mvvm.ViewModelBase;
+import com.twine.colorcapture.navigation.INavigationProvider;
import com.twine.colorcapture.opencv.ImageProcessor;
import com.twine.colorcapture.views.capture.ICaptureFragment.ICaptureFragmentListener;
+import com.twine.colorcapture.web.ITCCService;
+import com.twine.colorcapture.web.messages.DefinitionResponse;
+import com.twine.colorcapture.web.messages.DetectionResponse;
import com.yanzhenjie.zbar.Image;
import com.yanzhenjie.zbar.ImageScanner;
import com.yanzhenjie.zbar.Symbol;
import com.yanzhenjie.zbar.SymbolSet;
+import java.io.IOException;
+
public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implements ICaptureFragmentListener
{
+
private ImageProcessor processor;
private Bitmap frameBitmap = null;
- private Bitmap correctedBitmap = null;
+ private Bitmap sampleBitmap = null;
private int[] framePixels = null;
- private int[] correctedPixels = null;
+ private int[] samplePixels = null;
private int previewWidth;
private int previewHeight;
private boolean isProcessing;
private byte[] frameData;
private String barcode;
- private Size correctedSize = new Size(300, 330); //The desired cropped rectified bitmap.
-
- public CaptureFragmentVM()
+ private ITCCService tccService;
+ private DefinitionResponse definition;
+ private INavigationProvider navigationProvider;
+
+ public CaptureFragmentVM(ITCCService tccService, INavigationProvider navigationProvider)
{
+ this.navigationProvider = navigationProvider;
+ this.tccService = tccService;
processor = new ImageProcessor();
+
+ try
+ {
+ definition = tccService.getDefinition();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
}
-
+
@Override
protected void onViewAttached(ICaptureFragment view)
{
super.onViewAttached(view);
view.setListener(this);
}
-
+
@SuppressWarnings("SuspiciousNameCombination")
@Override
public void onFrameAvailable(byte[] frame)
@@ -46,60 +64,74 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement
if (!isProcessing)
{
isProcessing = true;
-
+
frameData = frame;
-
+
new TaskBuilder()
.setAction(() ->
{
isProcessing = true;
-
- processor.ProcessImage(
+
+ boolean detected = processor.ProcessImage(
previewWidth,
previewHeight,
- correctedSize.getWidth(),
- correctedSize.getHeight(),
+ definition.getSampleWidth(),
+ definition.getSampleHeight(),
+ definition.getHistogramMethod(),
+ definition.getSimilarityTolerance(),
+ definition.isEnableDoubleChecking(),
frameData,
framePixels,
- correctedPixels);
-
+ samplePixels);
+
frameBitmap.setPixels(framePixels, 0, previewHeight, 0, 0, previewHeight, previewWidth);
- correctedBitmap.setPixels(correctedPixels, 0, correctedSize.getWidth(), 0, 0, correctedSize.getWidth(), correctedSize.getHeight());
-
-
- Log.d("BARCODE", "scanning barcode...");
- ImageScanner scanner = new ImageScanner();
- Image img = new Image(frameBitmap.getWidth(), frameBitmap.getHeight(), "RGB4");
- img.setData(framePixels);
- int result = scanner.scanImage(img.convert("Y800"));
-
- if (result != 0)
+
+ if (detected)
{
- Log.d("BARCODE", "Got positive result...");
-
- String text = null;
-
- SymbolSet symSet = scanner.getResults();
- for (Symbol sym : symSet)
- text = sym.getData();
-
-
- barcode = text;
-
- Log.d("BARCODE", "Barcode text is: " + text);
+ sampleBitmap.setPixels(samplePixels, 0, definition.getSampleWidth(), 0, 0, definition.getSampleWidth(), definition.getSampleHeight());
+
+ Log.d("BARCODE", "scanning barcode...");
+ ImageScanner scanner = new ImageScanner();
+ Image img = new Image(frameBitmap.getWidth(), frameBitmap.getHeight(), "RGB4");
+ img.setData(framePixels);
+ int result = scanner.scanImage(img.convert("Y800"));
+
+ if (result != 0)
+ {
+ Log.d("BARCODE", "Got positive result...");
+
+ String text = null;
+
+ SymbolSet symSet = scanner.getResults();
+ for (Symbol sym : symSet)
+ text = sym.getData();
+
+
+ barcode = text;
+
+ Log.d("BARCODE", "Barcode text is: " + text);
+
+ DetectionResponse response = tccService.detect(sampleBitmap,barcode);
+ DetectionResponse a = response;
+ }
}
-
+
})
.setContinueWith(() ->
{
- view.onFrameResult(frameBitmap, correctedBitmap, barcode);
+ view.onFrameResult(frameBitmap, sampleBitmap, barcode);
+ isProcessing = false;
+ })
+ .setError((ex) ->
+ {
isProcessing = false;
+ ex.printStackTrace();
})
.build()
.start();
}
}
-
+
@SuppressWarnings("SuspiciousNameCombination")
@Override
public void onPreviewSettingsAvailable(int previewWidth, int previewHeight)
@@ -107,8 +139,8 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement
this.previewWidth = previewWidth;
this.previewHeight = previewHeight;
frameBitmap = Bitmap.createBitmap(previewHeight, previewWidth, Bitmap.Config.ARGB_8888);
- correctedBitmap = Bitmap.createBitmap(correctedSize.getWidth(), correctedSize.getHeight(), Bitmap.Config.ARGB_8888);
+ sampleBitmap = Bitmap.createBitmap(definition.getSampleWidth(), definition.getSampleHeight(), Bitmap.Config.ARGB_8888);
framePixels = new int[previewWidth * previewHeight];
- correctedPixels = new int[correctedSize.getWidth() * correctedSize.getHeight()];
+ samplePixels = new int[definition.getSampleWidth() * definition.getSampleHeight()];
}
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
index a7a3affff..8cf9c1ef6 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
@@ -1,9 +1,12 @@
package com.twine.colorcapture.views.loading;
+import android.annotation.SuppressLint;
import android.os.CountDownTimer;
import android.os.Handler;
+import android.util.Log;
import com.squareup.otto.Bus;
+import com.twine.colorcapture.BuildConfig;
import com.twine.colorcapture.core.Task;
import com.twine.colorcapture.mvvm.DependencyProperty;
import com.twine.colorcapture.mvvm.ViewModelBase;
@@ -11,42 +14,63 @@ import com.twine.colorcapture.navigation.INavigationProvider;
import com.twine.colorcapture.navigation.NavigationActivity;
import com.twine.colorcapture.navigation.NavigationFragment;
import com.twine.colorcapture.notification.INotificationProvider;
+import com.twine.colorcapture.web.ITCCService;
+import com.twine.colorcapture.web.IWebServiceAPI;
+import com.twine.colorcapture.web.WebApiFactory;
+import com.twine.colorcapture.web.messages.DefinitionRequest;
+import com.twine.colorcapture.web.messages.DefinitionResponse;
+import com.twine.colorcapture.web.messages.LoginRequest;
+import com.twine.colorcapture.web.messages.LoginResponse;
+
+import java.io.IOException;
import javax.inject.Inject;
+import io.reactivex.disposables.Disposable;
+
public class LoadingActivityVM extends ViewModelBase<ILoadingActivity>
{
private INavigationProvider navigationProvider;
+ private ITCCService tccService;
+ private boolean initialized;
public DependencyProperty<Integer> loadingProgress;
-
+
+
@Inject
- public LoadingActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider)
+ public LoadingActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITCCService tccService)
{
+ this.tccService = tccService;
this.navigationProvider = navigationProvider;
loadingProgress = new DependencyProperty<>(0);
}
-
+
@Override
protected void onViewAttached(ILoadingActivity view)
{
super.onViewAttached(view);
+ init();
+ }
- new Task.TaskBuilder().setAction(() ->
+ private void init()
+ {
+ if (!initialized)
{
- try
+ new Task.TaskBuilder().setAction(() ->
{
- Thread.sleep(5000);
- } catch (InterruptedException e)
+ tccService.getDefinition();
+ }).setContinueWith(() ->
{
- e.printStackTrace();
- }
-
+ initialized = true;
+ navigationProvider.navigateTo(NavigationActivity.Main, true);
- }).setContinueWith(() ->
+ }).setError((ex) ->
+ {
+ new Handler().postDelayed(this::init,5000);
+ }).build().start();
+ }
+ else
{
-
- navigationProvider.navigateTo(NavigationActivity.Main,true);
-
- }).build().start();
+ navigationProvider.navigateTo(NavigationActivity.Main, true);
+ }
}
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java
new file mode 100644
index 000000000..065faf106
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java
@@ -0,0 +1,16 @@
+package com.twine.colorcapture.web;
+
+import android.graphics.Bitmap;
+
+import com.twine.colorcapture.web.messages.DefinitionResponse;
+import com.twine.colorcapture.web.messages.DetectionRequest;
+import com.twine.colorcapture.web.messages.DetectionResponse;
+
+import java.io.IOException;
+
+public interface ITCCService
+{
+ DefinitionResponse getDefinition() throws IOException;
+
+ DetectionResponse detect(Bitmap bitmap, String barcode) throws IOException;
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java
new file mode 100644
index 000000000..6fa84c556
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/IWebServiceAPI.java
@@ -0,0 +1,25 @@
+package com.twine.colorcapture.web;
+
+import com.twine.colorcapture.web.messages.DefinitionRequest;
+import com.twine.colorcapture.web.messages.DefinitionResponse;
+import com.twine.colorcapture.web.messages.DetectionRequest;
+import com.twine.colorcapture.web.messages.DetectionResponse;
+import com.twine.colorcapture.web.messages.LoginRequest;
+import com.twine.colorcapture.web.messages.LoginResponse;
+
+import io.reactivex.Observable;
+import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.POST;
+
+public interface IWebServiceAPI
+{
+ @POST("ColorDetection/Login")
+ Call<LoginResponse> login(@Body LoginRequest request);
+
+ @POST("ColorDetection/GetDefinition")
+ Call<DefinitionResponse> getDefinition(@Body DefinitionRequest request);
+
+ @POST("ColorDetection/Detect")
+ Call<DetectionResponse> detect(@Body DetectionRequest request);
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java
new file mode 100644
index 000000000..98000f3dd
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java
@@ -0,0 +1,76 @@
+package com.twine.colorcapture.web;
+
+import android.graphics.Bitmap;
+import android.util.Base64;
+
+import com.twine.colorcapture.BuildConfig;
+import com.twine.colorcapture.utils.BitmapUtils;
+import com.twine.colorcapture.web.messages.DefinitionRequest;
+import com.twine.colorcapture.web.messages.DefinitionResponse;
+import com.twine.colorcapture.web.messages.DetectionRequest;
+import com.twine.colorcapture.web.messages.DetectionResponse;
+import com.twine.colorcapture.web.messages.LoginRequest;
+import com.twine.colorcapture.web.messages.LoginResponse;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+public class TCCService implements ITCCService
+{
+ private DefinitionResponse definition;
+ private IWebServiceAPI webAPI;
+ private LoginResponse loginResponse;
+
+ @Inject
+ public TCCService(IWebServiceAPI webServiceAPI)
+ {
+ this.webAPI = webServiceAPI;
+ }
+
+ @Override
+ public DefinitionResponse getDefinition() throws IOException
+ {
+ ensureAuthenticated();
+
+ if (definition == null)
+ {
+ definition = webAPI.getDefinition(new DefinitionRequest()).execute().body();
+ }
+
+ return definition;
+ }
+
+ @Override
+ public DetectionResponse detect(Bitmap bitmap, String barcode) throws IOException
+ {
+ ensureAuthenticated();
+
+ DetectionRequest request = new DetectionRequest();
+
+ request.setBitmapString(BitmapUtils.getBitmapBase64String(bitmap));
+ request.setBarcode(barcode);
+
+ DetectionResponse response = webAPI.detect(request).execute().body();
+
+ return response;
+ }
+
+ private void ensureAuthenticated() throws IOException
+ {
+ if (loginResponse == null)
+ {
+ login();
+ }
+ }
+
+ private LoginResponse login() throws IOException
+ {
+ LoginRequest request = new LoginRequest();
+ request.setAppId(BuildConfig.WEB_SERVICE_APP_ID);
+ request.setDeviceId("1234");
+ loginResponse = webAPI.login(request).execute().body();
+ WebApiFactory.setAuthenticationToken(loginResponse.getAccessToken());
+ return loginResponse;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java
new file mode 100644
index 000000000..3aeaccd14
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/WebApiFactory.java
@@ -0,0 +1,101 @@
+package com.twine.colorcapture.web;
+
+import com.google.gson.FieldNamingPolicy;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import retrofit2.Retrofit;
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+
+/**
+ * Represents the system restful api factory.
+ */
+public class WebApiFactory
+{
+ private static String baseUrl;
+ private static String accessToken;
+
+
+ /**
+ * Initializes the remote base url.
+ *
+ * @param base_url the base url
+ */
+ public static void init(String base_url)
+ {
+ baseUrl = base_url;
+ }
+
+ /**
+ * Gets synchronization api.
+ *
+ * @return the synchronization api
+ */
+ public static IWebServiceAPI getWebServiceApi()
+ {
+ return createAPI(IWebServiceAPI.class, 60);
+ }
+
+ /**
+ * Creates the specified API interface instance.
+ * @param cls
+ * @param timeout
+ * @param <T>
+ * @return
+ */
+ private static <T> T createAPI(Class<?> cls, int timeout)
+ {
+ OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
+ httpClient.addInterceptor(new Interceptor() {
+ @Override
+ public Response intercept(Chain chain) throws IOException
+ {
+ Request request;
+
+ if (accessToken != null)
+ {
+ request = chain.request().newBuilder().addHeader("Authorization", accessToken).build();
+ }
+ else
+ {
+ request = chain.request().newBuilder().build();
+ }
+ return chain.proceed(request);
+ }
+ });
+
+ httpClient.readTimeout(timeout, TimeUnit.SECONDS);
+ httpClient.writeTimeout(timeout, TimeUnit.SECONDS);
+
+ Gson gson = new GsonBuilder()
+ .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
+ .setLenient()
+ .setDateFormat("yyyy-MM-dd")
+ .create();
+
+ Retrofit retrofit = new Retrofit.Builder()
+ .baseUrl(baseUrl)
+
+// .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
+ .addConverterFactory(GsonConverterFactory.create(gson))
+ .client(httpClient.build())
+ .build();
+
+ return (T) retrofit.create(cls);
+ }
+
+ public static void setAuthenticationToken(String authenticationToken)
+ {
+ accessToken = authenticationToken;
+ }
+}
+
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionRequest.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionRequest.java
new file mode 100644
index 000000000..2847847b2
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionRequest.java
@@ -0,0 +1,5 @@
+package com.twine.colorcapture.web.messages;
+
+public class DefinitionRequest
+{
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java
new file mode 100644
index 000000000..2dde27e09
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DefinitionResponse.java
@@ -0,0 +1,105 @@
+package com.twine.colorcapture.web.messages;
+
+public class DefinitionResponse
+{
+ private String templateString;
+ private int sampleWidth;
+ private int sampleHeight;
+ private int cameraWidth;
+ private int cameraHeight;
+ private int histogramMethod;
+ private double similarityTolerance;
+ private boolean enableDoubleChecking;
+ private boolean enforceBarcodeDetection;
+
+ public String getTemplateString()
+ {
+ return templateString;
+ }
+
+ public void setTemplateString(String templateString)
+ {
+ this.templateString = templateString;
+ }
+
+ public int getSampleWidth()
+ {
+ return sampleWidth;
+ }
+
+ public void setSampleWidth(int sampleWidth)
+ {
+ this.sampleWidth = sampleWidth;
+ }
+
+ public int getSampleHeight()
+ {
+ return sampleHeight;
+ }
+
+ public void setSampleHeight(int sampleHeight)
+ {
+ this.sampleHeight = sampleHeight;
+ }
+
+ public int getCameraWidth()
+ {
+ return cameraWidth;
+ }
+
+ public void setCameraWidth(int cameraWidth)
+ {
+ this.cameraWidth = cameraWidth;
+ }
+
+ public int getCameraHeight()
+ {
+ return cameraHeight;
+ }
+
+ public void setCameraHeight(int cameraHeight)
+ {
+ this.cameraHeight = cameraHeight;
+ }
+
+ public int getHistogramMethod()
+ {
+ return histogramMethod;
+ }
+
+ public void setHistogramMethod(int histogramMethod)
+ {
+ this.histogramMethod = histogramMethod;
+ }
+
+
+ public double getSimilarityTolerance()
+ {
+ return similarityTolerance;
+ }
+
+ public void setSimilarityTolerance(double similarityTolerance)
+ {
+ this.similarityTolerance = similarityTolerance;
+ }
+
+ public boolean isEnableDoubleChecking()
+ {
+ return enableDoubleChecking;
+ }
+
+ public void setEnableDoubleChecking(boolean enableDoubleChecking)
+ {
+ this.enableDoubleChecking = enableDoubleChecking;
+ }
+
+ public boolean isEnforceBarcodeDetection()
+ {
+ return enforceBarcodeDetection;
+ }
+
+ public void setEnforceBarcodeDetection(boolean enforceBarcodeDetection)
+ {
+ this.enforceBarcodeDetection = enforceBarcodeDetection;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java
new file mode 100644
index 000000000..05e2d2c9f
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionColor.java
@@ -0,0 +1,38 @@
+package com.twine.colorcapture.web.messages;
+
+public class DetectionColor
+{
+ private int r;
+ private int g;
+ private int b;
+
+ public int getR()
+ {
+ return r;
+ }
+
+ public void setR(int r)
+ {
+ this.r = r;
+ }
+
+ public int getG()
+ {
+ return g;
+ }
+
+ public void setG(int g)
+ {
+ this.g = g;
+ }
+
+ public int getB()
+ {
+ return b;
+ }
+
+ public void setB(int b)
+ {
+ this.b = b;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionRequest.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionRequest.java
new file mode 100644
index 000000000..5686a6947
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionRequest.java
@@ -0,0 +1,27 @@
+package com.twine.colorcapture.web.messages;
+
+public class DetectionRequest
+{
+ private String bitmapString;
+ private String barcode;
+
+ public String getBitmapString()
+ {
+ return bitmapString;
+ }
+
+ public void setBitmapString(String bitmapString)
+ {
+ this.bitmapString = bitmapString;
+ }
+
+ public String getBarcode()
+ {
+ return barcode;
+ }
+
+ public void setBarcode(String barcode)
+ {
+ this.barcode = barcode;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java
new file mode 100644
index 000000000..2e33a04b5
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java
@@ -0,0 +1,27 @@
+package com.twine.colorcapture.web.messages;
+
+public class DetectionResponse
+{
+ private DetectionColor rawColor;
+ private DetectionColor processedColor;
+
+ public DetectionColor getRawColor()
+ {
+ return rawColor;
+ }
+
+ public void setRawColor(DetectionColor rawColor)
+ {
+ this.rawColor = rawColor;
+ }
+
+ public DetectionColor getProcessedColor()
+ {
+ return processedColor;
+ }
+
+ public void setProcessedColor(DetectionColor processedColor)
+ {
+ this.processedColor = processedColor;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginRequest.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginRequest.java
new file mode 100644
index 000000000..c49dcafe8
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginRequest.java
@@ -0,0 +1,49 @@
+package com.twine.colorcapture.web.messages;
+
+public class LoginRequest
+{
+ private String appId;
+ private String device;
+ private String deviceId;
+ private String osVersion;
+
+ public String getAppId()
+ {
+ return appId;
+ }
+
+ public void setAppId(String appId)
+ {
+ this.appId = appId;
+ }
+
+ public String getDevice()
+ {
+ return device;
+ }
+
+ public void setDevice(String device)
+ {
+ this.device = device;
+ }
+
+ public String getDeviceId()
+ {
+ return deviceId;
+ }
+
+ public void setDeviceId(String deviceId)
+ {
+ this.deviceId = deviceId;
+ }
+
+ public String getOsVersion()
+ {
+ return osVersion;
+ }
+
+ public void setOsVersion(String osVersion)
+ {
+ this.osVersion = osVersion;
+ }
+}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginResponse.java
new file mode 100644
index 000000000..4c719f32e
--- /dev/null
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/LoginResponse.java
@@ -0,0 +1,16 @@
+package com.twine.colorcapture.web.messages;
+
+public class LoginResponse
+{
+ private String accessToken;
+
+ public String getAccessToken()
+ {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken)
+ {
+ this.accessToken = accessToken;
+ }
+}